changeset 1254:5cdda0e144ab

branch merge
author William Pitcock <nenolod@atheme-project.org>
date Fri, 13 Jul 2007 04:59:36 -0500
parents 9d802f0a55af (current diff) 551f76613eb2 (diff)
children 84b837791e36 e1df1bad7837
files
diffstat 29 files changed, 354 insertions(+), 307 deletions(-) [+]
line wrap: on
line diff
--- a/configure.ac	Fri Jul 13 04:50:42 2007 -0500
+++ b/configure.ac	Fri Jul 13 04:59:36 2007 -0500
@@ -217,7 +217,7 @@
 		PICFLAGS="-fPIC -DPIC"
 		PICLDFLAGS="-fPIC -DPIC -shared"
 		LIBLDFLAGS="-fPIC -DPIC -shared"
-		AUDLDFLAGS="-Wl,-export-dynamic -Wl,-rpath=\${libdir}"
+		AUDLDFLAGS="-Wl,-export-dynamic -Wl,-rpath=\${libdir},-rpath=\${plugindir}"
 		SHARED_SUFFIX=".so"
 		;;
 esac
--- a/src/OSS4/OSS4.c	Fri Jul 13 04:50:42 2007 -0500
+++ b/src/OSS4/OSS4.c	Fri Jul 13 04:59:36 2007 -0500
@@ -24,6 +24,7 @@
 #include <glib.h>
 #include <audacious/i18n.h>
 #include <stdlib.h>
+#include <audacious/configdb.h>
 
 OutputPlugin oss_op = {
     NULL,
@@ -53,13 +54,14 @@
 
 void oss_cleanup(void)
 {
+    ConfigDb *db;
+    db = bmp_cfg_db_open();
+    bmp_cfg_db_set_int(db, "OSS", "saved_volume", vol);
+    bmp_cfg_db_close(db);
+
     if (oss_cfg.alt_audio_device) {
         free(oss_cfg.alt_audio_device);
         oss_cfg.alt_audio_device = NULL;
     }
-
-    if (oss_cfg.alt_mixer_device) {
-        free(oss_cfg.alt_mixer_device);
-        oss_cfg.alt_mixer_device = NULL;
-    }
+   
 }
--- a/src/OSS4/OSS4.h	Fri Jul 13 04:50:42 2007 -0500
+++ b/src/OSS4/OSS4.h	Fri Jul 13 04:59:36 2007 -0500
@@ -41,16 +41,15 @@
 
 typedef struct {
     gint audio_device;
-    gint mixer_device;
     gint buffer_size;
     gint prebuffer;
-    gboolean use_master,use_vmix;
-    gboolean use_alt_audio_device, use_alt_mixer_device;
-    gchar *alt_audio_device, *alt_mixer_device;
+    gboolean save_volume;
+    gboolean use_alt_audio_device;
+    gchar *alt_audio_device;
 } OSSConfig;
 
 extern OSSConfig oss_cfg;
-
+int vol;
 void oss_init(void);
 void oss_cleanup(void);
 void oss_about(void);
--- a/src/OSS4/about.c	Fri Jul 13 04:50:42 2007 -0500
+++ b/src/OSS4/about.c	Fri Jul 13 04:59:36 2007 -0500
@@ -39,8 +39,10 @@
     if (dialog != NULL)
         return;
 
-    dialog = xmms_show_message(_("About OSS Driver"),
-                               _("Audacious OSS4 Driver\n\n "
+    dialog = xmms_show_message(_("About OSSv4 Driver"),
+                               _("Audacious OSSv4 Driver\n\n"
+                                 "Based on the OSSv3 Output plugin,\n" 
+                                 "Ported to OSSv4's VMIX by Cristi Magherusan <majeru@gentoo.ro>\n\n"
                                  "This program is free software; you can redistribute it and/or modify\n"
                                  "it under the terms of the GNU General Public License as published by\n"
                                  "the Free Software Foundation; either version 2 of the License, or\n"
--- a/src/OSS4/audio.c	Fri Jul 13 04:50:42 2007 -0500
+++ b/src/OSS4/audio.c	Fri Jul 13 04:59:36 2007 -0500
@@ -739,7 +739,8 @@
 {
     int v;
     long cmd=SNDCTL_DSP_GETPLAYVOL;
-    ioctl(fd, cmd, &v);
+    if(ioctl(fd, cmd, &v) == -1)
+        v=vol;
     *r = (v & 0xFF00) >> 8;
     *l = (v & 0x00FF);
 }
@@ -747,11 +748,9 @@
 void
 oss_set_volume(int l, int r)
 {   
-    if(l!=r)
-        l=r=((l>r) ? l : r);
     long cmd=SNDCTL_DSP_SETPLAYVOL;   
-    int v = (r << 8) | l;
-    ioctl(fd, cmd, &v);
+    vol = (r << 8) | l;
+    ioctl(fd, cmd, &vol);
 }
 
 void
--- a/src/OSS4/configure.c	Fri Jul 13 04:50:42 2007 -0500
+++ b/src/OSS4/configure.c	Fri Jul 13 04:59:36 2007 -0500
@@ -32,10 +32,9 @@
 
 
 static GtkWidget *configure_win = NULL;
-static GtkWidget *mixer_usemaster_check, *buffer_size_spin, *buffer_pre_spin;
+static GtkWidget *mixer_save_check,*buffer_size_spin, *buffer_pre_spin;
 static GtkWidget *adevice_use_alt_check, *audio_alt_device_entry;
-static GtkWidget *mdevice_use_alt_check, *mixer_alt_device_entry;
-static gint audio_device, mixer_device;
+static gint audio_device;
 
 static void
 configure_win_ok_cb(GtkWidget * w, gpointer data)
@@ -43,52 +42,37 @@
     ConfigDb *db;
 
     oss_cfg.audio_device = audio_device;
-    oss_cfg.mixer_device = mixer_device;
     oss_cfg.buffer_size =
         gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(buffer_size_spin));
     oss_cfg.prebuffer =
         gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(buffer_pre_spin));
-    oss_cfg.use_master =
+    oss_cfg.save_volume =
         gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
-                                     (mixer_usemaster_check));
+                                     (mixer_save_check));
+
     oss_cfg.use_alt_audio_device =
         gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
                                      (adevice_use_alt_check));
-    oss_cfg.use_alt_mixer_device =
-        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
-                                     (mdevice_use_alt_check));
     g_free(oss_cfg.alt_audio_device);
     oss_cfg.alt_audio_device =
         gtk_editable_get_chars(GTK_EDITABLE(audio_alt_device_entry), 0, -1);
     g_strstrip(oss_cfg.alt_audio_device);
-    g_free(oss_cfg.alt_mixer_device);
-    oss_cfg.alt_mixer_device =
-        gtk_editable_get_chars(GTK_EDITABLE(mixer_alt_device_entry), 0, -1);
-    g_strstrip(oss_cfg.alt_mixer_device);
-
+    
     if (oss_cfg.use_alt_audio_device)
         /* do a minimum of sanity checking */
         if (oss_cfg.alt_audio_device[0] != '/')
             oss_cfg.use_alt_audio_device = FALSE;
-    if (oss_cfg.use_alt_mixer_device)
-        if (oss_cfg.alt_mixer_device[0] != '/')
-            oss_cfg.use_alt_mixer_device = FALSE;
-
+    
     db = bmp_cfg_db_open();
 
     bmp_cfg_db_set_int(db, "OSS", "audio_device", oss_cfg.audio_device);
-    bmp_cfg_db_set_int(db, "OSS", "mixer_device", oss_cfg.mixer_device);
     bmp_cfg_db_set_int(db, "OSS", "buffer_size", oss_cfg.buffer_size);
     bmp_cfg_db_set_int(db, "OSS", "prebuffer", oss_cfg.prebuffer);
