forked from len0rd/rockbox
hosted: Rename a bit in functions to avoid name clashes with unix headers.
Change-Id: I2baa5532ddcbca8a839c31434309013f02173ed8
This commit is contained in:
parent
3b7057fdae
commit
be967515ac
2 changed files with 17 additions and 18 deletions
|
@ -28,7 +28,7 @@ const struct button_mapping *plugin_contexts[] = { pla_main_ctx };
|
||||||
|
|
||||||
static int current = 0;
|
static int current = 0;
|
||||||
static bool tomorrow = false;
|
static bool tomorrow = false;
|
||||||
static int alarm[2] = {0, 0}, maxval[2] = {24, 60}, prev_tick = 3600 * 24;
|
static int alarms[2] = {0, 0}, maxval[2] = {24, 60}, prev_tick = 3600 * 24;
|
||||||
static bool quit = false, usb = false, waiting = false, done = false;
|
static bool quit = false, usb = false, waiting = false, done = false;
|
||||||
|
|
||||||
static inline int get_button(void)
|
static inline int get_button(void)
|
||||||
|
@ -39,8 +39,8 @@ static inline int get_button(void)
|
||||||
|
|
||||||
static int rem_seconds(void)
|
static int rem_seconds(void)
|
||||||
{
|
{
|
||||||
int seconds = (((alarm[0] - rb->get_time()->tm_hour) * 3600)
|
int seconds = (((alarms[0] - rb->get_time()->tm_hour) * 3600)
|
||||||
+((alarm[1] - rb->get_time()->tm_min) * 60)
|
+((alarms[1] - rb->get_time()->tm_min) * 60)
|
||||||
-(rb->get_time()->tm_sec));
|
-(rb->get_time()->tm_sec));
|
||||||
|
|
||||||
/* The tomorrow flag means that the alarm should ring on the next day */
|
/* The tomorrow flag means that the alarm should ring on the next day */
|
||||||
|
@ -79,12 +79,12 @@ static void draw(struct screen * display)
|
||||||
else {
|
else {
|
||||||
if (current == 0)
|
if (current == 0)
|
||||||
rb->snprintf(info, sizeof(info), "Set alarm at [%02d]:%02d.",
|
rb->snprintf(info, sizeof(info), "Set alarm at [%02d]:%02d.",
|
||||||
alarm[0],
|
alarms[0],
|
||||||
alarm[1]);
|
alarms[1]);
|
||||||
else
|
else
|
||||||
rb->snprintf(info, sizeof(info), "Set alarm at %02d:[%02d].",
|
rb->snprintf(info, sizeof(info), "Set alarm at %02d:[%02d].",
|
||||||
alarm[0],
|
alarms[0],
|
||||||
alarm[1]);
|
alarms[1]);
|
||||||
}
|
}
|
||||||
draw_centered_string(display, info);
|
draw_centered_string(display, info);
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ static bool can_play(void)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void play(void)
|
static void resume_audio(void)
|
||||||
{
|
{
|
||||||
int audio_status = rb->audio_status();
|
int audio_status = rb->audio_status();
|
||||||
if (!audio_status && rb->global_status->resume_index != -1) {
|
if (!audio_status && rb->global_status->resume_index != -1) {
|
||||||
|
@ -116,7 +116,7 @@ static void play(void)
|
||||||
rb->audio_resume();
|
rb->audio_resume();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pause(void)
|
static void pause_audio(void)
|
||||||
{
|
{
|
||||||
if (rb->audio_status() & AUDIO_STATUS_PLAY)
|
if (rb->audio_status() & AUDIO_STATUS_PLAY)
|
||||||
rb->audio_pause();
|
rb->audio_pause();
|
||||||
|
@ -132,7 +132,7 @@ enum plugin_status plugin_start(const void* parameter)
|
||||||
"Play or pause one first.");
|
"Play or pause one first.");
|
||||||
return PLUGIN_ERROR;
|
return PLUGIN_ERROR;
|
||||||
}
|
}
|
||||||
pause();
|
pause_audio();
|
||||||
|
|
||||||
while(!quit) {
|
while(!quit) {
|
||||||
button = get_button();
|
button = get_button();
|
||||||
|
@ -146,7 +146,7 @@ enum plugin_status plugin_start(const void* parameter)
|
||||||
if (waiting) {
|
if (waiting) {
|
||||||
if (rem_seconds() <= 0) {
|
if (rem_seconds() <= 0) {
|
||||||
quit = done = true;
|
quit = done = true;
|
||||||
play();
|
resume_audio();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -157,7 +157,7 @@ enum plugin_status plugin_start(const void* parameter)
|
||||||
case PLA_SCROLL_FWD:
|
case PLA_SCROLL_FWD:
|
||||||
case PLA_SCROLL_FWD_REPEAT:
|
case PLA_SCROLL_FWD_REPEAT:
|
||||||
#endif
|
#endif
|
||||||
alarm[current] = (alarm[current] + 1) % maxval[current];
|
alarms[current] = (alarms[current] + 1) % maxval[current];
|
||||||
break;
|
break;
|
||||||
case PLA_DOWN:
|
case PLA_DOWN:
|
||||||
case PLA_DOWN_REPEAT:
|
case PLA_DOWN_REPEAT:
|
||||||
|
@ -165,7 +165,7 @@ enum plugin_status plugin_start(const void* parameter)
|
||||||
case PLA_SCROLL_BACK:
|
case PLA_SCROLL_BACK:
|
||||||
case PLA_SCROLL_BACK_REPEAT:
|
case PLA_SCROLL_BACK_REPEAT:
|
||||||
#endif
|
#endif
|
||||||
alarm[current] = (alarm[current] + maxval[current] - 1)
|
alarms[current] = (alarms[current] + maxval[current] - 1)
|
||||||
% maxval[current];
|
% maxval[current];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ static void decrypt_buffer(char *buf, size_t size, uint32_t *key);
|
||||||
David Wheeler and Roger Needham taken from
|
David Wheeler and Roger Needham taken from
|
||||||
http://en.wikipedia.org/wiki/Tiny_Encryption_Algorithm */
|
http://en.wikipedia.org/wiki/Tiny_Encryption_Algorithm */
|
||||||
|
|
||||||
static void encrypt(uint32_t* v, uint32_t* k)
|
static void do_encrypt(uint32_t* v, uint32_t* k)
|
||||||
{
|
{
|
||||||
uint32_t v0=v[0], v1=v[1], sum=0, i; /* set up */
|
uint32_t v0=v[0], v1=v[1], sum=0, i; /* set up */
|
||||||
static const uint32_t delta=0x9e3779b9; /* a key schedule constant */
|
static const uint32_t delta=0x9e3779b9; /* a key schedule constant */
|
||||||
|
@ -91,7 +91,7 @@ static void encrypt(uint32_t* v, uint32_t* k)
|
||||||
v[0]=v0; v[1]=v1;
|
v[0]=v0; v[1]=v1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void decrypt(uint32_t* v, uint32_t* k)
|
static void do_decrypt(uint32_t* v, uint32_t* k)
|
||||||
{
|
{
|
||||||
uint32_t v0=v[0], v1=v[1], sum=0xC6EF3720, i; /* set up */
|
uint32_t v0=v[0], v1=v[1], sum=0xC6EF3720, i; /* set up */
|
||||||
static const uint32_t delta=0x9e3779b9; /* a key schedule constant */
|
static const uint32_t delta=0x9e3779b9; /* a key schedule constant */
|
||||||
|
@ -365,7 +365,7 @@ static void decrypt_buffer(char *buf, size_t size, uint32_t *key)
|
||||||
block[0] = letoh32(block[0]);
|
block[0] = letoh32(block[0]);
|
||||||
block[1] = letoh32(block[1]);
|
block[1] = letoh32(block[1]);
|
||||||
|
|
||||||
decrypt(&block[0], key);
|
do_decrypt(&block[0], key);
|
||||||
|
|
||||||
/* byte swap one block */
|
/* byte swap one block */
|
||||||
block[0] = letoh32(block[0]);
|
block[0] = letoh32(block[0]);
|
||||||
|
@ -388,7 +388,7 @@ static void encrypt_buffer(char *buf, size_t size, uint32_t *key)
|
||||||
block[0] = htole32(block[0]);
|
block[0] = htole32(block[0]);
|
||||||
block[1] = htole32(block[1]);
|
block[1] = htole32(block[1]);
|
||||||
|
|
||||||
encrypt(&block[0], key);
|
do_encrypt(&block[0], key);
|
||||||
|
|
||||||
block[0] = htole32(block[0]);
|
block[0] = htole32(block[0]);
|
||||||
block[1] = htole32(block[1]);
|
block[1] = htole32(block[1]);
|
||||||
|
@ -670,4 +670,3 @@ enum plugin_status plugin_start(const void *parameter)
|
||||||
|
|
||||||
return PLUGIN_OK;
|
return PLUGIN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue