blob: f7a06eea0ab5f1105e887024b6bdf1b2d711e4b8 [file] [log] [blame]
Jean-Michel Trivi56ec4ff2015-01-23 16:45:18 -08001/*
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
François Gaffiead3183e2015-03-18 16:55:35 +010017#pragma once
18
19#include "Ports.h"
Jean-Michel Trivi56ec4ff2015-01-23 16:45:18 -080020#include "ApmImplDefinitions.h"
François Gaffiead3183e2015-03-18 16:55:35 +010021#include <utils/Errors.h>
22#include <utils/Timers.h>
23#include <system/audio.h>
Jean-Michel Trivi56ec4ff2015-01-23 16:45:18 -080024
25namespace android {
26
François Gaffiead3183e2015-03-18 16:55:35 +010027class IOProfile;
28class AudioMix;
29
Jean-Michel Trivi56ec4ff2015-01-23 16:45:18 -080030// 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 bool isDuplicated() const { return (mOutput1 != NULL && mOutput2 != NULL); }
43 audio_devices_t supportedDevices();
44 uint32_t latency();
45 bool sharesHwModuleWith(const sp<AudioOutputDescriptor> outputDesc);
46 bool isActive(uint32_t inPastMs = 0) const;
47 bool isStreamActive(audio_stream_type_t stream,
48 uint32_t inPastMs = 0,
49 nsecs_t sysTime = 0) const;
Jean-Michel Trivi56ec4ff2015-01-23 16:45:18 -080050
51 virtual void toAudioPortConfig(struct audio_port_config *dstConfig,
52 const struct audio_port_config *srcConfig = NULL) const;
53 virtual sp<AudioPort> getAudioPort() const { return mProfile; }
54 void toAudioPort(struct audio_port *port) const;
55
56 audio_port_handle_t mId;
57 audio_io_handle_t mIoHandle; // output handle
58 uint32_t mLatency; //
59 audio_output_flags_t mFlags; //
60 audio_devices_t mDevice; // current device this output is routed to
61 AudioMix *mPolicyMix; // non NULL when used by a dynamic policy
62 audio_patch_handle_t mPatchHandle;
63 uint32_t mRefCount[AUDIO_STREAM_CNT]; // number of streams of each type using this output
64 nsecs_t mStopTime[AUDIO_STREAM_CNT];
65 sp<AudioOutputDescriptor> mOutput1; // used by duplicated outputs: first output
66 sp<AudioOutputDescriptor> mOutput2; // used by duplicated outputs: second output
67 float mCurVolume[AUDIO_STREAM_CNT]; // current stream volume
68 int mMuteCount[AUDIO_STREAM_CNT]; // mute request counter
69 const sp<IOProfile> mProfile; // I/O profile this output derives from
70 bool mStrategyMutedByDevice[NUM_STRATEGIES]; // strategies muted because of incompatible
71 // device selection. See checkDeviceMuteStrategies()
72 uint32_t mDirectOpenCount; // number of clients using this output (direct outputs only)
73};
74
75}; // namespace android