moc freezes after song change

Hi,
time to time my moc freezes when I want to play another song. After I hit enter, moc comletely freezes.
This was happening on 2.5.0~alpha3-3ubuntu1 version. So I tried to compile stable 2.4.4, but nothing changed and error still remains. Below are some infos that will hopefully help. Don't know if it's issue only for my ubuntu, or my architecture..

thanks
Lukas


[ ~ ] $ uname -a
Linux delphinus 2.6.27-11-generic #1 SMP Thu Jan 29 19:24:39 UTC 2009 i686 GNU/Linux

I configured mocp like this:

[ moc-2.4.4 ] $ ./configure --enable-debug --prefix=/home/delfin/local
...

MOC will be compiled with:
Decoder plugins: mp3 vorbis flac
OSS: yes
ALSA: yes
JACK: yes
DEBUG: yes
RCC: no
Network streams: yes
Resampling: no

After mocp freezed:

[ ~ ] $ ps -fp $(pgrep moc)
UID PID PPID C STIME TTY STAT TIME CMD
delfin 9568 31482 0 00:00 pts/0 S+ 0:35 mocp --debug
delfin 9569 9568 0 00:00 ? SLsl 5:31 mocp --debug
[ ~ ] $ strace -p 9568
Process 9568 attached - interrupt to quit
recv(3,


[ ~ ] $ strace -p 9569
Process 9569 attached - interrupt to quit
futex(0xb672ebd8, FUTEX_WAIT, 11226, NULL


[ ~ ] $ gdb $(which mocp) 9568
GNU gdb 6.8-debian
...
(gdb) bt
#0 0xb804f430 in __kernel_vsyscall ()
#1 0xb7f30401 in recv () from /lib/tls/i686/cmov/libpthread.so.0
#2 0x08052c49 in get_int (sock=3, i=0xbff4f274)
at /usr/include/bits/socket2.h:45
#3 0x0805c95a in get_int_from_srv () at interface.c:164
#4 0x0805c97c in wait_for_data () at interface.c:260
#5 0x0805ca3b in get_data_int () at interface.c:270
#6 0x0805e2bb in update_mixer_value () at interface.c:427
#7 0x08062a15 in interface_loop () at interface.c:3260
#8 0x080561ef in main (argc=2, argv=0xbff4f6e4) at main.c:190


[ ~ ] $ gdb $(which mocp) 9569
GNU gdb 6.8-debian
...
(gdb) bt
#0 0xb804f430 in __kernel_vsyscall ()
#1 0xb7f29bf7 in pthread_join () from /lib/tls/i686/cmov/libpthread.so.0
#2 0x0805ac34 in audio_stop () at audio.c:476
#3 0x0805af2f in audio_play (
fname=0x9684368 "/media/usb-disk/music/albums/Pink Floyd/Pink Floyd - (1987) A Momentary Lapse of Reason (192)/Pink Floyd 01 - Signs Of Life.mp3")
at audio.c:500
#4 0x08053d41 in handle_command (client_id=)
at server.c:493
#5 0x08054f75 in server_loop (list_sock=8) at server.c:1187
#6 0x08056441 in main (argc=2, argv=0xbff4f6e4) at main.c:157


[ ~ ] $ tail mocp_client_log
Mar 27 19:02:03.42508: interface.c:951 server_event(): EVENT: 0x11
Mar 27 19:02:03.42552: interface.c:610 ev_file_tags(): Received tags for /media/usb-disk/music/albums/Pink Floyd/Pink Floyd - (1987) A Momentary Lapse of Reason (192)/Pink Floyd 09 - A New Machine - Part 2.mp3
Mar 27 19:02:03.44961: interface.c:951 server_event(): EVENT: 0x11
Mar 27 19:02:03.44998: interface.c:610 ev_file_tags(): Received tags for /media/usb-disk/music/albums/Pink Floyd/Pink Floyd - (1987) A Momentary Lapse of Reason (192)/Pink Floyd 10 - Sorrow.mp3
Mar 27 19:02:03.47402: interface.c:3203 dequeue_events(): done
Mar 27 19:02:03.360113: interface.c:3196 dequeue_events(): Dequeuing events...
Mar 27 19:02:03.360155: interface.c:3203 dequeue_events(): done
Mar 27 19:02:03.757922: interface.c:3196 dequeue_events(): Dequeuing events...
Mar 27 19:02:03.757978: interface.c:3203 dequeue_events(): done
Mar 27 19:02:03.838859: interface.c:1562 play_it(): The server has different playlist


[ ~ ] $ tail mocp_server_log
Mar 27 19:02:03.845554: player.c:203 bitrate_list_get(): Getting bitrate for time 2 (192)
Mar 27 19:02:03.845582: server.c:251 wake_up_server(): Waking up the server
Mar 27 19:02:03.845626: out_buf.c:315 out_buf_stop(): done
Mar 27 19:02:03.845657: server.c:251 wake_up_server(): Waking up the server
Mar 27 19:02:03.845687: io.c:273 io_close(): Closing stream...
Mar 27 19:02:03.845713: io.c:281 io_close(): Waiting for io_read_thread()...
Mar 27 19:02:03.845739: io.c:283 io_close(): IO read thread exited
Mar 27 19:02:03.845957: io.c:328 io_close(): done
Mar 27 19:02:03.845990: player.c:133 bitrate_list_empty(): Bitrate list elements removed.
Mar 27 19:02:03.846018: out_buf.c:399 out_buf_wait(): Waiting for read thread to suspend...

Thanks for your extensive investigation!

I suspected there are race conditions in this code because I sometimes got noise after pausing. Please try the following patch:

<br /> Index: out_buf.c<br /> ===================================================================<br /> --- out_buf.c (revision 2148)<br /> +++ out_buf.c (working copy)<br /> @@ -83,11 +83,6 @@<br /> if (buf-&gt;stop)<br /> fifo_buf_clear (&amp;buf-&gt;buf);</p> <p>- if (fifo_buf_get_fill(&amp;buf-&gt;buf) == 0) {<br /> - debug ("Setting read_thread_waiting flag");<br /> - buf-&gt;read_thread_waiting = 1;<br /> - }<br /> -<br /> if (buf-&gt;free_callback) {</p> <p> /* unlock the mutex to make calls to out_buf functions<br /> @@ -110,6 +105,7 @@<br /> }</p> <p> debug ("waiting for someting in the buffer");<br /> + buf-&gt;read_thread_waiting = 1;<br /> pthread_cond_wait (&amp;buf-&gt;play_cond, &amp;buf-&gt;mutex);<br /> debug ("someting appeard in the buffer");<br />

Thats great, It seems that this patch solved my problem. Thanks for your quick reply ;-)

Lukas

I've been having the same problem. I will check this out when I get home!

I am very glad to see that some development is still happening to this nice player. =)

Is this patch now incorporated into the stable version of moc?

When using a USB-audio class external DAC for audio output via OSS the bug is always triggered on song change, making moc unusable without this patch..

No, it's only in SVN version.