static int l_audio_SourceCommon_getVolume(lua_State *state) { if (moduleData.audio_type == audio_type_stream){ audio_StreamSource* source = (audio_StreamSource *)lua_touserdata(state, 1); lua_pushnumber(state, audio_StreamSource_getVolume(source)); } else { audio_SourceCommon* source = (audio_SourceCommon*)lua_touserdata(state, 1); lua_pushnumber(state, audio_SourceCommon_getVolume(source)); } return 1; }
Obj* c_audio_getVolume(void* root, Obj** env, Obj** list) { if (length(*list) != 1) error("Expected <custom>."); Obj* arg = eval(root, env, &(*list)->car); DEFINE1(ret); if (moduleData.audio_type == audio_type_static) { audio_SourceCommon* source = (audio_SourceCommon*)arg->custom; float gain = audio_SourceCommon_getVolume(source); *ret = make_int(root, gain); return *ret; } audio_StreamSource* source = (audio_StreamSource*)arg->custom; float gain = audio_StreamSource_getVolume(source); *ret = make_int(root, gain); return *ret; }
static int l_audio_SourceCommon_getVolume(lua_State *state) { l_assertType(state, 1, isSource); audio_SourceCommon *source = (audio_SourceCommon*)lua_touserdata(state, 1); lua_pushnumber(state, audio_SourceCommon_getVolume(source)); return 1; }