mirror of
https://github.com/badaix/snapcast.git
synced 2025-07-28 22:07:51 +02:00
added setVolume
This commit is contained in:
parent
ccc84fb916
commit
fbd83d3b3e
2 changed files with 26 additions and 0 deletions
|
@ -208,6 +208,31 @@ void Player::worker()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Player::setVolume(double volume)
|
||||||
|
{
|
||||||
|
long min, max;
|
||||||
|
snd_mixer_t *handle;
|
||||||
|
snd_mixer_selem_id_t *sid;
|
||||||
|
const char *selem_name = "Master";
|
||||||
|
|
||||||
|
snd_mixer_open(&handle, 0);
|
||||||
|
snd_mixer_attach(handle, pcmDevice_.name.c_str());
|
||||||
|
snd_mixer_selem_register(handle, NULL, NULL);
|
||||||
|
snd_mixer_load(handle);
|
||||||
|
|
||||||
|
snd_mixer_selem_id_alloca(&sid);
|
||||||
|
snd_mixer_selem_id_set_index(sid, 0);
|
||||||
|
snd_mixer_selem_id_set_name(sid, selem_name);
|
||||||
|
snd_mixer_elem_t* elem = snd_mixer_find_selem(handle, sid);
|
||||||
|
|
||||||
|
snd_mixer_selem_get_playback_volume_range(elem, &min, &max);
|
||||||
|
snd_mixer_selem_set_playback_volume_all(elem, volume * max);
|
||||||
|
|
||||||
|
snd_mixer_close(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
vector<PcmDevice> Player::pcm_list(void)
|
vector<PcmDevice> Player::pcm_list(void)
|
||||||
{
|
{
|
||||||
void **hints, **n;
|
void **hints, **n;
|
||||||
|
|
|
@ -33,6 +33,7 @@ class Player
|
||||||
public:
|
public:
|
||||||
Player(const PcmDevice& pcmDevice, Stream* stream);
|
Player(const PcmDevice& pcmDevice, Stream* stream);
|
||||||
virtual ~Player();
|
virtual ~Player();
|
||||||
|
void setVolume(double volume);
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
static std::vector<PcmDevice> pcm_list(void);
|
static std::vector<PcmDevice> pcm_list(void);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue