1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-19 16:52:06 +00:00
serenity/Userland/Applications/Piano/AudioPlayerLoop.h
Itamar 3a71748e5d Userland: Rename IPC ClientConnection => ConnectionFromClient
This was done with CLion's automatic rename feature and with:
find . -name ClientConnection.h
    | rename 's/ClientConnection\.h/ConnectionFromClient.h/'

find . -name ClientConnection.cpp
    | rename 's/ClientConnection\.cpp/ConnectionFromClient.cpp/'
2022-02-25 22:35:12 +01:00

40 lines
1.2 KiB
C++

/*
* Copyright (c) 2021, kleines Filmröllchen <filmroellchen@serenityos.org>
* Copyright (c) 2021, JJ Roberts-White <computerfido@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include "Music.h"
#include <LibAudio/Buffer.h>
#include <LibAudio/ConnectionFromClient.h>
#include <LibAudio/WavWriter.h>
#include <LibCore/Object.h>
class TrackManager;
// Wrapper class accepting custom events to advance the track playing and forward audio data to the system.
// This does not run on a separate thread, preventing IPC multithreading madness.
class AudioPlayerLoop final : public Core::Object {
C_OBJECT(AudioPlayerLoop)
public:
void enqueue_audio();
void toggle_paused();
bool is_playing() { return m_should_play_audio; }
private:
AudioPlayerLoop(TrackManager& track_manager, bool& need_to_write_wav, Audio::WavWriter& wav_writer);
TrackManager& m_track_manager;
Array<Sample, sample_count> m_buffer;
Optional<Audio::ResampleHelper<double>> m_resampler;
RefPtr<Audio::ConnectionFromClient> m_audio_client;
bool m_should_play_audio = true;
bool& m_need_to_write_wav;
Audio::WavWriter& m_wav_writer;
};