Kevin Rocard | 4a7484bd | 2018-02-23 19:11:06 -0800 | [diff] [blame] | 1 | /* |
Mikhail Naganov | cc73ef0 | 2020-11-06 10:09:52 -0800 | [diff] [blame] | 2 | * Copyright (C) 2021 The Android Open Source Project |
Kevin Rocard | 4a7484bd | 2018-02-23 19:11:06 -0800 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Mikhail Naganov | cc73ef0 | 2020-11-06 10:09:52 -0800 | [diff] [blame] | 17 | #pragma once |
Kevin Rocard | 4a7484bd | 2018-02-23 19:11:06 -0800 | [diff] [blame] | 18 | |
Kevin Rocard | 95213bf | 2018-11-08 17:16:57 -0800 | [diff] [blame] | 19 | #include PATH(android/hardware/audio/FILE_VERSION/types.h) |
Kevin Rocard | 4a7484bd | 2018-02-23 19:11:06 -0800 | [diff] [blame] | 20 | #include <hidl/HidlSupport.h> |
| 21 | |
Kevin Rocard | 070e751 | 2018-05-22 09:29:13 -0700 | [diff] [blame] | 22 | using ::android::hardware::audio::CPP_VERSION::ParameterValue; |
| 23 | using ::android::hardware::audio::CPP_VERSION::Result; |
Kevin Rocard | 4a7484bd | 2018-02-23 19:11:06 -0800 | [diff] [blame] | 24 | using ::android::hardware::Return; |
| 25 | using ::android::hardware::hidl_vec; |
| 26 | using ::android::hardware::hidl_string; |
| 27 | |
| 28 | namespace android { |
Kevin Rocard | 070e751 | 2018-05-22 09:29:13 -0700 | [diff] [blame] | 29 | namespace CPP_VERSION { |
Kevin Rocard | 4a7484bd | 2018-02-23 19:11:06 -0800 | [diff] [blame] | 30 | namespace utils { |
| 31 | |
Kevin Rocard | 070e751 | 2018-05-22 09:29:13 -0700 | [diff] [blame] | 32 | #if MAJOR_VERSION == 2 |
| 33 | template <class T, class Callback> |
| 34 | Return<void> getParameters(T& object, hidl_vec<ParameterValue> /*context*/, |
| 35 | hidl_vec<hidl_string> keys, Callback callback) { |
| 36 | return object->getParameters(keys, callback); |
| 37 | } |
| 38 | |
| 39 | template <class T> |
| 40 | Return<Result> setParameters(T& object, hidl_vec<ParameterValue> /*context*/, |
| 41 | hidl_vec<ParameterValue> keys) { |
| 42 | return object->setParameters(keys); |
| 43 | } |
Kevin Rocard | 3d48dce | 2018-11-08 17:16:57 -0800 | [diff] [blame] | 44 | #elif MAJOR_VERSION >= 4 |
Kevin Rocard | 4a7484bd | 2018-02-23 19:11:06 -0800 | [diff] [blame] | 45 | template <class T, class Callback> |
| 46 | Return<void> getParameters(T& object, hidl_vec<ParameterValue> context, |
| 47 | hidl_vec<hidl_string> keys, Callback callback) { |
| 48 | return object->getParameters(context, keys, callback); |
| 49 | } |
| 50 | |
| 51 | template <class T> |
| 52 | Return<Result> setParameters(T& object, hidl_vec<ParameterValue> context, |
| 53 | hidl_vec<ParameterValue> keys) { |
| 54 | return object->setParameters(context, keys); |
| 55 | } |
Kevin Rocard | 070e751 | 2018-05-22 09:29:13 -0700 | [diff] [blame] | 56 | #endif |
Kevin Rocard | 4a7484bd | 2018-02-23 19:11:06 -0800 | [diff] [blame] | 57 | |
| 58 | } // namespace utils |
Kevin Rocard | 070e751 | 2018-05-22 09:29:13 -0700 | [diff] [blame] | 59 | } // namespace CPP_VERSION |
Kevin Rocard | 4a7484bd | 2018-02-23 19:11:06 -0800 | [diff] [blame] | 60 | } // namespace android |