~ubuntu-branches/ubuntu/raring/rygel/raring-proposed

« back to all changes in this revision

Viewing changes to src/media-engines/simple/rygel-simple-data-source.c

  • Committer: Package Import Robot
  • Author(s): Andreas Henriksson
  • Date: 2013-02-20 15:59:08 UTC
  • mfrom: (11.1.24 experimental)
  • Revision ID: package-import@ubuntu.com-20130220155908-b5y2q60z8xh9nlnt
Tags: 0.17.8-1
* dh_makeshlibs: fix exclude path for rygel 2.0 plugin ABI.
* Update package descriptions to be more factually correct.
  Thanks to to Jens Georg for suggesting the improvements.
* Add -Wl,-z,defs -Wl,--as-needed to LDFLAGS
* Make -dev packages replace and conflict because of clashing api docs
  (Closes: #700508)
* Imported Upstream version 0.17.8
* Add patch to not hide rygel-preferences in GNOME (yet):
  debian/patches/0001-Revert-data-Hide-rygel-preferences-in-GNOME.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* rygel-simple-data-source.c generated by valac 0.18.1, the Vala compiler
 
2
 * generated from rygel-simple-data-source.vala, do not modify */
 
3
 
 
4
/*
 
5
 * Copyright (C) 2012 Intel Corporation.
 
6
 *
 
7
 * Author: Jens Georg <jensg@openismus.com>
 
8
 *
 
9
 * This file is part of Rygel.
 
10
 *
 
11
 * Rygel is free software; you can redistribute it and/or modify
 
12
 * it under the terms of the GNU Lesser General Public License as published by
 
13
 * the Free Software Foundation; either version 2 of the License, or
 
14
 * (at your option) any later version.
 
15
 *
 
16
 * Rygel is distributed in the hope that it will be useful,
 
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
19
 * GNU Lesser General Public License for more details.
 
20
 *
 
21
 * You should have received a copy of the GNU Lesser General Public License
 
22
 * along with this program; if not, write to the Free Software Foundation,
 
23
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
24
 */
 
25
 
 
26
#include <glib.h>
 
27
#include <glib-object.h>
 
28
#include <rygel-server.h>
 
29
#include <stdlib.h>
 
30
#include <string.h>
 
31
#include <glib/gi18n-lib.h>
 
32
#include <gio/gio.h>
 
33
 
 
34
 
 
35
#define RYGEL_TYPE_SIMPLE_DATA_SOURCE (rygel_simple_data_source_get_type ())
 
36
#define RYGEL_SIMPLE_DATA_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_SIMPLE_DATA_SOURCE, RygelSimpleDataSource))
 
37
#define RYGEL_SIMPLE_DATA_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_SIMPLE_DATA_SOURCE, RygelSimpleDataSourceClass))
 
38
#define RYGEL_IS_SIMPLE_DATA_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_SIMPLE_DATA_SOURCE))
 
39
#define RYGEL_IS_SIMPLE_DATA_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_SIMPLE_DATA_SOURCE))
 
40
#define RYGEL_SIMPLE_DATA_SOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_SIMPLE_DATA_SOURCE, RygelSimpleDataSourceClass))
 
41
 
 
42
typedef struct _RygelSimpleDataSource RygelSimpleDataSource;
 
43
typedef struct _RygelSimpleDataSourceClass RygelSimpleDataSourceClass;
 
44
typedef struct _RygelSimpleDataSourcePrivate RygelSimpleDataSourcePrivate;
 
45
#define _g_free0(var) (var = (g_free (var), NULL))
 
46
#define _g_thread_unref0(var) ((var == NULL) ? NULL : (var = (g_thread_unref (var), NULL)))
 
47
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
 
48
typedef struct _Block1Data Block1Data;
 
49
#define _g_mapped_file_unref0(var) ((var == NULL) ? NULL : (var = (g_mapped_file_unref (var), NULL)))
 
50
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
 
51
 
 
52
struct _RygelSimpleDataSource {
 
53
        GObject parent_instance;
 
54
        RygelSimpleDataSourcePrivate * priv;
 
55
};
 
56
 
 
57
struct _RygelSimpleDataSourceClass {
 
58
        GObjectClass parent_class;
 
59
};
 
60
 
 
61
struct _RygelSimpleDataSourcePrivate {
 
62
        gchar* uri;
 
63
        GThread* thread;
 
64
        GMutex mutex;
 
65
        GCond cond;
 
66
        guint64 first_byte;
 
67
        guint64 last_byte;
 
68
        gboolean frozen;
 
69
        gboolean stop_thread;
 
70
        RygelHTTPSeek* offsets;
 
71
};
 
72
 
 
73
struct _Block1Data {
 
74
        int _ref_count_;
 
75
        RygelSimpleDataSource * self;
 
76
        guint8* slice;
 
77
        gint slice_length1;
 
78
        gint _slice_size_;
 
79
};
 
80
 
 
81
 
 
82
static gpointer rygel_simple_data_source_parent_class = NULL;
 
83
static RygelDataSourceIface* rygel_simple_data_source_rygel_data_source_parent_iface = NULL;
 
84
 
 
85
GType rygel_simple_data_source_get_type (void) G_GNUC_CONST;
 
86
#define RYGEL_SIMPLE_DATA_SOURCE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RYGEL_TYPE_SIMPLE_DATA_SOURCE, RygelSimpleDataSourcePrivate))
 
87
enum  {
 
88
        RYGEL_SIMPLE_DATA_SOURCE_DUMMY_PROPERTY
 
89
};
 
90
RygelSimpleDataSource* rygel_simple_data_source_new (const gchar* uri);
 
91
RygelSimpleDataSource* rygel_simple_data_source_construct (GType object_type, const gchar* uri);
 
92
static void rygel_simple_data_source_real_start (RygelDataSource* base, RygelHTTPSeek* offsets, GError** error);
 
93
static void* rygel_simple_data_source_thread_func (RygelSimpleDataSource* self);
 
94
static gpointer _rygel_simple_data_source_thread_func_gthread_func (gpointer self);
 
95
static void rygel_simple_data_source_real_freeze (RygelDataSource* base);
 
96
static void rygel_simple_data_source_real_thaw (RygelDataSource* base);
 
97
static void rygel_simple_data_source_real_stop (RygelDataSource* base);
 
98
static Block1Data* block1_data_ref (Block1Data* _data1_);
 
99
static void block1_data_unref (void * _userdata_);
 
100
static guint8* _vala_array_dup1 (guint8* self, int length);
 
101
static gboolean ____lambda2_ (Block1Data* _data1_);
 
102
static gboolean _____lambda2__gsource_func (gpointer self);
 
103
static gboolean __lambda3_ (RygelSimpleDataSource* self);
 
104
static gboolean ___lambda3__gsource_func (gpointer self);
 
105
static void rygel_simple_data_source_finalize (GObject* obj);
 
106
static void _vala_clear_GMutex (GMutex * mutex);
 
107
static void _vala_clear_GRecMutex (GRecMutex * mutex);
 
108
static void _vala_clear_GRWLock (GRWLock * mutex);
 
109
static void _vala_clear_GCond (GCond * mutex);
 
110
 
 
111
 
 
112
RygelSimpleDataSource* rygel_simple_data_source_construct (GType object_type, const gchar* uri) {
 
113
        RygelSimpleDataSource * self = NULL;
 
114
        const gchar* _tmp0_;
 
115
        const gchar* _tmp1_;
 
116
        gchar* _tmp2_;
 
117
        g_return_val_if_fail (uri != NULL, NULL);
 
118
        self = (RygelSimpleDataSource*) g_object_new (object_type, NULL);
 
119
        _tmp0_ = uri;
 
120
        g_debug ("rygel-simple-data-source.vala:44: Creating new data source for %s", _tmp0_);
 
121
        _tmp1_ = uri;
 
122
        _tmp2_ = g_strdup (_tmp1_);
 
123
        _g_free0 (self->priv->uri);
 
124
        self->priv->uri = _tmp2_;
 
125
        return self;
 
126
}
 
127
 
 
128
 
 
129
RygelSimpleDataSource* rygel_simple_data_source_new (const gchar* uri) {
 
130
        return rygel_simple_data_source_construct (RYGEL_TYPE_SIMPLE_DATA_SOURCE, uri);
 
131
}
 
132
 
 
133
 
 
134
static gpointer _g_object_ref0 (gpointer self) {
 
135
        return self ? g_object_ref (self) : NULL;
 
136
}
 
137
 
 
138
 
 
139
static gpointer _rygel_simple_data_source_thread_func_gthread_func (gpointer self) {
 
140
        gpointer result;
 
141
        result = rygel_simple_data_source_thread_func (self);
 
142
        g_object_unref (self);
 
143
        return result;
 
144
}
 
145
 
 
146
 
 
147
static void rygel_simple_data_source_real_start (RygelDataSource* base, RygelHTTPSeek* offsets, GError** error) {
 
148
        RygelSimpleDataSource * self;
 
149
        RygelHTTPSeek* _tmp0_;
 
150
        RygelHTTPSeek* _tmp6_;
 
151
        RygelHTTPSeek* _tmp7_;
 
152
        const gchar* _tmp8_;
 
153
        GThread* _tmp9_;
 
154
        GError * _inner_error_ = NULL;
 
155
        self = (RygelSimpleDataSource*) base;
 
156
        _tmp0_ = offsets;
 
157
        if (_tmp0_ != NULL) {
 
158
                RygelHTTPSeek* _tmp1_;
 
159
                RygelHTTPSeekType _tmp2_;
 
160
                RygelHTTPSeekType _tmp3_;
 
161
                _tmp1_ = offsets;
 
162
                _tmp2_ = rygel_http_seek_get_seek_type (_tmp1_);
 
163
                _tmp3_ = _tmp2_;
 
164
                if (_tmp3_ == RYGEL_HTTP_SEEK_TYPE_TIME) {
 
165
                        const gchar* _tmp4_ = NULL;
 
166
                        GError* _tmp5_;
 
167
                        _tmp4_ = _ ("Time-based seek not supported");
 
168
                        _tmp5_ = g_error_new_literal (RYGEL_DATA_SOURCE_ERROR, RYGEL_DATA_SOURCE_ERROR_SEEK_FAILED, _tmp4_);
 
169
                        _inner_error_ = _tmp5_;
 
170
                        g_propagate_error (error, _inner_error_);
 
171
                        return;
 
172
                }
 
173
        }
 
174
        _tmp6_ = offsets;
 
175
        _tmp7_ = _g_object_ref0 (_tmp6_);
 
176
        _g_object_unref0 (self->priv->offsets);
 
177
        self->priv->offsets = _tmp7_;
 
178
        _tmp8_ = self->priv->uri;
 
179
        g_debug ("rygel-simple-data-source.vala:63: Starting data source for uri %s", _tmp8_);
 
180
        _tmp9_ = g_thread_new ("Rygel Serving thread", _rygel_simple_data_source_thread_func_gthread_func, g_object_ref (self));
 
181
        _g_thread_unref0 (self->priv->thread);
 
182
        self->priv->thread = _tmp9_;
 
183
}
 
184
 
 
185
 
 
186
static void rygel_simple_data_source_real_freeze (RygelDataSource* base) {
 
187
        RygelSimpleDataSource * self;
 
188
        gboolean _tmp0_;
 
189
        self = (RygelSimpleDataSource*) base;
 
190
        _tmp0_ = self->priv->frozen;
 
191
        if (_tmp0_) {
 
192
                return;
 
193
        }
 
194
        g_mutex_lock (&self->priv->mutex);
 
195
        self->priv->frozen = TRUE;
 
196
        g_mutex_unlock (&self->priv->mutex);
 
197
}
 
198
 
 
199
 
 
200
static void rygel_simple_data_source_real_thaw (RygelDataSource* base) {
 
201
        RygelSimpleDataSource * self;
 
202
        gboolean _tmp0_;
 
203
        self = (RygelSimpleDataSource*) base;
 
204
        _tmp0_ = self->priv->frozen;
 
205
        if (!_tmp0_) {
 
206
                return;
 
207
        }
 
208
        g_mutex_lock (&self->priv->mutex);
 
209
        self->priv->frozen = FALSE;
 
210
        g_cond_broadcast (&self->priv->cond);
 
211
        g_mutex_unlock (&self->priv->mutex);
 
212
}
 
213
 
 
214
 
 
215
static void rygel_simple_data_source_real_stop (RygelDataSource* base) {
 
216
        RygelSimpleDataSource * self;
 
217
        gboolean _tmp0_;
 
218
        self = (RygelSimpleDataSource*) base;
 
219
        _tmp0_ = self->priv->stop_thread;
 
220
        if (_tmp0_) {
 
221
                return;
 
222
        }
 
223
        g_mutex_lock (&self->priv->mutex);
 
224
        self->priv->frozen = FALSE;
 
225
        self->priv->stop_thread = TRUE;
 
226
        g_cond_broadcast (&self->priv->cond);
 
227
        g_mutex_unlock (&self->priv->mutex);
 
228
}
 
229
 
 
230
 
 
231
static Block1Data* block1_data_ref (Block1Data* _data1_) {
 
232
        g_atomic_int_inc (&_data1_->_ref_count_);
 
233
        return _data1_;
 
234
}
 
235
 
 
236
 
 
237
static void block1_data_unref (void * _userdata_) {
 
238
        Block1Data* _data1_;
 
239
        _data1_ = (Block1Data*) _userdata_;
 
240
        if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
 
241
                RygelSimpleDataSource * self;
 
242
                self = _data1_->self;
 
243
                _data1_->slice = (g_free (_data1_->slice), NULL);
 
244
                _g_object_unref0 (self);
 
245
                g_slice_free (Block1Data, _data1_);
 
246
        }
 
247
}
 
