ladybird/Userland/Services/AudioServer/ConnectionFromManagerClient.h
kleines Filmröllchen 03fac609ee 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).
2023-06-25 00:16:44 +02:00

44 lines
1.4 KiB
C++

/*
* Copyright (c) 2023, kleines Filmröllchen <filmroellchen@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/NonnullOwnPtr.h>
#include <AudioServer/AudioManagerClientEndpoint.h>
#include <AudioServer/AudioManagerServerEndpoint.h>
#include <AudioServer/Mixer.h>
#include <LibIPC/ConnectionFromClient.h>
namespace AudioServer {
class ConnectionFromManagerClient final : public IPC::ConnectionFromClient<AudioManagerClientEndpoint, AudioManagerServerEndpoint> {
C_OBJECT(ConnectionFromManagerClient)
public:
~ConnectionFromManagerClient() override = default;
virtual void die() override;
static void for_each(Function<void(ConnectionFromManagerClient&)>);
void did_change_main_mix_muted_state(Badge<Mixer>, bool muted);
void did_change_main_mix_volume(Badge<Mixer>, double volume);
private:
ConnectionFromManagerClient(NonnullOwnPtr<Core::LocalSocket> client_socket, int client_id, Mixer& mixer);
virtual Messages::AudioManagerServer::GetMainMixVolumeResponse get_main_mix_volume() override;
virtual void set_main_mix_volume(double) override;
virtual Messages::AudioManagerServer::IsMainMixMutedResponse is_main_mix_muted() override;
virtual void set_main_mix_muted(bool) override;
virtual void set_device_sample_rate(u32 sample_rate) override;
virtual Messages::AudioManagerServer::GetDeviceSampleRateResponse get_device_sample_rate() override;
Mixer& m_mixer;
};
}