From e858d98f4f6980cb07cae6166d3f85ba86a46963 Mon Sep 17 00:00:00 2001 From: reimar Date: Fri, 18 Dec 2009 20:22:39 +0000 Subject: Get rid of global volume variable, it is only used for temporary values. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30060 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libao2/ao_pulse.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'libao2') diff --git a/libao2/ao_pulse.c b/libao2/ao_pulse.c index b2fdcbb175..f113548c1e 100644 --- a/libao2/ao_pulse.c +++ b/libao2/ao_pulse.c @@ -49,9 +49,6 @@ static struct pa_context *context; /** Main event loop object */ static struct pa_threaded_mainloop *mainloop; -/** A temporary variable to store the current volume */ -static pa_cvolume volume; - static int broken_pause; LIBAO_EXTERN(pulse) @@ -144,6 +141,7 @@ static int init(int rate_hz, int channels, int format, int flags) { char *host = NULL; char *sink = NULL; char *version = pa_get_library_version(); + struct pa_cvolume volume; if (ao_subdevice) { devarg = strdup(ao_subdevice); @@ -350,13 +348,14 @@ static float get_delay(void) { * pa_context_get_sink_input_info() operation completes. Saves the * volume field of the specified structure to the global variable volume. */ static void info_func(struct pa_context *c, const struct pa_sink_input_info *i, int is_last, void *userdata) { + struct pa_cvolume *volume = userdata; if (is_last < 0) { GENERIC_ERR_MSG(context, "Failed to get sink input info"); return; } if (!i) return; - volume = i->volume; + *volume = i->volume; pa_threaded_mainloop_signal(mainloop, 0); } @@ -365,8 +364,9 @@ static int control(int cmd, void *arg) { case AOCONTROL_GET_VOLUME: { ao_control_vol_t *vol = arg; uint32_t devidx = pa_stream_get_index(stream); + struct pa_cvolume volume; pa_threaded_mainloop_lock(mainloop); - if (!waitop(pa_context_get_sink_input_info(context, devidx, info_func, NULL))) { + if (!waitop(pa_context_get_sink_input_info(context, devidx, info_func, &volume))) { GENERIC_ERR_MSG(context, "pa_stream_get_sink_input_info() failed"); return CONTROL_ERROR; } @@ -384,7 +384,9 @@ static int control(int cmd, void *arg) { case AOCONTROL_SET_VOLUME: { const ao_control_vol_t *vol = arg; pa_operation *o; + struct pa_cvolume volume; + pa_cvolume_reset(&volume, ao_data.channels); if (volume.channels != 2) pa_cvolume_set(&volume, volume.channels, (pa_volume_t)vol->left*PA_VOLUME_NORM/100); else { -- cgit v1.2.3 From b7fa147ee8020c0124f82353a2386877305bcb1f Mon Sep 17 00:00:00 2001 From: reimar Date: Fri, 18 Dec 2009 20:26:28 +0000 Subject: Allow pulseaudio to restore the previous volume on init instead of forcing to full volume. The old behaviour can be restored by using -volume 100. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30061 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libao2/ao_pulse.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'libao2') diff --git a/libao2/ao_pulse.c b/libao2/ao_pulse.c index f113548c1e..25a3a77941 100644 --- a/libao2/ao_pulse.c +++ b/libao2/ao_pulse.c @@ -141,7 +141,6 @@ static int init(int rate_hz, int channels, int format, int flags) { char *host = NULL; char *sink = NULL; char *version = pa_get_library_version(); - struct pa_cvolume volume; if (ao_subdevice) { devarg = strdup(ao_subdevice); @@ -187,8 +186,6 @@ static int init(int rate_hz, int channels, int format, int flags) { pa_channel_map_init_auto(&map, ss.channels, PA_CHANNEL_MAP_ALSA); ao_data.bps = pa_bytes_per_second(&ss); - pa_cvolume_reset(&volume, ss.channels); - if (!(mainloop = pa_threaded_mainloop_new())) { mp_msg(MSGT_AO, MSGL_ERR, "AO: [pulse] Failed to allocate main loop\n"); goto fail; @@ -222,7 +219,7 @@ static int init(int rate_hz, int channels, int format, int flags) { 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, sink, NULL, PA_STREAM_INTERPOLATE_TIMING|PA_STREAM_AUTO_TIMING_UPDATE, &volume, NULL) < 0) + if (pa_stream_connect_playback(stream, sink, NULL, PA_STREAM_INTERPOLATE_TIMING|PA_STREAM_AUTO_TIMING_UPDATE, NULL, NULL) < 0) goto unlock_and_fail; /* Wait until the stream is ready */ -- cgit v1.2.3 From cb7a098c81c2cd2191faa452d9f025da7a22e1bc Mon Sep 17 00:00:00 2001 From: reimar Date: Fri, 18 Dec 2009 20:27:35 +0000 Subject: Add a missing const, fixes a compiler warning. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30062 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libao2/ao_pulse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libao2') diff --git a/libao2/ao_pulse.c b/libao2/ao_pulse.c index 25a3a77941..a07bf31da0 100644 --- a/libao2/ao_pulse.c +++ b/libao2/ao_pulse.c @@ -140,7 +140,7 @@ static int init(int rate_hz, int channels, int format, int flags) { char *devarg = NULL; char *host = NULL; char *sink = NULL; - char *version = pa_get_library_version(); + const char *version = pa_get_library_version(); if (ao_subdevice) { devarg = strdup(ao_subdevice); -- cgit v1.2.3