summaryrefslogtreecommitdiff
path: root/media
diff options
context:
space:
mode:
Diffstat (limited to 'media')
-rw-r--r--media/java/android/media/IMediaRouterService.aidl2
-rw-r--r--media/java/android/media/MediaRouter2Manager.java30
-rw-r--r--media/java/android/media/RouteDiscoveryPreference.java1
-rw-r--r--media/java/android/media/SoundPool.java5
-rw-r--r--media/jni/android_media_MediaExtractor.cpp2
-rw-r--r--media/jni/soundpool/SoundPool.cpp5
-rw-r--r--media/jni/soundpool/SoundPool.h5
-rw-r--r--media/jni/soundpool/Stream.cpp4
-rw-r--r--media/jni/soundpool/StreamManager.cpp4
-rw-r--r--media/jni/soundpool/StreamManager.h8
-rw-r--r--media/jni/soundpool/android_media_SoundPool.cpp8
11 files changed, 62 insertions, 12 deletions
diff --git a/media/java/android/media/IMediaRouterService.aidl b/media/java/android/media/IMediaRouterService.aidl
index 068f9689d06f..4b8a8adade1f 100644
--- a/media/java/android/media/IMediaRouterService.aidl
+++ b/media/java/android/media/IMediaRouterService.aidl
@@ -73,6 +73,8 @@ interface IMediaRouterService {
void unregisterManager(IMediaRouter2Manager manager);
void setRouteVolumeWithManager(IMediaRouter2Manager manager, int requestId,
in MediaRoute2Info route, int volume);
+ void startScan(IMediaRouter2Manager manager);
+ void stopScan(IMediaRouter2Manager manager);
void requestCreateSessionWithManager(IMediaRouter2Manager manager, int requestId,
in RoutingSessionInfo oldSession, in @nullable MediaRoute2Info route);
diff --git a/media/java/android/media/MediaRouter2Manager.java b/media/java/android/media/MediaRouter2Manager.java
index 4b09a5f19fb0..68237de2ca98 100644
--- a/media/java/android/media/MediaRouter2Manager.java
+++ b/media/java/android/media/MediaRouter2Manager.java
@@ -147,6 +147,36 @@ public final class MediaRouter2Manager {
}
/**
+ * Starts scanning remote routes.
+ * @see #stopScan(String)
+ */
+ public void startScan() {
+ Client client = getOrCreateClient();
+ if (client != null) {
+ try {
+ mMediaRouterService.startScan(client);
+ } catch (RemoteException ex) {
+ Log.e(TAG, "Unable to get sessions. Service probably died.", ex);
+ }
+ }
+ }
+
+ /**
+ * Stops scanning remote routes to reduce resource consumption.
+ * @see #startScan(String)
+ */
+ public void stopScan() {
+ Client client = getOrCreateClient();
+ if (client != null) {
+ try {
+ mMediaRouterService.stopScan(client);
+ } catch (RemoteException ex) {
+ Log.e(TAG, "Unable to get sessions. Service probably died.", ex);
+ }
+ }
+ }
+
+ /**
* Gets a {@link android.media.session.MediaController} associated with the
* given routing session.
* If there is no matching media session, {@code null} is returned.
diff --git a/media/java/android/media/RouteDiscoveryPreference.java b/media/java/android/media/RouteDiscoveryPreference.java
index 68f2964dbeb2..2f952474b7f0 100644
--- a/media/java/android/media/RouteDiscoveryPreference.java
+++ b/media/java/android/media/RouteDiscoveryPreference.java
@@ -153,6 +153,7 @@ public final class RouteDiscoveryPreference implements Parcelable {
return false;
}
RouteDiscoveryPreference other = (RouteDiscoveryPreference) o;
+ //TODO: Make this order-free
return Objects.equals(mPreferredFeatures, other.mPreferredFeatures)
&& mShouldPerformActiveScan == other.mShouldPerformActiveScan;
}
diff --git a/media/java/android/media/SoundPool.java b/media/java/android/media/SoundPool.java
index 1bf2863989a5..3f685a4c934e 100644
--- a/media/java/android/media/SoundPool.java
+++ b/media/java/android/media/SoundPool.java
@@ -149,7 +149,8 @@ public class SoundPool extends PlayerBase {
super(attributes, AudioPlaybackConfiguration.PLAYER_TYPE_JAM_SOUNDPOOL);
// do native setup
- if (native_setup(new WeakReference<SoundPool>(this), maxStreams, attributes) != 0) {
+ if (native_setup(new WeakReference<SoundPool>(this),
+ maxStreams, attributes, getCurrentOpPackageName()) != 0) {
throw new RuntimeException("Native setup failed");
}
mAttributes = attributes;
@@ -501,7 +502,7 @@ public class SoundPool extends PlayerBase {
private native final int _load(FileDescriptor fd, long offset, long length, int priority);
private native final int native_setup(Object weakRef, int maxStreams,
- Object/*AudioAttributes*/ attributes);
+ @NonNull Object/*AudioAttributes*/ attributes, @NonNull String opPackageName);
private native final int _play(int soundID, float leftVolume, float rightVolume,
int priority, int loop, float rate);
diff --git a/media/jni/android_media_MediaExtractor.cpp b/media/jni/android_media_MediaExtractor.cpp
index 948ebcd9fdd5..6a622c5a1566 100644
--- a/media/jni/android_media_MediaExtractor.cpp
+++ b/media/jni/android_media_MediaExtractor.cpp
@@ -68,7 +68,7 @@ JMediaExtractor::JMediaExtractor(JNIEnv *env, jobject thiz)
mClass = (jclass)env->NewGlobalRef(clazz);
mObject = env->NewWeakGlobalRef(thiz);
- mImpl = new NuMediaExtractor;
+ mImpl = new NuMediaExtractor(NuMediaExtractor::EntryPoint::SDK);
}
JMediaExtractor::~JMediaExtractor() {
diff --git a/media/jni/soundpool/SoundPool.cpp b/media/jni/soundpool/SoundPool.cpp
index ac44843859f6..253b4e3a8a09 100644
--- a/media/jni/soundpool/SoundPool.cpp
+++ b/media/jni/soundpool/SoundPool.cpp
@@ -84,8 +84,9 @@ bool checkLoop(int32_t *loop)
} // namespace
-SoundPool::SoundPool(int32_t maxStreams, const audio_attributes_t* attributes)
- : mStreamManager(maxStreams, kStreamManagerThreads, attributes)
+SoundPool::SoundPool(
+ int32_t maxStreams, const audio_attributes_t* attributes, const std::string& opPackageName)
+ : mStreamManager(maxStreams, kStreamManagerThreads, attributes, opPackageName)
{
ALOGV("%s(maxStreams=%d, attr={ content_type=%d, usage=%d, flags=0x%x, tags=%s })",
__func__, maxStreams,
diff --git a/media/jni/soundpool/SoundPool.h b/media/jni/soundpool/SoundPool.h
index d5b16ef629cd..ffb1c997393a 100644
--- a/media/jni/soundpool/SoundPool.h
+++ b/media/jni/soundpool/SoundPool.h
@@ -19,6 +19,8 @@
#include "SoundManager.h"
#include "StreamManager.h"
+#include <string>
+
namespace android {
/**
@@ -29,7 +31,8 @@ namespace android {
*/
class SoundPool {
public:
- SoundPool(int32_t maxStreams, const audio_attributes_t* attributes);
+ SoundPool(int32_t maxStreams, const audio_attributes_t* attributes,
+ const std::string& opPackageName = {});
~SoundPool();
// SoundPool Java API support
diff --git a/media/jni/soundpool/Stream.cpp b/media/jni/soundpool/Stream.cpp
index e7042d0562a4..73e319a5902e 100644
--- a/media/jni/soundpool/Stream.cpp
+++ b/media/jni/soundpool/Stream.cpp
@@ -332,7 +332,9 @@ void Stream::play_l(const std::shared_ptr<Sound>& sound, int32_t nextStreamID,
0 /*default notification frames*/, AUDIO_SESSION_ALLOCATE,
AudioTrack::TRANSFER_DEFAULT,
nullptr /*offloadInfo*/, -1 /*uid*/, -1 /*pid*/,
- mStreamManager->getAttributes());
+ mStreamManager->getAttributes(),
+ false /*doNotReconnect*/, 1.0f /*maxRequiredSpeed*/,
+ mStreamManager->getOpPackageName());
// Set caller name so it can be logged in destructor.
// MediaMetricsConstants.h: AMEDIAMETRICS_PROP_CALLERNAME_VALUE_SOUNDPOOL
newTrack->setCallerName("soundpool");
diff --git a/media/jni/soundpool/StreamManager.cpp b/media/jni/soundpool/StreamManager.cpp
index 5b6494d4947e..502ee00b583e 100644
--- a/media/jni/soundpool/StreamManager.cpp
+++ b/media/jni/soundpool/StreamManager.cpp
@@ -98,9 +98,11 @@ int32_t StreamMap::getNextIdForStream(Stream* stream) const {
#pragma clang diagnostic ignored "-Wthread-safety-analysis"
StreamManager::StreamManager(
- int32_t streams, size_t threads, const audio_attributes_t* attributes)
+ int32_t streams, size_t threads, const audio_attributes_t* attributes,
+ std::string opPackageName)
: StreamMap(streams)
, mAttributes(*attributes)
+ , mOpPackageName(std::move(opPackageName))
{
ALOGV("%s(%d, %zu, ...)", __func__, streams, threads);
forEach([this](Stream *stream) {
diff --git a/media/jni/soundpool/StreamManager.h b/media/jni/soundpool/StreamManager.h
index 59ae2f9d108b..81ac69eb4358 100644
--- a/media/jni/soundpool/StreamManager.h
+++ b/media/jni/soundpool/StreamManager.h
@@ -24,6 +24,7 @@
#include <map>
#include <memory>
#include <mutex>
+#include <string>
#include <unordered_set>
#include <vector>
@@ -386,7 +387,8 @@ class StreamManager : public StreamMap {
public:
// Note: the SoundPool pointer is only used for stream initialization.
// It is not stored in StreamManager.
- StreamManager(int32_t streams, size_t threads, const audio_attributes_t* attributes);
+ StreamManager(int32_t streams, size_t threads, const audio_attributes_t* attributes,
+ std::string opPackageName);
~StreamManager();
// Returns positive streamID on success, 0 on failure. This is locked.
@@ -400,6 +402,8 @@ public:
const audio_attributes_t* getAttributes() const { return &mAttributes; }
+ const std::string& getOpPackageName() const { return mOpPackageName; }
+
// Moves the stream to the restart queue (called upon BUFFER_END of the static track)
// this is locked internally.
// If activeStreamIDToMatch is nonzero, it will only move to the restart queue
@@ -473,6 +477,8 @@ private:
// The paired stream may be active or restarting.
// No particular order.
std::unordered_set<Stream*> mProcessingStreams GUARDED_BY(mStreamManagerLock);
+
+ const std::string mOpPackageName;
};
} // namespace android::soundpool
diff --git a/media/jni/soundpool/android_media_SoundPool.cpp b/media/jni/soundpool/android_media_SoundPool.cpp
index 26725f87bfdc..357cc63bd41e 100644
--- a/media/jni/soundpool/android_media_SoundPool.cpp
+++ b/media/jni/soundpool/android_media_SoundPool.cpp
@@ -22,6 +22,7 @@
#include <utils/Log.h>
#include <jni.h>
#include <nativehelper/JNIPlatformHelp.h>
+#include <nativehelper/ScopedUtfChars.h>
#include <android_runtime/AndroidRuntime.h>
#include "SoundPool.h"
@@ -181,7 +182,7 @@ static void android_media_callback(SoundPoolEvent event, SoundPool* soundPool, v
static jint
android_media_SoundPool_native_setup(JNIEnv *env, jobject thiz, jobject weakRef,
- jint maxChannels, jobject jaa)
+ jint maxChannels, jobject jaa, jstring opPackageName)
{
if (jaa == nullptr) {
ALOGE("Error creating SoundPool: invalid audio attributes");
@@ -203,7 +204,8 @@ android_media_SoundPool_native_setup(JNIEnv *env, jobject thiz, jobject weakRef,
paa->flags = (audio_flags_mask_t) env->GetIntField(jaa, javaAudioAttrFields.fieldFlags);
ALOGV("android_media_SoundPool_native_setup");
- auto *ap = new SoundPool(maxChannels, paa);
+ ScopedUtfChars opPackageNameStr(env, opPackageName);
+ auto *ap = new SoundPool(maxChannels, paa, opPackageNameStr.c_str());
if (ap == nullptr) {
return -1;
}
@@ -298,7 +300,7 @@ static JNINativeMethod gMethods[] = {
(void *)android_media_SoundPool_setRate
},
{ "native_setup",
- "(Ljava/lang/Object;ILjava/lang/Object;)I",
+ "(Ljava/lang/Object;ILjava/lang/Object;Ljava/lang/String;)I",
(void*)android_media_SoundPool_native_setup
},
{ "native_release",