[client] audio: fix microphone restart bookkeeping

This commit is contained in:
Geoffrey McRae
2026-07-28 13:17:02 +10:00
parent a5571f0e9e
commit d384591e05

View File

@@ -148,6 +148,7 @@ typedef struct
PlaybackDeviceTick; PlaybackDeviceTick;
static void playbackStop(void); static void playbackStop(void);
static void realRecordStop(void);
void audio_init(void) void audio_init(void)
{ {
@@ -800,15 +801,15 @@ void audio_recordStart(int channels, int sampleRate, PSAudioFormat format)
if (!audio.audioDev) if (!audio.audioDev)
return; return;
static int lastChannels = 0; const bool restart = audio.record.started;
static int lastSampleRate = 0;
if (audio.record.started) if (audio.record.started)
{ {
if (channels != lastChannels || sampleRate != lastSampleRate) if (channels == audio.record.lastChannels &&
audio.audioDev->record.stop(); sampleRate == audio.record.lastSampleRate &&
else format == audio.record.lastFormat)
return; return;
realRecordStop();
} }
audio.record.requested = true; audio.record.requested = true;
@@ -816,7 +817,7 @@ void audio_recordStart(int channels, int sampleRate, PSAudioFormat format)
audio.record.lastSampleRate = sampleRate; audio.record.lastSampleRate = sampleRate;
audio.record.lastFormat = format; audio.record.lastFormat = format;
if (audio.record.started) if (restart)
realRecordStart(channels, sampleRate, format); realRecordStart(channels, sampleRate, format);
else if (g_state.micDefaultState == MIC_DEFAULT_DENY) else if (g_state.micDefaultState == MIC_DEFAULT_DENY)
DEBUG_INFO("Microphone access denied by default"); DEBUG_INFO("Microphone access denied by default");