changeset 1247:ce4c57c2fa8d

Branch merge
author Ralf Ertzinger <ralf@skytale.net>
date Thu, 12 Jul 2007 19:36:09 +0200
parents 626f78ff2439 (current diff) a18b7cdc505d (diff)
children 0e0f73fed025
files
diffstat 6 files changed, 43 insertions(+), 111 deletions(-) [+]
line wrap: on
line diff
--- a/src/OSS4/OSS4.c	Thu Jul 12 19:30:31 2007 +0200
+++ b/src/OSS4/OSS4.c	Thu Jul 12 19:36:09 2007 +0200
@@ -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	Thu Jul 12 19:30:31 2007 +0200
+++ b/src/OSS4/OSS4.h	Thu Jul 12 19:36:09 2007 +0200
@@ -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	Thu Jul 12 19:30:31 2007 +0200
+++ b/src/OSS4/about.c	Thu Jul 12 19:36:09 2007 +0200
@@ -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	Thu Jul 12 19:30:31 2007 +0200
+++ b/src/OSS4/audio.c	Thu Jul 12 19:36:09 2007 +0200
@@ -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/configure.c	Thu Jul 12 19:30:31 2007 +0200
+++ b/src/OSS4/configure.c	Thu Jul 12 19:36:09 2007 +0200
@@ -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	Thu Jul 12 19:30:31 2007 +0200
+++ b/src/OSS4/init.c	Thu Jul 12 19:36:09 2007 +0200
@@ -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
+           
+
 }