forked from len0rd/rockbox
Correct detection of the absence of the current preset
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25990 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
cd8ed00dfe
commit
230f0405eb
1 changed files with 7 additions and 5 deletions
|
@ -398,13 +398,15 @@ const char *get_radio_token(struct wps_token *token, int preset_offset,
|
||||||
case WPS_TOKEN_PRESET_NAME:
|
case WPS_TOKEN_PRESET_NAME:
|
||||||
case WPS_TOKEN_PRESET_FREQ:
|
case WPS_TOKEN_PRESET_FREQ:
|
||||||
{
|
{
|
||||||
int preset = radio_current_preset() + preset_offset;
|
int preset_count = radio_preset_count();
|
||||||
if (radio_preset_count() == 0 || preset == -1)
|
int cur_preset = radio_current_preset();
|
||||||
|
if (preset_count == 0 || cur_preset < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
/* make sure its in the valid range */
|
int preset = cur_preset + preset_offset;
|
||||||
|
/* make sure it's in the valid range */
|
||||||
while (preset < 0)
|
while (preset < 0)
|
||||||
preset += radio_preset_count();
|
preset += preset_count;
|
||||||
preset %= radio_preset_count();
|
preset %= preset_count;
|
||||||
if (token->type == WPS_TOKEN_PRESET_NAME)
|
if (token->type == WPS_TOKEN_PRESET_NAME)
|
||||||
{
|
{
|
||||||
snprintf(buf, buf_size, "%s", radio_get_preset(preset)->name);
|
snprintf(buf, buf_size, "%s", radio_get_preset(preset)->name);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue