fix bug, test
This commit is contained in:
parent
fbcd539a76
commit
06c6fd0495
2 changed files with 19 additions and 4 deletions
|
@ -48,6 +48,7 @@ using .LibPortAudio:
|
|||
Pa_Initialize,
|
||||
paInputOverflowed,
|
||||
Pa_IsStreamStopped,
|
||||
paNoDevice,
|
||||
paNoFlag,
|
||||
Pa_OpenStream,
|
||||
paOutputUnderflowed,
|
||||
|
@ -195,12 +196,22 @@ function show(io::IO, device::PortAudioDevice)
|
|||
print(io, device.output_bounds.max_channels)
|
||||
end
|
||||
|
||||
function check_device_exists(device_index, device_type)
|
||||
if device_index == paNoDevice
|
||||
throw(ArgumentError("No $device_type device available"))
|
||||
end
|
||||
end
|
||||
|
||||
function get_default_input_index()
|
||||
handle_status(Pa_GetDefaultInputDevice())
|
||||
device_index = Pa_GetDefaultInputDevice()
|
||||
check_device_exists(device_index, "input")
|
||||
device_index
|
||||
end
|
||||
|
||||
function get_default_output_index()
|
||||
handle_status(Pa_GetDefaultOutputDevice())
|
||||
device_index = Pa_GetDefaultOutputDevice()
|
||||
check_device_exists(device_index, "output")
|
||||
device_index
|
||||
end
|
||||
|
||||
# we can look up devices by index or name
|
||||
|
|
|
@ -11,6 +11,7 @@ using PortAudio:
|
|||
get_output_type,
|
||||
handle_status,
|
||||
initialize,
|
||||
name,
|
||||
PortAudioException,
|
||||
PortAudio,
|
||||
PortAudioDevice,
|
||||
|
@ -18,7 +19,7 @@ using PortAudio:
|
|||
safe_load,
|
||||
seek_alsa_conf,
|
||||
terminate,
|
||||
name
|
||||
write_buffer
|
||||
using PortAudio.LibPortAudio:
|
||||
Pa_AbortStream,
|
||||
PaError,
|
||||
|
@ -109,7 +110,9 @@ using Test: @test, @test_logs, @test_nowarn, @testset, @test_throws
|
|||
initialize()
|
||||
end
|
||||
|
||||
if !isempty(devices())
|
||||
if isempty(devices())
|
||||
@test_throws ArgumentError("No input device available") get_default_input_index()
|
||||
else
|
||||
@testset "Tests with sound" begin
|
||||
# these default values are specific to local machines
|
||||
input_name = get_device(get_default_input_index()).name
|
||||
|
@ -130,6 +133,7 @@ if !isempty(devices())
|
|||
sleep(1)
|
||||
println("Testing pass-through")
|
||||
stream = PortAudioStream(input_name, output_name, 2, 2; adjust_channels = true)
|
||||
write_buffer(stream.sink_messenger.buffer, acquire_lock = false)
|
||||
sink = stream.sink
|
||||
source = stream.source
|
||||
@test sprint(show, stream) == """
|
||||
|
|
Loading…
Reference in a new issue