Mikhail Naganov | 1054829 | 2016-10-31 10:39:47 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 | |
Steven Moreland | d6e4f03 | 2016-11-28 18:37:07 -0800 | [diff] [blame] | 17 | #ifndef ANDROID_HARDWARE_AUDIO_V2_0_DEVICE_H |
| 18 | #define ANDROID_HARDWARE_AUDIO_V2_0_DEVICE_H |
Mikhail Naganov | 1054829 | 2016-10-31 10:39:47 -0700 | [diff] [blame] | 19 | |
| 20 | #include <memory> |
| 21 | |
| 22 | #include <media/AudioParameter.h> |
| 23 | #include <hardware/audio.h> |
| 24 | |
| 25 | #include <android/hardware/audio/2.0/IDevice.h> |
| 26 | #include <hidl/Status.h> |
| 27 | |
| 28 | #include <hidl/MQDescriptor.h> |
| 29 | |
Mikhail Naganov | 1054829 | 2016-10-31 10:39:47 -0700 | [diff] [blame] | 30 | namespace android { |
| 31 | namespace hardware { |
| 32 | namespace audio { |
| 33 | namespace V2_0 { |
| 34 | namespace implementation { |
| 35 | |
Mikhail Naganov | e4228e7 | 2017-04-28 13:20:56 -0700 | [diff] [blame] | 36 | class ParametersUtil; |
| 37 | |
Mikhail Naganov | 1054829 | 2016-10-31 10:39:47 -0700 | [diff] [blame] | 38 | using ::android::hardware::audio::common::V2_0::AudioConfig; |
Mikhail Naganov | 1054829 | 2016-10-31 10:39:47 -0700 | [diff] [blame] | 39 | using ::android::hardware::audio::common::V2_0::AudioHwSync; |
| 40 | using ::android::hardware::audio::common::V2_0::AudioInputFlag; |
Mikhail Naganov | 1054829 | 2016-10-31 10:39:47 -0700 | [diff] [blame] | 41 | using ::android::hardware::audio::common::V2_0::AudioOutputFlag; |
| 42 | using ::android::hardware::audio::common::V2_0::AudioPatchHandle; |
| 43 | using ::android::hardware::audio::common::V2_0::AudioPort; |
| 44 | using ::android::hardware::audio::common::V2_0::AudioPortConfig; |
Mikhail Naganov | 1054829 | 2016-10-31 10:39:47 -0700 | [diff] [blame] | 45 | using ::android::hardware::audio::common::V2_0::AudioSource; |
Mikhail Naganov | 1054829 | 2016-10-31 10:39:47 -0700 | [diff] [blame] | 46 | using ::android::hardware::audio::V2_0::DeviceAddress; |
| 47 | using ::android::hardware::audio::V2_0::IDevice; |
| 48 | using ::android::hardware::audio::V2_0::IStreamIn; |
| 49 | using ::android::hardware::audio::V2_0::IStreamOut; |
| 50 | using ::android::hardware::audio::V2_0::ParameterValue; |
| 51 | using ::android::hardware::audio::V2_0::Result; |
| 52 | using ::android::hardware::Return; |
| 53 | using ::android::hardware::Void; |
| 54 | using ::android::hardware::hidl_vec; |
| 55 | using ::android::hardware::hidl_string; |
| 56 | using ::android::sp; |
| 57 | |
Mikhail Naganov | e4228e7 | 2017-04-28 13:20:56 -0700 | [diff] [blame] | 58 | struct Device : public IDevice { |
Mikhail Naganov | 1054829 | 2016-10-31 10:39:47 -0700 | [diff] [blame] | 59 | explicit Device(audio_hw_device_t* device); |
| 60 | |
| 61 | // Methods from ::android::hardware::audio::V2_0::IDevice follow. |
| 62 | Return<Result> initCheck() override; |
| 63 | Return<Result> setMasterVolume(float volume) override; |
| 64 | Return<void> getMasterVolume(getMasterVolume_cb _hidl_cb) override; |
| 65 | Return<Result> setMicMute(bool mute) override; |
| 66 | Return<void> getMicMute(getMicMute_cb _hidl_cb) override; |
| 67 | Return<Result> setMasterMute(bool mute) override; |
| 68 | Return<void> getMasterMute(getMasterMute_cb _hidl_cb) override; |
| 69 | Return<void> getInputBufferSize( |
| 70 | const AudioConfig& config, getInputBufferSize_cb _hidl_cb) override; |
| 71 | Return<void> openOutputStream( |
| 72 | int32_t ioHandle, |
| 73 | const DeviceAddress& device, |
| 74 | const AudioConfig& config, |
| 75 | AudioOutputFlag flags, |
| 76 | openOutputStream_cb _hidl_cb) override; |
| 77 | Return<void> openInputStream( |
| 78 | int32_t ioHandle, |
| 79 | const DeviceAddress& device, |
| 80 | const AudioConfig& config, |
| 81 | AudioInputFlag flags, |
| 82 | AudioSource source, |
| 83 | openInputStream_cb _hidl_cb) override; |
Mikhail Naganov | 6e81e9b | 2016-11-16 16:30:17 -0800 | [diff] [blame] | 84 | Return<bool> supportsAudioPatches() override; |
Mikhail Naganov | 1054829 | 2016-10-31 10:39:47 -0700 | [diff] [blame] | 85 | Return<void> createAudioPatch( |
| 86 | const hidl_vec<AudioPortConfig>& sources, |
| 87 | const hidl_vec<AudioPortConfig>& sinks, |
| 88 | createAudioPatch_cb _hidl_cb) override; |
| 89 | Return<Result> releaseAudioPatch(int32_t patch) override; |
| 90 | Return<void> getAudioPort(const AudioPort& port, getAudioPort_cb _hidl_cb) override; |
| 91 | Return<Result> setAudioPortConfig(const AudioPortConfig& config) override; |
| 92 | Return<AudioHwSync> getHwAvSync() override; |
| 93 | Return<Result> setScreenState(bool turnedOn) override; |
| 94 | Return<void> getParameters( |
| 95 | const hidl_vec<hidl_string>& keys, getParameters_cb _hidl_cb) override; |
| 96 | Return<Result> setParameters(const hidl_vec<ParameterValue>& parameters) override; |
Martijn Coenen | 70b9a15 | 2016-11-18 15:29:32 +0100 | [diff] [blame] | 97 | Return<void> debugDump(const hidl_handle& fd) override; |
Mikhail Naganov | 1054829 | 2016-10-31 10:39:47 -0700 | [diff] [blame] | 98 | |
| 99 | // Utility methods for extending interfaces. |
| 100 | Result analyzeStatus(const char* funcName, int status); |
Mikhail Naganov | 936279e | 2017-03-29 09:31:18 -0700 | [diff] [blame] | 101 | void closeInputStream(audio_stream_in_t* stream); |
| 102 | void closeOutputStream(audio_stream_out_t* stream); |
Mikhail Naganov | 1054829 | 2016-10-31 10:39:47 -0700 | [diff] [blame] | 103 | audio_hw_device_t* device() const { return mDevice; } |
Mikhail Naganov | e4228e7 | 2017-04-28 13:20:56 -0700 | [diff] [blame] | 104 | Result getParam(const char* name, bool* value); |
| 105 | Result getParam(const char* name, int* value); |
| 106 | Result getParam(const char* name, String8* value); |
| 107 | Result setParam(const char* name, bool value); |
| 108 | Result setParam(const char* name, int value); |
| 109 | Result setParam(const char* name, const char* value); |
Mikhail Naganov | 1054829 | 2016-10-31 10:39:47 -0700 | [diff] [blame] | 110 | |
Mikhail Naganov | e4228e7 | 2017-04-28 13:20:56 -0700 | [diff] [blame] | 111 | private: |
Mikhail Naganov | 1054829 | 2016-10-31 10:39:47 -0700 | [diff] [blame] | 112 | audio_hw_device_t *mDevice; |
Mikhail Naganov | e4228e7 | 2017-04-28 13:20:56 -0700 | [diff] [blame] | 113 | std::unique_ptr<ParametersUtil> mParameters; |
Mikhail Naganov | 1054829 | 2016-10-31 10:39:47 -0700 | [diff] [blame] | 114 | |
Mikhail Naganov | 1054829 | 2016-10-31 10:39:47 -0700 | [diff] [blame] | 115 | virtual ~Device(); |
| 116 | |
Mikhail Naganov | 1054829 | 2016-10-31 10:39:47 -0700 | [diff] [blame] | 117 | uint32_t version() const { return mDevice->common.version; } |
| 118 | }; |
| 119 | |
| 120 | } // namespace implementation |
| 121 | } // namespace V2_0 |
| 122 | } // namespace audio |
| 123 | } // namespace hardware |
| 124 | } // namespace android |
| 125 | |
Steven Moreland | d6e4f03 | 2016-11-28 18:37:07 -0800 | [diff] [blame] | 126 | #endif // ANDROID_HARDWARE_AUDIO_V2_0_DEVICE_H |