This feature is required only for linux alsa and would use alsa-only code (subscribing to and reading alsa ctl values), in the very top layer where the config gets reloaded.
The existing design already subscribed for CoreAudio and WASAPI format changes and triggers STOP and throws CAPTUREFORMATCHANGE. So I don't think it's a linux specific feature. Nor will it mess up with the existing clean design as it's already there for other systems.
Take CoreAudio as example, it has two logics:
Here it gets the rate event from the system and trigger CAPTUREFORMATCHANGE, regardless of user defined stop_on_rate_change value. This detection is based on CoreAudio's rate
listener. And
here it check if the measured rate is off 4% and trigger CAPTUREFORMATCHANGE if stop_on_rate_change = true
You can search code for WASAPI output and find similar implementation as CoreAudio.
On ALSA the latter test is implemented
here, but no former equivalent. IMHO ALSA has an incomplete implementation now. Subscribing to Ctl values completes the implementation, rather than mess up the existing clean design.
I am not sure I understand your point. Of course the solution would have to read the new rate first and config CDSP accordingly.
So currently it go through a few stages:
* cdsp plays 44.1
-> user change to 96
* cdsp still plays 44.1 but reporting a rate mismatch if stop_on_rate_change is false (a)
-> gaudio_ctl gets notified and calling python script to reset config
* cdsp gets message and stop the current stream, switches to 96 and plays again
here, step marked with (a) is the annoying part because it plays 96khz material in 44.1khz, at least for 2 seconds.
user could set stop_on_rate_change = true to make it shorter, but no matter what rate_measure_interval you choose the hiccup is still there.
The problem does not present in CoreAudio nor WASAPI, as format changes stops the stream directly.
What should be done is to implement similar event listener as CoreAudio, and stop much earlier.
also can you shed light on
this question?