248
 
 
249
 
 
250
static guint8* _vala_array_dup1 (guint8* self, int length) {
 
251
        return g_memdup (self, length * sizeof (guint8));
 
252
}
 
253
 
 
254
 
 
255
static gboolean ____lambda2_ (Block1Data* _data1_) {
 
256
        RygelSimpleDataSource * self;
 
257
        gboolean result = FALSE;
 
258
        gboolean _tmp0_;
 
259
        self = _data1_->self;
 
260
        _tmp0_ = self->priv->stop_thread;
 
261
        if (!_tmp0_) {
 
262
                guint8* _tmp1_;
 
263
                gint _tmp1__length1;
 
264
                _tmp1_ = _data1_->slice;
 
265
                _tmp1__length1 = _data1_->slice_length1;
 
266
                g_signal_emit_by_name ((RygelDataSource*) self, "data-available", _tmp1_, _tmp1__length1);
 
267
        }
 
268
        result = FALSE;
 
269
        return result;
 
270
}
 
271
 
 
272
 
 
273
static gboolean _____lambda2__gsource_func (gpointer self) {
 
274
        gboolean result;
 
275
        result = ____lambda2_ (self);
 
276
        return result;
 
277
}
 
278
 
 
279
 
 
280
static gboolean __lambda3_ (RygelSimpleDataSource* self) {
 
281
        gboolean result = FALSE;
 
282
        g_signal_emit_by_name ((RygelDataSource*) self, "done");
 
283
        result = FALSE;
 
284
        return result;
 
285
}
 
