Correct audren event handling and zero the sample buffer

Not zeroing the sample buffer causes issues when a voice is started but
is playing no samples. The system event handling was also reworked
according to Thog's info.
This commit is contained in:
Billy Laws 2020-07-05 13:51:15 +01:00 committed by ◱ PixelyIon
parent 24d086cbec
commit 6329537a9e
2 changed files with 7 additions and 6 deletions

View File

@ -6,7 +6,7 @@
namespace skyline::service::audio::IAudioRenderer {
IAudioRenderer::IAudioRenderer(const DeviceState &state, ServiceManager &manager, AudioRendererParameters &parameters)
: releaseEvent(std::make_shared<type::KEvent>(state)), parameters(parameters), BaseService(state, manager, Service::audio_IAudioRenderer, "audio:IAudioRenderer", {
: systemEvent(std::make_shared<type::KEvent>(state)), parameters(parameters), BaseService(state, manager, Service::audio_IAudioRenderer, "audio:IAudioRenderer", {
{0x0, SFUNC(IAudioRenderer::GetSampleRate)},
{0x1, SFUNC(IAudioRenderer::GetSampleCount)},
{0x2, SFUNC(IAudioRenderer::GetMixBufferCount)},
@ -16,7 +16,7 @@ namespace skyline::service::audio::IAudioRenderer {
{0x6, SFUNC(IAudioRenderer::Stop)},
{0x7, SFUNC(IAudioRenderer::QuerySystemEvent)},
}) {
track = state.audio->OpenTrack(constant::ChannelCount, parameters.sampleRate, [this]() { releaseEvent->Signal(); });
track = state.audio->OpenTrack(constant::ChannelCount, parameters.sampleRate, []() {});
track->Start();
memoryPools.resize(parameters.effectCount + parameters.voiceCount * 4);
@ -80,6 +80,7 @@ namespace skyline::service::audio::IAudioRenderer {
effects[i].ProcessInput(effectsIn[i]);
UpdateAudio();
systemEvent->Signal();
UpdateDataHeader outputHeader{
.revision = constant::RevMagic,
@ -178,8 +179,8 @@ namespace skyline::service::audio::IAudioRenderer {
}
void IAudioRenderer::QuerySystemEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
auto handle = state.process->InsertItem(releaseEvent);
state.logger->Debug("Audren Buffer Release Event Handle: 0x{:X}", handle);
auto handle = state.process->InsertItem(systemEvent);
state.logger->Debug("Audren System Event Handle: 0x{:X}", handle);
response.copyHandles.push_back(handle);
}
}

View File

@ -66,11 +66,11 @@ namespace skyline {
AudioRendererParameters parameters; //!< The parameters to use for the renderer
RevisionInfo revisionInfo{}; //!< Stores info about supported features for the audren revision used
std::shared_ptr<skyline::audio::AudioTrack> track; //!< The audio track associated with the audio renderer
std::shared_ptr<type::KEvent> releaseEvent; //!< The KEvent that is signalled when a buffer has been released
std::shared_ptr<type::KEvent> systemEvent; //!< The KEvent that is signalled when the DSP has processed all the commands
std::vector<MemoryPool> memoryPools; //!< An vector of all memory pools that the guest may need
std::vector<Effect> effects; //!< An vector of all effects that the guest may need
std::vector<Voice> voices; //!< An vector of all voices that the guest may need
std::array<i16, constant::MixBufferSize * constant::ChannelCount> sampleBuffer; //!< The final output data that is appended to the stream
std::array<i16, constant::MixBufferSize * constant::ChannelCount> sampleBuffer{}; //!< The final output data that is appended to the stream
skyline::audio::AudioOutState playbackState{skyline::audio::AudioOutState::Stopped}; //!< The current state of playback
/**