FS#12353: For car adapter mode, make delay before resuming configurable

Original patch by Stanislav Chizhik
Udpated by Igor Poretsky & myself

Change-Id: I472d4852ac25885658245f077723e4c98b9ad9b8
This commit is contained in:
Solomon Peachy 2019-01-01 21:05:13 -05:00
parent 60c9df0b12
commit 0a6cad736f
7 changed files with 63 additions and 6 deletions

View file

@ -13983,3 +13983,20 @@
*: "Playing time"
</voice>
</phrase>
<phrase>
id: LANG_CAR_ADAPTER_MODE_DELAY
desc: Displayed for setting car adapter mode delay
user: core
<source>
*: none
charging: "Delay Before Resume"
</source>
<dest>
*: none
charging: "Delay Before Resume"
</dest>
<voice>
*: none
charging: "Delay Before Resume"
</voice>
</phrase>

View file

@ -13740,3 +13740,20 @@
*: "Play"
</voice>
</phrase>
<phrase>
id: LANG_CAR_ADAPTER_MODE_DELAY
desc: Displayed for setting car adapter mode delay
user: core
<source>
*: none
charging: "Delay Before Resume"
</source>
<dest>
*: none
charging: "Задержка перед возобновлением"
</dest>
<voice>
*: none
charging: "Задержка перед возобновлением"
</voice>
</phrase>

View file

@ -345,6 +345,9 @@ MENUITEM_SETTING(line_in, &global_settings.line_in, linein_callback);
#endif
#if CONFIG_CHARGING
MENUITEM_SETTING(car_adapter_mode, &global_settings.car_adapter_mode, NULL);
MENUITEM_SETTING(car_adapter_mode_delay, &global_settings.car_adapter_mode_delay, NULL);
MAKE_MENU(car_adapter_mode_menu, ID2P(LANG_CAR_ADAPTER_MODE), 0, Icon_NOICON,
&car_adapter_mode, &car_adapter_mode_delay);
#endif
#ifdef IPOD_ACCESSORY_PROTOCOL
MENUITEM_SETTING(serial_bitrate, &global_settings.serial_bitrate, NULL);
@ -424,7 +427,7 @@ MAKE_MENU(system_menu, ID2P(LANG_SYSTEM),
&line_in,
#endif
#if CONFIG_CHARGING
&car_adapter_mode,
&car_adapter_mode_menu,
#endif
#ifdef IPOD_ACCESSORY_PROTOCOL
&serial_bitrate,

View file

@ -466,6 +466,7 @@ bool list_stop_handler(void)
#if CONFIG_CHARGING
static bool waiting_to_resume_play = false;
static bool paused_on_unplugged = false;
static long play_resume_tick;
static void car_adapter_mode_processing(bool inserted)
@ -477,10 +478,10 @@ static void car_adapter_mode_processing(bool inserted)
/*
* Just got plugged in, delay & resume if we were playing
*/
if (audio_status() & AUDIO_STATUS_PAUSE)
if ((audio_status() & AUDIO_STATUS_PAUSE) && paused_on_unplugged)
{
/* delay resume a bit while the engine is cranking */
play_resume_tick = current_tick + HZ*5;
play_resume_tick = current_tick + HZ*global_settings.car_adapter_mode_delay;
waiting_to_resume_play = true;
}
}
@ -493,7 +494,10 @@ static void car_adapter_mode_processing(bool inserted)
!(audio_status() & AUDIO_STATUS_PAUSE))
{
pause_action(true, true);
paused_on_unplugged = true;
}
else if (!waiting_to_resume_play)
paused_on_unplugged = false;
waiting_to_resume_play = false;
}
}
@ -503,6 +507,9 @@ static void car_adapter_tick(void)
{
if (waiting_to_resume_play)
{
if ((audio_status() & AUDIO_STATUS_PLAY) &&
!(audio_status() & AUDIO_STATUS_PAUSE))
waiting_to_resume_play = false;
if (TIME_AFTER(current_tick, play_resume_tick))
{
if (audio_status() & AUDIO_STATUS_PAUSE)

View file

@ -500,6 +500,7 @@ struct user_settings
bool audioscrobbler; /* Audioscrobbler logging */
bool cuesheet;
bool car_adapter_mode; /* 0=off 1=on */
int car_adapter_mode_delay; /* delay before resume, in seconds*/
int start_in_screen;
#if defined(HAVE_RTC_ALARM) && \
(defined(HAVE_RECORDING) || CONFIG_TUNER)

View file

@ -1061,6 +1061,9 @@ const struct settings_list settings[] = {
#if CONFIG_CHARGING
OFFON_SETTING(NVRAM(1), car_adapter_mode,
LANG_CAR_ADAPTER_MODE, false, "car adapter mode", NULL),
INT_SETTING_NOWRAP(0, car_adapter_mode_delay, LANG_CAR_ADAPTER_MODE_DELAY,
5, "delay before resume", UNIT_SEC, 5, 30, 5,
NULL, NULL, NULL),
#endif
#ifdef IPOD_ACCESSORY_PROTOCOL
CHOICE_SETTING(0, serial_bitrate, LANG_SERIAL_BITRATE, 0, "serial bitrate",

View file

@ -145,14 +145,23 @@ This sub menu relates to limits in the Rockbox operating system.
in the \setting{Idle Poweroff} setting
(see \reference{ref:IdlePoweroffSetting}).
If power to the DC in jack is turned back on before the \emph{Idle Poweroff}
function has shut the \dap{} off, playback will be resumed 5 seconds after
the power is applied. This delay is to allow for the time while the car
engine is being started.
function has shut the \dap{} off, playback will be resumed after
\setting{Car Adapter Mode Delay} seconds after the power is applied.
This delay is to allow for the time while the car engine is being started.
\end{description}
Once the \dap{} is shut off either manually, or automatically with the
\setting{Idle Poweroff} function, it must be powered up manually to resume
playback.
\subsection{Car Adapter Mode Delay}
This option specifies
the time between power being applied and playback resuming
\begin{description}
\item [Car Adapter Mode Delay.] As different car headunits take
varying amounts of time to start up, the \setting{Car Adapter Mode Delay}
is configurable between 5 and 30 seconds, in 5 second increments.
\end{description}
}
\opt{accessory_supply}{