-    bmp_cfg_db_set_bool(db, "OSS", "use_master", oss_cfg.use_master);
+    bmp_cfg_db_set_bool(db, "OSS", "save_volume", oss_cfg.save_volume);
     bmp_cfg_db_set_bool(db, "OSS", "use_alt_audio_device",
                         oss_cfg.use_alt_audio_device);
     bmp_cfg_db_set_string(db, "OSS", "alt_audio_device",
                           oss_cfg.alt_audio_device);
-    bmp_cfg_db_set_bool(db, "OSS", "use_alt_mixer_device",
-                        oss_cfg.use_alt_mixer_device);
-    bmp_cfg_db_set_string(db, "OSS", "alt_mixer_device",
-                          oss_cfg.alt_mixer_device);
     bmp_cfg_db_close(db);
 }
 
@@ -99,12 +83,6 @@
 }
 
 static void
-configure_win_mixer_dev_cb(GtkWidget * widget, gint device)
-{
-    mixer_device = device;
-}
-
-static void
 audio_device_toggled(GtkToggleButton * widget, gpointer data)
 {
     gboolean use_alt_audio_device = gtk_toggle_button_get_active(widget);
@@ -113,14 +91,6 @@
 }
 
 static void
-mixer_device_toggled(GtkToggleButton * widget, gpointer data)
-{
-    gboolean use_alt_device = gtk_toggle_button_get_active(widget);
-    gtk_widget_set_sensitive(GTK_WIDGET(data), !use_alt_device);
-    gtk_widget_set_sensitive(mixer_alt_device_entry, use_alt_device);
-}
-
-static void
 scan_devices(gchar * type, GtkWidget * option_menu, GtkSignalFunc sigfunc)
 {
     GtkWidget *menu, *item;
@@ -184,7 +154,7 @@
     GtkWidget *buffer_size_box, *buffer_size_label;
     GtkObject *buffer_size_adj, *buffer_pre_adj;
     GtkWidget *buffer_pre_box, *buffer_pre_label;
-    GtkWidget *audio_alt_box, *mixer_alt_box;
+    GtkWidget *audio_alt_box;
     GtkWidget *bbox, *ok, *cancel;
     GtkWidget *mixer_table, *mixer_frame;
 
@@ -255,48 +225,7 @@
         gtk_widget_set_sensitive(adevice, FALSE);
     else
         gtk_widget_set_sensitive(audio_alt_device_entry, FALSE);
-
-    mdevice_frame = gtk_frame_new(_("Mixer device:"));
-    gtk_box_pack_start(GTK_BOX(dev_vbox), mdevice_frame, FALSE, FALSE, 0);
-
-    mdevice_box = gtk_vbox_new(FALSE, 0);
-    gtk_container_set_border_width(GTK_CONTAINER(mdevice_box), 5);
-    gtk_container_add(GTK_CONTAINER(mdevice_frame), mdevice_box);
-
-    mdevice = gtk_option_menu_new();
-    gtk_box_pack_start(GTK_BOX(mdevice_box), mdevice, TRUE, TRUE, 0);
-#if defined(HAVE_NEWPCM)
-    scan_devices("Installed devices:", mdevice, configure_win_mixer_dev_cb);
-#else
-    scan_devices("Mixers:", mdevice, G_CALLBACK(configure_win_mixer_dev_cb));
-#endif
-    mixer_device = oss_cfg.mixer_device;
-    gtk_option_menu_set_history(GTK_OPTION_MENU(mdevice),
-                                oss_cfg.mixer_device);
-    mixer_alt_box = gtk_hbox_new(FALSE, 0);
-    gtk_box_pack_start_defaults(GTK_BOX(mdevice_box), mixer_alt_box);
-    mdevice_use_alt_check =
-        gtk_check_button_new_with_label(_("Use alternate device:"));
-    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mdevice_use_alt_check),
-                                 oss_cfg.use_alt_mixer_device);
-    g_signal_connect(G_OBJECT(mdevice_use_alt_check), "toggled",
-                     G_CALLBACK(mixer_device_toggled), mdevice);
-    gtk_box_pack_start(GTK_BOX(mixer_alt_box), mdevice_use_alt_check,
-                       FALSE, FALSE, 0);
-    mixer_alt_device_entry = gtk_entry_new();
-    if (oss_cfg.alt_mixer_device != NULL)
-        gtk_entry_set_text(GTK_ENTRY(mixer_alt_device_entry),
-                           oss_cfg.alt_mixer_device);
-    else
-        gtk_entry_set_text(GTK_ENTRY(mixer_alt_device_entry), DEV_MIXER);
-    gtk_box_pack_start_defaults(GTK_BOX(mixer_alt_box),
-                                mixer_alt_device_entry);
-
-    if (oss_cfg.use_alt_mixer_device)
-        gtk_widget_set_sensitive(mdevice, FALSE);
-    else
-        gtk_widget_set_sensitive(mixer_alt_device_entry, FALSE);
-
+   
     gtk_notebook_append_page(GTK_NOTEBOOK(notebook), dev_vbox,
                              gtk_label_new(_("Devices")));
 
@@ -339,17 +268,18 @@
 
     gtk_notebook_append_page(GTK_NOTEBOOK(notebook), buffer_frame,
                              gtk_label_new(_("Buffering")));
+    
     mixer_frame = gtk_frame_new(_("Mixer Settings:"));
     gtk_container_set_border_width(GTK_CONTAINER(mixer_frame), 5);
-    mixer_table = gtk_table_new(3, 2, TRUE);
+    mixer_table = gtk_table_new(1, 1, TRUE);
     gtk_container_add(GTK_CONTAINER(mixer_frame), mixer_table);
     gtk_container_set_border_width(GTK_CONTAINER(mixer_table), 5);
-    mixer_usemaster_check =
-        gtk_check_button_new_with_label(_("Volume controls Master not PCM"));
-    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mixer_usemaster_check),
-                                 oss_cfg.use_master);
+    mixer_save_check =
+        gtk_check_button_new_with_label(_("Save VMIX volume between sessions"));
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mixer_save_check),
+                                 oss_cfg.save_volume);
     gtk_table_attach_defaults(GTK_TABLE(mixer_table),
-                              mixer_usemaster_check, 0, 1, 0, 1);
+                              mixer_save_check, 0, 1, 0, 1);
     gtk_notebook_append_page(GTK_NOTEBOOK(notebook), mixer_frame,
                              gtk_label_new(_("Mixer")));
 
--- a/src/OSS4/init.c	Fri Jul 13 04:50:42 2007 -0500
+++ b/src/OSS4/init.c	Fri Jul 13 04:59:36 2007 -0500
@@ -35,27 +35,26 @@
     memset(&oss_cfg, 0, sizeof(OSSConfig));
 
     oss_cfg.audio_device = 0;
-    oss_cfg.mixer_device = 0;
     oss_cfg.buffer_size = 3000;
     oss_cfg.prebuffer = 25;
     oss_cfg.use_alt_audio_device = FALSE;
     oss_cfg.alt_audio_device = NULL;
