~noskcaj/ubuntu/saucy/sflphone/merge-1.2.3-2

« back to all changes in this revision

Viewing changes to gnome/src/video/video_renderer.c

  • Committer: Jackson Doak
  • Date: 2013-07-10 21:04:46 UTC
  • mfrom: (20.1.3 sid)
  • Revision ID: noskcaj@ubuntu.com-20130710210446-y8f587vza807icr9
Properly merged from upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 *  Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010, 2011 Savoir-Faire Linux Inc.
 
2
 *  Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
3
3
 *  Author: Tristan Matthews <tristan.matthews@savoirfairelinux.com>
4
4
 *
5
5
 *  This program is free software; you can redistribute it and/or modify
14
14
 *
15
15
 *  You should have received a copy of the GNU General Public License
16
16
 *  along with this program; if not, write to the Free Software
17
 
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
17
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
18
18
 *
19
19
 *  Additional permission under GNU GPL version 3 section 7:
20
20
 *
38
38
#include <clutter/clutter.h>
39
39
#include <clutter-gtk/clutter-gtk.h>
40
40
 
41
 
#include "logger.h"
42
 
#include "unused.h"
43
 
 
44
41
/* This macro will implement the video_renderer_get_type function
45
42
   and define a parent class pointer accessible from the whole .c file */
46
43
G_DEFINE_TYPE(VideoRenderer, video_renderer, G_TYPE_OBJECT);
211
208
    g_return_val_if_fail(IS_VIDEO_RENDERER(self), FALSE);
212
209
    VideoRendererPrivate *priv = VIDEO_RENDERER_GET_PRIVATE(self);
213
210
    if (priv->fd != -1) {
214
 
        ERROR("fd must be -1");
 
211
        g_warning("fd must be -1");
215
212
        return FALSE;
216
213
    }
217
214
 
218
215
    priv->fd = shm_open(priv->shm_path, O_RDWR, 0);
219
216
    if (priv->fd < 0) {
220
 
        DEBUG("could not open shm area \"%s\", shm_open failed:%s", priv->shm_path, strerror(errno));
 
217
        g_debug("could not open shm area \"%s\", shm_open failed:%s", priv->shm_path, strerror(errno));
221
218
        return FALSE;
222
219
    }
223
220
    priv->shm_area_len = sizeof(SHMHeader);
224
221
    priv->shm_area = mmap(NULL, priv->shm_area_len, PROT_READ | PROT_WRITE, MAP_SHARED, priv->fd, 0);
225
222
    if (priv->shm_area == MAP_FAILED) {
226
 
        DEBUG("Could not map shm area, mmap failed");
 
223
        g_debug("Could not map shm area, mmap failed");
227
224
        return FALSE;
228
225
    }
229
226
    return TRUE;
248
245
    const struct timespec timeout = create_timeout();
249
246
    /* We need an upper limit on how long we'll wait to avoid locking the whole GUI */
250
247
    if (sem_timedwait(&shm_area->mutex, &timeout) == ETIMEDOUT) {
251
 
        ERROR("Timed out before shm lock was acquired");
 
248
        g_warning("Timed out before shm lock was acquired");
252
249
        return FALSE;
253
250
    }
254
251
    return TRUE;
268
265
 
269
266
        shm_unlock(priv->shm_area);
270
267
        if (munmap(priv->shm_area, priv->shm_area_len)) {
271
 
            DEBUG("Could not unmap shared area:%s", strerror(errno));
 
268
            g_debug("Could not unmap shared area:%s", strerror(errno));
272
269
            return FALSE;
273
270
        }
274
271
 
277
274
 
278
275
        if (!priv->shm_area) {
279
276
            priv->shm_area = 0;
280
 
            DEBUG("Could not remap shared area");
 
277
            g_debug("Could not remap shared area");
281
278
            return FALSE;
282
279
        }
283
280
 
307
304
    }
308
305
 
309
306
    if (!video_renderer_resize_shm(priv)) {
310
 
        ERROR("Could not resize shared memory");
 
307
        g_warning("Could not resize shared memory");
311
308
        return;
312
309
    }
313
310
 
380
377
    VideoRenderer *rend = g_object_new(VIDEO_RENDERER_TYPE, "drawarea", (gpointer) drawarea,
381
378
            "width", width, "height", height, "shm-path", shm_path, NULL);
382
379
    if (!video_renderer_start_shm(rend)) {
383
 
        ERROR("Could not start SHM");
 
380
        g_warning("Could not start SHM");
384
381
        return NULL;
385
382
    }
386
383
    return rend;
401
398
    gtk_window_set_geometry_hints(win, NULL, &geom, GDK_HINT_ASPECT);
402
399
 
403
400
    if (!GTK_CLUTTER_IS_EMBED(priv->drawarea))
404
 
        ERROR("Drawing area is not a GtkClutterEmbed widget");
 
401
        g_warning("Drawing area is not a GtkClutterEmbed widget");
405
402
 
406
403
    ClutterActor *stage = gtk_clutter_embed_get_stage(GTK_CLUTTER_EMBED(priv->drawarea));
407
404
    g_assert(stage);