Bug 1887774 add prefs to simulate drift in audio streams r=padenot

Differential Revision: https://phabricator.services.mozilla.com/D206863
This commit is contained in:
Karl Tomlinson 2024-04-10 18:42:35 +00:00
parent 29d972749f
commit 3018a1b599
2 changed files with 41 additions and 4 deletions

View File

@ -382,10 +382,33 @@ int CubebStreamInit(cubeb* context, cubeb_stream** stream,
if (ms) {
std::this_thread::sleep_for(std::chrono::milliseconds(ms));
}
return cubeb_stream_init(context, stream, stream_name, input_device,
input_stream_params, output_device,
output_stream_params, latency_frames, data_callback,
state_callback, user_ptr);
cubeb_stream_params inputParamData;
cubeb_stream_params outputParamData;
cubeb_stream_params* inputParamPtr = input_stream_params;
cubeb_stream_params* outputParamPtr = output_stream_params;
if (input_stream_params && !output_stream_params) {
inputParamData = *input_stream_params;
inputParamData.rate = llround(
static_cast<double>(StaticPrefs::media_cubeb_input_drift_factor()) *
inputParamData.rate);
MOZ_LOG(
gCubebLog, LogLevel::Info,
("CubebStreamInit input stream rate %" PRIu32, inputParamData.rate));
inputParamPtr = &inputParamData;
} else if (output_stream_params && !input_stream_params) {
outputParamData = *output_stream_params;
outputParamData.rate = llround(
static_cast<double>(StaticPrefs::media_cubeb_output_drift_factor()) *
outputParamData.rate);
MOZ_LOG(
gCubebLog, LogLevel::Info,
("CubebStreamInit output stream rate %" PRIu32, outputParamData.rate));
outputParamPtr = &outputParamData;
}
return cubeb_stream_init(
context, stream, stream_name, input_device, inputParamPtr, output_device,
outputParamPtr, latency_frames, data_callback, state_callback, user_ptr);
}
void InitBrandName() {

View File

@ -9592,6 +9592,20 @@
value: 32768 # Measured in KiB
mirror: always
# Multiplier to change the sample rate at which input-only streams run, so as
# to similate clock drift.
- name: media.cubeb.input_drift_factor
type: AtomicFloat
mirror: always
value: 1.f
# Multiplier to change the sample rate at which output-only streams run, so as
# to similate clock drift.
- name: media.cubeb.output_drift_factor
type: AtomicFloat
mirror: always
value: 1.f
# Whether cubeb is sandboxed (AudioIPC)
- name: media.cubeb.sandbox
type: bool