From 3186518f459ed8547361c71d6dba3ea42e5112b5 Mon Sep 17 00:00:00 2001 From: Eugene Rudchenko Date: Fri, 23 Aug 2013 11:56:36 +0300 Subject: Add option to convert 16 bit audio to 24 bit Conflicts: plugins/gtkui/callbacks.h streamer.c --- plugins/gtkui/callbacks.h | 4 ++++ plugins/gtkui/deadbeef.glade | 19 +++++++++++++++++++ plugins/gtkui/interface.c | 9 +++++++++ plugins/gtkui/prefwin.c | 11 ++++++++++- streamer.c | 13 +++++++++++++ 5 files changed, 55 insertions(+), 1 deletion(-) diff --git a/plugins/gtkui/callbacks.h b/plugins/gtkui/callbacks.h index c1a4a5c7..f0bd66e5 100644 --- a/plugins/gtkui/callbacks.h +++ b/plugins/gtkui/callbacks.h @@ -1152,6 +1152,10 @@ void on_design_mode1_activate (GtkMenuItem *menuitem, gpointer user_data); +void +on_convert16to24_toggled (GtkToggleButton *togglebutton, + gpointer user_data); + void on_reset_autostop_toggled (GtkToggleButton *togglebutton, gpointer user_data); diff --git a/plugins/gtkui/deadbeef.glade b/plugins/gtkui/deadbeef.glade index bbb7ccf9..7b23fb8b 100644 --- a/plugins/gtkui/deadbeef.glade +++ b/plugins/gtkui/deadbeef.glade @@ -2571,6 +2571,25 @@ Right False + + + True + True + Always convert 16 bit audio to 24 bit + True + GTK_RELIEF_NORMAL + True + False + False + True + + + + 0 + False + False + + False diff --git a/plugins/gtkui/interface.c b/plugins/gtkui/interface.c index ea1435eb..bfe2f8f7 100644 --- a/plugins/gtkui/interface.c +++ b/plugins/gtkui/interface.c @@ -1622,6 +1622,7 @@ create_prefwin (void) GtkWidget *label4; GtkWidget *pref_soundcard; GtkWidget *convert8to16; + GtkWidget *convert16to24; GtkWidget *Sound; GtkWidget *vbox8; GtkWidget *hbox10; @@ -1843,6 +1844,10 @@ create_prefwin (void) gtk_widget_show (convert8to16); gtk_box_pack_start (GTK_BOX (vbox10), convert8to16, FALSE, FALSE, 0); + convert16to24 = gtk_check_button_new_with_mnemonic (_("Always convert 16 bit audio to 24 bit")); + gtk_widget_show (convert16to24); + gtk_box_pack_start (GTK_BOX (vbox10), convert16to24, 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); @@ -2695,6 +2700,9 @@ create_prefwin (void) g_signal_connect ((gpointer) convert8to16, "toggled", G_CALLBACK (on_convert8to16_toggled), NULL); + g_signal_connect ((gpointer) convert16to24, "toggled", + G_CALLBACK (on_convert16to24_toggled), + NULL); g_signal_connect ((gpointer) pref_replaygain_mode, "changed", G_CALLBACK (on_pref_replaygain_mode_changed), NULL); @@ -2903,6 +2911,7 @@ create_prefwin (void) GLADE_HOOKUP_OBJECT (prefwin, label4, "label4"); GLADE_HOOKUP_OBJECT (prefwin, pref_soundcard, "pref_soundcard"); GLADE_HOOKUP_OBJECT (prefwin, convert8to16, "convert8to16"); + GLADE_HOOKUP_OBJECT (prefwin, convert16to24, "convert16to24"); 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 e5efc8d3..93b1ba04 100644 --- a/plugins/gtkui/prefwin.c +++ b/plugins/gtkui/prefwin.c @@ -183,6 +183,9 @@ on_preferences_activate (GtkMenuItem *menuitem, // 8_to_16 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (lookup_widget (w, "convert8to16")), deadbeef->conf_get_int ("streamer.8_to_16", 1)); + // 16_to_24 + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (lookup_widget (w, "convert16to24")), deadbeef->conf_get_int ("streamer.16_to_24", 0)); + // dsp dsp_setup_init (prefwin); @@ -1078,7 +1081,13 @@ on_convert8to16_toggled (GtkToggleButton *togglebutton, deadbeef->sendmessage (DB_EV_CONFIGCHANGED, 0, 0, 0); } - +void +on_convert16to24_toggled (GtkToggleButton *togglebutton, + gpointer user_data) +{ + deadbeef->conf_set_int ("streamer.16_to_24", gtk_toggle_button_get_active (togglebutton)); + deadbeef->sendmessage (DB_EV_CONFIGCHANGED, 0, 0, 0); +} void on_useragent_changed (GtkEditable *editable, diff --git a/streamer.c b/streamer.c index 50ab9bfc..fe655d07 100644 --- a/streamer.c +++ b/streamer.c @@ -80,6 +80,8 @@ static int dsp_on = 0; static int autoconv_8_to_16 = 1; +static int autoconv_16_to_24 = 0; + static int streaming_terminate; // buffer up to 3 seconds at 44100Hz stereo @@ -1976,6 +1978,11 @@ streamer_set_output_format (void) { fmt.bps = 16; } } + if (autoconv_16_to_24) { + if (fmt.bps == 16) { + fmt.bps = 24; + } + } output->setformat (&fmt); streamer_buffering = 1; if (playing && output->state () != OUTPUT_STATE_PLAYING) { @@ -2371,6 +2378,12 @@ streamer_configchanged (void) { formatchanged = 1; streamer_reset (1); } + int conf_autoconv_16_to_24 = conf_get_int ("streamer.16_to_24",0); + if (conf_autoconv_16_to_24 != autoconv_16_to_24) { + autoconv_16_to_24 = conf_autoconv_16_to_24; + formatchanged = 1; + streamer_reset (1); + } char mapstr[2048]; deadbeef->conf_get_str ("network.ctmapping", DDB_DEFAULT_CTMAPPING, mapstr, sizeof (mapstr)); -- cgit v1.2.3