diff options
Diffstat (limited to 'media')
5 files changed, 31 insertions, 28 deletions
diff --git a/media/java/android/media/MediaExtractor.java b/media/java/android/media/MediaExtractor.java index 9f10cb0..687d3a5 100644 --- a/media/java/android/media/MediaExtractor.java +++ b/media/java/android/media/MediaExtractor.java @@ -295,7 +295,7 @@ final public class MediaExtractor { * Returns true iff we are caching data and the cache has reached the * end of the data stream (for now, a future seek may of course restart * the fetching of data). - * This API only returns a meaningful result if {link #getCachedDuration} + * This API only returns a meaningful result if {@link #getCachedDuration} * indicates the presence of a cache, i.e. does NOT return -1. */ public native boolean hasCacheReachedEndOfStream(); diff --git a/media/java/android/media/MediaPlayer.java b/media/java/android/media/MediaPlayer.java index e76d25a..cd25865 100644 --- a/media/java/android/media/MediaPlayer.java +++ b/media/java/android/media/MediaPlayer.java @@ -706,7 +706,7 @@ public class MediaPlayer * surface rendering area. When the surface has the same aspect ratio * as the content, the aspect ratio of the content is maintained; * otherwise, the aspect ratio of the content is not maintained when video - * is being rendered. Unlike {@ #VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING}, + * is being rendered. Unlike {@link #VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING}, * there is no content cropping with this video scaling mode. */ public static final int VIDEO_SCALING_MODE_SCALE_TO_FIT = 1; @@ -2026,6 +2026,7 @@ public class MediaPlayer if (msg.obj instanceof Parcel) { Parcel parcel = (Parcel)msg.obj; TimedText text = new TimedText(parcel); + parcel.recycle(); mOnTimedTextListener.onTimedText(mMediaPlayer, text); } } diff --git a/media/java/android/media/MediaRouter.java b/media/java/android/media/MediaRouter.java index 357bf4e..a256079 100644 --- a/media/java/android/media/MediaRouter.java +++ b/media/java/android/media/MediaRouter.java @@ -126,6 +126,15 @@ public class MediaRouter { sStatic.mDefaultAudio.mNameResId = name; dispatchRouteChanged(sStatic.mDefaultAudio); } + + boolean a2dpEnabled; + try { + a2dpEnabled = mAudioService.isBluetoothA2dpOn(); + } catch (RemoteException e) { + Log.e(TAG, "Error querying Bluetooth A2DP state", e); + a2dpEnabled = false; + } + if (!TextUtils.equals(newRoutes.mBluetoothName, mCurRoutesInfo.mBluetoothName)) { mCurRoutesInfo.mBluetoothName = newRoutes.mBluetoothName; if (mCurRoutesInfo.mBluetoothName != null) { @@ -135,13 +144,6 @@ public class MediaRouter { info.mSupportedTypes = ROUTE_TYPE_LIVE_AUDIO; sStatic.mBluetoothA2dpRoute = info; addRoute(sStatic.mBluetoothA2dpRoute); - try { - if (mAudioService.isBluetoothA2dpOn()) { - selectRouteStatic(ROUTE_TYPE_LIVE_AUDIO, mBluetoothA2dpRoute); - } - } catch (RemoteException e) { - Log.e(TAG, "Error selecting Bluetooth A2DP route", e); - } } else { sStatic.mBluetoothA2dpRoute.mName = mCurRoutesInfo.mBluetoothName; dispatchRouteChanged(sStatic.mBluetoothA2dpRoute); @@ -151,6 +153,16 @@ public class MediaRouter { sStatic.mBluetoothA2dpRoute = null; } } + + if (mBluetoothA2dpRoute != null) { + if (mCurRoutesInfo.mMainType != AudioRoutesInfo.MAIN_SPEAKER && + mSelectedRoute == mBluetoothA2dpRoute) { + selectRouteStatic(ROUTE_TYPE_LIVE_AUDIO, mDefaultAudio); + } else if (mCurRoutesInfo.mMainType == AudioRoutesInfo.MAIN_SPEAKER && + mSelectedRoute == mDefaultAudio && a2dpEnabled) { + selectRouteStatic(ROUTE_TYPE_LIVE_AUDIO, mBluetoothA2dpRoute); + } + } } } diff --git a/media/jni/android_media_MediaPlayer.cpp b/media/jni/android_media_MediaPlayer.cpp index de22e09..c2a6889 100644 --- a/media/jni/android_media_MediaPlayer.cpp +++ b/media/jni/android_media_MediaPlayer.cpp @@ -72,7 +72,6 @@ private: JNIMediaPlayerListener(); jclass mClass; // Reference to MediaPlayer class jobject mObject; // Weak ref to MediaPlayer Java object to call on - jobject mParcel; }; JNIMediaPlayerListener::JNIMediaPlayerListener(JNIEnv* env, jobject thiz, jobject weak_thiz) @@ -91,7 +90,6 @@ JNIMediaPlayerListener::JNIMediaPlayerListener(JNIEnv* env, jobject thiz, jobjec // We use a weak reference so the MediaPlayer object can be garbage collected. // The reference is only used as a proxy for callbacks. mObject = env->NewGlobalRef(weak_thiz); - mParcel = env->NewGlobalRef(createJavaParcelObject(env)); } JNIMediaPlayerListener::~JNIMediaPlayerListener() @@ -100,20 +98,18 @@ JNIMediaPlayerListener::~JNIMediaPlayerListener() JNIEnv *env = AndroidRuntime::getJNIEnv(); env->DeleteGlobalRef(mObject); env->DeleteGlobalRef(mClass); - - recycleJavaParcelObject(env, mParcel); - env->DeleteGlobalRef(mParcel); } void JNIMediaPlayerListener::notify(int msg, int ext1, int ext2, const Parcel *obj) { JNIEnv *env = AndroidRuntime::getJNIEnv(); if (obj && obj->dataSize() > 0) { - if (mParcel != NULL) { - Parcel* nativeParcel = parcelForJavaObject(env, mParcel); + jobject jParcel = createJavaParcelObject(env); + if (jParcel != NULL) { + Parcel* nativeParcel = parcelForJavaObject(env, jParcel); nativeParcel->setData(obj->data(), obj->dataSize()); env->CallStaticVoidMethod(mClass, fields.post_event, mObject, - msg, ext1, ext2, mParcel); + msg, ext1, ext2, jParcel); } } else { env->CallStaticVoidMethod(mClass, fields.post_event, mObject, diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaPlayerStressTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaPlayerStressTest.java index 25b6e7f..67da6ac 100644 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaPlayerStressTest.java +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaPlayerStressTest.java @@ -24,6 +24,7 @@ import android.content.Intent; import android.hardware.Camera; import android.media.MediaPlayer; import android.media.MediaRecorder; +import android.os.Environment; import android.test.ActivityInstrumentationTestCase2; import android.test.suitebuilder.annotation.LargeTest; import android.util.Log; @@ -66,6 +67,9 @@ public class MediaPlayerStressTest extends ActivityInstrumentationTestCase2<Medi private int mTotalNotSeekable = 0; private int mTotalMetaDataUpdate = 0; + //Test result output file + private static final String PLAYBACK_RESULT = "PlaybackTestResult.txt"; + private void writeTestOutput(String filename, Writer output) throws Exception{ output.write("File Name: " + filename); output.write(" Complete: " + CodecTest.onCompleteSuccess); @@ -109,27 +113,19 @@ public class MediaPlayerStressTest extends ActivityInstrumentationTestCase2<Medi @LargeTest public void testVideoPlayback() throws Exception { String fileWithError = "Filename:\n"; - File playbackOutput = new File("/sdcard/PlaybackTestResult.txt"); + File playbackOutput = new File(Environment.getExternalStorageDirectory(), PLAYBACK_RESULT); Writer output = new BufferedWriter(new FileWriter(playbackOutput, true)); boolean testResult = true; // load directory files boolean onCompleteSuccess = false; File dir = new File(MediaNames.MEDIA_SAMPLE_POOL); - - Instrumentation inst = getInstrumentation(); - Intent intent = new Intent(); - - intent.setClass(getInstrumentation().getTargetContext(), MediaFrameworkTest.class); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - String[] children = dir.list(); if (children == null) { Log.v("MediaPlayerApiTest:testMediaSamples", "dir is empty"); return; } else { for (int i = 0; i < children.length; i++) { - Activity act = inst.startActivitySync(intent); //Get filename of directory String filename = children[i]; onCompleteSuccess = @@ -141,8 +137,6 @@ public class MediaPlayerStressTest extends ActivityInstrumentationTestCase2<Medi testResult = false; } Thread.sleep(3000); - //Call onCreat to recreate the surface - act.finish(); //Write test result to an output file writeTestOutput(filename,output); //Get the summary |