Commit 7303425a authored by Pierre-Eric Pelloux-Prayer's avatar Pierre-Eric Pelloux-Prayer
Browse files

video: defer orientation update to next video_call_update call

Otherwise a race condition may occur:
   set_device_orientation(); // THREAD A
   run_graphs();             // THREAD B <- crash on iOS
   video_call_update();      // THREAD A

Crash explaination: run_graph called after orientation changed ->
webcam output resolution has changed but before graph reconfiguration
-> webcam output res mismatch encoder input : will try to use rescaler
which isn't available
parent 6b75ac7c
......@@ -530,6 +530,19 @@ void video_stream_change_camera(VideoStream *stream, MSWebCam *cam){
/*re create new ones and configure them*/
if (!keep_source) stream->source = ms_web_cam_create_reader(cam);
stream->cam=cam;
/* update orientation */
if (stream->source){
ms_filter_call_method(stream->source,MS_VIDEO_CAPTURE_SET_DEVICE_ORIENTATION,&stream->device_orientation);
/* */
if (!stream->display_filter_auto_rotate_enabled)
ms_filter_call_method(stream->source,MS_VIDEO_DISPLAY_SET_DEVICE_ORIENTATION,&stream->device_orientation);
}
if (stream->output && stream->display_filter_auto_rotate_enabled) {
ms_filter_call_method(stream->output,MS_VIDEO_DISPLAY_SET_DEVICE_ORIENTATION,&stream->device_orientation);
}
configure_video_source(stream);
ms_filter_link (stream->source, 0, stream->pixconv, 0);
......@@ -648,17 +661,6 @@ void video_stream_set_device_rotation(VideoStream *stream, int orientation){
MSFilter* target_filter;
stream->device_orientation = orientation;
target_filter=stream->source;
if (target_filter){
ms_filter_call_method(target_filter,MS_VIDEO_CAPTURE_SET_DEVICE_ORIENTATION,&orientation);
// The below code may look weird so I'll add a bit of documentation
if (!stream->display_filter_auto_rotate_enabled)
ms_filter_call_method(target_filter,MS_VIDEO_DISPLAY_SET_DEVICE_ORIENTATION,&orientation);
}
if (stream->output && stream->display_filter_auto_rotate_enabled) {
ms_filter_call_method(stream->output,MS_VIDEO_DISPLAY_SET_DEVICE_ORIENTATION,&orientation);
}
}
VideoPreview * video_preview_new(void){
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment