Skip to content

Commit

Permalink
Remove AudioTrack
Browse files Browse the repository at this point in the history
  • Loading branch information
kairusds committed Aug 10, 2023
1 parent 7387b6a commit 5daa32f
Showing 1 changed file with 1 addition and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package github.kairusds.libvlcandroidtest;

import android.content.Context;
import android.media.AudioManager;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
Expand All @@ -11,7 +10,6 @@
import org.videolan.libvlc.LibVLC;
import org.videolan.libvlc.Media;
import org.videolan.libvlc.MediaPlayer;
import org.videolan.libvlc.util.HWDecoderUtil;
import org.videolan.libvlc.util.VLCVideoLayout;

import java.io.IOException;
Expand All @@ -26,7 +24,6 @@ public class MainActivity extends AppCompatActivity {

private LibVLC mLibVLC = null;
private MediaPlayer mMediaPlayer = null;
private int audiotrackSessionId = 0;

@Override
protected void onCreate(Bundle savedInstanceState){
Expand All @@ -37,18 +34,11 @@ protected void onCreate(Bundle savedInstanceState){

mLibVLC = new LibVLC(this, getOptions());
mMediaPlayer = new MediaPlayer(mLibVLC);
mMediaPlayer.setAudioOutput(((HWDecoderUtil.getAudioOutputFromDevice() == HWDecoderUtil.AudioOutput.OPENSLES) ? "opensles_android" : null));
mMediaPlayer.setAudioOutput("opensles_android");

mVideoLayout = findViewById(R.id.video_layout);
}

private void init(){
if(audiotrackSessionId == 0){
AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
audiotrackSessionId = audioManager.generateAudioSessionId();
}
}

private ArrayList<String> getOptions(){
final ArrayList<String> options = new ArrayList<>();
options.add("--no-audio-time-stretch");
Expand All @@ -60,7 +50,6 @@ private ArrayList<String> getOptions(){
options.add("0");
options.add("--audio-resampler");
options.add("soxr"); // use soxr for audio resampling
options.add("--audiotrack-session-id=" + audiotrackSessionId);
options.add("-v"); // minimum vlc logging
options.add("--preferred-resolution=-1"); // use maximum resolution

Expand Down

0 comments on commit 5daa32f

Please sign in to comment.