diff -r 994917e6cadf -r 1c421f2531d3 gst-plugins-mythtv/src/gstmythtvsrc.c --- a/gst-plugins-mythtv/src/gstmythtvsrc.c Tue Apr 17 15:37:20 2007 +0100 +++ b/gst-plugins-mythtv/src/gstmythtvsrc.c Tue Apr 24 00:43:20 2007 +0100 @@ -131,7 +131,8 @@ PROP_GMYTHTV_LIVEID, PROP_GMYTHTV_LIVE_CHAINID, PROP_GMYTHTV_ENABLE_TIMING_POSITION, - PROP_GMYTHTV_CHANNEL_NUM + PROP_GMYTHTV_CHANNEL_NUM, + PROP_GMYTHTV_MAX_TRY }; static void gst_mythtv_src_clear (GstMythtvSrc *mythtv_src); @@ -255,6 +256,13 @@ "Change MythTV channel number", "", G_PARAM_READWRITE)); + g_object_class_install_property + (gobject_class, PROP_GMYTHTV_MAX_TRY, + g_param_spec_int ("max-try", "max-try", + "Set the max try for get MythTV free recorder", + 0, G_MAXINT, 10, G_PARAM_READWRITE)); + + #ifndef GST_DISABLE_GST_DEBUG g_object_class_install_property (gobject_class, PROP_GMYTHTV_DBG, @@ -309,6 +317,8 @@ this->bytes_queue = NULL; this->wait_to_transfer = 0; + this->try_number = 0; + this->max_try = 10; gst_base_src_set_format (GST_BASE_SRC (this), GST_FORMAT_BYTES); @@ -322,7 +332,9 @@ static void gst_mythtv_src_clear (GstMythtvSrc *mythtv_src) { - + mythtv_src->unique_setup = FALSE; + mythtv_src->try_number = 0; + if (mythtv_src->spawn_livetv) { g_object_unref (mythtv_src->spawn_livetv); mythtv_src->spawn_livetv = NULL; @@ -338,14 +350,6 @@ mythtv_src->backend_info = NULL; } - if (mythtv_src->uri_name) { - g_free (mythtv_src->uri_name); - } - - if (mythtv_src->user_agent) { - g_free (mythtv_src->user_agent); - } - if (mythtv_src->bytes_queue) { g_byte_array_free (mythtv_src->bytes_queue, TRUE); mythtv_src->bytes_queue = NULL; @@ -360,6 +364,16 @@ gst_mythtv_src_clear (this); + if (this->uri_name) { + g_free (this->uri_name); + this->uri_name = NULL; + } + + if (this->user_agent) { + g_free (this->user_agent); + this->user_agent = NULL; + } + G_OBJECT_CLASS (parent_class)->finalize (gobject); } @@ -695,10 +709,9 @@ goto done; } - gmyth_uri = gmyth_uri_new_with_value( src->uri_name ); - + gmyth_uri = gmyth_uri_new_with_value (src->uri_name); src->backend_info = gmyth_backend_info_new_with_uri (src->uri_name); - src->live_tv |= gmyth_uri_is_livetv( gmyth_uri ); + src->live_tv = gmyth_uri_is_livetv( gmyth_uri ); /* testing UPnP... */ /* gmyth_backend_info_set_hostname( src->backend_info, NULL ); */ if ( src->live_tv ) { @@ -799,37 +812,57 @@ src->content_size, 0)); done: - /*if ( gmyth_uri != NULL ) + if (gmyth_uri != NULL) { - g_object_unref( gmyth_uri ); - gmyth_uri = NULL; - }*/ + g_object_unref (gmyth_uri); + gmyth_uri = NULL; + } - if (chain_id_local != NULL) { - g_string_free (chain_id_local, TRUE); - chain_id_local = NULL; - } + if (chain_id_local != NULL) { + g_string_free (chain_id_local, TRUE); + chain_id_local = NULL; + } - return TRUE; + return TRUE; - /* ERRORS */ + /* ERRORS */ init_failed: - { - if (src->spawn_livetv != NULL) - g_object_unref (src->spawn_livetv); + if (gmyth_uri != NULL) + { + g_object_unref (gmyth_uri); + gmyth_uri = NULL; + } + if (src->spawn_livetv != NULL) { + g_object_unref (src->spawn_livetv); + src->spawn_livetv = NULL; + } + + /* GST_ELEMENT_ERROR (src, LIBRARY, INIT, - (NULL), ("Could not initialize MythTV library (%i, %s)", ret, + (NULL), ("Could not initialize MythTV library (%i, %s)", ret, src->uri_name)); + */ + + if (++src->try_number <= src->max_try) { + gst_mythtv_src_clear (src); + GST_DEBUG_OBJECT (src, "Starting new try for get free recorder on MythTV"); + g_usleep (0.5 * G_USEC_PER_SEC); + return gst_mythtv_src_start (bsrc); + } + return FALSE; - } begin_req_failed: - { + if (gmyth_uri != NULL) + { + g_object_unref (gmyth_uri); + gmyth_uri = NULL; + } + GST_ELEMENT_ERROR (src, LIBRARY, INIT, (NULL), ("Could not begin request sent to MythTV server (%i, %s)", ret, src->uri_name)); return FALSE; - } } @@ -1081,6 +1114,11 @@ mythtvsrc->channel_name = g_value_dup_string (value); break; } + case PROP_GMYTHTV_MAX_TRY: + { + mythtvsrc->max_try = g_value_get_int (value); + break; + } default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1133,6 +1171,12 @@ g_value_set_string (value, mythtvsrc->channel_name); break; } + case PROP_GMYTHTV_MAX_TRY: + { + g_value_set_int (value, mythtvsrc->max_try); + break; + } + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break;