mirror of
https://github.com/RGBCube/serenity
synced 2025-10-28 18:12:33 +00:00
The file is now renamed to Queue.h, and the Resampler APIs with LegacyBuffer are also removed. These changes look large because nobody actually needs Buffer.h (or Queue.h). It was mostly transitive dependencies on the massive list of includes in that header, which are now almost all gone. Instead, we include common things like Sample.h directly, which should give faster compile times as very few files actually need Queue.h.
44 lines
1.3 KiB
C++
44 lines
1.3 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/ConnectionFromClient.h>
|
|
#include <LibAudio/Resampler.h>
|
|
#include <LibAudio/Sample.h>
|
|
#include <LibAudio/WavWriter.h>
|
|
#include <LibCore/Event.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);
|
|
|
|
virtual void timer_event(Core::TimerEvent&) override;
|
|
|
|
TrackManager& m_track_manager;
|
|
Array<Sample, sample_count> m_buffer;
|
|
Optional<Audio::ResampleHelper<Sample>> 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;
|
|
};
|