[svn r107] Some minor adjustments, added FRONTEND_READY message when prerroling. trunk
authorrosfran
Fri Nov 24 01:53:43 2006 +0000 (2006-11-24)
branchtrunk
changeset 106a4a151d4735d
parent 105 ba9bf90e7c4b
child 107 899326948b25
[svn r107] Some minor adjustments, added FRONTEND_READY message when prerroling.
gst-plugins-mythtv/src/gstmythtvsrc.c
     1.1 --- a/gst-plugins-mythtv/src/gstmythtvsrc.c	Fri Nov 24 01:51:47 2006 +0000
     1.2 +++ b/gst-plugins-mythtv/src/gstmythtvsrc.c	Fri Nov 24 01:53:43 2006 +0000
     1.3 @@ -85,9 +85,6 @@
     1.4  
     1.5  static void gst_mythtv_src_finalize (GObject * gobject);
     1.6  
     1.7 -//static GstFlowReturn gst_mythtv_src_create (GstBaseSrc * psrc, guint64 offset, 
     1.8 -//	guint size, GstBuffer ** outbuf);
     1.9 -
    1.10  static GstFlowReturn gst_mythtv_src_create ( GstPushSrc* psrc, GstBuffer** outbuf );
    1.11  
    1.12  static gboolean gst_mythtv_src_start (GstBaseSrc * bsrc);
    1.13 @@ -95,8 +92,10 @@
    1.14  static gboolean gst_mythtv_src_get_size (GstBaseSrc * bsrc, guint64 * size);
    1.15  static gboolean gst_mythtv_src_is_seekable( GstBaseSrc *push_src );
    1.16  
    1.17 -//static void gst_mythtv_src_get_times (GstBaseSrc * src, GstBuffer * buffer,
    1.18 -//   GstClockTime * start, GstClockTime * end);
    1.19 +/*
    1.20 +static void gst_mythtv_src_get_times (GstBaseSrc * src, GstBuffer * buffer,
    1.21 +   GstClockTime * start, GstClockTime * end);
    1.22 +*/
    1.23  
    1.24  static gboolean gst_mythtv_src_do_seek( GstBaseSrc *base, GstSegment *segment );
    1.25  
    1.26 @@ -135,9 +134,6 @@
    1.27        "MythTV src");
    1.28  }
    1.29  
    1.30 -//GST_BOILERPLATE_FULL (GstMythtvSrc, gst_mythtv_src, GstBaseSrc,
    1.31 -//    GST_TYPE_BASE_SRC, _urihandler_init)
    1.32 -    
    1.33  GST_BOILERPLATE_FULL (GstMythtvSrc, gst_mythtv_src, GstPushSrc,
    1.34      GST_TYPE_PUSH_SRC, _urihandler_init)
    1.35      
    1.36 @@ -278,13 +274,11 @@
    1.37    
    1.38    this->bytes_queue = NULL;
    1.39    
    1.40 -  //this->th_read_ahead = NULL;
    1.41 -  
    1.42    this->th_mutex = NULL;
    1.43    
    1.44    gst_base_src_set_format( GST_BASE_SRC( this ), GST_FORMAT_BYTES );  
    1.45  
    1.46 -  //gst_base_src_set_live ( GST_BASE_SRC( this ), TRUE );
    1.47 +  /* gst_base_src_set_live ( GST_BASE_SRC( this ), TRUE ); */
    1.48    
    1.49    gst_pad_set_event_function ( GST_BASE_SRC_PAD(GST_BASE_SRC(this)),
    1.50        gst_mythtv_src_handle_event );
    1.51 @@ -341,9 +335,7 @@
    1.52    guint sizetoread = size;
    1.53    guint max_iters = GMYTHTV_TRANSFER_MAX_RESENDS;
    1.54    
    1.55 -  //*data_ptr = g_malloc0( size );
    1.56 -
    1.57 -  g_print( "Starting: [%s] Reading %d bytes...\n", __FUNCTION__, sizetoread ); 
    1.58 +  GST_LOG_OBJECT( src, "Starting: [%s] Reading %d bytes...\n", __FUNCTION__, sizetoread ); 
    1.59  
    1.60    /* Loop sending the Myth File Transfer request:
    1.61     * Retry whilst authentication fails and we supply it. */
    1.62 @@ -409,10 +401,10 @@
    1.63      goto change_progchain;
    1.64  
    1.65    //g_static_rec_mutex_lock( &th_mutex );
    1.66 -  g_print ( "[%s] offset = %llu, size = %d...\n", __FUNCTION__, 
    1.67 +  GST_DEBUG_OBJECT( src, "[%s] offset = %llu, size = %d...\n", __FUNCTION__, 
    1.68    		src->read_offset, MAX_READ_SIZE );
    1.69  
    1.70 -  g_print ( "[%s]\t\tCreate: buffer_remain: %d\n", __FUNCTION__, 
    1.71 +  GST_DEBUG_OBJECT ( src, "[%s]\t\tCreate: buffer_remain: %d\n", __FUNCTION__, 
    1.72        (gint) src->buffer_remain);
    1.73  
    1.74    /* just get from the byte array, no network effort... */
    1.75 @@ -433,6 +425,9 @@
    1.76        goto change_progchain;
    1.77        
    1.78      src->bytes_queue = g_byte_array_append( src->bytes_queue, g_memdup( buffer->data, read ), read );
    1.79 +    if ( read > buffer_size_inter )
    1.80 +    	GST_WARNING_OBJECT( src, "[%s] INCREASED buffer size! Backend sent more than we ask him... (%d)\n", 
    1.81 +    			__FUNCTION__, abs( read - buffer_size_inter ) );
    1.82  
    1.83      src->buffer_remain = src->buffer_remain + read;
    1.84      
    1.85 @@ -441,7 +436,7 @@
    1.86      	buffer = NULL;    	
    1.87      }
    1.88  
    1.89 -    g_print( "[%s]\tBYTES READ (actual) = %d, BYTES READ (cumulative) = %llu, "\
    1.90 +    GST_DEBUG_OBJECT( src, "[%s]\tBYTES READ (actual) = %d, BYTES READ (cumulative) = %llu, "\
    1.91  	"OFFSET = %llu, CONTENT SIZE = %llu.\n", __FUNCTION__, read, src->bytes_read, 
    1.92  	src->read_offset, src->content_size );
    1.93  	
    1.94 @@ -464,7 +459,7 @@
    1.95    /* gets the first buffer_size bytes from the byte array buffer variable */ 
    1.96    guint8 *buf = g_memdup( src->bytes_queue->data, buffer_size );
    1.97  
    1.98 -  g_print( "[%s] read from network? %s!, buffer_remain = %d\n", __FUNCTION__, 
    1.99 +  GST_DEBUG_OBJECT( src, "[%s] read from network? %s!, buffer_remain = %d\n", __FUNCTION__, 
   1.100    	read == -1 ? "NO, got from buffer" : "YES, go see the backend's log file", src->buffer_remain );
   1.101  
   1.102    GST_BUFFER_SIZE (*outbuf) = buffer_size;
   1.103 @@ -478,12 +473,12 @@
   1.104  
   1.105    src->read_offset += GST_BUFFER_SIZE (*outbuf);
   1.106    src->bytes_read += GST_BUFFER_SIZE (*outbuf);
   1.107 -  g_print ( "[%s]\t\tBuffer output with size: %d\n", __FUNCTION__, GST_BUFFER_SIZE (*outbuf) );
   1.108 +  GST_DEBUG_OBJECT( src, "[%s]\t\tBuffer output with size: %d\n", __FUNCTION__, GST_BUFFER_SIZE (*outbuf) );
   1.109    
   1.110    /* flushs the newly buffer got from byte array */
   1.111    src->bytes_queue = g_byte_array_remove_range( src->bytes_queue, 0, buffer_size );
   1.112  
   1.113 -  g_print( "Got buffer: [%s]\t\tBUFFER --->SIZE = %d, OFFSET = %llu, "\
   1.114 +  GST_DEBUG_OBJECT( src, "Got buffer: [%s]\t\tBUFFER --->SIZE = %d, OFFSET = %llu, "\
   1.115        "OFFSET_END = %llu.\n\n", __FUNCTION__, GST_BUFFER_SIZE (*outbuf), 
   1.116        GST_BUFFER_OFFSET (*outbuf), GST_BUFFER_OFFSET_END (*outbuf) );
   1.117  
   1.118 @@ -530,139 +525,6 @@
   1.119  
   1.120  }
   1.121  
   1.122 -#if 0
   1.123 -static GstFlowReturn
   1.124 -gst_mythtv_src_create ( GstBaseSrc * psrc, guint64 offset, guint size, GstBuffer **outbuf )
   1.125 -{
   1.126 -  GstMythtvSrc *src;
   1.127 -  GstFlowReturn ret = GST_FLOW_OK;
   1.128 -  gint read = -1;
   1.129 -  gint adapter_size = 0;
   1.130 -  guint max_adapter_rep = 1;
   1.131 -
   1.132 -  src = GST_MYTHTV_SRC ( psrc );
   1.133 -
   1.134 -  /* The caller should know the number of bytes and not read beyond EOS. */
   1.135 -  if (G_UNLIKELY (src->eos))
   1.136 -    goto eos;
   1.137 -  if ( G_UNLIKELY (src->update_prog_chain) )
   1.138 -    goto change_progchain;
   1.139 -
   1.140 -  //g_static_rec_mutex_lock( &th_mutex );
   1.141 -  g_print ( "[%s] offset = %llu, size = %d...\n", __FUNCTION__, offset, size );
   1.142 -
   1.143 -  g_print ( "[%s]\t\tCreate: buffer_remain: %d\n", __FUNCTION__, 
   1.144 -      (gint) src->buffer_remain);
   1.145 -
   1.146 -  /* just get from the byte array, no network effort... */
   1.147 -  if ( ( src->buffer_remain = src->bytes_queue->len ) < MAX_READ_SIZE ) {
   1.148 -  	guint8 *buffer = g_malloc0( INTERNAL_BUFFER_SIZE - src->buffer_remain );
   1.149 -
   1.150 -    read = do_read_request_response( src, 0, INTERNAL_BUFFER_SIZE - src->buffer_remain, &(buffer) );
   1.151 -
   1.152 -    if (G_UNLIKELY (read < 0)) {
   1.153 -      if ( src->live_tv )
   1.154 -	goto change_progchain;
   1.155 -      else
   1.156 -	goto read_error;
   1.157 -    }
   1.158 -
   1.159 -    if ( G_UNLIKELY (src->update_prog_chain) )
   1.160 -      goto change_progchain;
   1.161 -      
   1.162 -    src->bytes_queue = g_byte_array_append( src->bytes_queue, buffer, read );
   1.163 -
   1.164 -    src->buffer_remain = src->buffer_remain + read;
   1.165 -
   1.166 -    g_print( "[%s]\tBYTES READ (actual) = %d, BYTES READ (cumulative) = %llu, "\
   1.167 -	"OFFSET = %llu, CONTENT SIZE = %llu.\n", __FUNCTION__, read, src->bytes_read, 
   1.168 -	src->read_offset, src->content_size );
   1.169 -	
   1.170 -  }
   1.171 -  
   1.172 -  guint buffer_size = ( src->buffer_remain < MAX_READ_SIZE) ? src->buffer_remain : MAX_READ_SIZE;
   1.173 -  
   1.174 -  /* Create the buffer. */
   1.175 -  ret = gst_pad_alloc_buffer ( GST_BASE_SRC_PAD (GST_BASE_SRC (psrc)),
   1.176 -      offset, buffer_size,
   1.177 -      GST_PAD_CAPS (GST_BASE_SRC_PAD (GST_BASE_SRC (psrc))), outbuf );    
   1.178 -
   1.179 -  if (G_UNLIKELY (ret != GST_FLOW_OK)) {
   1.180 -    if ( src->live_tv )
   1.181 -      goto change_progchain;
   1.182 -    else
   1.183 -      goto done;
   1.184 -  }
   1.185 -  
   1.186 -  guint8 *buf = g_memdup( src->bytes_queue->data, buffer_size );
   1.187 -
   1.188 -  g_print( "[%s] read = %d, buffer_remain = %d\n", __FUNCTION__, read, src->buffer_remain );
   1.189 -  //src->read_offset = offset;
   1.190 -
   1.191 -  GST_BUFFER_SIZE (*outbuf) = buffer_size;
   1.192 -  GST_BUFFER_MALLOCDATA( *outbuf ) = g_malloc0( GST_BUFFER_SIZE (*outbuf) );
   1.193 -  GST_BUFFER_DATA( *outbuf ) = GST_BUFFER_MALLOCDATA( *outbuf );
   1.194 -  g_memmove( GST_BUFFER_DATA( (*outbuf) ), buf, GST_BUFFER_SIZE(*outbuf) );
   1.195 -  GST_BUFFER_OFFSET (*outbuf) = offset;
   1.196 -  GST_BUFFER_OFFSET_END (*outbuf) = offset + GST_BUFFER_SIZE (*outbuf);
   1.197 -
   1.198 -  src->buffer_remain -= GST_BUFFER_SIZE (*outbuf);
   1.199 -
   1.200 -  src->read_offset += GST_BUFFER_SIZE (*outbuf);
   1.201 -  src->bytes_read += GST_BUFFER_SIZE (*outbuf);
   1.202 -  g_print ( "[%s]\t\tBuffer output with size: %d\n", __FUNCTION__, GST_BUFFER_SIZE (*outbuf) );
   1.203 -  
   1.204 -  /* flushs the newly buffer got from byte array */
   1.205 -  src->bytes_queue = g_byte_array_remove_range( src->bytes_queue, 0, buffer_size );
   1.206 -
   1.207 -  g_print( "Got buffer: [%s]\t\tBUFFER --->SIZE = %d, OFFSET = %llu, "\
   1.208 -      "OFFSET_END = %llu.\n\n", __FUNCTION__, GST_BUFFER_SIZE (*outbuf), 
   1.209 -      GST_BUFFER_OFFSET (*outbuf), GST_BUFFER_OFFSET_END (*outbuf) );
   1.210 -
   1.211 -  return ret;
   1.212 -
   1.213 -done:
   1.214 -  {
   1.215 -    const gchar *reason = gst_flow_get_name (ret);
   1.216 -
   1.217 -    GST_DEBUG_OBJECT (src, "DONE task, reason %s", reason);
   1.218 -    return ret;
   1.219 -  }
   1.220 -eos:
   1.221 -  {
   1.222 -    const gchar *reason = gst_flow_get_name (ret);
   1.223 -
   1.224 -    GST_DEBUG_OBJECT (src, "pausing task, reason %s", reason);
   1.225 -    return GST_FLOW_UNEXPECTED;
   1.226 -  }
   1.227 -  /* ERRORS */
   1.228 -read_error:
   1.229 -  {
   1.230 -    GST_ELEMENT_ERROR (src, RESOURCE, READ,
   1.231 -	(NULL), ("Could not read any bytes (%i, %s)", read,
   1.232 -		 src->uri_name));
   1.233 -    return GST_FLOW_ERROR;
   1.234 -  }
   1.235 -change_progchain:
   1.236 -  {
   1.237 -    GST_ELEMENT_ERROR (src, RESOURCE, READ,
   1.238 -	(NULL), ("Seek failed, go to the next program info... (%i, %s)", read,
   1.239 -		 src->uri_name));
   1.240 -
   1.241 -    gst_pad_push_event ( GST_BASE_SRC_PAD (GST_BASE_SRC (psrc)),
   1.242 -	gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_TIME, 0, -1, 0 ) );
   1.243 -    // go to the next program chain
   1.244 -    src->unique_setup = FALSE;
   1.245 -    src->update_prog_chain = TRUE;
   1.246 -
   1.247 -    gst_mythtv_src_next_program_chain( src );
   1.248 -
   1.249 -    return GST_FLOW_ERROR_NO_DATA;
   1.250 -  }
   1.251 -
   1.252 -}
   1.253 -#endif
   1.254 -
   1.255  gint64
   1.256  gst_mythtv_src_get_position ( GstMythtvSrc* src ) 
   1.257  {
   1.258 @@ -679,7 +541,7 @@
   1.259        src->content_size = size_tmp;
   1.260      else if ( size_tmp > 0 && --max_tries > 0 )
   1.261        goto get_file_pos;
   1.262 -    g_print( "\t[%s]\tGET_POSITION: file_position = %lld\n",
   1.263 +    GST_LOG_OBJECT( src, "\t[%s]\tGET_POSITION: file_position = %lld\n",
   1.264  	__FUNCTION__, size_tmp );
   1.265      /* sets the last content size amount before it can be updated */
   1.266      src->prev_content_size = src->content_size;
   1.267 @@ -697,22 +559,23 @@
   1.268    gint64 actual_seek = segment->start;
   1.269    gboolean ret = TRUE;
   1.270  
   1.271 -  g_print( "[%s]DO Seek called! (start = %lld, stop = %lld)\n", __FUNCTION__, segment->start, segment->stop );
   1.272 +  GST_LOG_OBJECT( src, "[%s]DO Seek called! (start = %lld, stop = %lld)\n", __FUNCTION__, 
   1.273 +  		segment->start, segment->stop );
   1.274  
   1.275    if ( segment->format == GST_FORMAT_TIME ) 
   1.276    {
   1.277      goto done; 
   1.278      //actual_seek = ( ( segment->start / 1000 ) * 28 ) * 4000;
   1.279    }
   1.280 -  g_print( "[%s]Trying to seek at the value (actual_seek = %lld, read_offset = %lld)\n", __FUNCTION__, actual_seek, src->read_offset );
   1.281 +  GST_LOG_OBJECT( src, "[%s]Trying to seek at the value (actual_seek = %lld, read_offset = %lld)\n", __FUNCTION__, actual_seek, src->read_offset );
   1.282    /* verify if it needs to seek */
   1.283    if ( src->read_offset != actual_seek )
   1.284    {
   1.285  
   1.286      new_offset = gmyth_file_transfer_seek( src->file_transfer, segment->start, SEEK_SET );
   1.287  
   1.288 -    g_print( "[%s] Segment offset start = %lld, SRC Offset = %lld, NEW actual backend SEEK Offset = %lld.\n",
   1.289 -	__FUNCTION__, segment->start, src->read_offset, new_offset );
   1.290 +    GST_LOG_OBJECT( src, "[%s] Segment offset start = %lld, SRC Offset = %lld, NEW actual backend SEEK Offset = %lld.\n",
   1.291 +			__FUNCTION__, segment->start, src->read_offset, new_offset );
   1.292      if ( G_UNLIKELY (new_offset < 0 ) )
   1.293      {
   1.294        ret = FALSE;
   1.295 @@ -725,7 +588,7 @@
   1.296      src->read_offset = new_offset;
   1.297  
   1.298      if ( ret == FALSE ) {
   1.299 -      g_print( "[%s] Failed to set the SEEK on segment!\n", __FUNCTION__ );
   1.300 +      GST_INFO_OBJECT( src, "[%s] Failed to set the SEEK on segment!\n", __FUNCTION__ );
   1.301      }
   1.302  
   1.303    }
   1.304 @@ -737,7 +600,6 @@
   1.305    {
   1.306  
   1.307      GST_DEBUG_OBJECT (src, "EOS found on seeking!!!");
   1.308 -    //gst_object_unref( src );
   1.309      return FALSE;
   1.310    }
   1.311  change_progchain:
   1.312 @@ -759,64 +621,6 @@
   1.313  
   1.314  }
   1.315  
   1.316 -#if 0
   1.317 -static void 
   1.318 -gst_mythtv_src_read_ahead ( void *data ) {
   1.319 -
   1.320 -  GstMythtvSrc *src = NULL;
   1.321 -
   1.322 -  GstBuffer *outbuf = NULL;
   1.323 -
   1.324 -  guint size = 5*2048;
   1.325 -  gint total = 0;
   1.326 -  gint read = -1;
   1.327 -
   1.328 -  src = GST_MYTHTV_SRC( data );
   1.329 -
   1.330 -  //GST_PAD_STREAM_TRYLOCK( GST_BASE_SRC_PAD (GST_BASE_SRC (src)) );
   1.331 -
   1.332 -  do {
   1.333 -    GST_TASK_WAIT( src->th_read_ahead );
   1.334 -
   1.335 -    gint8 *data = NULL;
   1.336 -    
   1.337 -    outbuf = gst_buffer_new_and_alloc( size );
   1.338 -
   1.339 -    read = do_read_request_response ( src, src->adapter_offset, size, &data );
   1.340 -
   1.341 -    if ( read > 0 ) {
   1.342 -      src->read_offset += read;
   1.343 -      src->bytes_read += read;
   1.344 -      total += read;
   1.345 -
   1.346 -      g_print( "[%s]\tBYTES READ (actual) = %d, BYTES READ (cumulative) = %llu, "\
   1.347 -	  "OFFSET = %llu, CONTENT SIZE = %llu.\n", __FUNCTION__, read, src->bytes_read, 
   1.348 -	  src->read_offset, src->content_size );
   1.349 -
   1.350 -      GST_BUFFER_SIZE (outbuf) = read;
   1.351 -      GST_BUFFER_MALLOCDATA( outbuf ) = g_malloc0( GST_BUFFER_SIZE (outbuf) );
   1.352 -      GST_BUFFER_DATA( outbuf ) = GST_BUFFER_MALLOCDATA( outbuf );
   1.353 -      g_memmove( GST_BUFFER_DATA( outbuf ), data, read );
   1.354 -      GST_BUFFER_OFFSET (outbuf) = src->adapter_offset;  
   1.355 -      GST_BUFFER_OFFSET_END (outbuf) = src->adapter_offset + read;
   1.356 -      g_print( "Got buffer: [%s]\t\tBUFFER --->SIZE = %d, OFFSET = %llu, "\
   1.357 -	  "OFFSET_END = %llu.\n\n", __FUNCTION__, GST_BUFFER_SIZE (outbuf), 
   1.358 -	  GST_BUFFER_OFFSET (outbuf), GST_BUFFER_OFFSET_END (outbuf) );
   1.359 -
   1.360 -    } 
   1.361 -
   1.362 -    gst_adapter_push( src->adapter, outbuf );
   1.363 -
   1.364 -    GST_TASK_SIGNAL( src->th_read_ahead );
   1.365 -
   1.366 -  } while ( read < size );
   1.367 -
   1.368 -  //GST_PAD_STREAM_UNLOCK( GST_BASE_SRC_PAD (GST_BASE_SRC (src)) );
   1.369 -
   1.370 -  return;	
   1.371 -}
   1.372 -#endif
   1.373 -
   1.374  /* create a socket for connecting to remote server */
   1.375  static gboolean
   1.376  gst_mythtv_src_start ( GstBaseSrc * bsrc )
   1.377 @@ -849,10 +653,10 @@
   1.378      chain_id_local = gmyth_tvchain_get_id( src->spawn_livetv->tvchain );
   1.379      if ( chain_id_local != NULL ) {
   1.380        src->live_chain_id = g_strdup( chain_id_local->str );
   1.381 -      g_print( "\t[%s]\tLocal chain ID = %s.\n", __FUNCTION__, src->live_chain_id );
   1.382 +      GST_INFO_OBJECT( src, "\t[%s]\tLocal chain ID = %s.\n", __FUNCTION__, src->live_chain_id );
   1.383      }
   1.384      src->live_tv_id = src->spawn_livetv->recorder->recorder_num;
   1.385 -    g_print ( "[%s] LiveTV id = %d, URI path = %s.\n", __FUNCTION__, src->live_tv_id, src->uri_name ); 
   1.386 +    GST_LOG_OBJECT( src, "[%s] LiveTV id = %d, URI path = %s.\n", __FUNCTION__, src->live_tv_id, src->uri_name ); 
   1.387    }
   1.388  
   1.389    src->file_transfer = gmyth_file_transfer_new( src->live_tv_id, 
   1.390 @@ -883,7 +687,7 @@
   1.391    if ( ret == FALSE ) {
   1.392  #ifndef GST_DISABLE_GST_DEBUG  
   1.393      if ( src->mythtv_msgs_dbg )
   1.394 -      g_printerr( "MythTV FileTransfer request failed when setting up socket connection!\n" );  	  
   1.395 +      GST_INFO_OBJECT( src, "MythTV FileTransfer request failed when setting up socket connection!\n" );  	  
   1.396  #endif
   1.397      goto begin_req_failed;
   1.398    }
   1.399 @@ -936,16 +740,6 @@
   1.400    }
   1.401  }
   1.402  
   1.403 -#if 0
   1.404 -static void
   1.405 -gst_mythtv_src_get_times (GstBaseSrc * src, GstBuffer * buffer,
   1.406 -    GstClockTime * start, GstClockTime * end)
   1.407 -{
   1.408 -  *start = -1;
   1.409 -  *end = -1;
   1.410 -}
   1.411 -#endif
   1.412 -
   1.413  /* create a new socket for connecting to the next program chain */
   1.414  static gboolean
   1.415  gst_mythtv_src_next_program_chain ( GstMythtvSrc *src )
   1.416 @@ -976,7 +770,7 @@
   1.417  
   1.418    if ( src->live_tv ) {
   1.419      if ( gmyth_livetv_next_program_chain( src->spawn_livetv ) == FALSE ) {
   1.420 -    	g_print( "\n\n[%s]\t\tFailed to go to the next program chain!!!\n\n", __FUNCTION__ );
   1.421 +    	GST_INFO_OBJECT( src, "\n\n[%s]\t\tFailed to go to the next program chain!!!\n\n", __FUNCTION__ );
   1.422        ret = FALSE;
   1.423        goto init_failed;
   1.424      }
   1.425 @@ -985,10 +779,10 @@
   1.426      chain_id_local = gmyth_tvchain_get_id( src->spawn_livetv->tvchain );
   1.427      if ( chain_id_local != NULL ) {
   1.428        src->live_chain_id = g_strdup( chain_id_local->str );
   1.429 -      g_print( "\t[%s]\tLocal chain ID = %s.\n", __FUNCTION__, src->live_chain_id );
   1.430 +      GST_DEBUG_OBJECT( src, "\t[%s]\tLocal chain ID = %s.\n", __FUNCTION__, src->live_chain_id );
   1.431      }
   1.432      src->live_tv_id = src->spawn_livetv->recorder->recorder_num;
   1.433 -    g_print ( "[%s] LiveTV id = %d, URI path = %s.\n", __FUNCTION__, src->live_tv_id, src->uri_name );
   1.434 +    GST_LOG_OBJECT( src, "[%s] LiveTV id = %d, URI path = %s.\n", __FUNCTION__, src->live_tv_id, src->uri_name );
   1.435    }
   1.436  
   1.437    src->file_transfer = gmyth_file_transfer_new( src->live_tv_id, 
   1.438 @@ -1018,23 +812,12 @@
   1.439    if ( ret == FALSE ) {
   1.440  #ifndef GST_DISABLE_GST_DEBUG  
   1.441      if ( src->mythtv_msgs_dbg )
   1.442 -      g_printerr( "MythTV FileTransfer request failed when setting up socket connection!\n" );  	  
   1.443 +      GST_ERROR_OBJECT( src, "MythTV FileTransfer request failed when setting up socket connection!\n" );  	  
   1.444  #endif
   1.445      goto begin_req_failed;
   1.446    }
   1.447    src->content_size_last = src->content_size;
   1.448  
   1.449 -#if 0
   1.450 -  if ( src->content_size < src->file_transfer->filesize ) {
   1.451 -    src->content_size = src->file_transfer->filesize;
   1.452 -  } else {
   1.453 -    //gint64 pos = gst_mythtv_src_get_position(src);
   1.454 -    //if ( pos > src->file_transfer->filesize )
   1.455 -    //	src->content_size = pos;  	
   1.456 -
   1.457 -  }
   1.458 -#endif
   1.459 -
   1.460    src->content_size = src->file_transfer->filesize;
   1.461    if ( src->live_tv ) {
   1.462    	wait_to_transfer = 0;
   1.463 @@ -1081,14 +864,13 @@
   1.464  {
   1.465    GstMythtvSrc *src = GST_MYTHTV_SRC (bsrc);
   1.466    gboolean ret = TRUE;
   1.467 -  g_print( "[%s] Differs from previous content size: %d (max.: %d)\n", __FUNCTION__, 
   1.468 +  GST_LOG_OBJECT( src, "[%s] Differs from previous content size: %d (max.: %d)\n", __FUNCTION__, 
   1.469    			abs( src->content_size - src->prev_content_size ), GMYTHTV_TRANSFER_MAX_BUFFER );
   1.470    			
   1.471    if ( src->live_tv ) {
   1.472    	ret = FALSE;
   1.473  	} else if ( src->live_tv && src->enable_timing_position && ( abs( src->content_size - src->bytes_read ) < 
   1.474  				GMYTHTV_TRANSFER_MAX_BUFFER ) ) {
   1.475 -    //g_static_mutex_lock( &update_size_mutex );
   1.476      
   1.477      gint64 new_offset = gmyth_file_transfer_get_file_position( src->file_transfer );
   1.478      if ( new_offset > 0 && new_offset > src->content_size ) {
   1.479 @@ -1097,11 +879,10 @@
   1.480  			src->update_prog_chain = TRUE;
   1.481  	  }
   1.482  
   1.483 -    //g_static_mutex_unlock( &update_size_mutex );
   1.484    }
   1.485  
   1.486    *size = src->content_size;
   1.487 -  g_print( "[%s] Content size = %lld\n", __FUNCTION__, src->content_size );
   1.488 +  GST_LOG_OBJECT( src, "[%s] Content size = %lld\n", __FUNCTION__, src->content_size );
   1.489    
   1.490    return ret;
   1.491  
   1.492 @@ -1139,38 +920,8 @@
   1.493    gboolean ret = FALSE;
   1.494  
   1.495    switch (GST_EVENT_TYPE (event)) {
   1.496 -#if 0
   1.497 -    case GST_EVENT_FLUSH_START:
   1.498 -      //src->eos = FALSE;
   1.499 -      g_print( "\n\n\n[%s]\t\tGot FLUSH_START event!!!\n\n\n", __FUNCTION__ );
   1.500 -      cont_size = gst_mythtv_src_get_position (src);
   1.501 -      if ( !src->live_tv ) {
   1.502 -	if ( cont_size > src->content_size ) {
   1.503 -	  src->content_size = cont_size;
   1.504 -	  src->eos = FALSE;
   1.505 -	} else {
   1.506 -	  src->eos = TRUE;
   1.507 -	  gst_element_set_state ( GST_ELEMENT (src), GST_STATE_NULL );
   1.508 -	  gst_element_set_locked_state ( GST_ELEMENT (src), FALSE );
   1.509 -	}
   1.510 -      } else {
   1.511 -	if ( cont_size <= 0 ) {
   1.512 -	  src->update_prog_chain = TRUE;
   1.513 -	  src->eos = TRUE;
   1.514 -	  src->unique_setup = FALSE;
   1.515 -	  src->do_start = TRUE;		  				  		
   1.516 -	}		  	
   1.517 -      }
   1.518 -      break;
   1.519 -    case GST_EVENT_FLUSH_STOP:
   1.520 -      src->do_start = TRUE;
   1.521 -      src->eos = FALSE;
   1.522 -      gst_element_set_state (GST_ELEMENT(src), GST_STATE_NULL);
   1.523 -      //gst_element_set_locked_state (GST_ELEMENT(src), TRUE);
   1.524 -      break;
   1.525 -#endif
   1.526      case GST_EVENT_EOS:
   1.527 -      g_print( "[%s] Got EOS event!!!\n", __FUNCTION__ );
   1.528 +      GST_WARNING_OBJECT( src, "[%s] Got EOS event!!!\n", __FUNCTION__ );
   1.529  
   1.530        if ( src->live_tv ) {
   1.531  	cont_size = gst_mythtv_src_get_position (src);
   1.532 @@ -1187,7 +938,7 @@
   1.533        ret = TRUE;
   1.534        break;
   1.535      case GST_EVENT_NEWSEGMENT:
   1.536 -      g_print( "[%s] Got NEWSEGMENT!!!\n", __FUNCTION__ );
   1.537 +      GST_INFO_OBJECT( src, "[%s] Got NEWSEGMENT!!!\n", __FUNCTION__ );
   1.538        ret = gst_pad_event_default (pad, event);
   1.539        break;
   1.540      case GST_EVENT_SEEK:  	  
   1.541 @@ -1195,7 +946,6 @@
   1.542  	gst_event_ref( event );
   1.543  
   1.544  	gdouble rate;
   1.545 -	//gboolean update = TRUE;
   1.546  	GstFormat format;
   1.547  	GstSeekType cur_type, stop_type;
   1.548  	GstSeekFlags flags;
   1.549 @@ -1204,9 +954,9 @@
   1.550  	    &flags, &cur_type, &cur,
   1.551  	    &stop_type, &stop );
   1.552  
   1.553 -	g_print( "[%s] Got EVENT_SEEK (pos = %lld)!!!\n", __FUNCTION__, cur );
   1.554 +	GST_INFO_OBJECT( src, "[%s] Got EVENT_SEEK (pos = %lld)!!!\n", __FUNCTION__, cur );
   1.555  	if ( !( flags & GST_SEEK_FLAG_FLUSH ) ) {
   1.556 -	  g_print( "[%s] Could get the FLAG_FLUSH message.\n", __FUNCTION__ );
   1.557 +	  GST_WARNING_OBJECT( src, "[%s] Could get the FLAG_FLUSH message.\n", __FUNCTION__ );
   1.558  	}
   1.559  	if ( format == GST_FORMAT_TIME && ( ret = gst_pad_event_default (pad, event) ) == FALSE ) {
   1.560  	  gst_event_unref( event );
   1.561 @@ -1289,13 +1039,16 @@
   1.562  
   1.563    switch (transition) {
   1.564      case GST_STATE_CHANGE_READY_TO_NULL:
   1.565 -      g_print( "[%s] READY to NULL called!\n", __FUNCTION__ );
   1.566 +      GST_INFO_OBJECT( src, "[%s] READY to NULL called!\n", __FUNCTION__ );
   1.567        break;
   1.568      case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
   1.569 -      g_print( "[%s] PLAYING to PAUSED called!\n", __FUNCTION__ );
   1.570 +      GST_INFO_OBJECT( src, "[%s] PLAYING to PAUSED called!\n", __FUNCTION__ );
   1.571      case GST_STATE_CHANGE_PAUSED_TO_READY:
   1.572 -      g_print( "[%s] PAUSED to READY called!\n", __FUNCTION__ );
   1.573 -      
   1.574 +      GST_INFO_OBJECT( src, "[%s] PAUSED to READY called!\n", __FUNCTION__ );
   1.575 +      if ( !gmyth_recorder_send_frontend_ready_command( src->spawn_livetv->recorder ) )
   1.576 +      	GST_WARNING_OBJECT( src, "[%s] Couldn't send the FRONTEND_READY message to the backend!", __FUNCTION__ );
   1.577 +      else
   1.578 +      	GST_DEBUG_OBJECT( src, "[%s] Message FRONTEND_READY was sent to the backend!", __FUNCTION__ );
   1.579        if ( src->live_tv && src->update_prog_chain ) {
   1.580        	
   1.581        /*