SDL: Allow vbam to run on systems without an audio device. Thanks to jcranmer for the patch.
This commit is contained in:
parent
2009faab00
commit
3c6e0514a9
|
@ -2,7 +2,7 @@ Source: vbam
|
|||
Section: otherosfs
|
||||
Priority: optional
|
||||
Maintainer: Fernando Tarlá Cardoso Lemos <fernandotcl@gmail.com>
|
||||
Build-Depends: debhelper (>= 7), cmake, nasm [i386 amd64], libsdl1.2-dev, libgl-dev, libgtkmm-2.4-dev, libgtkglextmm-x11-1.2-dev, libglademm-2.4-dev, libsfml-dev
|
||||
Build-Depends: debhelper (>= 7), cmake, nasm [i386 amd64], libsdl1.2-dev, libgl-dev, libgtkmm-2.4-dev, libgtkglextmm-x11-1.2-dev, libsfml-dev
|
||||
Standards-Version: 3.8.1
|
||||
Homepage: http://www.vbam.com
|
||||
|
||||
|
|
|
@ -24,7 +24,8 @@ extern bool speedup;
|
|||
const float SoundSDL::_delay = 0.1f;
|
||||
|
||||
SoundSDL::SoundSDL():
|
||||
_rbuf(0)
|
||||
_rbuf(0),
|
||||
_initialized(false)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -36,7 +37,7 @@ void SoundSDL::soundCallback(void *data, u8 *stream, int len)
|
|||
|
||||
void SoundSDL::read(u16 * stream, int length)
|
||||
{
|
||||
if (length <= 0 || !emulating)
|
||||
if (!_initialized || length <= 0 || !emulating)
|
||||
return;
|
||||
|
||||
SDL_mutexP(_mutex);
|
||||
|
@ -49,6 +50,9 @@ void SoundSDL::read(u16 * stream, int length)
|
|||
|
||||
void SoundSDL::write(u16 * finalWave, int length)
|
||||
{
|
||||
if (!_initialized)
|
||||
return;
|
||||
|
||||
if (SDL_GetAudioStatus() != SDL_AUDIO_PLAYING)
|
||||
SDL_PauseAudio(0);
|
||||
|
||||
|
@ -104,12 +108,16 @@ bool SoundSDL::init(long sampleRate)
|
|||
|
||||
_cond = SDL_CreateCond();
|
||||
_mutex = SDL_CreateMutex();
|
||||
_initialized = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
SoundSDL::~SoundSDL()
|
||||
{
|
||||
if (!_initialized)
|
||||
return;
|
||||
|
||||
SDL_mutexP(_mutex);
|
||||
int iSave = emulating;
|
||||
emulating = 0;
|
||||
|
@ -129,11 +137,17 @@ SoundSDL::~SoundSDL()
|
|||
|
||||
void SoundSDL::pause()
|
||||
{
|
||||
if (!_initialized)
|
||||
return;
|
||||
|
||||
SDL_PauseAudio(1);
|
||||
}
|
||||
|
||||
void SoundSDL::resume()
|
||||
{
|
||||
if (!_initialized)
|
||||
return;
|
||||
|
||||
SDL_PauseAudio(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,8 @@ private:
|
|||
SDL_cond * _cond;
|
||||
SDL_mutex * _mutex;
|
||||
|
||||
bool _initialized;
|
||||
|
||||
// Defines what delay in seconds we keep in the sound buffer
|
||||
static const float _delay;
|
||||
|
||||
|
|
Loading…
Reference in New Issue