Rust-Rust portaudio: rust-portaudio — PortAudio bindings

rust-portaudio Build Status Crates.io Crates.io

PortAudio bindings and wrappers for Rust.

PortAudio is a free, cross-platform, open-source, audio I/O library.

rust-portaudio is still under development, so there may be bugs - please feel free to add an issue or even better, submit a PR!

To use rust-portaudio in your own project, add it to your Cargo.toml dependencies like so:

[dependencies]
portaudio = "X.Y.Z"

Installation

rust-portaudio will try to detect portaudio on your system and, failing that (or if given the PORTAUDIO_ONLY_STATIC environment variable on the build process), will download and build portaudio statically. If this fails please let us know! In the mean-time, you can manually download and install PortAudio yourself.

On Mac OS X, you may need to install manually portaudio and pkg-config (using brew, run brew install portaudio and brew install pkg-config)

rust-portaudio is built using cargo, so just type cargo build at the root of the rust-portaudio repository.

You can build the tests and examples with cargo test, and the documentation with cargo doc.

Comments

  • example record to wav
    example record to wav

    May 23, 2018

    use portaudio for hw access use hound::WavWriter for encoding stream to wav

    Reply
  • Missing dependency on portaudio dev files
    Missing dependency on portaudio dev files

    Oct 14, 2018

    Portaudio was installed by cargo while building RustAudio synth. It produced a linker error, which I traced back to portaudio. Building portaudio requires the Ubuntu package portaudio19-dev to be installed first.

    OS is Ubuntu-derived 16.04LTS.

    I'm new to Rust and Cargo, and not aware of how cargo resolves or detects these dependencies, or if it is able to. If possible, a more comprehensible explanation of the error would be nice, rather than about 80 'undefined reference' messages. Better still, suggest (or even install) the package! :)

    Reply
  • Looking for Maintainers
    Looking for Maintainers

    Jun 7, 2019

    Hi all!

    I no longer have the time or motivation to manage the rust-portaudio crate. These days, most of my efforts have been going into CPAL - a pure-Rust alternative. As a result, I find it difficult to prioritise issues and PRs here.

    If anyone would like to step in as the maintainer for the crate they would be more than welcome. I'd be happy to add them as an administrator to the RustAudio organisation if they are not already so.

    Reply
  • Solution for build issue on OS X
    Solution for build issue on OS X

    Sep 25, 2019

    I experienced an issue where portaudio is not detected during the build process (even if pkgconfig and portaudio), which results in an attempt to build portaudio, which fails on systems with newer versions of xcode installed. Having been chasing myself around in circles for a few hours, I have determined that the issue was that PKG_CONFIG_PATH was not properly set, meaning that pkgconfig could not find the version of portaudio installed by brew. This problem was solved by setting PKG_CONFIG_PATH=/usr/local/lib/pkgconfig. It might be useful to either set this in the build script, or to mention it as a solution in the documentation.

    Reply
  • Callback does not time correctly
    Callback does not time correctly

    Nov 5, 2019

    As found in RustAudio/synth -> https://github.com/RustAudio/synth/issues/50

    At this line of the example whenever a synth is started sounds never stop playing as the time and the counter do not flow:

    TIMER >>>>>>>> 0.0
    TIME >>>>>>> OutputCallbackTimeInfo { current: 0.0, buffer_dac: 0.0016780045351473924 }
    TIMER >>>>>>>> 0.0
    TIME >>>>>>> OutputCallbackTimeInfo { current: 0.0, buffer_dac: 0.00022675736961451248 }
    TIMER >>>>>>>> 0.0
    TIME >>>>>>> OutputCallbackTimeInfo { current: 0.0, buffer_dac: 0.0016780045351473924 }
    TIMER >>>>>>>> 0.0
    TIME >>>>>>> OutputCallbackTimeInfo { current: 0.0, buffer_dac: 0.00022675736961451248 }
    TIMER >>>>>>>> 0.0
    TIME >>>>>>> OutputCallbackTimeInfo { current: 0.0, buffer_dac: 0.0016780045351473924 }
    TIMER >>>>>>>> 0.0
    TIME >>>>>>> OutputCallbackTimeInfo { current: 0.0, buffer_dac: 0.00022675736961451248 }
    TIMER >>>>>>>> 0.0
    TIME >>>>>>> OutputCallbackTimeInfo { current: 0.0, buffer_dac: 0.0016780045351473924 }
    TIMER >>>>>>>> 0.0
    TIME >>>>>>> OutputCallbackTimeInfo { current: 0.0, buffer_dac: 0.00022675736961451248 }
    TIMER >>>>>>>> 0.0
    TIME >>>>>>> OutputCallbackTimeInfo { current: 0.0, buffer_dac: 0.0016780045351473924 }
    TIMER >>>>>>>> 0.0
    
    Reply
  • Huge output gaps in duplex mode
    Huge output gaps in duplex mode

    May 3, 2020

    When using duplex mode, I'm getting serious gaps in the audio output. This is in release mode, and even if I increase the frames per buffer to buffers sizes corresponding to multiple seconds, there are gaps between the buffers. The gaps are approximate 1 sec long. A minimal example to reproduce looks like this:

    use std::io;
    use portaudio as pa;
    
    const CHANNELS: i32 = 2;
    const SAMPLE_RATE: f64 = 44_100.0;
    const FRAMES_PER_BUFFER: u32 = 1024;
    
    fn main() {
        run().unwrap()
    }
    
    fn run() -> Result<(), pa::Error> {
        let pa = pa::PortAudio::new()?;
    
        let mut settings = pa.default_duplex_stream_settings(
            CHANNELS,
            CHANNELS,
            SAMPLE_RATE,
            FRAMES_PER_BUFFER,
        )?;
        settings.flags = pa::stream_flags::CLIP_OFF;
    
        let callback = move |pa::DuplexStreamCallbackArgs { in_buffer, out_buffer, frames, time, .. }: pa::DuplexStreamCallbackArgs<f32, f32>| {
            for i in 0 .. out_buffer.len() {
                out_buffer[i] = ((i * 2 % 1000) - 500) as f32 / 1000.0;
            }
            pa::Continue
        };
    
        // Start stream
        let mut stream = pa.open_non_blocking_stream(settings, callback)?;
        stream.start()?;
    
        // Wait for user input to quit
        println!("Press enter/return to quit...");
        let mut user_input = String::new();
        io::stdin().read_line(&mut user_input).ok();
    
        stream.stop()?;
        stream.close()?;
    
        Ok(())
    }
    

    I can run the same example in other languages just fine, which indicates it is a problem in the Rust binding themselves.

    The non-duplex variant using default_output_stream_settings also runs fine.

    Reply
  • Change Stream to hold a generic reference to PortAudio
    Change Stream to hold a generic reference to PortAudio

    Jan 18, 2016

    Currently Stream requires a &'a PortAudio. This prevents placing both into the same structure. Perhaps this relationship could be changed such that Stream requires a T where T: Deref<PortAudio> such that you could use an Rc<PortAudio> instead, allowing greater flexibility when structuring code.

    Reply
  • Rust-portaudio crashes (doesn't panic) with
    Rust-portaudio crashes (doesn't panic) with "signal 11"

    Mar 6, 2015

    I started a project that uses rust-portaudio. The example provided in this repo seems to work, but when I try to generate and play a generated sound wave by myself, I run all kinds of strange phenomena.

    My code is in https://github.com/golddranks/ongen

    First of all, trying to pass it just a buffer of zeros, it emits loud buzzing noise. (With buffer of 0.00s, it should be just silent, right?) I thought this was maybe problem in latency and the output stream was starving, and thus producing clicks whenever the buffer was consumed and a new buffer was provided. I set the latency looser, default_high_output_latency, with no audible difference.

    Then I tried to set the frames_per_buffer value higher. Originally I had it in 256 like in the example. Changing the buffer size to 512 produced audible difference, but still just noise, all together. When I set it to 1024, Portaudio started crashing, not panicking in Rust-style but like this: Process didn't exit successfully:target/ongen(signal: 11)

    Do you have any idea how to fix these issues? It is surely the C library side that crashes with "signal 11"? Is buffer of 1024 outrageous in size? Any idea how to fix the buzzing?

    Running on OS X, rustc 1.0.0-nightly (3b3bb0e68 2015-03-04) (built 2015-03-04),

    PortAudio host name : Core Audio
    Default output device name : Built-in Output
    
    Reply
  • Issues with running Linux ALSA stream
    Issues with running Linux ALSA stream

    Apr 17, 2015

    @niclashoyer has been running into issues with rust-portaudio on Linux. The blocking stream immediately underruns and breaks from the loop, while the non-blocking stream shows some warning messages however seems to run fine. Perhaps we are missing some platform specific ALSA implementation? @jeremyletang any ideas? Do you test on linux?

    blocking.rs output

    PortAudio version : 1899
    PortAudio version text : PortAudio V19-devel (built Aug 18 2014 05:50:44)
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
    ALSA lib pcm_route.c:947:(find_matching_chmap) Found no matching channel map
    ALSA lib pcm_route.c:947:(find_matching_chmap) Found no matching channel map
    Cannot connect to server socket err = No such file or directory
    Cannot connect to server request channel
    jack server is not running or cannot be started
    Successfully initialized PortAudio
    PortAudio host count : 2
    PortAudio default host : 0
    PortAudio host name : ALSA
    PortAudio type id : -9979
    Default input device info :
        version : 2
        name : default
        max input channels : 32
        max output channels : 32
        default sample rate : 44100
    Default output device name : default
    Successfully opened the stream.
    Successfully started the stream.
    Read stream available with 96 frames.
    Write stream available with 768 frames.
    Read stream available with 120 frames.
    ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred
    Write stream available with 768 frames.
    An error occurred while writing to the output stream: The output stream has overflowed
    Successfully closed the stream.
    
    Successfully terminated PortAudio.
    

    non_blocking.rs output

    PortAudio version : 1899
    PortAudio version text : PortAudio V19-devel (built Aug 18 2014 05:50:44)
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
    ALSA lib pcm_route.c:947:(find_matching_chmap) Found no matching channel map
    ALSA lib pcm_route.c:947:(find_matching_chmap) Found no matching channel map
    Cannot connect to server socket err = No such file or directory
    Cannot connect to server request channel
    jack server is not running or cannot be started
    Successfully initialized PortAudio
    PortAudio host count : 2
    PortAudio default host : 0
    PortAudio host name : ALSA
    PortAudio type id : -9979
    Default input device info :
        version : 2
        name : default
        max input channels : 32
        max output channels : 32
        default sample rate : 44100
    Default output device name : default
    Successfully opened the stream.
    Successfully started the stream.
    

    Original issue was raised here.

    Reply
  • Occasional Runtime SIGSEGV, Segmentation fault when using a non-blocking Stream
    Occasional Runtime SIGSEGV, Segmentation fault when using a non-blocking Stream

    May 25, 2015

    This issue hasn't shown itself in any of the tests in the rust-portaudio, sound_stream, dsp-chain or synth crates, however it has appeared when trying to instantiate a non-blocking stream while following it immediately with a gl window event loop (using piston_window to be precise).

    The problem disappears if the event polling is removed (i.e. for event in window {}).

    @bvssvni mentioned the possibility of alignment issues - it could be worth looking into this.

    Here is the backtrace provided by gdb when the segfault is hit:

    Program received signal SIGSEGV, Segmentation fault.
    [Switching to Thread 0x170b of process 12317]
    0x0000000100035cef in extern$u20$$u22$rust.call$u22$$u20$fn$LP$$RF$mut$u20$for$LT$$u27$r$C$$u27$r$C$$u27$r$GT$$u20$core..ops..FnMut$LP$$RF$$u27$r$u20$$u5b$f32$u5d$$C$$u20$$RF$$u27$r$u20$mut$u20$$u5b$f32$u5d$$C$$u20$u32$C$$u20
    $$RF$$u27$r$u20$portaudio..pa..types..StreamCallbackTimeInfo$C$$u20$portaudio..pa..types..stream_callback_flags..StreamCallbackFlags$RP$$u20$.$GT$$u20$portaudio..pa..types..StreamCallbackResult$C$$u20$$LP$$RF$$u27$static$u20$
    $u5b$f32$u5d$$C$$u20$$RF$$u27$static$u20$mut$u20$$u5b$f32$u5d$$C$$u20$u32$C$$u20$$RF$$u27$static$u20$portaudio..pa..types..StreamCallbackTimeInfo$C$$u20$portaudio..pa..types..stream_callback_flags..StreamCallbackFlags$RP$$RP$
    $u20$.$GT$$u20$portaudio..pa..types..StreamCallbackResult::object_shim.7671::h696b92cd3d5f10da ()                                                                                                                                
    
    (gdb) backtrace                                                                                                                                                                                                                  
    
    #0  0x0000000100035cef in extern$u20$$u22$rust.call$u22$$u20$fn$LP$$RF$mut$u20$for$LT$$u27$r$C$$u27$r$C$$u27$r$GT$$u20$core..ops..FnMut$LP$$RF$$u27$r$u20$$u5b$f32$u5d$$C$$u20$$RF$$u27$r$u20$mut$u20$$u5b$f32$u5d$$C$$u20$u32$C$
    $u20$$RF$$u27$r$u20$portaudio..pa..types..StreamCallbackTimeInfo$C$$u20$portaudio..pa..types..stream_callback_flags..StreamCallbackFlags$RP$$u20$.$GT$$u20$portaudio..pa..types..StreamCallbackResult$C$$u20$$LP$$RF$$u27$static$
    u20$$u5b$f32$u5d$$C$$u20$$RF$$u27$static$u20$mut$u20$$u5b$f32$u5d$$C$$u20$u32$C$$u20$$RF$$u27$static$u20$portaudio..pa..types..StreamCallbackTimeInfo$C$$u20$portaudio..pa..types..stream_callback_flags..StreamCallbackFlags$RP$
    $RP$$u20$.$GT$$u20$portaudio..pa..types..StreamCallbackResult::object_shim.7671::h696b92cd3d5f10da ()                                                                                                                            
    #1  0x0000000100035a22 in fnfn (input=0x0, output=0x102c608d0, frame_count=64, time_info=0x10b7936d0, flags=0) at /Users/Mitch/Programming/Rust/rust-portaudio/src/pa/mod.rs:360                                                 
    #2  0x000000010020d292 in extern$u20$$u22$rust.call$u22$$u20$fn$LP$$RF$mut$u20$core..ops..FnMut$LP$$BP$const$u20$libc..types..common..c95..c_void$C$$u20$$BP$mut$u20$libc..types..common..c95..c_void$C$$u20$u64$C$$u20$$BP$const
    $u20$pa..types..StreamCallbackTimeInfo$C$$u20$u64$RP$$u20$.$GT$$u20$pa..types..StreamCallbackResult$C$$u20$$LP$$BP$const$u20$libc..types..common..c95..c_void$C$$u20$$BP$mut$u20$libc..types..common..c95..c_void$C$$u20$u64$C$$u
    20$$BP$const$u20$pa..types..StreamCallbackTimeInfo$C$$u20$u64$RP$$RP$$u20$.$GT$$u20$pa..types..StreamCallbackResult::object_shim.7462::h90ce1a85a735cc1d ()                                                                      
    #3  0x000000010020d248 in portaudio::pa::stream_callback_proc (input=0x0, output=0x102c608d0, frame_count=64, time_info=0x10b7936d0, flags=0, user_callback=0x101830120)                                                         
        at /Users/Mitch/Programming/Rust/rust-portaudio/src/pa/mod.rs:765                                                                                                                                                            
    #4  0x000000010020d1b2 in pa::stream_callback_proc::hadfcdc53593a76e60hd ()                                                                                                                                                      
    #5  0x0000000100660f6b in ?? ()                                                                                                                                                                                                  
    #6  0x000000010b7936cc in ?? ()                                                                                                                                                                                                  
    #7  0x0000000000000000 in ?? ()                                                                                                                                                                                                  
    Warning: the current language does not match this frame.                                                                                                                                                                         
    
    Reply
  • Callback function never called - arm
    Callback function never called - arm

    Mar 4, 2016

    I'm working on getting rust-portaudio to work on my bananapi. On the bananapi I want to ignore the builtin audio devices and use a USB soundblaster instead. I'm able to specify that device using a device index, but I get a lot of error messages concerning the builtin audio device. The results is I don't hear any audio. I'm not sure what the cause might be, though the error messages look suspicious. PortAudio doesn't seem to be too happy.

    FWIW, I am able to play audio through the soundblaster using other sound sources on that computer. aplay works, as does supercollider running through jack1.

    Output from my test program is below. (portaudio startup is at line 89 in my test program).

    initting with sample rate: 44100
    add_elem(ui_elem_type_t type, char *label) 0x00
    add_elem(ui_elem_type_t type, char *label) Volume
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.front.0:CARD=0'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM front
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.surround51.0:CARD=0'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM surround21
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.surround51.0:CARD=0'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM surround21
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.surround40.0:CARD=0'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM surround40
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.surround51.0:CARD=0'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM surround41
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.surround51.0:CARD=0'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM surround50
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.surround51.0:CARD=0'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM surround51
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.surround71.0:CARD=0'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM surround71
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM iec958
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM spdif
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM spdif
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
    ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused
    
    ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused
    
    connect(2) call to /dev/shm/jack-1000/default/jack_0 failed (err=No such file or directory)
    attempt to connect to server failed
    --------------------------------------- DeviceIndex(1)
    DeviceInfo {
        struct_version: 2,
        name: "Sound Blaster X-Fi Go! Pro: USB Audio (hw:1,0)",
        host_api: 0,
        max_input_channels: 2,
        max_output_channels: 2,
        default_low_input_latency: 0.008684807256235827,
        default_low_output_latency: 0.008707482993197279,
        default_high_input_latency: 0.034829931972789115,
        default_high_output_latency: 0.034829931972789115,
        default_sample_rate: 44100
    }
    Supported standard sample rates for half-duplex 16-bit 2 channel input:
        44100hz
    Supported standard sample rates for half-duplex 16-bit 2 channel output:
        44100hz
    Supported standard sample rates for full-duplex 16-bit 2 channel input, 2 channel output:
        44100hz
    

    And here's output from the 'devices.rs' example:

    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.front.0:CARD=0'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM front
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.surround51.0:CARD=0'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM surround21
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.surround51.0:CARD=0'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM surround21
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.surround40.0:CARD=0'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM surround40
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.surround51.0:CARD=0'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM surround41
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.surround51.0:CARD=0'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM surround50
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.surround51.0:CARD=0'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM surround51
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.surround71.0:CARD=0'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM surround71
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM iec958
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM spdif
    ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.sunxi-CODEC.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'
    ALSA lib conf.c:4260:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib conf.c:4739:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM spdif
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
    ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
    ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused
    
    ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused
    
    connect(2) call to /dev/shm/jack-1000/default/jack_0 failed (err=No such file or directory)
    attempt to connect to server failed
    Number of devices = 7
    --------------------------------------- DeviceIndex(0)
    DeviceInfo {
        struct_version: 2,
        name: "sunxi-CODEC: PCM (hw:0,0)",
        host_api: 0,
        max_input_channels: 2,
        max_output_channels: 2,
        default_low_input_latency: 0.06965986394557823,
        default_low_output_latency: 0.06965986394557823,
        default_high_input_latency: 0.06965986394557823,
        default_high_output_latency: 0.06965986394557823,
        default_sample_rate: 44100
    }
    Supported standard sample rates for half-duplex 16-bit 2 channel input:
        8000hz
        11025hz
        12000hz
        16000hz
        22050hz
        24000hz
        32000hz
        44100hz
        48000hz
        96000hz
        192000hz
    Supported standard sample rates for half-duplex 16-bit 2 channel output:
        8000hz
        11025hz
        12000hz
        16000hz
        22050hz
        24000hz
        32000hz
        44100hz
        48000hz
        96000hz
        192000hz
    Supported standard sample rates for full-duplex 16-bit 2 channel input, 2 channel output:
        8000hz
        11025hz
        12000hz
        16000hz
        22050hz
        24000hz
        32000hz
        44100hz
        48000hz
        96000hz
        192000hz
    --------------------------------------- DeviceIndex(1)
    DeviceInfo {
        struct_version: 2,
        name: "Sound Blaster X-Fi Go! Pro: USB Audio (hw:1,0)",
        host_api: 0,
        max_input_channels: 2,
        max_output_channels: 2,
        default_low_input_latency: 0.008684807256235827,
        default_low_output_latency: 0.008707482993197279,
        default_high_input_latency: 0.034829931972789115,
        default_high_output_latency: 0.034829931972789115,
        default_sample_rate: 44100
    }
    Supported standard sample rates for half-duplex 16-bit 2 channel input:
        44100hz
    Supported standard sample rates for half-duplex 16-bit 2 channel output:
        44100hz
    Supported standard sample rates for full-duplex 16-bit 2 channel input, 2 channel output:
        44100hz
    --------------------------------------- DeviceIndex(2)
    DeviceInfo {
        struct_version: 2,
        name: "sysdefault",
        host_api: 0,
        max_input_channels: 128,
        max_output_channels: 128,
        default_low_input_latency: 0.06965986394557823,
        default_low_output_latency: 0.06965986394557823,
        default_high_input_latency: 0.06965986394557823,
        default_high_output_latency: 0.06965986394557823,
        default_sample_rate: 44100
    }
    Supported standard sample rates for half-duplex 16-bit 128 channel input:
        8000hz
        9600hz
        11025hz
        12000hz
        16000hz
        22050hz
        24000hz
        32000hz
        44100hz
        48000hz
        88200hz
        96000hz
        192000hz
    Supported standard sample rates for half-duplex 16-bit 128 channel output:
        8000hz
        9600hz
        11025hz
        12000hz
        16000hz
        22050hz
        24000hz
        32000hz
        44100hz
        48000hz
        88200hz
        96000hz
        192000hz
    Supported standard sample rates for full-duplex 16-bit 128 channel input, 128 channel output:
        8000hz
        9600hz
        11025hz
        12000hz
        16000hz
        22050hz
        24000hz
        32000hz
        44100hz
        48000hz
        88200hz
        96000hz
        192000hz
    --------------------------------------- DeviceIndex(3)
    DeviceInfo {
        struct_version: 2,
        name: "default",
        host_api: 0,
        max_input_channels: 128,
        max_output_channels: 128,
        default_low_input_latency: 0.06965986394557823,
        default_low_output_latency: 0.06965986394557823,
        default_high_input_latency: 0.06965986394557823,
        default_high_output_latency: 0.06965986394557823,
        default_sample_rate: 44100
    }
    Supported standard sample rates for half-duplex 16-bit 128 channel input:
        8000hz
        9600hz
        11025hz
        12000hz
        16000hz
        22050hz
        24000hz
        32000hz
        44100hz
        48000hz
        88200hz
        96000hz
        192000hz
    Supported standard sample rates for half-duplex 16-bit 128 channel output:
        8000hz
        9600hz
        11025hz
        12000hz
        16000hz
        22050hz
        24000hz
        32000hz
        44100hz
        48000hz
        88200hz
        96000hz
        192000hz
    Supported standard sample rates for full-duplex 16-bit 128 channel input, 128 channel output:
        8000hz
        9600hz
        11025hz
        12000hz
        16000hz
        22050hz
        24000hz
        32000hz
        44100hz
        48000hz
        88200hz
        96000hz
        192000hz
    --------------------------------------- DeviceIndex(4)
    DeviceInfo {
        struct_version: 2,
        name: "dmix",
        host_api: 0,
        max_input_channels: 0,
        max_output_channels: 2,
        default_low_input_latency: -1,
        default_low_output_latency: 0.021333333333333333,
        default_high_input_latency: -1,
        default_high_output_latency: 0.021333333333333333,
        default_sample_rate: 48000
    }
    Supported standard sample rates for half-duplex 16-bit 0 channel input:
    Supported standard sample rates for half-duplex 16-bit 2 channel output:
        48000hz
    Supported standard sample rates for full-duplex 16-bit 0 channel input, 2 channel output:
    --------------------------------------- DeviceIndex(5)
    DeviceInfo {
        struct_version: 2,
        name: "/dev/dsp",
        host_api: 1,
        max_input_channels: 16,
        max_output_channels: 16,
        default_low_input_latency: 0.008707482993197279,
        default_low_output_latency: 0.008707482993197279,
        default_high_input_latency: 0.034829931972789115,
        default_high_output_latency: 0.034829931972789115,
        default_sample_rate: 44100
    }
    Supported standard sample rates for half-duplex 16-bit 16 channel input:
    Supported standard sample rates for half-duplex 16-bit 16 channel output:
    Supported standard sample rates for full-duplex 16-bit 16 channel input, 16 channel output:
    --------------------------------------- DeviceIndex(6)
    DeviceInfo {
        struct_version: 2,
        name: "/dev/dsp1",
        host_api: 1,
        max_input_channels: 16,
        max_output_channels: 16,
        default_low_input_latency: 0.008707482993197279,
        default_low_output_latency: 0.008707482993197279,
        default_high_input_latency: 0.034829931972789115,
        default_high_output_latency: 0.034829931972789115,
        default_sample_rate: 44100
    }
    Supported standard sample rates for half-duplex 16-bit 16 channel input:
    Supported standard sample rates for half-duplex 16-bit 16 channel output:
    Supported standard sample rates for full-duplex 16-bit 16 channel input, 16 channel output:
    
    bug 
    Reply
  • Implement / bind non-blocking API (portaudio callback)
    Implement / bind non-blocking API (portaudio callback)

    Nov 19, 2014

    Portaudio provide a non-blocking API using callback function which is called each time some new data are coming. For now this functionality is not implemented in rust-portaudio as a user can do the same thing using a rust task and calling the blocking api inside of it. Maybe we can bind this functionality too as the native implementation is probably more effective.

    Reply