# HG changeset patch # User rosfran # Date 1176500449 -3600 # Node ID aaf53e3d0b262426e8281bbe610f4712e34e3a2b # Parent 514f55d6b47ae553562fc385d2083d371e7699d0 [svn r555] Fixes the _dispose handler, and adds the GMythFile instances. diff -r 514f55d6b47a -r aaf53e3d0b26 gmyth/src/gmyth_livetv.c --- a/gmyth/src/gmyth_livetv.c Fri Apr 13 21:16:52 2007 +0100 +++ b/gmyth/src/gmyth_livetv.c Fri Apr 13 22:40:49 2007 +0100 @@ -36,7 +36,9 @@ #include "gmyth_backendinfo.h" #include "gmyth_debug.h" +#include "gmyth_file.h" #include "gmyth_file_transfer.h" +#include "gmyth_file_local.h" #include "gmyth_monitor_handler.h" #include "gmyth_common.h" @@ -72,7 +74,7 @@ livetv->monitor = NULL; livetv->backend_info = NULL; livetv->local_hostname = NULL; - livetv->file_transfer = NULL; + livetv->file = NULL; livetv->setup_done = FALSE; livetv->socket = NULL; @@ -101,6 +103,11 @@ g_object_unref (livetv->monitor); livetv->monitor = NULL; } + + if ( livetv->file != NULL ) { + g_object_unref (livetv->file); + livetv->file = NULL; + } if ( livetv->recorder != NULL ) { //gmyth_recorder_close(livetv->recorder); @@ -123,11 +130,6 @@ livetv->proginfo = NULL; } - if ( livetv->file_transfer != NULL ) { - g_object_unref (livetv->file_transfer); - livetv->file_transfer = NULL; - } - if ( livetv->backend_info != NULL ) { g_object_unref (livetv->backend_info); livetv->backend_info = NULL; @@ -194,7 +196,7 @@ gmyth_debug( "LIVETV Signal handler ( msg = %s, code = %d, live_tv param = %s, user_data = %s )\n", message, msg_code, live_tv != NULL ? "" : "NULL", user_data != NULL ? "" : "NULL" ); - if ( NULL == live_tv ) + if ( NULL == live_tv || !IS_GMYTH_FILE_TRANSFER( live_tv->file ) ) { gmyth_debug( "LiveTV_obj is equals to NULL!!!" ); return; @@ -211,11 +213,11 @@ gmyth_debug( "OK!!! MOVED to the next program chain [actual == %s]!", (gmyth_tvchain_get_id( live_tv->tvchain ))->str ); /* advertises the FileTransfer about the program info changed */ - if ( live_tv->file_transfer != NULL ) + if ( live_tv->file != NULL ) { gmyth_debug( "Emitting signal to the FileTransfer... [ \"program-info-changed \" ]" ); - gmyth_file_transfer_emit_program_info_changed_signal( live_tv->file_transfer, + gmyth_file_transfer_emit_program_info_changed_signal( GMYTH_FILE_TRANSFER(live_tv->file), msg_code, (gpointer)(live_tv->recorder) ); /* gmyth_livetv_monitor_handler_stop( live_tv ); */ @@ -232,11 +234,11 @@ gmyth_debug( "OK!!! MOVED to the next program chain [actual == %s]!", (gmyth_tvchain_get_id( live_tv->tvchain ))->str ); /* advertises the FileTransfer about the program info changed */ - if ( live_tv->file_transfer != NULL ) + if ( live_tv->file != NULL ) { gmyth_debug( "Emitting signal to the FileTransfer... [ \"backend-done-recording\" ]" ); - gmyth_file_transfer_emit_program_info_changed_signal( live_tv->file_transfer, + gmyth_file_transfer_emit_program_info_changed_signal( GMYTH_FILE_TRANSFER(live_tv->file), msg_code, (gpointer)(live_tv->recorder) ); } else @@ -745,12 +747,12 @@ * @return the actual GMythFileTransfer instance, generated using the * data got from the actual program info. */ -GMythFileTransfer * +GMythFile * gmyth_livetv_create_file_transfer( GMythLiveTV *livetv ) { //GMythURI* uri = NULL; - if ( NULL == livetv ) + if ( NULL == livetv ) goto done; if ( !livetv->setup_done ) @@ -766,55 +768,51 @@ gmyth_debug( "URI path (from URI) = %s.\n", livetv->uri->uri->str ); #endif - g_mutex_lock( livetv->mutex ); + g_mutex_lock( livetv->mutex ); - if ( livetv->file_transfer != NULL ) - { - /*gmyth_file_transfer_close( livetv->file_transfer );*/ - g_object_unref( livetv->file_transfer ); - livetv->file_transfer = NULL; - } + if ( livetv->file != NULL ) + { + /*gmyth_file_transfer_close( livetv->file );*/ + g_object_unref( livetv->file ); + livetv->file = NULL; + } - if ( livetv->uri != NULL ) - { - /* - if ( livetv->uri->path != NULL ) - { - g_string_free( livetv->uri->path, FALSE ); - livetv->uri->path = NULL; - } - */ -#ifdef GMYTH_USE_DEBUG - gmyth_debug( "URI is not NULL, creating from the ProgramInfo pathname... (%s)", livetv->proginfo->pathname->str ); -#endif - livetv->uri->path = g_string_erase(livetv->uri->path, 0, -1); - livetv->uri->path = g_string_new( g_strrstr( livetv->proginfo->pathname->str, "/" ) ); - } else { -#ifdef GMYTH_USE_DEBUG - gmyth_debug( "URI is NULL, creating from the ProgramInfo pathname... (%s)", livetv->proginfo->pathname->str ); -#endif - livetv->uri = gmyth_uri_new_with_value( livetv->proginfo->pathname->str ); - } + if ( livetv->uri != NULL ) + { + + #ifdef GMYTH_USE_DEBUG + gmyth_debug( "URI is not NULL, creating from the ProgramInfo pathname... (%s)", livetv->proginfo->pathname->str ); + #endif + livetv->uri->path = g_string_erase(livetv->uri->path, 0, -1); + livetv->uri->path = g_string_new( g_strrstr( livetv->proginfo->pathname->str, "/" ) ); + } else { + #ifdef GMYTH_USE_DEBUG + gmyth_debug( "URI is NULL, creating from the ProgramInfo pathname... (%s)", livetv->proginfo->pathname->str ); + #endif + livetv->uri = gmyth_uri_new_with_value( livetv->proginfo->pathname->str ); + } - if ( NULL == livetv->uri ) - { - gmyth_debug( "Couldn't parse the URI to start LiveTV! [ uri = %s ]", livetv->proginfo->pathname->str ); - goto done; - } - - livetv->file_transfer = gmyth_file_transfer_new( livetv->backend_info ); + if ( NULL == livetv->uri ) + { + gmyth_debug( "Couldn't parse the URI to start LiveTV! [ uri = %s ]", livetv->proginfo->pathname->str ); + goto done; + } + + if ( gmyth_uri_is_local_file( livetv->uri ) ) + livetv->file = GMYTH_FILE( gmyth_file_local_new( livetv->backend_info ) ); + else + livetv->file = GMYTH_FILE( gmyth_file_transfer_new( livetv->backend_info ) ); - if ( NULL == livetv->file_transfer ) - { - gmyth_debug( "Error: couldn't create the FileTransfer from LiveTV source!" ); - goto done; - } + if ( NULL == livetv->file ) + { + gmyth_debug( "Error: couldn't create the FileTransfer from LiveTV source!" ); + goto done; + } - g_object_ref( livetv->file_transfer ); + g_object_ref( livetv->file ); - /* gmyth_file_transfer_settimeout( livetv->file_transfer, TRUE ); */ - - g_mutex_unlock( livetv->mutex ); + /* gmyth_file_transfer_settimeout( livetv->file, TRUE ); */ + g_mutex_unlock( livetv->mutex ); done: /* @@ -825,7 +823,7 @@ } */ - return livetv->file_transfer; + return livetv->file; } diff -r 514f55d6b47a -r aaf53e3d0b26 gmyth/src/gmyth_livetv.h --- a/gmyth/src/gmyth_livetv.h Fri Apr 13 21:16:52 2007 +0100 +++ b/gmyth/src/gmyth_livetv.h Fri Apr 13 22:40:49 2007 +0100 @@ -34,7 +34,7 @@ #include "gmyth_recorder.h" #include "gmyth_tvchain.h" #include "gmyth_monitor_handler.h" -#include "gmyth_file_transfer.h" +#include "gmyth_file.h" #include "gmyth_programinfo.h" #include "gmyth_backendinfo.h" @@ -71,7 +71,7 @@ GMythTVChain *tvchain; GMythProgramInfo *proginfo; - GMythFileTransfer *file_transfer; + GMythFile *file; GMythMonitorHandler *monitor; GMythURI *uri; @@ -95,7 +95,7 @@ gboolean gmyth_livetv_channel_name_setup ( GMythLiveTV *livetv, gchar* channel); gboolean gmyth_livetv_next_program_chain ( GMythLiveTV *livetv ); -GMythFileTransfer* gmyth_livetv_create_file_transfer( GMythLiveTV *livetv ); +GMythFile* gmyth_livetv_create_file_transfer( GMythLiveTV *livetv ); gboolean gmyth_livetv_monitor_handler_start( GMythLiveTV *livetv ); void gmyth_livetv_monitor_handler_stop( GMythLiveTV *livetv ); diff -r 514f55d6b47a -r aaf53e3d0b26 gmyth/src/gmyth_monitor_handler.c --- a/gmyth/src/gmyth_monitor_handler.c Fri Apr 13 21:16:52 2007 +0100 +++ b/gmyth/src/gmyth_monitor_handler.c Fri Apr 13 22:40:49 2007 +0100 @@ -149,19 +149,19 @@ monitor->allow_msgs_listener = FALSE; - /* mutex to control access to the event socket consumer thread */ - if ( monitor->mutex != NULL ) - { - g_mutex_unlock( monitor->mutex ); - g_mutex_free( monitor->mutex ); - monitor->mutex = NULL; - } - if (monitor->sid_io_watch != -1) { g_source_remove (monitor->sid_io_watch); } + /* mutex to control access to the event socket consumer thread */ + if ( monitor->mutex != NULL ) + { + //g_mutex_unlock( monitor->mutex ); + g_mutex_free( monitor->mutex ); + monitor->mutex = NULL; + } + if ( monitor->event_sock != NULL ) { g_object_unref( monitor->event_sock );