1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 22:17:44 +00:00

AudioServer: Move ClientAudioStream to own files

This class will only grow, and it should really have its own files.
This commit is contained in:
kleines Filmröllchen 2023-07-10 23:41:08 +02:00 committed by Andrew Kaster
parent 3406d500a4
commit aacb4fc590
6 changed files with 181 additions and 95 deletions

View file

@ -0,0 +1,57 @@
/*
* Copyright (c) 2018-2022, the SerenityOS developers.
* Copyright (c) 2021-2023, kleines Filmröllchen <filmroellchen@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include "ConnectionFromClient.h"
#include "FadingProperty.h"
#include <AK/Atomic.h>
#include <AK/Badge.h>
#include <AK/Debug.h>
#include <AK/RefCounted.h>
#include <AK/WeakPtr.h>
#include <LibAudio/Queue.h>
namespace AudioServer {
class ClientAudioStream : public RefCounted<ClientAudioStream> {
public:
explicit ClientAudioStream(ConnectionFromClient&);
~ClientAudioStream() = default;
bool get_next_sample(Audio::Sample& sample, u32 audiodevice_sample_rate);
void clear();
bool is_connected() const;
ConnectionFromClient* client();
void set_buffer(OwnPtr<Audio::AudioQueue> buffer);
void set_paused(bool paused);
FadingProperty<double>& volume();
double volume() const;
void set_volume(double const volume);
bool is_muted() const;
void set_muted(bool muted);
u32 sample_rate() const;
void set_sample_rate(u32 sample_rate);
private:
OwnPtr<Audio::AudioQueue> m_buffer;
Vector<Audio::Sample> m_current_audio_chunk;
size_t m_in_chunk_location;
bool m_paused { true };
bool m_muted { false };
u32 m_sample_rate;
WeakPtr<ConnectionFromClient> m_client;
FadingProperty<double> m_volume { 1 };
};
}