BradLarson/GPUImage — pull request #1168 by karlvr (2013-09-07 03:24:03+00:00)
Title: GPUImageMovieWriter: synchronise finishRecording with the movieWritingQueue

As the AVAssetWriter gets started on the movieWritingQueue, so we need to check its state on that queue.

Also need to set isRecording = NO before checking AVAssetWriter state, otherwise in a race condition where frames haven't started arriving and the AVAssetWriter hasn't started writing, we wouldn't stop recording.

Also ensure that the handler is called async, otherwise it is called on the movieWritingQueue, which is dispatch_sync from the video processing queue, so if the user-code in the handler calls anything that dispatch_syncs to the video processing queue: deadlock.