mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:14:58 +00:00
AudioServer+Userland: Separate audio IPC into normal client and manager
This is a sensible separation of concerns that mirrors the WindowServer IPC split. On the one hand, there is the "normal" audio interface, used for clients that play audio, which is the primary service of AudioServer. On the other hand, there is the management interface, which, like the WindowManager endpoint, provides higher-level control over clients and the server itself. The reasoning for this split are manifold, as mentioned we are mirroring the WindowServer split. Another indication to the sensibility of the split is that no single audio client used the APIs of both interfaces. Also, useless audio queues are no longer created for managing clients (since those don't even exist, just like there's no window backing bitmap for window managing clients), eliminating any bugs that may occur there as they have in the past. Implementation-wise, we just move all the APIs and implementations from the old AudioServer into the AudioManagerServer (and respective clients, of course). There is one point of duplication, namely the hardware sample rate. This will be fixed in combination with per-client sample rate, eliminating client-side resampling and the related update bugs. For now, we keep one legacy API to simplify the transition. The new AudioManagerServer also gains a hardware sample rate change callback to have exact symmetry on the main server parameters (getter, setter, and callback).
This commit is contained in:
parent
c3f5b514c8
commit
03fac609ee
20 changed files with 250 additions and 87 deletions
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include <AK/Variant.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibAudio/ConnectionToServer.h>
|
||||
#include <LibAudio/ConnectionToManagerServer.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibCore/System.h>
|
||||
|
@ -27,8 +27,7 @@ enum AudioVariable : u32 {
|
|||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
{
|
||||
Core::EventLoop loop;
|
||||
auto audio_client = TRY(Audio::ConnectionToServer::try_create());
|
||||
audio_client->async_pause_playback();
|
||||
auto audio_client = TRY(Audio::ConnectionToManagerServer::try_create());
|
||||
|
||||
StringView command;
|
||||
Vector<StringView> command_arguments;
|
||||
|
@ -85,7 +84,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
break;
|
||||
}
|
||||
case AudioVariable::SampleRate: {
|
||||
u32 sample_rate = audio_client->get_sample_rate();
|
||||
u32 sample_rate = audio_client->get_device_sample_rate();
|
||||
if (human_mode)
|
||||
outln("Sample rate: {:5d} Hz", sample_rate);
|
||||
else
|
||||
|
@ -155,7 +154,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
}
|
||||
case AudioVariable::SampleRate: {
|
||||
int& sample_rate = to_set.value.get<int>();
|
||||
audio_client->set_sample_rate(sample_rate);
|
||||
audio_client->set_device_sample_rate(sample_rate);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue