Fixed cd audio would wait forever after closing emulator

This commit is contained in:
Dimitris Panokostas 2020-08-24 21:26:28 +02:00
parent 385ecc296e
commit db8eae83bf
2 changed files with 23 additions and 17 deletions

View file

@ -21,19 +21,18 @@ cda_audio::~cda_audio()
wait(0);
wait(1);
if (cdda_dev != 0)
if (cdda_dev > 0)
{
SDL_PauseAudioDevice(cdda_dev, 1);
SDL_LockAudioDevice(cdda_dev);
}
for (auto& i : pull_buffer_len)
i = 0;
if (pull_mode)
{
for (auto& i : pull_buffer_len)
i = 0;
}
if (cdda_dev != 0)
{
SDL_UnlockAudioDevice(cdda_dev);
SDL_CloseAudioDevice(cdda_dev);
}
for (auto& buffer : buffers)
@ -76,13 +75,16 @@ cda_audio::cda_audio(int num_sectors, int sectorsize, int samplerate, bool inter
}
else
{
for (auto i = 0; i < 2; i++)
if (pull_mode)
{
pull_buffer[i] = buffers[i];
pull_buffer_len[i] = bufsize;
for (auto i = 0; i < 2; i++)
{
pull_buffer[i] = buffers[i];
pull_buffer_len[i] = bufsize;
}
}
SDL_PauseAudioDevice(cdda_dev, 0);
SDL_PauseAudioDevice(cdda_dev, 0);
active = true;
playing = true;
}

View file

@ -213,7 +213,7 @@ static void pause_audio_sdl2(struct sound_data* sd)
{
sd->waiting_for_buffer = 0;
SDL_PauseAudioDevice(dev, 1);
if (cdda_dev != 0)
if (cdda_dev > 0)
SDL_PauseAudioDevice(cdda_dev, 1);
clearbuffer(sd);
}
@ -227,7 +227,7 @@ static void resume_audio_sdl2(struct sound_data* sd)
s->avg_correct = 0;
s->cnt_correct = 0;
SDL_PauseAudioDevice(dev, 0);
if (cdda_dev != 0)
if (cdda_dev > 0)
SDL_PauseAudioDevice(cdda_dev, 0);
}
@ -235,15 +235,19 @@ static void close_audio_sdl2(struct sound_data* sd)
{
auto* s = sd->data;
SDL_PauseAudioDevice(dev, 1);
SDL_LockAudioDevice(dev);
xfree(s->pullbuffer);
s->pullbuffer = NULL;
s->pullbufferlen = 0;
SDL_UnlockAudioDevice(dev);
SDL_CloseAudioDevice(dev);
if (cdda_dev != 0)
if (cdda_dev > 0)
{
SDL_PauseAudioDevice(cdda_dev, 1);
SDL_CloseAudioDevice(cdda_dev);
}
xfree(s->pullbuffer);
s->pullbuffer = NULL;
s->pullbufferlen = 0;
}
void set_volume_sound_device(struct sound_data* sd, int volume, int mute)