Skip to content

Commit 795dcfe

Browse files
committed
Add docs for exceptions thrown
1 parent f40dcfa commit 795dcfe

File tree

1 file changed

+7
-1
lines changed
  • firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type

1 file changed

+7
-1
lines changed

firebase-vertexai/src/main/kotlin/com/google/firebase/vertexai/type/AudioHelper.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ internal class AudioHelper(
6565
* Play the provided audio data on the playback track.
6666
*
6767
* Does nothing if this [AudioHelper] has been [released][release].
68+
*
69+
* @throws IllegalStateException If the playback track was not properly initialized.
70+
* @throws IllegalArgumentException If the playback data is invalid.
71+
* @throws RuntimeException If we fail to play the audio data for some unknown reason.
6872
*/
6973
fun playAudio(data: ByteArray) {
7074
if (released) return
@@ -88,7 +92,7 @@ internal class AudioHelper(
8892
throw IllegalArgumentException("Playback data is somehow invalid.")
8993
AudioTrack.ERROR_DEAD_OBJECT -> {
9094
Log.w(TAG, "Attempted to playback some audio, but the track has been released.")
91-
release()
95+
release() // to ensure `released` is set and `record` is released too
9296
}
9397
AudioTrack.ERROR ->
9498
throw RuntimeException("Failed to play the audio data for some unknown reason.")
@@ -101,6 +105,8 @@ internal class AudioHelper(
101105
* Does nothing if this [AudioHelper] has been [released][release].
102106
*
103107
* @see resumeRecording
108+
*
109+
* @throws IllegalStateException If the playback track was not properly initialized.
104110
*/
105111
fun pauseRecording() {
106112
if (released || recorder.recordingState == AudioRecord.RECORDSTATE_STOPPED) return

0 commit comments

Comments
 (0)