Implement WASAPI loopback support#339
Conversation
|
Tested with: diff --git a/examples/record_wav.rs b/examples/record_wav.rs
index 9127123..01f7c2d 100644
--- a/examples/record_wav.rs
+++ b/examples/record_wav.rs
@@ -13,9 +13,9 @@ fn main() -> Result<(), failure::Error> {
let host = cpal::default_host();
// Setup the default input device and stream with the default input format.
- let device = host.default_input_device().expect("Failed to get default input device");
+ let device = host.default_output_device().expect("Failed to get default input device");
println!("Default input device: {}", device.name()?);
- let format = device.default_input_format().expect("Failed to get default input format");
+ let format = device.default_output_format().expect("Failed to get default input format");
println!("Default input format: {:?}", format);
let event_loop = host.event_loop();
let stream_id = event_loop.build_input_stream(&device, &format)?;
|
|
I think this is okay, but the current API design makes it a very hidden feature. Would you like to add some docs? Though I think we might change the Device API to differ between input and output devices, someday. At that time we might need to add a Windows-specific function to convert an output to "loopback" input. |
|
What's a good place to document this? |
|
I think you can document it as a part of |
This works by detecting output devices in build_input_stream() and setting the AUDCLNT_STREAMFLAGS_LOOPBACK flag to enable loopback recording. closes RustAudio#251
|
Is there a way I can help push this forward? I have a project here, that would really benefit from this being merged. I currently have a vendored version of cpal with hacked together loopback support, it would be awesome if I could use a upstream version. |
|
Merging as per @ishitatsuyuki 's approval, there seem to be docs now. |
|
Awesome! Thank y'all for the continued work on cpal! |
|
Is there any document or example about how to use loopback in RustAudio/cpal? |
|
It used to be as simple as just creating an input stream and sticking that into your output stream. The cpal API changed tho and I didn't had the time to wrap my head around it so I can't provide example code. But I guess the general idea didn't change here, just the function names. |
This works by detecting output devices in build_input_stream() and
setting the AUDCLNT_STREAMFLAGS_LOOPBACK flag to enable loopback
recording.
closes #251