Better handle volume math
This commit is contained in:
parent
40189f3226
commit
d581e3eeab
|
|
@ -19,7 +19,6 @@
|
||||||
#define M_PI (3.14159265)
|
#define M_PI (3.14159265)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void gear_sound_stream(pa_stream *s, size_t length, void *userdata) {
|
void gear_sound_stream(pa_stream *s, size_t length, void *userdata) {
|
||||||
|
|
||||||
SoundData* data = (SoundData*)userdata;
|
SoundData* data = (SoundData*)userdata;
|
||||||
|
|
@ -131,14 +130,13 @@ int usb_generic_shaker_init(SoundDevice* sounddevice, pa_threaded_mainloop* main
|
||||||
|
|
||||||
pa_cvolume* cv;
|
pa_cvolume* cv;
|
||||||
pa_cvolume_mute(cv, channels);
|
pa_cvolume_mute(cv, channels);
|
||||||
uint16_t pvolume = ceil(((double) volume/100.0d)*65535);
|
|
||||||
// Settings copied as per the chromium browser source
|
pa_volume_t channel_volume = PA_CLAMP_VOLUME((pa_volume_t)((volume/100.d)*PA_VOLUME_NORM));
|
||||||
|
|
||||||
pa_stream_flags_t stream_flags;
|
pa_stream_flags_t stream_flags;
|
||||||
stream_flags = PA_STREAM_INTERPOLATE_TIMING | PA_STREAM_NOT_MONOTONIC | PA_STREAM_AUTO_TIMING_UPDATE | PA_STREAM_ADJUST_LATENCY | PA_STREAM_START_CORKED;
|
stream_flags = PA_STREAM_INTERPOLATE_TIMING | PA_STREAM_NOT_MONOTONIC | PA_STREAM_AUTO_TIMING_UPDATE | PA_STREAM_ADJUST_LATENCY | PA_STREAM_START_CORKED;
|
||||||
|
|
||||||
|
cv->values[pan] = channel_volume;
|
||||||
cv->values[pan] = pvolume;
|
|
||||||
|
|
||||||
assert(pa_stream_connect_playback(stream, devname, &buffer_attr, stream_flags, cv, NULL) == 0);
|
assert(pa_stream_connect_playback(stream, devname, &buffer_attr, stream_flags, cv, NULL) == 0);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue