1.1 --- a/gmyth/src/gmyth_file_transfer.c Fri Mar 23 13:47:44 2007 +0000
1.2 +++ b/gmyth/src/gmyth_file_transfer.c Fri Mar 23 13:52:12 2007 +0000
1.3 @@ -93,7 +93,7 @@
1.4 GMythRecorder *recorder;
1.5
1.6 gboolean do_next_program_chain;
1.7 -
1.8 + gboolean disposed;
1.9 };
1.10
1.11 static void gmyth_file_transfer_class_init (GMythFileTransferClass *klass);
1.12 @@ -174,41 +174,46 @@
1.13 gmyth_file_transfer_dispose (GObject *object)
1.14 {
1.15 GMythFileTransfer *transfer = GMYTH_FILE_TRANSFER (object);
1.16 -
1.17 - if ( transfer->mutex != NULL )
1.18 - {
1.19 +
1.20 + if (transfer->priv->disposed) {
1.21 + /* If dispose did already run, return. */
1.22 + return;
1.23 + }
1.24 +
1.25 + /* Make sure dispose does not run twice. */
1.26 + transfer->priv->disposed = TRUE;
1.27 +
1.28 + if ( transfer->priv->livetv != NULL ) {
1.29 + g_object_unref( transfer->priv->livetv );
1.30 + transfer->priv->livetv = NULL;
1.31 + }
1.32 +
1.33 + if ( transfer->mutex != NULL ) {
1.34 g_mutex_free( transfer->mutex );
1.35 transfer->mutex = NULL;
1.36 }
1.37
1.38 - if ( transfer->control_sock != NULL )
1.39 - {
1.40 + if ( transfer->control_sock != NULL ) {
1.41 g_object_unref( transfer->control_sock );
1.42 transfer->control_sock = NULL;
1.43 }
1.44
1.45 - if ( transfer->sock != NULL )
1.46 - {
1.47 + if ( transfer->sock != NULL ) {
1.48 g_object_unref( transfer->sock );
1.49 transfer->sock = NULL;
1.50 }
1.51
1.52 - if ( transfer->priv->recorder != NULL )
1.53 - {
1.54 + if ( transfer->backend_info != NULL ) {
1.55 + g_object_unref( transfer->backend_info );
1.56 + transfer->backend_info = NULL;
1.57 + }
1.58 +
1.59 + if ( transfer->priv->recorder != NULL ) {
1.60 g_object_unref( transfer->priv->recorder );
1.61 transfer->priv->recorder = NULL;
1.62 }
1.63 -
1.64 - /*
1.65 - if ( transfer->priv != NULL )
1.66 - {
1.67 - g_object_unref( transfer->priv );
1.68 - transfer->priv = NULL;
1.69 - }
1.70 - */
1.71 -
1.72 - if ( transfer->filename != NULL )
1.73 - {
1.74 +
1.75 + if ( transfer->filename != NULL ) {
1.76 g_free( transfer->filename );
1.77 transfer->filename = NULL;
1.78 }
1.79 @@ -233,11 +238,11 @@
1.80 * @return a new instance of the File Transfer.
1.81 */
1.82 GMythFileTransfer*
1.83 -gmyth_file_transfer_new ( const GMythBackendInfo *backend_info)
1.84 +gmyth_file_transfer_new (GMythBackendInfo *backend_info)
1.85 {
1.86 GMythFileTransfer *transfer = GMYTH_FILE_TRANSFER (g_object_new (GMYTH_FILE_TRANSFER_TYPE, NULL));
1.87
1.88 - transfer->backend_info = (GMythBackendInfo *)backend_info;
1.89 + transfer->backend_info = backend_info;
1.90 g_object_ref (transfer->backend_info);
1.91
1.92 return transfer;
1.93 @@ -275,14 +280,12 @@
1.94
1.95 g_return_val_if_fail (transfer != NULL, FALSE);
1.96 g_return_val_if_fail (filename != NULL && strlen(filename) > 0, FALSE);
1.97 - /*
1.98
1.99 if (transfer->filename != NULL)
1.100 {
1.101 g_free (transfer->filename);
1.102 transfer->filename = NULL;
1.103 }
1.104 - */
1.105
1.106 transfer->filename = g_strdup( filename );
1.107
1.108 @@ -292,7 +295,6 @@
1.109 gmyth_debug ("Connection to backend failed (Control Socket).\n");
1.110 ret = FALSE;
1.111 }
1.112 -
1.113 } else {
1.114 g_warning("Remote transfer control socket already created.\n");
1.115 }
1.116 @@ -300,7 +302,6 @@
1.117 gmyth_debug ("Got file with size = %lld.\n", transfer->filesize);
1.118
1.119 return ret;
1.120 -
1.121 }
1.122
1.123 /**
1.124 @@ -331,8 +332,8 @@
1.125 transfer->control_sock = NULL;
1.126 }
1.127
1.128 - //if ( NULL == transfer->control_sock )
1.129 - //{
1.130 + if ( NULL == transfer->control_sock )
1.131 + {
1.132 transfer->control_sock = gmyth_socket_new();
1.133
1.134 // Connects the socket, send Mythtv ANN command and verify Mythtv protocol version
1.135 @@ -344,7 +345,7 @@
1.136 return FALSE;
1.137 }
1.138
1.139 - //}
1.140 + }
1.141
1.142 /* Creates the data socket */
1.143 if (transfer->sock != NULL) {
1.144 @@ -813,12 +814,18 @@
1.145 }
1.146
1.147 transfer->priv = GMYTH_FILE_TRANSFER_GET_PRIVATE(transfer);
1.148 -
1.149 +
1.150 + // FIXME: add g_object_ref to livetv because is being deallocated
1.151 + if (transfer->priv->livetv != NULL) {
1.152 + g_object_unref (transfer->priv->livetv);
1.153 + }
1.154 +
1.155 g_object_ref(recorder);
1.156
1.157 transfer->priv->recorder = recorder;
1.158 + g_object_ref (transfer->priv->livetv);
1.159 +
1.160 transfer->priv->do_next_program_chain = TRUE;
1.161 -
1.162 }
1.163
1.164 /**
2.1 --- a/gmyth/src/gmyth_file_transfer.h Fri Mar 23 13:47:44 2007 +0000
2.2 +++ b/gmyth/src/gmyth_file_transfer.h Fri Mar 23 13:52:12 2007 +0000
2.3 @@ -1,4 +1,3 @@
2.4 -/* vim: set sw=2: -*- Mode: C; tab-width: 2; indent-tabs-mode: t; c-basic-offset: 2; c-indent-level: 2-*- */
2.5 /**
2.6 * GMyth Library
2.7 *
2.8 @@ -74,33 +73,33 @@
2.9
2.10 struct _GMythFileTransfer
2.11 {
2.12 - GObject parent;
2.13 + GObject parent;
2.14
2.15 /* Myth URI structure */
2.16 - gchar *filename;
2.17 + gchar *filename;
2.18 GMythBackendInfo *backend_info;
2.19
2.20 /* MythTV version number */
2.21 - gint mythtv_version;
2.22 + gint mythtv_version;
2.23
2.24 /* socket descriptors */
2.25 GMythSocket *control_sock;
2.26 GMythSocket *sock;
2.27
2.28 - GMutex *mutex;
2.29 + GMutex *mutex;
2.30
2.31 - gint64 readposition;
2.32 - guint64 filesize;
2.33 - gint file_id;
2.34 + gint64 readposition;
2.35 + guint64 filesize;
2.36 + gint file_id;
2.37
2.38 GMythFileTransferPrivate *priv;
2.39
2.40 };
2.41
2.42 -GType gmyth_file_transfer_get_type (void);
2.43 -GMythFileTransfer *gmyth_file_transfer_new (const GMythBackendInfo *backend_info);
2.44 -gboolean gmyth_file_transfer_open (GMythFileTransfer *transfer,
2.45 - const gchar* filename);
2.46 +GType gmyth_file_transfer_get_type (void);
2.47 +GMythFileTransfer* gmyth_file_transfer_new (GMythBackendInfo *backend_info);
2.48 +gboolean gmyth_file_transfer_open (GMythFileTransfer *transfer,
2.49 + const gchar* filename);
2.50 void gmyth_file_transfer_close (GMythFileTransfer *transfer);
2.51 gboolean gmyth_file_transfer_is_open (GMythFileTransfer *transfer);
2.52 gint gmyth_file_transfer_read (GMythFileTransfer *transfer,
2.53 @@ -110,12 +109,14 @@
2.54 gint64 gmyth_file_transfer_seek (GMythFileTransfer *transfer,
2.55 guint64 pos,
2.56 gint whence);
2.57 -gboolean gmyth_file_transfer_settimeout (GMythFileTransfer *transfer, gboolean fast);
2.58 +gboolean gmyth_file_transfer_settimeout (GMythFileTransfer *transfer,
2.59 + gboolean fast);
2.60 guint64 gmyth_file_transfer_get_filesize (GMythFileTransfer *transfer);
2.61
2.62 -void gmyth_file_transfer_emit_program_info_changed_signal ( GMythFileTransfer *transfer,
2.63 - gint msg_code,
2.64 - gpointer live_tv_recorder );
2.65 +void gmyth_file_transfer_emit_program_info_changed_signal (
2.66 + GMythFileTransfer *transfer,
2.67 + gint msg_code,
2.68 + gpointer live_tv_recorder );
2.69
2.70 G_END_DECLS
2.71