diff -r dedcca2fe529 -r 8113a3dce6ce gst-plugins-mythtv/src/gstmythtvsrc.c --- a/gst-plugins-mythtv/src/gstmythtvsrc.c Fri Oct 27 23:32:24 2006 +0100 +++ b/gst-plugins-mythtv/src/gstmythtvsrc.c Mon Nov 06 22:57:44 2006 +0000 @@ -36,7 +36,7 @@ #define GMYTHTV_TRANSFER_MAX_WAITS 100 -#define GMYTHTV_TRANSFER_MAX_BUFFER 512*1024 +#define GMYTHTV_TRANSFER_MAX_BUFFER 80*1024 //( 32*1024 ) /* 4*1024 ??? */ @@ -140,7 +140,7 @@ static void gst_mythtv_src_class_init (GstMythtvSrcClass * klass) { - GObjectClass *gobject_class; + GObjectClass *gobject_class; //GstPushSrcClass *gstpushsrc_class; GstBaseSrcClass *gstbasesrc_class; @@ -225,6 +225,8 @@ this->mythtv_version = GMYTHTV_VERSION_DEFAULT; this->bytes_read = 0; + + this->prev_content_size = 0; this->content_size = 0; this->read_offset = 0; @@ -314,7 +316,7 @@ if ( src->live_tv == FALSE ) { - goto done; + goto eos; } else { @@ -323,10 +325,9 @@ if ( gst_mythtv_src_next_program_chain ( src ) ) continue; else - goto done; + goto eos; } else - if ( src->content_size <= - ( src->read_offset + size + GMYTHTV_TRANSFER_MAX_BUFFER ) ) { + if ( abs( src->content_size - src->prev_content_size ) < GMYTHTV_TRANSFER_MAX_BUFFER ) { src->update_prog_chain = TRUE; if ( src->enable_timing_position ) { gint64 size_tmp = 0; @@ -340,7 +341,8 @@ g_print( "\t[%s]\tGET_POSITION: file_position = %lld\n", __FUNCTION__, size_tmp ); } - } else { + } else if ( abs( src->content_size - src->prev_content_size ) < GMYTHTV_TRANSFER_MAX_BUFFER ) { + src->prev_content_size = src->content_size; gint64 new_offset = gmyth_file_transfer_get_file_position( src->file_transfer ); if ( new_offset > 0 ) { if ( src->content_size < new_offset ) { @@ -352,6 +354,7 @@ } goto done; } + goto done; } } @@ -474,7 +477,7 @@ // go to the next program chain src->unique_setup = FALSE; src->update_prog_chain = TRUE; - gst_mythtv_src_next_program_chain( src ); + //gst_mythtv_src_next_program_chain( src ); return -101; } @@ -517,7 +520,10 @@ gint64 size_tmp = 0; guint max_tries = 3; - if (src->live_tv == TRUE) { + if (src->live_tv == TRUE && ( abs( src->content_size - src->prev_content_size ) < + GMYTHTV_TRANSFER_MAX_BUFFER ) ) { + /* sets the last content size amount before it can be updated */ + src->prev_content_size = src->content_size; get_file_pos: g_usleep( 10 ); size_tmp = gmyth_file_transfer_get_file_position( src->file_transfer ); @@ -716,6 +722,9 @@ #endif src->content_size = src->file_transfer->filesize; + while ( src->content_size < GMYTHTV_TRANSFER_MAX_BUFFER ) + src->content_size = gst_mythtv_src_get_position( src ); + //src->read_offset = 0; //src->update_prog_chain = FALSE; @@ -814,13 +823,16 @@ { GstMythtvSrc *src = GST_MYTHTV_SRC (bsrc); gboolean ret = TRUE; + g_print( "[%s] Difference from previous content size: %d (max.: %d)\n", __FUNCTION__, + abs( src->content_size - src->prev_content_size ), GMYTHTV_TRANSFER_MAX_BUFFER ); if (src->content_size <= 0) { ret= FALSE; - } else if ( src->live_tv ) { + } else if ( src->live_tv && ( abs( src->content_size - src->bytes_read ) < + GMYTHTV_TRANSFER_MAX_BUFFER ) ) { //g_static_mutex_lock( &update_size_mutex ); //GST_OBJECT_LOCK(src); - + src->prev_content_size = src->content_size; gint64 new_offset = gmyth_file_transfer_get_file_position( src->file_transfer ); if ( new_offset > 0 ) { if ( src->content_size < new_offset ) { @@ -1031,7 +1043,7 @@ static GstStateChangeReturn gst_mythtv_src_change_state (GstElement * element, GstStateChange transition) { - GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS; + GstStateChangeReturn ret = GST_STATE_CHANGE_NO_PREROLL; GstMythtvSrc *src = GST_MYTHTV_SRC (element); switch (transition) { @@ -1053,9 +1065,13 @@ switch (transition) { case GST_STATE_CHANGE_READY_TO_NULL: + g_print( "[%s] READY to NULL called!\n", __FUNCTION__ ); break; case GST_STATE_CHANGE_PLAYING_TO_PAUSED: + g_print( "[%s] PLAYING to PAUSED called!\n", __FUNCTION__ ); + break; case GST_STATE_CHANGE_PAUSED_TO_READY: + g_print( "[%s] PAUSED to READY called!\n", __FUNCTION__ ); if ( src->live_tv && src->update_prog_chain ) { src->read_offset = 0; src->bytes_read = 0;