Subject: Audacious plugin freeze in pause mode

From: Joker
Date: Sat May 13 03:19:49 2006

To: UADE-Developer-discussion
While i fixed some issue on my DUMB plugin for Audacious i've noticed
that the UADE plugin has the same issue.

When being in pause state, any action such as [] (stop) &gt;&gt; (next)
or even |&gt; (play) freezes the whole player.

Thats because produce_audio waits/locks while being in pause mode
and the stop/next/prev actions execute the stop function.
&quot;stop&quot; usualy contains a pthread_join() which joins the thread which
is currently hanging at produce_audio(). That means freeze.

The freeze at produce_audio() is new. I think XMMS and early audacious
didn't freeze while pause but simply buffered the output in the background.

The workaround for this is sending a pause(0) when the player is in pause
mode and stop gets executed.

What i did is the following in stop():
...
if(duh_ispaused) duh_pause(0);
g_thread_join(decode_thread);
...

and the pause() function has this added:
...
duh_ispaused = p;
duh_ip.output-&gt;pause(duh_ispaused);
...

I know this is ugly, but the WMA plugin Audacious ships itself
has the same workaround. If you already keep track of pause
state for some reason you can use that variable.

---

From: Joker
Date: Sat May 13 03:34:15 2006

Another minor thing: 

Audacious has GCC poisoned the old xmms cfg file functions.

The UADE plugin does not use any of those functions but still
includes the .h file.

Removing the following include line which doesn't seem to be
used in the plugin fixes this:

#include &lt;audacious/configfile.h&gt;

(songinfo.c and fileinfo.c i think)

This is only for the Audacious SVN version but the soon to be
released 1.1 version will also have it and it's trivial to fix.

---

From: Joker
Date: Sat May 13 03:35:50 2006

To: UADE-Developer-discussion
Erm wrong, it's those files:

./fileinfo.c:#include &lt;audacious/configfile.h&gt;
./subsongseek.c:#include &lt;audacious/configfile.h&gt;

---

From: Joker
Date: Sun May 14 13:39:53 2006

To: UADE-Developer-discussion
I think i have a &quot;cleaner&quot; way than doing an unpause event while
being paused and getting a stop trigger. It's not only ugly but you
also hear a tiny bit of the remaining buffer when hitting stop.

The produce_audio &quot;hanging&quot; can be avoided by looping inside the
plugin based on the buffer (right before produce_audio).

For example:
while ((uade_ip.output-&gt;buffer_free() &lt; play_bytes) &amp;&amp; abort_playing == 0) xmms_usleep(10000);                                               

Right after that something like:
if (abort_playing == 1) song_end_trigger = 1;
else produce_audio.....foobar

It's just a concept ... i'm no programmer. For the DUMB plugin i could
do a simple &quot;if (!duh_file-&gt;going) break;&quot; for the 2nd part but the
UADE plugin is a bit different and you'd hit the assert(left == 0); that way.

---

From: Joker
Date: Wed May 17 01:58:40 2006

To: UADE-Developer-discussion
There's a fix now in Audacious which handles stop while being in pause.
So no workaround is needed anymore.

Removal of &quot;#include &lt;audacious/configfile.h&gt;&quot; would still help as
the Plugin really doesn't use any of those poisened functions anyway.

---

From: Guest
Date: Wed May 17 06:56:01 2006

To: UADE-Developer-discussion
fixed. Thanks for the report :-)