diff --git a/src/modules/audio/Audio.h b/src/modules/audio/Audio.h index 92a2a4048..364f03191 100644 --- a/src/modules/audio/Audio.h +++ b/src/modules/audio/Audio.h @@ -59,7 +59,8 @@ namespace audio * Creates a new Source. * @returns A new Source. **/ - virtual Source * newSource(Audible * audible) = 0; + virtual Source * newSource(Sound * sound) = 0; + virtual Source * newSource(Music * music) = 0; /** * Gets the current number of simulatenous playing sources. diff --git a/src/modules/audio/null/Audio.cpp b/src/modules/audio/null/Audio.cpp index a63a65db6..57ccbf29d 100644 --- a/src/modules/audio/null/Audio.cpp +++ b/src/modules/audio/null/Audio.cpp @@ -49,7 +49,12 @@ namespace null return new Music(decoder); } - love::audio::Source * Audio::newSource(Audible * audible) + love::audio::Source * Audio::newSource(love::audio::Sound * sound) + { + return new Source(); + } + + love::audio::Source * Audio::newSource(love::audio::Music * music) { return new Source(); } diff --git a/src/modules/audio/null/Audio.h b/src/modules/audio/null/Audio.h index 45303a18a..ff6bddd5f 100644 --- a/src/modules/audio/null/Audio.h +++ b/src/modules/audio/null/Audio.h @@ -49,7 +49,8 @@ namespace null // Implements Audio. love::audio::Sound * newSound(love::sound::SoundData * data); love::audio::Music * newMusic(love::sound::Decoder * decoder); - love::audio::Source * newSource(Audible * audible); + love::audio::Source * newSource(love::audio::Sound * sound); + love::audio::Source * newSource(love::audio::Music * music); int getNumSources() const; int getMaxSources() const; void play(love::audio::Source * source); diff --git a/src/modules/audio/openal/Audio.cpp b/src/modules/audio/openal/Audio.cpp index 06a545df0..5493137c7 100644 --- a/src/modules/audio/openal/Audio.cpp +++ b/src/modules/audio/openal/Audio.cpp @@ -92,9 +92,14 @@ namespace openal return new Music(pool, decoder); } - love::audio::Source * Audio::newSource(Audible * audible) + love::audio::Source * Audio::newSource(love::audio::Sound * sound) { - return new Source(pool, audible); + return new Source(pool, sound); + } + + love::audio::Source * Audio::newSource(love::audio::Music * music) + { + return new Source(pool, music->clone()); } int Audio::getNumSources() const diff --git a/src/modules/audio/openal/Audio.h b/src/modules/audio/openal/Audio.h index ba22b4216..45fcf8f87 100644 --- a/src/modules/audio/openal/Audio.h +++ b/src/modules/audio/openal/Audio.h @@ -88,7 +88,8 @@ namespace openal // Implements Audio. love::audio::Sound * newSound(love::sound::SoundData * data); love::audio::Music * newMusic(love::sound::Decoder * decoder); - love::audio::Source * newSource(Audible * audible); + love::audio::Source * newSource(love::audio::Sound * sound); + love::audio::Source * newSource(love::audio::Music * music); int getNumSources() const; int getMaxSources() const; void play(love::audio::Source * source); diff --git a/src/modules/audio/wrap_Audio.cpp b/src/modules/audio/wrap_Audio.cpp index 0db875b59..40b40c010 100644 --- a/src/modules/audio/wrap_Audio.cpp +++ b/src/modules/audio/wrap_Audio.cpp @@ -67,8 +67,22 @@ namespace audio int w_newSource(lua_State * L) { - Audible * a = luax_checktype(L, 1, "Audible", AUDIO_AUDIBLE_T); - Source * t = instance->newSource(a); + Source * t = 0; + + if(luax_istype(L, 1, AUDIO_SOUND_T)) + { + Sound * s = luax_checksound(L, 1); + t = instance->newSource(s); + } + else if(luax_istype(L, 1, AUDIO_MUSIC_T)) + { + Music * m = luax_checkmusic(L, 1); + t = instance->newSource(m); + } + + if(!t) + return luaL_error(L, "No matching overload"); + luax_newtype(L, "Source", AUDIO_SOURCE_T, (void*)t); return 1; }