Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Callback #122

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
little refactor
  • Loading branch information
bramtayl committed Oct 18, 2022
commit a18c7d36d02e230ff0623d44c0c1fbbc11fb5d67
35 changes: 19 additions & 16 deletions src/PortAudio.jl
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,21 @@ Please specify a sample rate.
input_sample_rate
end

function fill_one_device(device, bounds, latency, samplerate)
return (
if latency === nothing
bounds.high_latency
else
latency
end,
if samplerate === nothing
device.default_sample_rate
else
float(samplerate)
end
)
end

# this is the top-level outer constructor that all the other outer constructors end up calling
"""
PortAudioStream(input_channels = 2, output_channels = 2; options...)
Expand Down Expand Up @@ -771,25 +786,13 @@ function PortAudioStream(
float(samplerate)
end
else
if latency === nothing
latency = input_device.input_bounds.high_latency
end
samplerate = if samplerate === nothing
input_device.default_sample_rate
else
float(samplerate)
end
latency, samplerate =
fill_one_device(input_device, input_device.input_bounds, latency, samplerate)
end
else
if output_channels_filled > 0
if latency === nothing
latency = output_device.output_bounds.high_latency
end
samplerate = if samplerate === nothing
output_device.default_sample_rate
else
float(samplerate)
end
latency, samplerate =
fill_one_device(output_device, output_device.output_bounds, latency, samplerate)
else
throw(ArgumentError("Input or output must have at least 1 channel"))
end
Expand Down