# HG changeset patch # User leo_sobral # Date 1174657932 0 # Node ID ee220ab67ffd9e7f2b8494e1d0866b83f24186c8 # Parent 2ca84b85d2dd2dc86a6ddc85c1d0b98121b9521a [svn r444] file transfer removed dependency from livetv diff -r 2ca84b85d2dd -r ee220ab67ffd gmyth/src/gmyth_file_transfer.c --- a/gmyth/src/gmyth_file_transfer.c Fri Mar 23 13:47:44 2007 +0000 +++ b/gmyth/src/gmyth_file_transfer.c Fri Mar 23 13:52:12 2007 +0000 @@ -93,7 +93,7 @@ GMythRecorder *recorder; gboolean do_next_program_chain; - + gboolean disposed; }; static void gmyth_file_transfer_class_init (GMythFileTransferClass *klass); @@ -174,41 +174,46 @@ gmyth_file_transfer_dispose (GObject *object) { GMythFileTransfer *transfer = GMYTH_FILE_TRANSFER (object); - - if ( transfer->mutex != NULL ) - { + + if (transfer->priv->disposed) { + /* If dispose did already run, return. */ + return; + } + + /* Make sure dispose does not run twice. */ + transfer->priv->disposed = TRUE; + + if ( transfer->priv->livetv != NULL ) { + g_object_unref( transfer->priv->livetv ); + transfer->priv->livetv = NULL; + } + + if ( transfer->mutex != NULL ) { g_mutex_free( transfer->mutex ); transfer->mutex = NULL; } - if ( transfer->control_sock != NULL ) - { + if ( transfer->control_sock != NULL ) { g_object_unref( transfer->control_sock ); transfer->control_sock = NULL; } - if ( transfer->sock != NULL ) - { + if ( transfer->sock != NULL ) { g_object_unref( transfer->sock ); transfer->sock = NULL; } - if ( transfer->priv->recorder != NULL ) - { + if ( transfer->backend_info != NULL ) { + g_object_unref( transfer->backend_info ); + transfer->backend_info = NULL; + } + + if ( transfer->priv->recorder != NULL ) { g_object_unref( transfer->priv->recorder ); transfer->priv->recorder = NULL; } - - /* - if ( transfer->priv != NULL ) - { - g_object_unref( transfer->priv ); - transfer->priv = NULL; - } - */ - - if ( transfer->filename != NULL ) - { + + if ( transfer->filename != NULL ) { g_free( transfer->filename ); transfer->filename = NULL; } @@ -233,11 +238,11 @@ * @return a new instance of the File Transfer. */ GMythFileTransfer* -gmyth_file_transfer_new ( const GMythBackendInfo *backend_info) +gmyth_file_transfer_new (GMythBackendInfo *backend_info) { GMythFileTransfer *transfer = GMYTH_FILE_TRANSFER (g_object_new (GMYTH_FILE_TRANSFER_TYPE, NULL)); - transfer->backend_info = (GMythBackendInfo *)backend_info; + transfer->backend_info = backend_info; g_object_ref (transfer->backend_info); return transfer; @@ -275,14 +280,12 @@ g_return_val_if_fail (transfer != NULL, FALSE); g_return_val_if_fail (filename != NULL && strlen(filename) > 0, FALSE); - /* if (transfer->filename != NULL) { g_free (transfer->filename); transfer->filename = NULL; } - */ transfer->filename = g_strdup( filename ); @@ -292,7 +295,6 @@ gmyth_debug ("Connection to backend failed (Control Socket).\n"); ret = FALSE; } - } else { g_warning("Remote transfer control socket already created.\n"); } @@ -300,7 +302,6 @@ gmyth_debug ("Got file with size = %lld.\n", transfer->filesize); return ret; - } /** @@ -331,8 +332,8 @@ transfer->control_sock = NULL; } - //if ( NULL == transfer->control_sock ) - //{ + if ( NULL == transfer->control_sock ) + { transfer->control_sock = gmyth_socket_new(); // Connects the socket, send Mythtv ANN command and verify Mythtv protocol version @@ -344,7 +345,7 @@ return FALSE; } - //} + } /* Creates the data socket */ if (transfer->sock != NULL) { @@ -813,12 +814,18 @@ } transfer->priv = GMYTH_FILE_TRANSFER_GET_PRIVATE(transfer); - + + // FIXME: add g_object_ref to livetv because is being deallocated + if (transfer->priv->livetv != NULL) { + g_object_unref (transfer->priv->livetv); + } + g_object_ref(recorder); transfer->priv->recorder = recorder; + g_object_ref (transfer->priv->livetv); + transfer->priv->do_next_program_chain = TRUE; - } /** diff -r 2ca84b85d2dd -r ee220ab67ffd gmyth/src/gmyth_file_transfer.h --- a/gmyth/src/gmyth_file_transfer.h Fri Mar 23 13:47:44 2007 +0000 +++ b/gmyth/src/gmyth_file_transfer.h Fri Mar 23 13:52:12 2007 +0000 @@ -1,4 +1,3 @@ -/* vim: set sw=2: -*- Mode: C; tab-width: 2; indent-tabs-mode: t; c-basic-offset: 2; c-indent-level: 2-*- */ /** * GMyth Library * @@ -74,33 +73,33 @@ struct _GMythFileTransfer { - GObject parent; + GObject parent; /* Myth URI structure */ - gchar *filename; + gchar *filename; GMythBackendInfo *backend_info; /* MythTV version number */ - gint mythtv_version; + gint mythtv_version; /* socket descriptors */ GMythSocket *control_sock; GMythSocket *sock; - GMutex *mutex; + GMutex *mutex; - gint64 readposition; - guint64 filesize; - gint file_id; + gint64 readposition; + guint64 filesize; + gint file_id; GMythFileTransferPrivate *priv; }; -GType gmyth_file_transfer_get_type (void); -GMythFileTransfer *gmyth_file_transfer_new (const GMythBackendInfo *backend_info); -gboolean gmyth_file_transfer_open (GMythFileTransfer *transfer, - const gchar* filename); +GType gmyth_file_transfer_get_type (void); +GMythFileTransfer* gmyth_file_transfer_new (GMythBackendInfo *backend_info); +gboolean gmyth_file_transfer_open (GMythFileTransfer *transfer, + const gchar* filename); void gmyth_file_transfer_close (GMythFileTransfer *transfer); gboolean gmyth_file_transfer_is_open (GMythFileTransfer *transfer); gint gmyth_file_transfer_read (GMythFileTransfer *transfer, @@ -110,12 +109,14 @@ gint64 gmyth_file_transfer_seek (GMythFileTransfer *transfer, guint64 pos, gint whence); -gboolean gmyth_file_transfer_settimeout (GMythFileTransfer *transfer, gboolean fast); +gboolean gmyth_file_transfer_settimeout (GMythFileTransfer *transfer, + gboolean fast); guint64 gmyth_file_transfer_get_filesize (GMythFileTransfer *transfer); -void gmyth_file_transfer_emit_program_info_changed_signal ( GMythFileTransfer *transfer, - gint msg_code, - gpointer live_tv_recorder ); +void gmyth_file_transfer_emit_program_info_changed_signal ( + GMythFileTransfer *transfer, + gint msg_code, + gpointer live_tv_recorder ); G_END_DECLS