Crate oboe_sys[][src]

Expand description

Raw (unsafe) bindings for Oboe library

github Crates.io Package Docs.rs API Docs License: Apache-2.0 CI Status

Oboe is a C++ library which makes it easy to build high-performance audio apps on Android. It was created primarily to allow developers to target a simplified API that works across multiple API levels back to API level 16 (Jelly Bean).

Usually you shouldn’t use this crate directly, instead use oboe crate which provides safe interface.

Structs

Base class for Oboe C++ audio stream.

Base class containing parameters for audio streams and builders.

Factory class for an audio Stream.

AudioStreamCallback defines a callback interface for:

AudioStreamDataCallback defines a callback interface for moving data to/from an audio stream using onAudioReady 2) being alerted when a stream has an error using onError* methods

AudioStreamErrorCallback defines a callback interface for being alerted when a stream has an error or is disconnected using onError* methods.

On API 16 to 26 OpenSL ES will be used. When using OpenSL ES the optimal values for sampleRate and framesPerBurst are not known by the native code. On API 17+ these values should be obtained from the AudioManager using this code:

The time at which the frame at position was presented

LatencyTuner can be used to dynamically tune the latency of an output stream. It adjusts the stream’s bufferSize by monitoring the number of underruns.

A ResultWithValue can store both the result of an operation (either OK or an error) and a value.

This struct is a stateless functor which closes an AudioStream prior to its deletion. This means it can be used to safely delete a smart pointer referring to an open stream.

Oboe versioning object

Constants

Try to use AAudio. Fail if unavailable.

Use OpenSL ES.

Try to use AAudio. If not available then use OpenSL ES.

Single precision floating point.

Signed 16-bit integers.

Signed 24-bit integers, packed into 3 bytes.

Signed 32-bit integers.

Invalid format.

Unspecified format. Format will be decided by Oboe.

Use this for mono audio

Use this for stereo audio.

Audio channel count definition, use Mono or Stereo

Use this for a movie or video soundtrack.

Use this for pre-recorded or live music.

Use this for sound is designed to accompany a user action, such as a click or beep sound made when the user presses a button.

Use this for spoken voice, audio books, etcetera.

Used for recording.

Used for playback.

Use this preset when recording video.

Use this preset when other presets do not apply.

Use this preset to obtain an input with no effects. Note that this input will not have automatic gain control so the recorded volume may be very low.

Use this preset when doing telephony or voice messaging.

Use this preset for capturing audio meant to be processed in real time and played back for live performance (e.g karaoke). The capture path will minimize latency and coupling with playback path.

Use this preset when doing speech recognition.

Reducing latency is most important.

No particular performance needs. Default.

Extending battery life is most important.

Highest quality conversion, which may be expensive in terms of CPU.

Fastest conversion but may not sound great. This may be implemented using bilinear interpolation.

Fastest conversion but may not sound great. This may be implemented using bilinear interpolation.

Fastest conversion but may not sound great. This may be implemented using bilinear interpolation.

Fastest conversion but may not sound great. This may be implemented using bilinear interpolation.

No conversion by Oboe. Underlying APIs may still do conversion.

Allocate a session ID that can be used to attach and control effects using the Java AudioEffects API. Note that the use of this flag may result in higher latency.

Do not allocate a session ID. Effects cannot be used with this stream. Default.

This will be the only stream using a particular source or sink. This mode will provide the lowest possible latency. You should close EXCLUSIVE streams immediately when you are not using them.

Multiple applications can share the same device. The data from output streams will be mixed by the audio service. The data for input streams will be distributed by the audio service.

Use this to demand the users attention.

Use this for screen readers, etcetera.

Use this for driving or navigation directions.

Use this for user interface sounds, beeps, etcetera.

Use this for audio responses to user queries, audio instructions or help utterances.

Use this for game audio and sound effects.

Use this for streaming media, music performance, video, podcasts, etcetera.

Use this for notifying the user when a message has arrived or some other background event has occured.

Use this to attract the users attention when, for example, the battery is low.

Use this when the phone rings.

Use this for voice over IP, telephony, etcetera.

Use this for sounds associated with telephony such as busy tones, DTMF, etcetera.

Statics

Functions

Is the AAudio API recommended this device?

Is the AAudio API supported on this device?

Create and open a stream object based on the current settings.

Construct an AudioStream using the given AudioStreamBuilder

Close the stream and deallocate any resources from the open() call.

Override this to provide your own behaviour for the audio callback

Flush the stream. This will block until the stream has been flushed, an error occurs or timeoutNanoseconds has been reached.

@return number of frames of data currently in the buffer

Get the number of bytes per sample. This is calculated using the sample format. For example, a stream using 16-bit integer samples will have 2 bytes per sample.

The number of audio frames read from the stream. This monotonic counter will never get reset.

The number of audio frames written into the stream. This monotonic counter will never get reset.

Get the estimated time that the frame at framePosition entered or left the audio processing pipeline.

Launch a thread that will stop the stream.

Pause the stream. This will block until the stream has been paused, an error occurs or timeoutNanoseconds has been reached.

Start the stream. This will block until the stream has been started, an error occurs or timeoutNanoseconds has been reached.

Stop the stream. This will block until the stream has been stopped, an error occurs or timeoutNanoseconds has been reached.

Wait until the stream has a minimum amount of data available in its buffer. This can be used with an EXCLUSIVE MMAP input stream to avoid reading data too close to the DSP write position, which may cause glitches.

Wait for a transition from one state to another. @return OK if the endingState was observed, or ErrorUnexpectedState if any state that was not the startingState or endingState was observed or ErrorTimeout.

Construct a new LatencyTuner object which will act on the given audio stream

Construct a new LatencyTuner object which will act on the given audio stream.

@return true if the audio stream’s buffer size is at the maximum value. If no maximum value was specified when constructing the LatencyTuner then the value of stream->getBufferCapacityInFrames is used

This may be called from another thread. Then tune() will call reset(), which will lower the latency to the minimum and then allow it to rise back up if there are glitches.

Adjust the bufferSizeInFrames to optimize latency. It will start with a low latency and then raise it if an underrun occurs.

Return the version of the SDK that is currently running.

Type Definitions

The underlying audio API used by the audio stream.

The format of audio samples.

The channel count of the audio stream. The underlying type is int32_t. Use of this enum is convenient to avoid “magic” numbers when specifying the channel count.

The ContentType attribute describes what you are playing. It expresses the general category of the content. This information is optional. But in case it is known (for instance {@link Movie} for a movie streaming service or {@link Speech} for an audio book application) this information might be used by the audio framework to enforce audio focus.

The result of an audio callback.

The direction of the stream.

Defines the audio source. An audio source defines both a default physical source of audio signal, and a recording configuration.

The performance mode of the audio stream.

The result of an operation. All except the OK result indicates that an error occurred. The Result can be converted into a human readable string using convertToText.

Specifies the quality of the sample rate conversion performed by Oboe. Higher quality will require more CPU load. Higher quality conversion will probably be implemented using a sinc based resampler.

This attribute can be used to allocate a session ID to the audio stream.

The sharing mode of the audio stream.

The state of the audio stream.

The Usage attribute expresses why you are playing a sound, what is this sound used for. This information is used by certain platforms or routing policies to make more refined volume or routing decisions.