diff -r c71d37b93734 -r 324e04989738 gst-plugins-mythtv/src/gstmythtvsrc.c --- a/gst-plugins-mythtv/src/gstmythtvsrc.c Wed Oct 18 23:45:17 2006 +0100 +++ b/gst-plugins-mythtv/src/gstmythtvsrc.c Mon Oct 23 14:36:26 2006 +0100 @@ -101,7 +101,7 @@ static gboolean gst_mythtv_src_handle_event (GstPad * pad, GstEvent * event); //static gboolean gst_mythtv_src_query ( GstPad * pad, GstQuery * query ); -static guint do_read_request_response (GstMythtvSrc *src, guint64 offset, +static gint do_read_request_response (GstMythtvSrc *src, guint64 offset, guint size, GstBuffer **outbuf); //static gboolean gst_mythtv_src_sink_activate_pull (GstPad * srcpad, gboolean active); @@ -276,10 +276,10 @@ G_OBJECT_CLASS (parent_class)->finalize (gobject); } -static guint +static gint do_read_request_response (GstMythtvSrc * src, guint64 offset, guint size, GstBuffer **outbuf) { - guint read = 0; + gint read = 0; guint sizetoread = size; //GST_BUFFER_SIZE (outbuf); //GstBuffer *buffer = gst_buffer_new_and_alloc( size ); @@ -287,9 +287,9 @@ /* Loop sending the Myth File Transfer request: * Retry whilst authentication fails and we supply it. */ - guint len = 0; + gint len = 0; - //GST_OBJECT_LOCK(src); + GST_OBJECT_LOCK(src); while ( sizetoread > 0 ) { @@ -346,7 +346,6 @@ GST_BUFFER_SIZE (*outbuf) = read; //GST_BUFFER_SIZE (buffer) = read; GST_BUFFER_OFFSET (*outbuf) = offset; //GST_BUFFER_OFFSET (buffer) = offset; GST_BUFFER_OFFSET_END (*outbuf) = offset + read;//GST_BUFFER_OFFSET_END (buffer) = offset + read; - //*outbuf = buffer; //memcpy( GST_BUFFER_DATA( *outbuf ), GST_BUFFER_DATA( buffer ), read ); g_print( "Stopping: [%s]\t\tBUFFER --->SIZE = %d, OFFSET = %llu, "\ @@ -359,11 +358,10 @@ goto done; eos: - //GST_OBJECT_UNLOCK(src); src->eos = TRUE; done: - //GST_OBJECT_UNLOCK(src); + GST_OBJECT_UNLOCK(src); return read; } @@ -373,7 +371,7 @@ { GstMythtvSrc *src; GstFlowReturn ret = GST_FLOW_OK; - guint read = 0; + gint read = -1; src = GST_MYTHTV_SRC (psrc); /* The caller should know the number of bytes and not read beyond EOS. */ @@ -389,7 +387,7 @@ if (G_UNLIKELY (new_offset < 0 ) )//|| new_offset != src->read_offset)) { { //GST_OBJECT_UNLOCK(src); - goto read_error; + goto seek_failed; } src->read_offset = offset; @@ -445,6 +443,17 @@ src->uri_name)); return GST_FLOW_ERROR; } +seek_failed: + { + GST_ELEMENT_ERROR (src, RESOURCE, READ, + (NULL), ("Seek failed, go to the next program info... (%i, %s)", read, + src->uri_name)); + // go to the next program chain + src->unique_setup = FALSE; + gst_mythtv_src_start( psrc ); + + return GST_FLOW_OK; + } } @@ -683,6 +692,7 @@ ret= FALSE; } else if ( abs ( src->content_size - src->read_offset ) <= MYTHTV_TRANSFER_MAX_BUFFER ) { //g_static_mutex_lock( &update_size_mutex ); + GST_OBJECT_LOCK(src); guint64 new_offset = myth_file_transfer_get_file_position( src->file_transfer ); if ( src->content_size < new_offset ) { @@ -703,6 +713,7 @@ __FUNCTION__, size_tmp ); } #endif + GST_OBJECT_UNLOCK(src); //g_static_mutex_unlock( &update_size_mutex ); }