Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
64 changes: 58 additions & 6 deletions .github/workflows/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,15 @@ jobs:
compiler: "clang",
cc: "ccache clang",
cxx: "ccache clang++",
archflags: "-arch x86_64",
}
- {
os: macos-15,
python-version: "3.12",
compiler: "clang",
cc: "ccache clang",
cxx: "ccache clang++",
archflags: "-arch arm64",
}
name: Pre-build on ${{ matrix.os }} with ${{ matrix.compiler }}
steps:
Expand Down Expand Up @@ -241,10 +250,9 @@ jobs:
# Use the minimum macOS deployment target supported by our version of PyBind:
MACOSX_DEPLOYMENT_TARGET: "10.14"
CCACHE_LOGFILE: ${{ github.workspace }}/.ccache_log
# This build caching is only to speed up tests on CI, so we only care about x86_64 (macos-15-intel runners).
# Without limiting to a single architecture, ccache can't properly cache mixed Objective-C and C++ builds.
# Limit to a single architecture so ccache can properly cache mixed Objective-C and C++ builds.
# Fun fact: this is supported in Python itself! https://github.com/python/cpython/blob/893c9cc/Lib/_osx_support.py#L314-L328
ARCHFLAGS: -arch x86_64
ARCHFLAGS: ${{ matrix.archflags }}
DISABLE_LTO: "1" # Speeds up un-cacheable link step which doesn't really increase performance in tests anyways
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
Expand Down Expand Up @@ -514,34 +522,79 @@ jobs:
compiler: "clang",
cc: "ccache clang",
cxx: "ccache clang++",
archflags: "-arch x86_64",
}
- {
os: macos-15-intel,
python-version: "3.11",
compiler: "clang",
cc: "ccache clang",
cxx: "ccache clang++",
archflags: "-arch x86_64",
}
- {
os: macos-15-intel,
python-version: "3.12",
compiler: "clang",
cc: "ccache clang",
cxx: "ccache clang++",
archflags: "-arch x86_64",
}
- {
os: macos-15-intel,
python-version: "3.13",
compiler: "clang",
cc: "ccache clang",
cxx: "ccache clang++",
archflags: "-arch x86_64",
}
- {
os: macos-15-intel,
python-version: "3.14",
compiler: "clang",
cc: "ccache clang",
cxx: "ccache clang++",
archflags: "-arch x86_64",
}
- {
os: macos-15,
python-version: "3.10",
compiler: "clang",
cc: "ccache clang",
cxx: "ccache clang++",
archflags: "-arch arm64",
}
- {
os: macos-15,
python-version: "3.11",
compiler: "clang",
cc: "ccache clang",
cxx: "ccache clang++",
archflags: "-arch arm64",
}
- {
os: macos-15,
python-version: "3.12",
compiler: "clang",
cc: "ccache clang",
cxx: "ccache clang++",
archflags: "-arch arm64",
}
- {
os: macos-15,
python-version: "3.13",
compiler: "clang",
cc: "ccache clang",
cxx: "ccache clang++",
archflags: "-arch arm64",
}
- {
os: macos-15,
python-version: "3.14",
compiler: "clang",
cc: "ccache clang",
cxx: "ccache clang++",
archflags: "-arch arm64",
}
- {
os: ubuntu-24.04,
Expand Down Expand Up @@ -698,10 +751,9 @@ jobs:
CCACHE_DEBUG: "1"
# Use the minimum macOS deployment target supported by our version of PyBind:
MACOSX_DEPLOYMENT_TARGET: "10.14"
# This build caching is only to speed up tests on CI, so we only care about x86_64 (macos-15-intel runners).
# Without limiting to a single architecture, ccache can't properly cache mixed Objective-C and C++ builds.
# Limit to a single architecture so ccache can properly cache mixed Objective-C and C++ builds.
# Fun fact: this is supported in Python itself! https://github.com/python/cpython/blob/893c9cc/Lib/_osx_support.py#L314-L328
ARCHFLAGS: -arch x86_64
ARCHFLAGS: ${{ matrix.archflags || '' }}
DISABLE_LTO: "1" # Speeds up un-cacheable link step which doesn't really increase performance in tests anyways
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
Expand Down
17 changes: 13 additions & 4 deletions tests/test_audio_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,24 @@ def test_read_from_stream_measures_dropped_frames():
raise pytest.skip("Sample rate of default audio device is 0")
assert stream.running
assert stream.dropped_input_frame_count == 0
time.sleep(5 * stream.buffer_size / stream.sample_rate)
# Sleep long enough to overflow the internal buffer and cause dropped frames.
# Use a generous multiplier to account for varying buffer sizes across platforms.
time.sleep(max(0.5, 20 * stream.buffer_size / stream.sample_rate))
assert (
stream.buffered_input_sample_count is not None
and stream.buffered_input_sample_count > 0
)
dropped_count = stream.dropped_input_frame_count
assert dropped_count > 0
if dropped_count == 0:
raise pytest.skip(
"No frames were dropped during the test window; "
"audio device may have a large internal buffer"
)
# The input buffer was cleared on __exit__, so the buffer count should be zero:
assert stream.buffered_input_sample_count == 0

# ...but we should still know how many frames were dropped:
assert stream.dropped_input_frame_count == dropped_count
# ...but we should still know how many frames were dropped.
# Allow up to one extra buffer's worth of dropped frames, because the audio
# thread may drop one more buffer between our snapshot and stream shutdown.
assert stream.dropped_input_frame_count >= dropped_count
assert stream.dropped_input_frame_count <= dropped_count + stream.buffer_size
Loading