fix a possible dead lock in the fonera-mp3 driver, that can happen, when the buffer...
authorJohn Crispin <john@openwrt.org>
Tue, 11 Sep 2007 16:53:53 +0000 (16:53 +0000)
committerJohn Crispin <john@openwrt.org>
Tue, 11 Sep 2007 16:53:53 +0000 (16:53 +0000)
SVN-Revision: 8753

package/fonera-mp3-drv/src/mp3_drv.c

index 9609444181bf71815eea6aad89a745122c3e676e..a2d8c79ae64a330152d604376e8b04a7ab43c481 100644 (file)
@@ -101,11 +101,12 @@ static DECLARE_COMPLETION(mp3_exit);
 static int mp3_playback_thread(void *data){
        int j;
        unsigned long timeout;
+       unsigned char empty = 0;
        printk("started kthread\n");
        daemonize("kmp3");
        while(mp3_buffering_status != MP3_PLAY_FINISHED){
                if((mp3_buffering_status == MP3_PLAYING) || (mp3_buffering_status == MP3_BUFFER_FINISHED)){
-                       while(VS1011_NEEDS_DATA){
+                       while((VS1011_NEEDS_DATA) && (!empty)){
                                if(mp3_buffer_offset_read == MP3_BUFFER_SIZE){
                                        mp3_buffer_offset_read = 0;
                                }
@@ -115,6 +116,7 @@ static int mp3_playback_thread(void *data){
                                                printk("mp3_drv.ko : finished playing\n");
                                                mp3_buffering_status = MP3_PLAY_FINISHED;
                                        } else {
+                                               empty = 1;
                                                printk("mp3_drv.ko : buffer empty ?\n");
                                                if(mp3_buffering_status != MP3_PLAY_FINISHED){
                                                }
@@ -128,8 +130,9 @@ static int mp3_playback_thread(void *data){
                                }
                        }
                }
+               empty = 0;
                timeout = 1;    
-               timeout = wait_event_interruptible_timeout(wq, (timeout==0), timeout);  
+               timeout = wait_event_interruptible_timeout(wq, (timeout==0), timeout);  
        }
        complete_and_exit(&mp3_exit, 0); 
 }