changeset 1408:a7db4a8a7b54

merge
author Cristi Magherusan <majeru@atheme-project.org>
date Sun, 05 Aug 2007 00:27:51 +0300
parents 776dd8fc2b38 (current diff) 90d4c120fbca (diff)
children 32aaec642cf8
files
diffstat 6 files changed, 56 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/flacng/flacng.h	Sun Aug 05 00:26:21 2007 +0300
+++ b/src/flacng/flacng.h	Sun Aug 05 00:27:51 2007 +0300
@@ -79,6 +79,7 @@
 
 
 typedef struct callback_info {
+    GMutex* mutex;
     gint32* output_buffer;
     gint32* write_pointer;
     guint buffer_free;
--- a/src/flacng/plugin.c	Sun Aug 05 00:26:21 2007 +0300
+++ b/src/flacng/plugin.c	Sun Aug 05 00:27:51 2007 +0300
@@ -180,8 +180,11 @@
 
     _DEBUG("Testing fd for file: %s", filename);
 
+    INFO_LOCK(test_info);
+
     if (FALSE == read_metadata(fd, test_decoder, test_info)) {
         _DEBUG("File not handled by this plugin!");
+        INFO_UNLOCK(test_info);
         _LEAVE FALSE;
     }
 
@@ -190,6 +193,7 @@
      */
     if (FALSE == test_info->metadata_changed) {
         _DEBUG("No metadata found in stream");
+        INFO_UNLOCK(test_info);
         _LEAVE FALSE;
     }
 
@@ -207,6 +211,7 @@
     if (MAX_SUPPORTED_CHANNELS < test_info->stream.channels) {
         _ERROR("This number of channels (%d) is currently not supported, stream not handled by this plugin",
             test_info->stream.channels);
+        INFO_UNLOCK(test_info);
         _LEAVE FALSE;
     }
 
@@ -215,6 +220,7 @@
         (8 != test_info->stream.bits_per_sample)) {
         _ERROR("This number of bits (%d) is currently not supported, stream not handled by this plugin",
             test_info->stream.bits_per_sample);
+        INFO_UNLOCK(test_info);
         _LEAVE FALSE;
     }
 
@@ -225,6 +231,7 @@
     _DEBUG("Accepting file %s", filename);
 
     reset_info(test_info, FALSE);
+    INFO_UNLOCK(test_info);
 
     _LEAVE TRUE;
 }
@@ -647,11 +654,14 @@
         _LEAVE;
     }
 
+    INFO_LOCK(test_info);
+
     if (FALSE == read_metadata(fd, test_decoder, test_info)) {
         _ERROR("Could not read file info!");
         *length = -1;
         *title = g_strdup("");
         reset_info(test_info, TRUE);
+        INFO_UNLOCK(test_info);
         _LEAVE;
     }
 
@@ -670,6 +680,7 @@
     *title = get_title(filename, test_info);
 
     reset_info(test_info, TRUE);
+    INFO_UNLOCK(test_info);
 
     _LEAVE;
 }
@@ -692,15 +703,19 @@
         _LEAVE NULL;
     }
 
+    INFO_LOCK(test_info);
+
     if (FALSE == read_metadata(fd, test_decoder, test_info)) {
         _ERROR("Could not read metadata tuple for file <%s>", filename);
         reset_info(test_info, TRUE);
+        INFO_UNLOCK(test_info);
         _LEAVE NULL;
     }
 
     tuple = get_tuple(filename, test_info);
 
     reset_info(test_info, TRUE);
+    INFO_UNLOCK(test_info);
 
     _LEAVE tuple;
 }
--- a/src/flacng/tools.c	Sun Aug 05 00:26:21 2007 +0300
+++ b/src/flacng/tools.c	Sun Aug 05 00:27:51 2007 +0300
@@ -66,6 +66,8 @@
     info->replaygain.album_peak = NULL;
     reset_info(info, FALSE);
 