-    oss_cfg.use_master = 0;
 
     if ((db = bmp_cfg_db_open())) {
         bmp_cfg_db_get_int(db, "OSS", "audio_device", &oss_cfg.audio_device);
-        bmp_cfg_db_get_int(db, "OSS", "mixer_device", &oss_cfg.mixer_device);
         bmp_cfg_db_get_int(db, "OSS", "buffer_size", &oss_cfg.buffer_size);
         bmp_cfg_db_get_int(db, "OSS", "prebuffer", &oss_cfg.prebuffer);
-        bmp_cfg_db_get_bool(db, "OSS", "use_master", &oss_cfg.use_master);
+        bmp_cfg_db_get_bool(db, "OSS", "save_volume", &oss_cfg.save_volume);
         bmp_cfg_db_get_bool(db, "OSS", "use_alt_audio_device",
                             &oss_cfg.use_alt_audio_device);
         bmp_cfg_db_get_string(db, "OSS", "alt_audio_device",
                               &oss_cfg.alt_audio_device);
-        bmp_cfg_db_get_bool(db, "OSS", "use_alt_mixer_device",
-                            &oss_cfg.use_alt_mixer_device);
-        bmp_cfg_db_get_string(db, "OSS", "alt_mixer_device",
-                              &oss_cfg.alt_mixer_device);
+        bmp_cfg_db_get_int(db, "OSS", "saved_volume", &vol);
         bmp_cfg_db_close(db);
     }
+        //volume gets saved anyway, but is ignored unless "saved_volume" is true
+        if(!oss_cfg.save_volume)
+            vol=0x6464;  //maximum
+           
+
 }
--- a/src/aosd/aosd_trigger.c	Fri Jul 13 04:50:42 2007 -0500
+++ b/src/aosd/aosd_trigger.c	Fri Jul 13 04:59:36 2007 -0500
@@ -26,6 +26,7 @@
 #include <audacious/playlist.h>
 #include <audacious/strings.h>
 #include <audacious/hook.h>
+#include <audacious/auddrct.h>
 
 
 extern aosd_cfg_t * global_config;
@@ -36,18 +37,22 @@
 {
   AOSD_TRIGGER_PB_START = 0,
   AOSD_TRIGGER_PB_TITLECHANGE = 1,
-  AOSD_TRIGGER_VOL_CHANGE = 2
+  AOSD_TRIGGER_VOL_CHANGE = 2,
+  AOSD_TRIGGER_PB_PAUSEON = 3,
+  AOSD_TRIGGER_PB_PAUSEOFF = 4
 };
 
 /* trigger codes array size */
-#define AOSD_TRIGGER_CODES_ARRAY_SIZE 3
+#define AOSD_TRIGGER_CODES_ARRAY_SIZE 5
 
 /* trigger codes array */
 gint aosd_trigger_codes[] =
 {
   AOSD_TRIGGER_PB_START,
   AOSD_TRIGGER_PB_TITLECHANGE,
-  AOSD_TRIGGER_VOL_CHANGE
+  AOSD_TRIGGER_VOL_CHANGE,
+  AOSD_TRIGGER_PB_PAUSEON,
+  AOSD_TRIGGER_PB_PAUSEOFF
 };
 
 /* prototypes of trigger functions */
@@ -57,6 +62,10 @@
 static void aosd_trigger_func_pb_titlechange_cb ( gpointer , gpointer );
 static void aosd_trigger_func_vol_change_onoff ( gboolean );
 static void aosd_trigger_func_vol_change_cb ( gpointer , gpointer );
+static void aosd_trigger_func_pb_pauseon_onoff ( gboolean );
+static void aosd_trigger_func_pb_pauseon_cb ( gpointer , gpointer );
+static void aosd_trigger_func_pb_pauseoff_onoff ( gboolean );
+static void aosd_trigger_func_pb_pauseoff_cb ( gpointer , gpointer );
 
 /* map trigger codes to trigger objects */
 aosd_trigger_t aosd_triggers[] =
@@ -76,7 +85,17 @@
   [AOSD_TRIGGER_VOL_CHANGE] = { N_("Volume Change") ,
                                 N_("Triggers OSD when volume is changed.") ,
                                 aosd_trigger_func_vol_change_onoff ,
-                                aosd_trigger_func_vol_change_cb }
+                                aosd_trigger_func_vol_change_cb },
+
+  [AOSD_TRIGGER_PB_PAUSEON] = { N_("Pause On") ,
+                                N_("Triggers OSD when playback is paused.") ,
+                                aosd_trigger_func_pb_pauseon_onoff ,
+                                aosd_trigger_func_pb_pauseon_cb },
+
+  [AOSD_TRIGGER_PB_PAUSEOFF] = { N_("Pause Off") ,
+                                 N_("Triggers OSD when playback is unpaused.") ,
+                                 aosd_trigger_func_pb_pauseoff_onoff ,
+                                 aosd_trigger_func_pb_pauseoff_cb }
 };
 
 
