From 5f2197158dbe2179a36fef75c8633eff5aa6ea11 Mon Sep 17 00:00:00 2001 From: Bill Meltsner Date: Sun, 11 Apr 2010 16:43:18 -0400 Subject: [PATCH] We now return nil instead of a null SoundData when getting recorded data fails. --- src/modules/audio/openal/Audio.cpp | 2 +- src/modules/audio/wrap_Audio.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/modules/audio/openal/Audio.cpp b/src/modules/audio/openal/Audio.cpp index 44a06b07d..a1353cb28 100644 --- a/src/modules/audio/openal/Audio.cpp +++ b/src/modules/audio/openal/Audio.cpp @@ -71,7 +71,7 @@ namespace openal alcMakeContextCurrent(0); alcDestroyContext(context); - alcCaptureCloseDevice(capture); + if (capture) alcCaptureCloseDevice(capture); alcCloseDevice(device); } diff --git a/src/modules/audio/wrap_Audio.cpp b/src/modules/audio/wrap_Audio.cpp index b382576e2..82fc70d46 100644 --- a/src/modules/audio/wrap_Audio.cpp +++ b/src/modules/audio/wrap_Audio.cpp @@ -212,7 +212,8 @@ namespace audio int w_getRecordedData(lua_State * L) { love::sound::SoundData * sd = instance->getRecordedData(); - luax_newtype(L, "SoundData", SOUND_SOUND_DATA_T, (void*)sd); + if (!sd) lua_pushnil(L); + else luax_newtype(L, "SoundData", SOUND_SOUND_DATA_T, (void*)sd); return 1; } @@ -220,7 +221,8 @@ namespace audio { if (luax_optboolean(L, 1, true)) { love::sound::SoundData * sd = instance->stopRecording(true); - luax_newtype(L, "SoundData", SOUND_SOUND_DATA_T, (void*)sd); + if (!sd) lua_pushnil(L); + else luax_newtype(L, "SoundData", SOUND_SOUND_DATA_T, (void*)sd); return 1; } instance->stopRecording(false);