2020-01-18 09:38:21 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 09:38:21 +01:00
|
|
|
*/
|
|
|
|
|
|
2019-07-13 19:42:03 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
2019-11-23 16:43:21 +01:00
|
|
|
#include <AudioServer/AudioClientEndpoint.h>
|
2019-08-03 19:41:02 +02:00
|
|
|
#include <AudioServer/AudioServerEndpoint.h>
|
2020-02-06 14:54:09 +01:00
|
|
|
#include <LibIPC/ServerConnection.h>
|
2019-07-17 14:52:12 +02:00
|
|
|
|
2020-02-06 10:40:02 +01:00
|
|
|
namespace Audio {
|
2019-07-13 19:42:03 +02:00
|
|
|
|
2020-02-06 10:40:02 +01:00
|
|
|
class Buffer;
|
|
|
|
|
|
|
|
|
|
class ClientConnection : public IPC::ServerConnection<AudioClientEndpoint, AudioServerEndpoint>
|
2019-11-23 16:43:21 +01:00
|
|
|
, public AudioClientEndpoint {
|
2020-02-06 10:40:02 +01:00
|
|
|
C_OBJECT(ClientConnection)
|
2019-07-13 19:42:03 +02:00
|
|
|
public:
|
2020-02-06 10:40:02 +01:00
|
|
|
ClientConnection();
|
2019-07-13 19:42:03 +02:00
|
|
|
|
2019-07-27 14:30:09 +02:00
|
|
|
virtual void handshake() override;
|
2020-02-06 10:40:02 +01:00
|
|
|
void enqueue(const Buffer&);
|
|
|
|
|
bool try_enqueue(const Buffer&);
|
2019-07-29 19:06:58 +02:00
|
|
|
|
2019-11-22 21:44:02 +01:00
|
|
|
bool get_muted();
|
|
|
|
|
void set_muted(bool);
|
|
|
|
|
|
2019-07-29 19:06:58 +02:00
|
|
|
int get_main_mix_volume();
|
|
|
|
|
void set_main_mix_volume(int);
|
2019-10-19 19:10:53 +02:00
|
|
|
|
|
|
|
|
int get_remaining_samples();
|
2019-11-04 19:39:17 +01:00
|
|
|
int get_played_samples();
|
|
|
|
|
int get_playing_buffer();
|
|
|
|
|
|
|
|
|
|
void set_paused(bool paused);
|
|
|
|
|
void clear_buffer(bool paused = false);
|
2019-11-23 16:43:21 +01:00
|
|
|
|
2019-11-23 17:21:12 +01:00
|
|
|
Function<void(i32 buffer_id)> on_finish_playing_buffer;
|
|
|
|
|
Function<void(bool muted)> on_muted_state_change;
|
2020-07-21 03:16:48 +02:00
|
|
|
Function<void(int volume)> on_main_mix_volume_change;
|
2019-11-23 17:21:12 +01:00
|
|
|
|
2019-11-23 16:43:21 +01:00
|
|
|
private:
|
2020-02-06 20:20:44 +01:00
|
|
|
virtual void handle(const Messages::AudioClient::FinishedPlayingBuffer&) override;
|
|
|
|
|
virtual void handle(const Messages::AudioClient::MutedStateChanged&) override;
|
2020-07-21 03:16:48 +02:00
|
|
|
virtual void handle(const Messages::AudioClient::MainMixVolumeChanged&) override;
|
2019-07-13 19:42:03 +02:00
|
|
|
};
|
2020-02-06 10:40:02 +01:00
|
|
|
|
|
|
|
|
}
|