Revert "fix(audio): add seamless playback for repeating audio (#597)"

This reverts commit ba602a0a4d80be3b46264fa292ade1d08c0861d8.
This commit is contained in:
D3SOX 2022-05-27 18:44:17 +02:00
parent e699020cf2
commit 90b23d53d3
No known key found for this signature in database
GPG Key ID: 39EC1673FC37B048

View File

@ -327,11 +327,6 @@ namespace Soundux::Objects
ma_uint64 readFrames{}; ma_uint64 readFrames{};
ma_decoder_read_pcm_frames(sound->raw.decoder, output, frameCount, &readFrames); ma_decoder_read_pcm_frames(sound->raw.decoder, output, frameCount, &readFrames);
if (sound->repeat && !sound->shouldSeek && readFrames == 0)
{
ma_decoder_seek_to_pcm_frame(sound->raw.decoder, 0);
ma_decoder_read_pcm_frames(sound->raw.decoder, output, frameCount, &readFrames);
}
if (sound->shouldSeek) if (sound->shouldSeek)
{ {
@ -343,27 +338,18 @@ namespace Soundux::Objects
Globals::gAudio.onSoundProgressed(sound, readFrames); Globals::gAudio.onSoundProgressed(sound, readFrames);
} }
if (sound->repeat && !sound->shouldSeek && readFrames < frameCount) if (readFrames <= 0)
{ {
while (frameCount > 0 && readFrames > 0) if (sound->repeat)
{ {
frameCount -= readFrames;
ma_decoder_seek_to_pcm_frame(sound->raw.decoder, 0); ma_decoder_seek_to_pcm_frame(sound->raw.decoder, 0);
output = reinterpret_cast<void *>( Globals::gAudio.onSoundSeeked(sound, 0);
reinterpret_cast<ma_uint8 *>(output) + }
readFrames * ma_get_bytes_per_frame(sound->raw.decoder.load()->outputFormat, else
sound->raw.decoder.load()->outputChannels)); {
ma_decoder_read_pcm_frames(sound->raw.decoder, output, frameCount, &readFrames); Globals::gQueue.push_unique(reinterpret_cast<std::uintptr_t>(device),
if (readFrames == frameCount) [sound = *sound] { Globals::gAudio.onFinished(sound); });
break;
} }
Globals::gAudio.onSoundSeeked(sound, readFrames);
}
else if (readFrames <= 0)
{
Globals::gQueue.push_unique(reinterpret_cast<std::uintptr_t>(device),
[sound = *sound] { Globals::gAudio.onFinished(sound); });
} }
} }
std::vector<AudioDevice> Audio::getAudioDevices() std::vector<AudioDevice> Audio::getAudioDevices()
@ -504,4 +490,4 @@ namespace Soundux::Objects
return *this; return *this;
} }
} // namespace Soundux::Objects } // namespace Soundux::Objects