@@ -162,7 +181,7 @@
   PlaylistEntry *pl_entry = plentry_gp;
   if ( plentry_gp != NULL )
   {
-    gchar *title;
+    gchar *title, *utf8_title;
     if ( pl_entry->title != NULL )
     {
       /* if there is a proper title, use it */
@@ -175,7 +194,7 @@
       gint pos = playlist_get_position(active);
       title = playlist_get_songtitle(active, pos);
     }
-    gchar *utf8_title = aosd_trigger_utf8convert( title );
+    utf8_title = aosd_trigger_utf8convert( title );
     if ( g_utf8_validate( utf8_title , -1 , NULL ) == TRUE )
     {
       gchar *utf8_title_markup = g_markup_printf_escaped(
@@ -333,3 +352,63 @@
   }
   return;
 }
+
+
+static void
+aosd_trigger_func_pb_pauseon_onoff ( gboolean turn_on )
+{
+  if ( turn_on == TRUE )
+    hook_associate( "playback pause" , aosd_trigger_func_pb_pauseon_cb , NULL );
+  else
+    hook_dissociate( "playback pause" , aosd_trigger_func_pb_pauseon_cb );
+  return;
+}
+
+static void
+aosd_trigger_func_pb_pauseon_cb ( gpointer unused1 , gpointer unused2 )
+{
+  gchar *utf8_title_markup = g_markup_printf_escaped(
+    "<span font_desc='%s'>Paused</span>" , global_config->osd->text.fonts_name[0] );
+  aosd_osd_display( utf8_title_markup , global_config->osd , FALSE );
+  g_free( utf8_title_markup );
+  return;
+}
+
+
+static void
+aosd_trigger_func_pb_pauseoff_onoff ( gboolean turn_on )
+{
+  if ( turn_on == TRUE )
+    hook_associate( "playback unpause" , aosd_trigger_func_pb_pauseoff_cb , NULL );
+  else
+    hook_dissociate( "playback unpause" , aosd_trigger_func_pb_pauseoff_cb );
+  return;
+}
+
+static void
+aosd_trigger_func_pb_pauseoff_cb ( gpointer unused1 , gpointer unused2 )
+{
+  Playlist *active = playlist_get_active();
+  gint pos = playlist_get_position(active);
+  gchar *title, *utf8_title, *utf8_title_markup;
+  gint time_cur, time_tot;
+  gint time_cur_m, time_cur_s, time_tot_m, time_tot_s;
+
+  time_tot = playlist_get_songtime(active, pos) / 1000;
+  time_cur = audacious_drct_get_time() / 1000;
+  time_cur_s = time_cur % 60;
+  time_cur_m = (time_cur - time_cur_s) / 60;
+  time_tot_s = time_tot % 60;
+  time_tot_m = (time_tot - time_tot_s) / 60;
+
+  title = playlist_get_songtitle(active, pos);
+  utf8_title = aosd_trigger_utf8convert( title );
+  utf8_title_markup = g_markup_printf_escaped(
+    "<span font_desc='%s'>%s (%i:%02i/%i:%02i)</span>" ,
+    global_config->osd->text.fonts_name[0] , utf8_title , time_cur_m , time_cur_s , time_tot_m , time_tot_s );
+  aosd_osd_display( utf8_title_markup , global_config->osd , FALSE );
+  g_free( utf8_title_markup );
+  g_free( utf8_title );
+  g_free( title );
+  return;
+}
--- a/src/cue/cuesheet.c	Fri Jul 13 04:50:42 2007 -0500
+++ b/src/cue/cuesheet.c	Fri Jul 13 04:59:36 2007 -0500
@@ -447,7 +447,7 @@
 	cur_cue_track = track;
 	cache_cue_file(path2);
 
-    if (cue_file == NULL || !g_file_test(cue_file, G_FILE_TEST_EXISTS))
+    if (cue_file == NULL || !vfs_file_test(cue_file, G_FILE_TEST_EXISTS))
         return;
 
 	real_ip_plugin = input_check_file(cue_file, FALSE);
--- a/src/flacng/Makefile	Fri Jul 13 04:50:42 2007 -0500
+++ b/src/flacng/Makefile	Fri Jul 13 04:59:36 2007 -0500
@@ -7,7 +7,7 @@
 
 LIBADD = $(GTK_LIBS) $(GLIB_LIBS) $(PANGO_LIBS) $(FLAC_LIBS)
 
-SOURCES = plugin.c tools.c seekable_stream_callbacks.c
+SOURCES = plugin.c tools.c seekable_stream_callbacks.c flac_compat112.c
 
 OBJECTS = ${SOURCES:.c=.o}
 
--- a/src/flacng/debug.h	Fri Jul 13 04:50:42 2007 -0500
+++ b/src/flacng/debug.h	Fri Jul 13 04:59:36 2007 -0500
@@ -19,6 +19,8 @@
 #ifndef DEBUG_H
 #define DEBUG_H
 
+#include <stdio.h>
+
 #define _ENTER _DEBUG("enter")
 #define _LEAVE _DEBUG("leave"); return
 #define _MESSAGE(tag, string, ...) do { fprintf(stderr, "%s: libflacng.so: %s:%d (%s): " string "\n", \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/flacng/flac_compat.h	Fri Jul 13 04:59:36 2007 -0500
@@ -0,0 +1,3 @@
+#include "flac_compat112.h"
+#include "flac_compat113.h"
+#include "flac_compat114.h"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/flacng/flac_compat112.c	Fri Jul 13 04:59:36 2007 -0500
@@ -0,0 +1,57 @@
+/*
+ *  A FLAC decoder plugin for the Audacious Media Player
+ *  Copyright (C) 2005 Ralf Ertzinger
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <FLAC/all.h>
+#include "flac_compat112.h"
+#include "debug.h"
+
+#if !defined(FLAC_API_VERSION_CURRENT)
+
+FLAC__SeekableStreamDecoderState FLAC__stream_decoder_init_stream(
+        FLAC__SeekableStreamDecoder*  decoder,
+        FLAC__SeekableStreamDecoderReadCallback read_callback,
+        FLAC__SeekableStreamDecoderSeekCallback     seek_callback,
+        FLAC__SeekableStreamDecoderTellCallback     tell_callback,
+        FLAC__SeekableStreamDecoderLengthCallback   length_callback,
+        FLAC__SeekableStreamDecoderEofCallback      eof_callback,
+        FLAC__SeekableStreamDecoderWriteCallback    write_callback,
+        FLAC__SeekableStreamDecoderMetadataCallback     metadata_callback,
+        FLAC__SeekableStreamDecoderErrorCallback    error_callback,
+        void *      client_data) {
+
+        FLAC__SeekableStreamDecoderState ret;
+
+        _ENTER;
+
+        FLAC__seekable_stream_decoder_set_read_callback(decoder, read_callback);
+        FLAC__seekable_stream_decoder_set_seek_callback(decoder, seek_callback);
+        FLAC__seekable_stream_decoder_set_tell_callback(decoder, tell_callback);
+        FLAC__seekable_stream_decoder_set_length_callback(decoder, length_callback);
+        FLAC__seekable_stream_decoder_set_eof_callback(decoder, eof_callback);
+        FLAC__seekable_stream_decoder_set_write_callback(decoder, write_callback);
+        FLAC__seekable_stream_decoder_set_metadata_callback(decoder, metadata_callback);
+        FLAC__seekable_stream_decoder_set_error_callback(decoder, error_callback);
+        FLAC__seekable_stream_decoder_set_client_data(decoder, client_data);
+
+        ret = FLAC__seekable_stream_decoder_init(decoder);
+
+        _LEAVE ret;
+}
+
+#endif
--- a/src/flacng/flac_compat112.h	Fri Jul 13 04:50:42 2007 -0500
+++ b/src/flacng/flac_compat112.h	Fri Jul 13 04:59:36 2007 -0500
@@ -3,22 +3,38 @@
 
 #if !defined(FLAC_API_VERSION_CURRENT)
 
+/* Basic stream decoder type */
 #define FLAC__StreamDecoder FLAC__SeekableStreamDecoder
 
+/* Stream decoder functions */
 #define FLAC__StreamDecoderReadStatus FLAC__SeekableStreamDecoderReadStatus 
 #define FLAC__StreamDecoderSeekStatus FLAC__SeekableStreamDecoderSeekStatus
 #define FLAC__StreamDecoderTellStatus FLAC__SeekableStreamDecoderTellStatus
 #define FLAC__StreamDecoderLengthStatus FLAC__SeekableStreamDecoderLengthStatus
 #define FLAC__stream_decoder_new FLAC__seekable_stream_decoder_new
+#define FLAC__stream_decoder_set_metadata_respond FLAC__seekable_stream_decoder_set_metadata_respond
+#define FLAC__stream_decoder_process_single FLAC__seekable_stream_decoder_process_single
+#define FLAC__stream_decoder_seek_absolute FLAC__seekable_stream_decoder_seek_absolute
+#define FLAC__stream_decoder_get_state FLAC__seekable_stream_decoder_get_state
+#define FLAC__stream_decoder_flush FLAC__seekable_stream_decoder_flush
+#define FLAC__stream_decoder_reset FLAC__seekable_stream_decoder_reset
+#define FLAC__stream_decoder_process_until_end_of_metadata FLAC__seekable_stream_decoder_process_until_end_of_metadata
+#define FLAC__StreamDecoderInitStatusString FLAC__SeekableStreamDecoderStateString
+#define FLAC__StreamDecoderStateString FLAC__SeekableStreamDecoderStateString
 
+/* Constants and types */
+#define FLAC__StreamDecoderInitStatus FLAC__SeekableStreamDecoderState
 #define FLAC__STREAM_DECODER_SEEK_STATUS_ERROR FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR
 #define FLAC__STREAM_DECODER_SEEK_STATUS_OK FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK
 #define FLAC__STREAM_DECODER_TELL_STATUS_ERROR FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_ERROR
 #define FLAC__STREAM_DECODER_TELL_STATUS_OK FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_OK
 #define FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_ERROR
 #define FLAC__STREAM_DECODER_LENGTH_STATUS_OK FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_OK
+#define FLAC__STREAM_DECODER_INIT_STATUS_OK FLAC__SEEKABLE_STREAM_DECODER_OK
+#define FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_OK
+#define FLAC__STREAM_DECODER_END_OF_STREAM FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM
 
-FLAC__stream_decoder_init_stream(
+FLAC__SeekableStreamDecoderState FLAC__stream_decoder_init_stream(
     FLAC__SeekableStreamDecoder*  decoder,
     FLAC__SeekableStreamDecoderReadCallback read_callback,
     FLAC__SeekableStreamDecoderSeekCallback     seek_callback,
--- a/src/flacng/plugin.c	Fri Jul 13 04:50:42 2007 -0500
+++ b/src/flacng/plugin.c	Fri Jul 13 04:59:36 2007 -0500
@@ -142,7 +142,8 @@
             metadata_callback,
             error_callback,
             test_info))) {
-        _ERROR("Could not initialize test FLAC decoder: %s(%d)", StreamDecoderInitState(ret), ret);
+        _ERROR("Could not initialize test FLAC decoder: %s(%d)",
+                FLAC__StreamDecoderInitStatusString[ret], ret);
         _LEAVE;
      }
 
