Files
eden/src/audio_core/in/audio_in.cpp
T

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

105 lines
2.6 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_in_manager.h"
#include "audio_core/in/audio_in.h"
#include "core/hle/kernel/k_event.h"
namespace AudioCore::AudioIn {
In::In(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 In::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& In::GetSystem() {
return audio_system;
2022-07-16 23:48:45 +01:00
}
AudioIn::State In::GetState() {
std::scoped_lock l{parent_mutex};
return audio_system.GetState();
2022-07-16 23:48:45 +01:00
}
Result In::StartSystem() {
std::scoped_lock l{parent_mutex};
return audio_system.Start();
2022-07-16 23:48:45 +01:00
}
void In::StartSession() {
std::scoped_lock l{parent_mutex};
audio_system.StartSession();
2022-07-16 23:48:45 +01:00
}
Result In::StopSystem() {
std::scoped_lock l{parent_mutex};
return audio_system.Stop();
2022-07-16 23:48:45 +01:00
}
Result In::AppendBuffer(const AudioInBuffer& buffer, 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 In::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 In::FlushAudioInBuffers() {
std::scoped_lock l{parent_mutex};
return audio_system.FlushAudioInBuffers();
2022-07-16 23:48:45 +01:00
}
u32 In::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& In::GetBufferEvent() {
std::scoped_lock l{parent_mutex};
return event->GetReadableEvent();
}
2022-09-16 09:40:41 -04:00
f32 In::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 In::SetVolume(f32 volume) {
std::scoped_lock l{parent_mutex};
audio_system.SetVolume(volume);
2022-07-16 23:48:45 +01:00
}
2022-09-16 09:40:41 -04:00
bool In::ContainsAudioBuffer(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:40:41 -04:00
u32 In::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:40:41 -04:00
u64 In::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::AudioIn