summaryrefslogtreecommitdiff
path: root/Userland/Services/AudioServer/ClientConnection.h
blob: bdee772a0e8c2831fc101998392c0134e03a11cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
 * 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(NonnullRefPtr<Core::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 void set_sample_rate(u32 sample_rate) override;
    virtual Messages::AudioServer::GetSampleRateResponse get_sample_rate() override;

    Mixer& m_mixer;
    RefPtr<ClientAudioStream> m_queue;
};

}