Giter Site home page Giter Site logo

rust-portaudio's People

Contributors

01d55 avatar amilajack avatar atul9 avatar bvssvni avatar cdghibaudo avatar clicketyclack avatar cramertj avatar cyndis avatar dansgithubuser avatar ebfe avatar euclio avatar filmor avatar hughrawlinson avatar jeremyletang avatar jworthe avatar kellydunn avatar kevinji avatar kryptan avatar limeburst avatar mitchmindtree avatar niclashoyer avatar paulirotta avatar rap2hpoutre avatar renato-zannon avatar rryan avatar tafia avatar thenyeguy avatar victor-shepardson avatar wmedrano avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rust-portaudio's Issues

Switch to Rust-Empty?

Rust-Empty is a Makefile that builds to the same target directory as the Cargo package manager. We use it in the Piston infrastructure.

The only difference will be that it builds to 'target/cpu-vendor-os/lib' directory.

Build fails on OS X 10.10.2

Hi,

I've installed last version of rust (1.0.0-nightly (b9ba643b7 2015-02-13 21:15:39 +0000)), and I have installed portaudio library using:

brew install portaudio

But when I launch cargo build I get the following errors:

   Compiling rust-portaudio v0.3.0 (file:///Users/KillKRT/Documents/Development/rust-portaudio)
error: linking with `cc` failed: exit code: 1
note: "cc" '"-m64"' '"-L"' '"/usr/local/lib/rustlib/x86_64-apple-darwin/lib"' '"-o"' '"/Users/KillKRT/Documents/Development/rust-portaudio/target/libportaudio-78d086cfbedfdb92.dylib"' '"/Users/KillKRT/Documents/Development/rust-portaudio/target/portaudio-78d086cfbedfdb92.o"' '"-Wl,-force_load,/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libmorestack.a"' '"/Users/KillKRT/Documents/Development/rust-portaudio/target/portaudio-78d086cfbedfdb92.metadata.o"' '"-Wl,-dead_strip"' '"-nodefaultlibs"' '"/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libstd-4e7c5e5c.rlib"' '"/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libcollections-4e7c5e5c.rlib"' '"/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libunicode-4e7c5e5c.rlib"' '"/usr/local/lib/rustlib/x86_64-apple-darwin/lib/librand-4e7c5e5c.rlib"' '"/usr/local/lib/rustlib/x86_64-apple-darwin/lib/liballoc-4e7c5e5c.rlib"' '"/usr/local/lib/rustlib/x86_64-apple-darwin/lib/liblibc-4e7c5e5c.rlib"' '"/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libcore-4e7c5e5c.rlib"' '"-L"' '"/Users/KillKRT/Documents/Development/rust-portaudio/target"' '"-L"' '"/Users/KillKRT/Documents/Development/rust-portaudio/target/deps"' '"-L"' '"/usr/local/lib/rustlib/x86_64-apple-darwin/lib"' '"-L"' '"/Users/KillKRT/Documents/Development/rust-portaudio/.rust/lib/x86_64-apple-darwin"' '"-L"' '"/Users/KillKRT/Documents/Development/rust-portaudio/lib/x86_64-apple-darwin"' '"-lportaudio"' '"-lSystem"' '"-lpthread"' '"-lc"' '"-lm"' '"-dynamiclib"' '"-Wl,-dylib"' '"-lcompiler-rt"'
note: ld: warning: directory not found for option '-L/Users/KillKRT/Documents/Development/rust-portaudio/.rust/lib/x86_64-apple-darwin'
ld: warning: directory not found for option '-L/Users/KillKRT/Documents/Development/rust-portaudio/lib/x86_64-apple-darwin'
ld: library not found for -lportaudio
clang: error: linker command failed with exit code 1 (use -v to see invocation)

error: aborting due to previous error
Could not compile `rust-portaudio`.

Cargo unnecessarily re-compiles rust-portaudio crate even when unchanged.

I have a few separate crates that depend on rust-portaudio. About 75% the time I cargo build, cargo re-compiles rust-portaudio (and in turn everything that depends on it) even though it hasn't changed since the last build.

I'm unsure why this would happen - going to do some research as it slows down the dev process quite a lot. Any ideas on why this is occurring or links to pre-existing issues in other crates would be greatly appreciated!

Both blocking and non-blocking examples use 100% CPU

When I run the two streaming programs from the examples directory, they take 100% of the CPU. When I limit it to just reading the input, the same happens, and it seems the main loop just gets 0 bytes and keeps looping like mad until finally a full buffer arrives. Is that a problem in rust-portaudio or in the lower portaudio library?

Callback function never called - arm

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:

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

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.                                                                                                                                                                         

Implement / bind non-blocking API (portaudio callback)

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.

Relicense under dual MIT/Apache-2.0

Why?

The MIT license requires reproducing countless copies of the same copyright
header with different names in the copyright field, for every MIT library in
use. The Apache license does not have this drawback, and has protections from
patent trolls and an explicit contribution licensing clause. However, the
Apache license is incompatible with GPLv2. This is why Rust is dual-licensed as
MIT/Apache (the "primary" license being Apache, MIT only for GPLv2 compat), and
doing so would be wise for this project. This also makes this crate suitable
for inclusion in the Rust standard distribution and other project using dual
MIT/Apache.

How?

To do this, get explicit approval from each contributor of copyrightable work
(as not all contributions qualify for copyright) and then add the following to
your README:

## License

Licensed under either of
 * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
 * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
at your option.

### Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you shall be dual licensed as above, without any
additional terms or conditions.

and in your license headers, use the following boilerplate (based on that used in Rust):

// Copyright (c) 2015 t developers
// Licensed under the Apache License, Version 2.0
// <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT
// license <LICENSE-MIT or http://opensource.org/licenses/MIT>,
// at your option. All files in the project carrying such
// notice may not be copied, modified, or distributed except
// according to those terms.

And don't forget to update the license metadata in your Cargo.toml!

Contributor checkoff

Finish implementing remaining stuff

I've noticed that there are bits and pieces around the place that don't seem to be fully implemented - if you get a chance to add all the remaining-stuff-to-do to the issues, I'd be happy to chip away at them when I have the time. It'd be nice to make this the go-to, solid, thorough PA binding :)

Change Stream type parameter

