Logo Search packages:      
Sourcecode: pulseaudio version File versions  Download package

pa_cvolume* pa_cvolume_scale ( pa_cvolume v,
pa_volume_t  max 

Scale the passed pa_cvolume structure so that the maximum volume of all channels equals max. The proportions between the channel volumes are kept.


Definition at line 682 of file volume.c.

References pa_cvolume::channels, PA_VOLUME_INVALID, PA_VOLUME_MUTED, pa_volume_t, and pa_cvolume::values.

    unsigned c;
    pa_volume_t t = 0;


    pa_return_val_if_fail(pa_cvolume_valid(v), NULL);
    pa_return_val_if_fail(max != PA_VOLUME_INVALID, NULL);

    t = pa_cvolume_max(v);

    if (t <= PA_VOLUME_MUTED)
        return pa_cvolume_set(v, v->channels, max);

    for (c = 0; c < v->channels; c++)
        v->values[c] = (pa_volume_t) (((uint64_t)  v->values[c] * (uint64_t) max) / (uint64_t) t);

    return v;

Generated by  Doxygen 1.6.0   Back to index