Skip to content

Commit

Permalink
Return None for an audio device name if the device name is the empty …
Browse files Browse the repository at this point in the history
…string.
  • Loading branch information
psobot committed Aug 22, 2024
1 parent 658c1e6 commit 52267f1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
10 changes: 7 additions & 3 deletions pedalboard/io/AudioStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,14 @@ class AudioStream : public std::enable_shared_from_this<AudioStream>
if (auto *type = deviceManager.getCurrentDeviceTypeObject()) {
const auto info = getSetupInfo(setup, isInput);

if (numChannelsNeeded > 0 && info.name.isEmpty())
return {
if (numChannelsNeeded > 0 && info.name.isEmpty()) {
std::string deviceName =
type->getDeviceNames(isInput)[type->getDefaultDeviceIndex(isInput)]
.toStdString()};
.toStdString();
if (!deviceName.empty()) {
return {deviceName};
}
}
}
#endif
return {};
Expand Down
8 changes: 4 additions & 4 deletions tests/test_audio_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def test_create_stream(input_device_name: str, output_device_name: str):
@pytest.mark.skipif(
(
pedalboard.io.AudioStream.default_output_device_name == "Null Audio Device"
or not pedalboard.io.AudioStream.default_output_device_name
or pedalboard.io.AudioStream.default_output_device_name is None
),
reason="Test requires a working audio device.",
)
Expand All @@ -98,7 +98,7 @@ def test_write_to_stream():
@pytest.mark.skipif(
(
pedalboard.io.AudioStream.default_output_device_name == "Null Audio Device"
or not pedalboard.io.AudioStream.default_output_device_name
or pedalboard.io.AudioStream.default_output_device_name is None
),
reason="Test requires a working audio device.",
)
Expand All @@ -124,7 +124,7 @@ def test_write_to_stream_without_opening():
@pytest.mark.skipif(
(
pedalboard.io.AudioStream.default_input_device_name == "Null Audio Device"
or not pedalboard.io.AudioStream.default_input_device_name
or pedalboard.io.AudioStream.default_input_device_name is None
),
reason="Test requires a working audio device.",
)
Expand All @@ -149,7 +149,7 @@ def test_read_from_stream():
@pytest.mark.skipif(
(
pedalboard.io.AudioStream.default_input_device_name == "Null Audio Device"
or not pedalboard.io.AudioStream.default_input_device_name
or pedalboard.io.AudioStream.default_input_device_name is None
),
reason="Test requires a working audio device.",
)
Expand Down

0 comments on commit 52267f1

Please sign in to comment.