Skip to contentSkip to conversation

snd_pcm_commit asserts

DISCUSSION Nicolas Hüppelshäuser 2 participants 4 messages Jun 11, 2004

lore
Share & tools
lore
#0 lore raw

Hello!

Using alsa 1.0.4 the following problem occurs.

If in between a snd_pcm_mmap_begin and snd_pcm_mmap_commit a xrun occured I'm not (always) able to do a successful commit.

If in XRUN state the snd_pcm_mmap_commit returns error code -32 (broken pipe). Getting this I do xrun recovery with bringing alsa into state PREPARED and repeating the snd_pcm_mmap_commit call. Some times this may succeed but most of the time it fails again, this time with an assertion:

pcm.c:5945: snd_pcm_mmap_commit: Assertion `offset == *pcm->appl.ptr % pcm->buffer_size' failed.

Another approach to prevent the first failing commit (the one returning broken pipe error) is to check immediately before calling snd_pcm_commit the state and ensure to be either in RUNNING state or in PREPARED state respectively. So if the XRUN occured after snd_pcm_mmap_begin and before calling snd_pcm_mmap_commit alsa is in state PREPARED when doing the commit. Sometimes this works, sometimes the snd_pcm_mmap_commit call throws again

pcm.c:5945: snd_pcm_mmap_commit: Assertion `offset == *pcm->appl.ptr % pcm->buffer_size ' failed.

Nevertheless the data provided to snd_pcm_mmap_commit is always the same and corresponds to the data obtained by the mmap_begin call.

The problem appears in playback and capture mode.

Viele Gruesse / best regards
Nicolas Hueppelshaeuser
--
nicolas hueppelshaeuser, emlix gmbh, http://www.emlix.com,

emlix - your embedded linux partner

-------------------------------------------------------
This SF.Net email is sponsored by the new InstallShield X.

Quoted 1 line

From Windows to Linux, servers to mobile, InstallShield X is the

one installation-authoring solution that does it all. Learn more and evaluate today! http://www.installshield.com/Dev2Dev/0504

#1 lore raw
Quoted 7 lines · Nicolas Hüppelshäuser

Hello!

Using alsa 1.0.4 the following problem occurs.

If in between a snd_pcm_mmap_begin and snd_pcm_mmap_commit a xrun occured I'm not (always) able to do a successful commit.

Quoted 7 lines

If in XRUN state the snd_pcm_mmap_commit returns error code -32 (broken pipe). Getting this I do xrun recovery with bringing alsa into state PREPARED and repeating the snd_pcm_mmap_commit call. Some times this may succeed but most of the time it fails again, this time with an assertion:

pcm.c:5945: snd_pcm_mmap_commit: Assertion `offset == *pcm->appl.ptr % pcm->buffer_size' failed.

Did you call snd_pcm_mmap_begin() after xrun recovery again?

Jaroslav

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

-------------------------------------------------------
This SF.Net email is sponsored by the new InstallShield X.

Quoted 1 line

From Windows to Linux, servers to mobile, InstallShield X is the

one installation-authoring solution that does it all. Learn more and evaluate today! http://www.installshield.com/Dev2Dev/0504

#2 lore raw
Quoted 14 lines · Jaroslav Kysela
Quoted 12 lines · Nicolas Hüppelshäuser

Hello!

Using alsa 1.0.4 the following problem occurs.

If in between a snd_pcm_mmap_begin and snd_pcm_mmap_commit a xrun occured I'm not (always) able to do a successful commit.

If in XRUN state the snd_pcm_mmap_commit returns error code -32 (broken pipe). Getting this I do xrun recovery with bringing alsa into state PREPARED and repeating the snd_pcm_mmap_commit call. Some times this may succeed but most of the time it fails again, this time with an assertion:

Quoted 4 lines
Quoted 2 lines

pcm.c:5945: snd_pcm_mmap_commit: Assertion `offset == *pcm->appl.ptr % pcm->buffer_size' failed.

Did you call snd_pcm_mmap_begin() after xrun recovery again?

No I did not. If I need to it takes me to the following questions:

(1) Does this mean in case of an xrun my mmap region got "unmapped"?

(2) Why does my second snd_pcm_mmap_commit call not fail every time then but only "most of the time"?

(3) The mmap region obtained via the "re-begin" - does it match the region previously obtained --- is it the same as before?

(4) In playback case - do I have to rewrite the data?

(5) What happens to the application frame pointer in xrun case?

Thanks in advance
Nicolas

-------------------------------------------------------
This SF.Net email is sponsored by the new InstallShield X.

Quoted 1 line

From Windows to Linux, servers to mobile, InstallShield X is the

one installation-authoring solution that does it all. Learn more and evaluate today! http://www.installshield.com/Dev2Dev/0504

#3 lore raw
Quoted 8 lines · Nicolas Hüppelshäuser
Quoted 4 lines
Quoted 2 lines

pcm.c:5945: snd_pcm_mmap_commit: Assertion `offset == *pcm->appl.ptr % pcm->buffer_size' failed.

Did you call snd_pcm_mmap_begin() after xrun recovery again?

No I did not. If I need to it takes me to the following questions:

(1) Does this mean in case of an xrun my mmap region got "unmapped"?

It is not valid more.

Quoted 2 lines

(2) Why does my second snd_pcm_mmap_commit call not fail every time then but only "most of the time"?

It's possible. The xrun recovery calls might shift/reset the writing position (appl_ptr).

Quoted 2 lines

(3) The mmap region obtained via the "re-begin" - does it match the region previously obtained --- is it the same as before?

It's not guaranteed.

Quoted 1 line

(4) In playback case - do I have to rewrite the data?

After xrun recovery, you start with an empty buffer.

Quoted 1 line

(5) What happens to the application frame pointer in xrun case?

snd_pcm_prepare() or snd_pcm_drop() sync the appl_ptr to hw_ptr (thus it can be moved).

Jaroslav

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

-------------------------------------------------------
This SF.Net email is sponsored by the new InstallShield X.

Quoted 1 line

From Windows to Linux, servers to mobile, InstallShield X is the

one installation-authoring solution that does it all. Learn more and evaluate today! http://www.installshield.com/Dev2Dev/0504