Fixed several plugins for dB volume.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8258 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
5cc7347463
commit
c80e0c19e1
7 changed files with 25 additions and 12 deletions
|
@ -367,6 +367,9 @@ static const struct plugin_api rockbox_api = {
|
|||
utf16BEdecode,
|
||||
utf8encode,
|
||||
utf8length,
|
||||
|
||||
sound_min,
|
||||
sound_max,
|
||||
};
|
||||
|
||||
int plugin_load(const char* plugin, void* parameter)
|
||||
|
|
|
@ -91,7 +91,7 @@
|
|||
#endif
|
||||
|
||||
/* increase this every time the api struct changes */
|
||||
#define PLUGIN_API_VERSION 53
|
||||
#define PLUGIN_API_VERSION 54
|
||||
|
||||
/* update this to latest version if a change to the api struct breaks
|
||||
backwards compatibility (and please take the opportunity to sort in any
|
||||
|
@ -448,6 +448,9 @@ struct plugin_api {
|
|||
unsigned char* (*utf16BEdecode)(const unsigned char *utf16, unsigned char *utf8, unsigned int count);
|
||||
unsigned char* (*utf8encode)(unsigned long ucs, unsigned char *utf8);
|
||||
unsigned long (*utf8length)(const unsigned char *utf8);
|
||||
|
||||
int (*sound_min)(int setting);
|
||||
int (*sound_max)(int setting);
|
||||
};
|
||||
|
||||
int plugin_load(const char* plugin, void* parameter);
|
||||
|
|
|
@ -1044,7 +1044,7 @@ void sound_neutral(void)
|
|||
rb->sound_set(SOUND_BASS, 0);
|
||||
rb->sound_set(SOUND_TREBLE, 0);
|
||||
rb->sound_set(SOUND_BALANCE, 0);
|
||||
rb->sound_set(SOUND_VOLUME, 92); /* 0 dB */
|
||||
rb->sound_set(SOUND_VOLUME, 0);
|
||||
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
|
||||
rb->sound_set(SOUND_LOUDNESS, 0);
|
||||
rb->sound_set(SOUND_SUPERBASS, 0);
|
||||
|
|
|
@ -196,10 +196,13 @@ void draw_display(void){
|
|||
/* helper function to change the volume by a certain amount, +/-
|
||||
ripped from video.c */
|
||||
void change_volume(int delta){
|
||||
int minvol = rb->sound_min(SOUND_VOLUME);
|
||||
int maxvol = rb->sound_max(SOUND_VOLUME);
|
||||
int vol = rb->global_settings->volume + delta;
|
||||
char buffer[30];
|
||||
if (vol > 100) vol = 100;
|
||||
else if (vol < 0) vol = 0;
|
||||
|
||||
if (vol > maxvol) vol = maxvol;
|
||||
else if (vol < minvol) vol = minvol;
|
||||
if (vol != rb->global_settings->volume) {
|
||||
rb->sound_set(SOUND_VOLUME, vol);
|
||||
rb->global_settings->volume = vol;
|
||||
|
|
|
@ -241,7 +241,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
|||
case OSCILLOSCOPE_VOL_UP:
|
||||
case OSCILLOSCOPE_VOL_UP | BUTTON_REPEAT:
|
||||
vol = rb->global_settings->volume;
|
||||
if (vol < 100)
|
||||
if (vol < rb->sound_max(SOUND_VOLUME))
|
||||
{
|
||||
vol++;
|
||||
rb->sound_set(SOUND_VOLUME, vol);
|
||||
|
@ -252,7 +252,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
|||
case OSCILLOSCOPE_VOL_DOWN:
|
||||
case OSCILLOSCOPE_VOL_DOWN | BUTTON_REPEAT:
|
||||
vol = rb->global_settings->volume;
|
||||
if (vol > 0)
|
||||
if (vol > rb->sound_min(SOUND_VOLUME))
|
||||
{
|
||||
vol--;
|
||||
rb->sound_set(SOUND_VOLUME, vol);
|
||||
|
|
|
@ -272,15 +272,17 @@ void DrawPosition(int pos, int total)
|
|||
// helper function to change the volume by a certain amount, +/-
|
||||
void ChangeVolume(int delta)
|
||||
{
|
||||
int minvol = rb->sound_min(SOUND_VOLUME);
|
||||
int maxvol = rb->sound_max(SOUND_VOLUME);
|
||||
int vol = rb->global_settings->volume + delta;
|
||||
|
||||
if (vol > 100) vol = 100;
|
||||
else if (vol < 0) vol = 0;
|
||||
if (vol > maxvol) vol = maxvol;
|
||||
else if (vol < minvol) vol = minvol;
|
||||
if (vol != rb->global_settings->volume)
|
||||
{
|
||||
rb->sound_set(SOUND_VOLUME, vol);
|
||||
rb->global_settings->volume = vol;
|
||||
rb->snprintf(gPrint, sizeof(gPrint), "Vol: %d", vol);
|
||||
rb->snprintf(gPrint, sizeof(gPrint), "Vol: %d dB", vol);
|
||||
rb->lcd_puts(0, 7, gPrint);
|
||||
if (gPlay.state == paused) // we have to draw ourselves
|
||||
rb->lcd_update_rect(0, LCD_HEIGHT-8, LCD_WIDTH, 8);
|
||||
|
|
|
@ -133,11 +133,13 @@ void save_settings(void) {
|
|||
}
|
||||
|
||||
void change_volume(int delta) {
|
||||
char curr_vol[4];
|
||||
char curr_vol[5];
|
||||
int minvol = rb->sound_min(SOUND_VOLUME);
|
||||
int maxvol = rb->sound_max(SOUND_VOLUME);
|
||||
int vol = rb->global_settings->volume + delta;
|
||||
|
||||
if (vol>100) vol = 100;
|
||||
else if (vol < 0) vol = 0;
|
||||
if (vol > maxvol) vol = maxvol;
|
||||
else if (vol < minvol) vol = minvol;
|
||||
if (vol != rb->global_settings->volume) {
|
||||
rb->sound_set(SOUND_VOLUME, vol);
|
||||
rb->global_settings->volume = vol;
|
||||
|
|
Loading…
Reference in a new issue