Loading core/jni/android_media_AudioErrors.h +1 −1 Original line number Diff line number Diff line Loading @@ -35,7 +35,7 @@ enum { AUDIO_JAVA_WOULD_BLOCK = -7, }; static inline jint nativeToJavaStatus(status_t status) { static constexpr inline jint nativeToJavaStatus(status_t status) { switch (status) { case NO_ERROR: return AUDIO_JAVA_SUCCESS; Loading core/jni/android_media_AudioTrack.cpp +26 −28 Original line number Diff line number Diff line Loading @@ -263,18 +263,7 @@ static jint android_media_AudioTrack_setup(JNIEnv *env, jobject thiz, jobject we return (jint) AUDIO_JAVA_ERROR; } // TODO: replace when we land matching AudioTrack::set() in frameworks/av in r or r-tv-dev. if (tunerConfiguration != nullptr) { const TunerConfigurationHelper tunerHelper(env, tunerConfiguration); ALOGE("Error creating AudioTrack: unsupported tuner contentId:%d syncId:%d", tunerHelper.getContentId(), tunerHelper.getSyncId()); return (jint)AUDIOTRACK_ERROR_SETUP_NATIVEINITFAILED; } // TODO: replace when we land matching AudioTrack::set() in frameworks/av in r or r-tv-dev. if (encapsulationMode != 0 /* ENCAPSULATION_MODE_NONE */) { ALOGE("Error creating AudioTrack: unsupported encapsulationMode %d", encapsulationMode); return (jint)AUDIOTRACK_ERROR_SETUP_NATIVEINITFAILED; } jint* nSession = (jint *) env->GetPrimitiveArrayCritical(jSession, NULL); if (nSession == NULL) { Loading Loading @@ -369,6 +358,18 @@ static jint android_media_AudioTrack_setup(JNIEnv *env, jobject thiz, jobject we offloadInfo.stream_type = AUDIO_STREAM_MUSIC; //required for offload } if (encapsulationMode != 0) { offloadInfo = AUDIO_INFO_INITIALIZER; offloadInfo.format = format; offloadInfo.sample_rate = sampleRateInHertz; offloadInfo.channel_mask = nativeChannelMask; offloadInfo.stream_type = AUDIO_STREAM_MUSIC; offloadInfo.encapsulation_mode = static_cast<audio_encapsulation_mode_t>(encapsulationMode); offloadInfo.content_id = tunerHelper.getContentId(); offloadInfo.sync_id = tunerHelper.getSyncId(); } // initialize the native AudioTrack object status_t status = NO_ERROR; switch (memoryMode) { Loading @@ -389,7 +390,8 @@ static jint android_media_AudioTrack_setup(JNIEnv *env, jobject thiz, jobject we sessionId, // audio session ID offload ? AudioTrack::TRANSFER_SYNC_NOTIF_CALLBACK : AudioTrack::TRANSFER_SYNC, offload ? &offloadInfo : NULL, -1, -1, // default uid, pid values (offload || encapsulationMode) ? &offloadInfo : NULL, -1, -1, // default uid, pid values paa.get()); break; Loading Loading @@ -1364,8 +1366,7 @@ static jint android_media_AudioTrack_setAudioDescriptionMixLeveldB(JNIEnv *env, return (jint)AUDIO_JAVA_ERROR; } // TODO: replace in r-dev or r-tv-dev with code if HW is able to set audio mix level. return (jint)AUDIO_JAVA_ERROR; return nativeToJavaStatus(lpTrack->setAudioDescriptionMixLevel(level)); } static jint android_media_AudioTrack_getAudioDescriptionMixLeveldB(JNIEnv *env, jobject thiz, Loading @@ -1381,12 +1382,10 @@ static jint android_media_AudioTrack_getAudioDescriptionMixLeveldB(JNIEnv *env, return (jint)AUDIO_JAVA_ERROR; } // TODO: replace in r-dev or r-tv-dev with code if HW is able to set audio mix level. // By contract we can return -infinity if unsupported. *nativeLevel = -std::numeric_limits<float>::infinity(); status_t status = lpTrack->getAudioDescriptionMixLevel(reinterpret_cast<float *>(nativeLevel)); env->ReleasePrimitiveArrayCritical(level, nativeLevel, 0 /* mode */); nativeLevel = nullptr; return (jint)AUDIO_JAVA_SUCCESS; return nativeToJavaStatus(status); } static jint android_media_AudioTrack_setDualMonoMode(JNIEnv *env, jobject thiz, jint dualMonoMode) { Loading @@ -1396,8 +1395,8 @@ static jint android_media_AudioTrack_setDualMonoMode(JNIEnv *env, jobject thiz, return (jint)AUDIO_JAVA_ERROR; } // TODO: replace in r-dev or r-tv-dev with code if HW is able to set audio mix level. return (jint)AUDIO_JAVA_ERROR; return nativeToJavaStatus( lpTrack->setDualMonoMode(static_cast<audio_dual_mono_mode_t>(dualMonoMode))); } static jint android_media_AudioTrack_getDualMonoMode(JNIEnv *env, jobject thiz, Loading @@ -1407,18 +1406,17 @@ static jint android_media_AudioTrack_getDualMonoMode(JNIEnv *env, jobject thiz, ALOGE("%s: AudioTrack not initialized", __func__); return (jint)AUDIO_JAVA_ERROR; } jfloat *nativeDualMonoMode = (jfloat *)env->GetPrimitiveArrayCritical(dualMonoMode, NULL); jint *nativeDualMonoMode = (jint *)env->GetPrimitiveArrayCritical(dualMonoMode, NULL); if (nativeDualMonoMode == nullptr) { ALOGE("%s: Cannot retrieve dualMonoMode pointer", __func__); return (jint)AUDIO_JAVA_ERROR; } // TODO: replace in r-dev or r-tv-dev with code if HW is able to select dual mono mode. // By contract we can return DUAL_MONO_MODE_OFF if unsupported. *nativeDualMonoMode = 0; // DUAL_MONO_MODE_OFF for now. status_t status = lpTrack->getDualMonoMode( reinterpret_cast<audio_dual_mono_mode_t *>(nativeDualMonoMode)); env->ReleasePrimitiveArrayCritical(dualMonoMode, nativeDualMonoMode, 0 /* mode */); nativeDualMonoMode = nullptr; return (jint)AUDIO_JAVA_SUCCESS; return nativeToJavaStatus(status); } // ---------------------------------------------------------------------------- Loading media/java/android/media/AudioManager.java +17 −6 Original line number Diff line number Diff line Loading @@ -5434,8 +5434,12 @@ public class AudioManager { public boolean setAdditionalOutputDeviceDelay( @NonNull AudioDeviceInfo device, @IntRange(from = 0) long delayMillis) { Objects.requireNonNull(device); // Implement the setter in r-dev or r-tv-dev as needed. return false; try { return getService().setAdditionalOutputDeviceDelay( new AudioDeviceAttributes(device), delayMillis); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** Loading @@ -5450,8 +5454,11 @@ public class AudioManager { @IntRange(from = 0) public long getAdditionalOutputDeviceDelay(@NonNull AudioDeviceInfo device) { Objects.requireNonNull(device); // Implement the getter in r-dev or r-tv-dev as needed. return 0; try { return getService().getAdditionalOutputDeviceDelay(new AudioDeviceAttributes(device)); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** Loading @@ -5468,8 +5475,12 @@ public class AudioManager { @IntRange(from = 0) public long getMaxAdditionalOutputDeviceDelay(@NonNull AudioDeviceInfo device) { Objects.requireNonNull(device); // Implement the getter in r-dev or r-tv-dev as needed. return 0; try { return getService().getMaxAdditionalOutputDeviceDelay( new AudioDeviceAttributes(device)); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** Loading media/java/android/media/AudioTrack.java +6 −4 Original line number Diff line number Diff line Loading @@ -1269,11 +1269,13 @@ public class AudioTrack extends PlayerBase // native code figure out the minimum buffer size. if (mMode == MODE_STREAM && mBufferSizeInBytes == 0) { int bytesPerSample = 1; if (AudioFormat.isEncodingLinearFrames(mFormat.getEncoding())) { try { bytesPerSample = mFormat.getBytesPerSample(mFormat.getEncoding()); } catch (IllegalArgumentException e) { // do nothing } } mBufferSizeInBytes = mFormat.getChannelCount() * bytesPerSample; } Loading media/java/android/media/IAudioService.aidl +6 −0 Original line number Diff line number Diff line Loading @@ -330,4 +330,10 @@ interface IAudioService { oneway void unregisterCommunicationDeviceDispatcher( ICommunicationDeviceDispatcher dispatcher); boolean setAdditionalOutputDeviceDelay(in AudioDeviceAttributes device, long delayMillis); long getAdditionalOutputDeviceDelay(in AudioDeviceAttributes device); long getMaxAdditionalOutputDeviceDelay(in AudioDeviceAttributes device); } Loading
core/jni/android_media_AudioErrors.h +1 −1 Original line number Diff line number Diff line Loading @@ -35,7 +35,7 @@ enum { AUDIO_JAVA_WOULD_BLOCK = -7, }; static inline jint nativeToJavaStatus(status_t status) { static constexpr inline jint nativeToJavaStatus(status_t status) { switch (status) { case NO_ERROR: return AUDIO_JAVA_SUCCESS; Loading
core/jni/android_media_AudioTrack.cpp +26 −28 Original line number Diff line number Diff line Loading @@ -263,18 +263,7 @@ static jint android_media_AudioTrack_setup(JNIEnv *env, jobject thiz, jobject we return (jint) AUDIO_JAVA_ERROR; } // TODO: replace when we land matching AudioTrack::set() in frameworks/av in r or r-tv-dev. if (tunerConfiguration != nullptr) { const TunerConfigurationHelper tunerHelper(env, tunerConfiguration); ALOGE("Error creating AudioTrack: unsupported tuner contentId:%d syncId:%d", tunerHelper.getContentId(), tunerHelper.getSyncId()); return (jint)AUDIOTRACK_ERROR_SETUP_NATIVEINITFAILED; } // TODO: replace when we land matching AudioTrack::set() in frameworks/av in r or r-tv-dev. if (encapsulationMode != 0 /* ENCAPSULATION_MODE_NONE */) { ALOGE("Error creating AudioTrack: unsupported encapsulationMode %d", encapsulationMode); return (jint)AUDIOTRACK_ERROR_SETUP_NATIVEINITFAILED; } jint* nSession = (jint *) env->GetPrimitiveArrayCritical(jSession, NULL); if (nSession == NULL) { Loading Loading @@ -369,6 +358,18 @@ static jint android_media_AudioTrack_setup(JNIEnv *env, jobject thiz, jobject we offloadInfo.stream_type = AUDIO_STREAM_MUSIC; //required for offload } if (encapsulationMode != 0) { offloadInfo = AUDIO_INFO_INITIALIZER; offloadInfo.format = format; offloadInfo.sample_rate = sampleRateInHertz; offloadInfo.channel_mask = nativeChannelMask; offloadInfo.stream_type = AUDIO_STREAM_MUSIC; offloadInfo.encapsulation_mode = static_cast<audio_encapsulation_mode_t>(encapsulationMode); offloadInfo.content_id = tunerHelper.getContentId(); offloadInfo.sync_id = tunerHelper.getSyncId(); } // initialize the native AudioTrack object status_t status = NO_ERROR; switch (memoryMode) { Loading @@ -389,7 +390,8 @@ static jint android_media_AudioTrack_setup(JNIEnv *env, jobject thiz, jobject we sessionId, // audio session ID offload ? AudioTrack::TRANSFER_SYNC_NOTIF_CALLBACK : AudioTrack::TRANSFER_SYNC, offload ? &offloadInfo : NULL, -1, -1, // default uid, pid values (offload || encapsulationMode) ? &offloadInfo : NULL, -1, -1, // default uid, pid values paa.get()); break; Loading Loading @@ -1364,8 +1366,7 @@ static jint android_media_AudioTrack_setAudioDescriptionMixLeveldB(JNIEnv *env, return (jint)AUDIO_JAVA_ERROR; } // TODO: replace in r-dev or r-tv-dev with code if HW is able to set audio mix level. return (jint)AUDIO_JAVA_ERROR; return nativeToJavaStatus(lpTrack->setAudioDescriptionMixLevel(level)); } static jint android_media_AudioTrack_getAudioDescriptionMixLeveldB(JNIEnv *env, jobject thiz, Loading @@ -1381,12 +1382,10 @@ static jint android_media_AudioTrack_getAudioDescriptionMixLeveldB(JNIEnv *env, return (jint)AUDIO_JAVA_ERROR; } // TODO: replace in r-dev or r-tv-dev with code if HW is able to set audio mix level. // By contract we can return -infinity if unsupported. *nativeLevel = -std::numeric_limits<float>::infinity(); status_t status = lpTrack->getAudioDescriptionMixLevel(reinterpret_cast<float *>(nativeLevel)); env->ReleasePrimitiveArrayCritical(level, nativeLevel, 0 /* mode */); nativeLevel = nullptr; return (jint)AUDIO_JAVA_SUCCESS; return nativeToJavaStatus(status); } static jint android_media_AudioTrack_setDualMonoMode(JNIEnv *env, jobject thiz, jint dualMonoMode) { Loading @@ -1396,8 +1395,8 @@ static jint android_media_AudioTrack_setDualMonoMode(JNIEnv *env, jobject thiz, return (jint)AUDIO_JAVA_ERROR; } // TODO: replace in r-dev or r-tv-dev with code if HW is able to set audio mix level. return (jint)AUDIO_JAVA_ERROR; return nativeToJavaStatus( lpTrack->setDualMonoMode(static_cast<audio_dual_mono_mode_t>(dualMonoMode))); } static jint android_media_AudioTrack_getDualMonoMode(JNIEnv *env, jobject thiz, Loading @@ -1407,18 +1406,17 @@ static jint android_media_AudioTrack_getDualMonoMode(JNIEnv *env, jobject thiz, ALOGE("%s: AudioTrack not initialized", __func__); return (jint)AUDIO_JAVA_ERROR; } jfloat *nativeDualMonoMode = (jfloat *)env->GetPrimitiveArrayCritical(dualMonoMode, NULL); jint *nativeDualMonoMode = (jint *)env->GetPrimitiveArrayCritical(dualMonoMode, NULL); if (nativeDualMonoMode == nullptr) { ALOGE("%s: Cannot retrieve dualMonoMode pointer", __func__); return (jint)AUDIO_JAVA_ERROR; } // TODO: replace in r-dev or r-tv-dev with code if HW is able to select dual mono mode. // By contract we can return DUAL_MONO_MODE_OFF if unsupported. *nativeDualMonoMode = 0; // DUAL_MONO_MODE_OFF for now. status_t status = lpTrack->getDualMonoMode( reinterpret_cast<audio_dual_mono_mode_t *>(nativeDualMonoMode)); env->ReleasePrimitiveArrayCritical(dualMonoMode, nativeDualMonoMode, 0 /* mode */); nativeDualMonoMode = nullptr; return (jint)AUDIO_JAVA_SUCCESS; return nativeToJavaStatus(status); } // ---------------------------------------------------------------------------- Loading
media/java/android/media/AudioManager.java +17 −6 Original line number Diff line number Diff line Loading @@ -5434,8 +5434,12 @@ public class AudioManager { public boolean setAdditionalOutputDeviceDelay( @NonNull AudioDeviceInfo device, @IntRange(from = 0) long delayMillis) { Objects.requireNonNull(device); // Implement the setter in r-dev or r-tv-dev as needed. return false; try { return getService().setAdditionalOutputDeviceDelay( new AudioDeviceAttributes(device), delayMillis); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** Loading @@ -5450,8 +5454,11 @@ public class AudioManager { @IntRange(from = 0) public long getAdditionalOutputDeviceDelay(@NonNull AudioDeviceInfo device) { Objects.requireNonNull(device); // Implement the getter in r-dev or r-tv-dev as needed. return 0; try { return getService().getAdditionalOutputDeviceDelay(new AudioDeviceAttributes(device)); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** Loading @@ -5468,8 +5475,12 @@ public class AudioManager { @IntRange(from = 0) public long getMaxAdditionalOutputDeviceDelay(@NonNull AudioDeviceInfo device) { Objects.requireNonNull(device); // Implement the getter in r-dev or r-tv-dev as needed. return 0; try { return getService().getMaxAdditionalOutputDeviceDelay( new AudioDeviceAttributes(device)); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** Loading
media/java/android/media/AudioTrack.java +6 −4 Original line number Diff line number Diff line Loading @@ -1269,11 +1269,13 @@ public class AudioTrack extends PlayerBase // native code figure out the minimum buffer size. if (mMode == MODE_STREAM && mBufferSizeInBytes == 0) { int bytesPerSample = 1; if (AudioFormat.isEncodingLinearFrames(mFormat.getEncoding())) { try { bytesPerSample = mFormat.getBytesPerSample(mFormat.getEncoding()); } catch (IllegalArgumentException e) { // do nothing } } mBufferSizeInBytes = mFormat.getChannelCount() * bytesPerSample; } Loading
media/java/android/media/IAudioService.aidl +6 −0 Original line number Diff line number Diff line Loading @@ -330,4 +330,10 @@ interface IAudioService { oneway void unregisterCommunicationDeviceDispatcher( ICommunicationDeviceDispatcher dispatcher); boolean setAdditionalOutputDeviceDelay(in AudioDeviceAttributes device, long delayMillis); long getAdditionalOutputDeviceDelay(in AudioDeviceAttributes device); long getMaxAdditionalOutputDeviceDelay(in AudioDeviceAttributes device); }