[vlc-devel] [PATCH 1/2] PulseAudio: add stream event callback and handle "format-lost"
Rémi Denis-Courmont
remi at remlab.net
Mon Oct 3 20:08:22 CEST 2011
---
modules/audio_output/pulse.c | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/modules/audio_output/pulse.c b/modules/audio_output/pulse.c
index c3c0aa0..fc7cdb8 100644
--- a/modules/audio_output/pulse.c
+++ b/modules/audio_output/pulse.c
@@ -355,6 +355,24 @@ static void stream_state_cb(pa_stream *s, void *userdata)
(void) userdata;
}
+static void stream_event_cb(pa_stream *s, const char *name, pa_proplist *pl,
+ void *userdata)
+{
+ audio_output_t *aout = userdata;
+
+ /* FIXME: expose aout_Restart() directly */
+ if (!strcmp(name, "format-lost")) {
+ vlc_value_t dummy = { .i_int = 0 };
+
+ msg_Dbg (aout, "format lost");
+ aout_ChannelsRestart (VLC_OBJECT(aout), "audio-device",
+ dummy, dummy, NULL);
+ } else
+ msg_Warn (aout, "unhandled event %s", name);
+ (void) s;
+ (void) pl;
+}
+
static void stream_moved_cb(pa_stream *s, void *userdata)
{
audio_output_t *aout = userdata;
@@ -791,6 +809,7 @@ static int Open(vlc_object_t *obj)
}
sys->stream = s;
pa_stream_set_state_callback(s, stream_state_cb, NULL);
+ pa_stream_set_event_callback(s, stream_event_cb, aout);
pa_stream_set_latency_update_callback(s, stream_latency_cb, aout);
pa_stream_set_moved_callback(s, stream_moved_cb, aout);
pa_stream_set_overflow_callback(s, stream_overflow_cb, aout);
@@ -856,6 +875,7 @@ static void Close (vlc_object_t *obj)
/* Clear all callbacks */
pa_stream_set_state_callback(s, NULL, NULL);
+ pa_stream_set_event_callback(s, NULL, NULL);
pa_stream_set_latency_update_callback(s, NULL, NULL);
pa_stream_set_moved_callback(s, NULL, NULL);
pa_stream_set_overflow_callback(s, NULL, NULL);
--
1.7.6.3
More information about the vlc-devel
mailing list