286
 
 
287
 
 
288
static gboolean ___lambda3__gsource_func (gpointer self) {
 
289
        gboolean result;
 
290
        result = __lambda3_ (self);
 
291
        return result;
 
292
}
 
293
 
 
294
 
 
295
static void* rygel_simple_data_source_thread_func (RygelSimpleDataSource* self) {
 
296
        void* result = NULL;
 
297
        const gchar* _tmp0_;
 
298
        GFile* _tmp1_ = NULL;
 
299
        GFile* file;
 
300
        const gchar* _tmp2_;
 
301
        GError * _inner_error_ = NULL;
 
302
        g_return_val_if_fail (self != NULL, NULL);
 
303
        _tmp0_ = self->priv->uri;
 
304
        _tmp1_ = g_file_new_for_commandline_arg (_tmp0_);
 
305
        file = _tmp1_;
 
306
        _tmp2_ = self->priv->uri;
 
307
        g_debug ("rygel-simple-data-source.vala:105: Spawning new thread for streaming f" \
 
308
"ile %s", _tmp2_);
 
309
        {
 
310
                GFile* _tmp3_;
 
311
                gchar* _tmp4_ = NULL;
 
312
                gchar* _tmp5_;
 
313
                GMappedFile* _tmp6_;
 
314
                GMappedFile* _tmp7_;
 
315
                GMappedFile* mapped;
 
316
                RygelHTTPSeek* _tmp8_;
 
317
                _tmp3_ = file;
 
318
                _tmp4_ = g_file_get_path (_tmp3_);
 
319
                _tmp5_ = _tmp4_;
 
320
                _tmp6_ = g_mapped_file_new (_tmp5_, FALSE, &_inner_error_);
 
321
                _tmp7_ = _tmp6_;
 
322
                _g_free0 (_tmp5_);
 
323
                mapped = _tmp7_;
 
324
                if (_inner_error_ != NULL) {
 
325
                        goto __catch0_g_error;
 
326
                }
 
327
                _tmp8_ = self->priv->offsets;
 
328
                if (_tmp8_ != NULL) {
 
329
                        RygelHTTPSeek* _tmp9_;
 
330
                        gint64 _tmp10_;
 
331
                        gint64 _tmp11_;
 
332
                        RygelHTTPSeek* _tmp12_;
 
333
                        gint64 _tmp13_;
 
334
                        gint64 _tmp14_;
 
335
                        _tmp9_ = self->priv->offsets;
 
336
                        _tmp10_ = rygel_http_seek_get_start (_tmp9_);
 
337
                        _tmp11_ = _tmp10_;
 
338
                        self->priv->first_byte = (guint64) _tmp11_;
 
339
                        _tmp12_ = self->priv->offsets;
 
340
                        _tmp13_ = rygel_http_seek_get_stop (_tmp12_);
 
341
                        _tmp14_ = _tmp13_;
 
342
                        self->priv->last_byte = (guint64) (_tmp14_ + 1);
 
343
                } else {
 
344
                        GMappedFile* _tmp15_;
 
345
                        gsize _tmp16_ = 0UL;
 
346
                        _tmp15_ = mapped;
 
347
                        _tmp16_ = g_mapped_file_get_length (_tmp15_);
 
348
                        self->priv->last_byte = (guint64) _tmp16_;
 
349
                }
 
350
                while (TRUE) {
 
351
                        Block1Data* _data1_;
 
352
                        gboolean exit = FALSE;
 
353
                        gboolean _tmp19_;
 
354
                        gboolean _tmp20_ = FALSE;
 
355
                        gboolean _tmp21_;
 
356
                        gboolean _tmp24_;
 
357
                        guint64 _tmp25_;
 
358
                        guint64 start;
 
359
                        guint64 _tmp26_;
 
360
                        guint16 _tmp27_;
 
361
                        guint64 stop;
 
362
                        guint64 _tmp28_;
 
363
                        guint64 _tmp29_;
 
364
                        GMappedFile* _tmp31_;
 
365
                        gchar* _tmp32_ = NULL;
 
366
                        guint8* data;
 
367
                        gint data_length1;
 
368
                        gint _data_size_;
 
369
                        GMappedFile* _tmp33_;
 
370
                        gsize _tmp34_ = 0UL;
 
371
                        gint _tmp35_;
 
372
                        guint8* _tmp36_;
 
373
                        gint _tmp36__length1;
 
374
                        guint64 _tmp37_;
 
375
                        guint64 _tmp38_;
 
376
                        guint8* _tmp39_;
 
377
                        gint _tmp39__length1;
 
378
                        guint64 _tmp40_;
 
379
                        _data1_ = g_slice_new0 (Block1Data);
 
380
                        _data1_->_ref_count_ = 1;
 
381
                        _data1_->self = g_object_ref (self);
 
382
                        g_mutex_lock (&self->priv->mutex);
 
383
                        while (TRUE) {
 
384
                                gboolean _tmp17_;
 
385
                                GMutex _tmp18_;
 
386
                                _tmp17_ = self->priv->frozen;
 
387
                                if (!_tmp17_) {
 
388
                                        break;
 
389
                                }
 
390
                                _tmp18_ = self->priv->mutex;
 
391
                                g_cond_wait (&self->priv->cond, &_tmp18_);
 
392
                        }
 
393
                        _tmp19_ = self->priv->stop_thread;
 
394
                        exit = _tmp19_;
 
395
                        g_mutex_unlock (&self->priv->mutex);
 
396
                        _tmp21_ = exit;
 
397
                        if (_tmp21_) {
 
398
                                _tmp20_ = TRUE;
 
399
                        } else {
 
400
                                guint64 _tmp22_;
 
401
                                guint64 _tmp23_;
 
402
                                _tmp22_ = self->priv->first_byte;
 
403
                                _tmp23_ = self->priv->last_byte;
 
404
                                _tmp20_ = _tmp22_ == _tmp23_;
 
405
                        }
 
406
                        _tmp24_ = _tmp20_;
 
407
                        if (_tmp24_) {
 
408
                                g_debug ("rygel-simple-data-source.vala:126: Done streaming!");
 
409
                                block1_data_unref (_data1_);
 
410
                                _data1_ = NULL;
 
411
                                break;
 
412
                        }
 
413
                        _tmp25_ = self->priv->first_byte;
 
414
                        start = _tmp25_;
 
415
                        _tmp26_ = start;
 
416
                        _tmp27_ = G_MAXUINT16;
 
417
                        stop = _tmp26_ + _tmp27_;
 
418
                        _tmp28_ = stop;
 
419
                        _tmp29_ = self->priv->last_byte;
 
420
                        if (_tmp28_ > _tmp29_) {
 
421
                                guint64 _tmp30_;
 
422
                                _tmp30_ = self->priv->last_byte;
 
423
                                stop = _tmp30_;
 
424
                        }
 
425
                        _tmp31_ = mapped;
 
426
                        _tmp32_ = g_mapped_file_get_contents (_tmp31_);
 
427
                        data = (guint8*) _tmp32_;
 
428
                        data_length1 = -1;
 
429
                        _data_size_ = data_length1;
 
430
                        _tmp33_ = mapped;
 
431
                        _tmp34_ = g_mapped_file_get_length (_tmp33_);
 
432
                        data_length1 = (gint) _tmp34_;
 
433
                        _tmp35_ = data_length1;
 
434
                        _tmp36_ = data;
 
435
                        _tmp36__length1 = data_length1;
 
436
                        _tmp37_ = start;
 
437
                        _tmp38_ = stop;
 
438
                        _tmp39_ = ((_tmp36_ + _tmp37_) != NULL) ? _vala_array_dup1 (_tmp36_ + _tmp37_, _tmp38_ - _tmp37_) : ((gpointer) (_tmp36_ + _tmp37_));
 
439
                        _tmp39__length1 = _tmp38_ - _tmp37_;
 
440
                        _data1_->slice = _tmp39_;
 
441
                        _data1_->slice_length1 = _tmp39__length1;
 
442
                        _data1_->_slice_size_ = _data1_->slice_length1;
 
443
                        _tmp40_ = stop;
 
444
                        self->priv->first_byte = _tmp40_;
 
445
                        g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, _____lambda2__gsource_func, block1_data_ref (_data1_), block1_data_unref);
 
446
                        block1_data_unref (_data1_);
 
447
                        _data1_ = NULL;
 
448
                }
 
449
                _g_mapped_file_unref0 (mapped);
 
450
        }
 
