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

Commit ed2edc7a authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Clean up AudioRouting API internals.

Reuse existing OnRoutingChangedListener APIs and internal logic by
extending the new AudioRouting.OnRoutingChangedListener.  We use
new default methods to delegate incoming calls on the legacy
interfaces.

Fix a handful of locking bugs.

Bug: 27950070, 27952052, 27949198
Change-Id: Ie584108bcbeeab064d8e27d4984e541f31d36728
parent 155e5d6d
Loading
Loading
Loading
Loading
+11 −9
Original line number Diff line number Diff line
@@ -19852,8 +19852,8 @@ package android.media {
  public class AudioRecord implements android.media.AudioRouting {
    ctor public AudioRecord(int, int, int, int, int) throws java.lang.IllegalArgumentException;
    method public void addOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler);
    method public deprecated void addOnRoutingChangedListener(android.media.AudioRecord.OnRoutingChangedListener, android.os.Handler);
    method public void addOnRoutingListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler);
    method public int getAudioFormat();
    method public int getAudioSessionId();
    method public int getAudioSource();
@@ -19878,8 +19878,8 @@ package android.media {
    method public int read(java.nio.ByteBuffer, int);
    method public int read(java.nio.ByteBuffer, int, int);
    method public void release();
    method public void removeOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener);
    method public deprecated void removeOnRoutingChangedListener(android.media.AudioRecord.OnRoutingChangedListener);
    method public void removeOnRoutingListener(android.media.AudioRouting.OnRoutingChangedListener);
    method public int setNotificationMarkerPosition(int);
    method public int setPositionNotificationPeriod(int);
    method public boolean setPreferredDevice(android.media.AudioDeviceInfo);
@@ -19913,8 +19913,9 @@ package android.media {
    method public abstract void onPeriodicNotification(android.media.AudioRecord);
  }
  public static abstract interface AudioRecord.OnRoutingChangedListener {
  public static abstract deprecated interface AudioRecord.OnRoutingChangedListener implements android.media.AudioRouting.OnRoutingChangedListener {
    method public abstract void onRoutingChanged(android.media.AudioRecord);
    method public default void onRoutingChanged(android.media.AudioRouting);
  }
  public final class AudioRecordingConfiguration implements android.os.Parcelable {
@@ -19929,10 +19930,10 @@ package android.media {
  }
  public abstract interface AudioRouting {
    method public abstract void addOnRoutingListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler);
    method public abstract void addOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler);
    method public abstract android.media.AudioDeviceInfo getPreferredDevice();
    method public abstract android.media.AudioDeviceInfo getRoutedDevice();
    method public abstract void removeOnRoutingListener(android.media.AudioRouting.OnRoutingChangedListener);
    method public abstract void removeOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener);
    method public abstract boolean setPreferredDevice(android.media.AudioDeviceInfo);
  }
@@ -19952,8 +19953,8 @@ package android.media {
    ctor public AudioTrack(int, int, int, int, int, int) throws java.lang.IllegalArgumentException;
    ctor public AudioTrack(int, int, int, int, int, int, int) throws java.lang.IllegalArgumentException;
    ctor public AudioTrack(android.media.AudioAttributes, android.media.AudioFormat, int, int, int) throws java.lang.IllegalArgumentException;
    method public void addOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler);
    method public deprecated void addOnRoutingChangedListener(android.media.AudioTrack.OnRoutingChangedListener, android.os.Handler);
    method public void addOnRoutingListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler);
    method public int attachAuxEffect(int);
    method public void flush();
    method public int getAudioFormat();
@@ -19985,8 +19986,8 @@ package android.media {
    method public void play() throws java.lang.IllegalStateException;
    method public void release();
    method public int reloadStaticData();
    method public void removeOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener);
    method public deprecated void removeOnRoutingChangedListener(android.media.AudioTrack.OnRoutingChangedListener);
    method public void removeOnRoutingListener(android.media.AudioRouting.OnRoutingChangedListener);
    method public int setAuxEffectSendLevel(float);
    method public int setBufferSizeInFrames(int);
    method public int setLoopPoints(int, int, int);
