Add key to manually restart audio

This commit is contained in:
Lorenzooone
2024-05-11 05:21:17 +02:00
parent b48ec6cf17
commit 8c526e3747
5 changed files with 27 additions and 1 deletions

View File

@@ -16,6 +16,8 @@ Sample::Sample(sf::Int16 *bytes, std::size_t size, float time) : bytes(bytes), s
Audio::Audio(AudioData *audio_data) {
this->audio_data = audio_data;
// Consume old events
this->audio_data->check_audio_restart_request();
sf::SoundStream::initialize(AUDIO_CHANNELS, SAMPLE_RATE);
#if (SFML_VERSION_MAJOR > 2) || ((SFML_VERSION_MAJOR == 2) && (SFML_VERSION_MINOR >= 6))
// Since we receive data every 16.6 ms, this is useless,
@@ -60,6 +62,8 @@ bool Audio::onGetData(sf::SoundStream::Chunk &data) {
num_consecutive_fast_seek = 0;
if(num_consecutive_fast_seek > AUDIO_FAILURE_THRESHOLD)
restart = true;
if(this->audio_data->check_audio_restart_request())
restart = true;
if(restart) {
terminate = true;