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

Commit 068225de authored by Glenn Kasten's avatar Glenn Kasten
Browse files

Add all-channel setVolume() API

Add combined channel APIs setVolume to AudioTrack, MediaPlayer, and
SoundPool to make later migration easier, and encourage apps to use
that API.  The new APIs are @hide for now.

Change-Id: I0c87bfdbff4f4292259fa33e65f67badbafd270b
parent cf27115a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3178,7 +3178,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
                        mediaPlayer.setDataSource(filePath);
                        mediaPlayer.setAudioStreamType(AudioSystem.STREAM_SYSTEM);
                        mediaPlayer.prepare();
                        mediaPlayer.setVolume(volFloat, volFloat);
                        mediaPlayer.setVolume(volFloat);
                        mediaPlayer.setOnCompletionListener(new OnCompletionListener() {
                            public void onCompletion(MediaPlayer mp) {
                                cleanupPlayer(mp);
+9 −0
Original line number Diff line number Diff line
@@ -778,6 +778,15 @@ public class AudioTrack
    }


    /**
     * Similar, except set volume of all channels to same value.
     * @hide
     */
    public int setVolume(float volume) {
        return setStereoVolume(volume, volume);
    }


    /**
     * Sets the playback sample rate for this track. This sets the sampling rate at which
     * the audio data will be consumed and played back, not the original sampling rate of the
+14 −1
Original line number Diff line number Diff line
@@ -1361,14 +1361,27 @@ public class MediaPlayer
     * within an application. Unless you are writing an application to
     * control user settings, this API should be used in preference to
     * {@link AudioManager#setStreamVolume(int, int, int)} which sets the volume of ALL streams of
     * a particular type. Note that the passed volume values are raw scalars.
     * a particular type. Note that the passed volume values are raw scalars in range 0.0 to 1.0.
     * UI controls should be scaled logarithmically.
     *
     * @param leftVolume left volume scalar
     * @param rightVolume right volume scalar
     */
    /*
     * FIXME: Merge this into javadoc comment above when setVolume(float) is not @hide.
     * The single parameter form below is preferred if the channel volumes don't need
     * to be set independently.
     */
    public native void setVolume(float leftVolume, float rightVolume);

    /**
     * Similar, excepts sets volume of all channels to same value.
     * @hide
     */
    public void setVolume(float volume) {
        setVolume(volume, volume);
    }

    /**
     * Currently not implemented, returns null.
     * @deprecated
+8 −0
Original line number Diff line number Diff line
@@ -353,6 +353,14 @@ public class SoundPool
    public native final void setVolume(int streamID,
            float leftVolume, float rightVolume);

    /**
     * Similar, except set volume of all channels to same value.
     * @hide
     */
    public void setVolume(int streamID, float volume) {
        setVolume(streamID, volume, volume);
    }

    /**
     * Change stream priority.
     *