diff options
author | waker <wakeroid@gmail.com> | 2011-05-20 21:28:56 +0200 |
---|---|---|
committer | waker <wakeroid@gmail.com> | 2011-05-20 21:28:56 +0200 |
commit | 1810ce0564058b621909567fdb2750c3d8cd02b6 (patch) | |
tree | b951a4888306a41393e4f3344b7c22c8a7af2878 | |
parent | 603a9f7c9e24e70b8e7a2c7f0700cb014885ef6d (diff) |
added GUI option to control 8 to 16 bit auto-conversion
-rw-r--r-- | plugins/gtkui/callbacks.c | 1 | ||||
-rw-r--r-- | plugins/gtkui/callbacks.h | 4 | ||||
-rw-r--r-- | plugins/gtkui/deadbeef.glade | 20 | ||||
-rw-r--r-- | plugins/gtkui/interface.c | 9 | ||||
-rw-r--r-- | plugins/gtkui/prefwin.c | 13 | ||||
-rw-r--r-- | streamer.c | 15 |
6 files changed, 57 insertions, 5 deletions
diff --git a/plugins/gtkui/callbacks.c b/plugins/gtkui/callbacks.c index 6e2cc158..4fdc73c3 100644 --- a/plugins/gtkui/callbacks.c +++ b/plugins/gtkui/callbacks.c @@ -1232,4 +1232,3 @@ on_sort_by_custom_activate (GtkMenuItem *menuitem, gtk_widget_destroy (dlg); dlg = NULL; } - diff --git a/plugins/gtkui/callbacks.h b/plugins/gtkui/callbacks.h index e51ecc92..fd92b376 100644 --- a/plugins/gtkui/callbacks.h +++ b/plugins/gtkui/callbacks.h @@ -1151,3 +1151,7 @@ on_sort_by_date_activate (GtkMenuItem *menuitem, void on_sort_by_custom_activate (GtkMenuItem *menuitem, gpointer user_data); + +void +on_convert8to16_toggled (GtkToggleButton *togglebutton, + gpointer user_data); diff --git a/plugins/gtkui/deadbeef.glade b/plugins/gtkui/deadbeef.glade index fe0f8251..73759b65 100644 --- a/plugins/gtkui/deadbeef.glade +++ b/plugins/gtkui/deadbeef.glade @@ -2540,6 +2540,26 @@ Right</property> <property name="fill">False</property> </packing> </child> + + <child> + <widget class="GtkCheckButton" id="convert8to16"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Always convert 8 bit audio to 16 bit</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + <signal name="toggled" handler="on_convert8to16_toggled" last_modification_time="Fri, 20 May 2011 18:56:52 GMT"/> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> </widget> <packing> <property name="tab_expand">False</property> diff --git a/plugins/gtkui/interface.c b/plugins/gtkui/interface.c index 79ceceba..67d70dba 100644 --- a/plugins/gtkui/interface.c +++ b/plugins/gtkui/interface.c @@ -1655,6 +1655,7 @@ create_prefwin (void) GtkWidget *hbox12; GtkWidget *label4; GtkWidget *pref_soundcard; + GtkWidget *convert8to16; GtkWidget *Sound; GtkWidget *vbox8; GtkWidget *hbox10; @@ -1837,6 +1838,10 @@ create_prefwin (void) gtk_widget_show (pref_soundcard); gtk_box_pack_start (GTK_BOX (hbox12), pref_soundcard, TRUE, TRUE, 0); + convert8to16 = gtk_check_button_new_with_mnemonic (_("Always convert 8 bit audio to 16 bit")); + gtk_widget_show (convert8to16); + gtk_box_pack_start (GTK_BOX (vbox10), convert8to16, FALSE, FALSE, 0); + Sound = gtk_label_new (_("Sound")); gtk_widget_show (Sound); gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), 0), Sound); @@ -2517,6 +2522,9 @@ create_prefwin (void) g_signal_connect ((gpointer) prefwin, "realize", G_CALLBACK (on_prefwin_realize), NULL); + g_signal_connect ((gpointer) convert8to16, "toggled", + G_CALLBACK (on_convert8to16_toggled), + NULL); g_signal_connect ((gpointer) pref_replaygain_mode, "changed", G_CALLBACK (on_pref_replaygain_mode_changed), NULL); @@ -2679,6 +2687,7 @@ create_prefwin (void) GLADE_HOOKUP_OBJECT (prefwin, hbox12, "hbox12"); GLADE_HOOKUP_OBJECT (prefwin, label4, "label4"); GLADE_HOOKUP_OBJECT (prefwin, pref_soundcard, "pref_soundcard"); + GLADE_HOOKUP_OBJECT (prefwin, convert8to16, "convert8to16"); GLADE_HOOKUP_OBJECT (prefwin, Sound, "Sound"); GLADE_HOOKUP_OBJECT (prefwin, vbox8, "vbox8"); GLADE_HOOKUP_OBJECT (prefwin, hbox10, "hbox10"); diff --git a/plugins/gtkui/prefwin.c b/plugins/gtkui/prefwin.c index 9ddb0186..4f6207f4 100644 --- a/plugins/gtkui/prefwin.c +++ b/plugins/gtkui/prefwin.c @@ -500,6 +500,9 @@ on_preferences_activate (GtkMenuItem *menuitem, // replaygain_preamp gtk_range_set_value (GTK_RANGE (lookup_widget (w, "replaygain_preamp")), deadbeef->conf_get_int ("replaygain_preamp", 0)); + // 8_to_16 + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (lookup_widget (w, "convert8to16")), deadbeef->conf_get_int ("streamer.8_to_16", 1)); + // dsp dsp_setup_init (prefwin); @@ -1341,3 +1344,13 @@ on_ignore_archives_toggled (GtkToggleButton *togglebutton, deadbeef->conf_set_int ("ignore_archives", gtk_toggle_button_get_active (togglebutton)); } + + +void +on_convert8to16_toggled (GtkToggleButton *togglebutton, + gpointer user_data) +{ + deadbeef->conf_set_int ("streamer.8_to_16", gtk_toggle_button_get_active (togglebutton)); + deadbeef->sendmessage (DB_EV_CONFIGCHANGED, 0, 0, 0); +} + @@ -1653,12 +1653,14 @@ streamer_set_output_format (void) { int playing = (output->state () == OUTPUT_STATE_PLAYING); fprintf (stderr, "streamer_set_output_format %dbit %s %dch %dHz channelmask=%X, bufferfill: %d\n", output_format.bps, output_format.is_float ? "float" : "int", output_format.channels, output_format.samplerate, output_format.channelmask, streamer_ringbuf.remaining); + ddb_waveformat_t fmt; + memcpy (&fmt, &output_format, sizeof (ddb_waveformat_t)); if (autoconv_8_to_16) { - if (output_format.bps == 8) { - output_format.bps = 16; + if (fmt.bps == 8) { + fmt.bps = 16; } } - output->setformat (&output_format); + output->setformat (&fmt); streamer_buffering = 1; if (playing && output->state () != OUTPUT_STATE_PLAYING) { if (0 != output->play ()) { @@ -1937,7 +1939,12 @@ streamer_configchanged (void) { if (playing_track) { playing_track->played = 1; } - autoconv_8_to_16 = conf_get_int ("streamer.8_to_16", 1); + int conf_autoconv_8_to_16 = conf_get_int ("streamer.8_to_16", 1); + if (conf_autoconv_8_to_16 != autoconv_8_to_16) { + autoconv_8_to_16 = conf_autoconv_8_to_16; + formatchanged = 1; + streamer_reset (1); + } } void |