Blob Blame History Raw
diff -Nur audacious-plugins-fedora-1.5.1-orig/src/musepack/libmpc.cxx audacious-plugins-fedora-1.5.1-musepack/src/musepack/libmpc.cxx
--- audacious-plugins-fedora-1.5.1-orig/src/musepack/libmpc.cxx	2008-06-08 10:37:44.000000000 +0200
+++ audacious-plugins-fedora-1.5.1-musepack/src/musepack/libmpc.cxx	2009-11-17 22:36:54.888775246 +0100
@@ -52,8 +52,7 @@
 static MpcDecoder   mpcDecoder   = {0};
 static TrackInfo    track        = {0};
 
-static GThread            *threadHandle;
-GStaticMutex threadMutex = G_STATIC_MUTEX_INIT;
+/* GStaticMutex threadMutex = G_STATIC_MUTEX_INIT; */
 
 /*
  * VFS callback implementation, adapted from mpc_reader.c.
@@ -305,24 +304,19 @@
     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)
 {
     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)
@@ -827,7 +821,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)
         {
@@ -836,18 +832,19 @@
         }
 
         lockAcquire();
-        short iPlaying = MpcPlugin.output->buffer_playing()? 1 : 0;
-        gint iFree = MpcPlugin.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);
             }
-            if (status == 0 && iPlaying == 0)
+            if (status == 0) {
+                data->eof = TRUE;
+                data->playing = FALSE;
                 return endThread(filename, input, true);
+            }
 
             lockRelease();
 
@@ -870,13 +867,16 @@
     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)
@@ -915,12 +915,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-1.5.1-orig/src/musepack/libmpc.h audacious-plugins-fedora-1.5.1-musepack/src/musepack/libmpc.h
--- audacious-plugins-fedora-1.5.1-orig/src/musepack/libmpc.h	2008-06-08 10:37:44.000000000 +0200
+++ audacious-plugins-fedora-1.5.1-musepack/src/musepack/libmpc.h	2009-11-17 12:42:28.035927069 +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);