diff options
Diffstat (limited to 'src/jni/rtp/AudioGroup.cpp')
-rw-r--r-- | src/jni/rtp/AudioGroup.cpp | 43 |
1 files changed, 18 insertions, 25 deletions
diff --git a/src/jni/rtp/AudioGroup.cpp b/src/jni/rtp/AudioGroup.cpp index e92e799..51b723d 100644 --- a/src/jni/rtp/AudioGroup.cpp +++ b/src/jni/rtp/AudioGroup.cpp @@ -44,8 +44,6 @@ #include <system/audio.h> #include <nativehelper/ScopedUtfChars.h> -#include <android/content/AttributionSourceState.h> -#include <android_os_Parcel.h> #include "jni.h" #include <nativehelper/JNIHelp.h> @@ -59,8 +57,6 @@ namespace { using namespace android; -using android::content::AttributionSourceState; - int gRandom = -1; // We use a circular array to implement jitter buffer. The simplest way is doing @@ -484,7 +480,7 @@ void AudioStream::decode(int tick) class AudioGroup { public: - explicit AudioGroup(const AttributionSourceState &attributionSource); + explicit AudioGroup(const String16 &opPackageName); ~AudioGroup(); bool set(int sampleRate, int sampleCount); @@ -509,7 +505,7 @@ private: int mEventQueue; volatile int mDtmfEvent; - const AttributionSourceState mAttributionSource; + String16 mOpPackageName; int mMode; int mSampleRate; @@ -558,9 +554,9 @@ private: sp<DeviceThread> mDeviceThread; }; -AudioGroup::AudioGroup(const AttributionSourceState &attributionSource) - : mAttributionSource(attributionSource) +AudioGroup::AudioGroup(const String16 &opPackageName) { + mOpPackageName = opPackageName; mMode = ON_HOLD; mChain = NULL; mEventQueue = -1; @@ -822,7 +818,7 @@ bool AudioGroup::DeviceThread::threadLoop() // Initialize AudioTrack and AudioRecord. sp<AudioTrack> track = new AudioTrack(); - sp<AudioRecord> record = new AudioRecord(mGroup->mAttributionSource); + sp<AudioRecord> record = new AudioRecord(mGroup->mOpPackageName); // Set caller name so it can be logged in destructor. // MediaMetricsConstants.h: AMEDIAMETRICS_PROP_CALLERNAME_VALUE_RTP track->setCallerName("rtp"); @@ -855,14 +851,14 @@ bool AudioGroup::DeviceThread::threadLoop() sp<AudioEffect> aec; if (mode == ECHO_SUPPRESSION) { if (mGroup->platformHasAec()) { - aec = new AudioEffect(mGroup->mAttributionSource); - aec->set(FX_IID_AEC, - NULL, - 0, - 0, - 0, - record->getSessionId(), - AUDIO_IO_HANDLE_NONE); // record sessionId is sufficient. + aec = new AudioEffect(FX_IID_AEC, + mGroup->mOpPackageName, + NULL, + 0, + 0, + 0, + record->getSessionId(), + AUDIO_IO_HANDLE_NONE); // record sessionId is sufficient. status_t status = aec->initCheck(); if (status == NO_ERROR || status == ALREADY_EXISTS) { aec->setEnabled(true); @@ -957,7 +953,7 @@ static jfieldID gMode; jlong add(JNIEnv *env, jobject thiz, jint mode, jint socket, jstring jRemoteAddress, jint remotePort, - jstring jCodecSpec, jint dtmfType, jobject jAttributionSource) + jstring jCodecSpec, jint dtmfType, jstring opPackageNameStr) { AudioCodec *codec = NULL; AudioStream *stream = NULL; @@ -985,9 +981,7 @@ jlong add(JNIEnv *env, jobject thiz, jint mode, return 0; } - Parcel* parcel = parcelForJavaObject(env, jAttributionSource); - AttributionSourceState attributionSource; - attributionSource.readFromParcel(parcel); + ScopedUtfChars opPackageName(env, opPackageNameStr); // Create audio codec. int codecType = -1; @@ -1018,7 +1012,7 @@ jlong add(JNIEnv *env, jobject thiz, jint mode, group = (AudioGroup *)env->GetLongField(thiz, gNative); if (!group) { int mode = env->GetIntField(thiz, gMode); - group = new AudioGroup(attributionSource); + group = new AudioGroup(String16(opPackageName.c_str())); if (!group->set(8000, 256) || !group->setMode(mode)) { jniThrowException(env, "java/lang/IllegalStateException", "cannot initialize audio group"); @@ -1074,7 +1068,7 @@ void sendDtmf(JNIEnv *env, jobject thiz, jint event) } JNINativeMethod gMethods[] = { - {"nativeAdd", "(IILjava/lang/String;ILjava/lang/String;ILandroid/os/Parcel;)J", (void *)add}, + {"nativeAdd", "(IILjava/lang/String;ILjava/lang/String;ILjava/lang/String;)J", (void *)add}, {"nativeRemove", "(J)V", (void *)remove}, {"nativeSetMode", "(I)V", (void *)setMode}, {"nativeSendDtmf", "(I)V", (void *)sendDtmf}, @@ -1084,7 +1078,7 @@ JNINativeMethod gMethods[] = { int registerAudioGroup(JNIEnv *env) { - gRandom = open("/dev/urandom", O_RDONLY | O_CLOEXEC); + gRandom = open("/dev/urandom", O_RDONLY); if (gRandom == -1) { ALOGE("urandom: %s", strerror(errno)); return -1; @@ -1098,6 +1092,5 @@ int registerAudioGroup(JNIEnv *env) ALOGE("JNI registration failed"); return -1; } - return 0; } |