Requests: Add volumedb field to SourceVolumeChanged Event

This commit is contained in:
Ruggero Tomaselli 2021-03-10 11:15:17 +01:00
parent 01c898b104
commit 452a307b33
No known key found for this signature in database
GPG Key ID: 12055021D56E044B

View File

@ -1145,6 +1145,7 @@ void WSEvents::OnSourceDestroy(void* param, calldata_t* data) {
*
* @return {String} `sourceName` Source name
* @return {float} `volume` Source volume
* @return {float} `volumeDb` Source volume in Decibel
*
* @api events
* @name SourceVolumeChanged
@ -1164,9 +1165,15 @@ void WSEvents::OnSourceVolumeChange(void* param, calldata_t* data) {
return;
}
double volumeDb = obs_mul_to_db(volume);
if (volumeDb == -INFINITY) {
volumeDb = -100.0;
}
OBSDataAutoRelease fields = obs_data_create();
obs_data_set_string(fields, "sourceName", obs_source_get_name(source));
obs_data_set_double(fields, "volume", volume);
obs_data_set_double(fields, "volumeDb", volumeDb);
self->broadcastUpdate("SourceVolumeChanged", fields);
}