X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/c076146f56b235db3757c6b075e4d3f0f000e0be..16bf32dcea05c64ff2ab831569be9a91c979a1b6:/server/gstdecode.c diff --git a/server/gstdecode.c b/server/gstdecode.c index e8883bb..1f4d7a2 100644 --- a/server/gstdecode.c +++ b/server/gstdecode.c @@ -35,11 +35,13 @@ #include #include -/* The only application we have for `attribute' is declaring function +/* The only applications we have for `attribute' is declaring function * arguments as being unused, because we have a lot of callback functions - * which are meant to comply with an externally defined interface. + * which are meant to comply with an externally defined interface; and + * marking `help' as not returning. */ #ifdef __GNUC__ +# define NORETURN __attribute__((noreturn)) # define UNUSED __attribute__((unused)) #endif @@ -109,19 +111,17 @@ static void report_element_pads(const char *what, GstElement *elt, goto done; case GST_ITERATOR_OK: #ifdef HAVE_GSTREAMER_0_10 - cs = gst_caps_to_string(gst_pad_get_caps(pad)); + cs = gst_caps_to_string(GST_PAD_CAPS(pad)); #else assert(G_VALUE_HOLDS(&gv, GST_TYPE_PAD)); pad = g_value_get_object(&gv); caps = gst_pad_query_caps(pad, 0); cs = gst_caps_to_string(caps); - g_object_unref(caps); + gst_caps_unref(caps); #endif disorder_error(0, " `%s' %s pad: %s", GST_OBJECT_NAME(elt), what, cs); g_free(cs); -#ifdef HAVE_GSTREAMER_0_10 - g_object_unref(pad); -#endif + gst_object_unref(pad); break; case GST_ITERATOR_RESYNC: gst_iterator_resync(it); @@ -151,7 +151,7 @@ static void link_elements(GstElement *left, GstElement *right) disorder_error(0, "failed to link GStreamer elements `%s' and `%s'", GST_OBJECT_NAME(left), GST_OBJECT_NAME(right)); report_element_pads("source", left, gst_element_iterate_src_pads(left)); - report_element_pads("source", right, gst_element_iterate_sink_pads(right)); + report_element_pads("dest", right, gst_element_iterate_sink_pads(right)); disorder_fatal(0, "can't decode `%s'", file); } @@ -184,10 +184,7 @@ static void decoder_pad_arrived(GstElement *decode, GstPad *pad, gpointer u) #endif goto match; } -#ifndef HAVE_GSTREAMER_0_10 - g_object_unref(caps); -#endif - return; + goto end; match: /* Yes, it's audio. Link the two elements together. */ @@ -199,6 +196,9 @@ match: GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(pipeline), GST_DEBUG_GRAPH_SHOW_ALL, "disorder-gstdecode"); + +end: + gst_caps_unref(caps); } /* Prepare the GStreamer pipeline, ready to decode the given FILE. This sets @@ -217,6 +217,10 @@ static void prepare_pipeline(void) GstCaps *caps; const struct stream_header *fmt = &config->sample_format; + if(!source || !decode || !resample || !convert || !sink) + disorder_fatal(0, "failed to create GStreamer elements: " + "need base and good plugins"); + #ifndef HAVE_GSTREAMER_0_10 static const struct fmttab { const char *fmt; @@ -273,6 +277,7 @@ static void prepare_pipeline(void) END); #endif gst_app_sink_set_caps(appsink, caps); + gst_caps_unref(caps); /* Add the various elements into the pipeline. We'll stitch them together * in pieces, because the pipeline is somewhat dynamic. @@ -292,6 +297,9 @@ static void prepare_pipeline(void) */ if(mode != OFF) { gain = gst_element_factory_make("rgvolume", "gain"); + if(!gain) + disorder_fatal(0, "failed to create GStreamer elements: " + "need base and good plugins"); g_object_set(gain, "album-mode", mode == ALBUM, "fallback-gain", fallback, @@ -315,16 +323,11 @@ static void prepare_pipeline(void) static void bus_message(GstBus UNUSED *bus, GstMessage *msg, gpointer UNUSED u) { - switch(msg->type) { + switch(GST_MESSAGE_TYPE(msg)) { case GST_MESSAGE_ERROR: -#ifdef HAVE_GSTREAMER_0_10 - disorder_fatal(0, "%s", - gst_structure_get_string(msg->structure, "debug")); -#else disorder_fatal(0, "%s", gst_structure_get_string(gst_message_get_structure(msg), "debug")); -#endif default: break; } @@ -476,7 +479,7 @@ static void decode(void) gst_app_sink_set_callbacks(appsink, &callbacks, 0, 0); /* Set the ball rolling. */ - gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_PLAYING); + gst_element_set_state(pipeline, GST_STATE_PLAYING); /* And wait for the miracle to come. */ g_main_loop_run(loop); @@ -484,7 +487,7 @@ static void decode(void) /* Shut down the pipeline. This isn't strictly necessary, since we're * about to exit very soon, but it's kind of polite. */ - gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_NULL); + gst_element_set_state(pipeline, GST_STATE_NULL); } static int getenum(const char *what, const char *s, const char *const *tags) @@ -532,7 +535,7 @@ static const struct option options[] = { { 0, 0, 0, 0 } }; -static void help(void) +static void NORETURN help(void) { xprintf("Usage:\n" " disorder-gstdecode [OPTIONS] PATH\n"