Android Audio Practical Combat - AudioTrack Analysis (26)

        AudioTrack is a class used to play audio data. You can use the set method to set the audio data, and then use start to start playback. The pause and stop are methods used to control the playback process. No matter what the APP uses to play audio files, AudioTrack will ultimately pass the data.

1. Source code analysis

1. Main methods

Constructor: called when creating AudioTrack.

play(): Play audio files.

pause(): Pause the audio file.

stop(): Stop playing the audio file.

flush(): Release the audio cache.

finalize(): System garbage collection callback.

release(): Release AudioTrack resources.

        In the following source code, we mainly analyze the above methods.

2、AudioTrack

Source code location:/frameworks/base/media/java/android/media/AudioTrack.java

Constructor

private AudioTrack(AudioAttributes attributes, AudioFormat format, int bufferSizeInBytes,
              int mode, int sessionId, boolean offload, int encapsulationMode,
              @Nullable TunerConfiguration tunerConfiguration) throws IllegalArgume

Guess you like

Origin blog.csdn.net/c19344881x/article/details/135204718