Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 26a857e1 authored by Jean-Michel Trivi's avatar Jean-Michel Trivi Committed by The Android Open Source Project
Browse files

Automated import from //branches/master/...@142377,142377

parent 6c349db7
Loading
Loading
Loading
Loading
+21 −5
Original line number Diff line number Diff line
@@ -64,6 +64,12 @@ public class JetPlayer
    private static final int JET_EVENT_TRACK_SHIFT = 18; // shift to get track ID to bit 0
    private static final int JET_EVENT_SEG_SHIFT   = 24; // shift to get segment ID to bit 0
    
    // to keep in sync with values used in external/sonivox/arm-wt-22k/Android.mk
    // Jet rendering audio parameters
    private static final int JET_OUTPUT_RATE = 22050; // _SAMPLE_RATE_22050 in Android.mk
    private static final int JET_OUTPUT_CHANNEL_CONFIG =
            AudioFormat.CHANNEL_CONFIGURATION_STEREO; // NUM_OUTPUT_CHANNELS=2 in Android.mk

    
    //--------------------------------------------
    // Member variables
@@ -102,8 +108,9 @@ public class JetPlayer
    // Constructor, finalize
    //------------------------
    public static JetPlayer getJetPlayer() {
        if (singletonRef == null)
        if (singletonRef == null) {
            singletonRef = new JetPlayer();
        }
        return singletonRef;
    }
    
@@ -122,9 +129,18 @@ public class JetPlayer
            mInitializationLooper = Looper.getMainLooper();
        }
        
        int buffSizeInBytes = AudioTrack.getMinBufferSize(JET_OUTPUT_RATE,
                JET_OUTPUT_CHANNEL_CONFIG, AudioFormat.ENCODING_PCM_16BIT);
        
        if ((buffSizeInBytes != AudioTrack.ERROR) 
                && (buffSizeInBytes != AudioTrack.ERROR_BAD_VALUE)) {
                            
            native_setup(new WeakReference<JetPlayer>(this),
                    JetPlayer.getMaxTracks(),
                1200); //TODO parametrize this (?)
                    // bytes to frame conversion: sample format is ENCODING_PCM_16BIT, 2 channels
                    // 1200 == minimum buffer size in frames on generation 1 hardware
                    Math.max(1200, buffSizeInBytes / 4));
        }
    }