451
        goto __finally0;
 
452
        __catch0_g_error:
 
453
        {
 
454
                GError* _error_ = NULL;
 
455
                GError* _tmp41_;
 
456
                const gchar* _tmp42_;
 
457
                _error_ = _inner_error_;
 
458
                _inner_error_ = NULL;
 
459
                _tmp41_ = _error_;
 
460
                _tmp42_ = _tmp41_->message;
 
461
                g_warning ("rygel-simple-data-source.vala:152: Failed to map file: %s", _tmp42_);
 
462
                _g_error_free0 (_error_);
 
463
        }
 
464
        __finally0:
 
465
        if (_inner_error_ != NULL) {
 
466
                _g_object_unref0 (file);
 
467
                g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
 
468
                g_clear_error (&_inner_error_);
 
469
                return NULL;
 
470
        }
 
471
        g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, ___lambda3__gsource_func, g_object_ref (self), g_object_unref);
 
472
        result = NULL;
 
473
        _g_object_unref0 (file);
 
474
        return result;
 
475
}
 
476
 
 
477
 
 
478
static void rygel_simple_data_source_class_init (RygelSimpleDataSourceClass * klass) {
 
479
        rygel_simple_data_source_parent_class = g_type_class_peek_parent (klass);
 
480
        g_type_class_add_private (klass, sizeof (RygelSimpleDataSourcePrivate));
 
481
        G_OBJECT_CLASS (klass)->finalize = rygel_simple_data_source_finalize;
 
482
}
 
