MediaPlayer2: remove AudioManager private API usage
Private API AudioManager.getDevicesStatic() is being used in
MediaPlayer2 for conversion between id <=> AudioDeviceInfo.
This conversion was added to talk with internal native AudioTrack API,
but in MediaPlayer2 since we will use public java AudioTrack API,
the given AudioDeviceInfo can be directly passed to java AudioTrack
instance.
Test: CtsMediaTestCases:android.media.cts.RoutingTest
Bug: 112767549
Change-Id: I9aeae02202edb6b5f0eb72b4f4dd3c936103ced2
diff --git a/media/libmediaplayer2/include/mediaplayer2/JAudioTrack.h b/media/libmediaplayer2/include/mediaplayer2/JAudioTrack.h
index 629968f..6122687 100644
--- a/media/libmediaplayer2/include/mediaplayer2/JAudioTrack.h
+++ b/media/libmediaplayer2/include/mediaplayer2/JAudioTrack.h
@@ -335,25 +335,24 @@
*/
status_t dump(int fd, const Vector<String16>& args) const;
- /* Returns the ID of the audio device actually used by the output to which this AudioTrack is
- * attached. When the AudioTrack is inactive, it will return AUDIO_PORT_HANDLE_NONE.
+ /* Returns the AudioDeviceInfo used by the output to which this AudioTrack is
+ * attached.
*/
- audio_port_handle_t getRoutedDeviceId();
+ jobject getRoutedDevice();
/* Returns the ID of the audio session this AudioTrack belongs to. */
audio_session_t getAudioSessionId();
- /* Selects the audio device to use for output of this AudioTrack. A value of
- * AUDIO_PORT_HANDLE_NONE indicates default routing.
+ /* Sets the preferred audio device to use for output of this AudioTrack.
*
* Parameters:
- * The device ID of the selected device (as returned by the AudioDevicesManager API).
+ * Device: an AudioDeviceInfo object.
*
* Returned value:
* - NO_ERROR: successful operation
- * - BAD_VALUE: failed to find the valid output device with given device Id.
+ * - BAD_VALUE: failed to set the device
*/
- status_t setOutputDevice(audio_port_handle_t deviceId);
+ status_t setPreferredDevice(jobject device);
// TODO: Add AUDIO_OUTPUT_FLAG_DIRECT when it is possible to check.
// TODO: Add AUDIO_FLAG_HW_AV_SYNC when it is possible to check.