2022-04-23 08:59:50 +00:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2018-07-27 00:01:37 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <memory>
|
2018-08-02 22:27:22 +00:00
|
|
|
#include <string>
|
2018-07-27 00:01:37 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "audio_core/buffer.h"
|
2018-07-28 17:44:50 +00:00
|
|
|
#include "audio_core/sink.h"
|
2018-07-27 00:01:37 +00:00
|
|
|
#include "audio_core/stream.h"
|
|
|
|
#include "common/common_types.h"
|
|
|
|
|
2019-02-14 17:42:58 +00:00
|
|
|
namespace Core::Timing {
|
|
|
|
class CoreTiming;
|
|
|
|
}
|
|
|
|
|
2018-07-27 00:01:37 +00:00
|
|
|
namespace AudioCore {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Represents an audio playback interface, used to open and play audio streams
|
|
|
|
*/
|
|
|
|
class AudioOut {
|
|
|
|
public:
|
|
|
|
/// Opens a new audio stream
|
2019-02-14 17:42:58 +00:00
|
|
|
StreamPtr OpenStream(Core::Timing::CoreTiming& core_timing, u32 sample_rate, u32 num_channels,
|
|
|
|
std::string&& name, Stream::ReleaseCallback&& release_callback);
|
2018-07-27 00:01:37 +00:00
|
|
|
|
|
|
|
/// Returns a vector of recently released buffers specified by tag for the specified stream
|
2018-09-15 13:21:06 +00:00
|
|
|
std::vector<Buffer::Tag> GetTagsAndReleaseBuffers(StreamPtr stream, std::size_t max_count);
|
2018-07-27 00:01:37 +00:00
|
|
|
|
2020-11-17 03:14:29 +00:00
|
|
|
/// Returns a vector of all recently released buffers specified by tag for the specified stream
|
|
|
|
std::vector<Buffer::Tag> GetTagsAndReleaseBuffers(StreamPtr stream);
|
|
|
|
|
2018-07-27 00:01:37 +00:00
|
|
|
/// Starts an audio stream for playback
|
|
|
|
void StartStream(StreamPtr stream);
|
|
|
|
|
|
|
|
/// Stops an audio stream that is currently playing
|
|
|
|
void StopStream(StreamPtr stream);
|
|
|
|
|
|
|
|
/// Queues a buffer into the specified audio stream, returns true on success
|
2018-08-04 04:03:12 +00:00
|
|
|
bool QueueBuffer(StreamPtr stream, Buffer::Tag tag, std::vector<s16>&& data);
|
2018-07-27 00:01:37 +00:00
|
|
|
|
|
|
|
private:
|
2018-07-28 17:35:22 +00:00
|
|
|
SinkPtr sink;
|
2018-07-27 00:01:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace AudioCore
|