Files
eden/src/audio_core/out/audio_out.cpp
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

105 lines
2.7 KiB
C++
Raw Normal View History

// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
2022-07-16 23:48:45 +01:00
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "audio_core/audio_out_manager.h"
#include "audio_core/out/audio_out.h"
#include "core/hle/kernel/k_event.h"
namespace AudioCore::AudioOut {
Out::Out(Core::System& system_, Manager& manager_, Kernel::KEvent* event_, size_t session_id_)
: manager{manager_}, parent_mutex{manager.mutex}, event{event_}
, audio_system{system_, event, session_id_}
{}
2022-07-16 23:48:45 +01:00
void Out::Free(Core::System& system) {
2022-07-16 23:48:45 +01:00
std::scoped_lock l{parent_mutex};
manager.ReleaseSessionId(system, audio_system.GetSessionId());
2022-07-16 23:48:45 +01:00
}
System& Out::GetSystem() {
return audio_system;
2022-07-16 23:48:45 +01:00
}
AudioOut::State Out::GetState() {
std::scoped_lock l{parent_mutex};
return audio_system.GetState();
2022-07-16 23:48:45 +01:00
}
Result Out::StartSystem() {
std::scoped_lock l{parent_mutex};
return audio_system.Start();
2022-07-16 23:48:45 +01:00
}
void Out::StartSession() {
std::scoped_lock l{parent_mutex};
audio_system.StartSession();
2022-07-16 23:48:45 +01:00
}
Result Out::StopSystem() {
std::scoped_lock l{parent_mutex};
return audio_system.Stop();
2022-07-16 23:48:45 +01:00
}
Result Out::AppendBuffer(const AudioOutBuffer& buffer, const u64 tag) {
std::scoped_lock l{parent_mutex};
if (audio_system.AppendBuffer(buffer, tag)) {
2022-07-16 23:48:45 +01:00
return ResultSuccess;
}
2023-03-06 19:04:12 -05:00
return Service::Audio::ResultBufferCountReached;
2022-07-16 23:48:45 +01:00
}
void Out::ReleaseAndRegisterBuffers() {
std::scoped_lock l{parent_mutex};
if (audio_system.GetState() == State::Started) {
audio_system.ReleaseBuffers();
audio_system.RegisterBuffers();
2022-07-16 23:48:45 +01:00
}
}
bool Out::FlushAudioOutBuffers() {
std::scoped_lock l{parent_mutex};
return audio_system.FlushAudioOutBuffers();
2022-07-16 23:48:45 +01:00
}
u32 Out::GetReleasedBuffers(std::span<u64> tags) {
std::scoped_lock l{parent_mutex};
return audio_system.GetReleasedBuffers(tags);
2022-07-16 23:48:45 +01:00
}
Kernel::KReadableEvent& Out::GetBufferEvent() {
std::scoped_lock l{parent_mutex};
return event->GetReadableEvent();
}
2022-09-16 09:38:17 -04:00
f32 Out::GetVolume() const {
2022-07-16 23:48:45 +01:00
std::scoped_lock l{parent_mutex};
return audio_system.GetVolume();
2022-07-16 23:48:45 +01:00
}
void Out::SetVolume(const f32 volume) {
std::scoped_lock l{parent_mutex};
audio_system.SetVolume(volume);
2022-07-16 23:48:45 +01:00
}
2022-09-16 09:38:17 -04:00
bool Out::ContainsAudioBuffer(const u64 tag) const {
2022-07-16 23:48:45 +01:00
std::scoped_lock l{parent_mutex};
return audio_system.ContainsAudioBuffer(tag);
2022-07-16 23:48:45 +01:00
}
2022-09-16 09:38:17 -04:00
u32 Out::GetBufferCount() const {
2022-07-16 23:48:45 +01:00
std::scoped_lock l{parent_mutex};
return audio_system.GetBufferCount();
2022-07-16 23:48:45 +01:00
}
2022-09-16 09:38:17 -04:00
u64 Out::GetPlayedSampleCount() const {
2022-07-16 23:48:45 +01:00
std::scoped_lock l{parent_mutex};
return audio_system.GetPlayedSampleCount();
2022-07-16 23:48:45 +01:00
}
} // namespace AudioCore::AudioOut