From: Andriy Gapon <avg@icyb.net.ua>
To: alsa-devel@alsa-project.org
Subject: oss plugin: SNDCTL_DSP_SETFRAGMENT problems
Date: Thu, 01 Mar 2012 11:59:59 +0200 [thread overview]
Message-ID: <4F4F489F.3010800@icyb.net.ua> (raw)
[-- Attachment #1: Type: text/plain, Size: 2602 bytes --]
First, a disclaimer: what I'd like to discuss seems to affect a FreeBSD OSS
implementation.
After looking at the code in oss_pointer() and in snd_pcm_ioplug_hw_ptr_update()
it seems that the code depends on OSS driver using exactly the same buffer size
as specified by the buffer_size parameter.
Otherwise the code that handles hw pointer cycling would calculate a delta
incorrectly.
Then, it seems that oss_hw_params() tries to enforce the driver's buffer size
using SNDCTL_DSP_SETFRAGMENT. But in the OSS specification there are oh so many
warnings about it:
http://manuals.opensound.com/developer/SNDCTL_DSP_SETFRAGMENT.html
> It's important to understand that this call just sets the size hint. There is
> no guarantee that the requested size gets used.
...
> It's very important to make this ioctl call as early as possible after
> opening the device since otherwise the call may not have any effect. In
> particular this call must be made before calling read, write or some other
> ioctl calls.
...
> This ioctl call will return an error only if the argument value is incorrect
> or if the call is made in a wrong place. Even if the call returned OK there
> is no guarantee that the requested buffer size will be used. This ioctl call
> sets just the size hint and the driver may or may not honor the request.
I see at least two issues with the oss plugin code:
o Actual OSS driver buffer size value is never queried/verified if the
SNDCTL_DSP_SETFRAGMENT call is successful
o Apparently oss_hw_constraint() function is called before oss_hw_params() and
the former makes SNDCTL_DSP_CHANNELS ioctl calls which change a configuration of
the OSS driver and may affect the future SNDCTL_DSP_SETFRAGMENT call. This also
violates the order described here:
http://manuals.opensound.com/developer/callorder.html
There is a retry loop in oss_hw_params() which closes and re-opens an OSS
device, but that loop is only activated on SNDCTL_DSP_SETFRAGMENT hard failure;
there is no handling for the case where the ioctl succeeds but the resulting
buffer size differs from the requested one.
I think that to nullify any effects of oss_hw_constraint() on the OSS driver
configuration there should be a call to SNDCTL_DSP_RESET at the end of the
function. Alternatively, there could be a call to this ioctl before
SNDCTL_DSP_SETFRAGMENT. Or perhaps there could be resets at both places...
Ideally, of course, the OSS plugin should query the exact OSS driver buffer size
and alter the buffer_size parameter accordingly. But this is a bit more work.
What do you think?
Thank you.
--
Andriy Gapon
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
reply other threads:[~2012-03-01 9:59 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=4F4F489F.3010800@icyb.net.ua \
--to=avg@icyb.net.ua \
--cc=alsa-devel@alsa-project.org \
/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.