From 6094bcffe4cca9c8acb8ef216a3ed354a9d2416b Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 4 Nov 2004 18:30:38 +0000 Subject: remove debug messages git-svn-id: file:///home/lennart/svn/public/gst-pulse/trunk@12 bb39ca4e-bce3-0310-b5d4-eea78a553289 --- src/polypsink.c | 123 ++++++++++++++++++++------------------------------------ 1 file changed, 43 insertions(+), 80 deletions(-) diff --git a/src/polypsink.c b/src/polypsink.c index 6376662..835b63c 100644 --- a/src/polypsink.c +++ b/src/polypsink.c @@ -1,3 +1,13 @@ +/* + * This sink plugin works, but has some room for improvements: + * + * - Export polypaudio's stream clock through gstreamer's API + * - Add support for querying latency information + * - Add a source for polypaudio + * + * Lennart Poettering, 2004 + */ + #include #include #include @@ -79,7 +89,6 @@ static void gst_polypsink_set_property (GObject *object, guint prop_id, const GV break; default: - g_message("Fehler!"); G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; } @@ -100,7 +109,6 @@ static void gst_polypsink_get_property(GObject *object, guint prop_id, GValue *v break; default: - g_message("Fehler!"); G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; } @@ -111,26 +119,18 @@ static GstElementStateReturn gst_polypsink_change_state(GstElement * element) { polypsink = GST_POLYPSINK (element); - g_message("state change: %i -> %i" , GST_STATE(element), GST_STATE_PENDING(element)); - switch(GST_STATE_TRANSITION(element)) { case GST_STATE_NULL_TO_READY: - g_message("NULL->READY"); create_context(polypsink); - g_message("NULL->READY DONE"); break; case GST_STATE_READY_TO_NULL: - g_message("READY->NULL"); destroy_context(polypsink); - g_message("READY->NULL DONE"); break; case GST_STATE_READY_TO_PAUSED: - g_message("READY->PAUSED"); - create_stream(polypsink); if (polypsink->stream && pa_stream_get_state(polypsink->stream) == PA_STREAM_READY) @@ -138,8 +138,6 @@ static GstElementStateReturn gst_polypsink_change_state(GstElement * element) { break; case GST_STATE_PLAYING_TO_PAUSED: - - g_message("PLAYING->PAUSED"); if (polypsink->stream && pa_stream_get_state(polypsink->stream) == PA_STREAM_READY) pa_operation_unref(pa_stream_cork(polypsink->stream, 1, NULL, NULL)); @@ -148,8 +146,6 @@ static GstElementStateReturn gst_polypsink_change_state(GstElement * element) { case GST_STATE_PAUSED_TO_PLAYING: - g_message("PAUSED->PLAYING"); - create_stream(polypsink); if (polypsink->stream && pa_stream_get_state(polypsink->stream) == PA_STREAM_READY) @@ -159,8 +155,6 @@ static GstElementStateReturn gst_polypsink_change_state(GstElement * element) { case GST_STATE_PAUSED_TO_READY: - g_message("PAUSED->READY"); - destroy_stream(polypsink); break; } @@ -187,8 +181,6 @@ static void do_write(GstPolypSink *polypsink, size_t length) { pa_stream_write(polypsink->stream, GST_BUFFER_DATA(polypsink->buffer) + polypsink->buffer_index, l, NULL, 0); polypsink->buffer_index += l; -/* g_message("WROTE: %i/%i", polypsink->buffer_index, GST_BUFFER_SIZE(polypsink->buffer)); */ - if (polypsink->buffer_index >= GST_BUFFER_SIZE(polypsink->buffer)) { gst_buffer_unref(polypsink->buffer); polypsink->buffer = NULL; @@ -207,8 +199,6 @@ static void stream_state_callback(struct pa_stream *s, void *userdata) { GstPolypSink *polypsink = userdata; g_assert(s && polypsink); -/* g_message("stream_state_callback()"); */ - switch (pa_stream_get_state(s)) { case PA_STREAM_DISCONNECTED: case PA_STREAM_CREATING: @@ -223,7 +213,6 @@ static void stream_state_callback(struct pa_stream *s, void *userdata) { /* Pass over */ case PA_STREAM_TERMINATED: default: - g_message("TERMINATED"); polypsink->mainloop_api->quit(polypsink->mainloop_api, 1); destroy_context(polypsink); break; @@ -234,8 +223,6 @@ static void context_state_callback(struct pa_context *c, void *userdata) { GstPolypSink *polypsink = userdata; g_assert(c && polypsink); -/* g_message("context_state_callback()"); */ - switch (pa_context_get_state(c)) { case PA_CONTEXT_UNCONNECTED: case PA_CONTEXT_CONNECTING: @@ -260,7 +247,6 @@ static void context_state_callback(struct pa_context *c, void *userdata) { /* Pass over */ case PA_CONTEXT_TERMINATED: default: - g_message("TERMINATED"); polypsink->mainloop_api->quit(polypsink->mainloop_api, 1); destroy_context(polypsink); break; @@ -285,8 +271,6 @@ static void create_stream(GstPolypSink *polypsink) { if (pa_context_get_state(polypsink->context) != PA_CONTEXT_READY) return; - g_message("creating stream"); - pa_sample_spec_snprint(t, sizeof(t), &polypsink->sample_spec); polypsink->stream = pa_stream_new(polypsink->context, "gstreamer output", &polypsink->sample_spec); @@ -294,7 +278,7 @@ static void create_stream(GstPolypSink *polypsink) { pa_stream_set_state_callback(polypsink->stream, stream_state_callback, polypsink); pa_stream_set_write_callback(polypsink->stream, stream_write_callback, polypsink); - pa_stream_connect_playback(polypsink->stream, NULL, NULL, 0, PA_VOLUME_NORM); + pa_stream_connect_playback(polypsink->stream, NULL, NULL, PA_STREAM_INTERPOLATE_LATENCY, PA_VOLUME_NORM); } static void create_context(GstPolypSink *polypsink) { @@ -303,8 +287,6 @@ static void create_context(GstPolypSink *polypsink) { if (polypsink->context) return; - g_message("creating context"); - polypsink->context = pa_context_new(polypsink->mainloop_api, "gstreamer"); g_assert(polypsink->context); @@ -321,8 +303,6 @@ static void destroy_stream(GstPolypSink *polypsink) { pa_stream_set_state_callback(s, NULL, NULL); pa_stream_set_write_callback(s, NULL, NULL); pa_stream_unref(s); - - g_message("destroying stream"); } } @@ -334,8 +314,6 @@ static void destroy_context(GstPolypSink *polypsink) { polypsink->context = NULL; pa_context_set_state_callback(c, NULL, NULL); pa_context_unref(c); - - g_message("destroying context"); } } @@ -344,14 +322,11 @@ static void gst_polypsink_chain(GstPad *pad, GstData *data) { g_assert(!polypsink->buffer); -/* g_message("chain-entry"); */ - if (GST_IS_EVENT(data)) { GstEvent *event = GST_EVENT(data); switch (GST_EVENT_TYPE(event)) { case GST_EVENT_EOS: - g_message("EOS"); if (polypsink->stream) { struct pa_operation *o; @@ -369,13 +344,11 @@ static void gst_polypsink_chain(GstPad *pad, GstData *data) { break; case GST_EVENT_FLUSH: - g_message("FLUSH"); if (polypsink->stream) pa_operation_unref(pa_stream_flush(polypsink->stream, NULL, NULL)); break; default: - g_message("other event: %i", GST_EVENT_TYPE(event)); break; } @@ -391,56 +364,54 @@ static void gst_polypsink_chain(GstPad *pad, GstData *data) { } while (polypsink->context && (pa_context_is_pending(polypsink->context) || polypsink->buffer)) { -/* g_message("iterate start %i %i", !!pa_context_is_pending(polypsink->context), !!polypsink->buffer); */ - if (pa_mainloop_iterate(polypsink->mainloop, 1, NULL) < 0) return; - -/* g_message("iterate stop"); */ } -/* g_message("chain-exit"); */ } -/* static void stream_get_latency_callback(struct pa_stream *s, const struct pa_latency_info *i, void *userdata) { */ -/* GstPolypSink *polypsink = (GstPolypSink*) userdata; */ +#if 0 +static void stream_get_latency_callback(struct pa_stream *s, const struct pa_latency_info *i, void *userdata) { + GstPolypSink *polypsink = (GstPolypSink*) userdata; -/* polypsink->latency = i->buffer_usec + i->sink_usec; */ -/* } */ + polypsink->latency = i->buffer_usec + i->sink_usec; +} -/* static GstClockTime gst_polypsink_get_time(GstClock *clock, gpointer data) { */ -/* struct pa_operation *o; */ -/* GstPolypSink *polypsink = GST_POLYPSINK(data); */ -/* GstClockTime r, l; */ +static GstClockTime gst_polypsink_get_time(GstClock *clock, gpointer data) { + struct pa_operation *o; + GstPolypSink *polypsink = GST_POLYPSINK(data); + GstClockTime r, l; -/* if (!polypsink->stream || pa_stream_get_state(polypsink->stream) != PA_STREAM_READY) */ -/* return 0; */ + if (!polypsink->stream || pa_stream_get_state(polypsink->stream) != PA_STREAM_READY) + return 0; -/* polypsink->latency = 0; */ + polypsink->latency = 0; -/* o = pa_stream_get_latency(polypsink_>stream, latency_func, polypsink); */ -/* g_assert(o); */ + o = pa_stream_get_latency(polypsink_>stream, latency_func, polypsink); + g_assert(o); -/* while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) { */ -/* if (pa_mainloop_iterate(polypsink->mainloop, 1, NULL) < 0) */ -/* return; */ -/* } */ + while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) { + if (pa_mainloop_iterate(polypsink->mainloop, 1, NULL) < 0) + return; + } -/* r = ((GstClockTime) polypsink->counter / pa_frame_size(&polypsink->sample_spec))*GST_SECOND/polypsink->sample_spec.rate; */ -/* l = polypsink->latency*GST_USECOND; */ + r = ((GstClockTime) polypsink->counter / pa_frame_size(&polypsink->sample_spec))*GST_SECOND/polypsink->sample_spec.rate; + l = polypsink->latency*GST_USECOND; -/* return r > l ? r - l : 0; */ -/* } */ + return r > l ? r - l : 0; +} + +static GstClock *gst_polypsink_get_clock(GstElement * element) { + GstPolypSink *polypsink = GST_POLYPSINK (element); + return GST_CLOCK (polypsink->provided_clock); +} -/* static GstClock *gst_polypsink_get_clock(GstElement * element) { */ -/* GstPolypSink *polypsink = GST_POLYPSINK (element); */ -/* return GST_CLOCK (polypsink->provided_clock); */ -/* } */ +static void gst_polypsink_set_clock (GstElement * element, GstClock * clock) { + GstPolypSink *polypsink = GST_POLYPSINK (element); + polypsink->clock = clock; +} -/* static void gst_polypsink_set_clock (GstElement * element, GstClock * clock) { */ -/* GstPolypSink *polypsink = GST_POLYPSINK (element); */ -/* polypsink->clock = clock; */ -/* } */ +#endif static GstPadLinkReturn gst_polypsink_link(GstPad *pad, const GstCaps *caps) { int depth = 16, endianness = 1234; @@ -452,8 +423,6 @@ static GstPadLinkReturn gst_polypsink_link(GstPad *pad, const GstCaps *caps) { GstElementState state; polypsink = GST_POLYPSINK(gst_pad_get_parent(pad)); - - g_message("link: %p", polypsink); structure = gst_caps_get_structure(caps, 0); @@ -482,13 +451,11 @@ static GstPadLinkReturn gst_polypsink_link(GstPad *pad, const GstCaps *caps) { polypsink->sample_spec.channels = 2; pa_sample_spec_snprint(t, sizeof(t), &polypsink->sample_spec); - g_message("using %s", t); gst_structure_get_int(structure, "channels", (int*) &polypsink->sample_spec.channels); gst_structure_get_int(structure, "rate", &polypsink->sample_spec.rate); pa_sample_spec_snprint(t, sizeof(t), &polypsink->sample_spec); - g_message("using %s", t); if (!pa_sample_spec_valid(&polypsink->sample_spec)) return GST_PAD_LINK_REFUSED; @@ -526,8 +493,6 @@ static GstCaps* gst_polypsink_sink_fixate(GstPad *pad, const GstCaps *caps) { static void gst_polypsink_init(GTypeInstance* instance, gpointer g_class) { GstPolypSink *polypsink = GST_POLYPSINK(instance); - g_message("created: %p", polypsink); - polypsink->sinkpad = gst_pad_new_from_template(gst_element_class_get_pad_template(GST_ELEMENT_GET_CLASS (instance), "sink"), "sink"); gst_element_add_pad(GST_ELEMENT(polypsink), polypsink->sinkpad); @@ -577,8 +542,6 @@ static void gst_polypsink_dispose(GObject *object) { pa_mainloop_free(polypsink->mainloop); G_OBJECT_CLASS(parent_class)->dispose(object); - - g_message("destroyed: %p", polypsink); } static void gst_polypsink_class_init(gpointer g_class, gpointer class_data) { -- cgit