@@ -20040,8 +20041,9 @@ package android.media {
    method public abstract void onPeriodicNotification(android.media.AudioTrack);
  }
  public static abstract deprecated interface AudioTrack.OnRoutingChangedListener {
    method public abstract deprecated void onRoutingChanged(android.media.AudioTrack);
  public static abstract deprecated interface AudioTrack.OnRoutingChangedListener implements android.media.AudioRouting.OnRoutingChangedListener {
    method public abstract void onRoutingChanged(android.media.AudioTrack);
    method public default void onRoutingChanged(android.media.AudioRouting);
  }
  public class CamcorderProfile {
+11 −9
Original line number Diff line number Diff line
@@ -21330,8 +21330,8 @@ package android.media {
  public class AudioRecord implements android.media.AudioRouting {
    ctor public AudioRecord(int, int, int, int, int) throws java.lang.IllegalArgumentException;
    ctor public AudioRecord(android.media.AudioAttributes, android.media.AudioFormat, int, int) throws java.lang.IllegalArgumentException;
    method public void addOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler);
    method public deprecated void addOnRoutingChangedListener(android.media.AudioRecord.OnRoutingChangedListener, android.os.Handler);
    method public void addOnRoutingListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler);
    method public int getAudioFormat();
    method public int getAudioSessionId();
    method public int getAudioSource();
@@ -21356,8 +21356,8 @@ package android.media {
    method public int read(java.nio.ByteBuffer, int);
    method public int read(java.nio.ByteBuffer, int, int);
    method public void release();
    method public void removeOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener);
    method public deprecated void removeOnRoutingChangedListener(android.media.AudioRecord.OnRoutingChangedListener);
    method public void removeOnRoutingListener(android.media.AudioRouting.OnRoutingChangedListener);
    method public int setNotificationMarkerPosition(int);
    method public int setPositionNotificationPeriod(int);
    method public boolean setPreferredDevice(android.media.AudioDeviceInfo);
@@ -21393,8 +21393,9 @@ package android.media {
    method public abstract void onPeriodicNotification(android.media.AudioRecord);
  }
  public static abstract interface AudioRecord.OnRoutingChangedListener {
  public static abstract deprecated interface AudioRecord.OnRoutingChangedListener implements android.media.AudioRouting.OnRoutingChangedListener {
    method public abstract void onRoutingChanged(android.media.AudioRecord);
    method public default void onRoutingChanged(android.media.AudioRouting);
  }
  public final class AudioRecordingConfiguration implements android.os.Parcelable {
@@ -21409,10 +21410,10 @@ package android.media {
  }
  public abstract interface AudioRouting {
    method public abstract void addOnRoutingListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler);
    method public abstract void addOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler);
    method public abstract android.media.AudioDeviceInfo getPreferredDevice();
    method public abstract android.media.AudioDeviceInfo getRoutedDevice();
    method public abstract void removeOnRoutingListener(android.media.AudioRouting.OnRoutingChangedListener);
    method public abstract void removeOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener);
    method public abstract boolean setPreferredDevice(android.media.AudioDeviceInfo);
  }
@@ -21432,8 +21433,8 @@ package android.media {
    ctor public AudioTrack(int, int, int, int, int, int) throws java.lang.IllegalArgumentException;
    ctor public AudioTrack(int, int, int, int, int, int, int) throws java.lang.IllegalArgumentException;
    ctor public AudioTrack(android.media.AudioAttributes, android.media.AudioFormat, int, int, int) throws java.lang.IllegalArgumentException;
    method public void addOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler);
    method public deprecated void addOnRoutingChangedListener(android.media.AudioTrack.OnRoutingChangedListener, android.os.Handler);
    method public void addOnRoutingListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler);
    method public int attachAuxEffect(int);
    method public void flush();
    method public int getAudioFormat();
@@ -21465,8 +21466,8 @@ package android.media {
    method public void play() throws java.lang.IllegalStateException;
    method public void release();
    method public int reloadStaticData();
    method public void removeOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener);
    method public deprecated void removeOnRoutingChangedListener(android.media.AudioTrack.OnRoutingChangedListener);
    method public void removeOnRoutingListener(android.media.AudioRouting.OnRoutingChangedListener);
    method public int setAuxEffectSendLevel(float);
    method public int setBufferSizeInFrames(int);
    method public int setLoopPoints(int, int, int);
