コード例 #1
0
ファイル: radioart.c プロジェクト: albb0920/rockbox
int radio_get_art_hid(struct dim *requested_dim)
{
    int preset = radio_current_preset();
    int free_idx = -1;
    const char* preset_name;

    if (!buf || radio_scan_mode() || preset < 0)
        return -1;

    preset_name = radio_get_preset_name(preset);
    for (int i=0; i<MAX_RADIOART_IMAGES; i++)
    {
        if (radioart[i].handle < 0)
        {
            free_idx = i;
        }
        else if (!strcmp(radioart[i].name, preset_name) &&
                 radioart[i].dim.width == requested_dim->width &&
                 radioart[i].dim.height == requested_dim->height)
        {
            radioart[i].last_tick = current_tick;
            return radioart[i].handle;
        }
    }
    if (free_idx >= 0)
    {
        return load_radioart_image(&radioart[free_idx], 
                                   preset_name, requested_dim);
    }
    else
    {
        int i = find_oldest_image_index();
        if (i != -1)
        {
            bufclose(radioart[i].handle);
            return load_radioart_image(&radioart[i],
                                       preset_name, requested_dim);
        }
    }
        
    return -1;
}
コード例 #2
0
int radio_get_art_hid(struct dim *requested_dim)
{
    int preset = radio_current_preset();
    int i, free_idx = -1;
    const char* preset_name;
    if (radio_scan_mode() || preset < 0)
        return -1;
#ifdef HAVE_RECORDING
    if (!allow_buffer_access)
        return -1;
#endif
    preset_name = radio_get_preset_name(preset);
    for(i=0;i<MAX_RADIOART_IMAGES;i++)
    {
        if (radioart[i].handle < 0)
        {
            free_idx = i;
        }
        else if (!strcmp(radioart[i].name, preset_name) &&
                 radioart[i].dim.width == requested_dim->width &&
                 radioart[i].dim.height == requested_dim->height)
        {
            radioart[i].last_tick = current_tick;
            return radioart[i].handle;
        }
    }
    if (free_idx >= 0)
    {
        return load_radioart_image(&radioart[free_idx], 
                                   preset_name, requested_dim);
    }
    else
    {
        int i = find_oldest_image();
        bufclose(radioart[i].handle);
        return load_radioart_image(&radioart[i],
                                   preset_name, requested_dim);        
    }
        
    return -1;
}