summaryrefslogtreecommitdiffstats
path: root/services/audiopolicy/common/managerdefinitions/include/AudioPort.h
diff options
context:
space:
mode:
Diffstat (limited to 'services/audiopolicy/common/managerdefinitions/include/AudioPort.h')
-rw-r--r--services/audiopolicy/common/managerdefinitions/include/AudioPort.h126
1 files changed, 126 insertions, 0 deletions
diff --git a/services/audiopolicy/common/managerdefinitions/include/AudioPort.h b/services/audiopolicy/common/managerdefinitions/include/AudioPort.h
new file mode 100644
index 0000000..52e845c
--- /dev/null
+++ b/services/audiopolicy/common/managerdefinitions/include/AudioPort.h
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <utils/String8.h>
+#include <utils/Vector.h>
+#include <utils/RefBase.h>
+#include <utils/Errors.h>
+#include <system/audio.h>
+#include <cutils/config_utils.h>
+
+#define MAX_MIXER_SAMPLING_RATE 48000
+#define MAX_MIXER_CHANNEL_COUNT 8
+
+namespace android {
+
+class HwModule;
+class AudioGain;
+
+class AudioPort: public virtual RefBase
+{
+public:
+ AudioPort(const String8& name, audio_port_type_t type,
+ audio_port_role_t role, const sp<HwModule>& module);
+ virtual ~AudioPort() {}
+
+ audio_port_handle_t getHandle() { return mId; }
+
+ void attach(const sp<HwModule>& module);
+ bool isAttached() { return mId != 0; }
+
+ static audio_port_handle_t getNextUniqueId();
+
+ virtual void toAudioPort(struct audio_port *port) const;
+
+ void importAudioPort(const sp<AudioPort> port);
+ void clearCapabilities();
+
+ void loadSamplingRates(char *name);
+ void loadFormats(char *name);
+ void loadOutChannels(char *name);
+ void loadInChannels(char *name);
+
+ audio_gain_mode_t loadGainMode(char *name);
+ void loadGain(cnode *root, int index);
+ virtual void loadGains(cnode *root);
+
+ // searches for an exact match
+ status_t checkExactSamplingRate(uint32_t samplingRate) const;
+ // searches for a compatible match, and returns the best match via updatedSamplingRate
+ status_t checkCompatibleSamplingRate(uint32_t samplingRate,
+ uint32_t *updatedSamplingRate) const;
+ // searches for an exact match
+ status_t checkExactChannelMask(audio_channel_mask_t channelMask) const;
+ // searches for a compatible match, currently implemented for input channel masks only
+ status_t checkCompatibleChannelMask(audio_channel_mask_t channelMask) const;
+ status_t checkFormat(audio_format_t format) const;
+ status_t checkGain(const struct audio_gain_config *gainConfig, int index) const;
+
+ uint32_t pickSamplingRate() const;
+ audio_channel_mask_t pickChannelMask() const;
+ audio_format_t pickFormat() const;
+
+ static const audio_format_t sPcmFormatCompareTable[];
+ static int compareFormats(audio_format_t format1, audio_format_t format2);
+
+ void dump(int fd, int spaces) const;
+
+ String8 mName;
+ audio_port_type_t mType;
+ audio_port_role_t mRole;
+ bool mUseInChannelMask;
+ // by convention, "0' in the first entry in mSamplingRates, mChannelMasks or mFormats
+ // indicates the supported parameters should be read from the output stream
+ // after it is opened for the first time
+ Vector <uint32_t> mSamplingRates; // supported sampling rates
+ Vector <audio_channel_mask_t> mChannelMasks; // supported channel masks
+ Vector <audio_format_t> mFormats; // supported audio formats
+ Vector < sp<AudioGain> > mGains; // gain controllers
+ sp<HwModule> mModule; // audio HW module exposing this I/O stream
+ uint32_t mFlags; // attribute flags (e.g primary output,
+ // direct output...).
+
+
+protected:
+ //TODO - clarify the role of mId in this case, both an "attached" indicator
+ // and a unique ID for identifying a port to the (upcoming) selection API,
+ // and its relationship to the mId in AudioOutputDescriptor and AudioInputDescriptor.
+ audio_port_handle_t mId;
+
+private:
+ static volatile int32_t mNextUniqueId;
+};
+
+class AudioPortConfig: public virtual RefBase
+{
+public:
+ AudioPortConfig();
+ virtual ~AudioPortConfig() {}
+
+ status_t applyAudioPortConfig(const struct audio_port_config *config,
+ struct audio_port_config *backupConfig = NULL);
+ virtual void toAudioPortConfig(struct audio_port_config *dstConfig,
+ const struct audio_port_config *srcConfig = NULL) const = 0;
+ virtual sp<AudioPort> getAudioPort() const = 0;
+ uint32_t mSamplingRate;
+ audio_format_t mFormat;
+ audio_channel_mask_t mChannelMask;
+ struct audio_gain_config mGain;
+};
+
+}; // namespace android