1.1 --- a/gst-plugins-mythtv/src/gstmythtvsrc.c Fri Oct 27 23:32:24 2006 +0100
1.2 +++ b/gst-plugins-mythtv/src/gstmythtvsrc.c Mon Oct 30 22:55:19 2006 +0000
1.3 @@ -36,7 +36,7 @@
1.4
1.5 #define GMYTHTV_TRANSFER_MAX_WAITS 100
1.6
1.7 -#define GMYTHTV_TRANSFER_MAX_BUFFER 512*1024
1.8 +#define GMYTHTV_TRANSFER_MAX_BUFFER 80*1024
1.9 //( 32*1024 )
1.10
1.11 /* 4*1024 ??? */
1.12 @@ -140,7 +140,7 @@
1.13 static void
1.14 gst_mythtv_src_class_init (GstMythtvSrcClass * klass)
1.15 {
1.16 - GObjectClass *gobject_class;
1.17 + GObjectClass *gobject_class;
1.18 //GstPushSrcClass *gstpushsrc_class;
1.19 GstBaseSrcClass *gstbasesrc_class;
1.20
1.21 @@ -225,6 +225,8 @@
1.22 this->mythtv_version = GMYTHTV_VERSION_DEFAULT;
1.23
1.24 this->bytes_read = 0;
1.25 +
1.26 + this->prev_content_size = 0;
1.27
1.28 this->content_size = 0;
1.29 this->read_offset = 0;
1.30 @@ -314,7 +316,7 @@
1.31
1.32 if ( src->live_tv == FALSE )
1.33 {
1.34 - goto done;
1.35 + goto eos;
1.36 }
1.37 else
1.38 {
1.39 @@ -323,10 +325,9 @@
1.40 if ( gst_mythtv_src_next_program_chain ( src ) )
1.41 continue;
1.42 else
1.43 - goto done;
1.44 + goto eos;
1.45 } else
1.46 - if ( src->content_size <=
1.47 - ( src->read_offset + size + GMYTHTV_TRANSFER_MAX_BUFFER ) ) {
1.48 + if ( abs( src->content_size - src->prev_content_size ) < GMYTHTV_TRANSFER_MAX_BUFFER ) {
1.49 src->update_prog_chain = TRUE;
1.50 if ( src->enable_timing_position ) {
1.51 gint64 size_tmp = 0;
1.52 @@ -340,7 +341,8 @@
1.53 g_print( "\t[%s]\tGET_POSITION: file_position = %lld\n",
1.54 __FUNCTION__, size_tmp );
1.55 }
1.56 - } else {
1.57 + } else if ( abs( src->content_size - src->prev_content_size ) < GMYTHTV_TRANSFER_MAX_BUFFER ) {
1.58 + src->prev_content_size = src->content_size;
1.59 gint64 new_offset = gmyth_file_transfer_get_file_position( src->file_transfer );
1.60 if ( new_offset > 0 ) {
1.61 if ( src->content_size < new_offset ) {
1.62 @@ -352,6 +354,7 @@
1.63 }
1.64 goto done;
1.65 }
1.66 + goto done;
1.67 }
1.68
1.69 }
1.70 @@ -474,7 +477,7 @@
1.71 // go to the next program chain
1.72 src->unique_setup = FALSE;
1.73 src->update_prog_chain = TRUE;
1.74 - gst_mythtv_src_next_program_chain( src );
1.75 + //gst_mythtv_src_next_program_chain( src );
1.76 return -101;
1.77 }
1.78
1.79 @@ -517,7 +520,10 @@
1.80
1.81 gint64 size_tmp = 0;
1.82 guint max_tries = 3;
1.83 - if (src->live_tv == TRUE) {
1.84 + if (src->live_tv == TRUE && ( abs( src->content_size - src->prev_content_size ) <
1.85 + GMYTHTV_TRANSFER_MAX_BUFFER ) ) {
1.86 + /* sets the last content size amount before it can be updated */
1.87 + src->prev_content_size = src->content_size;
1.88 get_file_pos:
1.89 g_usleep( 10 );
1.90 size_tmp = gmyth_file_transfer_get_file_position( src->file_transfer );
1.91 @@ -716,6 +722,9 @@
1.92 #endif
1.93
1.94 src->content_size = src->file_transfer->filesize;
1.95 + while ( src->content_size < GMYTHTV_TRANSFER_MAX_BUFFER )
1.96 + src->content_size = gst_mythtv_src_get_position( src );
1.97 +
1.98 //src->read_offset = 0;
1.99
1.100 //src->update_prog_chain = FALSE;
1.101 @@ -814,13 +823,16 @@
1.102 {
1.103 GstMythtvSrc *src = GST_MYTHTV_SRC (bsrc);
1.104 gboolean ret = TRUE;
1.105 + g_print( "[%s] Difference from previous content size: %d (max.: %d)\n", __FUNCTION__,
1.106 + abs( src->content_size - src->prev_content_size ), GMYTHTV_TRANSFER_MAX_BUFFER );
1.107
1.108 if (src->content_size <= 0) {
1.109 ret= FALSE;
1.110 - } else if ( src->live_tv ) {
1.111 + } else if ( src->live_tv && ( abs( src->content_size - src->bytes_read ) <
1.112 + GMYTHTV_TRANSFER_MAX_BUFFER ) ) {
1.113 //g_static_mutex_lock( &update_size_mutex );
1.114 //GST_OBJECT_LOCK(src);
1.115 -
1.116 + src->prev_content_size = src->content_size;
1.117 gint64 new_offset = gmyth_file_transfer_get_file_position( src->file_transfer );
1.118 if ( new_offset > 0 ) {
1.119 if ( src->content_size < new_offset ) {
1.120 @@ -1031,7 +1043,7 @@
1.121 static GstStateChangeReturn
1.122 gst_mythtv_src_change_state (GstElement * element, GstStateChange transition)
1.123 {
1.124 - GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
1.125 + GstStateChangeReturn ret = GST_STATE_CHANGE_NO_PREROLL;
1.126 GstMythtvSrc *src = GST_MYTHTV_SRC (element);
1.127
1.128 switch (transition) {
1.129 @@ -1053,9 +1065,13 @@
1.130
1.131 switch (transition) {
1.132 case GST_STATE_CHANGE_READY_TO_NULL:
1.133 + g_print( "[%s] READY to NULL called!\n", __FUNCTION__ );
1.134 break;
1.135 case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
1.136 + g_print( "[%s] PLAYING to PAUSED called!\n", __FUNCTION__ );
1.137 + break;
1.138 case GST_STATE_CHANGE_PAUSED_TO_READY:
1.139 + g_print( "[%s] PAUSED to READY called!\n", __FUNCTION__ );
1.140 if ( src->live_tv && src->update_prog_chain ) {
1.141 src->read_offset = 0;
1.142 src->bytes_read = 0;