Merge "Fix copy/paste errors in use of AAUDIO_FORMAT_UNSPECIFIED" into oc-dev
diff --git a/media/libaaudio/examples/input_monitor/src/input_monitor.cpp b/media/libaaudio/examples/input_monitor/src/input_monitor.cpp
index 5d55eaa..715c5f8 100644
--- a/media/libaaudio/examples/input_monitor/src/input_monitor.cpp
+++ b/media/libaaudio/examples/input_monitor/src/input_monitor.cpp
@@ -39,8 +39,8 @@
AAudioSimpleRecorder recorder;
int actualSamplesPerFrame;
int actualSampleRate;
- const aaudio_audio_format_t requestedDataFormat = AAUDIO_FORMAT_PCM_I16;
- aaudio_audio_format_t actualDataFormat;
+ const aaudio_format_t requestedDataFormat = AAUDIO_FORMAT_PCM_I16;
+ aaudio_format_t actualDataFormat;
const int requestedInputChannelCount = 1; // Can affect whether we get a FAST path.
diff --git a/media/libaaudio/examples/loopback/src/loopback.cpp b/media/libaaudio/examples/loopback/src/loopback.cpp
index 1b52652..9f06ee7 100644
--- a/media/libaaudio/examples/loopback/src/loopback.cpp
+++ b/media/libaaudio/examples/loopback/src/loopback.cpp
@@ -339,10 +339,10 @@
const int requestedOutputChannelCount = AAUDIO_UNSPECIFIED;
const int requestedSampleRate = SAMPLE_RATE;
int actualSampleRate = 0;
- const aaudio_audio_format_t requestedInputFormat = AAUDIO_FORMAT_PCM_I16;
- const aaudio_audio_format_t requestedOutputFormat = AAUDIO_FORMAT_PCM_FLOAT;
- aaudio_audio_format_t actualInputFormat;
- aaudio_audio_format_t actualOutputFormat;
+ const aaudio_format_t requestedInputFormat = AAUDIO_FORMAT_PCM_I16;
+ const aaudio_format_t requestedOutputFormat = AAUDIO_FORMAT_PCM_FLOAT;
+ aaudio_format_t actualInputFormat;
+ aaudio_format_t actualOutputFormat;
const aaudio_sharing_mode_t requestedSharingMode = AAUDIO_SHARING_MODE_EXCLUSIVE;
//const aaudio_sharing_mode_t requestedSharingMode = AAUDIO_SHARING_MODE_SHARED;
diff --git a/media/libaaudio/examples/write_sine/src/write_sine.cpp b/media/libaaudio/examples/write_sine/src/write_sine.cpp
index 27c6128..6522ba4 100644
--- a/media/libaaudio/examples/write_sine/src/write_sine.cpp
+++ b/media/libaaudio/examples/write_sine/src/write_sine.cpp
@@ -20,15 +20,22 @@
#include <stdlib.h>
#include <math.h>
#include <aaudio/AAudio.h>
+#include <aaudio/AAudioTesting.h>
#include "AAudioExampleUtils.h"
#include "AAudioSimplePlayer.h"
#define SAMPLE_RATE 48000
#define NUM_SECONDS 20
-#define REQUESTED_FORMAT AAUDIO_FORMAT_PCM_I16
-#define REQUESTED_SHARING_MODE AAUDIO_SHARING_MODE_SHARED
-//#define REQUESTED_SHARING_MODE AAUDIO_SHARING_MODE_EXCLUSIVE
+#define MMAP_POLICY AAUDIO_UNSPECIFIED
+//#define MMAP_POLICY AAUDIO_POLICY_NEVER
+//#define MMAP_POLICY AAUDIO_POLICY_AUTO
+//#define MMAP_POLICY AAUDIO_POLICY_ALWAYS
+
+#define REQUESTED_FORMAT AAUDIO_FORMAT_PCM_I16
+
+#define REQUESTED_SHARING_MODE AAUDIO_SHARING_MODE_SHARED
+//#define REQUESTED_SHARING_MODE AAUDIO_SHARING_MODE_EXCLUSIVE
int main(int argc, char **argv)
@@ -43,8 +50,8 @@
int actualChannelCount = 0;
const int requestedSampleRate = SAMPLE_RATE;
int actualSampleRate = 0;
- aaudio_audio_format_t requestedDataFormat = REQUESTED_FORMAT;
- aaudio_audio_format_t actualDataFormat = AAUDIO_FORMAT_UNSPECIFIED;
+ aaudio_format_t requestedDataFormat = REQUESTED_FORMAT;
+ aaudio_format_t actualDataFormat = AAUDIO_FORMAT_UNSPECIFIED;
aaudio_sharing_mode_t actualSharingMode = AAUDIO_SHARING_MODE_SHARED;
AAudioStream *aaudioStream = nullptr;
@@ -64,6 +71,9 @@
printf("%s - Play a sine wave using AAudio\n", argv[0]);
+ AAudio_setMMapPolicy(MMAP_POLICY);
+ printf("requested MMapPolicy = %d\n", AAudio_getMMapPolicy());
+
player.setSharingMode(REQUESTED_SHARING_MODE);
result = player.open(requestedChannelCount, requestedSampleRate, requestedDataFormat,
@@ -98,7 +108,7 @@
// This is the number of frames that are read in one chunk by a DMA controller
// or a DSP or a mixer.
framesPerBurst = AAudioStream_getFramesPerBurst(aaudioStream);
- printf("Buffer: bufferSize = %d\n", AAudioStream_getBufferSizeInFrames(aaudioStream));
+ printf("Buffer: bufferSize = %d\n", AAudioStream_getBufferSizeInFrames(aaudioStream));
bufferCapacity = AAudioStream_getBufferCapacityInFrames(aaudioStream);
printf("Buffer: bufferCapacity = %d, remainder = %d\n",
bufferCapacity, bufferCapacity % framesPerBurst);
@@ -112,11 +122,12 @@
printf("Buffer: framesPerBurst = %d\n",framesPerBurst);
printf("Buffer: framesPerWrite = %d\n",framesPerWrite);
- actualDataFormat = AAudioStream_getFormat(aaudioStream);
- printf("DataFormat: requested = %d, actual = %d\n", REQUESTED_FORMAT, actualDataFormat);
- // TODO handle other data formats
+ printf("PerformanceMode = %d\n", AAudioStream_getPerformanceMode(aaudioStream));
+ printf("is MMAP used? = %s\n", AAudioStream_isMMapUsed(aaudioStream) ? "yes" : "no");
- printf("PerformanceMode: %d\n", AAudioStream_getPerformanceMode(aaudioStream));
+ actualDataFormat = AAudioStream_getFormat(aaudioStream);
+ printf("DataFormat: requested = %d, actual = %d\n", REQUESTED_FORMAT, actualDataFormat);
+ // TODO handle other data formats
// Allocate a buffer for the audio data.
if (actualDataFormat == AAUDIO_FORMAT_PCM_FLOAT) {
diff --git a/media/libaaudio/include/aaudio/AAudio.h b/media/libaaudio/include/aaudio/AAudio.h
index 4e36e84..f11f1fa 100644
--- a/media/libaaudio/include/aaudio/AAudio.h
+++ b/media/libaaudio/include/aaudio/AAudio.h
@@ -42,7 +42,6 @@
* and would accept whatever it was given.
*/
#define AAUDIO_UNSPECIFIED 0
-#define AAUDIO_DEVICE_UNSPECIFIED 0
enum {
AAUDIO_DIRECTION_OUTPUT,
@@ -58,12 +57,6 @@
};
typedef int32_t aaudio_format_t;
-/**
- * @deprecated use aaudio_format_t instead
- * TODO remove when tests and examples are updated
- */
-typedef int32_t aaudio_audio_format_t;
-
enum {
AAUDIO_OK,
AAUDIO_ERROR_BASE = -900, // TODO review
@@ -197,11 +190,11 @@
* Request an audio device identified device using an ID.
* On Android, for example, the ID could be obtained from the Java AudioManager.
*
- * The default, if you do not call this function, is AAUDIO_DEVICE_UNSPECIFIED,
+ * The default, if you do not call this function, is AAUDIO_UNSPECIFIED,
* in which case the primary device will be used.
*
* @param builder reference provided by AAudio_createStreamBuilder()
- * @param deviceId device identifier or AAUDIO_DEVICE_UNSPECIFIED
+ * @param deviceId device identifier or AAUDIO_UNSPECIFIED
*/
AAUDIO_API void AAudioStreamBuilder_setDeviceId(AAudioStreamBuilder* builder,
int32_t deviceId);
@@ -263,7 +256,7 @@
* @param format common formats are AAUDIO_FORMAT_PCM_FLOAT and AAUDIO_FORMAT_PCM_I16.
*/
AAUDIO_API void AAudioStreamBuilder_setFormat(AAudioStreamBuilder* builder,
- aaudio_audio_format_t format);
+ aaudio_format_t format);
/**
* Request a mode for sharing the device.
@@ -754,7 +747,7 @@
* @param stream reference provided by AAudioStreamBuilder_openStream()
* @return actual data format
*/
-AAUDIO_API aaudio_audio_format_t AAudioStream_getFormat(AAudioStream* stream);
+AAUDIO_API aaudio_format_t AAudioStream_getFormat(AAudioStream* stream);
/**
* Provide actual sharing mode.
diff --git a/media/libaaudio/include/aaudio/AAudioTesting.h b/media/libaaudio/include/aaudio/AAudioTesting.h
new file mode 100644
index 0000000..02ec411
--- /dev/null
+++ b/media/libaaudio/include/aaudio/AAudioTesting.h
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+/**
+ * This is test support for AAudio.
+ */
+#ifndef AAUDIO_AAUDIO_TESTING_H
+#define AAUDIO_AAUDIO_TESTING_H
+
+#include <aaudio/AAudio.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/************************************************************************************
+ * The definitions below are only for testing. Do not use them in an application.
+ * They may change or be removed at any time.
+ ************************************************************************************/
+
+enum {
+ /**
+ * Related feature is disabled and never used.
+ */
+ AAUDIO_POLICY_NEVER = 1,
+
+ /**
+ * If related feature works then use it. Otherwise fall back to something else.
+ */
+ AAUDIO_POLICY_AUTO,
+
+ /**
+ * Related feature must be used. If not available then fail.
+ */
+ AAUDIO_POLICY_ALWAYS
+};
+typedef int32_t aaudio_policy_t;
+
+/**
+ * Control whether AAudioStreamBuilder_openStream() will use the new MMAP data path
+ * or the older "Legacy" data path.
+ *
+ * This will only affect the current process.
+ *
+ * If unspecified then the policy will be based on system properties or configuration.
+ *
+ * @note This is only for testing. Do not use this in an application.
+ * It may change or be removed at any time.
+ *
+ * @param policy AAUDIO_UNSPECIFIED, AAUDIO_POLICY_NEVER, AAUDIO_POLICY_AUTO, or AAUDIO_POLICY_ALWAYS
+ * @return AAUDIO_OK or a negative error
+ */
+AAUDIO_API aaudio_result_t AAudio_setMMapPolicy(aaudio_policy_t policy);
+
+/**
+ * Get the current MMAP policy set by AAudio_setMMapPolicy().
+ *
+ * @note This is only for testing. Do not use this in an application.
+ * It may change or be removed at any time.
+ *
+ * @return current policy
+ */
+AAUDIO_API aaudio_policy_t AAudio_getMMapPolicy();
+
+/**
+ * Return true if the stream uses the MMAP data path versus the legacy path.
+ *
+ * @note This is only for testing. Do not use this in an application.
+ * It may change or be removed at any time.
+ *
+ * @return true if the stream uses ther MMAP data path
+ */
+AAUDIO_API bool AAudioStream_isMMapUsed(AAudioStream* stream);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //AAUDIO_AAUDIO_TESTING_H
+
+/** @} */
diff --git a/media/libaaudio/libaaudio.map.txt b/media/libaaudio/libaaudio.map.txt
index 8f74800..2ba5250 100644
--- a/media/libaaudio/libaaudio.map.txt
+++ b/media/libaaudio/libaaudio.map.txt
@@ -3,6 +3,8 @@
AAudio_convertResultToText;
AAudio_convertStreamStateToText;
AAudio_createStreamBuilder;
+ AAudio_getMMapPolicy;
+ AAudio_setMMapPolicy;
AAudioStreamBuilder_setPerformanceMode;
AAudioStreamBuilder_setDeviceId;
AAudioStreamBuilder_setDataCallback;
@@ -43,6 +45,7 @@
AAudioStream_getFramesWritten;
AAudioStream_getFramesRead;
AAudioStream_getTimestamp;
+ AAudioStream_isMMapUsed;
local:
*;
};
diff --git a/media/libaaudio/src/binding/AAudioStreamConfiguration.cpp b/media/libaaudio/src/binding/AAudioStreamConfiguration.cpp
index 09eaa42..44edb1d 100644
--- a/media/libaaudio/src/binding/AAudioStreamConfiguration.cpp
+++ b/media/libaaudio/src/binding/AAudioStreamConfiguration.cpp
@@ -55,19 +55,16 @@
}
status_t AAudioStreamConfiguration::readFromParcel(const Parcel* parcel) {
- int32_t temp;
status_t status = parcel->readInt32(&mDeviceId);
if (status != NO_ERROR) goto error;
status = parcel->readInt32(&mSampleRate);
if (status != NO_ERROR) goto error;
status = parcel->readInt32(&mSamplesPerFrame);
if (status != NO_ERROR) goto error;
- status = parcel->readInt32(&temp);
+ status = parcel->readInt32(&mSharingMode);
if (status != NO_ERROR) goto error;
- mSharingMode = (aaudio_sharing_mode_t) temp;
- status = parcel->readInt32(&temp);
+ status = parcel->readInt32(&mAudioFormat);
if (status != NO_ERROR) goto error;
- mAudioFormat = (aaudio_audio_format_t) temp;
status = parcel->readInt32(&mBufferCapacity);
if (status != NO_ERROR) goto error;
return NO_ERROR;
diff --git a/media/libaaudio/src/binding/AAudioStreamConfiguration.h b/media/libaaudio/src/binding/AAudioStreamConfiguration.h
index b1e4a7d..144595a 100644
--- a/media/libaaudio/src/binding/AAudioStreamConfiguration.h
+++ b/media/libaaudio/src/binding/AAudioStreamConfiguration.h
@@ -58,11 +58,11 @@
mSamplesPerFrame = samplesPerFrame;
}
- aaudio_audio_format_t getAudioFormat() const {
+ aaudio_format_t getAudioFormat() const {
return mAudioFormat;
}
- void setAudioFormat(aaudio_audio_format_t audioFormat) {
+ void setAudioFormat(aaudio_format_t audioFormat) {
mAudioFormat = audioFormat;
}
@@ -91,11 +91,11 @@
void dump() const;
private:
- int32_t mDeviceId = AAUDIO_DEVICE_UNSPECIFIED;
+ int32_t mDeviceId = AAUDIO_UNSPECIFIED;
int32_t mSampleRate = AAUDIO_UNSPECIFIED;
int32_t mSamplesPerFrame = AAUDIO_UNSPECIFIED;
aaudio_sharing_mode_t mSharingMode = AAUDIO_SHARING_MODE_SHARED;
- aaudio_audio_format_t mAudioFormat = AAUDIO_FORMAT_UNSPECIFIED;
+ aaudio_format_t mAudioFormat = AAUDIO_FORMAT_UNSPECIFIED;
int32_t mBufferCapacity = AAUDIO_UNSPECIFIED;
};
diff --git a/media/libaaudio/src/client/AudioStreamInternal.h b/media/libaaudio/src/client/AudioStreamInternal.h
index fe4431c..a11f309 100644
--- a/media/libaaudio/src/client/AudioStreamInternal.h
+++ b/media/libaaudio/src/client/AudioStreamInternal.h
@@ -124,7 +124,7 @@
// Calculate timeout for an operation involving framesPerOperation.
int64_t calculateReasonableTimeout(int32_t framesPerOperation);
- aaudio_audio_format_t mDeviceFormat = AAUDIO_FORMAT_UNSPECIFIED;
+ aaudio_format_t mDeviceFormat = AAUDIO_FORMAT_UNSPECIFIED;
IsochronousClockModel mClockModel; // timing model for chasing the HAL
diff --git a/media/libaaudio/src/core/AAudioAudio.cpp b/media/libaaudio/src/core/AAudioAudio.cpp
index c644ee5..04bf2de 100644
--- a/media/libaaudio/src/core/AAudioAudio.cpp
+++ b/media/libaaudio/src/core/AAudioAudio.cpp
@@ -22,6 +22,7 @@
#include <pthread.h>
#include <aaudio/AAudio.h>
+#include <aaudio/AAudioTesting.h>
#include "AudioStreamBuilder.h"
#include "AudioStream.h"
@@ -94,6 +95,13 @@
#undef AAUDIO_CASE_ENUM
+
+/******************************************
+ * Static globals.
+ */
+static aaudio_policy_t s_MMapPolicy = AAUDIO_UNSPECIFIED;
+
+
static AudioStream *convertAAudioStreamToAudioStream(AAudioStream* stream)
{
return (AudioStream*) stream;
@@ -157,7 +165,7 @@
}
AAUDIO_API void AAudioStreamBuilder_setFormat(AAudioStreamBuilder* builder,
- aaudio_audio_format_t format)
+ aaudio_format_t format)
{
AudioStreamBuilder *streamBuilder = convertAAudioBuilderToStreamBuilder(builder);
streamBuilder->setFormat(format);
@@ -359,7 +367,7 @@
return audioStream->getState();
}
-AAUDIO_API aaudio_audio_format_t AAudioStream_getFormat(AAudioStream* stream)
+AAUDIO_API aaudio_format_t AAudioStream_getFormat(AAudioStream* stream)
{
AudioStream *audioStream = convertAAudioStreamToAudioStream(stream);
return audioStream->getFormat();
@@ -454,3 +462,29 @@
return audioStream->getTimestamp(clockid, framePosition, timeNanoseconds);
}
+
+AAUDIO_API aaudio_policy_t AAudio_getMMapPolicy() {
+ return s_MMapPolicy;
+}
+
+AAUDIO_API aaudio_result_t AAudio_setMMapPolicy(aaudio_policy_t policy) {
+ aaudio_result_t result = AAUDIO_OK;
+ switch(policy) {
+ case AAUDIO_UNSPECIFIED:
+ case AAUDIO_POLICY_NEVER:
+ case AAUDIO_POLICY_AUTO:
+ case AAUDIO_POLICY_ALWAYS:
+ s_MMapPolicy = policy;
+ break;
+ default:
+ result = AAUDIO_ERROR_ILLEGAL_ARGUMENT;
+ break;
+ }
+ return result;
+}
+
+AAUDIO_API bool AAudioStream_isMMapUsed(AAudioStream* stream)
+{
+ AudioStream *audioStream = convertAAudioStreamToAudioStream(stream);
+ return audioStream->isMMap();
+}
diff --git a/media/libaaudio/src/core/AudioStream.h b/media/libaaudio/src/core/AudioStream.h
index 377f24a..39c9f9c 100644
--- a/media/libaaudio/src/core/AudioStream.h
+++ b/media/libaaudio/src/core/AudioStream.h
@@ -142,7 +142,7 @@
return mSampleRate;
}
- aaudio_audio_format_t getFormat() const {
+ aaudio_format_t getFormat() const {
return mFormat;
}
@@ -264,7 +264,7 @@
/**
* This should not be called after the open() call.
*/
- void setFormat(aaudio_audio_format_t format) {
+ void setFormat(aaudio_format_t format) {
mFormat = format;
}
@@ -299,7 +299,7 @@
int32_t mDeviceId = AAUDIO_UNSPECIFIED;
aaudio_sharing_mode_t mSharingMode = AAUDIO_SHARING_MODE_SHARED;
bool mSharingModeMatchRequired = false; // must match sharing mode requested
- aaudio_audio_format_t mFormat = AAUDIO_FORMAT_UNSPECIFIED;
+ aaudio_format_t mFormat = AAUDIO_FORMAT_UNSPECIFIED;
aaudio_stream_state_t mState = AAUDIO_STREAM_STATE_UNINITIALIZED;
aaudio_performance_mode_t mPerformanceMode = AAUDIO_PERFORMANCE_MODE_NONE;
diff --git a/media/libaaudio/src/core/AudioStreamBuilder.cpp b/media/libaaudio/src/core/AudioStreamBuilder.cpp
index e6d5d74..4262f27 100644
--- a/media/libaaudio/src/core/AudioStreamBuilder.cpp
+++ b/media/libaaudio/src/core/AudioStreamBuilder.cpp
@@ -22,6 +22,7 @@
#include <stdint.h>
#include <aaudio/AAudio.h>
+#include <aaudio/AAudioTesting.h>
#include "binding/AAudioBinderClient.h"
#include "client/AudioStreamInternalCapture.h"
@@ -33,6 +34,9 @@
using namespace aaudio;
+#define AAUDIO_MMAP_POLICY_DEFAULT AAUDIO_POLICY_NEVER
+#define AAUDIO_MMAP_EXCLUSIVE_POLICY_DEFAULT AAUDIO_POLICY_NEVER
+
/*
* AudioStreamBuilder
*/
@@ -76,25 +80,41 @@
return result;
}
-// Try to open using MMAP path if that is enabled.
-// Fall back to Legacy path is MMAP not available.
+// Try to open using MMAP path if that is allowed.
+// Fall back to Legacy path if MMAP not available.
+// Exact behavior is controlled by MMapPolicy.
aaudio_result_t AudioStreamBuilder::build(AudioStream** streamPtr) {
AudioStream *audioStream = nullptr;
*streamPtr = nullptr;
- int32_t mmapEnabled = AAudioProperty_getMMapEnabled();
- int32_t mmapExclusiveEnabled = AAudioProperty_getMMapExclusiveEnabled();
+ // The API setting is the highest priority.
+ aaudio_policy_t mmapPolicy = AAudio_getMMapPolicy();
+ // If not specified then get from a system property.
+ if (mmapPolicy == AAUDIO_UNSPECIFIED) {
+ mmapPolicy = AAudioProperty_getMMapPolicy();
+ }
+ // If still not specified then use the default.
+ if (mmapPolicy == AAUDIO_UNSPECIFIED) {
+ mmapPolicy = AAUDIO_MMAP_POLICY_DEFAULT;
+ }
+
+ int32_t mapExclusivePolicy = AAudioProperty_getMMapExclusivePolicy();
+ if (mapExclusivePolicy == AAUDIO_UNSPECIFIED) {
+ mapExclusivePolicy = AAUDIO_MMAP_EXCLUSIVE_POLICY_DEFAULT;
+ }
+ ALOGD("AudioStreamBuilder(): mmapPolicy = %d, mapExclusivePolicy = %d",
+ mmapPolicy, mapExclusivePolicy);
aaudio_sharing_mode_t sharingMode = getSharingMode();
if ((sharingMode == AAUDIO_SHARING_MODE_EXCLUSIVE)
- && (mmapExclusiveEnabled == AAUDIO_USE_NEVER)) {
+ && (mapExclusivePolicy == AAUDIO_POLICY_NEVER)) {
ALOGW("AudioStreamBuilder(): EXCLUSIVE sharing mode not supported. Use SHARED.");
sharingMode = AAUDIO_SHARING_MODE_SHARED;
setSharingMode(sharingMode);
}
- bool allowMMap = mmapEnabled != AAUDIO_USE_NEVER;
- bool allowLegacy = mmapEnabled != AAUDIO_USE_ALWAYS;
+ bool allowMMap = mmapPolicy != AAUDIO_POLICY_NEVER;
+ bool allowLegacy = mmapPolicy != AAUDIO_POLICY_ALWAYS;
aaudio_result_t result = builder_createStream(getDirection(), sharingMode,
allowMMap, &audioStream);
diff --git a/media/libaaudio/src/core/AudioStreamBuilder.h b/media/libaaudio/src/core/AudioStreamBuilder.h
index 569ca63..fd416c4 100644
--- a/media/libaaudio/src/core/AudioStreamBuilder.h
+++ b/media/libaaudio/src/core/AudioStreamBuilder.h
@@ -64,11 +64,11 @@
return this;
}
- aaudio_audio_format_t getFormat() const {
+ aaudio_format_t getFormat() const {
return mFormat;
}
- AudioStreamBuilder *setFormat(aaudio_audio_format_t format) {
+ AudioStreamBuilder *setFormat(aaudio_format_t format) {
mFormat = format;
return this;
}
@@ -168,10 +168,10 @@
private:
int32_t mSamplesPerFrame = AAUDIO_UNSPECIFIED;
int32_t mSampleRate = AAUDIO_UNSPECIFIED;
- int32_t mDeviceId = AAUDIO_DEVICE_UNSPECIFIED;
+ int32_t mDeviceId = AAUDIO_UNSPECIFIED;
aaudio_sharing_mode_t mSharingMode = AAUDIO_SHARING_MODE_SHARED;
bool mSharingModeMatchRequired = false; // must match sharing mode requested
- aaudio_audio_format_t mFormat = AAUDIO_FORMAT_UNSPECIFIED;
+ aaudio_format_t mFormat = AAUDIO_FORMAT_UNSPECIFIED;
aaudio_direction_t mDirection = AAUDIO_DIRECTION_OUTPUT;
int32_t mBufferCapacity = AAUDIO_UNSPECIFIED;
aaudio_performance_mode_t mPerformanceMode = AAUDIO_PERFORMANCE_MODE_NONE;
diff --git a/media/libaaudio/src/legacy/AudioStreamTrack.cpp b/media/libaaudio/src/legacy/AudioStreamTrack.cpp
index 1e3119c..a0c1d45 100644
--- a/media/libaaudio/src/legacy/AudioStreamTrack.cpp
+++ b/media/libaaudio/src/legacy/AudioStreamTrack.cpp
@@ -145,7 +145,7 @@
// Get the actual values from the AudioTrack.
setSamplesPerFrame(mAudioTrack->channelCount());
- aaudio_audio_format_t aaudioFormat =
+ aaudio_format_t aaudioFormat =
AAudioConvert_androidToAAudioDataFormat(mAudioTrack->format());
setFormat(aaudioFormat);
diff --git a/media/libaaudio/src/utility/AAudioUtilities.cpp b/media/libaaudio/src/utility/AAudioUtilities.cpp
index 38ad59f..2c7634e 100644
--- a/media/libaaudio/src/utility/AAudioUtilities.cpp
+++ b/media/libaaudio/src/utility/AAudioUtilities.cpp
@@ -24,7 +24,9 @@
#include <utils/Errors.h>
#include "aaudio/AAudio.h"
-#include "AAudioUtilities.h"
+#include <aaudio/AAudioTesting.h>
+
+#include "utility/AAudioUtilities.h"
using namespace android;
@@ -33,7 +35,7 @@
#define MAX_HEADROOM (1.41253754f)
#define MIN_HEADROOM (0 - MAX_HEADROOM)
-int32_t AAudioConvert_formatToSizeInBytes(aaudio_audio_format_t format) {
+int32_t AAudioConvert_formatToSizeInBytes(aaudio_format_t format) {
int32_t size = AAUDIO_ERROR_ILLEGAL_ARGUMENT;
switch (format) {
case AAUDIO_FORMAT_PCM_I16:
@@ -275,7 +277,7 @@
return result;
}
-audio_format_t AAudioConvert_aaudioToAndroidDataFormat(aaudio_audio_format_t aaudioFormat) {
+audio_format_t AAudioConvert_aaudioToAndroidDataFormat(aaudio_format_t aaudioFormat) {
audio_format_t androidFormat;
switch (aaudioFormat) {
case AAUDIO_FORMAT_PCM_I16:
@@ -292,8 +294,8 @@
return androidFormat;
}
-aaudio_audio_format_t AAudioConvert_androidToAAudioDataFormat(audio_format_t androidFormat) {
- aaudio_audio_format_t aaudioFormat = AAUDIO_FORMAT_INVALID;
+aaudio_format_t AAudioConvert_androidToAAudioDataFormat(audio_format_t androidFormat) {
+ aaudio_format_t aaudioFormat = AAUDIO_FORMAT_INVALID;
switch (androidFormat) {
case AUDIO_FORMAT_PCM_16_BIT:
aaudioFormat = AAUDIO_FORMAT_PCM_I16;
@@ -329,9 +331,10 @@
const char * caller) {
int32_t prop = property_get_int32(propName, defaultValue);
switch (prop) {
- case AAUDIO_USE_NEVER:
- case AAUDIO_USE_ALWAYS:
- case AAUDIO_USE_AUTO:
+ case AAUDIO_UNSPECIFIED:
+ case AAUDIO_POLICY_NEVER:
+ case AAUDIO_POLICY_ALWAYS:
+ case AAUDIO_POLICY_AUTO:
break;
default:
ALOGE("%s: invalid = %d", caller, prop);
@@ -341,14 +344,14 @@
return prop;
}
-int32_t AAudioProperty_getMMapEnabled() {
- return AAudioProperty_getMMapProperty(AAUDIO_PROP_MMAP_ENABLED,
- AAUDIO_USE_NEVER, __func__);
+int32_t AAudioProperty_getMMapPolicy() {
+ return AAudioProperty_getMMapProperty(AAUDIO_PROP_MMAP_POLICY,
+ AAUDIO_UNSPECIFIED, __func__);
}
-int32_t AAudioProperty_getMMapExclusiveEnabled() {
- return AAudioProperty_getMMapProperty(AAUDIO_PROP_MMAP_EXCLUSIVE_ENABLED,
- AAUDIO_USE_NEVER, __func__);
+int32_t AAudioProperty_getMMapExclusivePolicy() {
+ return AAudioProperty_getMMapProperty(AAUDIO_PROP_MMAP_EXCLUSIVE_POLICY,
+ AAUDIO_UNSPECIFIED, __func__);
}
int32_t AAudioProperty_getMixerBursts() {
diff --git a/media/libaaudio/src/utility/AAudioUtilities.h b/media/libaaudio/src/utility/AAudioUtilities.h
index 7c383c7..f894bc0 100644
--- a/media/libaaudio/src/utility/AAudioUtilities.h
+++ b/media/libaaudio/src/utility/AAudioUtilities.h
@@ -161,42 +161,33 @@
int32_t bytesPerFrame,
int32_t *sizeInBytes);
-audio_format_t AAudioConvert_aaudioToAndroidDataFormat(aaudio_audio_format_t aaudio_format);
+audio_format_t AAudioConvert_aaudioToAndroidDataFormat(aaudio_format_t aaudio_format);
-aaudio_audio_format_t AAudioConvert_androidToAAudioDataFormat(audio_format_t format);
+aaudio_format_t AAudioConvert_androidToAAudioDataFormat(audio_format_t format);
/**
* @return the size of a sample of the given format in bytes or AAUDIO_ERROR_ILLEGAL_ARGUMENT
*/
-int32_t AAudioConvert_formatToSizeInBytes(aaudio_audio_format_t format);
+int32_t AAudioConvert_formatToSizeInBytes(aaudio_format_t format);
// Note that this code may be replaced by Settings or by some other system configuration tool.
-enum : int32_t {
- // Related feature is disabled
- AAUDIO_USE_NEVER = 0,
- // If related feature works then use it. Otherwise fall back to something else.
- AAUDIO_USE_AUTO = 1,
- // Related feature must be used. If not available then fail.
- AAUDIO_USE_ALWAYS = 2
-};
-
-#define AAUDIO_PROP_MMAP_ENABLED "aaudio.mmap_enabled"
+#define AAUDIO_PROP_MMAP_POLICY "aaudio.mmap_policy"
/**
* Read system property.
- * @return AAUDIO_USE_NEVER or AAUDIO_USE_AUTO or AAUDIO_USE_ALWAYS
+ * @return AAUDIO_UNSPECIFIED, AAUDIO_POLICY_NEVER or AAUDIO_POLICY_AUTO or AAUDIO_POLICY_ALWAYS
*/
-int32_t AAudioProperty_getMMapEnabled();
+int32_t AAudioProperty_getMMapPolicy();
-#define AAUDIO_PROP_MMAP_EXCLUSIVE_ENABLED "aaudio.mmap_exclusive_enabled"
+#define AAUDIO_PROP_MMAP_EXCLUSIVE_POLICY "aaudio.mmap_exclusive_policy"
/**
* Read system property.
- * @return AAUDIO_USE_NEVER or AAUDIO_USE_AUTO or AAUDIO_USE_ALWAYS
+ * @return AAUDIO_UNSPECIFIED, AAUDIO_POLICY_NEVER or AAUDIO_POLICY_AUTO or AAUDIO_POLICY_ALWAYS
*/
-int32_t AAudioProperty_getMMapExclusiveEnabled();
+int32_t AAudioProperty_getMMapExclusivePolicy();
#define AAUDIO_PROP_MIXER_BURSTS "aaudio.mixer_bursts"
diff --git a/media/libaaudio/tests/test_open_params.cpp b/media/libaaudio/tests/test_open_params.cpp
index 5125653..01b8799 100644
--- a/media/libaaudio/tests/test_open_params.cpp
+++ b/media/libaaudio/tests/test_open_params.cpp
@@ -57,7 +57,7 @@
static void testOpenOptions(aaudio_direction_t direction,
int32_t channelCount,
int32_t sampleRate,
- aaudio_audio_format_t format) {
+ aaudio_format_t format) {
aaudio_result_t result = AAUDIO_OK;
@@ -66,7 +66,7 @@
int32_t actualChannelCount = 0;
int32_t actualSampleRate = 0;
- aaudio_audio_format_t actualDataFormat = AAUDIO_FORMAT_UNSPECIFIED;
+ aaudio_format_t actualDataFormat = AAUDIO_FORMAT_UNSPECIFIED;
aaudio_sharing_mode_t actualSharingMode = AAUDIO_SHARING_MODE_SHARED;
aaudio_direction_t actualDirection;
@@ -134,7 +134,8 @@
//void foo() { // for tricking the Android Studio formatter
TEST(test_open_params, aaudio_open_all) {
aaudio_direction_t directions[] = {AAUDIO_DIRECTION_OUTPUT, AAUDIO_DIRECTION_INPUT};
- aaudio_audio_format_t formats[] = {AAUDIO_FORMAT_UNSPECIFIED, AAUDIO_FORMAT_PCM_I16, AAUDIO_FORMAT_PCM_FLOAT};
+ aaudio_format_t formats[] = {AAUDIO_FORMAT_UNSPECIFIED,
+ AAUDIO_FORMAT_PCM_I16, AAUDIO_FORMAT_PCM_FLOAT};
int32_t rates[] = {AAUDIO_UNSPECIFIED, 22050, 32000, 44100, 48000, 88200, 96000, 37913, 59132};
// Make printf print immediately so that debug info is not stuck
diff --git a/services/oboeservice/AAudioServiceStreamBase.h b/services/oboeservice/AAudioServiceStreamBase.h
index 9318c2e..ee52c39 100644
--- a/services/oboeservice/AAudioServiceStreamBase.h
+++ b/services/oboeservice/AAudioServiceStreamBase.h
@@ -133,7 +133,7 @@
// This is used by one thread to tell another thread to exit. So it must be atomic.
std::atomic<bool> mThreadEnabled;
- aaudio_audio_format_t mAudioFormat = AAUDIO_FORMAT_UNSPECIFIED;
+ aaudio_format_t mAudioFormat = AAUDIO_FORMAT_UNSPECIFIED;
int32_t mFramesPerBurst = 0;
int32_t mSamplesPerFrame = AAUDIO_UNSPECIFIED;
int32_t mSampleRate = AAUDIO_UNSPECIFIED;
diff --git a/services/oboeservice/AAudioServiceStreamMMAP.cpp b/services/oboeservice/AAudioServiceStreamMMAP.cpp
index 14b3379..97b9937 100644
--- a/services/oboeservice/AAudioServiceStreamMMAP.cpp
+++ b/services/oboeservice/AAudioServiceStreamMMAP.cpp
@@ -93,7 +93,7 @@
aaudio_direction_t direction = request.getDirection();
// Fill in config
- aaudio_audio_format_t aaudioFormat = configurationInput.getAudioFormat();
+ aaudio_format_t aaudioFormat = configurationInput.getAudioFormat();
if (aaudioFormat == AAUDIO_UNSPECIFIED || aaudioFormat == AAUDIO_FORMAT_PCM_FLOAT) {
aaudioFormat = AAUDIO_FORMAT_PCM_I16;
}