Skip to content

Commit 720933f

Browse files
authored
Update CXXCoreAudio and CXXAudioToolbox (#667)
1 parent 92a11b0 commit 720933f

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

Package.resolved

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ let package = Package(
2020
],
2121
dependencies: [
2222
.package(url: "https://github.com/sbooth/AVFAudioExtensions", from: "0.4.2"),
23-
.package(url: "https://github.com/sbooth/CXXCoreAudio", from: "0.2.0"),
24-
.package(url: "https://github.com/sbooth/CXXAudioToolbox", from: "0.1.2"),
23+
.package(url: "https://github.com/sbooth/CXXCoreAudio", from: "0.3.0"),
24+
.package(url: "https://github.com/sbooth/CXXAudioToolbox", from: "0.2.0"),
2525
.package(url: "https://github.com/sbooth/CXXRingBuffer", from: "0.3.0"),
2626
.package(url: "https://github.com/sbooth/CXXSharedMutex", from: "0.1.0"),
2727
.package(url: "https://github.com/sbooth/CXXUnfairLock", from: "0.1.0"),

Sources/CSFBAudioEngine/Player/AudioPlayerNode.mm

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -977,28 +977,28 @@ bool PerformSeekIfRequired() noexcept
977977

978978
// If there are audio frames available to read from the ring buffer read as many as possible
979979
if(const auto availableFrames = audioRingBuffer_.AvailableFrames(); availableFrames > 0) {
980-
const auto framesToRead = std::min(availableFrames, frameCount);
981-
const uint32_t framesRead = audioRingBuffer_.Read(outputData, framesToRead);
980+
const auto framesToRead = std::min(availableFrames, static_cast<CXXCoreAudio::AudioRingBuffer::size_type>(frameCount));
981+
const auto framesRead = audioRingBuffer_.Read(outputData, framesToRead);
982982
if(framesRead != framesToRead)
983-
os_log_fault(log_, "CXXCoreAudio::AudioRingBuffer::Read failed: Requested %u frames, got %u", framesToRead, framesRead);
983+
os_log_fault(log_, "CXXCoreAudio::AudioRingBuffer::Read failed: Requested %zu frames, got %zu", framesToRead, framesRead);
984984

985985
// If the ring buffer didn't contain as many frames as requested fill the remainder with silence
986986
if(framesRead != frameCount) {
987987
#if DEBUG
988-
os_log_debug(log_, "Insufficient audio in ring buffer: %u frames available, %u requested", framesRead, frameCount);
988+
os_log_debug(log_, "Insufficient audio in ring buffer: %zu frames available, %u requested", framesRead, frameCount);
989989
#endif /* DEBUG */
990990

991991
const auto framesOfSilence = frameCount - framesRead;
992-
const auto byteCountToSkip = audioRingBuffer_.Format().FrameCountToByteSize(framesRead);
993-
const auto byteCountToZero = audioRingBuffer_.Format().FrameCountToByteSize(framesOfSilence);
992+
const auto byteCountToSkip = framesRead * audioRingBuffer_.Format().mBytesPerFrame;
993+
const auto byteCountToZero = framesOfSilence * audioRingBuffer_.Format().mBytesPerFrame;
994994
for(UInt32 i = 0; i < outputData->mNumberBuffers; ++i) {
995995
std::memset(static_cast<uint8_t *>(outputData->mBuffers[i].mData) + byteCountToSkip, 0, byteCountToZero);
996996
outputData->mBuffers[i].mDataByteSize += byteCountToZero;
997997
}
998998
}
999999

10001000
const RenderingEventHeader header{RenderingEventCommand::framesRendered};
1001-
if(!renderEventRingBuffer_.WriteValues(header, timestamp, framesRead))
1001+
if(!renderEventRingBuffer_.WriteValues(header, timestamp, static_cast<uint32_t>(framesRead)))
10021002
os_log_fault(log_, "Error writing frames rendered event");
10031003
} else {
10041004
// Output silence if the ring buffer is empty

0 commit comments

Comments
 (0)