[svn r555] Fixes the _dispose handler, and adds the GMythFile instances.
1.1 --- a/gmyth/src/gmyth_livetv.c Fri Apr 13 21:16:52 2007 +0100
1.2 +++ b/gmyth/src/gmyth_livetv.c Fri Apr 13 22:40:49 2007 +0100
1.3 @@ -36,7 +36,9 @@
1.4 #include "gmyth_backendinfo.h"
1.5 #include "gmyth_debug.h"
1.6
1.7 +#include "gmyth_file.h"
1.8 #include "gmyth_file_transfer.h"
1.9 +#include "gmyth_file_local.h"
1.10 #include "gmyth_monitor_handler.h"
1.11
1.12 #include "gmyth_common.h"
1.13 @@ -72,7 +74,7 @@
1.14 livetv->monitor = NULL;
1.15 livetv->backend_info = NULL;
1.16 livetv->local_hostname = NULL;
1.17 - livetv->file_transfer = NULL;
1.18 + livetv->file = NULL;
1.19 livetv->setup_done = FALSE;
1.20
1.21 livetv->socket = NULL;
1.22 @@ -101,6 +103,11 @@
1.23 g_object_unref (livetv->monitor);
1.24 livetv->monitor = NULL;
1.25 }
1.26 +
1.27 + if ( livetv->file != NULL ) {
1.28 + g_object_unref (livetv->file);
1.29 + livetv->file = NULL;
1.30 + }
1.31
1.32 if ( livetv->recorder != NULL ) {
1.33 //gmyth_recorder_close(livetv->recorder);
1.34 @@ -123,11 +130,6 @@
1.35 livetv->proginfo = NULL;
1.36 }
1.37
1.38 - if ( livetv->file_transfer != NULL ) {
1.39 - g_object_unref (livetv->file_transfer);
1.40 - livetv->file_transfer = NULL;
1.41 - }
1.42 -
1.43 if ( livetv->backend_info != NULL ) {
1.44 g_object_unref (livetv->backend_info);
1.45 livetv->backend_info = NULL;
1.46 @@ -194,7 +196,7 @@
1.47 gmyth_debug( "LIVETV Signal handler ( msg = %s, code = %d, live_tv param = %s, user_data = %s )\n", message, msg_code, live_tv != NULL ? "" :
1.48 "NULL", user_data != NULL ? "" : "NULL" );
1.49
1.50 - if ( NULL == live_tv )
1.51 + if ( NULL == live_tv || !IS_GMYTH_FILE_TRANSFER( live_tv->file ) )
1.52 {
1.53 gmyth_debug( "LiveTV_obj is equals to NULL!!!" );
1.54 return;
1.55 @@ -211,11 +213,11 @@
1.56 gmyth_debug( "OK!!! MOVED to the next program chain [actual == %s]!",
1.57 (gmyth_tvchain_get_id( live_tv->tvchain ))->str );
1.58 /* advertises the FileTransfer about the program info changed */
1.59 - if ( live_tv->file_transfer != NULL )
1.60 + if ( live_tv->file != NULL )
1.61 {
1.62 gmyth_debug( "Emitting signal to the FileTransfer... [ \"program-info-changed \" ]" );
1.63
1.64 - gmyth_file_transfer_emit_program_info_changed_signal( live_tv->file_transfer,
1.65 + gmyth_file_transfer_emit_program_info_changed_signal( GMYTH_FILE_TRANSFER(live_tv->file),
1.66 msg_code, (gpointer)(live_tv->recorder) );
1.67
1.68 /* gmyth_livetv_monitor_handler_stop( live_tv ); */
1.69 @@ -232,11 +234,11 @@
1.70 gmyth_debug( "OK!!! MOVED to the next program chain [actual == %s]!",
1.71 (gmyth_tvchain_get_id( live_tv->tvchain ))->str );
1.72 /* advertises the FileTransfer about the program info changed */
1.73 - if ( live_tv->file_transfer != NULL )
1.74 + if ( live_tv->file != NULL )
1.75 {
1.76 gmyth_debug( "Emitting signal to the FileTransfer... [ \"backend-done-recording\" ]" );
1.77
1.78 - gmyth_file_transfer_emit_program_info_changed_signal( live_tv->file_transfer,
1.79 + gmyth_file_transfer_emit_program_info_changed_signal( GMYTH_FILE_TRANSFER(live_tv->file),
1.80 msg_code, (gpointer)(live_tv->recorder) );
1.81
1.82 } else
1.83 @@ -745,12 +747,12 @@
1.84 * @return the actual GMythFileTransfer instance, generated using the
1.85 * data got from the actual program info.
1.86 */
1.87 -GMythFileTransfer *
1.88 +GMythFile *
1.89 gmyth_livetv_create_file_transfer( GMythLiveTV *livetv )
1.90 {
1.91 //GMythURI* uri = NULL;
1.92
1.93 - if ( NULL == livetv )
1.94 + if ( NULL == livetv )
1.95 goto done;
1.96
1.97 if ( !livetv->setup_done )
1.98 @@ -766,55 +768,51 @@
1.99 gmyth_debug( "URI path (from URI) = %s.\n", livetv->uri->uri->str );
1.100 #endif
1.101
1.102 - g_mutex_lock( livetv->mutex );
1.103 + g_mutex_lock( livetv->mutex );
1.104
1.105 - if ( livetv->file_transfer != NULL )
1.106 - {
1.107 - /*gmyth_file_transfer_close( livetv->file_transfer );*/
1.108 - g_object_unref( livetv->file_transfer );
1.109 - livetv->file_transfer = NULL;
1.110 - }
1.111 + if ( livetv->file != NULL )
1.112 + {
1.113 + /*gmyth_file_transfer_close( livetv->file );*/
1.114 + g_object_unref( livetv->file );
1.115 + livetv->file = NULL;
1.116 + }
1.117
1.118 - if ( livetv->uri != NULL )
1.119 - {
1.120 - /*
1.121 - if ( livetv->uri->path != NULL )
1.122 - {
1.123 - g_string_free( livetv->uri->path, FALSE );
1.124 - livetv->uri->path = NULL;
1.125 - }
1.126 - */
1.127 -#ifdef GMYTH_USE_DEBUG
1.128 - gmyth_debug( "URI is not NULL, creating from the ProgramInfo pathname... (%s)", livetv->proginfo->pathname->str );
1.129 -#endif
1.130 - livetv->uri->path = g_string_erase(livetv->uri->path, 0, -1);
1.131 - livetv->uri->path = g_string_new( g_strrstr( livetv->proginfo->pathname->str, "/" ) );
1.132 - } else {
1.133 -#ifdef GMYTH_USE_DEBUG
1.134 - gmyth_debug( "URI is NULL, creating from the ProgramInfo pathname... (%s)", livetv->proginfo->pathname->str );
1.135 -#endif
1.136 - livetv->uri = gmyth_uri_new_with_value( livetv->proginfo->pathname->str );
1.137 - }
1.138 + if ( livetv->uri != NULL )
1.139 + {
1.140 +
1.141 + #ifdef GMYTH_USE_DEBUG
1.142 + gmyth_debug( "URI is not NULL, creating from the ProgramInfo pathname... (%s)", livetv->proginfo->pathname->str );
1.143 + #endif
1.144 + livetv->uri->path = g_string_erase(livetv->uri->path, 0, -1);
1.145 + livetv->uri->path = g_string_new( g_strrstr( livetv->proginfo->pathname->str, "/" ) );
1.146 + } else {
1.147 + #ifdef GMYTH_USE_DEBUG
1.148 + gmyth_debug( "URI is NULL, creating from the ProgramInfo pathname... (%s)", livetv->proginfo->pathname->str );
1.149 + #endif
1.150 + livetv->uri = gmyth_uri_new_with_value( livetv->proginfo->pathname->str );
1.151 + }
1.152
1.153 - if ( NULL == livetv->uri )
1.154 - {
1.155 - gmyth_debug( "Couldn't parse the URI to start LiveTV! [ uri = %s ]", livetv->proginfo->pathname->str );
1.156 - goto done;
1.157 - }
1.158 -
1.159 - livetv->file_transfer = gmyth_file_transfer_new( livetv->backend_info );
1.160 + if ( NULL == livetv->uri )
1.161 + {
1.162 + gmyth_debug( "Couldn't parse the URI to start LiveTV! [ uri = %s ]", livetv->proginfo->pathname->str );
1.163 + goto done;
1.164 + }
1.165 +
1.166 + if ( gmyth_uri_is_local_file( livetv->uri ) )
1.167 + livetv->file = GMYTH_FILE( gmyth_file_local_new( livetv->backend_info ) );
1.168 + else
1.169 + livetv->file = GMYTH_FILE( gmyth_file_transfer_new( livetv->backend_info ) );
1.170
1.171 - if ( NULL == livetv->file_transfer )
1.172 - {
1.173 - gmyth_debug( "Error: couldn't create the FileTransfer from LiveTV source!" );
1.174 - goto done;
1.175 - }
1.176 + if ( NULL == livetv->file )
1.177 + {
1.178 + gmyth_debug( "Error: couldn't create the FileTransfer from LiveTV source!" );
1.179 + goto done;
1.180 + }
1.181
1.182 - g_object_ref( livetv->file_transfer );
1.183 + g_object_ref( livetv->file );
1.184
1.185 - /* gmyth_file_transfer_settimeout( livetv->file_transfer, TRUE ); */
1.186 -
1.187 - g_mutex_unlock( livetv->mutex );
1.188 + /* gmyth_file_transfer_settimeout( livetv->file, TRUE ); */
1.189 + g_mutex_unlock( livetv->mutex );
1.190
1.191 done:
1.192 /*
1.193 @@ -825,7 +823,7 @@
1.194 }
1.195 */
1.196
1.197 - return livetv->file_transfer;
1.198 + return livetv->file;
1.199
1.200 }
1.201
2.1 --- a/gmyth/src/gmyth_livetv.h Fri Apr 13 21:16:52 2007 +0100
2.2 +++ b/gmyth/src/gmyth_livetv.h Fri Apr 13 22:40:49 2007 +0100
2.3 @@ -34,7 +34,7 @@
2.4 #include "gmyth_recorder.h"
2.5 #include "gmyth_tvchain.h"
2.6 #include "gmyth_monitor_handler.h"
2.7 -#include "gmyth_file_transfer.h"
2.8 +#include "gmyth_file.h"
2.9 #include "gmyth_programinfo.h"
2.10 #include "gmyth_backendinfo.h"
2.11
2.12 @@ -71,7 +71,7 @@
2.13 GMythTVChain *tvchain;
2.14 GMythProgramInfo *proginfo;
2.15
2.16 - GMythFileTransfer *file_transfer;
2.17 + GMythFile *file;
2.18
2.19 GMythMonitorHandler *monitor;
2.20 GMythURI *uri;
2.21 @@ -95,7 +95,7 @@
2.22 gboolean gmyth_livetv_channel_name_setup ( GMythLiveTV *livetv, gchar* channel);
2.23 gboolean gmyth_livetv_next_program_chain ( GMythLiveTV *livetv );
2.24
2.25 -GMythFileTransfer* gmyth_livetv_create_file_transfer( GMythLiveTV *livetv );
2.26 +GMythFile* gmyth_livetv_create_file_transfer( GMythLiveTV *livetv );
2.27
2.28 gboolean gmyth_livetv_monitor_handler_start( GMythLiveTV *livetv );
2.29 void gmyth_livetv_monitor_handler_stop( GMythLiveTV *livetv );
3.1 --- a/gmyth/src/gmyth_monitor_handler.c Fri Apr 13 21:16:52 2007 +0100
3.2 +++ b/gmyth/src/gmyth_monitor_handler.c Fri Apr 13 22:40:49 2007 +0100
3.3 @@ -149,19 +149,19 @@
3.4
3.5 monitor->allow_msgs_listener = FALSE;
3.6
3.7 - /* mutex to control access to the event socket consumer thread */
3.8 - if ( monitor->mutex != NULL )
3.9 - {
3.10 - g_mutex_unlock( monitor->mutex );
3.11 - g_mutex_free( monitor->mutex );
3.12 - monitor->mutex = NULL;
3.13 - }
3.14 -
3.15 if (monitor->sid_io_watch != -1)
3.16 {
3.17 g_source_remove (monitor->sid_io_watch);
3.18 }
3.19
3.20 + /* mutex to control access to the event socket consumer thread */
3.21 + if ( monitor->mutex != NULL )
3.22 + {
3.23 + //g_mutex_unlock( monitor->mutex );
3.24 + g_mutex_free( monitor->mutex );
3.25 + monitor->mutex = NULL;
3.26 + }
3.27 +
3.28 if ( monitor->event_sock != NULL )
3.29 {
3.30 g_object_unref( monitor->event_sock );