From: Knut Petersen <Knut_Petersen@t-online.de>
To: alsa-devel@alsa-project.org
Cc: Takashi Iwai <tiwai@suse.de>, Kai Vehmanen <kvehmanen@nosignal.fi>
Subject: end of playback ... design question
Date: Wed, 31 Jul 2013 15:42:39 +0200 [thread overview]
Message-ID: <51F9144F.9080807@t-online.de> (raw)
Hi everybody!
Although I looked at quite a bit of source code and documentation I have
to admit that I am confused about one question:
How should alsa playback be stopped in a way that _guarantees_ that no
artifacts remaining in the drivers ringbuffer are played back again?
Let´s assume we play stereo 16bit audio data using the rme96 driver, period size set to 0x800 frames.
At the end of the penultimate frame playing will not be stopped even if there is only one frame
of audio data remaining. Obviously that means 0x7ff frames of already played data is played again
after that one valid frame, plus possibly a few that are played during the short time from interrupt request to
the real stop of the playback hardware (about 5 frames on an old Pentium-M 1.2GHz).
Now that could be fixed in different ways:
A: Always ensure that there is a bit of silence (at least hardware buffer size plus a few frames) at the end of all audio data.
Easy for the user , but only a workaround.
B: At the rme96 driver level that condition can be detected and the relevant part of the buffer
can be filled with zeros.
I did that in an experimental change. It does work, but it´s definitely only a hack as it fixes
the problem for only one device.
C: The application playing audio data could pad all audio data to the period size with zeros.
That would prevent playback of that max 0x7ff frames of garbage, but the few samples that are played
during the time from interrupt request to the execution of the stop trigger do escape
D: Don´t try to drain the buffer but pad with zeros and set a stop threshold.
Workaround for applications should also work with older kernels.
E: The alsa core could detect that condition and solve it equivalent to solution D
I think that´s the proper solution.
Did I miss something or do you agree?
cu,
Knut
next reply other threads:[~2013-07-31 13:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-31 13:42 Knut Petersen [this message]
2013-07-31 14:07 ` end of playback ... design question Jaroslav Kysela
2013-08-02 19:20 ` Kai Vehmanen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51F9144F.9080807@t-online.de \
--to=knut_petersen@t-online.de \
--cc=alsa-devel@alsa-project.org \
--cc=kvehmanen@nosignal.fi \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.