Skip to content

Commit 4bdeea4

Browse files
committed
Make int16Data not nullable
1 parent 74a7349 commit 4bdeea4

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

firebaseai/LiveAudioExample/Audio/AudioBufferHelpers.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ extension AVAudioPCMBuffer {
4242
/// Gets the underlying `Data` in this buffer.
4343
///
4444
/// Will throw an error if this buffer doesn't hold int16 data.
45-
func int16Data() -> Data? {
45+
func int16Data() -> Data {
4646
guard let bufferPtr = audioBufferList.pointee.mBuffers.mData else {
4747
fatalError("Missing audio buffer list")
4848
}

firebaseai/LiveAudioExample/ViewModels/LiveViewModel.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,7 @@ class LiveViewModel: ObservableObject {
130130
let stream = try audioController.listenToMic()
131131
microphoneTask = Task {
132132
for await audioBuffer in stream {
133-
guard let data = audioBuffer.int16Data() else {
134-
logger.error("Failed to convert audio buffer to int16 Data.")
135-
continue
136-
}
137-
await liveSession.sendAudioRealtime(data)
133+
await liveSession.sendAudioRealtime(audioBuffer.int16Data())
138134
}
139135
}
140136
}

0 commit comments

Comments
 (0)