Skip to contentSkip to conversation

snd_pcm_mmap_begin returns 0 but sets areas to NULL

DISCUSSION Carlo Wood 3 participants 5 messages Jul 22, 2003 – Jul 23, 2003

lore
Share & tools
lore

Carlo Wood

author
#0 lore raw

Is it ever allowed that:

    snd_pcm_channel_area_t const* areas;
    snd_pcm_uframes_t offset;
    snd_pcm_uframes_t size = period_size;
    if (size > 0)
    {
      snd_pcm_uframes_t frames = size;
      int err = snd_pcm_mmap_begin(handle, &areas, &offset, &frames);

returns err == 0, but results in areas == NULL ?

Or is that a bug in alsa?

Signature · 8 lines
Carlo Wood <[email protected]>


-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
author
#1 lore raw
Quoted 3 lines · Carlo Wood
      int err = snd_pcm_mmap_begin(handle, &areas, &offset, &frames);

returns err == 0, but results in areas == NULL ?

I looked deeper into it, and it happens because
snd_pcm_mmap_begin returns snd_pcm_mmap_areas()
which returns pcm->running_areas:

314 static inline const snd_pcm_channel_area_t *snd_pcm_mmap_areas(snd_pcm_t *pcm)
315 {
316 if (pcm->stopped_areas &&
317 snd_pcm_state(pcm) != SND_PCM_STATE_RUNNING)
318 return pcm->stopped_areas;
319 return pcm->running_areas;
320 }

where

(gdb) p *pcm
$6 = {dl_handle = 0x40016670, name = 0x81a5088 "emu10k1", type = SND_PCM_TYPE_HW, stream = SND_PCM_STREAM_CAPTURE,
mode = 0, poll_fd = 9, poll_events = 1, setup = 1, access = SND_PCM_ACCESS_RW_INTERLEAVED,
format = SND_PCM_FORMAT_S16_LE, subformat = SND_PCM_SUBFORMAT_STD, channels = 1, rate = 22050, period_size = 384, period_time = 17414, periods = {min = 0, max = 0, openmin = 0, openmax = 0, integer = 0, empty = 0}, tick_time = 1000, tstamp_mode = SND_PCM_TSTAMP_NONE, period_step = 1, sleep_min = 0, avail_min = 384, start_threshold = 1, stop_threshold = 768, silence_threshold = 0, silence_size = 0, xfer_align = 384, boundary = 1610612736, info = 65795, msbits = 16, rate_num = 22050, rate_den = 1, fifo_size = 0, buffer_size = 768, buffer_time = {min = 0, max = 0,

    openmin = 0, openmax = 0, integer = 0, empty = 0}, sample_bits = 16, frame_bits = 16, appl = {master = 0x0,
    ptr = 0x4001b000, fd = 9, offset = -2130706432, link_dst_count = 0, link_dst = 0x0, private_data = 0x0, changed = 0},
  hw = {master = 0x0, ptr = 0x40018008, fd = 9, offset = -2147483640, link_dst_count = 0, link_dst = 0x0,
    private_data = 0x0, changed = 0}, min_align = 1, mmap_rw = 0, donot_close = 0, mmap_channels = 0x0,

running_areas = 0x0, stopped_areas = 0x0, ops = 0x400cdc20, fast_ops = 0x400cdc60, op_arg = 0x804ffa8, fast_op_arg = 0x804ffa8, private_data = 0x81a4a98, async_handlers = {next = 0x80e5304, prev = 0x80e5304}}

Why is running_areas == 0x0 ??

I need direct read access for this capture-stream.

Signature · 8 lines
Carlo Wood <[email protected]>


-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
#2 lore raw

At Tue, 22 Jul 2003 16:38:34 +0200,

Quoted 4 lines · Carlo Wood

(gdb) p *pcm
$6 = {dl_handle = 0x40016670, name = 0x81a5088 "emu10k1", type = SND_PCM_TYPE_HW, stream = SND_PCM_STREAM_CAPTURE,
mode = 0, poll_fd = 9, poll_events = 1, setup = 1, access = SND_PCM_ACCESS_RW_INTERLEAVED,

                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

shouldn't be SND_PCM_ACCESS_MMAP_INTERLEAVED ?

Takashi

-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine. WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the same time. Free trial click here: http://www.vmware.com/wl/offer/345/0

#3 lore raw
In reply to Carlo Wood
Quoted 1 line · Carlo Wood

access = SND_PCM_ACCESS_RW_INTERLEAVED,

Again, access is your problem. You requested read/write access. You have to request mmap interleaved one (SND_PCM_ACCESS_MMAP_INTERLEAVED).

Jaroslav

-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, SuSE Labs

-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine. WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the same time. Free trial click here: http://www.vmware.com/wl/offer/345/0

#4 lore raw
In reply to Carlo Wood
Quoted 10 lines · Carlo Wood

Is it ever allowed that:

    snd_pcm_channel_area_t const* areas;
    snd_pcm_uframes_t offset;
    snd_pcm_uframes_t size = period_size;
    if (size > 0)
    {
      snd_pcm_uframes_t frames = size;
      int err = snd_pcm_mmap_begin(handle, &areas, &offset, &frames);
Quoted 3 lines

returns err == 0, but results in areas == NULL ?

Or is that a bug in alsa?

Perhaps, you're in a bad state. Did you call hw_params() with a MMAP access request before?

Jaroslav

-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, SuSE Labs

-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine. WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the same time. Free trial click here: http://www.vmware.com/wl/offer/345/0