Commit e4317c11 authored by Mikhail Karpenko's avatar Mikhail Karpenko
Browse files

Wait for writer to finish last frame before stopping

parent 54bbff55
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -365,6 +365,9 @@ int camogm_end_jpeg(camogm_state *state)
	if (state->rawdev_op) {
		// write any remaining data, do not use writer thread as there can be only one block left CHUNK_REM buffer
		pthread_mutex_lock(&state->writer_params.writer_mutex);
		while (state->writer_params.data_ready)
			// wait for previous frame to be recorded first if it has not be recorded by the moment
			pthread_cond_wait(&state->writer_params.main_cond, &state->writer_params.writer_mutex);
		bytes = prep_last_block(state);
		if (bytes > 0) {
			D6(fprintf(debug_file, "Write last block of data, size = %d\n", bytes));