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