refactor(simu): use SDL & ImGui (#6233)
Co-authored-by: raphaelcoeffic <1050031+raphaelcoeffic@users.noreply.github.com> Co-authored-by: Malte Langermann <malte@langermann.net>
This commit is contained in:
co-authored by
raphaelcoeffic
Malte Langermann
parent
14287cb91d
commit
4eddda034d
+24
-12
@@ -370,6 +370,17 @@ AudioQueue::AudioQueue()
|
||||
|
||||
#define CODEC_ID_PCM_S16LE 1
|
||||
|
||||
|
||||
static void _audio_lock()
|
||||
{
|
||||
mutex_lock(&audioMutex);
|
||||
}
|
||||
|
||||
static void _audio_unlock()
|
||||
{
|
||||
mutex_unlock(&audioMutex);
|
||||
}
|
||||
|
||||
#if !defined(__SSAT)
|
||||
#define _sat_s16(x) ((int16_t)limit<int32_t>(INT16_MIN, (x), INT16_MAX))
|
||||
#else
|
||||
@@ -613,9 +624,9 @@ void AudioQueue::wakeup()
|
||||
|
||||
// mix the normal context (tones and wavs)
|
||||
if (normalContext.isEmpty() && !fragmentsFifo.empty()) {
|
||||
mutex_lock(&audioMutex);
|
||||
_audio_lock();
|
||||
normalContext.setFragment(fragmentsFifo.get());
|
||||
mutex_unlock(&audioMutex);
|
||||
_audio_unlock();
|
||||
}
|
||||
result = normalContext.mixBuffer(buffer, g_eeGeneral.beepVolume, g_eeGeneral.wavVolume, fade);
|
||||
if (result > 0) {
|
||||
@@ -696,10 +707,11 @@ bool AudioQueue::isPlaying(uint8_t id)
|
||||
void AudioQueue::playTone(uint16_t freq, uint16_t len, uint16_t pause, uint8_t flags, int8_t freqIncr, int8_t fragmentVolume)
|
||||
{
|
||||
#if defined(SIMU) && !defined(SIMU_AUDIO)
|
||||
#warning "NO audio"
|
||||
return;
|
||||
#endif
|
||||
|
||||
mutex_lock(&audioMutex);
|
||||
_audio_lock();
|
||||
|
||||
freq = limit<uint16_t>(BEEP_MIN_FREQ, freq, BEEP_MAX_FREQ);
|
||||
|
||||
@@ -722,7 +734,7 @@ void AudioQueue::playTone(uint16_t freq, uint16_t len, uint16_t pause, uint8_t f
|
||||
}
|
||||
}
|
||||
|
||||
mutex_unlock(&audioMutex);
|
||||
_audio_unlock();
|
||||
}
|
||||
|
||||
void AudioQueue::playFile(const char * filename, uint8_t flags, uint8_t id, int8_t fragmentVolume)
|
||||
@@ -745,7 +757,7 @@ void AudioQueue::playFile(const char * filename, uint8_t flags, uint8_t id, int8
|
||||
return;
|
||||
}
|
||||
|
||||
mutex_lock(&audioMutex);
|
||||
_audio_lock();
|
||||
|
||||
if (flags & PLAY_BACKGROUND) {
|
||||
backgroundContext.clear();
|
||||
@@ -755,7 +767,7 @@ void AudioQueue::playFile(const char * filename, uint8_t flags, uint8_t id, int8
|
||||
fragmentsFifo.push(AudioFragment(filename, flags & 0x0f, fragmentVolume, id));
|
||||
}
|
||||
|
||||
mutex_unlock(&audioMutex);
|
||||
_audio_unlock();
|
||||
}
|
||||
|
||||
void AudioQueue::stopPlay(uint8_t id)
|
||||
@@ -768,12 +780,12 @@ void AudioQueue::stopPlay(uint8_t id)
|
||||
return;
|
||||
#endif
|
||||
|
||||
mutex_lock(&audioMutex);
|
||||
_audio_lock();
|
||||
|
||||
fragmentsFifo.removePromptById(id);
|
||||
backgroundContext.stop(id);
|
||||
|
||||
mutex_unlock(&audioMutex);
|
||||
_audio_unlock();
|
||||
}
|
||||
|
||||
void AudioQueue::stopSD()
|
||||
@@ -786,19 +798,19 @@ void AudioQueue::stopSD()
|
||||
void AudioQueue::stopAll()
|
||||
{
|
||||
flush();
|
||||
mutex_lock(&audioMutex);
|
||||
_audio_lock();
|
||||
priorityContext.clear();
|
||||
normalContext.clear();
|
||||
mutex_unlock(&audioMutex);
|
||||
_audio_unlock();
|
||||
}
|
||||
|
||||
void AudioQueue::flush()
|
||||
{
|
||||
mutex_lock(&audioMutex);
|
||||
_audio_lock();
|
||||
fragmentsFifo.clear();
|
||||
varioContext.clear();
|
||||
backgroundContext.clear();
|
||||
mutex_unlock(&audioMutex);
|
||||
_audio_unlock();
|
||||
}
|
||||
|
||||
void audioPlay(unsigned int index, uint8_t id)
|
||||
|
||||
Reference in New Issue
Block a user