[pipe] Added instant volume support (pvol) to named metadata pipe.
This commit is contained in:
parent
1549d0d4b5
commit
93e4886993
|
@ -302,6 +302,47 @@ parse_progress(struct input_metadata *m, char *progress)
|
||||||
m->song_length = (end - start) * 10 / 441; // Convert to ms based on 44100
|
m->song_length = (end - start) * 10 / 441; // Convert to ms based on 44100
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
parse_volume(char *volume)
|
||||||
|
{
|
||||||
|
char *volume_next;
|
||||||
|
float airplay_volume;
|
||||||
|
float local_volume;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
airplay_volume = strtof(volume, &volume_next);
|
||||||
|
|
||||||
|
if ((errno == ERANGE) || (volume == volume_next))
|
||||||
|
{
|
||||||
|
DPRINTF(E_LOG, L_PLAYER, "Invalid airplay volume in string (%s): %s\n", volume,
|
||||||
|
(errno == ERANGE ? strerror(errno) : "First token is not a number."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(volume_next, ",0.00,0.00,0.00") != 0)
|
||||||
|
{
|
||||||
|
DPRINTF(E_DBG, L_PLAYER, "Not applying airplay volume while software volume control is enabled (%s)\n", volume);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (((int) airplay_volume) == -144)
|
||||||
|
{
|
||||||
|
DPRINTF(E_DBG, L_PLAYER, "Applying airplay volume ('mute', value: %.2f)\n", airplay_volume);
|
||||||
|
player_volume_set(0);
|
||||||
|
}
|
||||||
|
else if (airplay_volume >= -30.0 && airplay_volume <= 0.0)
|
||||||
|
{
|
||||||
|
local_volume = 100.0 + (airplay_volume / 30.0 * 100.0);
|
||||||
|
if (local_volume < 0 || local_volume > 100)
|
||||||
|
return;
|
||||||
|
|
||||||
|
DPRINTF(E_DBG, L_PLAYER, "Applying airplay volume (percent: %.0f, value: %.2f)\n", local_volume, airplay_volume);
|
||||||
|
player_volume_set((int) local_volume);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
DPRINTF(E_LOG, L_PLAYER, "Airplay volume out of range (-144.0, [-30.0 - 0.0]): %.2f\n", airplay_volume);
|
||||||
|
}
|
||||||
|
|
||||||
// returns 1 on metadata found, 0 on nothing, -1 on error
|
// returns 1 on metadata found, 0 on nothing, -1 on error
|
||||||
static int
|
static int
|
||||||
parse_item(struct input_metadata *m, const char *item)
|
parse_item(struct input_metadata *m, const char *item)
|
||||||
|
@ -313,6 +354,7 @@ parse_item(struct input_metadata *m, const char *item)
|
||||||
uint32_t type;
|
uint32_t type;
|
||||||
uint32_t code;
|
uint32_t code;
|
||||||
char *progress;
|
char *progress;
|
||||||
|
char *volume;
|
||||||
char **data;
|
char **data;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -356,6 +398,8 @@ parse_item(struct input_metadata *m, const char *item)
|
||||||
data = &m->genre;
|
data = &m->genre;
|
||||||
else if (code == dmapval("prgr"))
|
else if (code == dmapval("prgr"))
|
||||||
data = &progress;
|
data = &progress;
|
||||||
|
else if (code == dmapval("pvol"))
|
||||||
|
data = &volume;
|
||||||
else
|
else
|
||||||
goto out_nothing;
|
goto out_nothing;
|
||||||
|
|
||||||
|
@ -364,7 +408,7 @@ parse_item(struct input_metadata *m, const char *item)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&pipe_metadata_lock);
|
pthread_mutex_lock(&pipe_metadata_lock);
|
||||||
|
|
||||||
if (data != &progress)
|
if (data != &progress && data != &volume)
|
||||||
free(*data);
|
free(*data);
|
||||||
|
|
||||||
*data = b64_decode(s);
|
*data = b64_decode(s);
|
||||||
|
@ -376,6 +420,11 @@ parse_item(struct input_metadata *m, const char *item)
|
||||||
parse_progress(m, progress);
|
parse_progress(m, progress);
|
||||||
free(*data);
|
free(*data);
|
||||||
}
|
}
|
||||||
|
else if (data == &volume)
|
||||||
|
{
|
||||||
|
parse_volume(volume);
|
||||||
|
free(*data);
|
||||||
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&pipe_metadata_lock);
|
pthread_mutex_unlock(&pipe_metadata_lock);
|
||||||
|
|
||||||
|
@ -910,4 +959,3 @@ struct input_definition input_pipe =
|
||||||
.init = init,
|
.init = init,
|
||||||
.deinit = deinit,
|
.deinit = deinit,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue