summaryrefslogtreecommitdiffstats
path: root/audio/compat.h
diff options
context:
space:
mode:
Diffstat (limited to 'audio/compat.h')
-rw-r--r--audio/compat.h85
1 files changed, 85 insertions, 0 deletions
diff --git a/audio/compat.h b/audio/compat.h
new file mode 100644
index 0000000..83813e2
--- /dev/null
+++ b/audio/compat.h
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ * Copyright (C) 2013 Denis 'GNUtoo' Carikli <GNUtoo@no-log.org>
+ *
+ * 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.
+ */
+#ifndef __COMPAT_H__
+#define __COMPAT_H__
+
+#include <system/audio.h>
+
+#ifndef ALOGE
+#define ALOGE LOGE
+#endif
+
+#ifndef ALOGI
+#define ALOGI LOGI
+#endif
+
+#ifndef ALOGD
+#define ALOGD LOGD
+#endif
+
+#ifndef ALOGV
+#define ALOGV LOGV
+#endif
+
+#ifndef audio_channel_mask_t
+typedef uint32_t audio_channel_mask_t;
+#endif
+
+#ifndef audio_channel_mask_from_count
+/* Derive a channel mask from a channel count.
+ * This is to be used when the content channel mask is unknown. The 1, 2, 4, 5, 6, 7 and 8 channel
+ * cases are mapped to the standard game/home-theater layouts, but note that 4 is mapped to quad,
+ * and not stereo + FC + mono surround. A channel count of 3 is arbitrarily mapped to stereo + FC
+ * for continuity with stereo.
+ * Returns the matching channel mask, or 0 if the number of channels exceeds that of the
+ * configurations for which a default channel mask is defined.
+ */
+static inline audio_channel_mask_t audio_channel_mask_from_count(uint32_t channel_count)
+{
+ switch(channel_count) {
+ case 1:
+ return AUDIO_CHANNEL_OUT_MONO;
+ case 2:
+ return AUDIO_CHANNEL_OUT_STEREO;
+ case 3:
+ return (AUDIO_CHANNEL_OUT_STEREO | AUDIO_CHANNEL_OUT_FRONT_CENTER);
+ case 4: // 4.0
+ return AUDIO_CHANNEL_OUT_QUAD;
+ case 5: // 5.0
+ return (AUDIO_CHANNEL_OUT_QUAD | AUDIO_CHANNEL_OUT_FRONT_CENTER);
+ case 6: // 5.1
+ return AUDIO_CHANNEL_OUT_5POINT1;
+ case 7: // 6.1
+ return (AUDIO_CHANNEL_OUT_5POINT1 | AUDIO_CHANNEL_OUT_BACK_CENTER);
+ case 8:
+ return AUDIO_CHANNEL_OUT_7POINT1;
+ default:
+ return 0;
+ }
+}
+#endif
+
+#ifndef channel_config_s
+// EFFECT_FEATURE_AUX_CHANNELS feature configuration descriptor. Describe a combinatio
+// of main and auxiliary channels supported
+typedef struct channel_config_s {
+ uint32_t main_channels; // channel mask for main channels
+ uint32_t aux_channels; // channel mask for auxiliary channels
+} channel_config_t;
+#endif
+
+#endif