Loading media/liboboe/examples/write_sine/src/write_sine_threaded.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -86,10 +86,18 @@ public: result = AAudioStream_getSampleRate(mStream, &mFramesPerSecond); printf("open() mFramesPerSecond = %d\n", mFramesPerSecond); if (result != AAUDIO_OK) goto finish2; result = AAudioStream_getSamplesPerFrame(mStream, &mSamplesPerFrame); printf("open() mSamplesPerFrame = %d\n", mSamplesPerFrame); if (result != AAUDIO_OK) goto finish2; { aaudio_size_frames_t bufferCapacity; result = AAudioStream_getBufferCapacity(mStream, &bufferCapacity); if (result != AAUDIO_OK) goto finish2; printf("open() got bufferCapacity = %d\n", bufferCapacity); } // This is the number of frames that are read in one chunk by a DMA controller // or a DSP or a mixer. result = AAudioStream_getFramesPerBurst(mStream, &mFramesPerBurst); Loading media/liboboe/include/aaudio/AAudio.h +46 −13 Original line number Diff line number Diff line Loading @@ -205,6 +205,30 @@ AAUDIO_API aaudio_result_t AAudioStreamBuilder_setDirection(AAudioStreamBuilder AAUDIO_API aaudio_result_t AAudioStreamBuilder_getDirection(AAudioStreamBuilder builder, aaudio_direction_t *direction); /** * Set the requested maximum buffer capacity in frames. * The final AAudioStream capacity may differ, but will probably be at least this big. * * Default is AAUDIO_UNSPECIFIED. * * @param builder handle provided by AAudio_createStreamBuilder() * @param frames the desired buffer capacity in frames or AAUDIO_UNSPECIFIED * @return AAUDIO_OK or a negative error. */ AAUDIO_API aaudio_result_t AAudioStreamBuilder_setBufferCapacity(AAudioStreamBuilder builder, aaudio_size_frames_t frames); /** * Query the requested maximum buffer capacity in frames that was passed to * AAudioStreamBuilder_setBufferCapacity(). * * @param builder handle provided by AAudio_createStreamBuilder() * @param frames pointer to variable to receive the requested buffer capacity * @return AAUDIO_OK or a negative error. */ AAUDIO_API aaudio_result_t AAudioStreamBuilder_getBufferCapacity(AAudioStreamBuilder builder, aaudio_size_frames_t *frames); /** * Open a stream based on the options in the StreamBuilder. * Loading Loading @@ -432,7 +456,8 @@ AAUDIO_API aaudio_result_t AAudioStream_setBufferSize(AAudioStream stream, * @param frames pointer to variable to receive the buffer size * @return AAUDIO_OK or a negative error. */ AAUDIO_API aaudio_result_t AAudioStream_getBufferSize(AAudioStream stream, aaudio_size_frames_t *frames); AAUDIO_API aaudio_result_t AAudioStream_getBufferSize(AAudioStream stream, aaudio_size_frames_t *frames); /** * Query the number of frames that are read or written by the endpoint at one time. Loading @@ -441,7 +466,8 @@ AAUDIO_API aaudio_result_t AAudioStream_getBufferSize(AAudioStream stream, aaudi * @param frames pointer to variable to receive the burst size * @return AAUDIO_OK or a negative error. */ AAUDIO_API aaudio_result_t AAudioStream_getFramesPerBurst(AAudioStream stream, aaudio_size_frames_t *frames); AAUDIO_API aaudio_result_t AAudioStream_getFramesPerBurst(AAudioStream stream, aaudio_size_frames_t *frames); /** * Query maximum buffer capacity in frames. Loading @@ -450,7 +476,8 @@ AAUDIO_API aaudio_result_t AAudioStream_getFramesPerBurst(AAudioStream stream, a * @param frames pointer to variable to receive the buffer capacity * @return AAUDIO_OK or a negative error. */ AAUDIO_API aaudio_result_t AAudioStream_getBufferCapacity(AAudioStream stream, aaudio_size_frames_t *frames); AAUDIO_API aaudio_result_t AAudioStream_getBufferCapacity(AAudioStream stream, aaudio_size_frames_t *frames); /** * An XRun is an Underrun or an Overrun. Loading @@ -472,7 +499,8 @@ AAUDIO_API aaudio_result_t AAudioStream_getXRunCount(AAudioStream stream, int32_ * @param sampleRate pointer to variable to receive the actual sample rate * @return AAUDIO_OK or a negative error. */ AAUDIO_API aaudio_result_t AAudioStream_getSampleRate(AAudioStream stream, aaudio_sample_rate_t *sampleRate); AAUDIO_API aaudio_result_t AAudioStream_getSampleRate(AAudioStream stream, aaudio_sample_rate_t *sampleRate); /** * The samplesPerFrame is also known as channelCount. Loading @@ -481,21 +509,24 @@ AAUDIO_API aaudio_result_t AAudioStream_getSampleRate(AAudioStream stream, aaudi * @param samplesPerFrame pointer to variable to receive the actual samples per frame * @return AAUDIO_OK or a negative error. */ AAUDIO_API aaudio_result_t AAudioStream_getSamplesPerFrame(AAudioStream stream, int32_t *samplesPerFrame); AAUDIO_API aaudio_result_t AAudioStream_getSamplesPerFrame(AAudioStream stream, int32_t *samplesPerFrame); /** * @param stream handle provided by AAudioStreamBuilder_openStream() * @param deviceId pointer to variable to receive the actual device ID * @return AAUDIO_OK or a negative error. */ AAUDIO_API aaudio_result_t AAudioStream_getDeviceId(AAudioStream stream, aaudio_device_id_t *deviceId); AAUDIO_API aaudio_result_t AAudioStream_getDeviceId(AAudioStream stream, aaudio_device_id_t *deviceId); /** * @param stream handle provided by AAudioStreamBuilder_openStream() * @param format pointer to variable to receive the actual data format * @return AAUDIO_OK or a negative error. */ AAUDIO_API aaudio_result_t AAudioStream_getFormat(AAudioStream stream, aaudio_audio_format_t *format); AAUDIO_API aaudio_result_t AAudioStream_getFormat(AAudioStream stream, aaudio_audio_format_t *format); /** * Provide actual sharing mode. Loading @@ -511,7 +542,8 @@ AAUDIO_API aaudio_result_t AAudioStream_getSharingMode(AAudioStream stream, * @param direction pointer to a variable to be set to the current direction. * @return AAUDIO_OK or a negative error. */ AAUDIO_API aaudio_result_t AAudioStream_getDirection(AAudioStream stream, aaudio_direction_t *direction); AAUDIO_API aaudio_result_t AAudioStream_getDirection(AAudioStream stream, aaudio_direction_t *direction); /** * Passes back the number of frames that have been written since the stream was created. Loading @@ -538,7 +570,8 @@ AAUDIO_API aaudio_result_t AAudioStream_getFramesWritten(AAudioStream stream, * @param frames pointer to variable to receive the frames written * @return AAUDIO_OK or a negative error. */ AAUDIO_API aaudio_result_t AAudioStream_getFramesRead(AAudioStream stream, aaudio_position_frames_t *frames); AAUDIO_API aaudio_result_t AAudioStream_getFramesRead(AAudioStream stream, aaudio_position_frames_t *frames); /** * Passes back the time at which a particular frame was presented. Loading media/liboboe/src/binding/AAudioStreamConfiguration.cpp +10 −2 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ status_t AAudioStreamConfiguration::writeToParcel(Parcel* parcel) const { parcel->writeInt32(mSampleRate); parcel->writeInt32(mSamplesPerFrame); parcel->writeInt32((int32_t) mAudioFormat); parcel->writeInt32(mBufferCapacity); return NO_ERROR; // TODO check for errors above } Loading @@ -49,6 +50,7 @@ status_t AAudioStreamConfiguration::readFromParcel(const Parcel* parcel) { parcel->readInt32(&mSamplesPerFrame); parcel->readInt32(&temp); mAudioFormat = (aaudio_audio_format_t) temp; parcel->readInt32(&mBufferCapacity); return NO_ERROR; // TODO check for errors above } Loading @@ -74,6 +76,11 @@ aaudio_result_t AAudioStreamConfiguration::validate() { ALOGE("AAudioStreamConfiguration.validate() invalid audioFormat = %d", mAudioFormat); return AAUDIO_ERROR_INTERNAL; } if (mBufferCapacity < 0) { ALOGE("AAudioStreamConfiguration.validate() invalid mBufferCapacity = %d", mBufferCapacity); return AAUDIO_ERROR_INTERNAL; } return AAUDIO_OK; } Loading @@ -81,4 +88,5 @@ void AAudioStreamConfiguration::dump() { ALOGD("AAudioStreamConfiguration mSampleRate = %d -----", mSampleRate); ALOGD("AAudioStreamConfiguration mSamplesPerFrame = %d", mSamplesPerFrame); ALOGD("AAudioStreamConfiguration mAudioFormat = %d", (int)mAudioFormat); ALOGD("AAudioStreamConfiguration mBufferCapacity = %d", mBufferCapacity); } media/liboboe/src/binding/AAudioStreamConfiguration.h +10 −1 Original line number Diff line number Diff line Loading @@ -66,6 +66,14 @@ public: mAudioFormat = audioFormat; } aaudio_size_frames_t getBufferCapacity() const { return mBufferCapacity; } void setBufferCapacity(aaudio_size_frames_t frames) { mBufferCapacity = frames; } virtual status_t writeToParcel(Parcel* parcel) const override; virtual status_t readFromParcel(const Parcel* parcel) override; Loading @@ -79,6 +87,7 @@ protected: aaudio_sample_rate_t mSampleRate = AAUDIO_UNSPECIFIED; int32_t mSamplesPerFrame = AAUDIO_UNSPECIFIED; aaudio_audio_format_t mAudioFormat = AAUDIO_FORMAT_UNSPECIFIED; aaudio_size_frames_t mBufferCapacity = AAUDIO_UNSPECIFIED; }; } /* namespace aaudio */ Loading media/liboboe/src/binding/IAAudioService.h +5 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,11 @@ public: DECLARE_META_INTERFACE(AAudioService); /** * @param request info needed to create the stream * @param configuration contains information about the created stream * @return handle to the stream or a negative error */ virtual aaudio_handle_t openStream(aaudio::AAudioStreamRequest &request, aaudio::AAudioStreamConfiguration &configuration) = 0; Loading Loading
media/liboboe/examples/write_sine/src/write_sine_threaded.cpp +8 −0 Original line number Diff line number Diff line Loading @@ -86,10 +86,18 @@ public: result = AAudioStream_getSampleRate(mStream, &mFramesPerSecond); printf("open() mFramesPerSecond = %d\n", mFramesPerSecond); if (result != AAUDIO_OK) goto finish2; result = AAudioStream_getSamplesPerFrame(mStream, &mSamplesPerFrame); printf("open() mSamplesPerFrame = %d\n", mSamplesPerFrame); if (result != AAUDIO_OK) goto finish2; { aaudio_size_frames_t bufferCapacity; result = AAudioStream_getBufferCapacity(mStream, &bufferCapacity); if (result != AAUDIO_OK) goto finish2; printf("open() got bufferCapacity = %d\n", bufferCapacity); } // This is the number of frames that are read in one chunk by a DMA controller // or a DSP or a mixer. result = AAudioStream_getFramesPerBurst(mStream, &mFramesPerBurst); Loading
media/liboboe/include/aaudio/AAudio.h +46 −13 Original line number Diff line number Diff line Loading @@ -205,6 +205,30 @@ AAUDIO_API aaudio_result_t AAudioStreamBuilder_setDirection(AAudioStreamBuilder AAUDIO_API aaudio_result_t AAudioStreamBuilder_getDirection(AAudioStreamBuilder builder, aaudio_direction_t *direction); /** * Set the requested maximum buffer capacity in frames. * The final AAudioStream capacity may differ, but will probably be at least this big. * * Default is AAUDIO_UNSPECIFIED. * * @param builder handle provided by AAudio_createStreamBuilder() * @param frames the desired buffer capacity in frames or AAUDIO_UNSPECIFIED * @return AAUDIO_OK or a negative error. */ AAUDIO_API aaudio_result_t AAudioStreamBuilder_setBufferCapacity(AAudioStreamBuilder builder, aaudio_size_frames_t frames); /** * Query the requested maximum buffer capacity in frames that was passed to * AAudioStreamBuilder_setBufferCapacity(). * * @param builder handle provided by AAudio_createStreamBuilder() * @param frames pointer to variable to receive the requested buffer capacity * @return AAUDIO_OK or a negative error. */ AAUDIO_API aaudio_result_t AAudioStreamBuilder_getBufferCapacity(AAudioStreamBuilder builder, aaudio_size_frames_t *frames); /** * Open a stream based on the options in the StreamBuilder. * Loading Loading @@ -432,7 +456,8 @@ AAUDIO_API aaudio_result_t AAudioStream_setBufferSize(AAudioStream stream, * @param frames pointer to variable to receive the buffer size * @return AAUDIO_OK or a negative error. */ AAUDIO_API aaudio_result_t AAudioStream_getBufferSize(AAudioStream stream, aaudio_size_frames_t *frames); AAUDIO_API aaudio_result_t AAudioStream_getBufferSize(AAudioStream stream, aaudio_size_frames_t *frames); /** * Query the number of frames that are read or written by the endpoint at one time. Loading @@ -441,7 +466,8 @@ AAUDIO_API aaudio_result_t AAudioStream_getBufferSize(AAudioStream stream, aaudi * @param frames pointer to variable to receive the burst size * @return AAUDIO_OK or a negative error. */ AAUDIO_API aaudio_result_t AAudioStream_getFramesPerBurst(AAudioStream stream, aaudio_size_frames_t *frames); AAUDIO_API aaudio_result_t AAudioStream_getFramesPerBurst(AAudioStream stream, aaudio_size_frames_t *frames); /** * Query maximum buffer capacity in frames. Loading @@ -450,7 +476,8 @@ AAUDIO_API aaudio_result_t AAudioStream_getFramesPerBurst(AAudioStream stream, a * @param frames pointer to variable to receive the buffer capacity * @return AAUDIO_OK or a negative error. */ AAUDIO_API aaudio_result_t AAudioStream_getBufferCapacity(AAudioStream stream, aaudio_size_frames_t *frames); AAUDIO_API aaudio_result_t AAudioStream_getBufferCapacity(AAudioStream stream, aaudio_size_frames_t *frames); /** * An XRun is an Underrun or an Overrun. Loading @@ -472,7 +499,8 @@ AAUDIO_API aaudio_result_t AAudioStream_getXRunCount(AAudioStream stream, int32_ * @param sampleRate pointer to variable to receive the actual sample rate * @return AAUDIO_OK or a negative error. */ AAUDIO_API aaudio_result_t AAudioStream_getSampleRate(AAudioStream stream, aaudio_sample_rate_t *sampleRate); AAUDIO_API aaudio_result_t AAudioStream_getSampleRate(AAudioStream stream, aaudio_sample_rate_t *sampleRate); /** * The samplesPerFrame is also known as channelCount. Loading @@ -481,21 +509,24 @@ AAUDIO_API aaudio_result_t AAudioStream_getSampleRate(AAudioStream stream, aaudi * @param samplesPerFrame pointer to variable to receive the actual samples per frame * @return AAUDIO_OK or a negative error. */ AAUDIO_API aaudio_result_t AAudioStream_getSamplesPerFrame(AAudioStream stream, int32_t *samplesPerFrame); AAUDIO_API aaudio_result_t AAudioStream_getSamplesPerFrame(AAudioStream stream, int32_t *samplesPerFrame); /** * @param stream handle provided by AAudioStreamBuilder_openStream() * @param deviceId pointer to variable to receive the actual device ID * @return AAUDIO_OK or a negative error. */ AAUDIO_API aaudio_result_t AAudioStream_getDeviceId(AAudioStream stream, aaudio_device_id_t *deviceId); AAUDIO_API aaudio_result_t AAudioStream_getDeviceId(AAudioStream stream, aaudio_device_id_t *deviceId); /** * @param stream handle provided by AAudioStreamBuilder_openStream() * @param format pointer to variable to receive the actual data format * @return AAUDIO_OK or a negative error. */ AAUDIO_API aaudio_result_t AAudioStream_getFormat(AAudioStream stream, aaudio_audio_format_t *format); AAUDIO_API aaudio_result_t AAudioStream_getFormat(AAudioStream stream, aaudio_audio_format_t *format); /** * Provide actual sharing mode. Loading @@ -511,7 +542,8 @@ AAUDIO_API aaudio_result_t AAudioStream_getSharingMode(AAudioStream stream, * @param direction pointer to a variable to be set to the current direction. * @return AAUDIO_OK or a negative error. */ AAUDIO_API aaudio_result_t AAudioStream_getDirection(AAudioStream stream, aaudio_direction_t *direction); AAUDIO_API aaudio_result_t AAudioStream_getDirection(AAudioStream stream, aaudio_direction_t *direction); /** * Passes back the number of frames that have been written since the stream was created. Loading @@ -538,7 +570,8 @@ AAUDIO_API aaudio_result_t AAudioStream_getFramesWritten(AAudioStream stream, * @param frames pointer to variable to receive the frames written * @return AAUDIO_OK or a negative error. */ AAUDIO_API aaudio_result_t AAudioStream_getFramesRead(AAudioStream stream, aaudio_position_frames_t *frames); AAUDIO_API aaudio_result_t AAudioStream_getFramesRead(AAudioStream stream, aaudio_position_frames_t *frames); /** * Passes back the time at which a particular frame was presented. Loading
media/liboboe/src/binding/AAudioStreamConfiguration.cpp +10 −2 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ status_t AAudioStreamConfiguration::writeToParcel(Parcel* parcel) const { parcel->writeInt32(mSampleRate); parcel->writeInt32(mSamplesPerFrame); parcel->writeInt32((int32_t) mAudioFormat); parcel->writeInt32(mBufferCapacity); return NO_ERROR; // TODO check for errors above } Loading @@ -49,6 +50,7 @@ status_t AAudioStreamConfiguration::readFromParcel(const Parcel* parcel) { parcel->readInt32(&mSamplesPerFrame); parcel->readInt32(&temp); mAudioFormat = (aaudio_audio_format_t) temp; parcel->readInt32(&mBufferCapacity); return NO_ERROR; // TODO check for errors above } Loading @@ -74,6 +76,11 @@ aaudio_result_t AAudioStreamConfiguration::validate() { ALOGE("AAudioStreamConfiguration.validate() invalid audioFormat = %d", mAudioFormat); return AAUDIO_ERROR_INTERNAL; } if (mBufferCapacity < 0) { ALOGE("AAudioStreamConfiguration.validate() invalid mBufferCapacity = %d", mBufferCapacity); return AAUDIO_ERROR_INTERNAL; } return AAUDIO_OK; } Loading @@ -81,4 +88,5 @@ void AAudioStreamConfiguration::dump() { ALOGD("AAudioStreamConfiguration mSampleRate = %d -----", mSampleRate); ALOGD("AAudioStreamConfiguration mSamplesPerFrame = %d", mSamplesPerFrame); ALOGD("AAudioStreamConfiguration mAudioFormat = %d", (int)mAudioFormat); ALOGD("AAudioStreamConfiguration mBufferCapacity = %d", mBufferCapacity); }
media/liboboe/src/binding/AAudioStreamConfiguration.h +10 −1 Original line number Diff line number Diff line Loading @@ -66,6 +66,14 @@ public: mAudioFormat = audioFormat; } aaudio_size_frames_t getBufferCapacity() const { return mBufferCapacity; } void setBufferCapacity(aaudio_size_frames_t frames) { mBufferCapacity = frames; } virtual status_t writeToParcel(Parcel* parcel) const override; virtual status_t readFromParcel(const Parcel* parcel) override; Loading @@ -79,6 +87,7 @@ protected: aaudio_sample_rate_t mSampleRate = AAUDIO_UNSPECIFIED; int32_t mSamplesPerFrame = AAUDIO_UNSPECIFIED; aaudio_audio_format_t mAudioFormat = AAUDIO_FORMAT_UNSPECIFIED; aaudio_size_frames_t mBufferCapacity = AAUDIO_UNSPECIFIED; }; } /* namespace aaudio */ Loading
media/liboboe/src/binding/IAAudioService.h +5 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,11 @@ public: DECLARE_META_INTERFACE(AAudioService); /** * @param request info needed to create the stream * @param configuration contains information about the created stream * @return handle to the stream or a negative error */ virtual aaudio_handle_t openStream(aaudio::AAudioStreamRequest &request, aaudio::AAudioStreamConfiguration &configuration) = 0; Loading