Jean-Michel Trivi | 56ec4ff | 2015-01-23 16:45:18 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2015 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 "ApmImplDefinitions.h" |
| 18 | |
| 19 | namespace android { |
| 20 | |
| 21 | // descriptor for audio outputs. Used to maintain current configuration of each opened audio output |
| 22 | // and keep track of the usage of this output by each audio stream type. |
| 23 | class AudioOutputDescriptor: public AudioPortConfig |
| 24 | { |
| 25 | public: |
| 26 | AudioOutputDescriptor(const sp<IOProfile>& profile); |
| 27 | |
| 28 | status_t dump(int fd); |
| 29 | |
| 30 | audio_devices_t device() const; |
| 31 | void changeRefCount(audio_stream_type_t stream, int delta); |
| 32 | |
| 33 | bool isDuplicated() const { return (mOutput1 != NULL && mOutput2 != NULL); } |
| 34 | audio_devices_t supportedDevices(); |
| 35 | uint32_t latency(); |
| 36 | bool sharesHwModuleWith(const sp<AudioOutputDescriptor> outputDesc); |
| 37 | bool isActive(uint32_t inPastMs = 0) const; |
| 38 | bool isStreamActive(audio_stream_type_t stream, |
| 39 | uint32_t inPastMs = 0, |
| 40 | nsecs_t sysTime = 0) const; |
| 41 | bool isStrategyActive(routing_strategy strategy, |
| 42 | uint32_t inPastMs = 0, |
| 43 | nsecs_t sysTime = 0) const; |
| 44 | |
| 45 | virtual void toAudioPortConfig(struct audio_port_config *dstConfig, |
| 46 | const struct audio_port_config *srcConfig = NULL) const; |
| 47 | virtual sp<AudioPort> getAudioPort() const { return mProfile; } |
| 48 | void toAudioPort(struct audio_port *port) const; |
| 49 | |
| 50 | audio_port_handle_t mId; |
| 51 | audio_io_handle_t mIoHandle; // output handle |
| 52 | uint32_t mLatency; // |
| 53 | audio_output_flags_t mFlags; // |
| 54 | audio_devices_t mDevice; // current device this output is routed to |
| 55 | AudioMix *mPolicyMix; // non NULL when used by a dynamic policy |
| 56 | audio_patch_handle_t mPatchHandle; |
| 57 | uint32_t mRefCount[AUDIO_STREAM_CNT]; // number of streams of each type using this output |
| 58 | nsecs_t mStopTime[AUDIO_STREAM_CNT]; |
| 59 | sp<AudioOutputDescriptor> mOutput1; // used by duplicated outputs: first output |
| 60 | sp<AudioOutputDescriptor> mOutput2; // used by duplicated outputs: second output |
| 61 | float mCurVolume[AUDIO_STREAM_CNT]; // current stream volume |
| 62 | int mMuteCount[AUDIO_STREAM_CNT]; // mute request counter |
| 63 | const sp<IOProfile> mProfile; // I/O profile this output derives from |
| 64 | bool mStrategyMutedByDevice[NUM_STRATEGIES]; // strategies muted because of incompatible |
| 65 | // device selection. See checkDeviceMuteStrategies() |
| 66 | uint32_t mDirectOpenCount; // number of clients using this output (direct outputs only) |
| 67 | }; |
| 68 | |
| 69 | }; // namespace android |