summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
Diffstat (limited to 'media')
-rw-r--r--media/java/android/media/AudioManager.java62
-rw-r--r--media/java/android/media/AudioPortEventHandler.java2
-rw-r--r--media/java/android/media/MediaPlayer.java21
-rw-r--r--media/jni/android_media_MediaSync.h2
4 files changed, 74 insertions, 13 deletions
diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java
index 19900d0..56f0400 100644
--- a/media/java/android/media/AudioManager.java
+++ b/media/java/android/media/AudioManager.java
@@ -3402,7 +3402,17 @@ public class AudioManager {
* @hide
*/
public static int listAudioPorts(ArrayList<AudioPort> ports) {
- return updateAudioPortCache(ports, null);
+ return updateAudioPortCache(ports, null, null);
+ }
+
+ /**
+ * Returns a list of descriptors for all audio ports managed by the audio framework as
+ * it was before the last update calback.
+ * @param ports An AudioPort ArrayList where the list will be returned.
+ * @hide
+ */
+ public static int listPreviousAudioPorts(ArrayList<AudioPort> ports) {
+ return updateAudioPortCache(null, null, ports);
}
/**
@@ -3411,19 +3421,44 @@ public class AudioManager {
* @hide
*/
public static int listAudioDevicePorts(ArrayList<AudioDevicePort> devices) {
+ if (devices == null) {
+ return ERROR_BAD_VALUE;
+ }
ArrayList<AudioPort> ports = new ArrayList<AudioPort>();
- int status = updateAudioPortCache(ports, null);
+ int status = updateAudioPortCache(ports, null, null);
if (status == SUCCESS) {
- devices.clear();
- for (int i = 0; i < ports.size(); i++) {
- if (ports.get(i) instanceof AudioDevicePort) {
- devices.add((AudioDevicePort)ports.get(i));
- }
- }
+ filterDevicePorts(ports, devices);
+ }
+ return status;
+ }
+
+ /**
+ * Specialized version of listPreviousAudioPorts() listing only audio devices (AudioDevicePort)
+ * @see listPreviousAudioPorts(ArrayList<AudioPort>)
+ * @hide
+ */
+ public static int listPreviousAudioDevicePorts(ArrayList<AudioDevicePort> devices) {
+ if (devices == null) {
+ return ERROR_BAD_VALUE;
+ }
+ ArrayList<AudioPort> ports = new ArrayList<AudioPort>();
+ int status = updateAudioPortCache(null, null, ports);
+ if (status == SUCCESS) {
+ filterDevicePorts(ports, devices);
}
return status;
}
+ private static void filterDevicePorts(ArrayList<AudioPort> ports,
+ ArrayList<AudioDevicePort> devices) {
+ devices.clear();
+ for (int i = 0; i < ports.size(); i++) {
+ if (ports.get(i) instanceof AudioDevicePort) {
+ devices.add((AudioDevicePort)ports.get(i));
+ }
+ }
+ }
+
/**
* Create a connection between two or more devices. The framework will reject the request if
* device types are not compatible or the implementation does not support the requested
@@ -3474,7 +3509,7 @@ public class AudioManager {
* @hide
*/
public static int listAudioPatches(ArrayList<AudioPatch> patches) {
- return updateAudioPortCache(null, patches);
+ return updateAudioPortCache(null, patches, null);
}
/**
@@ -3540,6 +3575,7 @@ public class AudioManager {
static final int AUDIOPORT_GENERATION_INIT = 0;
static Integer sAudioPortGeneration = new Integer(AUDIOPORT_GENERATION_INIT);
static ArrayList<AudioPort> sAudioPortsCached = new ArrayList<AudioPort>();
+ static ArrayList<AudioPort> sPreviousAudioPortsCached = new ArrayList<AudioPort>();
static ArrayList<AudioPatch> sAudioPatchesCached = new ArrayList<AudioPatch>();
static int resetAudioPortGeneration() {
@@ -3551,7 +3587,8 @@ public class AudioManager {
return generation;
}
- static int updateAudioPortCache(ArrayList<AudioPort> ports, ArrayList<AudioPatch> patches) {
+ static int updateAudioPortCache(ArrayList<AudioPort> ports, ArrayList<AudioPatch> patches,
+ ArrayList<AudioPort> previousPorts) {
synchronized (sAudioPortGeneration) {
if (sAudioPortGeneration == AUDIOPORT_GENERATION_INIT) {
@@ -3610,6 +3647,7 @@ public class AudioManager {
}
}
+ sPreviousAudioPortsCached = sAudioPortsCached;
sAudioPortsCached = newPorts;
sAudioPatchesCached = newPatches;
sAudioPortGeneration = portGeneration[0];
@@ -3622,6 +3660,10 @@ public class AudioManager {
patches.clear();
patches.addAll(sAudioPatchesCached);
}
+ if (previousPorts != null) {
+ previousPorts.clear();
+ previousPorts.addAll(sPreviousAudioPortsCached);
+ }
}
return SUCCESS;
}
diff --git a/media/java/android/media/AudioPortEventHandler.java b/media/java/android/media/AudioPortEventHandler.java
index c49e8c2..c152245 100644
--- a/media/java/android/media/AudioPortEventHandler.java
+++ b/media/java/android/media/AudioPortEventHandler.java
@@ -84,7 +84,7 @@ class AudioPortEventHandler {
ArrayList<AudioPort> ports = new ArrayList<AudioPort>();
ArrayList<AudioPatch> patches = new ArrayList<AudioPatch>();
if (msg.what != AUDIOPORT_EVENT_SERVICE_DIED) {
- int status = AudioManager.updateAudioPortCache(ports, patches);
+ int status = AudioManager.updateAudioPortCache(ports, patches, null);
if (status != AudioManager.SUCCESS) {
return;
}
diff --git a/media/java/android/media/MediaPlayer.java b/media/java/android/media/MediaPlayer.java
index 6ec10c7..b3c1b4d 100644
--- a/media/java/android/media/MediaPlayer.java
+++ b/media/java/android/media/MediaPlayer.java
@@ -2824,6 +2824,13 @@ public class MediaPlayer implements SubtitleController.Listener
mSubtitleController.selectDefaultTrack();
}
break;
+ case MEDIA_INFO_BUFFERING_START:
+ case MEDIA_INFO_BUFFERING_END:
+ TimeProvider timeProvider = mTimeProvider;
+ if (timeProvider != null) {
+ timeProvider.onBuffering(msg.arg1 == MEDIA_INFO_BUFFERING_START);
+ }
+ break;
}
if (mOnInfoListener != null) {
@@ -3362,6 +3369,7 @@ public class MediaPlayer implements SubtitleController.Listener
private MediaPlayer mPlayer;
private boolean mPaused = true;
private boolean mStopped = true;
+ private boolean mBuffering;
private long mLastReportedTime;
private long mTimeAdjustment;
// since we are expecting only a handful listeners per stream, there is
@@ -3455,12 +3463,22 @@ public class MediaPlayer implements SubtitleController.Listener
}
/** @hide */
+ public void onBuffering(boolean buffering) {
+ synchronized (this) {
+ if (DEBUG) Log.d(TAG, "onBuffering: " + buffering);
+ mBuffering = buffering;
+ scheduleNotification(REFRESH_AND_NOTIFY_TIME, 0 /* delay */);
+ }
+ }
+
+ /** @hide */
public void onStopped() {
synchronized(this) {
if (DEBUG) Log.d(TAG, "onStopped");
mPaused = true;
mStopped = true;
mSeeking = false;
+ mBuffering = false;
scheduleNotification(NOTIFY_STOP, 0 /* delay */);
}
}
@@ -3481,6 +3499,7 @@ public class MediaPlayer implements SubtitleController.Listener
synchronized(this) {
mStopped = false;
mSeeking = true;
+ mBuffering = false;
scheduleNotification(NOTIFY_SEEK, 0 /* delay */);
}
}
@@ -3683,7 +3702,7 @@ public class MediaPlayer implements SubtitleController.Listener
nanoTime >= mLastNanoTime + MAX_NS_WITHOUT_POSITION_CHECK) {
try {
mLastTimeUs = mPlayer.getCurrentPosition() * 1000L;
- mPaused = !mPlayer.isPlaying();
+ mPaused = !mPlayer.isPlaying() || mBuffering;
if (DEBUG) Log.v(TAG, (mPaused ? "paused" : "playing") + " at " + mLastTimeUs);
} catch (IllegalStateException e) {
if (mPausing) {
diff --git a/media/jni/android_media_MediaSync.h b/media/jni/android_media_MediaSync.h
index fa5e5e0..5823057 100644
--- a/media/jni/android_media_MediaSync.h
+++ b/media/jni/android_media_MediaSync.h
@@ -26,7 +26,7 @@ namespace android {
struct AudioPlaybackRate;
class AudioTrack;
-struct IGraphicBufferProducer;
+class IGraphicBufferProducer;
struct MediaClock;
class MediaSync;