[vlc-commits] PulseAudio: implement and fix changing device while not playing
Rémi Denis-Courmont
git at videolan.org
Wed Jan 16 17:55:47 CET 2013
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Jan 16 18:53:59 2013 +0200| [9f27fbd9b8d10808814d06b1e33e954b4eb85e7e] | committer: Rémi Denis-Courmont
PulseAudio: implement and fix changing device while not playing
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9f27fbd9b8d10808814d06b1e33e954b4eb85e7e
---
modules/audio_output/pulse.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/modules/audio_output/pulse.c b/modules/audio_output/pulse.c
index 8f2fb6e..ffc360d 100644
--- a/modules/audio_output/pulse.c
+++ b/modules/audio_output/pulse.c
@@ -75,6 +75,7 @@ struct aout_sys_t
mtime_t first_pts; /**< Play time of buffer start */
mtime_t paused; /**< Time when (last) paused */
+ char *sink_force; /**< Forced sink name (stream must be NULL) */
struct sink *sinks; /**< Locally-cached list of sinks */
};
@@ -681,6 +682,15 @@ static int SinksList(audio_output_t *aout, char ***namesp, char ***descsp)
static int StreamMove(audio_output_t *aout, const char *name)
{
aout_sys_t *sys = aout->sys;
+
+ if (sys->stream == NULL)
+ {
+ msg_Dbg(aout, "will connect to sink %s", name);
+ free(sys->sink_force);
+ sys->sink_force = strdup(name);
+ return 0;
+ }
+
pa_operation *op;
uint32_t idx = pa_stream_get_index(sys->stream);
@@ -694,7 +704,7 @@ static int StreamMove(audio_output_t *aout, const char *name)
vlc_pa_error(aout, "cannot move sink input", sys->context);
pa_threaded_mainloop_unlock(sys->mainloop);
- return (op != NULL) ? VLC_SUCCESS : VLC_EGENERIC;
+ return (op != NULL) ? 0 : -1;
}
static void Stop(audio_output_t *);
@@ -896,11 +906,14 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
pa_stream_set_suspended_callback(s, stream_suspended_cb, aout);
pa_stream_set_underflow_callback(s, stream_underflow_cb, aout);
- if (pa_stream_connect_playback(s, NULL, &attr, flags, NULL, NULL) < 0
+ if (pa_stream_connect_playback(s, sys->sink_force, &attr, flags, NULL,
+ NULL) < 0
|| stream_wait(s, sys->mainloop)) {
vlc_pa_error(aout, "stream connection failure", sys->context);
goto fail;
}
+ free(sys->sink_force);
+ sys->sink_force = NULL;
const struct pa_sample_spec *spec = pa_stream_get_sample_spec(s);
#if PA_CHECK_VERSION(1,0,0)
@@ -983,6 +996,7 @@ static int Open(vlc_object_t *obj)
}
sys->stream = NULL;
sys->context = ctx;
+ sys->sink_force = NULL;
sys->sinks = NULL;
aout->sys = sys;
@@ -1032,5 +1046,6 @@ static void Close(vlc_object_t *obj)
free(sink->description);
free(sink);
}
+ free(sys->sink_force);
free(sys);
}
More information about the vlc-commits
mailing list