diff -r eb4a812d4073 -r a615ba8f8804 gst-plugins-mythtv/src/gstmythtvsrc.c --- a/gst-plugins-mythtv/src/gstmythtvsrc.c Tue Oct 17 01:03:06 2006 +0100 +++ b/gst-plugins-mythtv/src/gstmythtvsrc.c Fri Oct 20 22:48:04 2006 +0100 @@ -36,14 +36,14 @@ #define MYTHTV_TRANSFER_MAX_WAITS 100 -#define MYTHTV_TRANSFER_MAX_BUFFER 4*1024 +#define MYTHTV_TRANSFER_MAX_BUFFER 1024*1024 //( 32*1024 ) /* 4*1024 ??? */ #define MAX_READ_SIZE 12*1024 //( 32*1024 ) -#define ENABLE_TIMING_POSITION 1 +#define ENABLE_TIMING_POSITION 0 /* stablish a maximum iteration value to the IS_RECORDING message */ static guint wait_to_transfer = 0; @@ -289,7 +289,7 @@ * Retry whilst authentication fails and we supply it. */ guint len = 0; - GST_OBJECT_LOCK(src); + //GST_OBJECT_LOCK(src); while ( sizetoread > 0 ) { @@ -297,17 +297,36 @@ GST_BUFFER_DATA( *outbuf ) + read, sizetoread, TRUE ); if ( len > 0 ) { - read += len; - src->read_offset += read; + read += len; sizetoread -= len; } else if ( len <= 0 ) { if ( src->live_tv == FALSE ) { goto done; - } else if ( src->content_size >= src->read_offset && - abs ( src->content_size - src->read_offset ) <= MYTHTV_TRANSFER_MAX_BUFFER ) { - goto done; - } + } else if ( /*src->content_size >= src->read_offset && + abs ( src->content_size - src->read_offset ) <= 1024 ) ||*/ + ( src->content_size <= ( src->read_offset + size + MYTHTV_TRANSFER_MAX_BUFFER ) ) ) + { +#if ENABLE_TIMING_POSITION == 1 + guint64 size_tmp = 0; + if (src->live_tv == TRUE) { +get_file_pos: + size_tmp = myth_file_transfer_get_file_position( src->file_transfer ); + if ( size_tmp > ( src->content_size + MYTHTV_TRANSFER_MAX_BUFFER ) ) + src->content_size = size_tmp; + else + goto get_file_pos; + g_print( "\t[%s]\tGET_POSITION: file_position = %llu\n", + __FUNCTION__, size_tmp ); + } +#else + guint64 new_offset = myth_file_transfer_get_file_position( src->file_transfer ); + if ( src->content_size < new_offset ) { + src->content_size = new_offset; + } +#endif + goto done; + } } @@ -316,6 +335,7 @@ } if ( read > 0 ) { + src->read_offset += read; src->bytes_read += read; g_print( "[%s]\tBYTES READ (actual) = %d, BYTES READ (cumulative) = %llu, "\ @@ -333,7 +353,7 @@ "OFFSET_END = %llu.\n\n", __FUNCTION__, GST_BUFFER_SIZE (*outbuf), GST_BUFFER_OFFSET (*outbuf), GST_BUFFER_OFFSET_END (*outbuf) ); - } else + } else if ( !src->live_tv ) goto eos; goto done; @@ -343,7 +363,7 @@ src->eos = TRUE; done: - GST_OBJECT_UNLOCK(src); + //GST_OBJECT_UNLOCK(src); return read; } @@ -361,33 +381,13 @@ goto eos; //GST_OBJECT_LOCK(src); - if ( /*src->content_size >= src->read_offset && - abs ( src->content_size - src->read_offset ) <= 1024 ) ||*/ - ( src->content_size <= ( src->read_offset + size ) ) ) - { -#if ENABLE_TIMING_POSITION == 1 - guint64 size_tmp = 0; - if (src->live_tv == TRUE) { -get_file_pos: - size_tmp = myth_file_transfer_get_file_position( src->file_transfer ); - if ( size_tmp > ( src->content_size + MYTHTV_TRANSFER_MAX_BUFFER ) ) - src->content_size = size_tmp; - else - goto get_file_pos; - g_print( "\t[%s]\tGET_POSITION: file_position = %llu\n", - __FUNCTION__, size_tmp ); - } -#endif - //guint64 new_offset = myth_file_transfer_get_file_position( src->file_transfer ); - //if ( src->content_size < new_offset ) { - // src->content_size = new_offset; - //} - } if (G_UNLIKELY (src->read_offset != offset)) { guint64 new_offset = myth_file_transfer_seek(src->file_transfer, offset, SEEK_SET); - - if (G_UNLIKELY (new_offset < 0 || new_offset != offset)) { + g_print( "[%s] SRC Offset = %llu, NEW actual backend SEEK Offset = %llu.\n", + __FUNCTION__, src->read_offset, new_offset ); + if (G_UNLIKELY (new_offset < 0 ) )//|| new_offset != src->read_offset)) { + { //GST_OBJECT_UNLOCK(src); goto read_error; } @@ -446,15 +446,6 @@ return GST_FLOW_ERROR; } -#if 0 -need_pause: - { - const gchar *reason = gst_flow_get_name (ret); - - GST_DEBUG_OBJECT (src, "pausing task, reason %s", reason); - return GST_FLOW_UNEXPECTED; - } -#endif } void @@ -690,16 +681,14 @@ if (src->content_size <= 0) { ret= FALSE; - } else if ( src->content_size >= src->read_offset && - abs ( src->content_size - src->read_offset ) <= MYTHTV_TRANSFER_MAX_BUFFER ) { - g_static_mutex_lock( &update_size_mutex ); + } else if ( abs ( src->content_size - src->read_offset ) <= MYTHTV_TRANSFER_MAX_BUFFER ) { + //g_static_mutex_lock( &update_size_mutex ); guint64 new_offset = myth_file_transfer_get_file_position( src->file_transfer ); if ( src->content_size < new_offset ) { src->content_size = new_offset; } -#if 0 #if ENABLE_TIMING_POSITION == 1 guint64 size_tmp = 0; if (src->live_tv == TRUE) { @@ -714,8 +703,7 @@ __FUNCTION__, size_tmp ); } #endif -#endif - g_static_mutex_unlock( &update_size_mutex ); + //g_static_mutex_unlock( &update_size_mutex ); } @@ -771,14 +759,17 @@ case GST_EVENT_EOS: g_print( "[%s] Got EOS event!!!\n", __FUNCTION__ ); guint64 cont_size = gst_mythtv_src_get_position (src); - if ( cont_size > src->content_size ) { - src->content_size = cont_size; - src->eos = FALSE; - } else { - src->eos = TRUE; - gst_element_set_state ( GST_ELEMENT (src), GST_STATE_NULL ); - gst_element_set_locked_state ( GST_ELEMENT (src), FALSE ); - } + if ( !src->live_tv ) { + if ( cont_size > src->content_size ) { + src->content_size = cont_size; + src->eos = FALSE; + } else { + src->eos = TRUE; + gst_element_set_state ( GST_ELEMENT (src), GST_STATE_NULL ); + gst_element_set_locked_state ( GST_ELEMENT (src), FALSE ); + } + } else + src->eos = TRUE; break; #if 0 case GST_EVENT_NEWSEGMENT: