Shunkai Yao | 242521c | 2023-01-29 18:08:09 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2023 The Android Open Source Project |
| 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 | |
| 17 | #include <cstdint> |
| 18 | #include <cstring> |
| 19 | #include <optional> |
| 20 | #define LOG_TAG "AidlConversionVisualizer" |
| 21 | //#define LOG_NDEBUG 0 |
| 22 | |
| 23 | #include <error/expected_utils.h> |
| 24 | #include <media/AidlConversionNdk.h> |
| 25 | #include <media/AidlConversionEffect.h> |
| 26 | #include <media/audiohal/AudioEffectUuid.h> |
| 27 | #include <system/audio_effects/effect_visualizer.h> |
| 28 | |
| 29 | #include <utils/Log.h> |
| 30 | |
| 31 | #include "AidlConversionVisualizer.h" |
| 32 | |
| 33 | namespace android { |
| 34 | namespace effect { |
| 35 | |
| 36 | using ::aidl::android::aidl_utils::statusTFromBinderStatus; |
| 37 | using ::aidl::android::hardware::audio::effect::Parameter; |
| 38 | using ::android::status_t; |
| 39 | using utils::EffectParamReader; |
| 40 | using utils::EffectParamWriter; |
| 41 | |
| 42 | status_t AidlConversionVisualizer::setParameter(EffectParamReader& param) { |
| 43 | uint32_t type = 0; |
| 44 | uint16_t value = 0; |
| 45 | if (!param.validateParamValueSize(sizeof(uint32_t), sizeof(uint16_t)) || |
| 46 | OK != param.readFromParameter(&type) || OK != param.readFromValue(&value)) { |
| 47 | ALOGE("%s invalid param %s", __func__, param.toString().c_str()); |
| 48 | return BAD_VALUE; |
| 49 | } |
| 50 | Parameter aidlParam; |
| 51 | // TODO |
| 52 | return statusTFromBinderStatus(mEffect->setParameter(aidlParam)); |
| 53 | } |
| 54 | |
| 55 | status_t AidlConversionVisualizer::getParameter(EffectParamWriter& param) { |
| 56 | uint32_t type = 0, value = 0; |
| 57 | if (!param.validateParamValueSize(sizeof(uint32_t), sizeof(uint32_t)) || |
| 58 | OK != param.readFromParameter(&type)) { |
| 59 | ALOGE("%s invalid param %s", __func__, param.toString().c_str()); |
| 60 | param.setStatus(BAD_VALUE); |
| 61 | return BAD_VALUE; |
| 62 | } |
| 63 | // TODO |
| 64 | return param.writeToValue(&value); |
| 65 | } |
| 66 | |
| 67 | } // namespace effect |
| 68 | } // namespace android |