diff options
Diffstat (limited to '')
-rw-r--r-- | src/audio_core/audio_out.cpp | 8 | ||||
-rw-r--r-- | src/audio_core/audio_out.h | 3 | ||||
-rw-r--r-- | src/audio_core/stream.cpp | 7 | ||||
-rw-r--r-- | src/audio_core/stream.h | 4 |
4 files changed, 13 insertions, 9 deletions
diff --git a/src/audio_core/audio_out.cpp b/src/audio_core/audio_out.cpp index 3dfdf61f9..5cf665c22 100644 --- a/src/audio_core/audio_out.cpp +++ b/src/audio_core/audio_out.cpp @@ -27,16 +27,16 @@ static Stream::Format ChannelsToStreamFormat(u32 num_channels) { return {}; } -StreamPtr AudioOut::OpenStream(u32 sample_rate, u32 num_channels, +StreamPtr AudioOut::OpenStream(u32 sample_rate, u32 num_channels, std::string&& name, Stream::ReleaseCallback&& release_callback) { if (!sink) { const SinkDetails& sink_details = GetSinkDetails(Settings::values.sink_id); sink = sink_details.factory(Settings::values.audio_device_id); } - return std::make_shared<Stream>(sample_rate, ChannelsToStreamFormat(num_channels), - std::move(release_callback), - sink->AcquireSinkStream(sample_rate, num_channels)); + return std::make_shared<Stream>( + sample_rate, ChannelsToStreamFormat(num_channels), std::move(release_callback), + sink->AcquireSinkStream(sample_rate, num_channels), std::move(name)); } std::vector<Buffer::Tag> AudioOut::GetTagsAndReleaseBuffers(StreamPtr stream, size_t max_count) { diff --git a/src/audio_core/audio_out.h b/src/audio_core/audio_out.h index 95e9b53fe..d564ff91a 100644 --- a/src/audio_core/audio_out.h +++ b/src/audio_core/audio_out.h @@ -5,6 +5,7 @@ #pragma once #include <memory> +#include <string> #include <vector> #include "audio_core/buffer.h" @@ -20,7 +21,7 @@ namespace AudioCore { class AudioOut { public: /// Opens a new audio stream - StreamPtr OpenStream(u32 sample_rate, u32 num_channels, + StreamPtr OpenStream(u32 sample_rate, u32 num_channels, std::string&& name, Stream::ReleaseCallback&& release_callback); /// Returns a vector of recently released buffers specified by tag for the specified stream diff --git a/src/audio_core/stream.cpp b/src/audio_core/stream.cpp index a0045b7a1..7ab87c0c9 100644 --- a/src/audio_core/stream.cpp +++ b/src/audio_core/stream.cpp @@ -37,12 +37,12 @@ u32 Stream::GetSampleSize() const { } Stream::Stream(u32 sample_rate, Format format, ReleaseCallback&& release_callback, - SinkStream& sink_stream) + SinkStream& sink_stream, std::string&& name_) : sample_rate{sample_rate}, format{format}, release_callback{std::move(release_callback)}, - sink_stream{sink_stream} { + sink_stream{sink_stream}, name{std::move(name_)} { release_event = CoreTiming::RegisterEvent( - "Stream::Release", [this](u64 userdata, int cycles_late) { ReleaseActiveBuffer(); }); + name, [this](u64 userdata, int cycles_late) { ReleaseActiveBuffer(); }); } void Stream::Play() { @@ -104,6 +104,7 @@ void Stream::PlayNextBuffer() { } void Stream::ReleaseActiveBuffer() { + ASSERT(active_buffer); released_buffers.push(std::move(active_buffer)); release_callback(); PlayNextBuffer(); diff --git a/src/audio_core/stream.h b/src/audio_core/stream.h index 35253920e..00f991733 100644 --- a/src/audio_core/stream.h +++ b/src/audio_core/stream.h @@ -6,6 +6,7 @@ #include <functional> #include <memory> +#include <string> #include <vector> #include <queue> @@ -33,7 +34,7 @@ public: using ReleaseCallback = std::function<void()>; Stream(u32 sample_rate, Format format, ReleaseCallback&& release_callback, - SinkStream& sink_stream); + SinkStream& sink_stream, std::string&& name_); /// Plays the audio stream void Play(); @@ -96,6 +97,7 @@ private: std::queue<BufferPtr> queued_buffers; ///< Buffers queued to be played in the stream std::queue<BufferPtr> released_buffers; ///< Buffers recently released from the stream SinkStream& sink_stream; ///< Output sink for the stream + std::string name; ///< Name of the stream, must be unique }; using StreamPtr = std::shared_ptr<Stream>; |