Blob Blame History Raw
There is no callback feature in Audacious < 2.2 that moves the UI's volume
slider when external volume controls are used. When starting Audacious, the
Pulse Audio output plugin also doesn't connect to Pulse Audio to find out
the current volume. Hence stick to the default volume level and don't get
confused when trying to save/restore external volume levels.

diff -Nur audacious-plugins-fedora-2.1-orig/src/pulse_audio/pulse_audio.c audacious-plugins-fedora-2.1-pulseaudio/src/pulse_audio/pulse_audio.c
--- audacious-plugins-fedora-2.1-orig/src/pulse_audio/pulse_audio.c	2009-07-07 00:40:36.000000000 +0200
+++ audacious-plugins-fedora-2.1-pulseaudio/src/pulse_audio/pulse_audio.c	2009-11-30 14:37:06.000000000 +0100
@@ -177,7 +177,7 @@
     pa_cvolume v;
     int b = 0;
 
-    *l = *r = 100;
+    *l = *r = 50;
 
     if (connected) {
         pa_threaded_mainloop_lock(mainloop);
@@ -222,6 +222,9 @@
         pa_threaded_mainloop_lock(mainloop);
         CHECK_DEAD_GOTO(fail, 1);
     }
+    /* sanitize output volumes. */
+    l = CLAMP(l, 0, 100);
+    r = CLAMP(r, 0, 100);
 
     if (!volume_valid || volume.channels !=  1) {
         volume.values[0] = ((pa_volume_t) l * PA_VOLUME_NORM)/100;
@@ -613,12 +616,6 @@
     if (!pa_sample_spec_valid(&ss))
         return FALSE;
 
-    if (!volume_valid) {
-        pa_cvolume_reset(&volume, ss.channels);
-        volume_valid = 1;
-    } else if (volume.channels != ss.channels)
-        pa_cvolume_set(&volume, ss.channels, pa_cvolume_avg(&volume));
-
     if (!(mainloop = pa_threaded_mainloop_new())) {
         AUDDBG("Failed to allocate main loop");
         goto fail;
@@ -661,7 +658,8 @@
     pa_stream_set_write_callback(stream, stream_request_cb, NULL);
     pa_stream_set_latency_update_callback(stream, stream_latency_update_cb, NULL);
 
-    if (pa_stream_connect_playback(stream, NULL, NULL, PA_STREAM_INTERPOLATE_TIMING|PA_STREAM_AUTO_TIMING_UPDATE, &volume, NULL) < 0) {
+    /* Connect stream with sink and default volume */
+    if (pa_stream_connect_playback(stream, NULL, NULL, PA_STREAM_INTERPOLATE_TIMING|PA_STREAM_AUTO_TIMING_UPDATE, NULL, NULL) < 0) {
         AUDDBG("Failed to connect stream: %s", pa_strerror(pa_context_errno(context)));
         goto unlock_and_fail;
     }
@@ -693,22 +691,6 @@
 
     pa_operation_unref(o);
 
-    /* Now request the initial stream info */
-    if (!(o = pa_context_get_sink_input_info(context, pa_stream_get_index(stream), info_cb, NULL))) {
-        AUDDBG("pa_context_get_sink_input_info() failed: %s", pa_strerror(pa_context_errno(context)));
-        goto unlock_and_fail;
-    }
-
-    while (pa_operation_get_state(o) != PA_OPERATION_DONE) {
-        CHECK_DEAD_GOTO(fail, 1);
-        pa_threaded_mainloop_wait(mainloop);
-    }
-
-    if (!volume_valid) {
-        AUDDBG("pa_context_get_sink_input_info() failed: %s", pa_strerror(pa_context_errno(context)));
-        goto unlock_and_fail;
-    }
-
     do_trigger = 0;
     written = 0;
     time_offset_msec = 0;