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.
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;
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;
};
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
* @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.
* @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.
}
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;
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;
}
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;
};
// 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
}
AAUDIO_API void AAudioStreamBuilder_setFormat(AAudioStreamBuilder* builder,
- aaudio_audio_format_t format)
+ aaudio_format_t format)
{
AudioStreamBuilder *streamBuilder = convertAAudioBuilderToStreamBuilder(builder);
streamBuilder->setFormat(format);
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();
return mSampleRate;
}
- aaudio_audio_format_t getFormat() const {
+ aaudio_format_t getFormat() const {
return mFormat;
}
/**
* This should not be called after the open() call.
*/
- void setFormat(aaudio_audio_format_t format) {
+ void setFormat(aaudio_format_t format) {
mFormat = format;
}
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;
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;
}
int32_t mDeviceId = AAUDIO_DEVICE_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;
// 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);
#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:
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:
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;
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.
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;
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;
//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
// 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;
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;
}