Loading audio/7.1/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -13,11 +13,13 @@ hidl_interface { name: "android.hardware.audio@7.1", root: "android.hardware", srcs: [ "types.hal", "IDevice.hal", "IDevicesFactory.hal", "IPrimaryDevice.hal", "IStreamIn.hal", "IStreamOut.hal", "IStreamOutLatencyModeCallback.hal", ], interfaces: [ "android.hardware.audio@7.0", Loading audio/7.1/IStreamOut.hal +47 −0 Original line number Diff line number Diff line Loading @@ -16,7 +16,54 @@ package android.hardware.audio@7.1; import @7.0::Result; import @7.0::IStreamOut; import IStreamOutLatencyModeCallback; interface IStreamOut extends @7.0::IStreamOut { /** * Indicates the requested latency mode for this output stream. * * The requested mode can be one of the modes returned by * getRecommendedLatencyModes() API. * * Optional method. * Mandated only on specific spatial audio streams indicated by * AUDIO_OUTPUT_FLAG_SPATIALIZER flag if they can be routed to a BT classic sink. * * @return retval operation completion status. */ setLatencyMode(LatencyMode mode) generates (Result retval); /** * 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. * * Optional method. * Mandated only on specific spatial audio streams indicated by * AUDIO_OUTPUT_FLAG_SPATIALIZER flag if they can be routed to a BT classic sink. * * @return retval operation completion status. * @return modes currrently supported latency modes. */ getRecommendedLatencyModes() generates (Result retval, vec<LatencyMode> modes); /** * Set the callback interface for notifying changes in supported latency modes. * * Calling this method with a null pointer will result in releasing * the callback. * * Optional method. * Mandated only on specific spatial audio streams indicated by * AUDIO_OUTPUT_FLAG_SPATIALIZER flag if they can be routed to a BT classic sink. * * @return retval operation completion status. */ setLatencyModeCallback(IStreamOutLatencyModeCallback callback) generates (Result retval); }; audio/7.1/IStreamOutLatencyModeCallback.hal 0 → 100644 +28 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.hardware.audio@7.1; /** * Callback interface for output stream variable latency mode feature. */ interface IStreamOutLatencyModeCallback { /** * Called with the new list of supported latency modes when a change occurs. */ oneway onRecommendedLatencyModeChanged(vec<LatencyMode> modes); }; audio/7.1/types.hal 0 → 100644 +30 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.hardware.audio@7.1; /** * Latency modes used for the variable latency feature on output streams. * Used by setLatencyMode() and getRecommendedLatencyModes() methods. */ @export(name="audio_latency_mode_t", value_prefix="AUDIO_LATENCY_MODE_") enum LatencyMode : int32_t { /** No specific constraint on the latency */ FREE = 0, /** A relatively low latency compatible with head tracking operation (e.g less than 100ms) */ LOW = 1, }; audio/core/all-versions/default/StreamOut.cpp +67 −0 Original line number Diff line number Diff line Loading @@ -761,6 +761,73 @@ int StreamOut::asyncEventCallback(stream_event_callback_type_t event, void* para ALOGW_IF(!result.isOk(), "Client callback failed: %s", result.description().c_str()); return 0; } #if MAJOR_VERSION == 7 && MINOR_VERSION == 1 Return<Result> StreamOut::setLatencyMode(LatencyMode mode) { return mStream->set_latency_mode != nullptr ? Stream::analyzeStatus( "set_latency_mode", mStream->set_latency_mode(mStream, static_cast<audio_latency_mode_t>(mode))) : Result::NOT_SUPPORTED; }; Return<void> StreamOut::getRecommendedLatencyModes(getRecommendedLatencyModes_cb _hidl_cb) { Result retval = Result::NOT_SUPPORTED; hidl_vec<LatencyMode> hidlModes; size_t num_modes = AUDIO_LATENCY_MODE_CNT; audio_latency_mode_t modes[AUDIO_LATENCY_MODE_CNT]; if (mStream->get_recommended_latency_modes != nullptr && mStream->get_recommended_latency_modes(mStream, &modes[0], &num_modes) == 0) { if (num_modes == 0 || num_modes > AUDIO_LATENCY_MODE_CNT) { ALOGW("%s invalid number of modes returned: %zu", __func__, num_modes); retval = Result::INVALID_STATE; } else { hidlModes.resize(num_modes); for (size_t i = 0; i < num_modes; ++i) { hidlModes[i] = static_cast<LatencyMode>(modes[i]); } retval = Result::OK; } } _hidl_cb(retval, hidlModes); return Void(); }; // static void StreamOut::latencyModeCallback(audio_latency_mode_t* modes, size_t num_modes, void* cookie) { StreamOut* self = reinterpret_cast<StreamOut*>(cookie); sp<IStreamOutLatencyModeCallback> callback = self->mLatencyModeCallback.load(); if (callback.get() == nullptr) return; ALOGV("%s", __func__); if (num_modes == 0 || num_modes > AUDIO_LATENCY_MODE_CNT) { ALOGW("%s invalid number of modes returned: %zu", __func__, num_modes); return; } hidl_vec<LatencyMode> hidlModes(num_modes); for (size_t i = 0; i < num_modes; ++i) { hidlModes[i] = static_cast<LatencyMode>(modes[i]); } Return<void> result = callback->onRecommendedLatencyModeChanged(hidlModes); ALOGW_IF(!result.isOk(), "Client callback failed: %s", result.description().c_str()); } Return<Result> StreamOut::setLatencyModeCallback( const sp<IStreamOutLatencyModeCallback>& callback) { if (mStream->set_latency_mode_callback == nullptr) return Result::NOT_SUPPORTED; int result = mStream->set_latency_mode_callback(mStream, StreamOut::latencyModeCallback, this); if (result == 0) { mLatencyModeCallback = callback; } return Stream::analyzeStatus("set_latency_mode_callback", result, {ENOSYS} /*ignore*/); }; #endif #endif } // namespace implementation Loading Loading
audio/7.1/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -13,11 +13,13 @@ hidl_interface { name: "android.hardware.audio@7.1", root: "android.hardware", srcs: [ "types.hal", "IDevice.hal", "IDevicesFactory.hal", "IPrimaryDevice.hal", "IStreamIn.hal", "IStreamOut.hal", "IStreamOutLatencyModeCallback.hal", ], interfaces: [ "android.hardware.audio@7.0", Loading
audio/7.1/IStreamOut.hal +47 −0 Original line number Diff line number Diff line Loading @@ -16,7 +16,54 @@ package android.hardware.audio@7.1; import @7.0::Result; import @7.0::IStreamOut; import IStreamOutLatencyModeCallback; interface IStreamOut extends @7.0::IStreamOut { /** * Indicates the requested latency mode for this output stream. * * The requested mode can be one of the modes returned by * getRecommendedLatencyModes() API. * * Optional method. * Mandated only on specific spatial audio streams indicated by * AUDIO_OUTPUT_FLAG_SPATIALIZER flag if they can be routed to a BT classic sink. * * @return retval operation completion status. */ setLatencyMode(LatencyMode mode) generates (Result retval); /** * 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. * * Optional method. * Mandated only on specific spatial audio streams indicated by * AUDIO_OUTPUT_FLAG_SPATIALIZER flag if they can be routed to a BT classic sink. * * @return retval operation completion status. * @return modes currrently supported latency modes. */ getRecommendedLatencyModes() generates (Result retval, vec<LatencyMode> modes); /** * Set the callback interface for notifying changes in supported latency modes. * * Calling this method with a null pointer will result in releasing * the callback. * * Optional method. * Mandated only on specific spatial audio streams indicated by * AUDIO_OUTPUT_FLAG_SPATIALIZER flag if they can be routed to a BT classic sink. * * @return retval operation completion status. */ setLatencyModeCallback(IStreamOutLatencyModeCallback callback) generates (Result retval); };
audio/7.1/IStreamOutLatencyModeCallback.hal 0 → 100644 +28 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.hardware.audio@7.1; /** * Callback interface for output stream variable latency mode feature. */ interface IStreamOutLatencyModeCallback { /** * Called with the new list of supported latency modes when a change occurs. */ oneway onRecommendedLatencyModeChanged(vec<LatencyMode> modes); };
audio/7.1/types.hal 0 → 100644 +30 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.hardware.audio@7.1; /** * Latency modes used for the variable latency feature on output streams. * Used by setLatencyMode() and getRecommendedLatencyModes() methods. */ @export(name="audio_latency_mode_t", value_prefix="AUDIO_LATENCY_MODE_") enum LatencyMode : int32_t { /** No specific constraint on the latency */ FREE = 0, /** A relatively low latency compatible with head tracking operation (e.g less than 100ms) */ LOW = 1, };
audio/core/all-versions/default/StreamOut.cpp +67 −0 Original line number Diff line number Diff line Loading @@ -761,6 +761,73 @@ int StreamOut::asyncEventCallback(stream_event_callback_type_t event, void* para ALOGW_IF(!result.isOk(), "Client callback failed: %s", result.description().c_str()); return 0; } #if MAJOR_VERSION == 7 && MINOR_VERSION == 1 Return<Result> StreamOut::setLatencyMode(LatencyMode mode) { return mStream->set_latency_mode != nullptr ? Stream::analyzeStatus( "set_latency_mode", mStream->set_latency_mode(mStream, static_cast<audio_latency_mode_t>(mode))) : Result::NOT_SUPPORTED; }; Return<void> StreamOut::getRecommendedLatencyModes(getRecommendedLatencyModes_cb _hidl_cb) { Result retval = Result::NOT_SUPPORTED; hidl_vec<LatencyMode> hidlModes; size_t num_modes = AUDIO_LATENCY_MODE_CNT; audio_latency_mode_t modes[AUDIO_LATENCY_MODE_CNT]; if (mStream->get_recommended_latency_modes != nullptr && mStream->get_recommended_latency_modes(mStream, &modes[0], &num_modes) == 0) { if (num_modes == 0 || num_modes > AUDIO_LATENCY_MODE_CNT) { ALOGW("%s invalid number of modes returned: %zu", __func__, num_modes); retval = Result::INVALID_STATE; } else { hidlModes.resize(num_modes); for (size_t i = 0; i < num_modes; ++i) { hidlModes[i] = static_cast<LatencyMode>(modes[i]); } retval = Result::OK; } } _hidl_cb(retval, hidlModes); return Void(); }; // static void StreamOut::latencyModeCallback(audio_latency_mode_t* modes, size_t num_modes, void* cookie) { StreamOut* self = reinterpret_cast<StreamOut*>(cookie); sp<IStreamOutLatencyModeCallback> callback = self->mLatencyModeCallback.load(); if (callback.get() == nullptr) return; ALOGV("%s", __func__); if (num_modes == 0 || num_modes > AUDIO_LATENCY_MODE_CNT) { ALOGW("%s invalid number of modes returned: %zu", __func__, num_modes); return; } hidl_vec<LatencyMode> hidlModes(num_modes); for (size_t i = 0; i < num_modes; ++i) { hidlModes[i] = static_cast<LatencyMode>(modes[i]); } Return<void> result = callback->onRecommendedLatencyModeChanged(hidlModes); ALOGW_IF(!result.isOk(), "Client callback failed: %s", result.description().c_str()); } Return<Result> StreamOut::setLatencyModeCallback( const sp<IStreamOutLatencyModeCallback>& callback) { if (mStream->set_latency_mode_callback == nullptr) return Result::NOT_SUPPORTED; int result = mStream->set_latency_mode_callback(mStream, StreamOut::latencyModeCallback, this); if (result == 0) { mLatencyModeCallback = callback; } return Stream::analyzeStatus("set_latency_mode_callback", result, {ENOSYS} /*ignore*/); }; #endif #endif } // namespace implementation Loading