@@ -157,7 +158,8 @@
             metadata_callback,
             error_callback,
             main_info))) {
-        _ERROR("Could not initialize main FLAC decoder: %s(%d)", StreamDecoderInitState(ret), ret);
+        _ERROR("Could not initialize main FLAC decoder: %s(%d)",
+                FLAC__StreamDecoderInitStatusString[ret], ret);
         _LEAVE;
      }
 
--- a/src/flacng/seekable_stream_callbacks.c	Fri Jul 13 04:50:42 2007 -0500
+++ b/src/flacng/seekable_stream_callbacks.c	Fri Jul 13 04:59:36 2007 -0500
@@ -47,7 +47,7 @@
 
     if (0 <= info->read_max) {
         to_read = MIN(*bytes, info->read_max);
-        _DEBUG("Reading restricted to %d bytes", info->read_max);
+        _DEBUG("Reading restricted to %ld bytes", info->read_max);
     } else {
         to_read = *bytes;
     }
@@ -119,7 +119,7 @@
         return FLAC__STREAM_DECODER_TELL_STATUS_ERROR;
     }
 
-    _DEBUG("Current position: %d", position);
+    _DEBUG("Current position: %ld", position);
 
     *absolute_byte_offset = position;
 
@@ -166,7 +166,7 @@
         _LEAVE FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED;
     }
 
-    _DEBUG("Stream length is %d bytes", size);
+    _DEBUG("Stream length is %ld bytes", size);
     *stream_length = size;
 
     _LEAVE FLAC__STREAM_DECODER_LENGTH_STATUS_OK;
--- a/src/flacng/seekable_stream_callbacks.h	Fri Jul 13 04:50:42 2007 -0500
+++ b/src/flacng/seekable_stream_callbacks.h	Fri Jul 13 04:59:36 2007 -0500
@@ -19,9 +19,7 @@
 #ifndef CALLBACKS_H
 #define CALLBACKS_H
 
-#include "flac_compat112.h"
-#include "flac_compat113.h"
-#include "flac_compat114.h"
+#include "flac_compat.h"
 
 FLAC__StreamDecoderReadStatus read_callback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
 FLAC__StreamDecoderSeekStatus seek_callback(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data);
--- a/src/flacng/tools.c	Fri Jul 13 04:50:42 2007 -0500
+++ b/src/flacng/tools.c	Fri Jul 13 04:59:36 2007 -0500
@@ -172,89 +172,6 @@
 
 /* --- */
 
-gchar* StreamDecoderInitState(FLAC__StreamDecoderInitStatus state) {
-
-    _ENTER;
-
-    switch(state) {
-        case FLAC__STREAM_DECODER_INIT_STATUS_OK:
-            _LEAVE "FLAC__STREAM_DECODER_INIT_STATUS_OK";
-            break;
-
-        case FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER:
-            _LEAVE "FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER";
-            break;
-
-        case FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS:
-            _LEAVE "FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS";
-            break;
-
-        case FLAC__STREAM_DECODER_INIT_STATUS_MEMORY_ALLOCATION_ERROR:
-            _LEAVE "FLAC__STREAM_DECODER_INIT_STATUS_MEMORY_ALLOCATION_ERROR";
-            break;
-
-        case FLAC__STREAM_DECODER_INIT_STATUS_ERROR_OPENING_FILE:
-            _LEAVE "FLAC__STREAM_DECODER_INIT_STATUS_ERROR_OPENING_FILE";
-            break;
-
-        case FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED:
-            _LEAVE "FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED";
-            break;
-    }
-
-    _LEAVE "Unknown state";
-}
-
-/* --- */
-
-gchar* StreamDecoderState(FLAC__StreamDecoderState state) {
-
-    _ENTER;
-
-    switch(state) {
-
-        case FLAC__STREAM_DECODER_SEARCH_FOR_METADATA:
-            _LEAVE "FLAC__STREAM_DECODER_SEARCH_FOR_METADATA";
-            break;
-
-        case FLAC__STREAM_DECODER_READ_METADATA:
-            _LEAVE "FLAC__STREAM_DECODER_READ_METADATA";
-            break;
-
-        case FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC:
-            _LEAVE "FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC";
-            break;
-
-        case FLAC__STREAM_DECODER_READ_FRAME:
-            _LEAVE "FLAC__STREAM_DECODER_READ_FRAME";
-            break;
-
-        case FLAC__STREAM_DECODER_END_OF_STREAM:
-            _LEAVE "FLAC__STREAM_DECODER_END_OF_STREAM";
-            break;
-
-        case FLAC__STREAM_DECODER_ABORTED:
-            _LEAVE "FLAC__STREAM_DECODER_ABORTED";
-            break;
-
-        case FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR:
-            _LEAVE "FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR";
-            break;
-
-        case FLAC__STREAM_DECODER_UNINITIALIZED:
-            _LEAVE "FLAC__STREAM_DECODER_UNINITIALIZED";
-            break;
-
-        default:
-            break;
-
-    }
-
-    _LEAVE "";
-}
-
-/* --- */
-
 gboolean read_metadata(gchar* filename, FLAC__StreamDecoder* decoder, callback_info* info) {
 
     FLAC__StreamDecoderState ret;
@@ -300,7 +217,8 @@
      */
     if (false == FLAC__stream_decoder_process_until_end_of_metadata(decoder)) {
         ret = FLAC__stream_decoder_get_state(decoder);
-        _DEBUG("Could not read the metadata: %s(%d)!", StreamDecoderState(ret), ret);
+        _DEBUG("Could not read the metadata: %s(%d)!",
+                FLAC__StreamDecoderStateString[ret], ret);
         reset_info(info);
         _LEAVE FALSE;
     }
--- a/src/flacng/tools.h	Fri Jul 13 04:50:42 2007 -0500
+++ b/src/flacng/tools.h	Fri Jul 13 04:59:36 2007 -0500
@@ -22,13 +22,13 @@
 #include <glib.h>
 #include <FLAC/all.h>
 #include "flacng.h"
+#include "flac_compat.h"
 
 callback_info* init_callback_info(gchar* name);
 void reset_info(callback_info* info);
 gchar* get_title(const gchar* filename, callback_info* info);
 TitleInput *get_tuple(const gchar *filename, callback_info* info);
 void add_comment(callback_info* info, gchar* key, gchar* value);
-gchar* StreamDecoderInitState(FLAC__StreamDecoderInitStatus);
 gboolean read_metadata(gchar* filename, FLAC__StreamDecoder* decoder, callback_info* info);
 
 #endif
--- a/src/lastfm/lastfm.c	Fri Jul 13 04:50:42 2007 -0500
+++ b/src/lastfm/lastfm.c	Fri Jul 13 04:59:36 2007 -0500
@@ -30,7 +30,7 @@
 
 /*
  *  Current status and known issues:
- *      - Works fine ant is relatively stable unless DEBUG is enabled (read below)
+ *      - Works fine ant is relatively stable 
  *      - The adjust fails when having 2 or more opened streams at the same time.
  *              * It will randomly adjust to any one of them, because the playlist keeps 
  *                pulling metadata
@@ -49,9 +49,6 @@
 #include "lastfm.h"
 
 #define DEBUG 1
-/*Caution!!! setting DEBUG to 1 is very likely to crash the player because the g_print-ed values
-  aren't checked of being !=NULL
-  */
 
 size_t lastfm_store_res(void *ptr, size_t size, size_t nmemb, void *udata)
 {
@@ -106,14 +103,16 @@
         }
 }
 
