diff options
author | bunnei <bunneidev@gmail.com> | 2018-07-28 05:25:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-28 05:25:32 +0200 |
commit | e1d66ea7942800d51aff57c44d0e9ab9ffd949dc (patch) | |
tree | aaff4a680cafbd1111baa602af8d0d2d7297f585 /src/audio_core/audio_out.cpp | |
parent | Merge pull request #696 from DarkLordZach/romfs (diff) | |
parent | audout: Implement IAudioOut interface with AudioCore. (diff) | |
download | yuzu-e1d66ea7942800d51aff57c44d0e9ab9ffd949dc.tar yuzu-e1d66ea7942800d51aff57c44d0e9ab9ffd949dc.tar.gz yuzu-e1d66ea7942800d51aff57c44d0e9ab9ffd949dc.tar.bz2 yuzu-e1d66ea7942800d51aff57c44d0e9ab9ffd949dc.tar.lz yuzu-e1d66ea7942800d51aff57c44d0e9ab9ffd949dc.tar.xz yuzu-e1d66ea7942800d51aff57c44d0e9ab9ffd949dc.tar.zst yuzu-e1d66ea7942800d51aff57c44d0e9ab9ffd949dc.zip |
Diffstat (limited to 'src/audio_core/audio_out.cpp')
-rw-r--r-- | src/audio_core/audio_out.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/audio_core/audio_out.cpp b/src/audio_core/audio_out.cpp new file mode 100644 index 000000000..6d418a05b --- /dev/null +++ b/src/audio_core/audio_out.cpp @@ -0,0 +1,50 @@ +// Copyright 2018 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "audio_core/audio_out.h" +#include "common/assert.h" +#include "common/logging/log.h" + +namespace AudioCore { + +/// Returns the stream format from the specified number of channels +static Stream::Format ChannelsToStreamFormat(int num_channels) { + switch (num_channels) { + case 1: + return Stream::Format::Mono16; + case 2: + return Stream::Format::Stereo16; + case 6: + return Stream::Format::Multi51Channel16; + } + + LOG_CRITICAL(Audio, "Unimplemented num_channels={}", num_channels); + UNREACHABLE(); + return {}; +} + +StreamPtr AudioOut::OpenStream(int sample_rate, int num_channels, + Stream::ReleaseCallback&& release_callback) { + streams.push_back(std::make_shared<Stream>(sample_rate, ChannelsToStreamFormat(num_channels), + std::move(release_callback))); + return streams.back(); +} + +std::vector<u64> AudioOut::GetTagsAndReleaseBuffers(StreamPtr stream, size_t max_count) { + return stream->GetTagsAndReleaseBuffers(max_count); +} + +void AudioOut::StartStream(StreamPtr stream) { + stream->Play(); +} + +void AudioOut::StopStream(StreamPtr stream) { + stream->Stop(); +} + +bool AudioOut::QueueBuffer(StreamPtr stream, Buffer::Tag tag, std::vector<u8>&& data) { + return stream->QueueBuffer(std::make_shared<Buffer>(tag, std::move(data))); +} + +} // namespace AudioCore |