diff -Nur audacious-plugins-fedora-2.1-orig/src/musepack/libmpc.cxx audacious-plugins-fedora-2.1-musepack/src/musepack/libmpc.cxx --- audacious-plugins-fedora-2.1-orig/src/musepack/libmpc.cxx 2009-07-07 00:40:36.000000000 +0200 +++ audacious-plugins-fedora-2.1-musepack/src/musepack/libmpc.cxx 2009-11-30 11:49:47.000000000 +0100 @@ -48,8 +48,7 @@ static MpcDecoder mpcDecoder = {0}; static TrackInfo track = {0}; -static GThread *threadHandle; -static GStaticMutex threadMutex = G_STATIC_MUTEX_INIT; +/* static GStaticMutex threadMutex = G_STATIC_MUTEX_INIT; */ /* * VFS callback implementation, adapted from mpc_reader.c. @@ -301,24 +300,16 @@ mpcDecoder.isAlive = true; mpcDecoder.isOutput = false; mpcDecoder.isPause = false; - threadHandle = g_thread_self(); - data->set_pb_ready(data); decodeStream(data); + data->playing = FALSE; } static void mpcStop(InputPlayback *data) { + data->playing = FALSE; + mpcDecoder.isPause = false; + mpcDecoder.offset = -1; setAlive(false); - if (threadHandle) - { - g_thread_join(threadHandle); - if (mpcDecoder.isOutput) - { - data->output->buffer_free(); - data->output->close_audio(); - mpcDecoder.isOutput = false; - } - } } static void mpcPause(InputPlayback *data, short p_Pause) @@ -823,7 +814,9 @@ lockRelease(); gint counter = 2 * track.sampleFreq / 3; - while (isAlive()) + data->playing = TRUE; + data->set_pb_ready(data); + while (isAlive() && data->playing) { if (getOffset() != -1) { @@ -832,18 +825,19 @@ } lockAcquire(); - short iPlaying = data->output->buffer_playing()? 1 : 0; - gint iFree = data->output->buffer_free(); - if (!mpcDecoder.isPause && iFree >= ((1152 * 4) << iPlaying)) + if (!mpcDecoder.isPause) { - unsigned status = processBuffer(data, sampleBuffer, xmmsBuffer, decoder); - if (status == (unsigned) (-1)) + guint status = processBuffer(data, sampleBuffer, xmmsBuffer, decoder); + if (status == (guint)(-1)) { mpcDecoder.isError = g_strdup_printf("[xmms-musepack] error from internal decoder on %s", filename); - return endThread(filename, input, true); + break; + } + if (status == 0) { + data->eof = TRUE; + data->playing = FALSE; + break; } - if (status == 0 && iPlaying == 0) - return endThread(filename, input, true); lockRelease(); @@ -863,16 +857,22 @@ g_usleep(10000); } } + data->output->buffer_free(); + data->output->close_audio(); + mpcDecoder.isOutput = false; return endThread(filename, input, false); } -static int processBuffer(InputPlayback *playback, +static guint processBuffer(InputPlayback *playback, MPC_SAMPLE_FORMAT* sampleBuffer, char* xmmsBuffer, mpc_decoder& decoder) { mpc_uint32_t vbrAcc = 0; mpc_uint32_t vbrUpd = 0; - unsigned status = mpc_decoder_decode(&decoder, sampleBuffer, &vbrAcc, &vbrUpd); + guint status = mpc_decoder_decode(&decoder, sampleBuffer, &vbrAcc, &vbrUpd); + if (status == (guint)(-1)) { + return status; + } copyBuffer(sampleBuffer, xmmsBuffer, status); if (pluginConfig.dynamicBitrate) @@ -911,12 +911,12 @@ inline static void lockAcquire() { - g_static_mutex_lock(&threadMutex); + /* g_static_mutex_lock(&threadMutex); */ } inline static void lockRelease() { - g_static_mutex_unlock(&threadMutex); + /* g_static_mutex_unlock(&threadMutex); */ } inline static bool isAlive() diff -Nur audacious-plugins-fedora-2.1-orig/src/musepack/libmpc.h audacious-plugins-fedora-2.1-musepack/src/musepack/libmpc.h --- audacious-plugins-fedora-2.1-orig/src/musepack/libmpc.h 2009-07-07 00:40:36.000000000 +0200 +++ audacious-plugins-fedora-2.1-musepack/src/musepack/libmpc.h 2009-11-17 22:43:37.323774131 +0100 @@ -123,7 +123,7 @@ static void lockAcquire(); static void lockRelease(); static void* decodeStream(InputPlayback*); -static int processBuffer(InputPlayback*, MPC_SAMPLE_FORMAT*, char*, mpc_decoder&); +static guint processBuffer(InputPlayback*, MPC_SAMPLE_FORMAT*, char*, mpc_decoder&); //static void* endThread(char*, FILE*, bool); static bool isAlive(); static void setAlive(bool);