camorama r358 - in trunk: . src
- From: herzi svn gnome org
- To: svn-commits-list gnome org
- Subject: camorama r358 - in trunk: . src
- Date: Wed, 28 May 2008 14:20:19 +0000 (UTC)
Author: herzi
Date: Wed May 28 14:20:19 2008
New Revision: 358
URL: http://svn.gnome.org/viewvc/camorama?rev=358&view=rev
Log:
2008-05-28 Sven Herzberg <sven imendio com>
moved the read timeout
* src/callbacks.c: dropped the mmap timeout
* src/callbacks.h: dropped the mmap timeout
* src/camorama-globals.h: export frame
* src/capture-strategy-mmap.c: (timeout_func): added the timeout
Modified:
trunk/ChangeLog
trunk/src/callbacks.c
trunk/src/callbacks.h
trunk/src/camorama-globals.h
trunk/src/capture-strategy-mmap.c
Modified: trunk/src/callbacks.c
==============================================================================
--- trunk/src/callbacks.c (original)
+++ trunk/src/callbacks.c Wed May 28 14:20:19 2008
@@ -19,7 +19,7 @@
extern GtkWidget *dentry, *entry2, *string_entry;
extern GtkWidget *host_entry,
*directory_entry, *filename_entry, *login_entry, *pw_entry;
-int frame;
+int frame = 0;
/*
* pref callbacks
@@ -501,81 +501,6 @@
// threshold (cam->pic_buf, cam->x, cam->y, cam->dither);
}
-gint
-timeout_func (cam * cam)
-{
- int i, count = 0;
- GdkGC *gc;
-
- i = -1;
- while (i < 0) {
- i = ioctl (cam->dev, VIDIOCSYNC, &frame);
-
- if (i < 0 && errno == EINTR) {
- if (cam->debug == TRUE) {
- printf ("i = %d\n", i);
- }
- continue;
- }
- if (i < 0) {
- if (cam->debug == TRUE) {
- fprintf (stderr, "Unable to capture image (VIDIOCSYNC)\n");
- }
- error_dialog (_("Unable to capture image."));
- exit (-1);
- }
- break;
- }
- count++;
- /*
- * refer the frame
- */
- cam->pic_buf = cam->pic + cam->vid_buf.offsets[frame];
- if (cam->vid_pic.palette == VIDEO_PALETTE_YUV420P) {
- yuv420p_to_rgb (cam->pic_buf, cam->tmp, cam->x, cam->y, cam->depth);
- cam->pic_buf = cam->tmp;
- }
-
- apply_filters(cam);
-
-
- gc = gdk_gc_new (cam->pixmap);
-
- gdk_draw_rgb_image (cam->pixmap,
- gc, 0, 0,
- cam->vid_win.width, cam->vid_win.height,
- GDK_RGB_DITHER_NORMAL, cam->pic_buf,
- cam->vid_win.width * cam->depth);
-
- gtk_widget_queue_draw_area (glade_xml_get_widget (cam->xml, "da"), 0,
- 0, cam->x, cam->y);
-
- cam->vid_map.frame = frame;
- if (ioctl (cam->dev, VIDIOCMCAPTURE, &cam->vid_map) < 0) {
- if (cam->debug == TRUE) {
- fprintf (stderr, "Unable to capture image (VIDIOCMCAPTURE)\n");
- }
- error_dialog (_("Unable to capture image."));
- exit (-1);
- }
-
- /*
- * next frame
- */
- frame++;
-
- /*
- * reset to the 1st frame
- */
- if (frame >= cam->vid_buf.frames) {
- frame = 0;
- }
-
- frames2++;
- g_object_unref ((gpointer) gc);
- return TRUE; /* call this function again */
-}
-
gint fps (GtkWidget * sb)
{
gchar *stat;
Modified: trunk/src/callbacks.h
==============================================================================
--- trunk/src/callbacks.h (original)
+++ trunk/src/callbacks.h Wed May 28 14:20:19 2008
@@ -47,7 +47,6 @@
void init_cam (cam * cam);
gint timeout_capture_func (cam *);
gint fps (GtkWidget *);
-gboolean timeout_func (cam * application);
void edge_func1 (GtkToggleButton *, gpointer);
void sobel_func (GtkToggleButton *, gpointer);
void fix_colour_func (GtkToggleButton *, char *);
Modified: trunk/src/camorama-globals.h
==============================================================================
--- trunk/src/camorama-globals.h (original)
+++ trunk/src/camorama-globals.h Wed May 28 14:20:19 2008
@@ -30,6 +30,7 @@
G_BEGIN_DECLS
GtkWidget *main_window, *prefswindow;
+extern int frame;
int frames, frames2, seconds;
GtkWidget *dentry, *entry2, *string_entry, *format_selection;
GtkWidget *host_entry, *directory_entry, *filename_entry, *login_entry,
Modified: trunk/src/capture-strategy-mmap.c
==============================================================================
--- trunk/src/capture-strategy-mmap.c (original)
+++ trunk/src/capture-strategy-mmap.c Wed May 28 14:20:19 2008
@@ -23,7 +23,9 @@
#include "capture-strategy-mmap.h"
-#include "callbacks.h"
+#include <errno.h>
+#include <glib/gi18n.h>
+#include "camorama-globals.h"
/* GType Implementation */
@@ -51,6 +53,82 @@
/* Capture Strategy Implementation */
+static
+gint
+timeout_func (cam * cam)
+{
+ int i, count = 0;
+ GdkGC *gc;
+
+ i = -1;
+ while (i < 0) {
+ i = ioctl (cam->dev, VIDIOCSYNC, &frame);
+
+ if (i < 0 && errno == EINTR) {
+ if (cam->debug == TRUE) {
+ printf ("i = %d\n", i);
+ }
+ continue;
+ }
+ if (i < 0) {
+ if (cam->debug == TRUE) {
+ fprintf (stderr, "Unable to capture image (VIDIOCSYNC)\n");
+ }
+ error_dialog (_("Unable to capture image."));
+ exit (-1);
+ }
+ break;
+ }
+ count++;
+ /*
+ * refer the frame
+ */
+ cam->pic_buf = cam->pic + cam->vid_buf.offsets[frame];
+ if (cam->vid_pic.palette == VIDEO_PALETTE_YUV420P) {
+ yuv420p_to_rgb (cam->pic_buf, cam->tmp, cam->x, cam->y, cam->depth);
+ cam->pic_buf = cam->tmp;
+ }
+
+ apply_filters(cam);
+
+
+ gc = gdk_gc_new (cam->pixmap);
+
+ gdk_draw_rgb_image (cam->pixmap,
+ gc, 0, 0,
+ cam->vid_win.width, cam->vid_win.height,
+ GDK_RGB_DITHER_NORMAL, cam->pic_buf,
+ cam->vid_win.width * cam->depth);
+
+ gtk_widget_queue_draw_area (glade_xml_get_widget (cam->xml, "da"), 0,
+ 0, cam->x, cam->y);
+
+ cam->vid_map.frame = frame;
+ if (ioctl (cam->dev, VIDIOCMCAPTURE, &cam->vid_map) < 0) {
+ if (cam->debug == TRUE) {
+ fprintf (stderr, "Unable to capture image (VIDIOCMCAPTURE)\n");
+ }
+ error_dialog (_("Unable to capture image."));
+ exit (-1);
+ }
+
+ /*
+ * next frame
+ */
+ frame++;
+
+ /*
+ * reset to the 1st frame
+ */
+ if (frame >= cam->vid_buf.frames) {
+ frame = 0;
+ }
+
+ frames2++;
+ g_object_unref ((gpointer) gc);
+ return TRUE; /* call this function again */
+}
+
static void
implement_capture_strategy (CaptureStrategyIface* iface)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]