+    info->mutex = g_mutex_new();
+
     _DEBUG("Playback buffer allocated for %d samples, %d bytes", BUFFER_SIZE_SAMP, BUFFER_SIZE_BYTE);
 
     _LEAVE info;
--- a/src/flacng/tools.h	Sun Aug 05 00:26:21 2007 +0300
+++ b/src/flacng/tools.h	Sun Aug 05 00:27:51 2007 +0300
@@ -23,6 +23,21 @@
 #include <FLAC/all.h>
 #include "flacng.h"
 #include "flac_compat.h"
+#include "debug.h"
+
+#define INFO_LOCK(__info) \
+    do { \
+        _DEBUG("Trying to lock info %s", (__info)->name); \
+        g_mutex_lock((__info)->mutex); \
+        _DEBUG("Locked info %s", (__info)->name); \
+    } while(0)
+
+#define INFO_UNLOCK(__info) \
+    do { \
+        _DEBUG("Unlocking info %s", (__info)->name); \
+        g_mutex_unlock((__info)->mutex); \
+        _DEBUG("Unlocked info %s", (__info)->name); \
+    } while(0)
 
 callback_info* init_callback_info(gchar* name);
 void reset_info(callback_info* info, gboolean close_fd);
--- a/src/vtx/vtx.c	Sun Aug 05 00:26:21 2007 +0300
+++ b/src/vtx/vtx.c	Sun Aug 05 00:27:51 2007 +0300
@@ -22,6 +22,7 @@
 #include <audacious/output.h>
 #include <audacious/util.h>
 #include <audacious/titlestring.h>
+#include <audacious/configdb.h>
 #include <audacious/vfs.h>
 #include <audacious/strings.h>
 #include <audacious/i18n.h>
@@ -56,6 +57,19 @@
 
 static gchar *vtx_fmts[] = { "vtx", NULL };
 
+void
+vtx_init(void)
+{
+        ConfigDb *db;
+        db = bmp_cfg_db_open();
+
+        bmp_cfg_db_get_int(db, NULL, "src_rate", &freq);
+        if (freq < 4000 || freq > 192000)
+                freq = 44100;
+
+        bmp_cfg_db_close(db);
+}
+
 int
 vtx_is_our_fd (char *filename, VFSFile *fp)
 {
@@ -169,6 +183,9 @@
 	{
 	  playback->output->buffer_free ();
 	  playback->output->buffer_free ();
+	  while (playback->output->buffer_playing())
+	    g_usleep(10000);
+	  playback->playing = 0;
 	}
     
       /* jump to time in seek_to (in seconds) */
@@ -179,10 +196,7 @@
 	  seek_to = -1;
 	}
     }
-
-  /* close sound and release vtx file must be done in vtx_stop() */
-  g_thread_exit (NULL);
-
+  ayemu_vtx_free (&vtx);
   return NULL;
 }
 
@@ -229,7 +243,8 @@
       bmp_title_input_free(ti);
 
       playback->playing = TRUE;
-      play_thread = g_thread_create (play_loop, playback, TRUE, NULL);
+      play_thread = g_thread_self();
+      play_loop(playback);
     }
 }
 
@@ -292,8 +307,8 @@
 InputPlugin vtx_ip = {
 	NULL,			/* FILLED BY XMMS */
 	NULL,			/* FILLED BY XMMS */
-	"VTX Audio Plugin",		/* Plugin description */
-	NULL,			/* Initialization */
+	"VTX Audio Plugin",	/* Plugin description */
+	vtx_init,		/* Initialization */
 	vtx_about,		/* Show aboutbox */
 	vtx_config,		/* Show/edit configuration */
 	vtx_is_our_file,	/* Check file, return 1 if the plugin can handle this file */
--- a/src/vtx/vtx.h	Sun Aug 05 00:26:21 2007 +0300
+++ b/src/vtx/vtx.h	Sun Aug 05 00:27:51 2007 +0300
@@ -13,6 +13,7 @@
 
 #include "audacious/plugin.h"
 
+void vtx_init(void);
 void vtx_about(void);
 void vtx_config(void);
 void vtx_file_info(char *filename);