From a70e65a61c0578ae1065318d99653bbc27e433c0 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sun, 12 Sep 2004 13:17:19 +0000 Subject: update to polypaudio 0.5 keep volume if not connected to polypaudio git-svn-id: file:///home/lennart/svn/public/xmms-pulse/trunk@19 ef929aba-56e2-0310-84e0-b7573d389508 --- configure.ac | 4 ++-- src/plugin.c | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 3db69df..124f6b4 100644 --- a/configure.ac +++ b/configure.ac @@ -47,10 +47,10 @@ ACX_PTHREAD if test -d ../polypaudio ; then POLYP_CFLAGS='-I$(top_srcdir)/../polypaudio' - POLYP_LIBS='-L$(top_srcdir)/../polypaudio/polyp -lpolyp-simple' + POLYP_LIBS='-L$(top_srcdir)/../polypaudio/polyp -lpolyp-0.5 -lpolyp-mainloop-0.5 -lpolyp-error-0.5' echo "*** Found polypaudio in ../polypaudio, using that version ***" else - PKG_CHECK_MODULES(POLYP, [ polyplib >= 0.4 ]) + PKG_CHECK_MODULES(POLYP, [ polyplib >= 0.5 ]) fi AC_SUBST(POLYP_LIBS) diff --git a/src/plugin.c b/src/plugin.c index 39420e4..1ee7d35 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -75,6 +75,7 @@ static size_t written = 0; static int do_trigger = 0, triggered = 0; static struct pa_sample_spec sample_spec; static int locked_by_thread = 0; +static pa_volume_t saved_volume = PA_VOLUME_NORM; /* This function is from xmms' core */ gint ctrlsocket_get_session_id(void); @@ -166,6 +167,7 @@ static void stream_state_callback(struct pa_stream *s, void *userdata) { break; case PA_STREAM_READY: assert(current_request && current_request->message == MESSAGE_OPEN); + pa_operation_unref(pa_context_set_sink_input_volume(context, pa_stream_get_index(s), current_request->volume, NULL, NULL)); pa_operation_unref(pa_context_get_sink_input_info(context, pa_stream_get_index(s), info_callback, NULL)); finish_request(1); break; @@ -221,7 +223,7 @@ static void latency_callback(struct pa_stream *s, const struct pa_latency_info* assert(s == stream && s); assert(current_request && current_request->message == MESSAGE_LATENCY); if (i) { - current_request->latency = i->buffer_usec + i->sink_usec; + current_request->latency = i->buffer_usec + i->sink_usec + i->transport_usec; current_request->value = i->playing; } finish_request(!!i); @@ -440,7 +442,7 @@ static void polyp_get_volume(int *l, int *r) { execute_request(&req); if (!req.success) { - *l = *r = 100; + *l = *r = (saved_volume*100)/PA_VOLUME_NORM; return; } @@ -454,6 +456,8 @@ void polyp_set_volume(int l, int r) { req.message = MESSAGE_SETVOLUME; req.volume = ((l>r?l:r)*PA_VOLUME_NORM)/100; execute_request(&req); + + saved_volume = req.volume; } static void polyp_pause(short b) { @@ -511,7 +515,7 @@ static int polyp_get_output_time(void) { return 0; t = polyp_get_written_time(); - ms = r.latency/1000; + ms = (int) r.latency/1000; return ms > t ? 0 : t-ms+100; } @@ -573,6 +577,7 @@ static int polyp_open(AFormat fmt, int rate, int nch) { start_thread(); r.message = MESSAGE_OPEN; + r.volume = saved_volume; execute_request(&r); if (!r.success) { -- cgit