1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 20:28:11 +00:00
serenity/Userland/Services/AudioServer/ClientConnection.h
sin-ack 2e1bbcb0fa LibCore+LibIPC+Everywhere: Return Stream::LocalSocket from LocalServer
This change unfortunately cannot be atomically made without a single
commit changing everything.

Most of the important changes are in LibIPC/Connection.cpp,
LibIPC/ServerConnection.cpp and LibCore/LocalServer.cpp.

The notable changes are:
- IPCCompiler now generates the decode and decode_message functions such
  that they take a Core::Stream::LocalSocket instead of the socket fd.
- IPC::Decoder now uses the receive_fd method of LocalSocket instead of
  doing system calls directly on the fd.
- IPC::ConnectionBase and related classes now use the Stream API
  functions.
- IPC::ServerConnection no longer constructs the socket itself; instead,
  a convenience macro, IPC_CLIENT_CONNECTION, is used in place of
  C_OBJECT and will generate a static try_create factory function for
  the ServerConnection subclass. The subclass is now responsible for
  passing the socket constructed in this function to its
  ServerConnection base; the socket is passed as the first argument to
  the constructor (as a NonnullOwnPtr<Core::Stream::LocalServer>) before
  any other arguments.
- The functionality regarding taking over sockets from SystemServer has
  been moved to LibIPC/SystemServerTakeover.cpp. The Core::LocalSocket
  implementation of this functionality hasn't been deleted due to my
  intention of removing this class in the near future and to reduce
  noise on this (already quite noisy) PR.
2022-01-15 13:29:48 +03:30

61 lines
2.3 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 <LibIPC/ClientConnection.h>
namespace Audio {
class Buffer;
}
namespace AudioServer {
class ClientAudioStream;
class Mixer;
class ClientConnection final : public IPC::ClientConnection<AudioClientEndpoint, AudioServerEndpoint> {
C_OBJECT(ClientConnection)
public:
~ClientConnection() override;
void did_finish_playing_buffer(Badge<ClientAudioStream>, int buffer_id);
void did_change_client_volume(Badge<ClientAudioStream>, double volume);
void did_change_main_mix_muted_state(Badge<Mixer>, bool muted);
void did_change_main_mix_volume(Badge<Mixer>, double volume);
virtual void die() override;
static void for_each(Function<void(ClientConnection&)>);
private:
explicit ClientConnection(NonnullOwnPtr<Core::Stream::LocalSocket>, int client_id, Mixer& mixer);
virtual Messages::AudioServer::GetMainMixVolumeResponse get_main_mix_volume() override;
virtual void set_main_mix_volume(double) override;
virtual Messages::AudioServer::GetSelfVolumeResponse get_self_volume() override;
virtual void set_self_volume(double) override;
virtual Messages::AudioServer::EnqueueBufferResponse enqueue_buffer(Core::AnonymousBuffer const&, i32, int) override;
virtual Messages::AudioServer::GetRemainingSamplesResponse get_remaining_samples() override;
virtual Messages::AudioServer::GetPlayedSamplesResponse get_played_samples() override;
virtual void set_paused(bool) override;
virtual void clear_buffer(bool) override;
virtual Messages::AudioServer::GetPlayingBufferResponse get_playing_buffer() override;
virtual Messages::AudioServer::IsMainMixMutedResponse is_main_mix_muted() override;
virtual void set_main_mix_muted(bool) override;
virtual Messages::AudioServer::IsSelfMutedResponse is_self_muted() override;
virtual void set_self_muted(bool) override;
virtual void set_sample_rate(u32 sample_rate) override;
virtual Messages::AudioServer::GetSampleRateResponse get_sample_rate() override;
Mixer& m_mixer;
RefPtr<ClientAudioStream> m_queue;
};
}