changeset 1244:d0f1e147cf62

now it saves VMIX volume between sessions
author Cristi Magherusan <majeru@atheme-project.org>
date Thu, 12 Jul 2007 18:21:23 +0300
parents 4cf6ccace89c
children a18b7cdc505d
files src/OSS4/OSS4.c src/OSS4/OSS4.h src/OSS4/audio.c src/OSS4/init.c
diffstat 4 files changed, 13 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/OSS4/OSS4.c	Thu Jul 12 17:51:36 2007 +0300
+++ b/src/OSS4/OSS4.c	Thu Jul 12 18:21:23 2007 +0300
@@ -24,6 +24,7 @@
 #include <glib.h>
 #include <audacious/i18n.h>
 #include <stdlib.h>
+#include <audacious/configdb.h>
 
 OutputPlugin oss_op = {
     NULL,
@@ -53,6 +54,11 @@
 
 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;
@@ -61,5 +67,5 @@
     if (oss_cfg.alt_mixer_device) {
         free(oss_cfg.alt_mixer_device);
         oss_cfg.alt_mixer_device = NULL;
-    }
+    }    
 }
--- a/src/OSS4/OSS4.h	Thu Jul 12 17:51:36 2007 +0300
+++ b/src/OSS4/OSS4.h	Thu Jul 12 18:21:23 2007 +0300
@@ -50,7 +50,7 @@
 } OSSConfig;
 
 extern OSSConfig oss_cfg;
-
+int vol;
 void oss_init(void);
 void oss_cleanup(void);
 void oss_about(void);
--- a/src/OSS4/audio.c	Thu Jul 12 17:51:36 2007 +0300
+++ b/src/OSS4/audio.c	Thu Jul 12 18:21:23 2007 +0300
@@ -36,7 +36,7 @@
 
 #define NFRAGS		32
 
-static gint fd = 0,temp_vol=0x6464;
+static gint fd = 0;
 static char *buffer;
 static gboolean going, prebuffer, paused, unpause, do_pause, remove_prebuffer;
 static gint device_buffer_used, buffer_size, prebuffer_size, blk_size;
@@ -740,7 +740,7 @@
     int v;
     long cmd=SNDCTL_DSP_GETPLAYVOL;
     if(ioctl(fd, cmd, &v) == -1)
-        v=temp_vol;
+        v=vol;
     *r = (v & 0xFF00) >> 8;
     *l = (v & 0x00FF);
 }
@@ -749,8 +749,8 @@
 oss_set_volume(int l, int r)
 {   
     long cmd=SNDCTL_DSP_SETPLAYVOL;   
-    temp_vol = (r << 8) | l;
-    ioctl(fd, cmd, &temp_vol);
+    vol = (r << 8) | l;
+    ioctl(fd, cmd, &vol);
 }
 
 void
--- a/src/OSS4/init.c	Thu Jul 12 17:51:36 2007 +0300
+++ b/src/OSS4/init.c	Thu Jul 12 18:21:23 2007 +0300
@@ -43,6 +43,7 @@
     oss_cfg.use_master = 0;
 
     if ((db = bmp_cfg_db_open())) {
+        bmp_cfg_db_get_int(db, "OSS", "saved_volume", &vol);
         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);