File src/Volume.cpp changed (mode: 100644) (index f796347..902f855) |
... |
... |
std::pair<bool, int> Volume::getVolumeLevel() const |
58 |
58 |
if (snd_mixer_open(&raw_handle, 0) < 0) { |
if (snd_mixer_open(&raw_handle, 0) < 0) { |
59 |
59 |
return {false, -1}; |
return {false, -1}; |
60 |
60 |
} |
} |
61 |
|
|
|
62 |
|
if (snd_mixer_attach(raw_handle, cardName.c_str()) < 0) { |
|
63 |
|
return {false, -1}; |
|
64 |
|
} |
|
65 |
61 |
if (snd_mixer_selem_register(raw_handle, nullptr, nullptr) < 0) { |
if (snd_mixer_selem_register(raw_handle, nullptr, nullptr) < 0) { |
66 |
62 |
return {false, -1}; |
return {false, -1}; |
67 |
63 |
} |
} |
68 |
64 |
} |
} |
69 |
65 |
|
|
|
66 |
|
if (snd_mixer_attach(raw_handle, cardName.c_str()) < 0) { |
|
67 |
|
return {false, -1}; |
|
68 |
|
} |
|
69 |
|
|
70 |
70 |
if (snd_mixer_load(raw_handle) < 0) { |
if (snd_mixer_load(raw_handle) < 0) { |
71 |
71 |
return {false, -1}; |
return {false, -1}; |
72 |
72 |
} |
} |
|
... |
... |
std::pair<bool, int> Volume::getVolumeLevel() const |
99 |
99 |
|
|
100 |
100 |
snd_mixer_free(raw_handle); |
snd_mixer_free(raw_handle); |
101 |
101 |
|
|
|
102 |
|
if (snd_mixer_detach(raw_handle, cardName.c_str()) < 0) { |
|
103 |
|
return {false, -1}; |
|
104 |
|
} |
|
105 |
|
|
102 |
106 |
return {state, (100*(vol - min))/(max - min)}; |
return {state, (100*(vol - min))/(max - min)}; |
103 |
107 |
} |
} |