mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 17:44:56 +09:00

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).
50 lines
1.6 KiB
C++
50 lines
1.6 KiB
C++
/*
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/HashMap.h>
|
|
#include <AudioServer/AudioClientEndpoint.h>
|
|
#include <AudioServer/AudioServerEndpoint.h>
|
|
#include <LibAudio/Queue.h>
|
|
#include <LibCore/EventLoop.h>
|
|
#include <LibIPC/ConnectionFromClient.h>
|
|
|
|
namespace AudioServer {
|
|
|
|
class ClientAudioStream;
|
|
class Mixer;
|
|
|
|
class ConnectionFromClient final : public IPC::ConnectionFromClient<AudioClientEndpoint, AudioServerEndpoint> {
|
|
C_OBJECT(ConnectionFromClient)
|
|
public:
|
|
~ConnectionFromClient() override = default;
|
|
|
|
void did_change_client_volume(Badge<ClientAudioStream>, double volume);
|
|
|
|
virtual void die() override;
|
|
|
|
static void for_each(Function<void(ConnectionFromClient&)>);
|
|
|
|
private:
|
|
explicit ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket>, int client_id, Mixer& mixer);
|
|
|
|
virtual Messages::AudioServer::GetSelfVolumeResponse get_self_volume() override;
|
|
virtual void set_self_volume(double) override;
|
|
virtual void set_buffer(Audio::AudioQueue const&) override;
|
|
virtual void clear_buffer() override;
|
|
virtual void start_playback() override;
|
|
virtual void pause_playback() override;
|
|
virtual Messages::AudioServer::IsSelfMutedResponse is_self_muted() override;
|
|
virtual void set_self_muted(bool) override;
|
|
// FIXME: Decouple client sample rate from device sample rate, then remove this endpoint
|
|
virtual Messages::AudioServer::GetSampleRateResponse get_sample_rate() override;
|
|
|
|
Mixer& m_mixer;
|
|
RefPtr<ClientAudioStream> m_queue;
|
|
};
|
|
|
|
}
|