mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-29 05:40:23 -04:00
add new function pa_alsa_volume_divide()
This commit is contained in:
parent
8ab85fdf9e
commit
29daef7a26
2 changed files with 27 additions and 0 deletions
|
|
@ -1117,3 +1117,27 @@ pa_rtpoll_item* pa_alsa_build_pollfd(snd_pcm_t *pcm, pa_rtpoll *rtpoll) {
|
|||
|
||||
return item;
|
||||
}
|
||||
|
||||
pa_cvolume *pa_alsa_volume_divide(pa_cvolume *r, const pa_cvolume *t) {
|
||||
unsigned i;
|
||||
|
||||
pa_assert(r);
|
||||
pa_assert(t);
|
||||
pa_assert(r->channels == t->channels);
|
||||
|
||||
for (i = 0; i < r->channels; i++) {
|
||||
double a, b, c;
|
||||
|
||||
a = pa_sw_volume_to_linear(r->values[i]); /* the hw volume */
|
||||
b = pa_sw_volume_to_linear(t->values[i]); /* the intended volume */
|
||||
|
||||
if (a <= 0)
|
||||
c = 0;
|
||||
else
|
||||
c = b / a;
|
||||
|
||||
r->values[i] = pa_sw_volume_from_linear(c);
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#include <asoundlib.h>
|
||||
|
||||
#include <pulse/sample.h>
|
||||
#include <pulse/volume.h>
|
||||
#include <pulse/mainloop-api.h>
|
||||
#include <pulse/channelmap.h>
|
||||
#include <pulse/proplist.h>
|
||||
|
|
@ -94,4 +95,6 @@ int pa_alsa_recover_from_poll(snd_pcm_t *pcm, int revents);
|
|||
|
||||
pa_rtpoll_item* pa_alsa_build_pollfd(snd_pcm_t *pcm, pa_rtpoll *rtpoll);
|
||||
|
||||
pa_cvolume *pa_alsa_volume_divide(pa_cvolume *r, const pa_cvolume *t);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue