Commit 055e9fd7 authored by Jean-Paul Saman's avatar Jean-Paul Saman

access/alsa.c: mmap capture mode.

Capture using alsa mmap functions.
parent d3dd9028
......@@ -66,6 +66,10 @@
static int DemuxOpen ( vlc_object_t * );
static void DemuxClose( vlc_object_t * );
#define MMAP_TEXT N_( "Memory Mapped I/O" )
#define MMAP_LONGTEXT N_( \
"Capture audio samples using mmap I/O API." )
#define STEREO_TEXT N_( "Stereo" )
#define STEREO_LONGTEXT N_( \
"Capture the audio stream in stereo." )
......@@ -102,6 +106,8 @@ vlc_module_begin()
set_capability( "access_demux", 10 )
set_callbacks( DemuxOpen, DemuxClose )
add_bool( CFG_PREFIX "mmap", false, MMAP_TEXT, MMAP_LONGTEXT,
false )
add_bool( CFG_PREFIX "stereo", true, STEREO_TEXT, STEREO_LONGTEXT,
true )
add_string( CFG_PREFIX "format", "s16l", FORMAT_TEXT,
......@@ -131,6 +137,7 @@ struct demux_sys_t
/* Audio */
int i_cache;
unsigned int i_sample_rate;
bool b_mmap; /* mmap'ed I/O */
bool b_stereo;
vlc_fourcc_t i_format;
size_t i_max_frame_size;
......@@ -278,6 +285,7 @@ static int DemuxOpen( vlc_object_t *p_this )
free( psz_format );
p_sys->i_sample_rate = var_InheritInteger( p_demux, CFG_PREFIX "samplerate" );
p_sys->b_mmap = var_InheritBool( p_demux, CFG_PREFIX "mmap" );
p_sys->b_stereo = var_InheritBool( p_demux, CFG_PREFIX "stereo" );
p_sys->i_cache = var_InheritInteger( p_demux, CFG_PREFIX "caching" );
p_sys->p_es = NULL;
......@@ -405,8 +413,10 @@ static block_t* GrabAudio( demux_t *p_demux )
p_sys->p_block = p_block;
/* ALSA */
i_read = snd_pcm_readi( p_sys->p_alsa_pcm, p_block->p_buffer,
p_sys->i_alsa_chunk_size );
if( p_sys->b_mmap )
i_read = snd_pcm_mmap_readi( p_sys->p_alsa_pcm, p_block->p_buffer, p_sys->i_alsa_chunk_size );
else
i_read = snd_pcm_readi( p_sys->p_alsa_pcm, p_block->p_buffer, p_sys->i_alsa_chunk_size );
if( i_read == -EAGAIN )
{
snd_pcm_wait( p_sys->p_alsa_pcm, 10 ); /* See poll() comment in oss.c */
......@@ -567,6 +577,7 @@ static int OpenAudioDevAlsa( demux_t *p_demux, const char *psz_device )
/* Set Interleaved access */
if( ( i_err = snd_pcm_hw_params_set_access( p_sys->p_alsa_pcm, p_hw_params,
p_sys->b_mmap ? SND_PCM_ACCESS_MMAP_INTERLEAVED :
SND_PCM_ACCESS_RW_INTERLEAVED ) ) < 0 )
{
msg_Err( p_demux, "ALSA: cannot set access type (%s)",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment