Create Sources from AudioStreams;
@@ -62,12 +62,19 @@ int l_lovrAudioIsSpatialized(lua_State* L) {
}
int l_lovrAudioNewSource(lua_State* L) {
+ void** type;
+ AudioStream* stream;
+ if ((type = luax_totype(L, 1, AudioStream)) != NULL) {
+ stream = *type;
+ } else {
Blob* blob = luax_readblob(L, 1, "Source");
- AudioStream* stream = lovrAudioStreamCreate(blob, 4096);
+ stream = lovrAudioStreamCreate(blob, 4096);
+ lovrRelease(&blob->ref);
+ }
+
Source* source = lovrSourceCreate(stream);
luax_pushtype(L, Source, source);
lovrRelease(&source->ref);
- lovrRelease(&blob->ref);
return 1;
}