-        void lastfm_store(gchar *var_name,gchar* var){  /*mowgli storage wrapper*/
-                if (mowgli_global_storage_get(var_name))
-                        mowgli_global_storage_free(var_name);
+void lastfm_store(gchar *var_name,gchar* var)  /*mowgli storage wrapper, for storing global data*/
+{
+        if (mowgli_global_storage_get(var_name))
+                mowgli_global_storage_free(var_name);
 
-                mowgli_global_storage_put(var_name,var);
-        }
+        mowgli_global_storage_put(var_name,var);
+}
 
 int lastfm_login(void)  /*gets the session ID and the mp3 stream URL and stores them*/
+        //it is called just on the first fopen, since it doesnt change (hopefully!!!)
 {
         gint    status, i,
                 ret=LASTFM_LOGIN_OK; /*suppose everything goes fine*/
@@ -157,7 +156,7 @@
         return g_strdup(strchr(input_string, '=') + 1);
 }
 
-gint lastfm_adjust(const gchar * uri)  /*tunes into a channel*/
+gint lastfm_adjust(LastFM * handle,const gchar * uri)  /*tunes into a channel*/
 {
         gint status, i,ret = LASTFM_ADJUST_FAILED;
         gchar *fetch_url=NULL,
@@ -175,20 +174,14 @@
         fetch_url=g_strdup_printf(LASTFM_ADJUST_URL, session_id, uri);
         res= g_string_new(NULL);
         status = lastfm_get_data_from_uri(fetch_url, res);
-#if 0
-        g_print("\nAdjusting: \nSession ID:%s\n",session_id);
-        g_print("Fetch URL:%s\n",fetch_url);
-        g_print("Adjust OK, \nReceived data:\n%s\n", res->str);
-#endif
+
         if (status == CURLE_OK)
         {
-                split = g_strsplit(res->str, "\n", 20);
+                split = g_strsplit(res->str, "\n", 2);
                 for (i = 0; split && split[i]; i++)
                 {
                         if (g_str_has_prefix(split[i], "response=OK"))
                                 ret = LASTFM_ADJUST_OK;
-                        if (g_str_has_prefix(split[i], "url="))
-                                lastfm_store("lastfm_tuned_to_url", parse(split[i], "url="));
                 }
         }
         g_string_erase(res, 0, -1);
@@ -303,11 +296,12 @@
         t0=g_new0(GTimeVal,1);
         t1=g_new0(GTimeVal,1);
         gboolean track_end_expected=FALSE,track_beginning=TRUE;
-        gchar* previous_track_title=NULL;
+        //  gchar* previous_track_title=NULL;
         LastFM *handle = (LastFM *)arg;
-        // metadata is fetched 1 second after the stream is opened.
+        // metadata is fetched 1 second after the stream is opened, 
+        // and again after 2 seconds.
         // if metadata was fetched ok i'm waiting for 
-        // track_length - fetch_duration - 5 seconds
+        // track_length - fetch_duration - 10 seconds
         // then start polling for new metadata each 2 seconds, until
         // the track gets changed from the previous iteration
         do
@@ -315,45 +309,60 @@
                 if(count%sleep_duration==0)
                 {    
                         g_get_current_time (t0);
-                        g_mutex_lock(mutex);
+                        g_mutex_lock(metadata_mutex);
                         status=fetch_metadata(handle);
-                        g_mutex_unlock(mutex);
+                        g_mutex_unlock(metadata_mutex);
                         g_get_current_time (t1);
                         if(status==METADATA_FETCH_SUCCEEDED)
                         {        
                                 if(!track_end_expected)
                                 {
-                                        if(track_beginning||(previous_track_duration==-1)) //fetch again 2 sec after track start
+                                        if(track_beginning)
+                                        {       //first try after track has changed
+#if DEBUG
+                                                g_print("retrying in 2 seconds\n");
+#endif
+                                                track_beginning=FALSE;
+                                                sleep_duration=2;
+                                        }
+                                        else 
                                         {
+                                                sleep_duration=handle->lastfm_duration-(t1->tv_sec - t0->tv_sec)-10;
+                                                previous_track_duration=handle->lastfm_duration;
+                                                count=err=0;
+                                                track_end_expected=TRUE; /*then the track_end will follow*/
+                                                track_beginning=TRUE;
+#if DEBUG
+                                                g_print("second fetch after new track started, the next will follow in %d sec\n",sleep_duration);
+#endif
+                                        }
+
+                                }
+                                else
+                                {       
+                                        //if the track hasnt yet changed (two tracks are considered identical if they 
+                                        //have the same length or the same title)
+                                        if(handle->lastfm_duration == previous_track_duration)
+                                        {      
+#if DEBUG                                        
+                                                g_print("it is the same track as before, waiting for new track to start\n");
+#endif
                                                 sleep_duration=2;
-                                                track_beginning=FALSE;
                                         }
                                         else
                                         {
-                                                sleep_duration=handle->lastfm_duration-(t1->tv_sec - t0->tv_sec)-5;
-                                                previous_track_duration=handle->lastfm_duration;
-                                                previous_track_title=g_strdup(handle->lastfm_title);
-                                                track_end_expected=TRUE; /*then the track_end will follow*/
-                                                count=err=0;
-                                                track_beginning=TRUE;
+#if DEBUG
+                                                g_print("the track has changed\n");
+#endif
+                                                track_end_expected=FALSE;
+                                                sleep_duration=2;
+                                                /*if(previous_track_title)
+                                                  {
+                                                  g_free(previous_track_title);
+                                                  previous_track_title=NULL;
+                                                  }*/
                                         }
                                 }
-                                else
-                                {       
-                                        //if the track has changed (two tracks are considered identical if they 
-                                        //have the same length and the same title)
-                                        if((handle->lastfm_duration != previous_track_duration)||
-                                                        !g_str_has_prefix(handle->lastfm_title, previous_track_title))
-                                        {       
-                                                track_end_expected=FALSE;
-                                                if(previous_track_title)
-                                                {
-                                                        g_free(previous_track_title);
-                                                        previous_track_title=NULL;
-                                                }
-                                        }
-                                        sleep_duration=2;
-                                }
 #if DEBUG
                                 g_print("Current thread, ID = %p\n", (void *)g_thread_self());
 #endif
@@ -365,7 +374,7 @@
                         }
 #if DEBUG
                         g_print("Thread_count: %d\n",thread_count);
-                        g_print("Sleeping for %d seconds\n",sleep_duration);
+                        g_print("Sleeping for %d seconds, track length = %d sec\n",sleep_duration, handle->lastfm_duration);
 #endif
 
                 }
@@ -386,26 +395,35 @@
 {
         VFSFile *file = g_new0(VFSFile, 1);
         LastFM  *handle = g_new0(LastFM, 1);
-        gchar* lastfm_uri=NULL;
+        handle->lastfm_artist=NULL;
+        handle->lastfm_title=NULL;
+        handle->lastfm_album=NULL;
+        handle->lastfm_cover=NULL;
+        handle->lastfm_session_id=NULL;
+        handle->lastfm_mp3_stream_url=NULL;
+        handle->lastfm_station_name=NULL;
         int login_count = 0;
-        while((login_count++ <= 3)&&(lastfm_login()!= LASTFM_LOGIN_OK))
-                sleep(5);
+
+        if(!mowgli_global_storage_get("lastfm_session_id")) //login only if really needed
+        {
+                while((login_count++ <= 3)&&(lastfm_login()!= LASTFM_LOGIN_OK))
+                        sleep(5);
+                if(login_count>3)
+                        return NULL;
+        }
+        //the following data is completed during login, which happens just once
+        //maybe making it happen on each time vfs_fopen would make it eliminate the issue 
+        //that occurs when having more opened tracks (random play of anyone of them)
         handle->lastfm_session_id = mowgli_global_storage_get("lastfm_session_id");
         handle->lastfm_mp3_stream_url = mowgli_global_storage_get("lastfm_stream_uri");
-        lastfm_uri=mowgli_global_storage_get("lastfm_tuned_to_url");
-        //only tune in if the existing uri is NULL or != our new one(from path)
-        //adjust doesnt work as it should when having more than one lastfm stream opened at a time
-        if (!lastfm_uri || (!g_str_has_prefix(path,lastfm_uri)) ) 
-                if(!lastfm_adjust(path)==LASTFM_ADJUST_OK)
-                        return NULL;
-
+        if(!lastfm_adjust(handle,path)==LASTFM_ADJUST_OK)
+                return NULL;
         metadata_thread = g_thread_create(lastfm_metadata_thread_func, handle, FALSE, NULL);
         thread_count++;
 #if DEBUG
         g_print("Thread_count: %d\n",thread_count);
 #endif
         handle->proxy_fd = vfs_fopen(handle->lastfm_mp3_stream_url, mode);
-
         file->handle = handle;
         return file;
 }
@@ -520,13 +538,14 @@
 static void init(void)
 {       
         vfs_register_transport(&lastfm_const);
-        if (!mutex)
-                mutex = g_mutex_new ();
+        if (!metadata_mutex)
+                metadata_mutex = g_mutex_new ();
+
 }
 
 static void cleanup(void)
 {
-        g_mutex_free(mutex);
+        g_mutex_free(metadata_mutex);
         mowgli_global_storage_free("lastfm_session_id");
         mowgli_global_storage_free("lastfm_stream_uri");
 #if DEBUG
--- a/src/lastfm/lastfm.h	Fri Jul 13 04:50:42 2007 -0500
+++ b/src/lastfm/lastfm.h	Fri Jul 13 04:59:36 2007 -0500
@@ -29,7 +29,7 @@
 
 GThread* metadata_thread=NULL;
 gint thread_count=0;
-static GMutex * mutex = NULL;
+static GMutex * metadata_mutex = NULL;
 
 VFSFile *lastfm_vfs_fopen_impl(const gchar * path, const gchar * mode);
 
--- a/src/m3u/m3u.c	Fri Jul 13 04:50:42 2007 -0500
+++ b/src/m3u/m3u.c	Fri Jul 13 04:59:36 2007 -0500
@@ -85,10 +85,16 @@
     gint ext_len = -1;
     gboolean is_extm3u = FALSE;
     Playlist *playlist = playlist_get_active();
+    gchar *uri;
+    
+    uri = g_filename_to_uri(filename, NULL, NULL);
 
-    if ((file = vfs_fopen(filename, "rb")) == NULL)
+    if ((file = vfs_fopen(uri ? uri : filename, "rb")) == NULL)
         return;
 
+    if (uri)
+        g_free(uri);
+
     line = g_malloc(line_len);
     while (vfs_fgets(line, line_len, file)) {
         while (strlen(line) == line_len - 1 && line[strlen(line) - 1] != '\n') {
@@ -126,7 +132,11 @@
             ext_info = NULL;
         }
 
-        playlist_load_ins_file(playlist, line, filename, pos, ext_title, ext_len);
+        uri = g_filename_to_uri(line, NULL, NULL);
+        playlist_load_ins_file(playlist, uri ? uri : line, filename, pos, ext_title, ext_len);
+
+        if (uri)
+            g_free(uri);
 
         str_replace_in(&ext_title, NULL);
         ext_len = -1;
@@ -146,6 +156,7 @@
     gchar *outstr = NULL;
     VFSFile *file;
     Playlist *playlist = playlist_get_active();
+    gchar *fn;
 
     g_return_if_fail(filename != NULL);
     g_return_if_fail(playlist != NULL);
@@ -180,7 +191,11 @@
             }
         }
 
-        vfs_fprintf(file, "%s\n", entry->filename);
+        fn = g_filename_from_uri(entry->filename, NULL, NULL);
+        vfs_fprintf(file, "%s\n", fn ? fn : entry->filename);
+
+        if (fn)
+            g_free(fn);
     }
 
     PLAYLIST_UNLOCK(playlist->mutex);
