diff options
| author | William Wilgus <me.theuser@yahoo.com> | 2019-07-25 10:17:40 -0500 |
|---|---|---|
| committer | William Wilgus <me.theuser@yahoo.com> | 2019-07-25 10:17:40 -0500 |
| commit | 6e32e06498782f98db57bbb05baa6fc4ba3d76be (patch) | |
| tree | dd7d93ab39212df2d4232abb3c78b7d145953764 /apps/plugins/lua/rocklib.c | |
| parent | 3834094172480a0c64c91a20544c0a6f81c646c2 (diff) | |
| download | rockbox-6e32e06498782f98db57bbb05baa6fc4ba3d76be.zip rockbox-6e32e06498782f98db57bbb05baa6fc4ba3d76be.tar.gz rockbox-6e32e06498782f98db57bbb05baa6fc4ba3d76be.tar.bz2 rockbox-6e32e06498782f98db57bbb05baa6fc4ba3d76be.tar.xz | |
lua add sound_current, consolidate sound_ functions
add defines for sound functions
SOUND_VOLUME, SOUND_BALANCE, SOUND_CHANNELS, SOUND_STEREO_WIDTH ...
defines depend on target
require "sound_defines" to add them to rb.sound_settings[]
consolidates:
sound_set, sound_current, sound_default, sound_min, sound_max,
sound_unit, sound_pitch, sound_val2phys to a single function
rb.sound("name", setting, [value])
require "sound.lua" for old functionality
Change-Id: Ice695218aa433f4fcbb48fbd6b8a9bf29c994110
Diffstat (limited to 'apps/plugins/lua/rocklib.c')
| -rw-r--r-- | apps/plugins/lua/rocklib.c | 62 |
1 files changed, 61 insertions, 1 deletions
diff --git a/apps/plugins/lua/rocklib.c b/apps/plugins/lua/rocklib.c index 9518fe9..b37f524 100644 --- a/apps/plugins/lua/rocklib.c +++ b/apps/plugins/lua/rocklib.c @@ -378,6 +378,65 @@ RB_WRAP(audio) return 1; } +RB_WRAP(sound) +{ + enum e_snd {SOUND_SET = 0, SOUND_CURRENT, SOUND_DEFAULT, + SOUND_MIN, SOUND_MAX, SOUND_UNIT, SOUND_SET_PITCH, + SOUND_VAL2PHYS, SOUND_ECOUNT}; + + const char *snd_option[] = {"set", "current", "default", + "min", "max", "unit", "pitch", + "val2phys", NULL}; + + lua_pushnil(L); /*push nil so options w/o return have something to return */ + + int option = luaL_checkoption (L, 1, NULL, snd_option); + int setting = luaL_checkint(L, 2); + int value, result; + switch(option) + { + case SOUND_SET: + value = luaL_checkint(L, 3); + rb->sound_set(setting, value); + return 1; /*nil*/ + break; + case SOUND_CURRENT: + result = rb->sound_current(setting); + break; + case SOUND_DEFAULT: + result = rb->sound_default(setting); + break; + case SOUND_MIN: + result = rb->sound_min(setting); + break; + case SOUND_MAX: + result = rb->sound_max(setting); + break; + case SOUND_UNIT: + lua_pushstring (L, rb->sound_unit(setting)); + return 1; + break; +#if ((CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) || \ + (CONFIG_CODEC == SWCODEC)) && defined (HAVE_PITCHCONTROL) + case SOUND_SET_PITCH: + rb->sound_set_pitch(setting); + return 1;/*nil*/ + break; +#endif + case SOUND_VAL2PHYS: + value = luaL_checkint(L, 3); + result = rb->sound_val2phys(setting, value); + break; + + default: + return 1; + break; + } + + lua_pushinteger(L, result); + return 1; +} + #if CONFIG_CODEC == SWCODEC RB_WRAP(pcm) { @@ -723,9 +782,10 @@ static const luaL_Reg rocklib[] = RB_FUNC(gui_syncyesno_run), RB_FUNC(do_menu), - /* DEVICE AUDIO / PLAYLIST CONTROL */ + /* DEVICE AUDIO / SOUND / PLAYLIST CONTROL */ RB_FUNC(audio), RB_FUNC(playlist), + RB_FUNC(sound), #if CONFIG_CODEC == SWCODEC RB_FUNC(pcm), RB_FUNC(mixer_frequency), |