Language

AudioTrack.FlushWrittenFramesFromPosition(Int64, Int32) Method

Definition

Flush all data from the given position.

[Android.Runtime.Register("flushWrittenFramesFromPosition", "(JI)J", "GetFlushWrittenFramesFromPosition_JIHandler", ApiSince=37)]
public virtual long FlushWrittenFramesFromPosition(long positionInFrames, int accuracy);
[<Android.Runtime.Register("flushWrittenFramesFromPosition", "(JI)J", "GetFlushWrittenFramesFromPosition_JIHandler", ApiSince=37)>]
abstract member FlushWrittenFramesFromPosition : int64 * int -> int64
override this.FlushWrittenFramesFromPosition : int64 * int -> int64

Parameters

positionInFrames
Int64

the start point in frames to flush. The value must be between 0 and total written frames.

accuracy
Int32

the accuracy requirement when flushing. Use #FLUSH_FROM_ACCURACY_BEST_EFFORT to indicate flush as close as possible to the requested position. Use #FLUSH_FROM_ACCURACY_EXACT to indicate must flush from the requested position.

Returns

the actual flushed position.

Attributes

Remarks

Flush all data from the given position.

If this operation returns successfully, write(byte, int, int) after a call to this method will be written from frame position returned by this method. The method getWrittenFramesCount() may be used to find the current frame position.

This method is only allowed in offload mode ((i.e. tracks created with Builder.setOffloadedPlayback(boolean) set to true)). Applications can call this function to flush data while it is actively playing.

Supporting this method relies on the device's capabilities. Call getFlushWrittenFramesFromPositionSupport(AudioFormat,AudioAttributes) to query how this method is supported with the AudioFormat and AudioAttributes before creating the AudioTrack. If getFlushWrittenFramesFromPositionSupport(AudioFormat, AudioAttributes) returns 0, UnsupportedOperationException will be thrown.

When clients request to flush from a certain position, the audio system will return the actual flushed position based on the requested position, the requested flush accuracy, and how much it was able to discard. All data from the actual flushed position will be discarded. When the stream is flushed, the stream end (if set by setOffloadEndOfStream()) will be reset.

The client must not write any data before this function returns. Otherwise, the data may be corrupted. When the method returns successfully and the stream is active, the client must write data immediately if little audio data remains, otherwise the playback may underrun.

Android reference for android.media.AudioTrack.flushWrittenFramesFromPosition.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to