--- a/src/madplug/Makefile	Fri Jul 13 04:50:42 2007 -0500
+++ b/src/madplug/Makefile	Fri Jul 13 04:59:36 2007 -0500
@@ -19,6 +19,7 @@
 
 CFLAGS   += $(PICFLAGS) $(GTK_CFLAGS) $(GLIB_CFLAGS) $(PANGO_CFLAGS) $(ARCH_DEFINES) $(SIMD_CFLAGS) -I../../intl -I../.. -Wall
 
+LDFLAGS += $(AUDLDFLAGS)
 LIBADD = -L/opt/local/lib -L$(plugindir) -laudid3tag -lmad $(GTK_LIBS) $(GLIB_LIBS) $(PANGO_LIBS)
 
 include ../../mk/objective.mk
--- a/src/timidity/libtimidity/common.c	Fri Jul 13 04:50:42 2007 -0500
+++ b/src/timidity/libtimidity/common.c	Fri Jul 13 04:59:36 2007 -0500
@@ -54,7 +54,7 @@
   /* First try the given name */
 
   DEBUG_MSG("Trying to open %s\n", name);
-  if ((fp = vfs_fopen(name, OPEN_MODE)))
+  if ((fp = vfs_fopen(g_filename_to_uri(name, NULL, NULL), OPEN_MODE)))
     return fp;
 
   if (name[0] != PATH_SEP)
@@ -78,7 +78,7 @@
 	  }
 	strcat(current_filename, name);
 	DEBUG_MSG("Trying to open %s\n", current_filename);
-	if ((fp = vfs_fopen(current_filename, OPEN_MODE)))
+	if ((fp = vfs_fopen(g_filename_to_uri(current_filename, NULL, NULL), OPEN_MODE)))
 	  return fp;
 	plp = plp->next;
       }
--- a/src/tta/Makefile	Fri Jul 13 04:50:42 2007 -0500
+++ b/src/tta/Makefile	Fri Jul 13 04:59:36 2007 -0500
@@ -11,6 +11,7 @@
 
 CFLAGS += -fPIC -DPIC $(GTK_CFLAGS) $(GLIB_CFLAGS) $(PANGO_CFLAGS) -I../../intl -I../..
 
+LDFLAGS += $(AUDLDFLAGS)
 LIBADD = -L$(plugindir) -laudid3tag $(GTK_LIBS) $(GLIB_LIBS) $(PANGO_LIBS)
 
 include ../../mk/objective.mk
