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_STREAM_H |
| 18 | #define ANDROID_HARDWARE_AUDIO_V2_0_STREAM_H |
Mikhail Naganov | 1054829 | 2016-10-31 10:39:47 -0700 | [diff] [blame] | 19 | |
| 20 | #include <android/hardware/audio/2.0/IStream.h> |
| 21 | #include <hidl/Status.h> |
| 22 | |
| 23 | #include <hidl/MQDescriptor.h> |
| 24 | |
| 25 | #include "ParametersUtil.h" |
| 26 | |
| 27 | namespace android { |
| 28 | namespace hardware { |
| 29 | namespace audio { |
| 30 | namespace V2_0 { |
| 31 | namespace implementation { |
| 32 | |
| 33 | using ::android::hardware::audio::common::V2_0::AudioChannelMask; |
| 34 | using ::android::hardware::audio::common::V2_0::AudioDevice; |
| 35 | using ::android::hardware::audio::common::V2_0::AudioFormat; |
| 36 | using ::android::hardware::audio::V2_0::DeviceAddress; |
| 37 | using ::android::hardware::audio::V2_0::IStream; |
| 38 | using ::android::hardware::audio::V2_0::ParameterValue; |
| 39 | using ::android::hardware::audio::V2_0::Result; |
| 40 | using ::android::hardware::Return; |
| 41 | using ::android::hardware::Void; |
| 42 | using ::android::hardware::hidl_vec; |
| 43 | using ::android::hardware::hidl_string; |
| 44 | using ::android::sp; |
| 45 | |
| 46 | struct Stream : public IStream, public ParametersUtil { |
| 47 | explicit Stream(audio_stream_t* stream); |
| 48 | |
| 49 | // Methods from ::android::hardware::audio::V2_0::IStream follow. |
| 50 | Return<uint64_t> getFrameSize() override; |
| 51 | Return<uint64_t> getFrameCount() override; |
| 52 | Return<uint64_t> getBufferSize() override; |
| 53 | Return<uint32_t> getSampleRate() override; |
| 54 | Return<void> getSupportedSampleRates(getSupportedSampleRates_cb _hidl_cb) override; |
| 55 | Return<Result> setSampleRate(uint32_t sampleRateHz) override; |
| 56 | Return<AudioChannelMask> getChannelMask() override; |
| 57 | Return<void> getSupportedChannelMasks(getSupportedChannelMasks_cb _hidl_cb) override; |
| 58 | Return<Result> setChannelMask(AudioChannelMask mask) override; |
| 59 | Return<AudioFormat> getFormat() override; |
| 60 | Return<void> getSupportedFormats(getSupportedFormats_cb _hidl_cb) override; |
| 61 | Return<Result> setFormat(AudioFormat format) override; |
| 62 | Return<void> getAudioProperties(getAudioProperties_cb _hidl_cb) override; |
| 63 | Return<Result> addEffect(uint64_t effectId) override; |
| 64 | Return<Result> removeEffect(uint64_t effectId) override; |
| 65 | Return<Result> standby() override; |
| 66 | Return<AudioDevice> getDevice() override; |
| 67 | Return<Result> setDevice(const DeviceAddress& address) override; |
| 68 | Return<Result> setConnectedState(const DeviceAddress& address, bool connected) override; |
| 69 | Return<Result> setHwAvSync(uint32_t hwAvSync) override; |
| 70 | Return<void> getParameters( |
| 71 | const hidl_vec<hidl_string>& keys, getParameters_cb _hidl_cb) override; |
| 72 | Return<Result> setParameters(const hidl_vec<ParameterValue>& parameters) override; |
Martijn Coenen | 70b9a15 | 2016-11-18 15:29:32 +0100 | [diff] [blame] | 73 | Return<void> debugDump(const hidl_handle& fd) override; |
Mikhail Naganov | 1054829 | 2016-10-31 10:39:47 -0700 | [diff] [blame] | 74 | |
| 75 | // Utility methods for extending interfaces. |
Mikhail Naganov | 13f43f4 | 2016-12-07 17:05:40 -0800 | [diff] [blame] | 76 | Result analyzeStatus(const char* funcName, int status, int ignoreError = OK); |
Mikhail Naganov | 1054829 | 2016-10-31 10:39:47 -0700 | [diff] [blame] | 77 | |
| 78 | private: |
| 79 | audio_stream_t *mStream; |
| 80 | |
| 81 | virtual ~Stream(); |
| 82 | |
| 83 | // Methods from ParametersUtil. |
| 84 | char* halGetParameters(const char* keys) override; |
| 85 | int halSetParameters(const char* keysAndValues) override; |
| 86 | }; |
| 87 | |
| 88 | } // namespace implementation |
| 89 | } // namespace V2_0 |
| 90 | } // namespace audio |
| 91 | } // namespace hardware |
| 92 | } // namespace android |
| 93 | |
Steven Moreland | d6e4f03 | 2016-11-28 18:37:07 -0800 | [diff] [blame] | 94 | #endif // ANDROID_HARDWARE_AUDIO_V2_0_STREAM_H |