[svn r468] Function to free the remotely allocated TV tuner.
1.1 --- a/gmyth/src/gmyth_recorder.c Tue Mar 27 20:27:51 2007 +0100
1.2 +++ b/gmyth/src/gmyth_recorder.c Tue Mar 27 21:31:34 2007 +0100
1.3 @@ -104,6 +104,7 @@
1.4 {
1.5 gmyth_recorder_stop_playing(recorder);
1.6 gmyth_recorder_finish_recording(recorder);
1.7 + gmyth_recorder_free_tuner(recorder);
1.8 }
1.9
1.10 /** Creates a new instance of GMythRecorder.
1.11 @@ -1079,3 +1080,50 @@
1.12
1.13 return ret;
1.14 }
1.15 +
1.16 +/**
1.17 + * Free the tuner responsible for recording this channel.
1.18 + *
1.19 + * @param recorder The GMythRecorder instance.
1.20 + *
1.21 + * @return <code>true</code>, if the tuner had been freed.
1.22 + */
1.23 +gboolean
1.24 +gmyth_recorder_free_tuner( GMythRecorder *recorder) {
1.25 + gboolean ret = TRUE;
1.26 +
1.27 + g_return_val_if_fail( recorder != NULL, FALSE );
1.28 +
1.29 + GMythStringList *str_list = gmyth_string_list_new();
1.30 + GString *message = g_string_new("");
1.31 +
1.32 + g_mutex_lock( recorder->mutex );
1.33 +
1.34 + g_string_printf( message, "%s %d", "FREE_TUNER", recorder->recorder_num );
1.35 + gmyth_string_list_append_string(str_list, message);
1.36 +
1.37 + gmyth_socket_sendreceive_stringlist( recorder->myth_socket, str_list);
1.38 +
1.39 + if ( str_list != NULL && gmyth_string_list_length(str_list)> 0) {
1.40 + GString *str= NULL;
1.41 + if ( ( str = gmyth_string_list_get_string( str_list, 0 ) ) != NULL &&
1.42 + g_ascii_strncasecmp( str->str, "ok", 2 ) != 0 ) {
1.43 + gint is_rec = gmyth_string_list_get_int( str_list, 0);
1.44 + if ( is_rec != 0)
1.45 + ret = TRUE;
1.46 + else
1.47 + ret = FALSE;
1.48 + }
1.49 + g_string_free (str, TRUE);
1.50 + }
1.51 +
1.52 + gmyth_debug( "%s, tuner is %s freed!\n", ret ? "YES" : "NO", ret ? "" : "NOT" );
1.53 + g_mutex_unlock ( recorder->mutex );
1.54 +
1.55 + if ( str_list != NULL )
1.56 + g_object_unref (str_list);
1.57 +
1.58 + g_string_free (message, TRUE);
1.59 +
1.60 + return ret;
1.61 +}
2.1 --- a/gmyth/src/gmyth_recorder.h Tue Mar 27 20:27:51 2007 +0100
2.2 +++ b/gmyth/src/gmyth_recorder.h Tue Mar 27 21:31:34 2007 +0100
2.3 @@ -144,6 +144,8 @@
2.4
2.5 gboolean gmyth_recorder_stop_playing( GMythRecorder *recorder);
2.6
2.7 +gboolean gmyth_recorder_free_tuner( GMythRecorder *recorder);
2.8 +
2.9 G_END_DECLS
2.10
2.11 #endif /* __GMYTH_REMOTE_ENCODER_H__ */