# HG changeset patch # User rosfran # Date 1169590821 0 # Node ID c56122d88430dd6b29af2bb18bb113d583ad73a5 # Parent 73fa3a0f2f085e31fdef7aad7d2ccb8392c1a2ef [svn r293] Some fixes to the program info. diff -r 73fa3a0f2f08 -r c56122d88430 gmyth/src/gmyth_livetv.c --- a/gmyth/src/gmyth_livetv.c Tue Jan 23 21:37:27 2007 +0000 +++ b/gmyth/src/gmyth_livetv.c Tue Jan 23 22:20:21 2007 +0000 @@ -46,7 +46,7 @@ static gint tvchain_curr_index = -1; -#define GMYTHTV_RECORDER_HEADER "QUERY_RECORDER" +static GStaticMutex lock = G_STATIC_MUTEX_INIT; #define GMYTHTV_TRANSFER_MAX_WAITS 100 @@ -239,6 +239,8 @@ GMythSocket *socket = gmyth_socket_new (); livetv->backend_info = backend_info; + + g_static_mutex_lock( &lock ); // FIME: Implement this at gmyth_socket res = gmyth_socket_connect_to_backend (socket, livetv->backend_info->hostname, @@ -299,11 +301,11 @@ gint wait_to_transfer = 0; while (wait_to_transfer++ < GMYTHTV_TRANSFER_MAX_WAITS && - (gmyth_livetv_is_recording (livetv) == FALSE)) + (gmyth_recorder_is_recording (livetv->recorder) == FALSE)) g_usleep (500); /* IS_RECORDING again, just like the MythTV backend does... */ - gmyth_livetv_is_recording (livetv); + gmyth_recorder_is_recording (livetv->recorder); if ( channel != -1 ) { @@ -328,7 +330,6 @@ sleep (6); /* FIXME: this is evil (tpm) */ } - // Reload all TV chain from Mysql database. gmyth_tvchain_reload_all (livetv->tvchain); @@ -347,6 +348,8 @@ res = TRUE; gmyth_debug ("GMythLiveTV: All requests to backend to start TV were OK. [%s]\n", livetv->proginfo->pathname->str ); } + + g_static_mutex_unlock( &lock ); if ( !gmyth_livetv_monitor_handler_start( livetv ) ) { @@ -483,6 +486,8 @@ } gmyth_debug( "URI path = %s.\n", livetv->proginfo->pathname->str ); + + g_static_mutex_lock( &lock ); livetv->file_transfer = gmyth_file_transfer_new( livetv->backend_info ); @@ -507,6 +512,8 @@ livetv->file_transfer = NULL; goto done; } + + g_static_mutex_unlock( &lock ); done: if ( uri != NULL ) @@ -532,45 +539,6 @@ } } -// FIXME: put here just a wrapper function to call gmyth_recorder_is_recording()... -gboolean -gmyth_livetv_is_recording ( GMythLiveTV *livetv ) -{ - gboolean ret = TRUE; - - GMythStringList *str_list = gmyth_string_list_new (); - GString *message = g_string_new (""); - - g_string_printf( message, "%s %d", GMYTHTV_RECORDER_HEADER, - /* FIXME file_transfer->rec_id >= 0 ? file_transfer->rec_id : file_transfer->card_id );*/ - livetv->recorder->recorder_num); - gmyth_string_list_append_string (str_list, message); - gmyth_string_list_append_string (str_list, g_string_new ("IS_RECORDING")); - - gmyth_socket_sendreceive_stringlist ( livetv->recorder->myth_socket, str_list ); - - if ( str_list != NULL && gmyth_string_list_length(str_list) > 0 ) - { - GString *str = NULL; - if ( ( str = gmyth_string_list_get_string( str_list, 0 ) ) != NULL && strcmp( str->str, "bad" )!= 0 ) { - gint is_rec = gmyth_string_list_get_int( str_list, 0 ); - if ( is_rec != 0 ) - ret = TRUE; - else - ret = FALSE; - } - } - g_print( "[%s] %s, stream is %s being recorded!\n", __FUNCTION__, ret ? "YES" : "NO", ret ? "" : "NOT" ); - //g_static_mutex_unlock (&mutex); - - if ( str_list != NULL ) - g_object_unref (str_list); - - return ret; - -} - - gboolean gmyth_livetv_is_playing (GMythLiveTV *livetv) { diff -r 73fa3a0f2f08 -r c56122d88430 gmyth/src/gmyth_livetv.h --- a/gmyth/src/gmyth_livetv.h Tue Jan 23 21:37:27 2007 +0000 +++ b/gmyth/src/gmyth_livetv.h Tue Jan 23 22:20:21 2007 +0000 @@ -85,8 +85,6 @@ void gmyth_livetv_start_playing (GMythLiveTV *livetv); void gmyth_livetv_stop_playing (GMythLiveTV *livetv); -gboolean gmyth_livetv_is_recording ( GMythLiveTV *livetv ); - gboolean gmyth_livetv_setup (GMythLiveTV *livetv, GMythBackendInfo *backend_info); gboolean gmyth_livetv_channel_setup ( GMythLiveTV *livetv, gint channel, GMythBackendInfo *backend_info ); gboolean gmyth_livetv_next_program_chain ( GMythLiveTV *livetv ); diff -r 73fa3a0f2f08 -r c56122d88430 gmyth/src/gmyth_programinfo.c --- a/gmyth/src/gmyth_programinfo.c Tue Jan 23 21:37:27 2007 +0000 +++ b/gmyth/src/gmyth_programinfo.c Tue Jan 23 22:20:21 2007 +0000 @@ -148,7 +148,7 @@ static void gmyth_program_info_dispose (GObject *object) { - GMythProgramInfo *gmyth_program_info = GMYTH_PROGRAM_INFO(object); + //GMythProgramInfo *gmyth_program_info = GMYTH_PROGRAM_INFO(object); G_OBJECT_CLASS (gmyth_program_info_parent_class)->dispose (object); } @@ -232,47 +232,47 @@ g_return_val_if_fail (slist != NULL, NULL); - prog->title = gmyth_string_list_read_string (slist); - prog->subtitle = gmyth_string_list_read_string (slist); - prog->description = gmyth_string_list_read_string (slist); - prog->category = gmyth_string_list_read_string (slist); - prog->chanid = gmyth_string_list_read_string (slist); - prog->chanstr = gmyth_string_list_read_string (slist); - prog->chansign = gmyth_string_list_read_string (slist); - prog->channame = gmyth_string_list_read_string (slist); - prog->pathname = gmyth_string_list_read_string (slist); - prog->filesize = gmyth_string_list_read_int64 (slist); + prog->title = gmyth_string_list_get_string (slist, 0); + prog->subtitle = gmyth_string_list_get_string (slist, 1); + prog->description = gmyth_string_list_get_string (slist, 2); + prog->category = gmyth_string_list_get_string (slist, 3); + prog->chanid = gmyth_string_list_get_string (slist, 4); + prog->chanstr = gmyth_string_list_get_string (slist, 5); + prog->chansign = gmyth_string_list_get_string (slist, 6); + prog->channame = gmyth_string_list_get_string (slist, 7); + prog->pathname = gmyth_string_list_get_string (slist, 8); + prog->filesize = gmyth_string_list_get_int64 (slist, 9); - gmyth_string_list_read_int (slist); //DATETIME_TO_LIST(startts) - gmyth_string_list_read_int (slist); //DATETIME_TO_LIST(endts) - prog->duplicate = gmyth_string_list_read_int (slist); - prog->shareable = gmyth_string_list_read_int (slist); - prog->findid = gmyth_string_list_read_int (slist); - prog->hostname = gmyth_string_list_read_string (slist); - prog->sourceid = gmyth_string_list_read_int (slist); - prog->cardid = gmyth_string_list_read_int (slist); - prog->inputid = gmyth_string_list_read_int (slist); - prog->recpriority = gmyth_string_list_read_int (slist); - gmyth_string_list_read_int (slist); - prog->recordid = gmyth_string_list_read_int (slist, prog->recordid); - gmyth_string_list_read_int (slist); - gmyth_string_list_read_int (slist); - gmyth_string_list_read_int (slist); - gmyth_string_list_read_int (slist); //DATETIME_TO_LIST(recstartts) - gmyth_string_list_read_int (slist); //DATETIME_TO_LIST(recendts) - prog->repeat = gmyth_string_list_read_int (slist); - prog->programflags = gmyth_string_list_read_int (slist); - prog->recgroup = gmyth_string_list_read_string (slist); //prog->(recgroup != "") ? recgroup : "Default") - prog->chancommfree = gmyth_string_list_read_int (slist); - prog->chanOutputFilters = gmyth_string_list_read_string (slist); - prog->seriesid = gmyth_string_list_read_string (slist); - prog->programid = gmyth_string_list_read_string (slist); - gmyth_string_list_read_int (slist); //DATETIME_TO_LIST(lastmodified) - gmyth_string_list_read_int (slist); //FLOAT_TO_LIST(stars) - gmyth_string_list_read_int (slist); //DATETIME_TO_LIST(QDateTime(originalAirDate)) - prog->hasAirDate = gmyth_string_list_read_int (slist); - prog->playgroup = gmyth_string_list_read_char_array (slist); //prog->(playgroup != "") ? playgroup : "Default") - prog->recpriority2 = gmyth_string_list_read_int (slist); + gmyth_string_list_get_int (slist, 10); //DATETIME_TO_LIST(startts) + gmyth_string_list_get_int (slist, 11); //DATETIME_TO_LIST(endts) + prog->duplicate = gmyth_string_list_get_int (slist, 12); + prog->shareable = gmyth_string_list_get_int (slist, 13); + prog->findid = gmyth_string_list_get_int (slist, 14); + prog->hostname = gmyth_string_list_get_string (slist, 15); + prog->sourceid = gmyth_string_list_get_int (slist, 16); + prog->cardid = gmyth_string_list_get_int (slist, 17); + prog->inputid = gmyth_string_list_get_int (slist, 18); + prog->recpriority = gmyth_string_list_get_int (slist, 19); + gmyth_string_list_get_int (slist, 20); + prog->recordid = gmyth_string_list_get_int (slist, 21); + gmyth_string_list_get_int (slist, 22); + gmyth_string_list_get_int (slist, 23); + gmyth_string_list_get_int (slist, 24); + gmyth_string_list_get_int (slist, 25); //DATETIME_TO_LIST(recstartts) + gmyth_string_list_get_int (slist, 26); //DATETIME_TO_LIST(recendts) + prog->repeat = gmyth_string_list_get_int (slist, 27); + prog->programflags = gmyth_string_list_get_int (slist, 28); + prog->recgroup = gmyth_string_list_get_string (slist, 29); //prog->(recgroup != "") ? recgroup : "Default") + prog->chancommfree = gmyth_string_list_get_int (slist, 30); + prog->chanOutputFilters = gmyth_string_list_get_string (slist, 31); + prog->seriesid = gmyth_string_list_get_string (slist, 32); + prog->programid = gmyth_string_list_get_string (slist, 33); + gmyth_string_list_get_int (slist, 34); //DATETIME_TO_LIST(lastmodified) + gmyth_string_list_get_int (slist, 35); //FLOAT_TO_LIST(stars) + gmyth_string_list_get_int (slist, 36); //DATETIME_TO_LIST(QDateTime(originalAirDate)) + prog->hasAirDate = gmyth_string_list_get_int (slist, 37); + prog->playgroup = gmyth_string_list_get_string (slist, 38); //prog->(playgroup != "") ? playgroup : "Default") + prog->recpriority2 = gmyth_string_list_get_int (slist, 39); return prog; } diff -r 73fa3a0f2f08 -r c56122d88430 gmyth/src/gmyth_programinfo.h --- a/gmyth/src/gmyth_programinfo.h Tue Jan 23 21:37:27 2007 +0000 +++ b/gmyth/src/gmyth_programinfo.h Tue Jan 23 22:20:21 2007 +0000 @@ -92,9 +92,9 @@ GString *seriesid; /** The program unique id. */ GString *programid; - GString * catType; + GString *catType; - GString * sortTitle; + GString *sortTitle; /** A flag informing if the program has video or not. */ gboolean isVideo; diff -r 73fa3a0f2f08 -r c56122d88430 gmyth/src/gmyth_recorder.c --- a/gmyth/src/gmyth_recorder.c Tue Jan 23 21:37:27 2007 +0000 +++ b/gmyth/src/gmyth_recorder.c Tue Jan 23 22:20:21 2007 +0000 @@ -506,3 +506,40 @@ } +gboolean +gmyth_recorder_is_recording ( GMythRecorder *recorder ) +{ + gboolean ret = TRUE; + + g_return_val_if_fail( recorder != NULL, FALSE ); + + GMythStringList *str_list = gmyth_string_list_new (); + GString *message = g_string_new (""); + + g_string_printf( message, "%s %d", GMYTHTV_RECORDER_HEADER, recorder->recorder_num); + gmyth_string_list_append_string (str_list, message); + gmyth_string_list_append_string (str_list, g_string_new ("IS_RECORDING")); + + gmyth_socket_sendreceive_stringlist ( recorder->myth_socket, str_list ); + + if ( str_list != NULL && gmyth_string_list_length(str_list) > 0 ) + { + GString *str = NULL; + if ( ( str = gmyth_string_list_get_string( str_list, 0 ) ) != NULL && strcmp( str->str, "bad" )!= 0 ) + { + gint is_rec = gmyth_string_list_get_int( str_list, 0 ); + if ( is_rec != 0 ) + ret = TRUE; + else + ret = FALSE; + } + } + gmyth_debug( "%s, stream is %s being recorded!\n", ret ? "YES" : "NO", ret ? "" : "NOT" ); + //g_static_mutex_unlock (&mutex); + + if ( str_list != NULL ) + g_object_unref (str_list); + + return ret; + +} diff -r 73fa3a0f2f08 -r c56122d88430 gmyth/src/gmyth_recorder.h --- a/gmyth/src/gmyth_recorder.h Tue Jan 23 21:37:27 2007 +0000 +++ b/gmyth/src/gmyth_recorder.h Tue Jan 23 22:20:21 2007 +0000 @@ -101,6 +101,8 @@ gint64 gmyth_recorder_get_file_position ( GMythRecorder *recorder ); +gboolean gmyth_recorder_is_recording ( GMythRecorder *recorder ); + G_END_DECLS #endif /* __GMYTH_REMOTE_ENCODER_H__ */ diff -r 73fa3a0f2f08 -r c56122d88430 gmyth/src/gmyth_uri.c --- a/gmyth/src/gmyth_uri.c Tue Jan 23 21:37:27 2007 +0000 +++ b/gmyth/src/gmyth_uri.c Tue Jan 23 22:20:21 2007 +0000 @@ -39,7 +39,7 @@ #include "gmyth_debug.h" -static void gmyth_string_list_class_init (GMythURIClass *klass); +static void gmyth_uri_class_init (GMythURIClass *klass); static void gmyth_uri_init (GMythURI *object); static void gmyth_uri_dispose (GObject *object);