Index: apps/playback.c =================================================================== RCS file: /cvsroot/rockbox/apps/playback.c,v retrieving revision 1.396 diff -u -r1.396 playback.c --- apps/playback.c 18 Nov 2006 02:18:22 -0000 1.396 +++ apps/playback.c 18 Nov 2006 10:45:45 -0000 @@ -3205,11 +3205,21 @@ { ci.stop_codec = true; pcmbuf_pause(true); + + /* Make sure codec doesn't deadlock if waiting on the callback queue */ + LOGFQUEUE("audio > codec Q_CODEC_REQUEST_COMPLETE"); + queue_post(&codec_callback_queue, Q_CODEC_REQUEST_COMPLETE, NULL); + while (audio_codec_loaded) yield(); + + /* Remove message in case codec was not dequeueing at the time */ + queue_remove_from_head(&codec_callback_queue, Q_CODEC_REQUEST_COMPLETE); + /* If the audio codec is not loaded any more, and the audio is still * playing, it is now and _only_ now safe to call this function from the * audio thread */ + if (pcm_is_playing()) pcmbuf_play_stop(); pcmbuf_pause(paused);