mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 09:58:14 +00:00
AudioServer+Userland: Decouple client sample rates from device rate
This change was a long time in the making ever since we obtained sample rate awareness in the system. Now, each client has its own sample rate, accessible via new IPC APIs, and the device sample rate is only accessible via the management interface. AudioServer takes care of resampling client streams into the device sample rate. Therefore, the main improvement introduced with this commit is full responsiveness to sample rate changes; all open audio programs will continue to play at correct speed with the audio resampled to the new device rate. The immediate benefits are manifold: - Gets rid of the legacy hardware sample rate IPC message in the non-managing client - Removes duplicate resampling and sample index rescaling code everywhere - Avoids potential sample index scaling bugs in SoundPlayer (which have happened many times before) and fixes a sample index scaling bug in aplay - Removes several FIXMEs - Reduces amount of sample copying in all applications (especially Piano, where this is critical), improving performance - Reduces number of resampling users, making future API changes (which will need to happen for correct resampling to be implemented) easier I also threw in a simple race condition fix for Piano's audio player loop.
This commit is contained in:
parent
d52a2ff10e
commit
b4fbd30b70
20 changed files with 100 additions and 93 deletions
|
@ -55,6 +55,8 @@ public:
|
|||
// Non-realtime code needn't worry about this.
|
||||
size_t remaining_buffers() const;
|
||||
|
||||
void set_self_sample_rate(u32 sample_rate);
|
||||
|
||||
virtual void die() override;
|
||||
|
||||
Function<void(double volume)> on_client_volume_change;
|
||||
|
@ -67,7 +69,6 @@ private:
|
|||
// We use this to perform the audio enqueuing on the background thread's event loop
|
||||
virtual void custom_event(Core::CustomEvent&) override;
|
||||
|
||||
// FIXME: This should be called every time the sample rate changes, but we just cautiously call it on every non-realtime enqueue.
|
||||
void update_good_sleep_time();
|
||||
|
||||
// Shared audio buffer: both server and client constantly read and write to/from this.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue