diff options
author | William Wilgus <wilgus.william@gmail.com> | 2021-11-13 03:38:28 -0500 |
---|---|---|
committer | William Wilgus <wilgus.william@gmail.com> | 2021-11-13 03:38:28 -0500 |
commit | 11ddc6cf1cd4380e0bd2ec45c3debfe04810097f (patch) | |
tree | 000c191648d611c8c1263ee861afd49f367b2144 | |
parent | 59ef877c94c9cabd9007e86994bc858c35fd5c95 (diff) | |
download | rockbox-11ddc6cf1cd4380e0bd2ec45c3debfe04810097f.tar.gz rockbox-11ddc6cf1cd4380e0bd2ec45c3debfe04810097f.zip |
announce_status Fix USB fall through and usb on plugin start
When running and USB plugged announce status ack'd the USB and then un intentionally fell through to EV_EXIT
this caused the thread to exit but not the TSR hook
Now: plugin keeps track of usb status and doesn't announce till usb is unplugged again
on unplug the start-up beep is played to announce its presence
announce_status on startup blocks usb since USB handling is done in the thread that hasn't started yet
Now: don't start if USB is plugged
Plugin now beeps if it couldn't play the announcement excpept for missing voice file unfortunately
Change-Id: I69cf7e687508ce02358432e7bd1adc27c78c4072
-rw-r--r-- | apps/plugins/announce_status.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/apps/plugins/announce_status.c b/apps/plugins/announce_status.c index a9958f198d..77e9015000 100644 --- a/apps/plugins/announce_status.c +++ b/apps/plugins/announce_status.c | |||
@@ -191,6 +191,8 @@ void announce(void) | |||
191 | rb->talk_force_shutup(); | 191 | rb->talk_force_shutup(); |
192 | rb->sleep(HZ / 2); | 192 | rb->sleep(HZ / 2); |
193 | voice_general_info(false); | 193 | voice_general_info(false); |
194 | if (rb->talk_id(VOICE_PAUSE, true) < 0) | ||
195 | rb->beep_play(800, 100, 1000); | ||
194 | //rb->talk_force_enqueue_next(); | 196 | //rb->talk_force_enqueue_next(); |
195 | } | 197 | } |
196 | 198 | ||
@@ -412,6 +414,7 @@ static int settings_menu(void) | |||
412 | /****************** main thread + helper ******************/ | 414 | /****************** main thread + helper ******************/ |
413 | void thread(void) | 415 | void thread(void) |
414 | { | 416 | { |
417 | bool in_usb = false; | ||
415 | long interval; | 418 | long interval; |
416 | long last_tick = *rb->current_tick; /* for 1 sec tick */ | 419 | long last_tick = *rb->current_tick; /* for 1 sec tick */ |
417 | 420 | ||
@@ -424,6 +427,14 @@ void thread(void) | |||
424 | { | 427 | { |
425 | case SYS_USB_CONNECTED: | 428 | case SYS_USB_CONNECTED: |
426 | rb->usb_acknowledge(SYS_USB_CONNECTED_ACK); | 429 | rb->usb_acknowledge(SYS_USB_CONNECTED_ACK); |
430 | in_usb = true; | ||
431 | break; | ||
432 | case SYS_USB_DISCONNECTED: | ||
433 | in_usb = false; | ||
434 | /*fall through*/ | ||
435 | case EV_STARTUP: | ||
436 | rb->beep_play(1500, 100, 1000); | ||
437 | break; | ||
427 | case EV_EXIT: | 438 | case EV_EXIT: |
428 | return; | 439 | return; |
429 | case EV_OTHINSTANCE: | 440 | case EV_OTHINSTANCE: |
@@ -431,15 +442,12 @@ void thread(void) | |||
431 | { | 442 | { |
432 | last_tick += interval; | 443 | last_tick += interval; |
433 | rb->sleep(HZ / 10); | 444 | rb->sleep(HZ / 10); |
434 | announce(); | 445 | if (!in_usb) announce(); |
435 | } | 446 | } |
436 | break; | 447 | break; |
437 | case EV_STARTUP: | ||
438 | rb->beep_play(1500, 100, 1000); | ||
439 | break; | ||
440 | case EV_TRACKCHANGE: | 448 | case EV_TRACKCHANGE: |
441 | rb->sleep(HZ / 10); | 449 | rb->sleep(HZ / 10); |
442 | announce(); | 450 | if (!in_usb) announce(); |
443 | break; | 451 | break; |
444 | } | 452 | } |
445 | } | 453 | } |
@@ -464,6 +472,7 @@ void thread_quit(void) | |||
464 | rb->thread_wait(gThread.id); | 472 | rb->thread_wait(gThread.id); |
465 | /* we don't want any more events */ | 473 | /* we don't want any more events */ |
466 | rb->remove_event(PLAYBACK_EVENT_TRACK_CHANGE, playback_event_callback); | 474 | rb->remove_event(PLAYBACK_EVENT_TRACK_CHANGE, playback_event_callback); |
475 | |||
467 | /* remove the thread's queue from the broadcast list */ | 476 | /* remove the thread's queue from the broadcast list */ |
468 | rb->queue_delete(&gThread.queue); | 477 | rb->queue_delete(&gThread.queue); |
469 | gThread.exiting = true; | 478 | gThread.exiting = true; |
@@ -560,6 +569,8 @@ int plugin_main(const void* parameter) | |||
560 | enum plugin_status plugin_start(const void* parameter) | 569 | enum plugin_status plugin_start(const void* parameter) |
561 | { | 570 | { |
562 | /* now go ahead and have fun! */ | 571 | /* now go ahead and have fun! */ |
572 | if (rb->usb_inserted() == true) | ||
573 | return PLUGIN_USB_CONNECTED; | ||
563 | int ret = plugin_main(parameter); | 574 | int ret = plugin_main(parameter); |
564 | return (ret==0) ? PLUGIN_OK : PLUGIN_ERROR; | 575 | return (ret==0) ? PLUGIN_OK : PLUGIN_ERROR; |
565 | } | 576 | } |