Fix issue where volume gets set to -1 on startup of raop devices

This commit is contained in:
ejurgensen 2015-09-27 15:24:04 +02:00
parent 50bcdd2551
commit 4db6318a82
2 changed files with 11 additions and 8 deletions

View File

@ -80,6 +80,9 @@
#define MAX(a, b) ((a > b) ? a : b) #define MAX(a, b) ((a > b) ? a : b)
#endif #endif
// Default volume (must be from 0 - 100)
#define PLAYER_DEFAULT_VOLUME 50
enum player_sync_source enum player_sync_source
{ {
PLAYER_SYNC_CLOCK, PLAYER_SYNC_CLOCK,
@ -378,7 +381,7 @@ speaker_select_laudio(void)
if (laudio_volume > master_volume) if (laudio_volume > master_volume)
{ {
if (player_state == PLAY_STOPPED) if (player_state == PLAY_STOPPED || master_volume == -1)
volume_master_update(laudio_volume); volume_master_update(laudio_volume);
else else
laudio_volume = master_volume; laudio_volume = master_volume;
@ -394,7 +397,7 @@ speaker_select_raop(struct raop_device *rd)
if (rd->volume > master_volume) if (rd->volume > master_volume)
{ {
if (player_state == PLAY_STOPPED) if (player_state == PLAY_STOPPED || master_volume == -1)
volume_master_update(rd->volume); volume_master_update(rd->volume);
else else
rd->volume = master_volume; rd->volume = master_volume;
@ -2102,7 +2105,7 @@ device_add(struct player_command *cmd)
if (ret < 0) if (ret < 0)
{ {
selected = 0; selected = 0;
rd->volume = (master_volume >= 0) ? master_volume : 75; rd->volume = (master_volume >= 0) ? master_volume : PLAYER_DEFAULT_VOLUME;
} }
if (dev_autoselect && selected) if (dev_autoselect && selected)
@ -5302,7 +5305,7 @@ player_init(void)
ret = db_speaker_get(0, &laudio_selected, &laudio_volume); ret = db_speaker_get(0, &laudio_selected, &laudio_volume);
if (ret < 0) if (ret < 0)
laudio_volume = 75; laudio_volume = PLAYER_DEFAULT_VOLUME;
else if (laudio_selected) else if (laudio_selected)
speaker_select_laudio(); /* Run the select helper */ speaker_select_laudio(); /* Run the select helper */

View File

@ -2219,12 +2219,12 @@ raop_volume_convert(int volume, char *name)
/* RAOP volume /* RAOP volume
* -144.0 is off * -144.0 is off
* 0 - -30.0 maps to 100 - 0 * 0 - 100 maps to -30.0 - 0
*/ */
if (volume == 0) if (volume > 0 && volume <= 100)
raop_volume = -144.0;
else
raop_volume = -30.0 + ((float)max_volume * (float)volume * 30.0) / (100.0 * RAOP_CONFIG_MAX_VOLUME); raop_volume = -30.0 + ((float)max_volume * (float)volume * 30.0) / (100.0 * RAOP_CONFIG_MAX_VOLUME);
else
raop_volume = -144.0;
return raop_volume; return raop_volume;
} }