changeset 1032:aa0559a5fee1 trunk

[svn] - hackhackhack workaround for the fact that joins will fail at times, inspired by the hackhack in WMA
author nenolod
date Fri, 12 May 2006 14:12:17 -0700
parents c9e641ff4a28
children e69e900eca1e
files Plugins/Input/aac/src/libmp4.c
diffstat 1 files changed, 31 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Plugins/Input/aac/src/libmp4.c	Fri May 12 14:03:50 2006 -0700
+++ b/Plugins/Input/aac/src/libmp4.c	Fri May 12 14:12:17 2006 -0700
@@ -78,6 +78,7 @@
 
 void     audmp4_file_info_box(gchar *);
 gboolean buffer_playing;
+gint	 doExit;
 
 InputPlugin mp4_ip =
   {
@@ -172,6 +173,7 @@
 static void mp4_play(char *filename)
 {
   buffer_playing = TRUE;
+  doExit = 0;
   decodeThread = g_thread_create((GThreadFunc)mp4Decode, g_strdup(filename), TRUE, NULL);
   return;
 }
@@ -182,6 +184,17 @@
     buffer_playing = FALSE;
     mp4_ip.output->close_audio();
   }
+
+  /*
+   * The problem is, we can't just go try to reap the thread, it probably
+   * won't work. This hint gives us points where the thread can just quit.
+   * Which basically serves the same function...
+   *
+   *       - nenolod
+   */
+  g_static_mutex_lock(&mutex);
+  doExit = 1;
+  g_static_mutex_unlock(&mutex);
 }
 
 static int	mp4_IsOurFile(char *filename)
@@ -420,9 +433,21 @@
 				/* Finish playing before we close the
 				   output. */
 				while ( mp4_ip.output->buffer_playing() ) {
+					if (doExit)
+					{
+						doExit = 0;
+						g_thread_exit(NULL);
+					}
+
 					xmms_usleep(10000);
 				}
 
+				if (doExit)
+				{
+					doExit = 0;
+					g_thread_exit(NULL);
+				}
+
 				mp4_ip.output->flush(seekPosition*1000);
 				mp4_ip.output->close_audio();
 				faacDecClose(decoder);
@@ -452,6 +477,12 @@
 				return FALSE;
 			}
 
+			if (doExit)
+			{
+				doExit = 0;
+				g_thread_exit(NULL);
+			}
+
 			sampleBuffer= faacDecDecode(decoder, 
 						    &frameInfo, 
 						    buffer,