GNOME Bugzilla – Bug 748055
avfvideosrc: get connection and input clock early
Last modified: 2015-06-12 15:51:00 UTC
Created attachment 301840 [details] [review] avfvideosrc: get connection and input clock early Slight refactoring. Will also be useful as a base for exposing any other properties that are controlled through the connection, e.g. orientation and mirroring.
commit a02a948a5dbdda949f2aa818981eb2fc96e03b76 Author: Ilya Konstantinov <ilya.konstantinov@gmail.com> Date: Fri Apr 17 05:12:10 2015 +0300 avfvideosrc: get connection and input clock early
Created attachment 305157 [details] [review] avfvideosrc: set sample buffer delegate last Oops, the previous patch would cause this sporadic error: (<unknown>:1161): GStreamer-CRITICAL **: _gst_util_uint64_scale: assertion 'denom != 0' failed occurring in: now = CMClockGetTime(inputClock); // <-- inputClock == nil // ^ now == 0 input_clock_now = gst_util_uint64_scale (GST_SECOND, now.value, now.timescale); // <-- critical error The problem is caused by: [output setSampleBufferDelegate:self queue:workerQueue]; [session addOutput:output]; ... // ERROR: At this point, inputClock == nil // and the delegate can be called already inputClock = ((AVCaptureInputPort *)connection.inputPorts[0]).clock; The solution is simple -- postpone setting sample buffer delegate to the end.
Actually, I take it back -- this issue doesn't affect avfvideosrc as-is. It affects my avfvideosrc because it has another (not yet submitted) patch which allows setting an external session (i.e. a session shared with the user's app). In this case, the (externally-set) session is already running, so the delegate will be called as soon as: [output setSampleBufferDelegate:self queue:workerQueue]; [session addOutput:output]; is performed, triggering the above problem.