1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-14 07:33:03 +01:00

Refactoring to compliment OSX

This commit is contained in:
cnhenry 2015-08-16 02:20:16 -05:00
parent 619fdc1098
commit e91aaf6c73
3 changed files with 23 additions and 11 deletions

View File

@ -186,7 +186,7 @@ void read_device_callback(const int16_t* captured, uint32_t size, void* data)
void write_device_callback(uint32_t friend_number, const int16_t* PCM, uint16_t size)
{
if (friend_number >= 0 && CallControl.calls[friend_number].ttas)
if ( CallControl.calls[friend_number].ttas )
write_out(CallControl.calls[friend_number].out_idx, PCM, size, CallControl.audio_channels);
}

View File

@ -294,10 +294,10 @@ void cmd_list_video_devices(WINDOW *window, ToxWindow *self, Tox *m, int argc, c
VideoDeviceType type;
if ( strcasecmp(argv[1], "in") == 0 ) /* Input devices */
type = input;
type = vdt_input;
else if ( strcasecmp(argv[1], "out") == 0 ) /* Output devices */
type = output;
type = vdt_output;
else {
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Invalid type: %s", argv[1]);
@ -327,10 +327,10 @@ void cmd_change_video_device(WINDOW *window, ToxWindow *self, Tox *m, int argc,
VideoDeviceType type;
if ( strcmp(argv[1], "in") == 0 ) /* Input devices */
type = input;
type = vdt_input;
else if ( strcmp(argv[1], "out") == 0 ) /* Output devices */
type = output;
type = vdt_output;
else {
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Invalid type: %s", argv[1]);
@ -371,10 +371,10 @@ void cmd_ccur_video_device(WINDOW *window, ToxWindow *self, Tox *m, int argc, ch
VideoDeviceType type;
if ( strcmp(argv[1], "in") == 0 ) /* Input devices */
type = input;
type = vdt_input;
else if ( strcmp(argv[1], "out") == 0 ) /* Output devices */
type = output;
type = vdt_output;
else {
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Invalid type: %s", argv[1]);
@ -404,8 +404,8 @@ void cmd_ccur_video_device(WINDOW *window, ToxWindow *self, Tox *m, int argc, ch
}
else {
/* TODO: check for failure */
close_video_device(input, this_call->vin_idx);
open_video_device(input, selection, &this_call->vin_idx);
close_video_device(vdt_input, this_call->vin_idx);
open_video_device(vdt_input, selection, &this_call->vin_idx);
register_video_device_callback(self->num, this_call->vin_idx, read_video_device_callback, &self->num);
}
}

View File

@ -65,9 +65,12 @@ typedef struct VideoDevice {
void* cb_data; /* Data to be passed to callback */
int32_t friend_number; /* ToxAV friend number */
#ifdef __linux__
struct v4l2_format fmt;
struct VideoBuffer *buffers;
uint32_t n_buffers;
uint32_t n_buffers;
#else /* __OSX__ */
#endif
uint32_t ref_count;
int32_t selection;
@ -660,10 +663,13 @@ void* video_thread_poll (void* arg) // TODO: maybe use thread for every input so
XFlush(device->x_display);
free(img_data);
#ifdef __linux__
if ( -1 == xioctl(device->fd, VIDIOC_QBUF, &buf) ) {
unlock;
continue;
}
#else /* __OSX__ */
#endif
}
unlock;
}
@ -692,7 +698,7 @@ VideoDeviceError close_video_device(VideoDeviceType type, uint32_t device_idx)
if ( !device->ref_count ) {
if ( type == vdt_input ) {
#ifdef __linux__
enum v4l2_buf_type buf_type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if( -1 == xioctl(device->fd, VIDIOC_STREAMOFF, &buf_type) ) {}
@ -701,12 +707,18 @@ VideoDeviceError close_video_device(VideoDeviceType type, uint32_t device_idx)
if ( -1 == munmap(device->buffers[i].start, device->buffers[i].length) ) {
}
}
#else /* __OSX__ */
#endif
close(device->fd);
XDestroyWindow(device->x_display, device->x_window);
XFlush(device->x_display);
XCloseDisplay(device->x_display);
pthread_mutex_destroy(device->mutex);
#ifdef __linux__
free(device->buffers);
#else /* __OSX__ */
#endif
free(device);
} else {
vpx_img_free(&device->input);