@@ -21520,8 +21521,9 @@ package android.media {
    method public abstract void onPeriodicNotification(android.media.AudioTrack);
  }
  public static abstract deprecated interface AudioTrack.OnRoutingChangedListener {
    method public abstract deprecated void onRoutingChanged(android.media.AudioTrack);
  public static abstract deprecated interface AudioTrack.OnRoutingChangedListener implements android.media.AudioRouting.OnRoutingChangedListener {
    method public abstract void onRoutingChanged(android.media.AudioTrack);
    method public default void onRoutingChanged(android.media.AudioRouting);
  }
  public class CamcorderProfile {
+11 −9
Original line number Diff line number Diff line
@@ -19918,8 +19918,8 @@ package android.media {
  public class AudioRecord implements android.media.AudioRouting {
    ctor public AudioRecord(int, int, int, int, int) throws java.lang.IllegalArgumentException;
    method public void addOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler);
    method public deprecated void addOnRoutingChangedListener(android.media.AudioRecord.OnRoutingChangedListener, android.os.Handler);
    method public void addOnRoutingListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler);
    method public int getAudioFormat();
    method public int getAudioSessionId();
    method public int getAudioSource();
@@ -19944,8 +19944,8 @@ package android.media {
    method public int read(java.nio.ByteBuffer, int);
    method public int read(java.nio.ByteBuffer, int, int);
    method public void release();
    method public void removeOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener);
    method public deprecated void removeOnRoutingChangedListener(android.media.AudioRecord.OnRoutingChangedListener);
    method public void removeOnRoutingListener(android.media.AudioRouting.OnRoutingChangedListener);
    method public int setNotificationMarkerPosition(int);
    method public int setPositionNotificationPeriod(int);
    method public boolean setPreferredDevice(android.media.AudioDeviceInfo);
@@ -19979,8 +19979,9 @@ package android.media {
    method public abstract void onPeriodicNotification(android.media.AudioRecord);
  }
  public static abstract interface AudioRecord.OnRoutingChangedListener {
  public static abstract deprecated interface AudioRecord.OnRoutingChangedListener implements android.media.AudioRouting.OnRoutingChangedListener {
    method public abstract void onRoutingChanged(android.media.AudioRecord);
    method public default void onRoutingChanged(android.media.AudioRouting);
  }
  public final class AudioRecordingConfiguration implements android.os.Parcelable {
@@ -19995,10 +19996,10 @@ package android.media {
  }
  public abstract interface AudioRouting {
    method public abstract void addOnRoutingListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler);
    method public abstract void addOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler);
    method public abstract android.media.AudioDeviceInfo getPreferredDevice();
    method public abstract android.media.AudioDeviceInfo getRoutedDevice();
    method public abstract void removeOnRoutingListener(android.media.AudioRouting.OnRoutingChangedListener);
    method public abstract void removeOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener);
    method public abstract boolean setPreferredDevice(android.media.AudioDeviceInfo);
  }
@@ -20018,8 +20019,8 @@ package android.media {
    ctor public AudioTrack(int, int, int, int, int, int) throws java.lang.IllegalArgumentException;
    ctor public AudioTrack(int, int, int, int, int, int, int) throws java.lang.IllegalArgumentException;
    ctor public AudioTrack(android.media.AudioAttributes, android.media.AudioFormat, int, int, int) throws java.lang.IllegalArgumentException;
    method public void addOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler);
    method public deprecated void addOnRoutingChangedListener(android.media.AudioTrack.OnRoutingChangedListener, android.os.Handler);
    method public void addOnRoutingListener(android.media.AudioRouting.OnRoutingChangedListener, android.os.Handler);
    method public int attachAuxEffect(int);
    method public void flush();
    method public int getAudioFormat();
@@ -20051,8 +20052,8 @@ package android.media {
    method public void play() throws java.lang.IllegalStateException;
    method public void release();
    method public int reloadStaticData();
    method public void removeOnRoutingChangedListener(android.media.AudioRouting.OnRoutingChangedListener);
    method public deprecated void removeOnRoutingChangedListener(android.media.AudioTrack.OnRoutingChangedListener);
    method public void removeOnRoutingListener(android.media.AudioRouting.OnRoutingChangedListener);
    method public int setAuxEffectSendLevel(float);
    method public int setBufferSizeInFrames(int);
    method public int setLoopPoints(int, int, int);
@@ -20106,8 +20107,9 @@ package android.media {
    method public abstract void onPeriodicNotification(android.media.AudioTrack);
  }
  public static abstract deprecated interface AudioTrack.OnRoutingChangedListener {
    method public abstract deprecated void onRoutingChanged(android.media.AudioTrack);
  public static abstract deprecated interface AudioTrack.OnRoutingChangedListener implements android.media.AudioRouting.OnRoutingChangedListener {
    method public abstract void onRoutingChanged(android.media.AudioTrack);
    method public default void onRoutingChanged(android.media.AudioRouting);
  }
  public class CamcorderProfile {
+60 −128

File changed.

Preview size limit exceeded, changes collapsed.

+2 −2
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ public interface AudioRouting {
     * the callback. If <code>null</code>, the {@link Handler} associated with the main
     * {@link Looper} will be used.
     */
    public void addOnRoutingListener(OnRoutingChangedListener listener,
    public void addOnRoutingChangedListener(OnRoutingChangedListener listener,
            Handler handler);

    /**
@@ -66,7 +66,7 @@ public interface AudioRouting {
     * @param listener The previously added {@link AudioRouting.OnRoutingChangedListener} interface
     * to remove.
     */
    public void removeOnRoutingListener(OnRoutingChangedListener listener);
    public void removeOnRoutingChangedListener(OnRoutingChangedListener listener);

    /**
     * Defines the interface by which applications can receive notifications of routing
Loading