483
 
 
484
 
 
485
static void rygel_simple_data_source_rygel_data_source_interface_init (RygelDataSourceIface * iface) {
 
486
        rygel_simple_data_source_rygel_data_source_parent_iface = g_type_interface_peek_parent (iface);
 
487
        iface->start = (void (*)(RygelDataSource*, RygelHTTPSeek*, GError**)) rygel_simple_data_source_real_start;
 
488
        iface->freeze = (void (*)(RygelDataSource*)) rygel_simple_data_source_real_freeze;
 
489
        iface->thaw = (void (*)(RygelDataSource*)) rygel_simple_data_source_real_thaw;
 
490
        iface->stop = (void (*)(RygelDataSource*)) rygel_simple_data_source_real_stop;
 
491
}
 
492
 
 
493
 
 
494
static void rygel_simple_data_source_instance_init (RygelSimpleDataSource * self) {
 
495
        GMutex _tmp0_ = {0};
 
496
        GCond _tmp1_ = {0};
 
497
        self->priv = RYGEL_SIMPLE_DATA_SOURCE_GET_PRIVATE (self);
 
498
        g_mutex_init (&_tmp0_);
 
499
        self->priv->mutex = _tmp0_;
 
500
        g_cond_init (&_tmp1_);
 
501
        self->priv->cond = _tmp1_;
 
502
        self->priv->first_byte = (guint64) 0;
 
503
        self->priv->last_byte = (guint64) 0;
 
504
        self->priv->frozen = FALSE;
 
505
        self->priv->stop_thread = FALSE;
 
506
        self->priv->offsets = NULL;
 
507
}
 
