changeset 488:cb0f36590d98 trunk

[svn] ESD output plugin enhancements by max_verem -at- yahoo.com.
author nenolod
date Tue, 24 Jan 2006 07:52:28 -0800
parents a2478a8475ee
children e0ee28a14570
files Plugins/Output/esd/audio.c Plugins/Output/esd/init.c Plugins/Output/esd/mixer.c
diffstat 3 files changed, 28 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/Plugins/Output/esd/audio.c	Mon Jan 23 14:11:40 2006 -0800
+++ b/Plugins/Output/esd/audio.c	Tue Jan 24 07:52:28 2006 -0800
@@ -46,6 +46,7 @@
 static GThread *buffer_thread;
 static gboolean realtime = FALSE;
 static void *(*esd_translate) (void *, gint);
+static int player_id_unique = 0;
 
 static gint
 get_latency(void)
@@ -454,7 +455,7 @@
     paused = FALSE;
     remove_prebuffer = FALSE;
 
-    esd_cfg.playername = g_strdup_printf("xmms - plugin (%d)", getpid());
+    esd_cfg.playername = g_strdup_printf("xmms - plugin (%d) [%d]", getpid(), player_id_unique++);
 
     if (esd_cfg.hostname)
         g_free(esd_cfg.hostname);
--- a/Plugins/Output/esd/init.c	Mon Jan 23 14:11:40 2006 -0800
+++ b/Plugins/Output/esd/init.c	Tue Jan 24 07:52:28 2006 -0800
@@ -34,6 +34,7 @@
 {
     ConfigDb *db;
     char *env;
+    int lp = 80 , rp = 80;
 
     memset(&esd_cfg, 0, sizeof(ESDConfig));
     esd_cfg.port = ESD_DEFAULT_PORT;
@@ -62,6 +63,12 @@
     bmp_cfg_db_get_bool(db, "ESD", "use_oss_mixer", &esd_cfg.use_oss_mixer);
     bmp_cfg_db_get_int(db, "ESD", "buffer_size", &esd_cfg.buffer_size);
     bmp_cfg_db_get_int(db, "ESD", "prebuffer", &esd_cfg.prebuffer);
+    
+    /* restore volume levels */
+    bmp_cfg_db_get_int(db, "ESD", "volume_left", &lp);
+    bmp_cfg_db_get_int(db, "ESD", "volume_right", &rp);
+    esdout_set_volume(lp, rp);
+    
     bmp_cfg_db_close(db);
 
     if (!esd_cfg.server)
--- a/Plugins/Output/esd/mixer.c	Mon Jan 23 14:11:40 2006 -0800
+++ b/Plugins/Output/esd/mixer.c	Tue Jan 24 07:52:28 2006 -0800
@@ -24,6 +24,8 @@
 #include <string.h>
 #include <esd.h>
 
+#include <libbeep/configdb.h>
+
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/types.h>
@@ -41,7 +43,7 @@
 
 #include <libaudacious/util.h>
 
-
+#define QUERY_PLAYER_ID_ATTEMPTS 5
 
 static void esdout_get_oss_volume(int *l, int *r);
 static void esdout_set_oss_volume(int l, int r);
@@ -56,7 +58,15 @@
 void
 esdout_mixer_init(void)
 {
-    esdout_fetch_volume(NULL, NULL);
+    int i;
+
+    /* reset player id */
+    player = -1;
+    
+    /* query n-time for player id */
+    for(i=0; (i<QUERY_PLAYER_ID_ATTEMPTS) && (player == (-1)) ; i++)
+	esdout_fetch_volume(NULL, NULL);
+	
     if (!(OSS_AVAILABLE && esd_cfg.use_oss_mixer && !esd_cfg.use_remote))
         esdout_set_volume(lp, rp);
 }
@@ -130,6 +140,7 @@
 void
 esdout_set_volume(int l, int r)
 {
+    ConfigDb *db;
     lp = l;
     rp = r;
 
@@ -143,6 +154,12 @@
             esd_close(fd);
         }
     }
+    
+    /* save volume values in db */
+    db = bmp_cfg_db_open();
+    bmp_cfg_db_set_int(db, "ESD", "volume_left", lp);
+    bmp_cfg_db_set_int(db, "ESD", "volume_right", rp);
+    bmp_cfg_db_close(db);
 }
 
 #ifdef HAVE_OSS