1.1 --- a/gst-plugins-mythtv/src/gstmythtvsrc.c Wed Oct 18 23:45:17 2006 +0100
1.2 +++ b/gst-plugins-mythtv/src/gstmythtvsrc.c Mon Oct 23 14:41:30 2006 +0100
1.3 @@ -101,7 +101,7 @@
1.4 static gboolean gst_mythtv_src_handle_event (GstPad * pad, GstEvent * event);
1.5 //static gboolean gst_mythtv_src_query ( GstPad * pad, GstQuery * query );
1.6
1.7 -static guint do_read_request_response (GstMythtvSrc *src, guint64 offset,
1.8 +static gint do_read_request_response (GstMythtvSrc *src, guint64 offset,
1.9 guint size, GstBuffer **outbuf);
1.10 //static gboolean gst_mythtv_src_sink_activate_pull (GstPad * srcpad, gboolean active);
1.11
1.12 @@ -276,10 +276,10 @@
1.13 G_OBJECT_CLASS (parent_class)->finalize (gobject);
1.14 }
1.15
1.16 -static guint
1.17 +static gint
1.18 do_read_request_response (GstMythtvSrc * src, guint64 offset, guint size, GstBuffer **outbuf)
1.19 {
1.20 - guint read = 0;
1.21 + gint read = 0;
1.22 guint sizetoread = size; //GST_BUFFER_SIZE (outbuf);
1.23 //GstBuffer *buffer = gst_buffer_new_and_alloc( size );
1.24
1.25 @@ -287,9 +287,9 @@
1.26
1.27 /* Loop sending the Myth File Transfer request:
1.28 * Retry whilst authentication fails and we supply it. */
1.29 - guint len = 0;
1.30 + gint len = 0;
1.31
1.32 - //GST_OBJECT_LOCK(src);
1.33 + GST_OBJECT_LOCK(src);
1.34
1.35 while ( sizetoread > 0 ) {
1.36
1.37 @@ -346,7 +346,6 @@
1.38 GST_BUFFER_SIZE (*outbuf) = read; //GST_BUFFER_SIZE (buffer) = read;
1.39 GST_BUFFER_OFFSET (*outbuf) = offset; //GST_BUFFER_OFFSET (buffer) = offset;
1.40 GST_BUFFER_OFFSET_END (*outbuf) = offset + read;//GST_BUFFER_OFFSET_END (buffer) = offset + read;
1.41 - //*outbuf = buffer;
1.42 //memcpy( GST_BUFFER_DATA( *outbuf ), GST_BUFFER_DATA( buffer ), read );
1.43
1.44 g_print( "Stopping: [%s]\t\tBUFFER --->SIZE = %d, OFFSET = %llu, "\
1.45 @@ -359,11 +358,10 @@
1.46 goto done;
1.47
1.48 eos:
1.49 - //GST_OBJECT_UNLOCK(src);
1.50 src->eos = TRUE;
1.51
1.52 done:
1.53 - //GST_OBJECT_UNLOCK(src);
1.54 + GST_OBJECT_UNLOCK(src);
1.55
1.56 return read;
1.57 }
1.58 @@ -373,7 +371,7 @@
1.59 {
1.60 GstMythtvSrc *src;
1.61 GstFlowReturn ret = GST_FLOW_OK;
1.62 - guint read = 0;
1.63 + gint read = -1;
1.64
1.65 src = GST_MYTHTV_SRC (psrc);
1.66 /* The caller should know the number of bytes and not read beyond EOS. */
1.67 @@ -389,7 +387,7 @@
1.68 if (G_UNLIKELY (new_offset < 0 ) )//|| new_offset != src->read_offset)) {
1.69 {
1.70 //GST_OBJECT_UNLOCK(src);
1.71 - goto read_error;
1.72 + goto seek_failed;
1.73 }
1.74
1.75 src->read_offset = offset;
1.76 @@ -445,6 +443,17 @@
1.77 src->uri_name));
1.78 return GST_FLOW_ERROR;
1.79 }
1.80 +seek_failed:
1.81 + {
1.82 + GST_ELEMENT_ERROR (src, RESOURCE, READ,
1.83 + (NULL), ("Seek failed, go to the next program info... (%i, %s)", read,
1.84 + src->uri_name));
1.85 + // go to the next program chain
1.86 + src->unique_setup = FALSE;
1.87 + gst_mythtv_src_start( psrc );
1.88 +
1.89 + return GST_FLOW_OK;
1.90 + }
1.91
1.92 }
1.93
1.94 @@ -683,6 +692,7 @@
1.95 ret= FALSE;
1.96 } else if ( abs ( src->content_size - src->read_offset ) <= MYTHTV_TRANSFER_MAX_BUFFER ) {
1.97 //g_static_mutex_lock( &update_size_mutex );
1.98 + GST_OBJECT_LOCK(src);
1.99
1.100 guint64 new_offset = myth_file_transfer_get_file_position( src->file_transfer );
1.101 if ( src->content_size < new_offset ) {
1.102 @@ -703,6 +713,7 @@
1.103 __FUNCTION__, size_tmp );
1.104 }
1.105 #endif
1.106 + GST_OBJECT_UNLOCK(src);
1.107 //g_static_mutex_unlock( &update_size_mutex );
1.108
1.109 }