aboutsummaryrefslogtreecommitdiff
path: root/include/oboe/AudioStreamBuilder.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/oboe/AudioStreamBuilder.h')
-rw-r--r--include/oboe/AudioStreamBuilder.h40
1 files changed, 39 insertions, 1 deletions
diff --git a/include/oboe/AudioStreamBuilder.h b/include/oboe/AudioStreamBuilder.h
index 80c5da42..d63578c3 100644
--- a/include/oboe/AudioStreamBuilder.h
+++ b/include/oboe/AudioStreamBuilder.h
@@ -306,8 +306,44 @@ public:
}
/**
+ * Specifies an object to handle data related callbacks from the underlying API.
+ *
+ * <strong>Important: See AudioStreamCallback for restrictions on what may be called
+ * from the callback methods.</strong>
+ *
+ * @param dataCallback
+ * @return pointer to the builder so calls can be chained
+ */
+ AudioStreamBuilder *setDataCallback(oboe::AudioStreamDataCallback *dataCallback) {
+ mDataCallback = dataCallback;
+ return this;
+ }
+
+ /**
+ * Specifies an object to handle error related callbacks from the underlying API.
+ * This can occur when a stream is disconnected because a headset is plugged in or unplugged.
+ * It can also occur if the audio service fails or if an exclusive stream is stolen by
+ * another stream.
+ *
+ * <strong>Important: See AudioStreamCallback for restrictions on what may be called
+ * from the callback methods.</strong>
+ *
+ * <strong>When an error callback occurs, the associated stream must be stopped and closed
+ * in a separate thread.</strong>
+ *
+ * @param errorCallback
+ * @return pointer to the builder so calls can be chained
+ */
+ AudioStreamBuilder *setErrorCallback(oboe::AudioStreamErrorCallback *errorCallback) {
+ mErrorCallback = errorCallback;
+ return this;
+ }
+
+ /**
* Specifies an object to handle data or error related callbacks from the underlying API.
*
+ * This is the equivalent of calling both setDataCallback() and setErrorCallback().
+ *
* <strong>Important: See AudioStreamCallback for restrictions on what may be called
* from the callback methods.</strong>
*
@@ -327,7 +363,9 @@ public:
* @return pointer to the builder so calls can be chained
*/
AudioStreamBuilder *setCallback(AudioStreamCallback *streamCallback) {
- mStreamCallback = streamCallback;
+ // Use the same callback object for both, dual inheritance.
+ mDataCallback = streamCallback;
+ mErrorCallback = streamCallback;
return this;
}