For now, the Stream stuck is parameterize over only one type. But maybe the input type can be different of the output type. Moreover, this type can be anything, so I think we should implement a internal trait on each possible SampleFormat, (f32, i32, u8, i8) which constraint the instantiation of the stream struct to these types. The only problem is that i'm not sure how we should handle the two others sample format with this technique (CustomFormat, NonInterleaved).

@mitchmindtree any thought ?

Change Stream to hold a generic reference to PortAudio

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.

Mention dependency on wget for download

Build failed for me on OS X 10.10 without useful information (see below). Reading the build.rs I saw that wget was used and not installed. (brew install wget solves that.)


failed to run custom build command for `portaudio v0.3.1`
Process didn't exit successfully: `/Users/pascal/Projekte/tools/synth/target/release/build/portaudio-372af45747eb377c/build-script-build` (exit code: 101)
--- stderr
thread '<main>' panicked at 'no such file or directory', /Users/pascal/.cargo/registry/src/github.com-1ecc6299db9ec823/portaudio-0.3.1/build.rs:72

Linking error on latest rust "error: linking with `cc` failed: exit code: 1"

Really not sure why this has appeared all of a sudden, but it's appearing on both travis and my local machine.

   Compiling portaudio v0.4.9 (file:///Users/Mitch/Programming/Rust/rust-portaudio)
error: linking with `cc` failed: exit code: 1
note: "cc" "-m64" "-L" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib" "-o" "/Users/Mitch/Programming/Rust/rust-portaudio/target/debug/examples/non_blocking" "/Users/Mitch/Programming/Rust/rust-portaudio/target/debug/examples/non_blocking.o" "-Wl,-force_load,/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libmorestack.a" "-Wl,-dead_strip" "-nodefaultlibs" "/Users/Mitch/Programming/Rust/rust-portaudio/target/debug/libportaudio.rlib" "/Users/Mitch/Programming/Rust/rust-portaudio/target/debug/deps/libnum-b6664aad0573bf89.rlib" "/Users/Mitch/Programming/Rust/rust-portaudio/target/debug/deps/librustc_serialize-9ef26f158d5284e0.rlib" "/Users/Mitch/Programming/Rust/rust-portaudio/target/debug/deps/libbitflags-518ea12e21428edd.rlib" "/Users/Mitch/Programming/Rust/rust-portaudio/target/debug/deps/librand-b924d9fc5b3eb5b8.rlib" "/Users/Mitch/Programming/Rust/rust-portaudio/target/debug/deps/liblibc-674726c388d62fa2.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libstd-4e7c5e5c.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libcollections-4e7c5e5c.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/librustc_unicode-4e7c5e5c.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/librand-4e7c5e5c.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/liballoc-4e7c5e5c.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/liblibc-4e7c5e5c.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libcore-4e7c5e5c.rlib" "-L" "/Users/Mitch/Programming/Rust/rust-portaudio/target/debug" "-L" "/Users/Mitch/Programming/Rust/rust-portaudio/target/debug/deps" "-L" "/usr/local/lib" "-L" "/usr/local/lib" "-L" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib" "-L" "/Users/Mitch/Programming/Rust/rust-portaudio/.rust/lib/x86_64-apple-darwin" "-L" "/Users/Mitch/Programming/Rust/rust-portaudio/lib/x86_64-apple-darwin" "-L" "/Users/Mitch/.rust/lib/x86_64-apple-darwin" "-lportaudio" "-lportaudio" "-framework" "CoreAudio" "-framework" "AudioToolbox" "-framework" "AudioUnit" "-framework" "Carbon" "-lc" "-lm" "-lSystem" "-lpthread" "-lc" "-lm" "-lcompiler-rt"
note: ld: warning: directory not found for option '-L/Users/Mitch/Programming/Rust/rust-portaudio/.rust/lib/x86_64-apple-darwin'
ld: warning: directory not found for option '-L/Users/Mitch/Programming/Rust/rust-portaudio/lib/x86_64-apple-darwin'
Undefined symbols for architecture x86_64:
  "_Pa_IsFormatSupported", referenced from:
      pa::is_format_supported::h1ef3fd3c748d2d7bwUc in libportaudio.rlib(portaudio.o)
  "_Pa_Terminate", referenced from:
      pa::terminate::h856c916ea7636e63ZTc in libportaudio.rlib(portaudio.o)
  "_Pa_GetVersionText", referenced from:
      pa::get_version_text::h1d9d5a55302362ecgTc in libportaudio.rlib(portaudio.o)
  "_Pa_GetDefaultInputDevice", referenced from:
      pa::device::get_default_input::h924f4c1b20bf1a283Qc in libportaudio.rlib(portaudio.o)
  "_Pa_GetHostApiInfo", referenced from:
      pa::host::get_api_info::h2fbcc6a5c8c1e723cSc in libportaudio.rlib(portaudio.o)
  "_Pa_GetDefaultOutputDevice", referenced from:
      pa::device::get_default_output::hed9ab2ede0d6545abRc in libportaudio.rlib(portaudio.o)
  "_Pa_StartStream", referenced from:
      pa::Stream$LT$I$C$$u20$O$GT$::start::h15868907980879137214 in non_blocking.o
  "_Pa_GetDeviceInfo", referenced from:
      pa::device::get_info::h769a764d65668102jRc in libportaudio.rlib(portaudio.o)
  "_Pa_IsStreamActive", referenced from:
      pa::Stream$LT$I$C$$u20$O$GT$::is_active::h16392955518606313780 in non_blocking.o
  "_Pa_Initialize", referenced from:
      pa::initialize::h3439edf44263d4b1GTc in libportaudio.rlib(portaudio.o)
  "_Pa_GetVersion", referenced from:
      pa::get_version::hd1aab81cb90c65618Sc in libportaudio.rlib(portaudio.o)
  "_Pa_GetDefaultHostApi", referenced from:
      pa::host::get_default_api::h27f764f218f6182e4Rc in libportaudio.rlib(portaudio.o)
  "_Pa_CloseStream", referenced from:
      pa::Stream$LT$I$C$$u20$O$GT$::close::h10379566129765308786 in non_blocking.o
  "_Pa_GetHostApiCount", referenced from:
      pa::host::get_api_count::ha9d2e7fee5b02461WRc in libportaudio.rlib(portaudio.o)
  "_Pa_OpenStream", referenced from:
      pa::Stream$LT$I$C$$u20$O$GT$::open::h2200290684482684206 in non_blocking.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

error: aborting due to previous error
Could not compile `portaudio`.

Switch to std::result::Result?

The current API directly exposes the consumer to how PortAudio does error handling: returning special valued integers or C enums. I propose that the rust-portaudio API switch to returning Result, similar to the changes that were accepted in rust-sndfile yesterday. If I get the go ahead, I will create a changeset.

The one project that I've found that uses rust-portaudio currently is rust-dsp. Most of rust-dsp's PortAudio code doesn't have real error handling or graceful failure. Some critical code like its call to PaStream::open() lacks error handling altogether. Using Result in the API would help avoid such situations.

Change return type of `get_stream_read/write_available` to an enum

Just a suggestion - perhaps we can improve the return types of get_stream_read_available and get_stream_write_available by using an enum for each? At the moment they use an i64 to represent multiple states. Maybe something like this would be clearer and more Rusty

pub type NumFrames = u32;
pub enum ReadState {
    Ready(NumFrames),
    Waiting,
}

We could translate the current return using match

match unsafe { ffi::Pa_GetStreamReadAvailable(self.c_pa_stream) } {
    0 => Ok(ReadState::Waiting),
    n if n > 0 => Ok(ReadState::Ready(n as u32)),
    n => Err(WhateverTheMatchingErrorIs),
}

Thoughts?

Runtime error on Arch Linux

FreeFull tried out the portaudio example today and was getting an overflow error. Here's his full output:

freefull@freefull-hp ~/c/o/r/rust-portaudio> cargo run --example main
     Running `target/examples/main`
PortAudio version : 1899
PortAudio version text : PortAudio V19-devel (built Jan 31 2014 21:19:35)
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
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

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
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 : 128
        max output channels : 128
        default sample rate : 48000
Default output device name : default
Successfully opened the stream.
Successfully started the stream.
Read stream available with 940 frames.
Write stream available with 1881 frames.
Read stream available with 684 frames.
Write stream available with 1625 frames.
Read stream available with 428 frames.
Write stream available with 1369 frames.
Read stream available with 172 frames.
Write stream available with 1113 frames.
Read stream available with 856 frames.
Write stream available with 876 frames.
Read stream available with 600 frames.
Write stream available with 634 frames.
Read stream available with 344 frames.
Write stream available with 393 frames.
Read stream available with 88 frames.
Write stream available with 1957 frames.
Read stream available with 1712 frames.
Write stream available with 1701 frames.
Read stream available with 1456 frames.
Write stream available with 1445 frames.
Read stream available with 1200 frames.
Write stream available with 1189 frames.
Read stream available with 944 frames.
Write stream available with 933 frames.
Read stream available with 1628 frames.
Write stream available with 677 frames.
Read stream available with 1372 frames.
Write stream available with 421 frames.
Read stream available with 1116 frames.
Write stream available with 165 frames.
Read stream available with 860 frames.
Write stream available with 1790 frames.
An error occurred while writing to the output stream: The output stream has overflowed
Successfully closed the stream.

Successfully terminated PortAudio.

Perhaps there is still some work we need to do to get things running smoothly on Linux?

Failing build on osx with no prior portaudio installation (rust 1.5 nightly)

My understanding is if I don't have a prior portaudio installation on my system, this build should download it and we're good to go. That doesn't seem to be the case, however. This is my full terminal log from download to build:

macferris:projects yupferris$ git clone [email protected]:jeremyletang/rust-portaudio.git
Cloning into 'rust-portaudio'...
remote: Counting objects: 1174, done.
remote: Total 1174 (delta 0), reused 0 (delta 0), pack-reused 1174
Receiving objects: 100% (1174/1174), 1010.41 KiB | 1.01 MiB/s, done.
Resolving deltas: 100% (691/691), done.
Checking connectivity... done.
macferris:projects yupferris$ cd rust-portaudio/
macferris:rust-portaudio yupferris$ cargo build
    Updating registry `https://github.com/rust-lang/crates.io-index`
   Compiling libc v0.1.10
   Compiling bitflags v0.3.2
   Compiling pkg-config v0.3.6
   Compiling num v0.1.27
   Compiling portaudio v0.4.17 (file:///Users/yupferris/dev/projects/rust-portaudio)
src/pa/mod.rs:368:64: 368:88 warning: the parameter type `O` may not live long enough [E0310]
src/pa/mod.rs:368                 let user_callback = Box::new(UserCallback { f: user_callback_fn_wrapper });
                                                                                 ^~~~~~~~~~~~~~~~~~~~~~~~
src/pa/mod.rs:368:64: 368:88 help: run `rustc --explain E0310` to see a detailed explanation
src/pa/mod.rs:368:64: 368:88 help: consider adding an explicit lifetime bound `O: 'static`...
src/pa/mod.rs:368:64: 368:88 note: this warning results from recent bug fixes and clarifications; it will become a HARD ERROR in the next release. See RFC 1214 for details.
src/pa/mod.rs:368                 let user_callback = Box::new(UserCallback { f: user_callback_fn_wrapper });
                                                                                 ^~~~~~~~~~~~~~~~~~~~~~~~
src/pa/mod.rs:368:64: 368:88 note: ...so that the type `[closure@src/pa/mod.rs:346:57: 367:18 num_input_channels:u32, num_output_channels:u32, callback:Box<for<'r, 'r, 'r> core::ops::FnMut(&'r [I], &'r mut [O], u32, &'r pa::types::StreamCallbackTimeInfo, pa::types::stream_callback_flags::StreamCallbackFlags) -> pa::types::StreamCallbackResult>]` will meet its required lifetime bounds
src/pa/mod.rs:368                 let user_callback = Box::new(UserCallback { f: user_callback_fn_wrapper });
                                                                                 ^~~~~~~~~~~~~~~~~~~~~~~~
src/pa/mod.rs:368:64: 368:88 warning: the parameter type `I` may not live long enough [E0310]
src/pa/mod.rs:368                 let user_callback = Box::new(UserCallback { f: user_callback_fn_wrapper });
                                                                                 ^~~~~~~~~~~~~~~~~~~~~~~~
src/pa/mod.rs:368:64: 368:88 help: run `rustc --explain E0310` to see a detailed explanation
src/pa/mod.rs:368:64: 368:88 help: consider adding an explicit lifetime bound `I: 'static`...
src/pa/mod.rs:368:64: 368:88 note: this warning results from recent bug fixes and clarifications; it will become a HARD ERROR in the next release. See RFC 1214 for details.
src/pa/mod.rs:368                 let user_callback = Box::new(UserCallback { f: user_callback_fn_wrapper });
                                                                                 ^~~~~~~~~~~~~~~~~~~~~~~~
src/pa/mod.rs:368:64: 368:88 note: ...so that the type `[closure@src/pa/mod.rs:346:57: 367:18 num_input_channels:u32, num_output_channels:u32, callback:Box<for<'r, 'r, 'r> core::ops::FnMut(&'r [I], &'r mut [O], u32, &'r pa::types::StreamCallbackTimeInfo, pa::types::stream_callback_flags::StreamCallbackFlags) -> pa::types::StreamCallbackResult>]` will meet its required lifetime bounds
src/pa/mod.rs:368                 let user_callback = Box::new(UserCallback { f: user_callback_fn_wrapper });
                                                                                 ^~~~~~~~~~~~~~~~~~~~~~~~
src/pa/mod.rs:482:64: 482:88 warning: the parameter type `O` may not live long enough [E0310]
src/pa/mod.rs:482                 let user_callback = Box::new(UserCallback { f: user_callback_fn_wrapper });
                                                                                 ^~~~~~~~~~~~~~~~~~~~~~~~
src/pa/mod.rs:482:64: 482:88 help: run `rustc --explain E0310` to see a detailed explanation
src/pa/mod.rs:482:64: 482:88 help: consider adding an explicit lifetime bound `O: 'static`...
src/pa/mod.rs:482:64: 482:88 note: this warning results from recent bug fixes and clarifications; it will become a HARD ERROR in the next release. See RFC 1214 for details.
src/pa/mod.rs:482                 let user_callback = Box::new(UserCallback { f: user_callback_fn_wrapper });
                                                                                 ^~~~~~~~~~~~~~~~~~~~~~~~
src/pa/mod.rs:482:64: 482:88 note: ...so that the type `[closure@src/pa/mod.rs:461:57: 481:18 num_input_channels:i32, num_output_channels:i32, callback:Box<for<'r, 'r, 'r> core::ops::FnMut(&'r [I], &'r mut [O], u32, &'r pa::types::StreamCallbackTimeInfo, pa::types::stream_callback_flags::StreamCallbackFlags) -> pa::types::StreamCallbackResult>]` will meet its required lifetime bounds
src/pa/mod.rs:482                 let user_callback = Box::new(UserCallback { f: user_callback_fn_wrapper });
                                                                                 ^~~~~~~~~~~~~~~~~~~~~~~~
src/pa/mod.rs:482:64: 482:88 warning: the parameter type `I` may not live long enough [E0310]
src/pa/mod.rs:482                 let user_callback = Box::new(UserCallback { f: user_callback_fn_wrapper });
                                                                                 ^~~~~~~~~~~~~~~~~~~~~~~~
src/pa/mod.rs:482:64: 482:88 help: run `rustc --explain E0310` to see a detailed explanation
src/pa/mod.rs:482:64: 482:88 help: consider adding an explicit lifetime bound `I: 'static`...
src/pa/mod.rs:482:64: 482:88 note: this warning results from recent bug fixes and clarifications; it will become a HARD ERROR in the next release. See RFC 1214 for details.
src/pa/mod.rs:482                 let user_callback = Box::new(UserCallback { f: user_callback_fn_wrapper });
                                                                                 ^~~~~~~~~~~~~~~~~~~~~~~~
src/pa/mod.rs:482:64: 482:88 note: ...so that the type `[closure@src/pa/mod.rs:461:57: 481:18 num_input_channels:i32, num_output_channels:i32, callback:Box<for<'r, 'r, 'r> core::ops::FnMut(&'r [I], &'r mut [O], u32, &'r pa::types::StreamCallbackTimeInfo, pa::types::stream_callback_flags::StreamCallbackFlags) -> pa::types::StreamCallbackResult>]` will meet its required lifetime bounds
src/pa/mod.rs:482                 let user_callback = Box::new(UserCallback { f: user_callback_fn_wrapper });
                                                                                 ^~~~~~~~~~~~~~~~~~~~~~~~
<bitflags macros>:7:27: 8:19 warning: missing documentation for a constant
<bitflags macros>:7 $ ( # [ $ Flag_attr ] ) * pub const $ Flag : $ BitFlags = $ BitFlags {
<bitflags macros>:8 bits : $ value } ; ) + impl :: std:: fmt:: Debug for $ BitFlags {
<bitflags macros>:90:1: 92:63 note: in this expansion of bitflags! (defined in <bitflags macros>)
src/pa/types.rs:84:5: 108:6 note: in this expansion of bitflags! (defined in <bitflags macros>)
src/lib.rs:54:9: 54:21 note: lint level defined here
src/lib.rs:54 #![warn(missing_docs)]
                      ^~~~~~~~~~~~
<bitflags macros>:7:27: 8:19 warning: missing documentation for a constant
<bitflags macros>:7 $ ( # [ $ Flag_attr ] ) * pub const $ Flag : $ BitFlags = $ BitFlags {
<bitflags macros>:8 bits : $ value } ; ) + impl :: std:: fmt:: Debug for $ BitFlags {
<bitflags macros>:90:1: 92:63 note: in this expansion of bitflags! (defined in <bitflags macros>)
src/pa/types.rs:84:5: 108:6 note: in this expansion of bitflags! (defined in <bitflags macros>)
src/lib.rs:54:9: 54:21 note: lint level defined here
src/lib.rs:54 #![warn(missing_docs)]
                      ^~~~~~~~~~~~
<bitflags macros>:7:27: 8:19 warning: missing documentation for a constant
<bitflags macros>:7 $ ( # [ $ Flag_attr ] ) * pub const $ Flag : $ BitFlags = $ BitFlags {
<bitflags macros>:8 bits : $ value } ; ) + impl :: std:: fmt:: Debug for $ BitFlags {
<bitflags macros>:90:1: 92:63 note: in this expansion of bitflags! (defined in <bitflags macros>)
src/pa/types.rs:84:5: 108:6 note: in this expansion of bitflags! (defined in <bitflags macros>)
src/lib.rs:54:9: 54:21 note: lint level defined here
src/lib.rs:54 #![warn(missing_docs)]
                      ^~~~~~~~~~~~
<bitflags macros>:7:27: 8:19 warning: missing documentation for a constant
<bitflags macros>:7 $ ( # [ $ Flag_attr ] ) * pub const $ Flag : $ BitFlags = $ BitFlags {
<bitflags macros>:8 bits : $ value } ; ) + impl :: std:: fmt:: Debug for $ BitFlags {
<bitflags macros>:90:1: 92:63 note: in this expansion of bitflags! (defined in <bitflags macros>)
src/pa/types.rs:84:5: 108:6 note: in this expansion of bitflags! (defined in <bitflags macros>)
src/lib.rs:54:9: 54:21 note: lint level defined here
src/lib.rs:54 #![warn(missing_docs)]
                      ^~~~~~~~~~~~
<bitflags macros>:7:27: 8:19 warning: missing documentation for a constant
<bitflags macros>:7 $ ( # [ $ Flag_attr ] ) * pub const $ Flag : $ BitFlags = $ BitFlags {
<bitflags macros>:8 bits : $ value } ; ) + impl :: std:: fmt:: Debug for $ BitFlags {
<bitflags macros>:90:1: 92:63 note: in this expansion of bitflags! (defined in <bitflags macros>)
src/pa/types.rs:84:5: 108:6 note: in this expansion of bitflags! (defined in <bitflags macros>)
src/lib.rs:54:9: 54:21 note: lint level defined here
src/lib.rs:54 #![warn(missing_docs)]
                      ^~~~~~~~~~~~
<bitflags macros>:7:27: 8:19 warning: missing documentation for a constant
<bitflags macros>:7 $ ( # [ $ Flag_attr ] ) * pub const $ Flag : $ BitFlags = $ BitFlags {
<bitflags macros>:8 bits : $ value } ; ) + impl :: std:: fmt:: Debug for $ BitFlags {
<bitflags macros>:90:1: 92:63 note: in this expansion of bitflags! (defined in <bitflags macros>)
src/pa/types.rs:84:5: 108:6 note: in this expansion of bitflags! (defined in <bitflags macros>)
src/lib.rs:54:9: 54:21 note: lint level defined here
src/lib.rs:54 #![warn(missing_docs)]
                      ^~~~~~~~~~~~
<bitflags macros>:7:27: 8:19 warning: missing documentation for a constant
<bitflags macros>:7 $ ( # [ $ Flag_attr ] ) * pub const $ Flag : $ BitFlags = $ BitFlags {
<bitflags macros>:8 bits : $ value } ; ) + impl :: std:: fmt:: Debug for $ BitFlags {
<bitflags macros>:90:1: 92:63 note: in this expansion of bitflags! (defined in <bitflags macros>)
src/pa/types.rs:140:5: 173:6 note: in this expansion of bitflags! (defined in <bitflags macros>)
src/lib.rs:54:9: 54:21 note: lint level defined here
src/lib.rs:54 #![warn(missing_docs)]
                      ^~~~~~~~~~~~
<bitflags macros>:7:27: 8:19 warning: missing documentation for a constant
<bitflags macros>:7 $ ( # [ $ Flag_attr ] ) * pub const $ Flag : $ BitFlags = $ BitFlags {
<bitflags macros>:8 bits : $ value } ; ) + impl :: std:: fmt:: Debug for $ BitFlags {
<bitflags macros>:90:1: 92:63 note: in this expansion of bitflags! (defined in <bitflags macros>)
src/pa/types.rs:140:5: 173:6 note: in this expansion of bitflags! (defined in <bitflags macros>)
src/lib.rs:54:9: 54:21 note: lint level defined here
src/lib.rs:54 #![warn(missing_docs)]
                      ^~~~~~~~~~~~
<bitflags macros>:7:27: 8:19 warning: missing documentation for a constant
<bitflags macros>:7 $ ( # [ $ Flag_attr ] ) * pub const $ Flag : $ BitFlags = $ BitFlags {
<bitflags macros>:8 bits : $ value } ; ) + impl :: std:: fmt:: Debug for $ BitFlags {
<bitflags macros>:90:1: 92:63 note: in this expansion of bitflags! (defined in <bitflags macros>)
src/pa/types.rs:140:5: 173:6 note: in this expansion of bitflags! (defined in <bitflags macros>)
src/lib.rs:54:9: 54:21 note: lint level defined here
src/lib.rs:54 #![warn(missing_docs)]
                      ^~~~~~~~~~~~
<bitflags macros>:7:27: 8:19 warning: missing documentation for a constant
<bitflags macros>:7 $ ( # [ $ Flag_attr ] ) * pub const $ Flag : $ BitFlags = $ BitFlags {
<bitflags macros>:8 bits : $ value } ; ) + impl :: std:: fmt:: Debug for $ BitFlags {
<bitflags macros>:90:1: 92:63 note: in this expansion of bitflags! (defined in <bitflags macros>)
src/pa/types.rs:140:5: 173:6 note: in this expansion of bitflags! (defined in <bitflags macros>)
src/lib.rs:54:9: 54:21 note: lint level defined here
src/lib.rs:54 #![warn(missing_docs)]
                      ^~~~~~~~~~~~
<bitflags macros>:7:27: 8:19 warning: missing documentation for a constant
<bitflags macros>:7 $ ( # [ $ Flag_attr ] ) * pub const $ Flag : $ BitFlags = $ BitFlags {
<bitflags macros>:8 bits : $ value } ; ) + impl :: std:: fmt:: Debug for $ BitFlags {
<bitflags macros>:90:1: 92:63 note: in this expansion of bitflags! (defined in <bitflags macros>)
src/pa/types.rs:140:5: 173:6 note: in this expansion of bitflags! (defined in <bitflags macros>)
src/lib.rs:54:9: 54:21 note: lint level defined here
src/lib.rs:54 #![warn(missing_docs)]
                      ^~~~~~~~~~~~
<bitflags macros>:7:27: 8:19 warning: missing documentation for a constant
<bitflags macros>:7 $ ( # [ $ Flag_attr ] ) * pub const $ Flag : $ BitFlags = $ BitFlags {
<bitflags macros>:8 bits : $ value } ; ) + impl :: std:: fmt:: Debug for $ BitFlags {
<bitflags macros>:90:1: 92:63 note: in this expansion of bitflags! (defined in <bitflags macros>)
src/pa/types.rs:140:5: 173:6 note: in this expansion of bitflags! (defined in <bitflags macros>)
src/lib.rs:54:9: 54:21 note: lint level defined here
src/lib.rs:54 #![warn(missing_docs)]
                      ^~~~~~~~~~~~
error: could not find native static library `portaudio`, perhaps an -L flag is missing?
Could not compile `portaudio`.

To learn more, run the command again with --verbose.

Remove unnecessary Pa prefix from types?

Just a suggestion, but maybe we could remove the Pa prefix from the types? I don't think it's really necessary in the portaudio crate, and I'm guessing most people would just alias them if they needed to anyway? i.e. use portaudio::types::Error as PortAudioError. After using rust for a while lib prefixes are starting to smell a little of C/C++ haha.

edit: I was thinking of having a stab at adding proper error handling so could probably do this at the same time.

Crash when `frames` argument passed to blocking stream `write` method exceeds internal buffer size

Sample code:

let output_settings = try!(pa.default_output_stream_settings::<i16>(CHANNELS, SAMPLE_RATE, FRAMES));
let mut output_stream = try!(pa.open_blocking_stream(output_settings));
try!(output_stream.start());
try!(output_stream.write(FRAMES * 2, |output| {
    for i in 0..2*FRAMES {
        output[i] = 10000;
    }
}));

There are no any check for size in neither Stream::write nor Buffer::slice_mut.

Stream::write design differs significantly from Pa_WriteStream: while the latter accepts external buffer and has no frames limit, first one uses internal buffer and thus has such restriction. Why is that?

Make `fn write` take T where T: AsSlice<O> rather than Vec<O>

This would allow a user to pass in a fixed-size array or a slice as well as a Vec. Do you think this would be worth doing? I'm using a fixed-size array in my own project atm and I have to .iter().map(|&val| val).collect() it every time write is called, so I think that this generalisation would help to increase performance a bit.

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

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

use not well supported OSS API by default on debian8

Out of the box rust-portaudio used OSS API.

It result in not being able to use multiple sound sources.
(launching vlc and then my_program -> my_program failed because device busy,
launching my_program and then vlc -> vlc not able to produce sound)

building portaudio for linux state

The OSS sound API is very old and not well supported. It is recommended that you use the ALSA
sound API. The PortAudio configure script will look for the ALSA SDK. You can install the ALSA
SDK on Ubuntu using:
sudo apt-get install libasound-dev
...

So I installed libasound-dev && cargo clean && cargo run.
And now it uses ALSA API. So everything work well.

I don't know how you manage to download and build portaudio and if it is possible to install libasound-dev when it is recommended.
But if not I would advise to open a Troubleshooting section in the readme

thanks

Issues with running Linux ALSA stream

@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.

Update `portaudio` cargo package

Hey @jeremyletang :) just wondering if you could $ cargo publish for me? I'm trying to publish sound_stream on crates.io, but to do this all dependencies must also be on crates.io and the latest version of portaudio that's up there is a bit behind.

Thanks!!

Rust-portaudio docs?

Hi, is there any up-to-date documentation for rust-portaudio? If there is, it would be nice to have a link on the repo front page.

rust-portaudio failed to build

I added this line to my Cargo.toml
portaudio = "0.6.2"

And then I did a cargo build to download it and I got this error:

C:\Users\Sebastian Malton\Documents\Rust_Projects\sound_ques\src>cargo build Updating registryhttps://github.com/rust-lang/crates.io-index`
Downloading num v0.1.30
Downloading pkg-config v0.3.6
Downloading portaudio v0.6.2
Compiling pkg-config v0.3.6
Compiling bitflags v0.3.3
Compiling num v0.1.30
Compiling libc v0.2.7
Compiling portaudio v0.6.2
C:\Users\Sebastian Malton.cargo\registry\src\github.com-88ac128001ac3a9a\portaudio-0.6.2\build.rs:48:9: 48:29 error: this function takes 1 parameter but 0 parameters were supplied [E0061]
C:\Users\Sebastian Malton.cargo\registry\src\github.com-88ac128001ac3a9a\portaudio-0.6.2\build.rs:48 platform::download();
^~~~~~~~~~~~~~~~~~~~
C:\Users\Sebastian Malton.cargo\registry\src\github.com-88ac128001ac3a9a\portaudio-0.6.2\build.rs:48:9: 48:29 help: run rustc --explain E0061 to see a detailed explanation
error: aborting due to previous error
Build failed, waiting for other jobs to finish...
Could not compile portaudio.

To learn more, run the command again with --verbose.`

Cargo Build is failing on ffi and linking errors

This is the error I'm getting

Could not compile `rust-portaudio`.

--- stderr
src/ffi.rs:135:104: 135:128 warning: found type without foreign-function-safe
                                      representation annotation in foreign module, consider adding a #[repr(...)] attribute to the type, #[warn(ctypes)] on by default
src/ffi.rs:135                          streamCallback : Option<extern "C" fn(*const c_void, *mut c_void, u32, *const PaStreamCallbackTimeInfo, PaStreamCallbackFlags, *mut c_void) -> PaStreamCallbackResult>,
                                                                                                                      ^~~~~~~~~~~~~~~~~~~~~~~~
src/ffi.rs:135:169: 135:191 warning: found type without foreign-function-safe
                                      representation annotation in foreign module, consider adding a #[repr(...)] attribute to the type, #[warn(ctypes)] on by default
src/ffi.rs:135                          streamCallback : Option<extern "C" fn(*const c_void, *mut c_void, u32, *const PaStreamCallbackTimeInfo, PaStreamCallbackFlags, *mut c_void) -> PaStreamCallbackResult>,
                                                                                                                                                                                       ^~~~~~~~~~~~~~~~~~~~~~
src/ffi.rs:144:111: 144:135 warning: found type without foreign-function-safe
                                      representation annotation in foreign module, consider adding a #[repr(...)] attribute to the type, #[warn(ctypes)] on by default
src/ffi.rs:144                                 streamCallback : Option<extern "C" fn(*const c_void, *mut c_void, u32, *const PaStreamCallbackTimeInfo, PaStreamCallbackFlags, *mut c_void) -> PaStreamCallbackResult>,
                                                                                                                             ^~~~~~~~~~~~~~~~~~~~~~~~
src/ffi.rs:144:176: 144:198 warning: found type without foreign-function-safe
                                      representation annotation in foreign module, consider adding a #[repr(...)] attribute to the type, #[warn(ctypes)] on by default
src/ffi.rs:144                                 streamCallback : Option<extern "C" fn(*const c_void, *mut c_void, u32, *const PaStreamCallbackTimeInfo, PaStreamCallbackFlags, *mut c_void) -> PaStreamCallbackResult>,
                                                                                                                                                                                              ^~~~~~~~~~~~~~~~~~~~~~
error: linking with `cc` failed: exit code: 1
note: cc '-m64' '-L' '/usr/local/lib/rustlib/x86_64-apple-darwin/lib' '-o' '/Users/Mitch/Programming/Rust/rust-dsp/target/deps/libportaudio-59aae95b923e80ca.dylib' '/Users/Mitch/Programming/Rust/rust-dsp/target/deps/portaudio-59aae95b923e80ca.o' '-Wl,-force_load,/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libmorestack.a' '/Users/Mitch/Programming/Rust/rust-dsp/target/deps/portaudio-59aae95b923e80ca.metadata.o' '-nodefaultlibs' '-fno-lto' '-fno-use-linker-plugin' '-Wl,-dead_strip' '-L' '/usr/local/lib/rustlib/x86_64-apple-darwin/lib' '-lstd-4e7c5e5c' '-L' '/usr/local/lib/rustlib/x86_64-apple-darwin/lib' '-lsync-4e7c5e5c' '-L' '/usr/local/lib/rustlib/x86_64-apple-darwin/lib' '-lrustrt-4e7c5e5c' '-L' '/Users/Mitch/Programming/Rust/rust-dsp/target/deps' '-L' '/Users/Mitch/Programming/Rust/rust-dsp/target/deps' '-L' '/Users/Mitch/.cargo/git/checkouts/rust-portaudio-a404c333fd0ba772/master/.rust' '-L' '/Users/Mitch/.cargo/git/checkouts/rust-portaudio-a404c333fd0ba772/master' '-L' '/Users/Mitch/.rust' '-lportaudio' '-lSystem' '-lpthread' '-lc' '-lm' '-dynamiclib' '-Wl,-dylib' '-lcompiler-rt'
note: clang: error: unknown argument: '-fno-use-linker-plugin' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future

error: aborting due to previous error

I can fix the src/ffi.rs error by adding ctypes to the #![allow...] at the top of the module, however I'm unsure how to fix the linker error. This is the first time i've used anything with rust-portaudio in about a month (was working prior). I'm on the latest rustc nightly.

Get build.rs script for Windows working

Hi,

I'm trying to compiling rust-portaudio under Windows 7 SP1 64bit with Rust 1.0.0 (9854143cb 2015-04-02), but I'm getting the following error:

   Compiling portaudio v0.4.0 (file:///C:/temp/rust/rust-portaudio)
     Running `rustc build.rs --crate-name build_script_build --crate-type bin -C
 prefer-dynamic -g --out-dir C:\temp\rust\rust-portaudio\target\debug\build\port
audio-abac5c6e3fd19304 --emit=dep-info,link -L dependency=C:\temp\rust\rust-port
audio\target\debug -L dependency=C:\temp\rust\rust-portaudio\target\debug\deps -
-extern pkg_config=C:\temp\rust\rust-portaudio\target\debug\deps\libpkg_config-c
0e9294bfeefddd9.rlib`
       Fresh pkg-config v0.3.3
       Fresh libc v0.1.6
       Fresh rustc-serialize v0.3.12
   Compiling num v0.1.22
     Running `rustc C:\Users\KillKRT\.cargo\registry\src\github.com-1ecc6299db9e
c823\num-0.1.22\src\lib.rs --crate-name num --crate-type lib -g -C metadata=798f
e7e31b30dacd -C extra-filename=-798fe7e31b30dacd --out-dir C:\temp\rust\rust-por
taudio\target\debug\deps --emit=dep-info,link -L dependency=C:\temp\rust\rust-po
rtaudio\target\debug\deps -L dependency=C:\temp\rust\rust-portaudio\target\debug
\deps --extern rand=C:\temp\rust\rust-portaudio\target\debug\deps\librand-7b0a3a
f7ae4685dc.rlib --extern rustc_serialize=C:\temp\rust\rust-portaudio\target\debu
g\deps\librustc_serialize-70d93d5334da1e4e.rlib -Awarnings`
       Fresh log v0.3.1
       Fresh rand v0.3.7
build.rs:48:9: 48:29 error: this function takes 1 parameter but 0 parameters wer
e supplied [E0061]
build.rs:48         platform::download();
                    ^~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error
Build failed, waiting for other jobs to finish...
Could not compile `portaudio`.

Caused by:
  Process didn't exit successfully: `rustc build.rs --crate-name build_script_bu
ild --crate-type bin -C prefer-dynamic -g --out-dir C:\temp\rust\rust-portaudio\
target\debug\build\portaudio-abac5c6e3fd19304 --emit=dep-info,link -L dependency
=C:\temp\rust\rust-portaudio\target\debug -L dependency=C:\temp\rust\rust-portau
dio\target\debug\deps --extern pkg_config=C:\temp\rust\rust-portaudio\target\deb
ug\deps\libpkg_config-c0e9294bfeefddd9.rlib` (exit code: 101)

I've also tried to compile under a MinGW64 environment, but I got the same error.

Change trait `SamplePrivate` to `ToSampleFormat` and make it public.

I'm currently working on an Iterator version of the SoundStream from rust-dsp and I've come across a use-case where this would be useful.

The SampleFormat is needed to construct both input and output stream parameters. When designing a wrapper around Stream<I, O> it shouldn't be necessary for the user to specify both <I, O> types as well as the SampleFormat in arg form - the API designer should be able to just grab the SampleFormat from the <I, O> types given, where both I and O implement ToSampleFormat. Then, we could do this:

let default_input_sample: I = ::std::default::Default::default(); 
let default_output_sample: O = ::std::default::Default::default();
let input_sample_format  = default_input_sample.sample_format();  
let output_sample_format = default_output_sample.sample_format(); 

Smaller num dependency

Just FYI, you can use just the traits in the num crate this way:

[depencencies]
num = { version = "*", default-features = false }

If you do this in this crate it will build a bit faster. The features were just added to num, and they are bignum, rational, complex, you don't need those, and may even avoid the deps they pull in (rustc_serialize and rand).

Non-blocking Stream Callback assumes interleaved channels (ignoring non-interleaved SampleFormat)

At the moment the StreamCallbackFn's signature is like this:

/// User specified callback function.
pub type StreamCallbackFn<I, O> =
    Box<FnMut(&[I], &mut[O], u32, &StreamCallbackTimeInfo, Option<StreamCallbackFlags>)
            -> StreamCallbackResult>;

The &[I] and &mut[O] arguments mean we are always assuming the channels are interleaved.

In the case that channels are non-interleaved, they should be more like &[&[I]] and &mut[&mut[O]] where each outer slice is for each channel, and each inner slice is for the channel's samples.

We could make StreamCallbackFn an enum with all possible combinations of input and output interleaved and non-interleaved, however this would be messy internally and look a bit ugly to the user. Same goes for making the args themselves enums.

Another perhaps cleaner option would be to always have the args as a slice of slices (where interleaved channels are always just on the first slice), however I guess that still adds a little unnecessary noise in the callback function's type signature. This is probably my favourite option so far.

Will keep pondering on this, any suggestions appreciated!

Add a `PortAudio` type for safer, automatic initialisation and termination of PortAudio.

At the moment a user must initialise and terminate PortAudio manually with the initialize and terminate functions. This makes it easy to forget to release resources or for a stream to accidentally outlive PortAudio's termination.

I propose that we create a PortAudio type whose constructor calls pa::initialize() and destructor calls pa::terminate(). We could also move many of the library's functions onto PortAudio methods. i.e if we had

let pa = PortAudio::new();

then

let stream = pa::Stream::new();

would become

let stream = pa.new_stream();

This is strictly safer because:

  1. A Stream cannot be created without PortAudio being initialised and
  2. A Stream's lifetime could be limited to that of the PortAudio type, ensuring that no streams outlive the PortAudio type (and in turn pa::terminate).

Examples don't work on Windows with ASIO

I built portaudio from the latest SVN snapshot with ASIO support (no other API) and debugging enabled for win32.
(I have an ASIO compatible audio interface (Steinberg UR22) that works with ASIO usually, which portaudio correctly identifies as the default device.)
Then tried to run the examples (also win32), but they don't work as they should.
What they have in common is this output from portaudio:

PinNew: Error -9999
...
FilterNew: Error -9985
...
Filter NOT created

So for some reason it can't open the audio interface.
The blocking example crashes sometimes (sometimes not), the others run but there is no sound coming out.
Maybe the issue is with the access to the audio interface?
I noticed that some DAWs that support ASIO as a backend will give up if the audio interface is already in use, and others will "steal" the access from the existing owner. How can I force portaudio to steal the access? (Even though in this case I think the audio interface shouldn't have been in use.)

See debug output in the attachments:
blocking.txt
devices.txt
non_blocking.txt
saw.txt
sine.txt

I tried to debug the examples using Visual Studio but it only shows asm, not very helpful:
blocking
The point of failure is apparently in wdmaud.drv. But my audio interface works with ASIO in other Software like Reaper, Ableton etc. so somehow portaudio must be causing it..
When I run blocking outside of Visual Studio:

Maybe portaudio is trying to open the device using the wrong parameters?

Can't compile even though portaudio is installed

I'm using Mac OS.

I have added portaudio as a dependency in a project and I have the following error, both when using version 0.6.3 from crates.io and and from the git master:

Compiling portaudio v0.6.3 (https://github.com/RustAudio/rust-portaudio.git#dc1f284f)
error: could not find native static library `portaudio`, perhaps an -L flag is missing?
Could not compile `portaudio`.

However, I have installed portaudio with port:

$ ls /opt/local/lib | grep portaudio
libportaudio.2.dylib
libportaudio.a
libportaudio.dylib
libportaudiocpp.0.dylib
libportaudiocpp.a
libportaudiocpp.dylib

I have added it to the library path:

$ echo $LIBRARY_PATH
/opt/local/lib/

I have also tried cargo rustc -- -L/opt/local/bin/ without success... apparently, the flags added for rustc are not used to compile dependencies.

I have also tried to install portaudio with Homebrew (so that it is in the more usual location, in /usr/local/lib/) but it doesn't work either.

Anyway, shouldn't the build process download portaudio and compile it if it is not found?

Change StreamCallbackFn from `Box<FnMut>` to generic `F: FnMut` (blocked on unboxed_closures feature)

The reason this isn't yet implemented yet is because we need to be able to specify some default type (for the generic F parameter) for the case where a user gives None and doesn't require the non-blocking stream. This currently isn't possible without constructing some "dummy" type (to use as the default type) and implementing the Fn trait for it, which currently requires use of the unboxed_closures gated feature. Once the feature is stabilised we can make this change.

Compile errors with examples on OS X 10.10.3

After adding

[dependencies]
portaudio = "*"

To my Cargo.toml in a new project, and copying the non-blocking example verbatim into my main.rs file, I receive the following error below when compiling.

main.rs:81:18: 85:57 error: no method named `open_blocking` found for type `portaudio::pa::Stream<f32, f32>` in the current scope
main.rs:81     match stream.open_blocking(Some(&input_stream_params),
main.rs:82                                Some(&output_stream_params),
main.rs:83                                SAMPLE_RATE,
main.rs:84                                FRAMES,
main.rs:85                                pa::StreamFlags::empty()) {
main.rs:87:80: 87:97 error: the type of this value must be known in this context
main.rs:87         Err(err) => println!("An error occurred while opening the stream: {}", err.description()),
                                                                                          ^~~~~~~~~~~~~~~~~

I also received a very similar error when trying the non-blocking example.

main.rs:122:18: 127:45 error: no method named `open_non_blocking` found for type `portaudio::pa::Stream<f32, f32>` in the current scope
main.rs:122     match stream.open_non_blocking(Some(&input_stream_params),
main.rs:123                                    Some(&output_stream_params),
main.rs:124                                    SAMPLE_RATE,
main.rs:125                                    FRAMES,
main.rs:126                                    pa::StreamFlags::empty(),
main.rs:127                                    callback) {
main.rs:129:80: 129:97 error: the type of this value must be known in this context
main.rs:129         Err(err) => println!("An error occurred while opening the stream: {}", err.description()),
                                                                                           ^~~~~~~~~~~~~~~~~

I'm not sure if I setup my project improperly. I just recently cloned the repo and was able to build successfully and run the non_blocking executable produced in the target/debug/examples folder. The blocking executable threw this error, however: "An error occurred while reading from the input stream: The input stream has overflowed"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.