[alsa-devel] Sample format changes by plugin while playing
Hi,
I have a general question about ALSA plugins: Is it possible for an ALSA plugin to reconfigure the sample rate and sample format of its slave in such a way that the software playing through that plugin wouldn't notice?
That is, given some audio stream, the plugin shall be allowed to change the sample rate and format based on control data extracted from the audio data pushed through the plugin. In my imagination, any output format changes should be completely transparent to the sound player; the player would always deliver a stream of audio data at a constant rate, and once in a while the plugin would change the hardware settings. For sure there would be an audible gap during reconfiguration, but that would be OK for me.
Now, is this possible at all?
Best regards, Robert
Robert Tiemann wrote:
Is this the correct list to ask questions about ALSA plugin development?
Yes.
Is it possible for an ALSA plugin to reconfigure the sample rate and sample format of its slave in such a way that the software playing through that plugin wouldn't notice?
In theory, yes. But you'd have to implement most of this yourself.
Regards, Clemens
On 04/19/2018 03:53 PM, Clemens Ladisch wrote:
Is it possible for an ALSA plugin to reconfigure the sample rate and sample format of its slave in such a way that the software playing through that plugin wouldn't notice?
In theory, yes. But you'd have to implement most of this yourself.
That's fine, I just wanted to know if this could possibly work and if an ALSA plugin could be the right place for this kind of stuff. That is, before diving into development and hitting any roadblocks only much later.
I guess "in theory" means that you don't know about any plugin of such kind I could take a look at, right?
Thank you, Robert
On Thu, 19 Apr 2018, Robert Tiemann wrote:
On 04/19/2018 03:53 PM, Clemens Ladisch wrote:
Is it possible for an ALSA plugin to reconfigure the sample rate and sample format of its slave in such a way that the software playing through that plugin wouldn't notice?
In theory, yes. But you'd have to implement most of this yourself.
That's fine, I just wanted to know if this could possibly work and if an ALSA plugin could be the right place for this kind of stuff. That is, before diving into development and hitting any roadblocks only much later.
I'm curious about this. Do you have a need to reconfigure the sample rate and format while a stream is playing? We had such a use case a while ago, where we had a source whose sample rate could change at any time, but ALSA sets up the stream configuration (sample rate etc) when the stream is opened (hw_params()) and it doesn't seem to be possible to reconfigure it on the fly. In the end we dropped the idea and solved the problem a different way.
/Ricard
On 04/19/2018 04:34 PM, Ricard Wanderlof wrote:
I'm curious about this. Do you have a need to reconfigure the sample rate and format while a stream is playing? We had such a use case a while ago,
Sort of. The input format, however, is fixed in my case. The output format may be different and must be recovered from the audio stream. Infrequently, the output format will change while the input format remains the same.
You can think about it as a compression scheme. I'd like to play such audio streams without touching any players, that's why I thought about writing an ALSA plugin for this.
but ALSA sets up the stream configuration (sample rate etc) when the stream is opened (hw_params()) and it doesn't seem to be possible to reconfigure it on the fly
This is probably something that my plugin would have to do with its slave. If this would possible during playback without disrupting the player, then I'd take this route.
Robert Tiemann wrote:
I guess "in theory" means that you don't know about any plugin of such kind I could take a look at, right?
No; most plugins force the configuration of the slave to be similar, and to be done at the same time as their own.
PulseAudio does something similar to this, but it's much more complex than just an ALSA plugin.
Regards, Clemens
On 04/19/2018 05:57 PM, Clemens Ladisch wrote:
Robert Tiemann wrote:
I guess "in theory" means that you don't know about any plugin of such kind I could take a look at, right?
No; most plugins force the configuration of the slave to be similar, and to be done at the same time as their own.
So a plugin can configure its slave the way it likes? Would it be possible to change the slave configuration multiple times during playback (close/open slave would be OK for me)?
PulseAudio does something similar to this, but it's much more complex than just an ALSA plugin.
I'd like to avoid PulseAudio for my case. Basically, I have the choice between writing an ALSA plugin for a generic and transparent solution, or implementing the functionality in the playback software.
The latter solution would be rather messy, I suspect, and be restricted to individual players (currently, I need to support two different players, both doing their things in very different ways). Anyway, taking a look a PulseAudio won't hurt if it cannot be done as ALSA plugin.
participants (3)
-
Clemens Ladisch
-
Ricard Wanderlof
-
Robert Tiemann