Phil Burk | 062e67a | 2015-02-11 13:40:50 -0800 | [diff] [blame] | 1 | /* |
| 2 | ** |
| 3 | ** Copyright 2007, The Android Open Source Project |
| 4 | ** |
| 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | ** you may not use this file except in compliance with the License. |
| 7 | ** You may obtain a copy of the License at |
| 8 | ** |
| 9 | ** http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | ** |
| 11 | ** Unless required by applicable law or agreed to in writing, software |
| 12 | ** distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | ** See the License for the specific language governing permissions and |
| 15 | ** limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | #ifndef ANDROID_AUDIO_HW_DEVICE_H |
| 19 | #define ANDROID_AUDIO_HW_DEVICE_H |
| 20 | |
| 21 | #include <stdint.h> |
| 22 | #include <stdlib.h> |
| 23 | #include <sys/types.h> |
| 24 | |
Mikhail Naganov | a0c9133 | 2016-09-19 10:01:12 -0700 | [diff] [blame] | 25 | #include <media/audiohal/DeviceHalInterface.h> |
Phil Burk | 062e67a | 2015-02-11 13:40:50 -0800 | [diff] [blame] | 26 | #include <utils/Errors.h> |
| 27 | #include <system/audio.h> |
| 28 | |
Phil Burk | 062e67a | 2015-02-11 13:40:50 -0800 | [diff] [blame] | 29 | namespace android { |
| 30 | |
| 31 | class AudioStreamOut; |
| 32 | |
| 33 | class AudioHwDevice { |
| 34 | public: |
| 35 | enum Flags { |
| 36 | AHWD_CAN_SET_MASTER_VOLUME = 0x1, |
| 37 | AHWD_CAN_SET_MASTER_MUTE = 0x2, |
| 38 | }; |
| 39 | |
| 40 | AudioHwDevice(audio_module_handle_t handle, |
| 41 | const char *moduleName, |
Mikhail Naganov | e4f1f63 | 2016-08-31 11:35:10 -0700 | [diff] [blame] | 42 | sp<DeviceHalInterface> hwDevice, |
Phil Burk | 062e67a | 2015-02-11 13:40:50 -0800 | [diff] [blame] | 43 | Flags flags) |
| 44 | : mHandle(handle) |
| 45 | , mModuleName(strdup(moduleName)) |
| 46 | , mHwDevice(hwDevice) |
| 47 | , mFlags(flags) { } |
| 48 | virtual ~AudioHwDevice() { free((void *)mModuleName); } |
| 49 | |
| 50 | bool canSetMasterVolume() const { |
| 51 | return (0 != (mFlags & AHWD_CAN_SET_MASTER_VOLUME)); |
| 52 | } |
| 53 | |
| 54 | bool canSetMasterMute() const { |
| 55 | return (0 != (mFlags & AHWD_CAN_SET_MASTER_MUTE)); |
| 56 | } |
| 57 | |
| 58 | audio_module_handle_t handle() const { return mHandle; } |
| 59 | const char *moduleName() const { return mModuleName; } |
Mikhail Naganov | e4f1f63 | 2016-08-31 11:35:10 -0700 | [diff] [blame] | 60 | sp<DeviceHalInterface> hwDevice() const { return mHwDevice; } |
Phil Burk | 062e67a | 2015-02-11 13:40:50 -0800 | [diff] [blame] | 61 | |
| 62 | /** This method creates and opens the audio hardware output stream. |
| 63 | * The "address" parameter qualifies the "devices" audio device type if needed. |
| 64 | * The format format depends on the device type: |
| 65 | * - Bluetooth devices use the MAC address of the device in the form "00:11:22:AA:BB:CC" |
| 66 | * - USB devices use the ALSA card and device numbers in the form "card=X;device=Y" |
| 67 | * - Other devices may use a number or any other string. |
| 68 | */ |
| 69 | status_t openOutputStream( |
| 70 | AudioStreamOut **ppStreamOut, |
| 71 | audio_io_handle_t handle, |
| 72 | audio_devices_t devices, |
| 73 | audio_output_flags_t flags, |
| 74 | struct audio_config *config, |
| 75 | const char *address); |
| 76 | |
Mikhail Naganov | 9ee0540 | 2016-10-13 15:58:17 -0700 | [diff] [blame^] | 77 | bool supportsAudioPatches() const; |
| 78 | |
Phil Burk | 062e67a | 2015-02-11 13:40:50 -0800 | [diff] [blame] | 79 | private: |
| 80 | const audio_module_handle_t mHandle; |
| 81 | const char * const mModuleName; |
Mikhail Naganov | e4f1f63 | 2016-08-31 11:35:10 -0700 | [diff] [blame] | 82 | sp<DeviceHalInterface> mHwDevice; |
Phil Burk | 062e67a | 2015-02-11 13:40:50 -0800 | [diff] [blame] | 83 | const Flags mFlags; |
| 84 | }; |
| 85 | |
| 86 | } // namespace android |
| 87 | |
| 88 | #endif // ANDROID_AUDIO_HW_DEVICE_H |