Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hacky fix for Android delay issue #516

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/io/cpal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use crossbeam_channel::Receiver;
use super::{AudioBackendManager, RenderThreadInit};

use crate::buffer::AudioBuffer;
use crate::context::AudioContextLatencyCategory;
use crate::context::AudioContextOptions;
use crate::io::microphone::MicrophoneRender;
use crate::media_devices::{MediaDeviceInfo, MediaDeviceInfoKind};
Expand Down Expand Up @@ -179,6 +180,16 @@ impl AudioBackendManager for CpalBackend {

preferred_config.buffer_size = cpal::BufferSize::Fixed(clamped_buffer_size);

// On android detected range for the buffer size seems to be too big, use default buffer size instead
// See https://github.com/orottier/web-audio-api-rs/issues/515
if cfg!(target_os = "android") {
if let AudioContextLatencyCategory::Balanced
| AudioContextLatencyCategory::Interactive = options.latency_hint
{
preferred_config.buffer_size = cpal::BufferSize::Default;
}
}

// report the picked sample rate to the render thread, i.e. if the requested
// sample rate is not supported by the hardware, it will fallback to the
// default device sample rate
Expand Down
Loading