[svn r484] Added gmyth_util_get_channel_list to the gmyth_util.h; removes static_mutex locking/unlocking from the gmyth_util.
1.1 --- a/gmyth/src/gmyth_recorder.c Mon Apr 02 18:00:39 2007 +0100
1.2 +++ b/gmyth/src/gmyth_recorder.c Mon Apr 02 20:05:56 2007 +0100
1.3 @@ -102,9 +102,12 @@
1.4 void
1.5 gmyth_recorder_close(GMythRecorder *recorder)
1.6 {
1.7 - gmyth_recorder_stop_playing(recorder);
1.8 - gmyth_recorder_finish_recording(recorder);
1.9 - gmyth_recorder_free_tuner(recorder);
1.10 + if ( recorder != NULL && recorder->recorder_num != -1 )
1.11 + {
1.12 + gmyth_recorder_stop_playing(recorder);
1.13 + gmyth_recorder_finish_recording(recorder);
1.14 + gmyth_recorder_free_tuner(recorder);
1.15 + }
1.16 }
1.17
1.18 /** Creates a new instance of GMythRecorder.
2.1 --- a/gmyth/src/gmyth_util.c Mon Apr 02 18:00:39 2007 +0100
2.2 +++ b/gmyth/src/gmyth_util.c Mon Apr 02 20:05:56 2007 +0100
2.3 @@ -55,8 +55,6 @@
2.4
2.5 #endif
2.6
2.7 -static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
2.8 -
2.9 /** Converts a time_t struct in a GString at ISO standard format
2.10 * (e.g. 2006-07-20T09:56:41).
2.11 *
2.12 @@ -72,11 +70,8 @@
2.13 struct tm tm_time;
2.14 GString *result;
2.15
2.16 - g_static_mutex_lock ( &mutex );
2.17 -
2.18 if (localtime_r(&time_value, &tm_time) == NULL) {
2.19 - g_static_mutex_unlock ( &mutex );
2.20 - g_warning ("gmyth_util_time_to_isoformat convertion error!\n");
2.21 + gmyth_debug("gmyth_util_time_to_isoformat convertion error!\n");
2.22 return NULL;
2.23 }
2.24
2.25 @@ -87,8 +82,6 @@
2.26
2.27 gmyth_debug( "Result (ISO 8601) = %s", result->str );
2.28
2.29 - g_static_mutex_unlock ( &mutex );
2.30 -
2.31 return result;
2.32 }
2.33
2.34 @@ -118,18 +111,15 @@
2.35
2.36 tm_time = g_malloc0( sizeof(struct tm) );
2.37
2.38 - g_static_mutex_lock ( &mutex );
2.39 -
2.40 if ( NULL == localtime_r( &time, tm_time ) ) {
2.41 - g_warning ("gmyth_util_time_to_isoformat convertion error!\n");
2.42 + gmyth_debug ("gmyth_util_time_to_isoformat convertion error!\n");
2.43 } else {
2.44 /* we first check the return of strftime to allocate a buffer of the correct size */
2.45 buffer_len = strftime( NULL, SSIZE_MAX, fmt_string, tm_time );
2.46 if ( buffer_len > 0 ) {
2.47 result = g_malloc0( buffer_len + 1 );
2.48 if( result == NULL ) {
2.49 - g_static_mutex_unlock ( &mutex );
2.50 - g_warning ("gmyth_util_time_to_isoformat convertion error!\n");
2.51 + gmyth_debug ("gmyth_util_time_to_isoformat convertion error!\n");
2.52 return NULL;
2.53 }
2.54 strftime( result, buffer_len + 1, fmt_string, tm_time );
2.55 @@ -145,8 +135,6 @@
2.56
2.57 g_free (tm_time);
2.58
2.59 - g_static_mutex_unlock ( &mutex );
2.60 -
2.61 gmyth_debug( "Result (ISO 8601) = %s", result );
2.62
2.63 return result;
2.64 @@ -276,12 +264,10 @@
2.65
2.66 if ( sscanf (time_str->str, "%04d-%02d-%02d %02d:%02d:%02d",
2.67 &year, &month, &day, &hour, &min, &sec) < 3 ) {
2.68 - g_warning ("GMythUtil: isoformat_to_time converter error!\n");
2.69 + gmyth_debug ("GMythUtil: isoformat_to_time converter error!\n");
2.70 return 0;
2.71 }
2.72
2.73 - g_static_mutex_lock ( &mutex );
2.74 -
2.75 struct tm* tm_time = g_malloc0( sizeof(struct tm) );
2.76 tm_time->tm_year = year - 1900;
2.77 tm_time->tm_mon = month - 1;
2.78 @@ -290,8 +276,6 @@
2.79 tm_time->tm_min = min;
2.80 tm_time->tm_sec = sec;
2.81
2.82 - g_static_mutex_unlock ( &mutex );
2.83 -
2.84 return mktime( tm_time );
2.85 }
2.86
2.87 @@ -308,12 +292,12 @@
2.88 time_t time_micros = time->tv_sec;// + (gint)( time->tv_usec / G_USEC_PER_SEC );
2.89
2.90 if ( NULL == date ) {
2.91 - g_warning ( "GMythUtil: GDate *gmyth_util_time_val_to_date (GTimeVal* time) - converter error!\n" );
2.92 + gmyth_debug ( "GMythUtil: GDate *gmyth_util_time_val_to_date (GTimeVal* time) - converter error!\n" );
2.93 return NULL;
2.94 }
2.95
2.96 if ( NULL == localtime_r( &time_micros, date ) ) {
2.97 - g_warning ( "gmyth_util_time_to_isoformat convertion error!\n" );
2.98 + gmyth_debug ( "gmyth_util_time_to_isoformat convertion error!\n" );
2.99 return NULL;
2.100 }
2.101
2.102 @@ -341,12 +325,10 @@
2.103
2.104 if ( NULL == time_str )
2.105 {
2.106 - g_warning ("GMythUtil: isoformat_to_time converter error!\n");
2.107 + gmyth_debug ("GMythUtil: isoformat_to_time converter error!\n");
2.108 return NULL;
2.109 }
2.110
2.111 - g_static_mutex_lock ( &mutex );
2.112 -
2.113 tm_time = g_malloc0( sizeof(struct tm) );
2.114
2.115 /* we first check the return of strftime to allocate a buffer of the correct size */
2.116 @@ -360,7 +342,6 @@
2.117 if ( NULL == result) {
2.118 result = strptime( time_str, "%Y-%m-%dT%H:%M", tm_time );
2.119 if ( NULL == result ) {
2.120 - g_static_mutex_unlock ( &mutex );
2.121 gmyth_debug( "Dateline (ISO result): %s", result );
2.122 g_free(tm_time);
2.123 return NULL;
2.124 @@ -376,7 +357,6 @@
2.125
2.126 gmyth_debug( "After mktime call... = %s", asctime(tm_time) );
2.127
2.128 - g_static_mutex_unlock ( &mutex );
2.129 g_free (tm_time);
2.130
2.131 return time;
2.132 @@ -561,6 +541,38 @@
2.133 return basename;
2.134 }
2.135
2.136 +
2.137 +/**
2.138 + * Gets the channel list.
2.139 + *
2.140 + * @param backend_info The GMythBackendInfo instance.
2.141 + *
2.142 + * @return a pointer to a GList with all the channels.
2.143 + */
2.144 +GList *
2.145 +gmyth_util_get_channel_list (GMythBackendInfo *backend_info)
2.146 +{
2.147 + GMythRecorder *recorder;
2.148 + GList *channel_list = NULL;
2.149 + gboolean res = FALSE;
2.150 +
2.151 + gmyth_debug ("Gets channel list.");
2.152 +
2.153 + g_return_val_if_fail (backend_info != NULL, FALSE);
2.154 +
2.155 + recorder = gmyth_recorder_new ( -1, g_string_new( gmyth_backend_info_get_hostname( backend_info ) ),
2.156 + gmyth_backend_info_get_port( backend_info ) );
2.157 + res = gmyth_recorder_setup (recorder);
2.158 +
2.159 + if (res == TRUE) {
2.160 + channel_list = gmyth_recorder_get_channel_list( recorder );
2.161 + }
2.162 +
2.163 + g_object_unref (recorder);
2.164 +
2.165 + return channel_list;
2.166 +}
2.167 +
2.168 #if !GLIB_CHECK_VERSION (2, 10, 0)
2.169
2.170 /* Hacked from glib 2.10 <gtime.c> */
3.1 --- a/gmyth/src/gmyth_util.h Mon Apr 02 18:00:39 2007 +0100
3.2 +++ b/gmyth/src/gmyth_util.h Mon Apr 02 20:05:56 2007 +0100
3.3 @@ -68,6 +68,8 @@
3.4
3.5 gchar* gmyth_util_create_filename( const gint chan_id, const GTimeVal* start_time );
3.6
3.7 +GList * gmyth_util_get_channel_list (GMythBackendInfo *backend_info);
3.8 +
3.9 G_END_DECLS
3.10
3.11 #endif /*GMYTH_UTIL_H_*/