--- a/src/tta/libtta.c	Fri Jul 13 04:50:42 2007 -0500
+++ b/src/tta/libtta.c	Fri Jul 13 04:59:36 2007 -0500
@@ -460,7 +460,7 @@
 static void
 play_file (InputPlayback *playback)
 {
-	char *filename = playback->filename;
+	gchar *filename = playback->filename;
 	char *title;
 	int datasize, origsize, bitrate;
 	TitleInput *tuple = NULL;
@@ -469,7 +469,7 @@
 
 	////////////////////////////////////////
 	// open TTA file
-	if (open_tta_file (filename, &info, 0) < 0)
+	if (open_tta_file (filename, &info, 0) > 0)
 	{
 	    tta_error (info.STATE);
 	    close_tta_file (&info);
--- a/src/tta/ttadec.c	Fri Jul 13 04:50:42 2007 -0500
+++ b/src/tta/ttadec.c	Fri Jul 13 04:59:36 2007 -0500
@@ -87,7 +87,7 @@
 __inline void get_binary(unsigned int *value, unsigned int bits) {
 	while (bit_count < bits) {
 		if (bitpos == iso_buffers_end) {
-			int res = fread(isobuffers, 1,
+			int res = vfs_fread(isobuffers, 1,
 				ISO_BUFFERS_SIZE, ttainfo->HANDLE);
 			if (!res) {
 				ttainfo->STATE = READ_ERROR;
@@ -113,7 +113,7 @@
 
 	while (!(bit_cache ^ bit_mask[bit_count])) {
 		if (bitpos == iso_buffers_end) {
-			int res = fread(isobuffers, 1,
+			int res = vfs_fread(isobuffers, 1,
 				ISO_BUFFERS_SIZE, ttainfo->HANDLE);
 			if (!res) {
 				ttainfo->STATE = READ_ERROR;
@@ -145,7 +145,7 @@
 	rbytes = iso_buffers_end - bitpos;
 	if (rbytes < sizeof(int)) {
 		memcpy(isobuffers, bitpos, 4);
-		res = fread(isobuffers + rbytes, 1,
+		res = vfs_fread(isobuffers + rbytes, 1,
 			ISO_BUFFERS_SIZE - rbytes, ttainfo->HANDLE);
 		if (!res) {
 			ttainfo->STATE = READ_ERROR;
@@ -260,7 +260,7 @@
 	} __ATTRIBUTE_PACKED__ id3v2;
 	unsigned int len = 0;
 
-	if (!fread(&id3v2, sizeof(id3v2), 1, ttainfo->HANDLE) || 
+	if (!vfs_fread(&id3v2, sizeof(id3v2), 1, ttainfo->HANDLE) || 
 	    memcmp(id3v2.id, "ID3", 3) ||
 	    id3v2.size[0] & 0x80)
 	{
@@ -279,14 +279,14 @@
 }
 
 int open_tta_file (const char *filename, tta_info *info, unsigned int data_offset) {
-	FILE *infile;
+	VFSFile *infile;
 	tta_hdr ttahdr;
 	unsigned int checksum;
 
 	// clear the memory
 	memset (info, 0, sizeof(tta_info));
 
-	info->HANDLE = infile = fopen(filename, "rb");
+	info->HANDLE = infile = vfs_fopen(filename, "rb");
 	if (!infile) return OPEN_ERROR;
 
 	// read id3v2 header
@@ -294,18 +294,18 @@
 //		data_offset = id3v2_header_length(info);
 
 	data_offset = get_id3_tags (filename, info);
-	fseek (infile, data_offset, SEEK_SET);
+	vfs_fseek (infile, data_offset, SEEK_SET);
 
 	// read TTA header
-	if (fread (&ttahdr, 1, sizeof (ttahdr), infile) == 0) {
-		fclose (infile);
+	if (vfs_fread (&ttahdr, 1, sizeof (ttahdr), infile) == 0) {
+		vfs_fclose (infile);
 		info->STATE = READ_ERROR;
 		return -1;
 	}
 
 	// check for TTA3 signature
 	if (ENDSWAP_INT32(ttahdr.TTAid) != TTA1_SIGN) {
-		fclose (infile);
+		vfs_fclose (infile);
 		info->STATE = FORMAT_ERROR;
 		return -1;
 	}
@@ -314,7 +314,7 @@
 	checksum = crc32((unsigned char *) &ttahdr,
 	sizeof(tta_hdr) - sizeof(int));
 	if (checksum != ttahdr.CRC32) {
-		fclose (infile);
+		vfs_fclose (infile);
 		info->STATE = FILE_ERROR;
 		return -1;
 	}
@@ -338,7 +338,7 @@
 		ttahdr.SampleRate != 64000 &&
 		ttahdr.SampleRate != 88200 &&
 		ttahdr.SampleRate != 96000)) {
-		fclose (infile);
+		vfs_fclose (infile);
 		info->STATE = FORMAT_ERROR;
 		return FORMAT_ERROR;
 	}
@@ -398,7 +398,7 @@
 	}
 
 	seek_pos = ttainfo->DATAPOS + seek_table[data_pos = pos];
-	fseek(ttainfo->HANDLE, seek_pos, SEEK_SET);
+	vfs_fseek(ttainfo->HANDLE, seek_pos, SEEK_SET);
 
 	data_cur = 0;
 	framelen = 0;
@@ -432,7 +432,7 @@
 	}
 
 	// read seek table
-	if (!fread(seek_table, st_size, 1, ttainfo->HANDLE)) {
+	if (!vfs_fread(seek_table, st_size, 1, ttainfo->HANDLE)) {
 		ttainfo->STATE = READ_ERROR;
 		return -1;
 	}
@@ -455,7 +455,7 @@
 
 void close_tta_file (tta_info *info) {
 	if (info->HANDLE) {
-		fclose (info->HANDLE);
+		vfs_fclose (info->HANDLE);
 		info->HANDLE = NULL;
 	}
 }
@@ -530,8 +530,7 @@
 			rice->k0++;
 		}
 
-        // DEC is not defined??
-//		value = DEC(value);
+		value = DEC(value);
 
 		// decompress stage 1: adaptive hybrid filter
 		hybrid_filter(fst, &value);
--- a/src/tta/ttalib.h	Fri Jul 13 04:50:42 2007 -0500
+++ b/src/tta/ttalib.h	Fri Jul 13 04:59:36 2007 -0500
@@ -80,7 +80,7 @@
 } id3_info;
 
 typedef struct {
-	FILE		*HANDLE;	// file handle
+	VFSFile		*HANDLE;	// file handle
 	unsigned short	NCH;		// number of channels
 	unsigned short	BPS;		// bits per sample
 	unsigned short	BSIZE;		// byte size
--- a/src/wav/wav-sndfile.c	Fri Jul 13 04:50:42 2007 -0500
+++ b/src/wav/wav-sndfile.c	Fri Jul 13 04:59:36 2007 -0500
@@ -132,18 +132,22 @@
 }
 
 static int
-is_our_file (char *filename)
+is_our_file (char *fileuri)
 {
 	SNDFILE	*tmp_sndfile;
 	SF_INFO tmp_sfinfo;
+	gchar *filename = g_filename_from_uri(fileuri, NULL, NULL);
 
 	/* Have to open the file to see if libsndfile can handle it. */
-	if (! (tmp_sndfile = sf_open (filename, SFM_READ, &tmp_sfinfo)))
+	if (! (tmp_sndfile = sf_open (filename, SFM_READ, &tmp_sfinfo))) {
+		g_free(filename);
 		return FALSE;
+    }
 
 	/* It can so close file and return TRUE. */
 	sf_close (tmp_sndfile);
 	tmp_sndfile = NULL;
+	g_free(filename);
 
 	return TRUE;
 }
@@ -222,7 +226,7 @@
 static void
 play_start (InputPlayback *playback)
 {
-	char *filename = playback->filename;
+	gchar *filename = g_filename_from_uri(playback->filename, NULL, NULL);
 	int pcmbitwidth;
 	gchar *song_title;
 
@@ -303,10 +307,12 @@
 }
 
 static void
-get_song_info (char *filename, char **title, int *length)
+get_song_info (char *fileuri, char **title, int *length)
 {
+	gchar *filename = g_filename_from_uri(fileuri, NULL, NULL);
 	(*length) = get_song_length(filename);
 	(*title) = get_title(filename);
+	g_free(filename);
 }
 
 static void wav_about(void)