snd_pcm_mmap

Name

snd_pcm_mmap -- mmap the hardware buffers to the user space

Synopsis

int snd_pcm_mmap(snd_pcm_t *handle, int channel, snd_pcm_mmap_control_t **control, void **buffer);

Description

Performs the mmaping and returns control block and data block (buffer) in direction according to the specified channel. Function may be called in SND_PCM_STATUS_READY state, otherwise -EBADFD error is returned. Function returns zero and filled control and buffer pointers if successful, otherwise it returns an error code. This call is allowed only when the subdevice is in the block transfer mode.

The meaning of members from the control structure differs between the interleaved and non-interleaved transfer modes. The non-interleaved mode uses smaller transfer unit - fragment size divide voices. This unit is called as 'voice fragment' in the following text. All members from the control structure (as frag_io, frags, frag_size and number) refer to this unit.

typedef struct {
	volatile int status;
	volatile int frag_io;
	int frags;
	int frag_size;
	int voices;
	volatile unsigned int block;
	volatile unsigned int expblock;
	int res[9];
} snd_pcm_mmap_io_status_t;

typedef struct {
	unsigned int number;
	off_t addr;
	int voice;
	volatile char data;
	volatile char io;
	char res[2];
} snd_pcm_mmap_fragment_t;

typedef struct {
	snd_pcm_mmap_io_status_t status;
	snd_pcm_mmap_fragment_t fragments[128];
} snd_pcm_mmap_control_t;

MemberDescription
statusCurrent status (SND_PCM_STATUS_*) for direction.
frag_ioFragment or voice fragment number currently processed.
fragsCount of used fragments or voice fragments.
frag_sizeSize of fragment or voice fragment in bytes.
voicesNumber of voices for non-interleaved transfer or -1 when the interleaved format is used.
blockCurrent block number.
expblockExpected block number for wakeup. This block number is usually highter than the current block number. The application may use poll or select functions to wait until the transfer of this block is started.
numberFragment number.
addrOffset in bytes where the fragment or voice fragment begins.
voiceVoice number assigned to this voice fragment or -1 (interleaved stream).
dataFragment or voice fragment contains valid samples (data).
ioFragment or voice fragment is processed.