static int l_audio_SourceCommon_setVolume(lua_State *state) { l_assertType(state, 1, isSource); float gain = l_tools_toNumberOrError(state, 2); audio_SourceCommon *source = (audio_SourceCommon*)lua_touserdata(state, 1); audio_SourceCommon_setVolume(source, gain); return 0; }
static int l_audio_SourceCommon_setVolume(lua_State *state) { float gain = l_tools_toNumberOrError(state, 2); if (moduleData.audio_type == audio_type_stream){ audio_StreamSource* source = (audio_StreamSource *)lua_touserdata(state, 1); audio_StreamSource_setVolume(source, gain); } else { audio_SourceCommon* source = (audio_SourceCommon*)lua_touserdata(state, 1); audio_SourceCommon_setVolume(source, gain); } return 1; }
Obj* c_audio_setVolume(void* root, Obj** env, Obj** list) { if (length(*list) != 2) error("Expected <custom> and an int."); Obj* arg = eval(root, env, &(*list)->car); float gain = creo_tointeger(root, env, list, 1); if (moduleData.audio_type == audio_type_static) { audio_SourceCommon* source = (audio_SourceCommon*)arg->custom; audio_SourceCommon_setVolume(source, gain); return True; } audio_StreamSource* source = (audio_StreamSource*)arg->custom; audio_StreamSource_setVolume(source, gain); return True; }