-
Notifications
You must be signed in to change notification settings - Fork 290
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
[Bug] using crate cpal
crashes
#1058
Comments
Hi! Thanks for opening your first issue here! 😄 |
Hmm I guess maybe ask |
I opened an issue with them, maybe they know what the problem is. I found out that it fails to compile for MacOS:
|
This issue is probably caused by mismatching architectures. You're probably compiling your library for x86 and linking with arm64. I had this problem too a couple of months back. |
I have no issues building cpal in my project. https://github.com/erikas-taroza/simple_audio |
Thank you for the good example. In simple_audio: 🤔 |
@tGrothmannFluffy Maybe this will help. It's a piece of documentation I wrote when trying to make a plugin. I think something in there isn't updated, but the plugin tool's source code will be up to date. Of course, you can try using the tool in your project as well. |
Thank you, I've seen the tool being used in simple_audio. (on windows)
|
I have also tried to build the
I would think it's just not possible if I didn't know that there are projects out there doing exactly this... 🤔 |
@tGrothmannFluffy Are you linking with the C++ library, like simple audio does here? Also, on iOS you need to add the let session = AVAudioSession.sharedInstance to the |
cpal
crashes
I think that was it. The missing symbol error is gone now. Thank you! |
Sorry for reopening this (I know it's not really an issue with flutter_rust_bridge) After I added a device.build_input_stream(config, ... I still get an error, though:
I created a repo If you remove only these lines the app works. |
For anyone having this issue. Maybe adding
to Now I am getting either a missing symbol See also this issue on oboe-rs |
The simple audio project also includes the However, I personally now have the problem that my stream creation thread crashes when I ask cpal for its output devices. Maybe @erikas-taroza knows how to solve this? When I build the android libraries from scratch using his |
This is the reason I have @w-ensink, are there any issues building the project or is it only in runtime? Is there a stack trace you can provide of the crash? |
I don't know how to get a stack trace in this case... It just crashes a background thread (started from a call from dart, just like you do in let host = cpal::default_host();
info!("got the host!");
match host.devices() {
Ok(devices) => {
info!("ok devices");
for d in devices {
info!("- device: {:?}!", d.name());
}
}
Err(e) => {
info!("error getting devices: {e:?}");
}
} It does get to the first info!, but it never reaches the second, so it has to crash there. Do you know of a way to get a stack trace out of this? What's interesting as well, is that I do get audio without any issues when I use Oboe directly instead of cpal. |
I do not know what is happening here. Calling |
Maybe this is related to the issue I am having now: After adding the let host = cpal::default_host();
let device = host.default_input_device().expect("no output device available");
let mut supported_configs_range = device
.supported_input_configs() // <- error already happens here
.expect("error while querying configs");
let supported_config = supported_configs_range
.next()
.expect("no supported config?!")
.with_max_sample_rate(); I get the error:
so basically: Found this comment on an issue at cpal but don't know how/where to add this to my app. |
That issue looks familiar to me, I think I had the same problem early on in my project. I don't recall how I fixed it though. Looks like you can just put that code anywhere in your project. Try |
Adding it directly to
Creating a separate |
I may have found the problem and a solution: In let host = cpal::default_host();
let device = host.default_output_device().unwrap();
let config: cpal::StreamConfig = device.default_output_config().unwrap().into(); You do: let host = cpal::default_host();
let device = host.default_output_device().unwrap();
let config = cpal::StreamConfig {
channels: 1,
sample_rate: cpal::SampleRate(48000),
buffer_size: cpal::BufferSize::Default,
}; |
Thank you guys very much. This helped me a lot. |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new issue. |
Describe the bug
Hi there,
(I'm new to both flutter and rust so this will likely just be user error.)
I set up the project from the template (main) and everything works fine.
My intention was to use the crate cpal to get a callback for audio input.
-> added it to Cargo.toml (
cargo add cpal
)At this stage everything still works, but as soon as I add
to
api.rs
I get the folling error:Codegen logs with
RUST_LOG=debug
environment variableTo Reproduce
No response
Expected behavior
No response
Generated binding code
No response
OS
MacOS
Version of
flutter_rust_bridge_codegen
1.63.1
Flutter info
Version of
clang++
14.0.0 (clang-1400.0.29.202)
Version of
ffigen
ffigen: ^7.2.5
Additional context
No response
The text was updated successfully, but these errors were encountered: