mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-22 05:27:20 +00:00
[client] audio: fix use after free race
This commit is contained in:
parent
7f4dcd1ced
commit
b3c81bcedf
@ -75,6 +75,8 @@ AudioState;
|
|||||||
|
|
||||||
static AudioState audio = { 0 };
|
static AudioState audio = { 0 };
|
||||||
|
|
||||||
|
static void playbackStopNL(void);
|
||||||
|
|
||||||
void audio_init(void)
|
void audio_init(void)
|
||||||
{
|
{
|
||||||
// search for the best audiodev to use
|
// search for the best audiodev to use
|
||||||
@ -95,7 +97,11 @@ void audio_free(void)
|
|||||||
if (!audio.audioDev)
|
if (!audio.audioDev)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
audio_playbackStop();
|
// immediate stop of the stream, do not wait for drain
|
||||||
|
LG_LOCK(audio.playback.lock);
|
||||||
|
playbackStopNL();
|
||||||
|
LG_UNLOCK(audio.playback.lock);
|
||||||
|
|
||||||
audio_recordStop();
|
audio_recordStop();
|
||||||
|
|
||||||
audio.audioDev->free();
|
audio.audioDev->free();
|
||||||
@ -118,8 +124,11 @@ static const char * audioGraphFormatFn(const char * name,
|
|||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
void playbackStopNL(void)
|
static void playbackStopNL(void)
|
||||||
{
|
{
|
||||||
|
if (audio.playback.state == STREAM_STATE_STOP)
|
||||||
|
return;
|
||||||
|
|
||||||
audio.playback.state = STREAM_STATE_STOP;
|
audio.playback.state = STREAM_STATE_STOP;
|
||||||
audio.audioDev->playback.stop();
|
audio.audioDev->playback.stop();
|
||||||
ringbuffer_free(&audio.playback.buffer);
|
ringbuffer_free(&audio.playback.buffer);
|
||||||
@ -364,7 +373,6 @@ void audio_tick(unsigned long long tickCount)
|
|||||||
if (audio.audioDev->playback.latency)
|
if (audio.audioDev->playback.latency)
|
||||||
frames += audio.audioDev->playback.latency();
|
frames += audio.audioDev->playback.latency();
|
||||||
|
|
||||||
|
|
||||||
const float latency = frames / (float)(audio.playback.sampleRate / 1000);
|
const float latency = frames / (float)(audio.playback.sampleRate / 1000);
|
||||||
|
|
||||||
ringbuffer_push(audio.playback.timings, &latency);
|
ringbuffer_push(audio.playback.timings, &latency);
|
||||||
|
Loading…
Reference in New Issue
Block a user