- chirp_stop() implemented
- chirps stop playing when ESC or F5
This commit is contained in:
@@ -151,3 +151,8 @@ int32_t interpret_next_token(uint8_t* buffer) {
|
|||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void chirp_stop() {
|
||||||
|
audio_state=AUDIO_NONE;
|
||||||
|
audio_lock=false;
|
||||||
|
}
|
||||||
|
|||||||
2
chirp.h
2
chirp.h
@@ -6,3 +6,5 @@ void chirp_init();
|
|||||||
void chirp_play(const char* new_song, const bool lock);
|
void chirp_play(const char* new_song, const bool lock);
|
||||||
|
|
||||||
int32_t interpret_next_token(uint8_t* buffer);
|
int32_t interpret_next_token(uint8_t* buffer);
|
||||||
|
|
||||||
|
void chirp_stop();
|
||||||
|
|||||||
6
lua.cpp
6
lua.cpp
@@ -657,6 +657,11 @@ extern "C" {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int cpp_stopchirp(lua_State *L) {
|
||||||
|
stopchirp();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int cpp_exit(lua_State *L) {
|
static int cpp_exit(lua_State *L) {
|
||||||
exit();
|
exit();
|
||||||
return 0;
|
return 0;
|
||||||
@@ -759,6 +764,7 @@ void push_lua_funcs() {
|
|||||||
lua_pushcfunction(L,cpp_freadb); lua_setglobal(L, "freadb");
|
lua_pushcfunction(L,cpp_freadb); lua_setglobal(L, "freadb");
|
||||||
|
|
||||||
lua_pushcfunction(L,cpp_playchirp); lua_setglobal(L, "playchirp");
|
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");
|
lua_pushcfunction(L,cpp_exit); lua_setglobal(L, "quit");
|
||||||
|
|
||||||
|
|||||||
6
mini.cpp
6
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_QUIT) { should_exit=true; should_quit=true; break; }
|
||||||
if (mini_eve.type == SDL_KEYDOWN) {
|
if (mini_eve.type == SDL_KEYDOWN) {
|
||||||
if (mini_eve.key.keysym.scancode == SDL_SCANCODE_ESCAPE) {
|
if (mini_eve.key.keysym.scancode == SDL_SCANCODE_ESCAPE) {
|
||||||
|
chirp_stop();
|
||||||
if (lua_is_playing()) {
|
if (lua_is_playing()) {
|
||||||
lua_quit();
|
lua_quit();
|
||||||
quitaudio();
|
quitaudio();
|
||||||
@@ -228,6 +229,7 @@ int main(int argc,char*argv[]){
|
|||||||
//lua_call_init();
|
//lua_call_init();
|
||||||
}
|
}
|
||||||
} else if (mini_eve.key.keysym.scancode == SDL_SCANCODE_F5) {
|
} else if (mini_eve.key.keysym.scancode == SDL_SCANCODE_F5) {
|
||||||
|
chirp_stop();
|
||||||
should_exit=true;
|
should_exit=true;
|
||||||
//lua_quit();
|
//lua_quit();
|
||||||
//reinit();
|
//reinit();
|
||||||
@@ -987,6 +989,10 @@ void playchirp(const char *song, const bool lock) {
|
|||||||
chirp_play(song, lock);
|
chirp_play(song, lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void stopchirp() {
|
||||||
|
chirp_stop();
|
||||||
|
}
|
||||||
|
|
||||||
void exit() {
|
void exit() {
|
||||||
should_exit = true;
|
should_exit = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user