1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
William Wilgus 2021-11-13 03:38:28 -05:00
parent 59ef877c94
commit 11ddc6cf1c

View file

@ -191,6 +191,8 @@ void announce(void)
rb->talk_force_shutup(); rb->talk_force_shutup();
rb->sleep(HZ / 2); rb->sleep(HZ / 2);
voice_general_info(false); voice_general_info(false);
if (rb->talk_id(VOICE_PAUSE, true) < 0)
rb->beep_play(800, 100, 1000);
//rb->talk_force_enqueue_next(); //rb->talk_force_enqueue_next();
} }
@ -412,6 +414,7 @@ static int settings_menu(void)
/****************** main thread + helper ******************/ /****************** main thread + helper ******************/
void thread(void) void thread(void)
{ {
bool in_usb = false;
long interval; long interval;
long last_tick = *rb->current_tick; /* for 1 sec tick */ long last_tick = *rb->current_tick; /* for 1 sec tick */
@ -424,6 +427,14 @@ void thread(void)
{ {
case SYS_USB_CONNECTED: case SYS_USB_CONNECTED:
rb->usb_acknowledge(SYS_USB_CONNECTED_ACK); rb->usb_acknowledge(SYS_USB_CONNECTED_ACK);
in_usb = true;
break;
case SYS_USB_DISCONNECTED:
in_usb = false;
/*fall through*/
case EV_STARTUP:
rb->beep_play(1500, 100, 1000);
break;
case EV_EXIT: case EV_EXIT:
return; return;
case EV_OTHINSTANCE: case EV_OTHINSTANCE:
@ -431,15 +442,12 @@ void thread(void)
{ {
last_tick += interval; last_tick += interval;
rb->sleep(HZ / 10); rb->sleep(HZ / 10);
announce(); if (!in_usb) announce();
} }
break; break;
case EV_STARTUP:
rb->beep_play(1500, 100, 1000);
break;
case EV_TRACKCHANGE: case EV_TRACKCHANGE:
rb->sleep(HZ / 10); rb->sleep(HZ / 10);
announce(); if (!in_usb) announce();
break; break;
} }
} }
@ -464,6 +472,7 @@ void thread_quit(void)
rb->thread_wait(gThread.id); rb->thread_wait(gThread.id);
/* we don't want any more events */ /* we don't want any more events */
rb->remove_event(PLAYBACK_EVENT_TRACK_CHANGE, playback_event_callback); rb->remove_event(PLAYBACK_EVENT_TRACK_CHANGE, playback_event_callback);
/* remove the thread's queue from the broadcast list */ /* remove the thread's queue from the broadcast list */
rb->queue_delete(&gThread.queue); rb->queue_delete(&gThread.queue);
gThread.exiting = true; gThread.exiting = true;
@ -560,6 +569,8 @@ int plugin_main(const void* parameter)
enum plugin_status plugin_start(const void* parameter) enum plugin_status plugin_start(const void* parameter)
{ {
/* now go ahead and have fun! */ /* now go ahead and have fun! */
if (rb->usb_inserted() == true)
return PLUGIN_USB_CONNECTED;
int ret = plugin_main(parameter); int ret = plugin_main(parameter);
return (ret==0) ? PLUGIN_OK : PLUGIN_ERROR; return (ret==0) ? PLUGIN_OK : PLUGIN_ERROR;
} }