508
 
 
509
 
 
510
static void rygel_simple_data_source_finalize (GObject* obj) {
 
511
        RygelSimpleDataSource * self;
 
512
        self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_TYPE_SIMPLE_DATA_SOURCE, RygelSimpleDataSource);
 
513
        rygel_data_source_stop ((RygelDataSource*) self);
 
514
        _g_free0 (self->priv->uri);
 
515
        _g_thread_unref0 (self->priv->thread);
 
516
        _vala_clear_GMutex (&self->priv->mutex);
 
517
        _vala_clear_GCond (&self->priv->cond);
 
518
        _g_object_unref0 (self->priv->offsets);
 
519
        G_OBJECT_CLASS (rygel_simple_data_source_parent_class)->finalize (obj);
 
520
}
 
521
 
 
522
 
 
523
/**
 
524
 * A simple data source for use with the simple media engine (RygelSimpleMediaEngine).
 
525
 *
 
526
 * This does not support time-base seeking with 
 
527
 * rygel_data_source_start() because it does not
 
528
 * use any multimedia framework. Therefore, calling start() with
 
529
 * RYGEL_HTTP_SEEK_TYPE_TIME will fail with a 
 
530
 * RYGEL_DATA_SOURCE_ERROR_SEEK_FAILED GError code,
 
531
 */
 
