Skip to content

Commit

Permalink
use shrecord uiomux to alloc capture buffers
Browse files Browse the repository at this point in the history
  • Loading branch information
kfish committed Apr 16, 2010
1 parent c24ee0d commit ba52009
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
21 changes: 7 additions & 14 deletions src/capture.c
Expand Up @@ -591,15 +591,13 @@ static void init_device(capture * cap)

static void close_device(capture * cap)
{
uiomux_close(cap->uiomux);

if (-1 == close(cap->fd))
errno_exit("close");

cap->fd = -1;
}

static void open_device(capture * cap)
static void open_device(capture * cap, UIOMux * uiomux)
{
struct stat st;

Expand All @@ -625,12 +623,7 @@ static void open_device(capture * cap)
}

/* User mapped memory */
cap->uiomux = uiomux_open();
if (cap->uiomux == 0) {
fprintf(stderr, "Cannot uiomux: %d, %s\n",
errno, strerror(errno));
exit(EXIT_FAILURE);
}
cap->uiomux = uiomux;
}

void capture_close(capture * cap)
Expand All @@ -642,7 +635,7 @@ void capture_close(capture * cap)
free(cap);
}

static capture *capture_open_mode(const char *device_name, int width, int height, int mode)
static capture *capture_open_mode(const char *device_name, int width, int height, int mode, UIOMux * uiomux)
{
capture *cap;

Expand All @@ -656,20 +649,20 @@ static capture *capture_open_mode(const char *device_name, int width, int height
cap->height = height;
cap->use_physical = 0;

open_device(cap);
open_device(cap, uiomux);
init_device(cap);

return cap;
}

capture *capture_open(const char *device_name, int width, int height)
{
return capture_open_mode(device_name, width, height, IO_METHOD_MMAP);
return capture_open_mode(device_name, width, height, IO_METHOD_MMAP, NULL);
}

capture *capture_open_userio(const char *device_name, int width, int height)
capture *capture_open_userio(const char *device_name, int width, int height, UIOMux * uiomux)
{
return capture_open_mode(device_name, width, height, IO_METHOD_USERPTR);
return capture_open_mode(device_name, width, height, IO_METHOD_USERPTR, uiomux);
}

int capture_get_width(capture * cap)
Expand Down
2 changes: 1 addition & 1 deletion src/capture.h
Expand Up @@ -28,7 +28,7 @@ typedef void (*capture_callback) (capture * cap, const unsigned char *frame_data

capture *capture_open(const char *device_name, int width, int height);

capture *capture_open_userio(const char *device_name, int width, int height);
capture *capture_open_userio(const char *device_name, int width, int height, UIOMux * uiomux);

void capture_close(capture * cap);

Expand Down
2 changes: 1 addition & 1 deletion src/shrecord.c
Expand Up @@ -407,7 +407,7 @@ void * shrecord_main (void * data)
}

/* Camera capture initialisation */
pvt->cameras[i].ceu = capture_open_userio(pvt->cameras[i].devicename, pvt->cameras[i].cap_w, pvt->cameras[i].cap_h);
pvt->cameras[i].ceu = capture_open_userio(pvt->cameras[i].devicename, pvt->cameras[i].cap_w, pvt->cameras[i].cap_h, pvt->uiomux);
if (pvt->cameras[i].ceu == NULL) {
fprintf(stderr, "capture_open failed, exiting\n");
return NULL;
Expand Down

0 comments on commit ba52009

Please sign in to comment.