85975d6cc3
- Replace Swift Array<UInt8> ring buffer with UnsafeMutableRawPointer to eliminate COW ref-count checks on every write/read - Add append(from:count:) to copy directly from Core Audio buffer pointer into the ring buffer, removing the per-callback Data heap allocation - Pre-allocate AVAudioPCMBuffer pair in AudioFormatConverter and reuse across transform() calls (lazy init, capacity-checked) - Fix float-to-int truncation in output frame count calculation (ceil) - Add comprehensive AudioBuffer test suite (12 tests) including proper wrap-around coverage for both append and read paths Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
32 lines
671 B
Swift
32 lines
671 B
Swift
import XCTest
|
|
|
|
@testable import AudioTeeCore
|
|
|
|
final class AudioPacketTests: XCTestCase {
|
|
func testPacketCreation() {
|
|
let timestamp = Date()
|
|
let duration = 1.0
|
|
let data = Data([0x01, 0x02, 0x03, 0x04])
|
|
|
|
let packet = AudioPacket(
|
|
timestamp: timestamp,
|
|
duration: duration,
|
|
data: data
|
|
)
|
|
|
|
XCTAssertEqual(packet.timestamp, timestamp)
|
|
XCTAssertEqual(packet.duration, duration)
|
|
XCTAssertEqual(packet.data, data)
|
|
}
|
|
|
|
func testPacketDataSize() {
|
|
let packet = AudioPacket(
|
|
timestamp: Date(),
|
|
duration: 0.5,
|
|
data: Data(repeating: 0xFF, count: 1024)
|
|
)
|
|
|
|
XCTAssertEqual(packet.data.count, 1024)
|
|
}
|
|
}
|