532
GType rygel_simple_data_source_get_type (void) {
 
533
        static volatile gsize rygel_simple_data_source_type_id__volatile = 0;
 
534
        if (g_once_init_enter (&rygel_simple_data_source_type_id__volatile)) {
 
535
                static const GTypeInfo g_define_type_info = { sizeof (RygelSimpleDataSourceClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_simple_data_source_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelSimpleDataSource), 0, (GInstanceInitFunc) rygel_simple_data_source_instance_init, NULL };
 
536
                static const GInterfaceInfo rygel_data_source_info = { (GInterfaceInitFunc) rygel_simple_data_source_rygel_data_source_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
 
537
                GType rygel_simple_data_source_type_id;
 
538
                rygel_simple_data_source_type_id = g_type_register_static (G_TYPE_OBJECT, "RygelSimpleDataSource", &g_define_type_info, 0);
 
539
                g_type_add_interface_static (rygel_simple_data_source_type_id, RYGEL_TYPE_DATA_SOURCE, &rygel_data_source_info);
 
540
                g_once_init_leave (&rygel_simple_data_source_type_id__volatile, rygel_simple_data_source_type_id);
 
541
        }
 
542
        return rygel_simple_data_source_type_id__volatile;
 
543
}
 
544
 
 
545
 
 
546
static void _vala_clear_GMutex (GMutex * mutex) {
 
547
        GMutex zero_mutex = { 0 };
 
548
        if (memcmp (mutex, &zero_mutex, sizeof (GMutex))) {
 
549
                g_mutex_clear (mutex);
 
550
                memset (mutex, 0, sizeof (GMutex));
 
551
        }
 
552
}
 
553
 
 
554
 
 
555
static void _vala_clear_GRecMutex (GRecMutex * mutex) {
 
556
        GRecMutex zero_mutex = { 0 };
 
557
        if (memcmp (mutex, &zero_mutex, sizeof (GRecMutex))) {
 
558
                g_rec_mutex_clear (mutex);
 
559
                memset (mutex, 0, sizeof (GRecMutex));
 
560
        }
 
561
}
 
562
 
 
563
 
 
564
static void _vala_clear_GRWLock (GRWLock * mutex) {
 
565
        GRWLock zero_mutex = { 0 };
 
566
        if (memcmp (mutex, &zero_mutex, sizeof (GRWLock))) {
 
567
                g_rw_lock_clear (mutex);
 
568
                memset (mutex, 0, sizeof (GRWLock));
 
569
        }
 
570
}
 
571
 
 
572
 
 
573
static void _vala_clear_GCond (GCond * mutex) {
 
574
        GCond zero_mutex = { 0 };
 
575
        if (memcmp (mutex, &zero_mutex, sizeof (GCond))) {
 
576
                g_cond_clear (mutex);
 
577
                memset (mutex, 0, sizeof (GCond));
 
578
        }
 
579
}
 
580
 
 
581
 
 
582