# HG changeset patch # User rosfran # Date 1177955665 -3600 # Node ID 45798efca6ef33210ae2b9469b8de967fa6b79f3 # Parent 4dd9bf602c18a04316a618b2642b4ba49963a20d [svn r612] Optimizations - doesn't need to call all the time the URI functions to see if is a LiveTV, and if it is a local file URI. diff -r 4dd9bf602c18 -r 45798efca6ef libgnomevfs2-mythtv/modules/mythtv-method.c --- a/libgnomevfs2-mythtv/modules/mythtv-method.c Mon Apr 30 18:16:36 2007 +0100 +++ b/libgnomevfs2-mythtv/modules/mythtv-method.c Mon Apr 30 18:54:25 2007 +0100 @@ -60,6 +60,9 @@ GMythRecorder *live_recorder; gboolean started; gint64 offset; + + gboolean is_livetv; /* it is, or not a Live TV content transfer */ + gboolean is_local_file; /* tell if the file is local to the current content transfer */ gchar *channel_name; @@ -98,6 +101,9 @@ *method_handle = g_new0 (MythtvHandle, 1); (*method_handle)->mythtv_version = MYTHTV_VERSION_DEFAULT; + + (*method_handle)->is_livetv = FALSE; + (*method_handle)->is_local_file = FALSE; tmp_str1 = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE); tmp_str2 = gnome_vfs_unescape_string (tmp_str1, ""); @@ -188,7 +194,7 @@ info->name = g_strdup (gmyth_uri_get_path (gmyth_uri)); /* file size for remote files */ - if (gmyth_uri_is_livetv (gmyth_uri) == FALSE) { + if ( ( myth_handle->is_livetv = gmyth_uri_is_livetv (gmyth_uri) ) == FALSE) { GMythFile *file = NULL; gboolean ret = FALSE; @@ -201,7 +207,7 @@ return GNOME_VFS_ERROR_NOT_FOUND; } - if ( gmyth_uri_is_local_file(gmyth_uri) ) + if ( ( myth_handle->is_local_file = gmyth_uri_is_local_file(gmyth_uri) ) == TRUE ) { file = GMYTH_FILE( gmyth_file_local_new(backend_info) ); ret = gmyth_file_local_open ( GMYTH_FILE_LOCAL( file ) ); @@ -237,7 +243,7 @@ _GNOME_VFS_METHOD_PARAM_CHECK (method_handle->backend_info != NULL); /* Connect to the backend */ - if (gmyth_uri_is_livetv (method_handle->gmyth_uri) == TRUE) { + if ( ( method_handle->is_livetv = gmyth_uri_is_livetv (method_handle->gmyth_uri) ) == TRUE) { method_handle->livetv = gmyth_livetv_new (method_handle->backend_info); method_handle->channel_name = gmyth_uri_get_channel_name (method_handle->gmyth_uri); @@ -282,7 +288,7 @@ goto error; } - if ( gmyth_uri_is_local_file(method_handle->gmyth_uri) ) + if ( ( method_handle->is_local_file = gmyth_uri_is_local_file(method_handle->gmyth_uri) ) == TRUE ) { method_handle->file = GMYTH_FILE( gmyth_file_local_new(method_handle->backend_info) ); ret = gmyth_file_local_open ( GMYTH_FILE_LOCAL( method_handle->file ) ); @@ -385,15 +391,14 @@ _GNOME_VFS_METHOD_PARAM_CHECK (method_handle != NULL); myth_handle = (MythtvHandle *) method_handle; - if ( gmyth_uri_is_local_file(myth_handle->gmyth_uri) ) + if ( myth_handle->is_local_file ) result = gmyth_file_local_read ( GMYTH_FILE_LOCAL(myth_handle->file), myth_buffer, - num_bytes, gmyth_uri_is_livetv (myth_handle->gmyth_uri)); + num_bytes, myth_handle->is_livetv ); else result = gmyth_file_transfer_read ( GMYTH_FILE_TRANSFER(myth_handle->file), myth_buffer, - num_bytes, gmyth_uri_is_livetv (myth_handle->gmyth_uri)); - + num_bytes, myth_handle->is_livetv ); if (result == GMYTH_FILE_READ_ERROR) { retval = GNOME_VFS_ERROR_IO;