# HG changeset patch # User rosfran # Date 1164839788 0 # Node ID 998bdad22bfe6de4b09f17d7445c256ff5a483b8 # Parent d667a2b3a43f79264c129f99a83077aff19069d6 [svn r143] Fixed problem when trying to find EOS. diff -r d667a2b3a43f -r 998bdad22bfe gst-plugins-mythtv/src/gstmythtvsrc.c --- a/gst-plugins-mythtv/src/gstmythtvsrc.c Wed Nov 29 21:50:53 2006 +0000 +++ b/gst-plugins-mythtv/src/gstmythtvsrc.c Wed Nov 29 22:36:28 2006 +0000 @@ -61,7 +61,7 @@ #define REQUEST_MAX_SIZE 64*1024 -#define INTERNAL_BUFFER_SIZE 200*1024 +#define INTERNAL_BUFFER_SIZE 90*1024 /* stablish a maximum iteration value to the IS_RECORDING message */ static guint wait_to_transfer = 0; @@ -348,7 +348,7 @@ { gint read = 0; guint sizetoread = size; - guint max_iters = GMYTHTV_TRANSFER_MAX_RESENDS; + gint max_iters = GMYTHTV_TRANSFER_MAX_RESENDS; GST_LOG_OBJECT( src, "Starting: [%s] Reading %d bytes...\n", __FUNCTION__, sizetoread ); @@ -382,7 +382,8 @@ goto done; } - } + } else if ( len == 0 ) + goto done; if ( read == sizetoread ) goto done; @@ -423,46 +424,40 @@ (gint) src->buffer_remain, src->bytes_queue->len ); /* just get from the byte array, no network effort... */ - if ( ( src->buffer_remain = src->bytes_queue->len ) < MAX_READ_SIZE ) { + if ( ( src->buffer_remain = src->bytes_queue->len ) < MAX_READ_SIZE && + abs( src->content_size - src->bytes_read ) > MAX_READ_SIZE ) { //( ( INTERNAL_BUFFER_SIZE - src->buffer_remain ) >= REQUEST_MAX_SIZE ) ) { GByteArray *buffer = NULL; - guint amount_to_fill = ( INTERNAL_BUFFER_SIZE - src->buffer_remain ); - guint buffer_size_inter = 0; + guint buffer_size_inter = ( INTERNAL_BUFFER_SIZE - src->buffer_remain ); + if ( buffer_size_inter > REQUEST_MAX_SIZE ) + buffer_size_inter = REQUEST_MAX_SIZE; - //do { - if ( amount_to_fill < REQUEST_MAX_SIZE ) - buffer_size_inter = amount_to_fill; - else - buffer_size_inter = REQUEST_MAX_SIZE; + buffer = g_byte_array_new(); - buffer = g_byte_array_new(); - - read = do_read_request_response( src, buffer_size_inter, buffer ); - - if (G_UNLIKELY (read < 0)) { - if ( src->live_tv ) - goto change_progchain; - else - goto read_error; - } - - if ( G_UNLIKELY (src->update_prog_chain) ) - goto change_progchain; - - src->bytes_queue = g_byte_array_append( src->bytes_queue, g_memdup( buffer->data, read ), read ); - if ( read > buffer_size_inter ) - GST_WARNING_OBJECT( src, "[%s] INCREASED buffer size! Backend sent more than we ask him... (%d)\n", - __FUNCTION__, abs( read - buffer_size_inter ) ); - - src->buffer_remain += read; - amount_to_fill -= read; - - //} while ( amount_to_fill > 0 ); - - if ( buffer != NULL ) { - g_byte_array_free( buffer, TRUE ); - buffer = NULL; - } + read = do_read_request_response( src, buffer_size_inter, buffer ); + + if (G_UNLIKELY (read < 0)) { + if ( src->live_tv ) + goto change_progchain; + else + goto read_error; + } else if (G_UNLIKELY (read == 0) && !src->live_tv ) + goto eos; + + if ( G_UNLIKELY (src->update_prog_chain) ) + goto change_progchain; + + src->bytes_queue = g_byte_array_append( src->bytes_queue, g_memdup( buffer->data, read ), read ); + if ( read > buffer_size_inter ) + GST_WARNING_OBJECT( src, "\n\n\n[%s]\t\tINCREASED buffer size! Backend sent more than we ask him... (%d)\n\n\n", + __FUNCTION__, abs( read - buffer_size_inter ) ); + + src->buffer_remain += read; + + if ( buffer != NULL ) { + g_byte_array_free( buffer, TRUE ); + buffer = NULL; + } GST_DEBUG_OBJECT( src, "[%s]\tBYTES READ (actual) = %d, BYTES READ (cumulative) = %llu, "\ "OFFSET = %llu, CONTENT SIZE = %llu.\n", __FUNCTION__, read, src->bytes_read, @@ -510,7 +505,11 @@ "OFFSET_END = %llu.\n\n", __FUNCTION__, GST_BUFFER_SIZE (*outbuf), GST_BUFFER_OFFSET (*outbuf), GST_BUFFER_OFFSET_END (*outbuf) ); - return ret; + GST_DEBUG_OBJECT( src, "[%s]\tCONTENT_SIZE = %llu, BYTES_READ = %llu.\n", __FUNCTION__, + src->content_size, src->bytes_read ); + + if ( G_UNLIKELY (src->eos) || ( !src->live_tv && ( src->bytes_read >= src->content_size ) ) ) + goto eos; done: {