diff -r cb885ee44618 -r 19626dc62c16 gst-gmyth/mythsrc/gstmythtvsrc.c --- a/gst-gmyth/mythsrc/gstmythtvsrc.c Thu Jun 14 20:40:47 2007 +0100 +++ b/gst-gmyth/mythsrc/gstmythtvsrc.c Fri Aug 10 14:45:36 2007 +0100 @@ -383,7 +383,7 @@ G_OBJECT_CLASS(parent_class)->finalize(gobject); } -static GMythFileReadResult +static GMythFileReadResult do_read_request_response(GstMythtvSrc * src, guint size, GByteArray * data_ptr) { @@ -457,7 +457,7 @@ return result; } -static GstFlowReturn +static GstFlowReturn gst_mythtv_src_create(GstPushSrc * psrc, GstBuffer ** outbuf) { GstMythtvSrc *src; @@ -498,8 +498,8 @@ /* * got the next program info? */ - if (G_UNLIKELY(src->update_prog_chain) - || (result == GMYTH_FILE_READ_NEXT_PROG_CHAIN)) { + if (G_UNLIKELY(src->update_prog_chain) || + (result == GMYTH_FILE_READ_NEXT_PROG_CHAIN)) { GST_DEBUG_OBJECT(src, "Update PROGRAM CHAIN!!! buffer_size = %d.", src->bytes_queue->len); @@ -543,14 +543,13 @@ /* */ if (G_UNLIKELY(buffer->len < 0)) { - if (buffer != NULL) { g_byte_array_free(buffer, TRUE); buffer = NULL; } - if (src->live_tv - || (result == GMYTH_FILE_READ_NEXT_PROG_CHAIN)) + if (src->live_tv || + (result == GMYTH_FILE_READ_NEXT_PROG_CHAIN)) goto change_progchain; else goto read_error; @@ -561,8 +560,12 @@ buffer = NULL; } - if (!src->live_tv) - goto done; + if (!src->live_tv) { + if (src->eos) + goto eos; + else + goto done; + } else goto program_chain_changed; } @@ -589,9 +592,10 @@ */ } - guint buffer_size = - (src->buffer_remain < - MAX_READ_SIZE) ? src->buffer_remain : MAX_READ_SIZE; + guint buffer_size; + buffer_size = (src->buffer_remain < MAX_READ_SIZE) ? + src->buffer_remain : + MAX_READ_SIZE; *outbuf = gst_buffer_new(); @@ -623,21 +627,17 @@ src->bytes_queue = g_byte_array_remove_range(src->bytes_queue, 0, buffer_size); - if (G_UNLIKELY(src->eos) || (!src->live_tv - && (src->bytes_read >= - src->content_size))) + if (src->eos || + (!src->live_tv && (src->bytes_read >= src->content_size)) + ) goto eos; done: { - const gchar *reason = gst_flow_get_name(ret); return ret; } eos: { - const gchar *reason = gst_flow_get_name(ret); - - GST_DEBUG_OBJECT(src, "pausing task, reason %s", reason); return GST_FLOW_UNEXPECTED; } /* @@ -700,7 +700,7 @@ } -static gboolean +static gboolean gst_mythtv_src_do_seek(GstBaseSrc * base, GstSegment * segment) { GstMythtvSrc *src = GST_MYTHTV_SRC(base); @@ -764,7 +764,7 @@ /* * create a socket for connecting to remote server */ -static gboolean +static gboolean gst_mythtv_src_start(GstBaseSrc * bsrc) { GstMythtvSrc *src = GST_MYTHTV_SRC(bsrc); @@ -972,7 +972,7 @@ } -static gboolean +static gboolean gst_mythtv_src_get_size(GstBaseSrc * bsrc, guint64 * size) { GstMythtvSrc *src = GST_MYTHTV_SRC(bsrc); @@ -1010,7 +1010,7 @@ * close the socket and associated resources used both to recover from * errors and go to NULL state */ -static gboolean +static gboolean gst_mythtv_src_stop(GstBaseSrc * bsrc) { GstMythtvSrc *src = GST_MYTHTV_SRC(bsrc); @@ -1024,17 +1024,15 @@ return TRUE; } -static gboolean +static gboolean gst_mythtv_src_handle_event(GstPad * pad, GstEvent * event) { GstMythtvSrc *src = GST_MYTHTV_SRC(GST_PAD_PARENT(pad)); gint64 cont_size = 0; - gboolean ret = FALSE; + gboolean ret = TRUE; switch (GST_EVENT_TYPE(event)) { case GST_EVENT_EOS: - GST_WARNING_OBJECT(src, "Got EOS event"); - if (src->live_tv) { cont_size = gst_mythtv_src_get_position(src); if (cont_size > src->content_size) { @@ -1051,16 +1049,17 @@ ret = gst_pad_event_default(pad, event); } + GST_DEBUG_OBJECT (src, "HANDLE EVENT %d", ret); return ret; } -static gboolean +static gboolean gst_mythtv_src_is_seekable(GstBaseSrc * push_src) { return TRUE; } -static gboolean +static gboolean gst_mythtv_src_handle_query(GstPad * pad, GstQuery * query) { gboolean res = FALSE; @@ -1107,12 +1106,12 @@ return res; } -static GstStateChangeReturn +static GstStateChangeReturn gst_mythtv_src_change_state(GstElement * element, GstStateChange transition) { GstStateChangeReturn ret = GST_STATE_CHANGE_FAILURE; - GstMythtvSrc *src = GST_MYTHTV_SRC(element); + GstMythtvSrc *src = GST_MYTHTV_SRC(element); switch (transition) { case GST_STATE_CHANGE_NULL_TO_READY: @@ -1133,11 +1132,10 @@ break; } - - ret = - GST_ELEMENT_CLASS(parent_class)->change_state(element, transition); - if (ret == GST_STATE_CHANGE_FAILURE) + ret = GST_ELEMENT_CLASS(parent_class)->change_state(element, transition); + if (ret == GST_STATE_CHANGE_FAILURE) { return ret; + } switch (transition) { @@ -1293,7 +1291,7 @@ GST_OBJECT_UNLOCK(mythtvsrc); } -static gboolean +static gboolean plugin_init(GstPlugin * plugin) { return gst_element_register(plugin, "mythtvsrc", GST_RANK_NONE, @@ -1309,7 +1307,7 @@ /*** GSTURIHANDLER INTERFACE *************************************************/ -static guint +static guint gst_mythtv_src_uri_get_type(void) { return GST_URI_SRC; @@ -1331,7 +1329,7 @@ return src->uri_name; } -static gboolean +static gboolean gst_mythtv_src_uri_set_uri(GstURIHandler * handler, const gchar * uri) { GstMythtvSrc *src = GST_MYTHTV_SRC(handler);