summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2022-02-08 20:20:00 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-02-08 20:20:00 +0000
commit14e51195e5afe64b7b6bbf3fb96e3deae2e1dd15 (patch)
tree418e2d1e82714750fcf4f85501618a7931dce549
parent04a0700f25fc93e31c79438b3b3384352c30a3df (diff)
parent07d5a5d873ed7cbc9630a71771a52663699a76ec (diff)
downloadlibhardware-14e51195e5afe64b7b6bbf3fb96e3deae2e1dd15.tar.gz
Merge "Audio HAL: Add latency mode APIs" am: 5c264411c6 am: 909e4b4cc5 am: 07d5a5d873
Original change: https://android-review.googlesource.com/c/platform/hardware/libhardware/+/1975466 Change-Id: I7f07b98c79413e7622f2773ca57a64ad34412989
-rw-r--r--include/hardware/audio.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/include/hardware/audio.h b/include/hardware/audio.h
index adec3da8..a3b52146 100644
--- a/include/hardware/audio.h
+++ b/include/hardware/audio.h
@@ -247,6 +247,10 @@ typedef struct sink_metadata_v7 {
struct record_track_metadata_v7* tracks;
} sink_metadata_v7_t;
+/** output stream callback method to indicate changes in supported latency modes */
+typedef void (*stream_latency_mode_callback_t)(
+ audio_latency_mode_t *modes, size_t num_modes, void *cookie);
+
/**
* audio_stream_out is the abstraction interface for the audio output hardware.
*
@@ -533,7 +537,68 @@ struct audio_stream_out {
*/
int (*set_playback_rate_parameters)(struct audio_stream_out *stream,
const audio_playback_rate_t *playbackRate);
+
+ /**
+ * Indicates the requested latency mode for this output stream.
+ *
+ * The requested mode can be one of the modes returned by
+ * get_recommended_latency_modes().
+ *
+ * Support for this method is optional but mandated on specific spatial audio
+ * streams indicated by AUDIO_OUTPUT_FLAG_SPATIALIZER flag if they can be routed
+ * to a BT classic sink.
+ *
+ * \param[in] stream the stream object.
+ * \param[in] mode the requested latency mode.
+ * \return 0 in case of success.
+ * -EINVAL if the arguments are invalid
+ * -ENOSYS if the function is not available
+ */
+ int (*set_latency_mode)(struct audio_stream_out *stream, audio_latency_mode_t mode);
+
+ /**
+ * Indicates which latency modes are currently supported on this output stream.
+ * If the transport protocol (e.g Bluetooth A2DP) used by this output stream to reach
+ * the output device supports variable latency modes, the HAL indicates which
+ * modes are currently supported.
+ * The framework can then call setLatencyMode() with one of the supported modes to select
+ * the desired operation mode.
+ *
+ * Support for this method is optional but mandated on specific spatial audio
+ * streams indicated by AUDIO_OUTPUT_FLAG_SPATIALIZER flag if they can be routed
+ * to a BT classic sink.
+ *
+ * \return 0 in case of success.
+ * -EINVAL if the arguments are invalid
+ * -ENOSYS if the function is not available
+ * \param[in] stream the stream object.
+ * \param[out] modes the supported latency modes.
+ * \param[in/out] num_modes as input the maximum number of modes to return,
+ * as output the actual number of modes returned.
+ */
+ int (*get_recommended_latency_modes)(struct audio_stream_out *stream,
+ audio_latency_mode_t *modes, size_t *num_modes);
+
+ /**
+ * Set the callback interface for notifying changes in supported latency modes.
+ *
+ * Calling this method with a null pointer will result in clearing a previously set callback.
+ *
+ * Support for this method is optional but mandated on specific spatial audio
+ * streams indicated by AUDIO_OUTPUT_FLAG_SPATIALIZER flag if they can be routed
+ * to a BT classic sink.
+ *
+ * \param[in] stream the stream object.
+ * \param[in] callback the registered callback or null to unregister.
+ * \param[in] cookie the context to pass when calling the callback.
+ * \return 0 in case of success.
+ * -EINVAL if the arguments are invalid
+ * -ENOSYS if the function is not available
+ */
+ int (*set_latency_mode_callback)(struct audio_stream_out *stream,
+ stream_latency_mode_callback_t callback, void *cookie);
};
+
typedef struct audio_stream_out audio_stream_out_t;
struct audio_stream_in {