# HG changeset patch # User rosfran # Date 1175027494 -3600 # Node ID 771f91aa9d5d6584afa00ccf7eab4c3088154e12 # Parent 0e6de3b59f57f136e5ebd74df4cde2ca05ae0da2 [svn r468] Function to free the remotely allocated TV tuner. diff -r 0e6de3b59f57 -r 771f91aa9d5d gmyth/src/gmyth_recorder.c --- a/gmyth/src/gmyth_recorder.c Tue Mar 27 20:27:51 2007 +0100 +++ b/gmyth/src/gmyth_recorder.c Tue Mar 27 21:31:34 2007 +0100 @@ -104,6 +104,7 @@ { gmyth_recorder_stop_playing(recorder); gmyth_recorder_finish_recording(recorder); + gmyth_recorder_free_tuner(recorder); } /** Creates a new instance of GMythRecorder. @@ -1079,3 +1080,50 @@ return ret; } + +/** + * Free the tuner responsible for recording this channel. + * + * @param recorder The GMythRecorder instance. + * + * @return true, if the tuner had been freed. + */ +gboolean +gmyth_recorder_free_tuner( 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_mutex_lock( recorder->mutex ); + + g_string_printf( message, "%s %d", "FREE_TUNER", recorder->recorder_num ); + gmyth_string_list_append_string(str_list, message); + + 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 && + g_ascii_strncasecmp( str->str, "ok", 2 ) != 0 ) { + gint is_rec = gmyth_string_list_get_int( str_list, 0); + if ( is_rec != 0) + ret = TRUE; + else + ret = FALSE; + } + g_string_free (str, TRUE); + } + + gmyth_debug( "%s, tuner is %s freed!\n", ret ? "YES" : "NO", ret ? "" : "NOT" ); + g_mutex_unlock ( recorder->mutex ); + + if ( str_list != NULL ) + g_object_unref (str_list); + + g_string_free (message, TRUE); + + return ret; +} diff -r 0e6de3b59f57 -r 771f91aa9d5d gmyth/src/gmyth_recorder.h --- a/gmyth/src/gmyth_recorder.h Tue Mar 27 20:27:51 2007 +0100 +++ b/gmyth/src/gmyth_recorder.h Tue Mar 27 21:31:34 2007 +0100 @@ -144,6 +144,8 @@ gboolean gmyth_recorder_stop_playing( GMythRecorder *recorder); +gboolean gmyth_recorder_free_tuner( GMythRecorder *recorder); + G_END_DECLS #endif /* __GMYTH_REMOTE_ENCODER_H__ */