Browse Source

SDL 2.0.3 SVid: Use non-device Audio API

Fixes audio in movies on RG350!

From SDL docs: The legacy calls are good both for backwards compatibility and when you don't care about multiple, specific, or capture devices.
pull/422/head
Gleb Mazovetskiy 7 years ago committed by Anders Jenbo
parent
commit
f0eab35672
  1. 42
      SourceX/storm/storm.cpp

42
SourceX/storm/storm.cpp

@ -414,17 +414,16 @@ SDL_Surface *SVidSurface;
BYTE *SVidBuffer;
unsigned long SVidWidth, SVidHeight;
#ifdef USE_SDL1
#if SDL_VERSION_ATLEAST(2, 0, 4)
SDL_AudioDeviceID deviceId;
static bool HaveAudio()
{
return SDL_GetAudioStatus() != SDL_AUDIO_STOPPED;
return deviceId != 0;
}
#else
SDL_AudioDeviceID deviceId;
static bool HaveAudio()
{
return deviceId != 0;
return SDL_GetAudioStatus() != SDL_AUDIO_STOPPED;
}
#endif
@ -459,14 +458,14 @@ public:
void Enqueue(const unsigned char *data, unsigned long len)
{
#ifdef USE_SDL1
SDL_LockAudio();
EnqueueUnsafe(data, len);
SDL_UnlockAudio();
#else
#if SDL_VERSION_ATLEAST(2, 0, 4)
SDL_LockAudioDevice(deviceId);
EnqueueUnsafe(data, len);
SDL_UnlockAudioDevice(deviceId);
#else
SDL_LockAudio();
EnqueueUnsafe(data, len);
SDL_UnlockAudio();
#endif
}
@ -566,22 +565,19 @@ void SVidPlayBegin(char *filename, int a2, int a3, int a4, int a5, int flags, HA
Mix_CloseAudio();
#if !SDL_VERSION_ATLEAST(2, 0, 4)
sVidAudioQueue->Subscribe(&audioFormat);
#endif
#ifdef USE_SDL1
if (SDL_OpenAudio(&audioFormat, NULL) != 0) {
ErrSdl();
}
SDL_PauseAudio(0);
#else
#if SDL_VERSION_ATLEAST(2, 0, 4)
deviceId = SDL_OpenAudioDevice(NULL, 0, &audioFormat, NULL, 0);
if (deviceId == 0) {
ErrSdl();
}
SDL_PauseAudioDevice(deviceId, 0); /* start audio playing. */
#else
sVidAudioQueue->Subscribe(&audioFormat);
if (SDL_OpenAudio(&audioFormat, NULL) != 0) {
ErrSdl();
}
SDL_PauseAudio(0);
#endif
}
@ -750,11 +746,7 @@ void SVidPlayEnd(HANDLE video)
SDL_ClearQueuedAudio(deviceId);
SDL_CloseAudioDevice(deviceId);
deviceId = 0;
#elif SDL_VERSION_ATLEAST(2, 0, 0)
SDL_CloseAudioDevice(deviceId);
deviceId = 0;
sVidAudioQueue->Clear();
#else // USE_SDL1
#else
SDL_CloseAudio();
sVidAudioQueue->Clear();
#endif

Loading…
Cancel
Save