[vlc-devel] [PATCH] v4l/v4l2: add mmap() fall back for nommu systems
Mike Frysinger
vapier at gentoo.org
Fri Jan 9 11:49:29 CET 2009
On Linux no-mmu systems, getting a shared mapping often results in failure.
If the mmap() in v4l failed with MAP_SHARED, then fall back to MAP_PRIVATE.
Signed-off-by: Mike Frysinger <vapier at gentoo.org>
---
modules/access/v4l.c | 22 +++++++++++++++++-----
modules/access/v4l2.c | 9 +++++++--
2 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/modules/access/v4l.c b/modules/access/v4l.c
index 69eb305..f9d5841 100644
--- a/modules/access/v4l.c
+++ b/modules/access/v4l.c
@@ -1113,8 +1113,14 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device )
PROT_READ | PROT_WRITE, MAP_SHARED, i_fd, 0 );
if( p_sys->p_video_mmap == MAP_FAILED )
{
- msg_Err( p_demux, "mmap failed" );
- goto vdev_failed;
+ p_sys->p_video_mmap = mmap( 0,
+ p_sys->mjpeg_buffers.size * p_sys->mjpeg_buffers.count,
+ PROT_READ | PROT_WRITE, MAP_PRIVATE, i_fd, 0 );
+ if( p_sys->p_video_mmap == MAP_FAILED )
+ {
+ msg_Err( p_demux, "mmap failed" );
+ goto vdev_failed;
+ }
}
p_sys->i_fourcc = VLC_FOURCC( 'm','j','p','g' );
@@ -1165,9 +1171,15 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device )
i_fd, 0 );
if( p_sys->p_video_mmap == MAP_FAILED )
{
- /* FIXME -> normal read */
- msg_Err( p_demux, "mmap failed" );
- goto vdev_failed;
+ p_sys->p_video_mmap = mmap( 0, p_sys->vid_mbuf.size,
+ PROT_READ|PROT_WRITE, MAP_PRIVATE,
+ i_fd, 0 );
+ if( p_sys->p_video_mmap == MAP_FAILED )
+ {
+ /* FIXME -> normal read */
+ msg_Err( p_demux, "mmap failed" );
+ goto vdev_failed;
+ }
}
/* init grabbing */
diff --git a/modules/access/v4l2.c b/modules/access/v4l2.c
index e4fb38a..039aeca 100644
--- a/modules/access/v4l2.c
+++ b/modules/access/v4l2.c
@@ -1428,8 +1428,13 @@ static int InitMmap( demux_t *p_demux, int i_fd )
if( p_sys->p_buffers[p_sys->i_nbuffers].start == MAP_FAILED )
{
- msg_Err( p_demux, "mmap failed (%m)" );
- goto open_failed;
+ p_sys->p_buffers[p_sys->i_nbuffers].start =
+ v4l2_mmap( NULL, buf.length, PROT_READ | PROT_WRITE, MAP_PRIVATE, i_fd, buf.m.offset );
+ if( p_sys->p_buffers[p_sys->i_nbuffers].start == MAP_FAILED )
+ {
+ msg_Err( p_demux, "mmap failed (%m)" );
+ goto open_failed;
+ }
}
}
--
1.6.0.6
More information about the vlc-devel
mailing list