diff --git a/chirp.cpp b/chirp.cpp index 1f53040..605a00d 100644 --- a/chirp.cpp +++ b/chirp.cpp @@ -150,4 +150,9 @@ int32_t interpret_next_token(uint8_t* buffer) { ++*token; return 0; }; -} \ No newline at end of file +} + +void chirp_stop() { + audio_state=AUDIO_NONE; + audio_lock=false; +} diff --git a/chirp.h b/chirp.h index 7fedcf9..ac5a320 100644 --- a/chirp.h +++ b/chirp.h @@ -6,3 +6,5 @@ void chirp_init(); void chirp_play(const char* new_song, const bool lock); int32_t interpret_next_token(uint8_t* buffer); + +void chirp_stop(); diff --git a/lua.cpp b/lua.cpp index 976a125..e76d72b 100644 --- a/lua.cpp +++ b/lua.cpp @@ -657,6 +657,11 @@ extern "C" { return 0; } + static int cpp_stopchirp(lua_State *L) { + stopchirp(); + return 0; + } + static int cpp_exit(lua_State *L) { exit(); return 0; @@ -759,6 +764,7 @@ void push_lua_funcs() { lua_pushcfunction(L,cpp_freadb); lua_setglobal(L, "freadb"); lua_pushcfunction(L,cpp_playchirp); lua_setglobal(L, "playchirp"); + lua_pushcfunction(L,cpp_stopchirp); lua_setglobal(L, "stopchirp"); lua_pushcfunction(L,cpp_exit); lua_setglobal(L, "quit"); diff --git a/mini.cpp b/mini.cpp index 4a1bff9..e954d01 100644 --- a/mini.cpp +++ b/mini.cpp @@ -217,6 +217,7 @@ int main(int argc,char*argv[]){ if (mini_eve.type == SDL_QUIT) { should_exit=true; should_quit=true; break; } if (mini_eve.type == SDL_KEYDOWN) { if (mini_eve.key.keysym.scancode == SDL_SCANCODE_ESCAPE) { + chirp_stop(); if (lua_is_playing()) { lua_quit(); quitaudio(); @@ -228,6 +229,7 @@ int main(int argc,char*argv[]){ //lua_call_init(); } } else if (mini_eve.key.keysym.scancode == SDL_SCANCODE_F5) { + chirp_stop(); should_exit=true; //lua_quit(); //reinit(); @@ -987,6 +989,10 @@ void playchirp(const char *song, const bool lock) { chirp_play(song, lock); } +void stopchirp() { + chirp_stop(); +} + void exit() { should_exit = true; } diff --git a/mini.h b/mini.h index dfc0f00..94e7179 100644 --- a/mini.h +++ b/mini.h @@ -258,5 +258,6 @@ const char *freadw(); bool freadb(); void playchirp(const char *song, const bool lock); +void stopchirp(); void exit();