@@ -176,29 +176,30 @@ struct audio_export * audio_export_init(const char *filename)
176176
177177void audio_export_destroy (struct audio_export * s )
178178{
179- if (s ) {
180- if (s -> thread_id ) {
181- pthread_mutex_lock (& s -> lock );
182- s -> should_exit_worker = true;
183- s -> new_work_ready = true;
184- if (s -> worker_waiting ) {
185- pthread_cond_signal (& s -> worker_cv );
186- }
187- pthread_mutex_unlock (& s -> lock );
188- pthread_join (s -> thread_id , NULL );
179+ if (s == NULL ) {
180+ return ;
181+ }
182+ if (s -> thread_id ) {
183+ pthread_mutex_lock (& s -> lock );
184+ s -> should_exit_worker = true;
185+ s -> new_work_ready = true;
186+ if (s -> worker_waiting ) {
187+ pthread_cond_signal (& s -> worker_cv );
189188 }
189+ pthread_mutex_unlock (& s -> lock );
190+ pthread_join (s -> thread_id , NULL );
191+ }
190192
191- if (s -> wav != NULL ) {
192- wav_writer_close (s -> wav );
193- }
194- if (s -> ring != NULL ) {
195- ring_buffer_destroy (s -> ring );
196- }
197- pthread_cond_destroy (& s -> worker_cv );
198- pthread_mutex_destroy (& s -> lock );
199- free (s -> filename );
200- free (s );
193+ if (s -> wav != NULL ) {
194+ wav_writer_close (s -> wav );
195+ }
196+ if (s -> ring != NULL ) {
197+ ring_buffer_destroy (s -> ring );
201198 }
199+ pthread_cond_destroy (& s -> worker_cv );
200+ pthread_mutex_destroy (& s -> lock );
201+ free (s -> filename );
202+ free (s );
202203}
203204
204205void audio_export_raw (struct audio_export * s , void * data , unsigned len ){
0 commit comments