summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--callbacks.c83
-rw-r--r--callbacks.h24
-rw-r--r--conf.c13
-rw-r--r--deadbeef.glade339
-rw-r--r--deadbeef.h2
-rw-r--r--interface.c172
-rw-r--r--main.c5
-rw-r--r--palsa.c70
-rw-r--r--palsa.h6
-rw-r--r--streamer.c24
-rw-r--r--streamer.h3
11 files changed, 600 insertions, 141 deletions
diff --git a/callbacks.c b/callbacks.c
index 3a0858e9..95801fda 100644
--- a/callbacks.c
+++ b/callbacks.c
@@ -1357,6 +1357,27 @@ on_add_audio_cd_activate (GtkMenuItem *menuitem,
static GtkWidget *prefwin;
+static char alsa_device_names[100][64];
+static int num_alsa_devices;
+
+static void
+gtk_enum_sound_callback (const char *name, const char *desc, void *userdata) {
+ if (num_alsa_devices >= 100) {
+ fprintf (stderr, "wtf!! more than 100 alsa devices??\n");
+ return;
+ }
+ GtkComboBox *combobox = GTK_COMBO_BOX (userdata);
+ gtk_combo_box_append_text (combobox, desc);
+
+ if (!strcmp (conf_get_str ("alsa_soundcard", "default"), name)) {
+ gtk_combo_box_set_active (combobox, num_alsa_devices);
+ }
+
+ strncpy (alsa_device_names[num_alsa_devices], name, 63);
+ alsa_device_names[num_alsa_devices][63] = 0;
+ num_alsa_devices++;
+}
+
void
on_preferences_activate (GtkMenuItem *menuitem,
gpointer user_data)
@@ -1365,19 +1386,18 @@ on_preferences_activate (GtkMenuItem *menuitem,
gtk_window_set_transient_for (GTK_WINDOW (w), GTK_WINDOW (mainwin));
// alsa_soundcard
- // FIXME: get list of soundcards from alsa
+
const char *s = conf_get_str ("alsa_soundcard", "default");
GtkComboBox *combobox = GTK_COMBO_BOX (lookup_widget (w, "pref_soundcard"));
- if (strcasecmp (s, "default")) {
- gtk_combo_box_append_text (combobox, s);
- gtk_combo_box_set_active (combobox, 1);
- }
- else {
+ gtk_combo_box_append_text (combobox, "Default Audio Device");
+ if (!strcmp (s, "default")) {
gtk_combo_box_set_active (combobox, 0);
}
+ num_alsa_devices = 1;
+ strcpy (alsa_device_names[0], "default");
+ palsa_enum_soundcards (gtk_enum_sound_callback, combobox);
// alsa resampling
-// gtk_entry_set_text (GTK_ENTRY (lookup_widget (w, "pref_samplerate")), conf_get_str ("samplerate", "48000"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (lookup_widget (w, "pref_alsa_resampling")), conf_get_int ("alsa.resample", 0));
// src_quality
@@ -1417,17 +1437,20 @@ void
on_pref_soundcard_changed (GtkComboBox *combobox,
gpointer user_data)
{
- char *text = gtk_combo_box_get_active_text (combobox);
- conf_set_str ("alsa_soundcard", text ? text : "default");
+ int active = gtk_combo_box_get_active (combobox);
+ if (active >= 0 && active < num_alsa_devices) {
+ conf_set_str ("alsa_soundcard", alsa_device_names[active]);
+ messagepump_push (M_CONFIGCHANGED, 0, 0, 0);
+ }
}
-
void
on_pref_alsa_resampling_clicked (GtkButton *button,
gpointer user_data)
{
int active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
conf_set_int ("alsa.resample", active);
+ messagepump_push (M_CONFIGCHANGED, 0, 0, 0);
}
@@ -1437,6 +1460,7 @@ on_pref_src_quality_changed (GtkComboBox *combobox,
{
int active = gtk_combo_box_get_active (combobox);
conf_set_int ("src_quality", active == -1 ? 2 : active);
+ messagepump_push (M_CONFIGCHANGED, 0, 0, 0);
}
@@ -1446,6 +1470,7 @@ on_pref_replaygain_mode_changed (GtkComboBox *combobox,
{
int active = gtk_combo_box_get_active (combobox);
conf_set_int ("replaygain_mode", active == -1 ? 0 : active);
+ messagepump_push (M_CONFIGCHANGED, 0, 0, 0);
}
void
@@ -1454,6 +1479,7 @@ on_pref_replaygain_scale_clicked (GtkButton *button,
{
int active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
conf_set_int ("replaygain_scale", active);
+ messagepump_push (M_CONFIGCHANGED, 0, 0, 0);
}
@@ -1463,6 +1489,7 @@ on_pref_close_send_to_tray_clicked (GtkButton *button,
{
int active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
conf_set_int ("close_send_to_tray", active);
+ messagepump_push (M_CONFIGCHANGED, 0, 0, 0);
}
@@ -1564,3 +1591,39 @@ on_remove_column_activate (GtkMenuItem *menuitem,
}
+
+void
+on_pref_alsa_freewhenstopped_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ int active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
+ conf_set_int ("alsa.freeonstop", active);
+}
+
+
+
+
+
+void
+on_pref_network_proxyaddress_changed (GtkEditable *editable,
+ gpointer user_data)
+{
+
+}
+
+
+void
+on_pref_network_enableproxy_clicked (GtkButton *button,
+ gpointer user_data)
+{
+
+}
+
+
+void
+on_pref_network_proxyport_changed (GtkEditable *editable,
+ gpointer user_data)
+{
+
+}
+
diff --git a/callbacks.h b/callbacks.h
index 0f00fe82..e557823f 100644
--- a/callbacks.h
+++ b/callbacks.h
@@ -634,3 +634,27 @@ on_remove_column_activate (GtkMenuItem *menuitem,
void
on_pref_alsa_resampling_clicked (GtkButton *button,
gpointer user_data);
+
+void
+on_pref_alsa_freewhenstopped_clicked (GtkButton *button,
+ gpointer user_data);
+
+void
+on_pref_soundcard_editing_done (GtkCellEditable *celleditable,
+ gpointer user_data);
+
+void
+on_pref_soundcard_changed (GtkComboBox *combobox,
+ gpointer user_data);
+
+void
+on_pref_network_proxyaddress_changed (GtkEditable *editable,
+ gpointer user_data);
+
+void
+on_pref_network_enableproxy_clicked (GtkButton *button,
+ gpointer user_data);
+
+void
+on_pref_network_proxyport_changed (GtkEditable *editable,
+ gpointer user_data);
diff --git a/conf.c b/conf.c
index 2a374193..378309b3 100644
--- a/conf.c
+++ b/conf.c
@@ -67,19 +67,6 @@ conf_load (void) {
*p = 0;
// new items are appended, to preserve order
conf_set_str (str, value);
-#if 0
- DB_conf_item_t *it = malloc (sizeof (DB_conf_item_t));
- memset (it, 0, sizeof (DB_conf_item_t));
- it->key = strdup (str);
- it->value = strdup (value);
- if (!tail) {
- conf_items = it;
- }
- else {
- tail->next = it;
- }
- tail = it;
-#endif
}
fclose (fp);
changed = 0;
diff --git a/deadbeef.glade b/deadbeef.glade
index d24847ac..4dcb1009 100644
--- a/deadbeef.glade
+++ b/deadbeef.glade
@@ -1327,7 +1327,7 @@
<widget class="GtkTable" id="table3">
<property name="border_width">3</property>
<property name="visible">True</property>
- <property name="n_rows">5</property>
+ <property name="n_rows">6</property>
<property name="n_columns">2</property>
<property name="homogeneous">False</property>
<property name="row_spacing">0</property>
@@ -1336,7 +1336,7 @@
<child>
<widget class="GtkLabel" id="label4">
<property name="visible">True</property>
- <property name="label" translatable="yes">Soundcard</property>
+ <property name="label" translatable="yes">Output device</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
@@ -1362,27 +1362,9 @@
</child>
<child>
- <widget class="GtkComboBoxEntry" id="pref_soundcard">
- <property name="visible">True</property>
- <property name="items" translatable="yes">default</property>
- <property name="add_tearoffs">False</property>
- <property name="has_frame">True</property>
- <property name="focus_on_click">True</property>
- <signal name="changed" handler="on_pref_soundcard_changed" last_modification_time="Sat, 10 Oct 2009 18:51:35 GMT"/>
- </widget>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">0</property>
- <property name="bottom_attach">1</property>
- <property name="y_options">fill</property>
- </packing>
- </child>
-
- <child>
<widget class="GtkLabel" id="label5">
<property name="visible">True</property>
- <property name="label" translatable="yes">Enable alsa (software) resampling</property>
+ <property name="label" translatable="yes">Software ALSA resampling</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
@@ -1410,7 +1392,7 @@
<child>
<widget class="GtkLabel" id="label6">
<property name="visible">True</property>
- <property name="label" translatable="yes">SRC quality</property>
+ <property name="label" translatable="yes">SRC quality (libsamplerate)</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
@@ -1466,7 +1448,7 @@
<child>
<widget class="GtkLabel" id="label9">
<property name="visible">True</property>
- <property name="label" translatable="yes">Apply replaygain peak scale</property>
+ <property name="label" translatable="yes">Replaygain peak scale</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
@@ -1492,6 +1474,56 @@
</child>
<child>
+ <widget class="GtkLabel" id="label15">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Release ALSA while stopped</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkCheckButton" id="pref_alsa_resampling">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes"></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="clicked" handler="on_pref_alsa_resampling_clicked" last_modification_time="Sat, 24 Oct 2009 16:50:34 GMT"/>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
<widget class="GtkCheckButton" id="pref_replaygain_scale">
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -1509,12 +1541,49 @@
<property name="right_attach">2</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
- <property name="x_options">expand</property>
<property name="y_options"></property>
</packing>
</child>
<child>
+ <widget class="GtkCheckButton" id="pref_alsa_freewhenstopped">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes"></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="clicked" handler="on_pref_alsa_freewhenstopped_clicked" last_modification_time="Sat, 07 Nov 2009 11:37:02 GMT"/>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkComboBox" id="pref_soundcard">
+ <property name="visible">True</property>
+ <property name="add_tearoffs">False</property>
+ <property name="focus_on_click">True</property>
+ <signal name="changed" handler="on_pref_soundcard_changed" last_modification_time="Sat, 07 Nov 2009 14:12:28 GMT"/>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
+ <property name="y_options">fill</property>
+ </packing>
+ </child>
+
+ <child>
<widget class="GtkComboBox" id="pref_src_quality">
<property name="visible">True</property>
<property name="items" translatable="yes">sinc_best_quality
@@ -1531,7 +1600,6 @@ linear</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
- <property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
</child>
@@ -1551,13 +1619,79 @@ Album</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
- <property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
</child>
+ </widget>
+ <packing>
+ <property name="tab_expand">False</property>
+ <property name="tab_fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="Sound">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Sound</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="type">tab</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkTable" id="table4">
+ <property name="border_width">3</property>
+ <property name="visible">True</property>
+ <property name="n_rows">1</property>
+ <property name="n_columns">2</property>
+ <property name="homogeneous">False</property>
+ <property name="row_spacing">0</property>
+ <property name="column_spacing">3</property>
<child>
- <widget class="GtkCheckButton" id="pref_alsa_resampling">
+ <widget class="GtkLabel" id="label7">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Close minimizes to tray</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkCheckButton" id="pref_close_send_to_tray">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes"></property>
@@ -1567,14 +1701,13 @@ Album</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
- <signal name="clicked" handler="on_pref_alsa_resampling_clicked" last_modification_time="Sat, 24 Oct 2009 16:50:34 GMT"/>
+ <signal name="clicked" handler="on_pref_close_send_to_tray_clicked" last_modification_time="Sat, 10 Oct 2009 18:52:15 GMT"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">expand</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
<property name="y_options"></property>
</packing>
</child>
@@ -1586,9 +1719,9 @@ Album</property>
</child>
<child>
- <widget class="GtkLabel" id="Sound">
+ <widget class="GtkLabel" id="label2">
<property name="visible">True</property>
- <property name="label" translatable="yes">Sound</property>
+ <property name="label" translatable="yes">GUI</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
@@ -1609,19 +1742,19 @@ Album</property>
</child>
<child>
- <widget class="GtkTable" id="table4">
+ <widget class="GtkTable" id="table6">
<property name="border_width">3</property>
<property name="visible">True</property>
- <property name="n_rows">1</property>
+ <property name="n_rows">3</property>
<property name="n_columns">2</property>
<property name="homogeneous">False</property>
<property name="row_spacing">0</property>
<property name="column_spacing">3</property>
<child>
- <widget class="GtkLabel" id="label7">
+ <widget class="GtkLabel" id="label17">
<property name="visible">True</property>
- <property name="label" translatable="yes">Close minimizes to tray</property>
+ <property name="label" translatable="yes">Enable proxy server</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
@@ -1647,7 +1780,57 @@ Album</property>
</child>
<child>
- <widget class="GtkCheckButton" id="pref_close_send_to_tray">
+ <widget class="GtkLabel" id="label18">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Proxy server address</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkEntry" id="pref_network_proxyaddress">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">True</property>
+ <property name="visibility">True</property>
+ <property name="max_length">0</property>
+ <property name="text" translatable="yes"></property>
+ <property name="has_frame">True</property>
+ <property name="invisible_char">•</property>
+ <property name="activates_default">False</property>
+ <signal name="changed" handler="on_pref_network_proxyaddress_changed" last_modification_time="Sat, 07 Nov 2009 15:13:12 GMT"/>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkCheckButton" id="pref_network_enableproxy">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes"></property>
@@ -1657,14 +1840,64 @@ Album</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
- <signal name="clicked" handler="on_pref_close_send_to_tray_clicked" last_modification_time="Sat, 10 Oct 2009 18:52:15 GMT"/>
+ <signal name="clicked" handler="on_pref_network_enableproxy_clicked" last_modification_time="Sat, 07 Nov 2009 15:12:34 GMT"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
- <property name="x_options">expand</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label19">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Proxy server port</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkEntry" id="pref_network_proxyport">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">True</property>
+ <property name="visibility">True</property>
+ <property name="max_length">0</property>
+ <property name="text" translatable="yes"></property>
+ <property name="has_frame">True</property>
+ <property name="invisible_char">•</property>
+ <property name="activates_default">False</property>
+ <signal name="changed" handler="on_pref_network_proxyport_changed" last_modification_time="Sat, 07 Nov 2009 15:13:18 GMT"/>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
<property name="y_options"></property>
</packing>
</child>
@@ -1676,9 +1909,9 @@ Album</property>
</child>
<child>
- <widget class="GtkLabel" id="label2">
+ <widget class="GtkLabel" id="label16">
<property name="visible">True</property>
- <property name="label" translatable="yes">GUI</property>
+ <property name="label" translatable="yes">Network</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
@@ -1738,7 +1971,7 @@ Album</property>
<widget class="GtkTable" id="table5">
<property name="width_request">400</property>
<property name="visible">True</property>
- <property name="n_rows">5</property>
+ <property name="n_rows">4</property>
<property name="n_columns">2</property>
<property name="homogeneous">False</property>
<property name="row_spacing">0</property>
@@ -1939,26 +2172,6 @@ Album</property>
<property name="y_options"></property>
</packing>
</child>
-
- <child>
- <widget class="GtkButton" id="pref_plugin_configure">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label" translatable="yes">Configure</property>
- <property name="use_underline">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <signal name="clicked" handler="on_pref_plugin_configure_activate" last_modification_time="Sat, 10 Oct 2009 18:51:12 GMT"/>
- </widget>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">4</property>
- <property name="bottom_attach">5</property>
- <property name="x_options"></property>
- <property name="y_options"></property>
- </packing>
- </child>
</widget>
<packing>
<property name="shrink">True</property>
diff --git a/deadbeef.h b/deadbeef.h
index 51f512dc..20fccd5d 100644
--- a/deadbeef.h
+++ b/deadbeef.h
@@ -115,6 +115,7 @@ enum {
DB_EV_SONGSTARTED = 2, // triggers when song started playing (for scrobblers and such)
DB_EV_SONGFINISHED = 3, // triggers when song finished playing (for scrobblers and such)
DB_EV_TRACKDELETED = 4, // triggers when track is to be deleted from playlist
+ DB_EV_CONFIGCHANGED = 5, // configuration option changed
DB_EV_MAX
};
@@ -149,6 +150,7 @@ enum {
M_PLAYLISTREFRESH,
M_REINIT_SOUND,
M_TRACKCHANGED, // p1=tracknumber
+ M_CONFIGCHANGED, // no arguments
};
// typecasting macros
diff --git a/interface.c b/interface.c
index 53597b89..849c4c2a 100644
--- a/interface.c
+++ b/interface.c
@@ -1145,20 +1145,30 @@ create_prefwin (void)
GtkWidget *notebook2;
GtkWidget *table3;
GtkWidget *label4;
- GtkWidget *pref_soundcard;
GtkWidget *label5;
GtkWidget *label6;
GtkWidget *label8;
GtkWidget *label9;
+ GtkWidget *label15;
+ GtkWidget *pref_alsa_resampling;
GtkWidget *pref_replaygain_scale;
+ GtkWidget *pref_alsa_freewhenstopped;
+ GtkWidget *pref_soundcard;
GtkWidget *pref_src_quality;
GtkWidget *pref_replaygain_mode;
- GtkWidget *pref_alsa_resampling;
GtkWidget *Sound;
GtkWidget *table4;
GtkWidget *label7;
GtkWidget *pref_close_send_to_tray;
GtkWidget *label2;
+ GtkWidget *table6;
+ GtkWidget *label17;
+ GtkWidget *label18;
+ GtkWidget *pref_network_proxyaddress;
+ GtkWidget *pref_network_enableproxy;
+ GtkWidget *label19;
+ GtkWidget *pref_network_proxyport;
+ GtkWidget *label16;
GtkWidget *hpaned1;
GtkWidget *scrolledwindow2;
GtkWidget *pref_pluginlist;
@@ -1171,7 +1181,6 @@ create_prefwin (void)
GtkWidget *pref_plugin_author;
GtkWidget *pref_plugin_email;
GtkWidget *pref_plugin_website;
- GtkWidget *pref_plugin_configure;
GtkWidget *label3;
prefwin = gtk_window_new (GTK_WINDOW_TOPLEVEL);
@@ -1183,34 +1192,27 @@ create_prefwin (void)
gtk_widget_show (notebook2);
gtk_container_add (GTK_CONTAINER (prefwin), notebook2);
- table3 = gtk_table_new (5, 2, FALSE);
+ table3 = gtk_table_new (6, 2, FALSE);
gtk_widget_show (table3);
gtk_container_add (GTK_CONTAINER (notebook2), table3);
gtk_container_set_border_width (GTK_CONTAINER (table3), 3);
gtk_table_set_col_spacings (GTK_TABLE (table3), 3);
- label4 = gtk_label_new ("Soundcard");
+ label4 = gtk_label_new ("Output device");
gtk_widget_show (label4);
gtk_table_attach (GTK_TABLE (table3), label4, 0, 1, 0, 1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment (GTK_MISC (label4), 0, 0.5);
- pref_soundcard = gtk_combo_box_entry_new_text ();
- gtk_widget_show (pref_soundcard);
- gtk_table_attach (GTK_TABLE (table3), pref_soundcard, 1, 2, 0, 1,
- (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
- (GtkAttachOptions) (GTK_FILL), 0, 0);
- gtk_combo_box_append_text (GTK_COMBO_BOX (pref_soundcard), "default");
-
- label5 = gtk_label_new ("Enable alsa (software) resampling");
+ label5 = gtk_label_new ("Software ALSA resampling");
gtk_widget_show (label5);
gtk_table_attach (GTK_TABLE (table3), label5, 0, 1, 1, 2,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment (GTK_MISC (label5), 0, 0.5);
- label6 = gtk_label_new ("SRC quality");
+ label6 = gtk_label_new ("SRC quality (libsamplerate)");
gtk_widget_show (label6);
gtk_table_attach (GTK_TABLE (table3), label6, 0, 1, 2, 3,
(GtkAttachOptions) (GTK_FILL),
@@ -1224,23 +1226,48 @@ create_prefwin (void)
(GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment (GTK_MISC (label8), 0, 0.5);
- label9 = gtk_label_new ("Apply replaygain peak scale");
+ label9 = gtk_label_new ("Replaygain peak scale");
gtk_widget_show (label9);
gtk_table_attach (GTK_TABLE (table3), label9, 0, 1, 4, 5,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment (GTK_MISC (label9), 0, 0.5);
+ label15 = gtk_label_new ("Release ALSA while stopped");
+ gtk_widget_show (label15);
+ gtk_table_attach (GTK_TABLE (table3), label15, 0, 1, 5, 6,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_misc_set_alignment (GTK_MISC (label15), 0, 0.5);
+
+ pref_alsa_resampling = gtk_check_button_new_with_mnemonic ("");
+ gtk_widget_show (pref_alsa_resampling);
+ gtk_table_attach (GTK_TABLE (table3), pref_alsa_resampling, 1, 2, 1, 2,
+ (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+
pref_replaygain_scale = gtk_check_button_new_with_mnemonic ("");
gtk_widget_show (pref_replaygain_scale);
gtk_table_attach (GTK_TABLE (table3), pref_replaygain_scale, 1, 2, 4, 5,
- (GtkAttachOptions) (GTK_EXPAND),
+ (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
+ pref_alsa_freewhenstopped = gtk_check_button_new_with_mnemonic ("");
+ gtk_widget_show (pref_alsa_freewhenstopped);
+ gtk_table_attach (GTK_TABLE (table3), pref_alsa_freewhenstopped, 1, 2, 5, 6,
+ (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+
+ pref_soundcard = gtk_combo_box_new_text ();
+ gtk_widget_show (pref_soundcard);
+ gtk_table_attach (GTK_TABLE (table3), pref_soundcard, 1, 2, 0, 1,
+ (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+ (GtkAttachOptions) (GTK_FILL), 0, 0);
+
pref_src_quality = gtk_combo_box_new_text ();
gtk_widget_show (pref_src_quality);
gtk_table_attach (GTK_TABLE (table3), pref_src_quality, 1, 2, 2, 3,
- (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
(GtkAttachOptions) (GTK_FILL), 0, 0);
gtk_combo_box_append_text (GTK_COMBO_BOX (pref_src_quality), "sinc_best_quality");
gtk_combo_box_append_text (GTK_COMBO_BOX (pref_src_quality), "sinc_medium_quality");
@@ -1251,18 +1278,12 @@ create_prefwin (void)
pref_replaygain_mode = gtk_combo_box_new_text ();
gtk_widget_show (pref_replaygain_mode);
gtk_table_attach (GTK_TABLE (table3), pref_replaygain_mode, 1, 2, 3, 4,
- (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
(GtkAttachOptions) (GTK_FILL), 0, 0);
gtk_combo_box_append_text (GTK_COMBO_BOX (pref_replaygain_mode), "Disable");
gtk_combo_box_append_text (GTK_COMBO_BOX (pref_replaygain_mode), "Track");
gtk_combo_box_append_text (GTK_COMBO_BOX (pref_replaygain_mode), "Album");
- pref_alsa_resampling = gtk_check_button_new_with_mnemonic ("");
- gtk_widget_show (pref_alsa_resampling);
- gtk_table_attach (GTK_TABLE (table3), pref_alsa_resampling, 1, 2, 1, 2,
- (GtkAttachOptions) (GTK_EXPAND),
- (GtkAttachOptions) (0), 0, 0);
-
Sound = gtk_label_new ("Sound");
gtk_widget_show (Sound);
gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook2), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook2), 0), Sound);
@@ -1283,13 +1304,64 @@ create_prefwin (void)
pref_close_send_to_tray = gtk_check_button_new_with_mnemonic ("");
gtk_widget_show (pref_close_send_to_tray);
gtk_table_attach (GTK_TABLE (table4), pref_close_send_to_tray, 1, 2, 0, 1,
- (GtkAttachOptions) (GTK_EXPAND),
+ (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
label2 = gtk_label_new ("GUI");
gtk_widget_show (label2);
gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook2), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook2), 1), label2);
+ table6 = gtk_table_new (3, 2, FALSE);
+ gtk_widget_show (table6);
+ gtk_container_add (GTK_CONTAINER (notebook2), table6);
+ gtk_container_set_border_width (GTK_CONTAINER (table6), 3);
+ gtk_table_set_col_spacings (GTK_TABLE (table6), 3);
+
+ label17 = gtk_label_new ("Enable proxy server");
+ gtk_widget_show (label17);
+ gtk_table_attach (GTK_TABLE (table6), label17, 0, 1, 0, 1,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_misc_set_alignment (GTK_MISC (label17), 0, 0.5);
+
+ label18 = gtk_label_new ("Proxy server address");
+ gtk_widget_show (label18);
+ gtk_table_attach (GTK_TABLE (table6), label18, 0, 1, 1, 2,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_misc_set_alignment (GTK_MISC (label18), 0, 0.5);
+
+ pref_network_proxyaddress = gtk_entry_new ();
+ gtk_widget_show (pref_network_proxyaddress);
+ gtk_table_attach (GTK_TABLE (table6), pref_network_proxyaddress, 1, 2, 1, 2,
+ (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_entry_set_invisible_char (GTK_ENTRY (pref_network_proxyaddress), 8226);
+
+ pref_network_enableproxy = gtk_check_button_new_with_mnemonic ("");
+ gtk_widget_show (pref_network_enableproxy);
+ gtk_table_attach (GTK_TABLE (table6), pref_network_enableproxy, 1, 2, 0, 1,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+
+ label19 = gtk_label_new ("Proxy server port");
+ gtk_widget_show (label19);
+ gtk_table_attach (GTK_TABLE (table6), label19, 0, 1, 2, 3,
+ (GtkAttachOptions) (GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_misc_set_alignment (GTK_MISC (label19), 0, 0.5);
+
+ pref_network_proxyport = gtk_entry_new ();
+ gtk_widget_show (pref_network_proxyport);
+ gtk_table_attach (GTK_TABLE (table6), pref_network_proxyport, 1, 2, 2, 3,
+ (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+ (GtkAttachOptions) (0), 0, 0);
+ gtk_entry_set_invisible_char (GTK_ENTRY (pref_network_proxyport), 8226);
+
+ label16 = gtk_label_new ("Network");
+ gtk_widget_show (label16);
+ gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook2), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook2), 2), label16);
+
hpaned1 = gtk_hpaned_new ();
gtk_widget_show (hpaned1);
gtk_container_add (GTK_CONTAINER (notebook2), hpaned1);
@@ -1305,7 +1377,7 @@ create_prefwin (void)
gtk_widget_show (pref_pluginlist);
gtk_container_add (GTK_CONTAINER (scrolledwindow2), pref_pluginlist);
- table5 = gtk_table_new (5, 2, FALSE);
+ table5 = gtk_table_new (4, 2, FALSE);
gtk_widget_show (table5);
gtk_paned_pack2 (GTK_PANED (hpaned1), table5, TRUE, TRUE);
gtk_widget_set_size_request (table5, 400, -1);
@@ -1370,60 +1442,73 @@ create_prefwin (void)
gtk_editable_set_editable (GTK_EDITABLE (pref_plugin_website), FALSE);
gtk_entry_set_invisible_char (GTK_ENTRY (pref_plugin_website), 9679);
- pref_plugin_configure = gtk_button_new_with_mnemonic ("Configure");
- gtk_widget_show (pref_plugin_configure);
- gtk_table_attach (GTK_TABLE (table5), pref_plugin_configure, 1, 2, 4, 5,
- (GtkAttachOptions) (0),
- (GtkAttachOptions) (0), 0, 0);
-
label3 = gtk_label_new ("Plugins");
gtk_widget_show (label3);
- gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook2), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook2), 2), label3);
+ gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook2), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook2), 3), label3);
- g_signal_connect ((gpointer) pref_soundcard, "changed",
- G_CALLBACK (on_pref_soundcard_changed),
+ g_signal_connect ((gpointer) pref_alsa_resampling, "clicked",
+ G_CALLBACK (on_pref_alsa_resampling_clicked),
NULL);
g_signal_connect ((gpointer) pref_replaygain_scale, "clicked",
G_CALLBACK (on_pref_replaygain_scale_clicked),
NULL);
+ g_signal_connect ((gpointer) pref_alsa_freewhenstopped, "clicked",
+ G_CALLBACK (on_pref_alsa_freewhenstopped_clicked),
+ NULL);
+ g_signal_connect ((gpointer) pref_soundcard, "changed",
+ G_CALLBACK (on_pref_soundcard_changed),
+ NULL);
g_signal_connect ((gpointer) pref_src_quality, "changed",
G_CALLBACK (on_pref_src_quality_changed),
NULL);
g_signal_connect ((gpointer) pref_replaygain_mode, "changed",
G_CALLBACK (on_pref_replaygain_mode_changed),
NULL);
- g_signal_connect ((gpointer) pref_alsa_resampling, "clicked",
- G_CALLBACK (on_pref_alsa_resampling_clicked),
- NULL);
g_signal_connect ((gpointer) pref_close_send_to_tray, "clicked",
G_CALLBACK (on_pref_close_send_to_tray_clicked),
NULL);
+ g_signal_connect ((gpointer) pref_network_proxyaddress, "changed",
+ G_CALLBACK (on_pref_network_proxyaddress_changed),
+ NULL);
+ g_signal_connect ((gpointer) pref_network_enableproxy, "clicked",
+ G_CALLBACK (on_pref_network_enableproxy_clicked),
+ NULL);
+ g_signal_connect ((gpointer) pref_network_proxyport, "changed",
+ G_CALLBACK (on_pref_network_proxyport_changed),
+ NULL);
g_signal_connect ((gpointer) pref_pluginlist, "cursor_changed",
G_CALLBACK (on_pref_pluginlist_cursor_changed),
NULL);
- g_signal_connect ((gpointer) pref_plugin_configure, "clicked",
- G_CALLBACK (on_pref_plugin_configure_activate),
- NULL);
/* Store pointers to all widgets, for use by lookup_widget(). */
GLADE_HOOKUP_OBJECT_NO_REF (prefwin, prefwin, "prefwin");
GLADE_HOOKUP_OBJECT (prefwin, notebook2, "notebook2");
GLADE_HOOKUP_OBJECT (prefwin, table3, "table3");
GLADE_HOOKUP_OBJECT (prefwin, label4, "label4");
- GLADE_HOOKUP_OBJECT (prefwin, pref_soundcard, "pref_soundcard");
GLADE_HOOKUP_OBJECT (prefwin, label5, "label5");
GLADE_HOOKUP_OBJECT (prefwin, label6, "label6");
GLADE_HOOKUP_OBJECT (prefwin, label8, "label8");
GLADE_HOOKUP_OBJECT (prefwin, label9, "label9");
+ GLADE_HOOKUP_OBJECT (prefwin, label15, "label15");
+ GLADE_HOOKUP_OBJECT (prefwin, pref_alsa_resampling, "pref_alsa_resampling");
GLADE_HOOKUP_OBJECT (prefwin, pref_replaygain_scale, "pref_replaygain_scale");
+ GLADE_HOOKUP_OBJECT (prefwin, pref_alsa_freewhenstopped, "pref_alsa_freewhenstopped");
+ GLADE_HOOKUP_OBJECT (prefwin, pref_soundcard, "pref_soundcard");
GLADE_HOOKUP_OBJECT (prefwin, pref_src_quality, "pref_src_quality");
GLADE_HOOKUP_OBJECT (prefwin, pref_replaygain_mode, "pref_replaygain_mode");
- GLADE_HOOKUP_OBJECT (prefwin, pref_alsa_resampling, "pref_alsa_resampling");
GLADE_HOOKUP_OBJECT (prefwin, Sound, "Sound");
GLADE_HOOKUP_OBJECT (prefwin, table4, "table4");
GLADE_HOOKUP_OBJECT (prefwin, label7, "label7");
GLADE_HOOKUP_OBJECT (prefwin, pref_close_send_to_tray, "pref_close_send_to_tray");
GLADE_HOOKUP_OBJECT (prefwin, label2, "label2");
+ GLADE_HOOKUP_OBJECT (prefwin, table6, "table6");
+ GLADE_HOOKUP_OBJECT (prefwin, label17, "label17");
+ GLADE_HOOKUP_OBJECT (prefwin, label18, "label18");
+ GLADE_HOOKUP_OBJECT (prefwin, pref_network_proxyaddress, "pref_network_proxyaddress");
+ GLADE_HOOKUP_OBJECT (prefwin, pref_network_enableproxy, "pref_network_enableproxy");
+ GLADE_HOOKUP_OBJECT (prefwin, label19, "label19");
+ GLADE_HOOKUP_OBJECT (prefwin, pref_network_proxyport, "pref_network_proxyport");
+ GLADE_HOOKUP_OBJECT (prefwin, label16, "label16");
GLADE_HOOKUP_OBJECT (prefwin, hpaned1, "hpaned1");
GLADE_HOOKUP_OBJECT (prefwin, scrolledwindow2, "scrolledwindow2");
GLADE_HOOKUP_OBJECT (prefwin, pref_pluginlist, "pref_pluginlist");
@@ -1436,7 +1521,6 @@ create_prefwin (void)
GLADE_HOOKUP_OBJECT (prefwin, pref_plugin_author, "pref_plugin_author");
GLADE_HOOKUP_OBJECT (prefwin, pref_plugin_email, "pref_plugin_email");
GLADE_HOOKUP_OBJECT (prefwin, pref_plugin_website, "pref_plugin_website");
- GLADE_HOOKUP_OBJECT (prefwin, pref_plugin_configure, "pref_plugin_configure");
GLADE_HOOKUP_OBJECT (prefwin, label3, "label3");
return prefwin;
diff --git a/main.c b/main.c
index 65d5d0d9..13967195 100644
--- a/main.c
+++ b/main.c
@@ -474,6 +474,11 @@ player_thread (uintptr_t ctx) {
search_refresh ();
GDK_THREADS_LEAVE();
break;
+ case M_CONFIGCHANGED:
+ palsa_configchanged ();
+ streamer_configchanged ();
+ plug_trigger_event (DB_EV_CONFIGCHANGED, 0);
+ break;
}
}
usleep(50000);
diff --git a/palsa.c b/palsa.c
index f7061359..80ec577b 100644
--- a/palsa.c
+++ b/palsa.c
@@ -42,6 +42,9 @@ static int state; // 0 = stopped, 1 = playing, 2 = pause
static uintptr_t mutex;
static intptr_t alsa_tid;
+static int conf_alsa_resample = 0;
+static char conf_alsa_soundcard[100] = "default";
+
static void
palsa_callback (char *stream, int len);
@@ -51,7 +54,7 @@ palsa_thread (uintptr_t context);
static int
palsa_set_hw_params (int samplerate) {
snd_pcm_hw_params_t *hw_params = NULL;
- int alsa_resample = conf_get_int ("alsa.resample", 0);
+// int alsa_resample = conf_get_int ("alsa.resample", 0);
int err = 0;
if ((err = snd_pcm_hw_params_malloc (&hw_params)) < 0) {
@@ -85,12 +88,12 @@ palsa_set_hw_params (int samplerate) {
}
snd_pcm_hw_params_get_format (hw_params, &fmt);
- printf ("chosen sample format: %04Xh\n", (int)fmt);
+ trace ("chosen sample format: %04Xh\n", (int)fmt);
int val = samplerate;
int ret = 0;
- if ((err = snd_pcm_hw_params_set_rate_resample (audio, hw_params, alsa_resample)) < 0) {
+ if ((err = snd_pcm_hw_params_set_rate_resample (audio, hw_params, conf_alsa_resample)) < 0) {
trace ("cannot setup resampling (%s)\n",
snd_strerror (err));
goto error;
@@ -102,7 +105,7 @@ palsa_set_hw_params (int samplerate) {
goto error;
}
alsa_rate = val;
- printf ("chosen samplerate: %d Hz\n", alsa_rate);
+ trace ("chosen samplerate: %d Hz\n", alsa_rate);
if ((err = snd_pcm_hw_params_set_channels (audio, hw_params, 2)) < 0) {
trace ("cannot set channel count (%s)\n",
@@ -112,7 +115,7 @@ palsa_set_hw_params (int samplerate) {
int nchan;
snd_pcm_hw_params_get_channels (hw_params, &nchan);
- printf ("alsa channels: %d\n", nchan);
+ trace ("alsa channels: %d\n", nchan);
unsigned int buffer_time = 500000;
int dir;
@@ -144,9 +147,16 @@ error:
int
palsa_init (void) {
int err;
+
+ // get and cache conf variables
+ strcpy (conf_alsa_soundcard, conf_get_str ("alsa_soundcard", "default"));
+ conf_alsa_resample = conf_get_int ("alsa.resample", 0);
+ trace ("alsa_soundcard: %s\n", conf_alsa_soundcard);
+ trace ("alsa.resample: %d\n", conf_alsa_resample);
+
snd_pcm_sw_params_t *sw_params = NULL;
state = 0;
- const char *conf_alsa_soundcard = conf_get_str ("alsa_soundcard", "default");
+ //const char *conf_alsa_soundcard = conf_get_str ("alsa_soundcard", "default");
if ((err = snd_pcm_open (&audio, conf_alsa_soundcard, SND_PCM_STREAM_PLAYBACK, 0))) {
trace ("could not open audio device (%s)\n",
snd_strerror (err));
@@ -226,6 +236,9 @@ open_error:
int
palsa_change_rate (int rate) {
+ if (!audio) {
+ return 0;
+ }
if (rate == alsa_rate) {
trace ("palsa_change_rate: same rate (%d), ignored\n", rate);
return rate;
@@ -262,6 +275,9 @@ palsa_free (void) {
static void
palsa_hw_pause (int pause) {
+ if (!audio) {
+ return;
+ }
if (state == 0) {
return;
}
@@ -306,8 +322,7 @@ palsa_stop (void) {
return 0;
}
state = 0;
- int freeonstop = conf_get_int ("alsa.freeonstop", 0);
- if (freeonstop) {
+ if (conf_get_int ("alsa.freeonstop", 0)) {
palsa_free ();
}
else {
@@ -466,3 +481,42 @@ palsa_callback (char *stream, int len) {
memset (stream + bytesread, 0, len-bytesread);
}
}
+
+void
+palsa_configchanged (void) {
+ int alsa_resample = conf_get_int ("alsa.resample", 0);
+ const char *alsa_soundcard = conf_get_str ("alsa_soundcard", "default");
+ if (alsa_resample != conf_alsa_resample
+ || strcmp (alsa_soundcard, conf_alsa_soundcard)) {
+ messagepump_push (M_REINIT_SOUND, 0, 0, 0);
+ }
+}
+
+// derived from alsa-utils/aplay.c
+void
+palsa_enum_soundcards (void (*callback)(const char *name, const char *desc, void *), void *userdata) {
+ void **hints, **n;
+ char *name, *descr, *descr1, *io;
+ const char *filter = "Output";
+ if (snd_device_name_hint(-1, "pcm", &hints) < 0)
+ return;
+ n = hints;
+ while (*n != NULL) {
+ name = snd_device_name_get_hint(*n, "NAME");
+ descr = snd_device_name_get_hint(*n, "DESC");
+ io = snd_device_name_get_hint(*n, "IOID");
+ if (io == NULL || !strcmp(io, filter)) {
+ if (name && descr && callback) {
+ callback (name, descr, userdata);
+ }
+ }
+ if (name != NULL)
+ free(name);
+ if (descr != NULL)
+ free(descr);
+ if (io != NULL)
+ free(io);
+ n++;
+ }
+ snd_device_name_free_hint(hints);
+}
diff --git a/palsa.h b/palsa.h
index 292a1d4f..2896702a 100644
--- a/palsa.h
+++ b/palsa.h
@@ -48,5 +48,11 @@ palsa_unpause (void);
int
palsa_get_rate (void);
+void
+palsa_configchanged (void);
+
+void
+palsa_enum_soundcards (void (*callback)(const char *name, const char *desc, void*), void *userdata);
+
#endif // __PALSA_H
diff --git a/streamer.c b/streamer.c
index b4dd2d21..2d7cd377 100644
--- a/streamer.c
+++ b/streamer.c
@@ -40,6 +40,7 @@
#define trace(fmt,...)
static intptr_t streamer_tid;
+static int src_quality;
static SRC_STATE *src;
static SRC_DATA srcdata;
static int codecleft;
@@ -422,9 +423,8 @@ streamer_thread (uintptr_t ctx) {
int
streamer_init (void) {
mutex = mutex_create ();
-// src = src_new (SRC_SINC_BEST_QUALITY, 2, NULL);
-// src = src_new (SRC_LINEAR, 2, NULL);
- src = src_new (conf_get_int ("src_quality", 2), 2, NULL);
+ src_quality = conf_get_int ("src_quality", 2);
+ src = src_new (src_quality, 2, NULL);
conf_replaygain_mode = conf_get_int ("replaygain_mode", 0);
conf_replaygain_scale = conf_get_int ("replaygain_scale", 1);
if (!src) {
@@ -831,3 +831,21 @@ streamer_is_buffering (void) {
return 0;
}
}
+
+void
+streamer_configchanged (void) {
+ conf_replaygain_mode = conf_get_int ("replaygain_mode", 0);
+ conf_replaygain_scale = conf_get_int ("replaygain_scale", 1);
+ int q = conf_get_int ("src_quality", 2);
+ if (q != src_quality && q >= SRC_SINC_BEST_QUALITY && q <= SRC_LINEAR) {
+ fprintf (stderr, "changing src_quality from %d to %d\n", src_quality, q);
+ src_quality = q;
+ streamer_lock ();
+ if (src) {
+ src_delete (src);
+ src = NULL;
+ }
+ src = src_new (src_quality, 2, NULL);
+ streamer_unlock ();
+ }
+}
diff --git a/streamer.h b/streamer.h
index 5284380a..9544c755 100644
--- a/streamer.h
+++ b/streamer.h
@@ -75,4 +75,7 @@ streamer_song_removed_notify (playItem_t *it);
playItem_t *
streamer_get_streaming_track (void);
+void
+streamer_configchanged (void);
+
#endif // __STREAMER_H