Merge "Add visibility rule for packages/modules/Media"
diff --git a/cmds/stagefright/AudioPlayer.cpp b/cmds/stagefright/AudioPlayer.cpp
index a63bde6..6cddf47 100644
--- a/cmds/stagefright/AudioPlayer.cpp
+++ b/cmds/stagefright/AudioPlayer.cpp
@@ -453,7 +453,7 @@
}
size_t AudioPlayer::onMoreData(const AudioTrack::Buffer& buffer) {
- return fillBuffer(buffer.raw, buffer.size);
+ return fillBuffer(buffer.data(), buffer.size());
}
void AudioPlayer::onStreamEnd() {
diff --git a/drm/libmediadrm/CryptoHalAidl.cpp b/drm/libmediadrm/CryptoHalAidl.cpp
index 37091dc..642264f 100644
--- a/drm/libmediadrm/CryptoHalAidl.cpp
+++ b/drm/libmediadrm/CryptoHalAidl.cpp
@@ -110,7 +110,7 @@
auto handle = buffer.secureMemory.getNativeHandle();
if (handle) {
aidldb.set<DestinationBufferAidl::Tag::secureMemory>(
- ::android::makeToAidl(handle));
+ ::android::dupToAidl(handle));
} else {
NativeHandleAidlCommon emptyhandle;
aidldb.set<DestinationBufferAidl::Tag::secureMemory>(
diff --git a/media/Android.mk b/media/Android.mk
new file mode 100644
index 0000000..220a358
--- /dev/null
+++ b/media/Android.mk
@@ -0,0 +1,5 @@
+LOCAL_PATH := $(call my-dir)
+
+$(eval $(call declare-1p-copy-files,frameworks/av/media/libeffects,audio_effects.conf))
+$(eval $(call declare-1p-copy-files,frameworks/av/media/libeffects,audio_effects.xml))
+$(eval $(call declare-1p-copy-files,frameworks/av/media/libstagefright,))
diff --git a/media/audioserver/Android.bp b/media/audioserver/Android.bp
index 0b44700..828d861 100644
--- a/media/audioserver/Android.bp
+++ b/media/audioserver/Android.bp
@@ -21,6 +21,7 @@
header_libs: [
"libaudiohal_headers",
+ "libmedia_headers",
"libmediametrics_headers",
],
@@ -51,7 +52,6 @@
"frameworks/av/media/libaaudio/include",
"frameworks/av/media/libaaudio/src",
"frameworks/av/media/libaaudio/src/binding",
- "frameworks/av/media/libmedia/include",
"frameworks/av/services/audioflinger",
"frameworks/av/services/audiopolicy",
"frameworks/av/services/audiopolicy/common/include",
diff --git a/media/codec2/hidl/1.0/utils/Component.cpp b/media/codec2/hidl/1.0/utils/Component.cpp
index 082c5e3..df30dba 100644
--- a/media/codec2/hidl/1.0/utils/Component.cpp
+++ b/media/codec2/hidl/1.0/utils/Component.cpp
@@ -482,6 +482,37 @@
if (res != C2_OK) {
mInit = res;
}
+
+ struct ListenerDeathRecipient : public HwDeathRecipient {
+ ListenerDeathRecipient(const wp<Component>& comp)
+ : mComponent{comp} {
+ }
+
+ virtual void serviceDied(
+ uint64_t /* cookie */,
+ const wp<::android::hidl::base::V1_0::IBase>& /* who */
+ ) override {
+ auto strongComponent = mComponent.promote();
+ if (strongComponent) {
+ LOG(INFO) << "Client died ! release the component !!";
+ strongComponent->release();
+ } else {
+ LOG(ERROR) << "Client died ! no component to release !!";
+ }
+ }
+
+ wp<Component> mComponent;
+ };
+
+ mDeathRecipient = new ListenerDeathRecipient(self);
+ Return<bool> transStatus = mListener->linkToDeath(
+ mDeathRecipient, 0);
+ if (!transStatus.isOk()) {
+ LOG(ERROR) << "Listener linkToDeath() transaction failed.";
+ }
+ if (!static_cast<bool>(transStatus)) {
+ LOG(DEBUG) << "Listener linkToDeath() call failed.";
+ }
}
Component::~Component() {
diff --git a/media/codec2/hidl/1.0/utils/include/codec2/hidl/1.0/Component.h b/media/codec2/hidl/1.0/utils/include/codec2/hidl/1.0/Component.h
index 86dccd0..e343655 100644
--- a/media/codec2/hidl/1.0/utils/include/codec2/hidl/1.0/Component.h
+++ b/media/codec2/hidl/1.0/utils/include/codec2/hidl/1.0/Component.h
@@ -132,6 +132,9 @@
friend struct ComponentStore;
struct Listener;
+
+ using HwDeathRecipient = ::android::hardware::hidl_death_recipient;
+ sp<HwDeathRecipient> mDeathRecipient;
};
} // namespace utils
diff --git a/media/codec2/hidl/1.0/vts/functional/common/Android.bp b/media/codec2/hidl/1.0/vts/functional/common/Android.bp
index 4106be8..be4bafa 100644
--- a/media/codec2/hidl/1.0/vts/functional/common/Android.bp
+++ b/media/codec2/hidl/1.0/vts/functional/common/Android.bp
@@ -14,8 +14,8 @@
"libcodec2-hidl-client-defaults",
],
- include_dirs: [
- "frameworks/av/media/codec2/hidl/client/include",
+ header_libs: [
+ "libcodec2_client_headers",
],
srcs: [
diff --git a/media/codec2/hidl/1.1/utils/Component.cpp b/media/codec2/hidl/1.1/utils/Component.cpp
index 1d7d3d8..2dd922f 100644
--- a/media/codec2/hidl/1.1/utils/Component.cpp
+++ b/media/codec2/hidl/1.1/utils/Component.cpp
@@ -489,6 +489,37 @@
if (res != C2_OK) {
mInit = res;
}
+
+ struct ListenerDeathRecipient : public HwDeathRecipient {
+ ListenerDeathRecipient(const wp<Component>& comp)
+ : component{comp} {
+ }
+
+ virtual void serviceDied(
+ uint64_t /* cookie */,
+ const wp<::android::hidl::base::V1_0::IBase>& /* who */
+ ) override {
+ auto strongComponent = component.promote();
+ if (strongComponent) {
+ LOG(INFO) << "Client died ! release the component !!";
+ strongComponent->release();
+ } else {
+ LOG(ERROR) << "Client died ! no component to release !!";
+ }
+ }
+
+ wp<Component> component;
+ };
+
+ mDeathRecipient = new ListenerDeathRecipient(self);
+ Return<bool> transStatus = mListener->linkToDeath(
+ mDeathRecipient, 0);
+ if (!transStatus.isOk()) {
+ LOG(ERROR) << "Listener linkToDeath() transaction failed.";
+ }
+ if (!static_cast<bool>(transStatus)) {
+ LOG(DEBUG) << "Listener linkToDeath() call failed.";
+ }
}
Component::~Component() {
diff --git a/media/codec2/hidl/1.1/utils/include/codec2/hidl/1.1/Component.h b/media/codec2/hidl/1.1/utils/include/codec2/hidl/1.1/Component.h
index 16c81d4..1c8c20c 100644
--- a/media/codec2/hidl/1.1/utils/include/codec2/hidl/1.1/Component.h
+++ b/media/codec2/hidl/1.1/utils/include/codec2/hidl/1.1/Component.h
@@ -137,6 +137,9 @@
friend struct ComponentStore;
struct Listener;
+
+ using HwDeathRecipient = ::android::hardware::hidl_death_recipient;
+ sp<HwDeathRecipient> mDeathRecipient;
};
} // namespace utils
diff --git a/media/codec2/hidl/client/Android.bp b/media/codec2/hidl/client/Android.bp
index 0e52813..f32711d 100644
--- a/media/codec2/hidl/client/Android.bp
+++ b/media/codec2/hidl/client/Android.bp
@@ -7,6 +7,24 @@
default_applicable_licenses: ["frameworks_av_license"],
}
+cc_library_headers {
+ name: "libcodec2_client_headers",
+ export_include_dirs: ["include"],
+ vendor_available: true,
+ apex_available: [
+ "//apex_available:platform",
+ "com.android.media",
+ "com.android.media.swcodec",
+ ],
+ min_sdk_version: "29",
+ host_supported: true,
+ target: {
+ darwin: {
+ enabled: false,
+ },
+ },
+}
+
cc_library {
name: "libcodec2_client",
diff --git a/media/codec2/sfplugin/Android.bp b/media/codec2/sfplugin/Android.bp
index feeddb5..a73b493 100644
--- a/media/codec2/sfplugin/Android.bp
+++ b/media/codec2/sfplugin/Android.bp
@@ -7,6 +7,12 @@
default_applicable_licenses: ["frameworks_av_license"],
}
+cc_library_headers {
+ name: "libsfplugin_ccodec_internal_headers",
+ export_include_dirs: ["."],
+ // only for internal tests, perhaps restrict via visibility clause
+}
+
cc_library_shared {
name: "libsfplugin_ccodec",
diff --git a/media/codec2/sfplugin/tests/Android.bp b/media/codec2/sfplugin/tests/Android.bp
index 92f3754..246e563 100644
--- a/media/codec2/sfplugin/tests/Android.bp
+++ b/media/codec2/sfplugin/tests/Android.bp
@@ -23,8 +23,8 @@
"libcodec2-internal-defaults",
],
- include_dirs: [
- "frameworks/av/media/codec2/sfplugin",
+ header_libs: [
+ "libsfplugin_ccodec_internal_headers",
],
shared_libs: [
@@ -60,13 +60,10 @@
"MediaCodec_sanity_test.cpp",
],
- include_dirs: [
- "frameworks/av/media/codec2/sfplugin",
- ],
-
header_libs: [
"libmediadrm_headers",
"libmediametrics_headers",
+ "libsfplugin_ccodec_internal_headers",
],
shared_libs: [
diff --git a/media/libaaudio/src/legacy/AudioStreamLegacy.cpp b/media/libaaudio/src/legacy/AudioStreamLegacy.cpp
index 38f3c24..dd11169 100644
--- a/media/libaaudio/src/legacy/AudioStreamLegacy.cpp
+++ b/media/libaaudio/src/legacy/AudioStreamLegacy.cpp
@@ -76,6 +76,7 @@
// This takes advantage of them killing the stream when they see a size out of range.
// That is an undocumented behavior.
// TODO add to API in AudioRecord and AudioTrack
+ // TODO(b/216175830) cleanup size re-computation
const size_t SIZE_STOP_CALLBACKS = SIZE_MAX;
aaudio_data_callback_result_t callbackResult;
(void) checkForDisconnectRequest(true);
@@ -83,7 +84,7 @@
// Note that this code assumes an AudioTrack::Buffer is the same as
// AudioRecord::Buffer
// TODO define our own AudioBuffer and pass it from the subclasses.
- size_t written = buffer.size;
+ size_t written = buffer.size();
if (getState() == AAUDIO_STREAM_STATE_DISCONNECTED) {
ALOGW("%s() data, stream disconnected", __func__);
// This will kill the stream and prevent it from being restarted.
@@ -96,23 +97,23 @@
// caused by Legacy callbacks running after the track is "stopped".
written = 0;
} else {
- if (buffer.frameCount == 0) {
+ if (buffer.getFrameCount() == 0) {
ALOGW("%s() data, frameCount is zero", __func__);
return written;
}
// If the caller specified an exact size then use a block size adapter.
if (mBlockAdapter != nullptr) {
- int32_t byteCount = buffer.frameCount * getBytesPerDeviceFrame();
+ int32_t byteCount = buffer.getFrameCount() * getBytesPerDeviceFrame();
callbackResult = mBlockAdapter->processVariableBlock(
- static_cast<uint8_t*>(buffer.raw), byteCount);
+ buffer.data(), byteCount);
} else {
// Call using the AAudio callback interface.
- callbackResult = callDataCallbackFrames(static_cast<uint8_t *>(buffer.raw),
- buffer.frameCount);
+ callbackResult = callDataCallbackFrames(buffer.data(),
+ buffer.getFrameCount());
}
if (callbackResult == AAUDIO_CALLBACK_RESULT_CONTINUE) {
- written = buffer.frameCount * getBytesPerDeviceFrame();
+ written = buffer.getFrameCount() * getBytesPerDeviceFrame();
} else {
if (callbackResult == AAUDIO_CALLBACK_RESULT_STOP) {
ALOGD("%s() callback returned AAUDIO_CALLBACK_RESULT_STOP", __func__);
@@ -134,6 +135,70 @@
return written;
}
+// TODO (b/216175830) this method is duplicated in order to ease refactoring which will
+// reconsolidate.
+size_t AudioStreamLegacy::onMoreData(const android::AudioRecord::Buffer& buffer) {
+ // This illegal size can be used to tell AudioRecord or AudioTrack to stop calling us.
+ // This takes advantage of them killing the stream when they see a size out of range.
+ // That is an undocumented behavior.
+ // TODO add to API in AudioRecord and AudioTrack
+ const size_t SIZE_STOP_CALLBACKS = SIZE_MAX;
+ aaudio_data_callback_result_t callbackResult;
+ (void) checkForDisconnectRequest(true);
+
+ // Note that this code assumes an AudioTrack::Buffer is the same as
+ // AudioRecord::Buffer
+ // TODO define our own AudioBuffer and pass it from the subclasses.
+ size_t written = buffer.size();
+ if (getState() == AAUDIO_STREAM_STATE_DISCONNECTED) {
+ ALOGW("%s() data, stream disconnected", __func__);
+ // This will kill the stream and prevent it from being restarted.
+ // That is OK because the stream is disconnected.
+ written = SIZE_STOP_CALLBACKS;
+ } else if (!mCallbackEnabled.load()) {
+ ALOGW("%s() no data because callback disabled, set size=0", __func__);
+ // Do NOT use SIZE_STOP_CALLBACKS here because that will kill the stream and
+ // prevent it from being restarted. This can occur because of a race condition
+ // caused by Legacy callbacks running after the track is "stopped".
+ written = 0;
+ } else {
+ if (buffer.getFrameCount() == 0) {
+ ALOGW("%s() data, frameCount is zero", __func__);
+ return written;
+ }
+
+ // If the caller specified an exact size then use a block size adapter.
+ if (mBlockAdapter != nullptr) {
+ int32_t byteCount = buffer.getFrameCount() * getBytesPerDeviceFrame();
+ callbackResult = mBlockAdapter->processVariableBlock(
+ buffer.data(), byteCount);
+ } else {
+ // Call using the AAudio callback interface.
+ callbackResult = callDataCallbackFrames(buffer.data(),
+ buffer.getFrameCount());
+ }
+ if (callbackResult == AAUDIO_CALLBACK_RESULT_CONTINUE) {
+ written = buffer.getFrameCount() * getBytesPerDeviceFrame();
+ } else {
+ if (callbackResult == AAUDIO_CALLBACK_RESULT_STOP) {
+ ALOGD("%s() callback returned AAUDIO_CALLBACK_RESULT_STOP", __func__);
+ } else {
+ ALOGW("%s() callback returned invalid result = %d",
+ __func__, callbackResult);
+ }
+ written = 0;
+ systemStopInternal();
+ // Disable the callback just in case the system keeps trying to call us.
+ mCallbackEnabled.store(false);
+ }
+
+ if (updateStateMachine() != AAUDIO_OK) {
+ forceDisconnect();
+ mCallbackEnabled.store(false);
+ }
+ }
+ return written;
+}
aaudio_result_t AudioStreamLegacy::checkForDisconnectRequest(bool errorCallbackEnabled) {
if (mRequestDisconnect.isRequested()) {
diff --git a/media/libaaudio/src/legacy/AudioStreamLegacy.h b/media/libaaudio/src/legacy/AudioStreamLegacy.h
index c54d7e2..53f6e06 100644
--- a/media/libaaudio/src/legacy/AudioStreamLegacy.h
+++ b/media/libaaudio/src/legacy/AudioStreamLegacy.h
@@ -17,9 +17,10 @@
#ifndef LEGACY_AUDIO_STREAM_LEGACY_H
#define LEGACY_AUDIO_STREAM_LEGACY_H
+#include <media/AudioRecord.h>
+#include <media/AudioSystem.h>
#include <media/AudioTimestamp.h>
#include <media/AudioTrack.h>
-#include <media/AudioSystem.h>
#include <aaudio/AAudio.h>
@@ -57,7 +58,8 @@
class AudioStreamLegacy : public AudioStream,
public FixedBlockProcessor,
- protected android::AudioTrack::IAudioTrackCallback {
+ protected android::AudioTrack::IAudioTrackCallback,
+ protected android::AudioRecord::IAudioRecordCallback {
public:
AudioStreamLegacy();
@@ -82,7 +84,11 @@
protected:
size_t onMoreData(const android::AudioTrack::Buffer& buffer) override;
+ // TODO (b/216175830) this method is duplicated in order to ease refactoring which will
+ // reconsolidate.
+ size_t onMoreData(const android::AudioRecord::Buffer& buffer) override;
void onNewIAudioTrack() override;
+ void onNewIAudioRecord() override { onNewIAudioTrack(); }
aaudio_result_t getBestTimestamp(clockid_t clockId,
int64_t *framePosition,
int64_t *timeNanoseconds,
diff --git a/media/libaaudio/src/legacy/AudioStreamRecord.cpp b/media/libaaudio/src/legacy/AudioStreamRecord.cpp
index d9f12a5..ed31ec9 100644
--- a/media/libaaudio/src/legacy/AudioStreamRecord.cpp
+++ b/media/libaaudio/src/legacy/AudioStreamRecord.cpp
@@ -37,10 +37,6 @@
using namespace android;
using namespace aaudio;
-static void sCallbackWrapper(int event, void* userData, void* info) {
- static_cast<AudioStreamRecord*>(userData)->processCallback(event, info);
-}
-
AudioStreamRecord::AudioStreamRecord()
: AudioStreamLegacy()
, mFixedBlockWriter(*this)
@@ -128,13 +124,11 @@
uint32_t notificationFrames = 0;
// Setup the callback if there is one.
- AudioRecord::legacy_callback_t callback = nullptr;
- void *callbackData = nullptr;
+ sp<AudioRecord::IAudioRecordCallback> callback;
AudioRecord::transfer_type streamTransferType = AudioRecord::transfer_type::TRANSFER_SYNC;
if (builder.getDataCallbackProc() != nullptr) {
streamTransferType = AudioRecord::transfer_type::TRANSFER_CALLBACK;
- callback = sCallbackWrapper;
- callbackData = this;
+ callback = sp<AudioRecord::IAudioRecordCallback>::fromExisting(this);
}
mCallbackBufferSize = builder.getFramesPerDataCallback();
@@ -181,7 +175,6 @@
channelMask,
frameCount,
callback,
- callbackData,
notificationFrames,
false /*threadCanCallJava*/,
sessionId,
@@ -354,24 +347,6 @@
}
}
-void AudioStreamRecord::processCallback(int event, void *info) {
- switch (event) {
- case AudioRecord::EVENT_MORE_DATA:
- {
- AudioTrack::Buffer *audioBuffer = static_cast<AudioTrack::Buffer *>(info);
- audioBuffer->size = onMoreData(*audioBuffer);
- break;
- }
- // Stream got rerouted so we disconnect.
- case AudioRecord::EVENT_NEW_IAUDIORECORD:
- onNewIAudioTrack();
- break;
- default:
- break;
- }
- return;
-}
-
aaudio_result_t AudioStreamRecord::requestStart_l()
{
if (mAudioRecord.get() == nullptr) {
diff --git a/media/libaudioclient/AudioRecord.cpp b/media/libaudioclient/AudioRecord.cpp
index edcb86a..a5fb394 100644
--- a/media/libaudioclient/AudioRecord.cpp
+++ b/media/libaudioclient/AudioRecord.cpp
@@ -267,7 +267,7 @@
size_t onMoreData(const AudioRecord::Buffer& buffer) override {
AudioRecord::Buffer copy = buffer;
mCallback(AudioRecord::EVENT_MORE_DATA, mData, ©);
- return copy.size;
+ return copy.size();
}
void onOverrun() override { mCallback(AudioRecord::EVENT_OVERRUN, mData, nullptr); }
@@ -307,7 +307,6 @@
int32_t maxSharedAudioHistoryMs)
{
status_t status = NO_ERROR;
- const sp<IAudioRecordCallback> callbackHandle = callback.promote();
// Note mPortId is not valid until the track is created, so omit mPortId in ALOG for set.
ALOGV("%s(): inputSource %d, sampleRate %u, format %#x, channelMask %#x, frameCount %zu, "
"notificationFrames %u, sessionId %d, transferType %d, flags %#x, attributionSource %s"
@@ -373,14 +372,14 @@
mTransfer = transferType;
switch (mTransfer) {
case TRANSFER_DEFAULT:
- if (callbackHandle == nullptr || threadCanCallJava) {
+ if (callback == nullptr || threadCanCallJava) {
mTransfer = TRANSFER_SYNC;
} else {
mTransfer = TRANSFER_CALLBACK;
}
break;
case TRANSFER_CALLBACK:
- if (callbackHandle == nullptr) {
+ if (callback == nullptr) {
errorMessage = StringPrintf(
"%s: Transfer type TRANSFER_CALLBACK but callback == nullptr", __func__);
status = BAD_VALUE;
@@ -429,7 +428,7 @@
mNotificationFramesReq = notificationFrames;
// mNotificationFramesAct is initialized in createRecord_l
- mCallback = callbackHandle;
+ mCallback = callback;
if (mCallback != nullptr) {
mAudioRecordThread = new AudioRecordThread(*this);
mAudioRecordThread->run("AudioRecord", ANDROID_PRIORITY_AUDIO);
@@ -640,7 +639,7 @@
{
AutoMutex lock(mLock);
// The only purpose of setting marker position is to get a callback
- if (mCallback.promote() == nullptr) {
+ if (mCallback == nullptr) {
return INVALID_OPERATION;
}
@@ -670,7 +669,7 @@
{
AutoMutex lock(mLock);
// The only purpose of setting position update period is to get a callback
- if (mCallback.promote() == nullptr) {
+ if (mCallback == nullptr) {
return INVALID_OPERATION;
}
@@ -1037,7 +1036,7 @@
mNotificationFramesReq, output.notificationFrameCount, output.frameCount);
}
mNotificationFramesAct = (uint32_t)output.notificationFrameCount;
- if (mServerConfig.format != mFormat && mCallback.promote() != nullptr) {
+ if (mServerConfig.format != mFormat && mCallback != nullptr) {
mFormatConversionBufRaw = std::make_unique<uint8_t[]>(mNotificationFramesAct * mFrameSize);
mFormatConversionBuffer.raw = mFormatConversionBufRaw.get();
}
@@ -1142,7 +1141,7 @@
}
if (mTransfer != TRANSFER_OBTAIN) {
audioBuffer->frameCount = 0;
- audioBuffer->size = 0;
+ audioBuffer->mSize = 0;
audioBuffer->raw = NULL;
if (nonContig != NULL) {
*nonContig = 0;
@@ -1231,7 +1230,7 @@
} while ((status == DEAD_OBJECT) && (tryCounter-- > 0));
audioBuffer->frameCount = buffer.mFrameCount;
- audioBuffer->size = buffer.mFrameCount * mServerFrameSize;
+ audioBuffer->mSize = buffer.mFrameCount * mServerFrameSize;
audioBuffer->raw = buffer.mRaw;
audioBuffer->sequence = oldSequence;
if (nonContig != NULL) {
@@ -1308,7 +1307,7 @@
size_t bytesRead = audioBuffer.frameCount * mFrameSize;
memcpy_by_audio_format(buffer, mFormat, audioBuffer.raw, mServerConfig.format,
- audioBuffer.size / mServerSampleSize);
+ audioBuffer.mSize / mServerSampleSize);
buffer = ((char *) buffer) + bytesRead;
userSize -= bytesRead;
read += bytesRead;
@@ -1514,15 +1513,15 @@
if (mServerConfig.format != mFormat) {
buffer = &mFormatConversionBuffer;
buffer->frameCount = audioBuffer.frameCount;
- buffer->size = buffer->frameCount * mFrameSize;
+ buffer->mSize = buffer->frameCount * mFrameSize;
buffer->sequence = audioBuffer.sequence;
memcpy_by_audio_format(buffer->raw, mFormat, audioBuffer.raw,
- mServerConfig.format, audioBuffer.size / mServerSampleSize);
+ mServerConfig.format, audioBuffer.size() / mServerSampleSize);
}
- const size_t reqSize = buffer->size;
+ const size_t reqSize = buffer->size();
const size_t readSize = callback->onMoreData(*buffer);
- buffer->size = readSize;
+ buffer->mSize = readSize;
// Validate on returned size
if (ssize_t(readSize) < 0 || readSize > reqSize) {
diff --git a/media/libaudioclient/AudioTrack.cpp b/media/libaudioclient/AudioTrack.cpp
index 4bc61f5..bceca2d 100644
--- a/media/libaudioclient/AudioTrack.cpp
+++ b/media/libaudioclient/AudioTrack.cpp
@@ -293,7 +293,7 @@
size_t onMoreData(const AudioTrack::Buffer & buffer) override {
AudioTrack::Buffer copy = buffer;
mCallback(AudioTrack::EVENT_MORE_DATA, mData, static_cast<void*>(©));
- return copy.size;
+ return copy.size();
}
void onUnderrun() override {
mCallback(AudioTrack::EVENT_UNDERRUN, mData, nullptr);
@@ -319,7 +319,7 @@
size_t onCanWriteMoreData(const AudioTrack::Buffer & buffer) override {
AudioTrack::Buffer copy = buffer;
mCallback(AudioTrack::EVENT_CAN_WRITE_MORE_DATA, mData, static_cast<void*>(©));
- return copy.size;
+ return copy.size();
}
};
}
@@ -2213,7 +2213,7 @@
}
if (mTransfer != TRANSFER_OBTAIN) {
audioBuffer->frameCount = 0;
- audioBuffer->size = 0;
+ audioBuffer->mSize = 0;
audioBuffer->raw = NULL;
if (nonContig != NULL) {
*nonContig = 0;
@@ -2305,7 +2305,7 @@
} while (((status == DEAD_OBJECT) || (status == NOT_ENOUGH_DATA)) && (tryCounter-- > 0));
audioBuffer->frameCount = buffer.mFrameCount;
- audioBuffer->size = buffer.mFrameCount * mFrameSize;
+ audioBuffer->mSize = buffer.mFrameCount * mFrameSize;
audioBuffer->raw = buffer.mRaw;
audioBuffer->sequence = oldSequence;
if (nonContig != NULL) {
@@ -2321,7 +2321,7 @@
return;
}
- size_t stepCount = audioBuffer->size / mFrameSize;
+ size_t stepCount = audioBuffer->mSize / mFrameSize;
if (stepCount == 0) {
return;
}
@@ -2401,8 +2401,8 @@
return ssize_t(err);
}
- size_t toWrite = audioBuffer.size;
- memcpy(audioBuffer.i8, buffer, toWrite);
+ size_t toWrite = audioBuffer.size();
+ memcpy(audioBuffer.raw, buffer, toWrite);
buffer = ((const char *) buffer) + toWrite;
userSize -= toWrite;
written += toWrite;
@@ -2759,11 +2759,11 @@
}
}
- size_t reqSize = audioBuffer.size;
+ size_t reqSize = audioBuffer.size();
if (mTransfer == TRANSFER_SYNC_NOTIF_CALLBACK) {
// when notifying client it can write more data, pass the total size that can be
// written in the next write() call, since it's not passed through the callback
- audioBuffer.size += nonContig;
+ audioBuffer.mSize += nonContig;
}
const size_t writtenSize = (mTransfer == TRANSFER_CALLBACK)
? callback->onMoreData(audioBuffer)
@@ -2828,7 +2828,7 @@
}
// releaseBuffer reads from audioBuffer.size
- audioBuffer.size = writtenSize;
+ audioBuffer.mSize = writtenSize;
size_t releasedFrames = writtenSize / mFrameSize;
audioBuffer.frameCount = releasedFrames;
diff --git a/media/libaudioclient/ToneGenerator.cpp b/media/libaudioclient/ToneGenerator.cpp
index cd3eacb..9b43f3c 100644
--- a/media/libaudioclient/ToneGenerator.cpp
+++ b/media/libaudioclient/ToneGenerator.cpp
@@ -1329,7 +1329,7 @@
//
// Input:
// buffer An buffer object containing a pointer which we will fill with
-// buffer.size bytes.
+// buffer.size() bytes.
//
// Output:
// The number of bytes we successfully wrote.
@@ -1337,16 +1337,16 @@
////////////////////////////////////////////////////////////////////////////////
size_t ToneGenerator::onMoreData(const AudioTrack::Buffer& buffer) {
- int16_t *lpOut = buffer.i16;
- uint32_t lNumSmp = (buffer.size / sizeof(int16_t) < UINT32_MAX) ?
- buffer.size / sizeof(int16_t) : UINT32_MAX;
- if (buffer.size == 0) return 0;
+ int16_t *lpOut = reinterpret_cast<int16_t*>(buffer.data());
+ uint32_t lNumSmp = (buffer.size() / sizeof(int16_t) < UINT32_MAX) ?
+ buffer.size() / sizeof(int16_t) : UINT32_MAX;
+ if (buffer.size() == 0) return 0;
// We will write to the entire buffer unless we are stopped, then we return
// 0 at loop end
size_t bytesWritten = lNumSmp * sizeof(int16_t);
// Clear output buffer: WaveGenerator accumulates into lpOut buffer
- memset(lpOut, 0, buffer.size);
+ memset(lpOut, 0, buffer.size());
while (lNumSmp) {
unsigned int lReqSmp = lNumSmp < mProcessSize*2 ? lNumSmp : mProcessSize;
diff --git a/media/libaudioclient/TrackPlayerBase.cpp b/media/libaudioclient/TrackPlayerBase.cpp
index 188f321..4fc1c44 100644
--- a/media/libaudioclient/TrackPlayerBase.cpp
+++ b/media/libaudioclient/TrackPlayerBase.cpp
@@ -33,11 +33,14 @@
doDestroy();
}
-void TrackPlayerBase::init(AudioTrack* pat, player_type_t playerType, audio_usage_t usage,
- audio_session_t sessionId) {
+void TrackPlayerBase::init(const sp<AudioTrack>& pat,
+ const sp<AudioTrack::IAudioTrackCallback>& callback,
+ player_type_t playerType, audio_usage_t usage,
+ audio_session_t sessionId) {
PlayerBase::init(playerType, usage, sessionId);
mAudioTrack = pat;
if (mAudioTrack != 0) {
+ mCallbackHandle = callback;
mSelfAudioDeviceCallback = new SelfAudioDeviceCallback(*this);
mAudioTrack->addAudioDeviceCallback(mSelfAudioDeviceCallback);
mAudioTrack->setPlayerIId(mPIId); // set in PlayerBase::init().
diff --git a/media/libaudioclient/fuzzer/audioflinger_fuzzer.cpp b/media/libaudioclient/fuzzer/audioflinger_fuzzer.cpp
index 7667501..036e72e 100644
--- a/media/libaudioclient/fuzzer/audioflinger_fuzzer.cpp
+++ b/media/libaudioclient/fuzzer/audioflinger_fuzzer.cpp
@@ -355,7 +355,7 @@
audioBuffer.frameCount = static_cast<size_t>(mFdp.ConsumeIntegral<uint32_t>());
record->obtainBuffer(&audioBuffer, waitCount, &nonContig);
bool blocking = false;
- record->read(audioBuffer.raw, audioBuffer.size, blocking);
+ record->read(audioBuffer.data(), audioBuffer.size(), blocking);
record->getInputFramesLost();
record->getFlags();
diff --git a/media/libaudioclient/include/media/AudioRecord.h b/media/libaudioclient/include/media/AudioRecord.h
index 3cfcbf3..faea716 100644
--- a/media/libaudioclient/include/media/AudioRecord.h
+++ b/media/libaudioclient/include/media/AudioRecord.h
@@ -40,7 +40,6 @@
struct audio_track_cblk_t;
class AudioRecordClientProxy;
-
// ----------------------------------------------------------------------------
class AudioRecord : public AudioSystem::AudioDeviceCallback
@@ -70,15 +69,21 @@
class Buffer
{
+ friend AudioRecord;
public:
- // FIXME use m prefix
+ size_t size() const { return mSize; }
+ size_t getFrameCount() const { return frameCount; }
+ uint8_t* data() const { return ui8; }
+ // Leaving public for now to assist refactoring. This class will
+ // be replaced.
size_t frameCount; // number of sample frames corresponding to size;
// on input to obtainBuffer() it is the number of frames desired
// on output from obtainBuffer() it is the number of available
// frames to be read
// on input to releaseBuffer() it is currently ignored
- size_t size; // input/output in bytes == frameCount * frameSize
+ private:
+ size_t mSize; // input/output in bytes == frameCount * frameSize
// on input to obtainBuffer() it is ignored
// on output from obtainBuffer() it is the number of available
// bytes to be read, which is frameCount * frameSize
@@ -90,7 +95,7 @@
union {
void* raw;
int16_t* i16; // signed 16-bit
- int8_t* i8; // unsigned 8-bit, offset by 0x80
+ uint8_t* ui8; // unsigned 8-bit, offset by 0x80
// input to obtainBuffer(): unused, output: pointer to buffer
};
diff --git a/media/libaudioclient/include/media/AudioTrack.h b/media/libaudioclient/include/media/AudioTrack.h
index 153d4b5..1708cc7 100644
--- a/media/libaudioclient/include/media/AudioTrack.h
+++ b/media/libaudioclient/include/media/AudioTrack.h
@@ -95,34 +95,36 @@
class Buffer
{
+ friend AudioTrack;
public:
- // FIXME use m prefix
+ size_t size() const { return mSize; }
+ size_t getFrameCount() const { return frameCount; }
+ uint8_t * data() const { return ui8; }
+ // Leaving public for now to ease refactoring. This class will be
+ // replaced
size_t frameCount; // number of sample frames corresponding to size;
// on input to obtainBuffer() it is the number of frames desired,
// on output from obtainBuffer() it is the number of available
// [empty slots for] frames to be filled
// on input to releaseBuffer() it is currently ignored
-
- size_t size; // input/output in bytes == frameCount * frameSize
+ private:
+ size_t mSize; // input/output in bytes == frameCount * frameSize
// on input to obtainBuffer() it is ignored
// on output from obtainBuffer() it is the number of available
// [empty slots for] bytes to be filled,
// which is frameCount * frameSize
// on input to releaseBuffer() it is the number of bytes to
// release
- // FIXME This is redundant with respect to frameCount. Consider
- // removing size and making frameCount the primary field.
union {
void* raw;
int16_t* i16; // signed 16-bit
- int8_t* i8; // unsigned 8-bit, offset by 0x80
+ uint8_t* ui8; // unsigned 8-bit, offset by 0x80
}; // input to obtainBuffer(): unused, output: pointer to buffer
uint32_t sequence; // IAudioTrack instance sequence number, as of obtainBuffer().
// It is set by obtainBuffer() and confirmed by releaseBuffer().
// Not "user-serviceable".
- // TODO Consider sp<IMemory> instead, or in addition to this.
};
/* As a convenience, if a callback is supplied, a handler thread
diff --git a/media/libaudioclient/include/media/TrackPlayerBase.h b/media/libaudioclient/include/media/TrackPlayerBase.h
index 80124b8..fe88116 100644
--- a/media/libaudioclient/include/media/TrackPlayerBase.h
+++ b/media/libaudioclient/include/media/TrackPlayerBase.h
@@ -28,8 +28,8 @@
explicit TrackPlayerBase();
virtual ~TrackPlayerBase();
- void init(AudioTrack* pat, player_type_t playerType, audio_usage_t usage,
- audio_session_t sessionId);
+ void init(const sp<AudioTrack>& pat, const sp<AudioTrack::IAudioTrackCallback>& callback,
+ player_type_t playerType, audio_usage_t usage, audio_session_t sessionId);
virtual void destroy();
//IPlayer implementation
@@ -66,8 +66,8 @@
// volume coming from the player volume API
float mPlayerVolumeL, mPlayerVolumeR;
-
- sp<SelfAudioDeviceCallback> mSelfAudioDeviceCallback;
+ sp<AudioTrack::IAudioTrackCallback> mCallbackHandle;
+ sp<SelfAudioDeviceCallback> mSelfAudioDeviceCallback;
};
} // namespace android
diff --git a/media/libaudiofoundation/AudioProfile.cpp b/media/libaudiofoundation/AudioProfile.cpp
index 734fa9c..2170cd8 100644
--- a/media/libaudiofoundation/AudioProfile.cpp
+++ b/media/libaudiofoundation/AudioProfile.cpp
@@ -127,16 +127,17 @@
"%*s%s\n", spaces, "", audio_encapsulation_type_to_string(mEncapsulationType)));
}
-bool AudioProfile::equals(const sp<AudioProfile>& other) const
+bool AudioProfile::equals(const sp<AudioProfile>& other, bool ignoreDynamicFlags) const
{
return other != nullptr &&
mName.compare(other->mName) == 0 &&
mFormat == other->getFormat() &&
mChannelMasks == other->getChannels() &&
mSamplingRates == other->getSampleRates() &&
- mIsDynamicFormat == other->isDynamicFormat() &&
- mIsDynamicChannels == other->isDynamicChannels() &&
- mIsDynamicRate == other->isDynamicRate() &&
+ (ignoreDynamicFlags ||
+ (mIsDynamicFormat == other->isDynamicFormat() &&
+ mIsDynamicChannels == other->isDynamicChannels() &&
+ mIsDynamicRate == other->isDynamicRate())) &&
mEncapsulationType == other->getEncapsulationType();
}
@@ -326,10 +327,10 @@
return false;
}
-bool AudioProfileVector::contains(const sp<AudioProfile>& profile) const
+bool AudioProfileVector::contains(const sp<AudioProfile>& profile, bool ignoreDynamicFlags) const
{
for (const auto& audioProfile : *this) {
- if (audioProfile->equals(profile)) {
+ if (audioProfile->equals(profile, ignoreDynamicFlags)) {
return true;
}
}
@@ -356,6 +357,14 @@
});
}
+void AudioProfileVector::addAllValidProfiles(const AudioProfileVector& audioProfiles) {
+ for (const auto& audioProfile : audioProfiles) {
+ if (audioProfile->isValid() && !contains(audioProfile, true /*ignoreDynamicFlags*/)) {
+ add(audioProfile);
+ }
+ }
+}
+
ConversionResult<AudioProfileVector>
aidl2legacy_AudioProfileVector(const AudioProfileVector::Aidl& aidl, bool isInput) {
return convertContainers<AudioProfileVector>(aidl.first, aidl.second,
diff --git a/media/libaudiofoundation/include/media/AudioProfile.h b/media/libaudiofoundation/include/media/AudioProfile.h
index c3a0fb2..79dfd12 100644
--- a/media/libaudiofoundation/include/media/AudioProfile.h
+++ b/media/libaudiofoundation/include/media/AudioProfile.h
@@ -78,7 +78,7 @@
void dump(std::string *dst, int spaces) const;
- bool equals(const sp<AudioProfile>& other) const;
+ bool equals(const sp<AudioProfile>& other, bool ignoreDynamicFlags = false) const;
using Aidl = std::pair<media::audio::common::AudioProfile, media::AudioProfileSys>;
ConversionResult<Aidl> toParcelable(bool isInput) const;
@@ -139,11 +139,12 @@
bool hasDynamicProfile() const;
bool hasDynamicRateFor(audio_format_t format) const;
- bool contains(const sp<AudioProfile>& profile) const;
+ bool contains(const sp<AudioProfile>& profile, bool ignoreDynamicFlags = false) const;
virtual void dump(std::string *dst, int spaces) const;
bool equals(const AudioProfileVector& other) const;
+ void addAllValidProfiles(const AudioProfileVector& audioProfiles);
using Aidl = std::pair<
std::vector<media::audio::common::AudioProfile>,
diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp
index 3b5e1e2..a71631a 100644
--- a/media/libmediaplayerservice/MediaPlayerService.cpp
+++ b/media/libmediaplayerservice/MediaPlayerService.cpp
@@ -2658,7 +2658,7 @@
return 0;
}
size_t actualSize = (*me->mCallback)(
- me.get(), buffer.raw, buffer.size, me->mCallbackCookie,
+ me.get(), buffer.data(), buffer.size(), me->mCallbackCookie,
CB_EVENT_FILL_BUFFER);
// Log when no data is returned from the callback.
diff --git a/media/libstagefright/AudioSource.cpp b/media/libstagefright/AudioSource.cpp
index b6acdc8..bfe8538 100644
--- a/media/libstagefright/AudioSource.cpp
+++ b/media/libstagefright/AudioSource.cpp
@@ -36,21 +36,9 @@
using content::AttributionSourceState;
-static void AudioRecordCallbackFunction(int event, void *user, void *info) {
- AudioSource *source = (AudioSource *) user;
- switch (event) {
- case AudioRecord::EVENT_MORE_DATA: {
- source->dataCallback(*((AudioRecord::Buffer *) info));
- break;
- }
- case AudioRecord::EVENT_OVERRUN: {
- ALOGW("AudioRecord reported overrun!");
- break;
- }
- default:
- // does nothing
- break;
- }
+
+void AudioSource::onOverrun() {
+ ALOGW("AudioRecord reported overrun!");
}
AudioSource::AudioSource(
@@ -129,8 +117,7 @@
audio_channel_in_mask_from_count(channelCount),
attributionSource,
(size_t) (bufCount * frameCount),
- AudioRecordCallbackFunction,
- this,
+ wp<AudioRecord::IAudioRecordCallback>{this},
frameCount /*notificationFrames*/,
AUDIO_SESSION_ALLOCATE,
AudioRecord::TRANSFER_DEFAULT,
@@ -359,7 +346,7 @@
return;
}
-status_t AudioSource::dataCallback(const AudioRecord::Buffer& audioBuffer) {
+size_t AudioSource::onMoreData(const AudioRecord::Buffer& audioBuffer) {
int64_t timeUs, position, timeNs;
ExtendedTimestamp ts;
ExtendedTimestamp::Location location;
@@ -384,21 +371,21 @@
ALOGV("dataCallbackTimestamp: %" PRId64 " us", timeUs);
Mutex::Autolock autoLock(mLock);
+
if (!mStarted) {
ALOGW("Spurious callback from AudioRecord. Drop the audio data.");
- return OK;
+ return audioBuffer.size();
}
- const size_t bufferSize = audioBuffer.size;
// Drop retrieved and previously lost audio data.
if (mNumFramesReceived == 0 && timeUs < mStartTimeUs) {
(void) mRecord->getInputFramesLost();
- int64_t receievedFrames = bufferSize / mRecord->frameSize();
+ int64_t receievedFrames = audioBuffer.size() / mRecord->frameSize();
ALOGV("Drop audio data(%" PRId64 " frames) at %" PRId64 "/%" PRId64 " us",
receievedFrames, timeUs, mStartTimeUs);
mNumFramesSkipped += receievedFrames;
- return OK;
+ return audioBuffer.size();
}
if (mStopSystemTimeUs != -1 && timeUs >= mStopSystemTimeUs) {
@@ -406,7 +393,7 @@
(long long)timeUs, (long long)mStopSystemTimeUs);
mNoMoreFramesToRead = true;
mFrameAvailableCondition.signal();
- return OK;
+ return audioBuffer.size();
}
if (mNumFramesReceived == 0 && mPrevSampleTimeUs == 0) {
@@ -427,7 +414,7 @@
}
CHECK_EQ(numLostBytes & 1, 0u);
- CHECK_EQ(audioBuffer.size & 1, 0u);
+ CHECK_EQ(audioBuffer.size() & 1, 0u);
if (numLostBytes > 0) {
// Loss of audio frames should happen rarely; thus the LOGW should
// not cause a logging spam
@@ -449,17 +436,17 @@
queueInputBuffer_l(lostAudioBuffer, timeUs);
}
- if (audioBuffer.size == 0) {
+ if (audioBuffer.size() == 0) {
ALOGW("Nothing is available from AudioRecord callback buffer");
- return OK;
+ return audioBuffer.size();
}
- MediaBuffer *buffer = new MediaBuffer(bufferSize);
+ MediaBuffer *buffer = new MediaBuffer(audioBuffer.size());
memcpy((uint8_t *) buffer->data(),
- audioBuffer.i16, audioBuffer.size);
- buffer->set_range(0, bufferSize);
+ audioBuffer.data(), audioBuffer.size());
+ buffer->set_range(0, audioBuffer.size());
queueInputBuffer_l(buffer, timeUs);
- return OK;
+ return audioBuffer.size();
}
void AudioSource::queueInputBuffer_l(MediaBuffer *buffer, int64_t timeUs) {
diff --git a/media/libstagefright/data/media_codecs_sw.xml b/media/libstagefright/data/media_codecs_sw.xml
index a4e3425..53ca4e7 100644
--- a/media/libstagefright/data/media_codecs_sw.xml
+++ b/media/libstagefright/data/media_codecs_sw.xml
@@ -91,11 +91,11 @@
<MediaCodec name="c2.android.mpeg4.decoder" type="video/mp4v-es">
<Alias name="OMX.google.mpeg4.decoder" />
<!-- profiles and levels: ProfileSimple : Level3 -->
- <Limit name="size" min="2x2" max="352x288" />
+ <Limit name="size" min="2x2" max="1920x1920" />
<Limit name="alignment" value="2x2" />
- <Limit name="block-size" value="16x16" />
- <Limit name="blocks-per-second" range="12-11880" />
- <Limit name="bitrate" range="1-384000" />
+ <Limit name="block-count" range="1-14400" />
+ <Limit name="blocks-per-second" range="1-432000" />
+ <Limit name="bitrate" range="1-40000000" />
<Feature name="adaptive-playback" />
</MediaCodec>
<MediaCodec name="c2.android.h263.decoder" type="video/3gpp">
diff --git a/media/libstagefright/include/media/stagefright/AudioSource.h b/media/libstagefright/include/media/stagefright/AudioSource.h
index 43d50f1..5e84977 100644
--- a/media/libstagefright/include/media/stagefright/AudioSource.h
+++ b/media/libstagefright/include/media/stagefright/AudioSource.h
@@ -35,7 +35,9 @@
class AudioRecord;
-struct AudioSource : public MediaSource, public MediaBufferObserver {
+struct AudioSource : public MediaSource,
+ public MediaBufferObserver,
+ public AudioRecord::IAudioRecordCallback {
// Note that the "channels" parameter _is_ the number of channels,
// _not_ a bitmask of audio_channels_t constants.
AudioSource(
@@ -74,7 +76,6 @@
MediaBufferBase **buffer, const ReadOptions *options = NULL);
virtual status_t setStopTimeUs(int64_t stopTimeUs);
- status_t dataCallback(const AudioRecord::Buffer& buffer);
virtual void signalBufferReturned(MediaBufferBase *buffer);
status_t setInputDevice(audio_port_handle_t deviceId);
@@ -142,6 +143,10 @@
void waitOutstandingEncodingFrames_l();
status_t reset();
+ // IAudioRecordCallback implementation
+ size_t onMoreData(const AudioRecord::Buffer&) override;
+ void onOverrun() override;
+
AudioSource(const AudioSource &);
AudioSource &operator=(const AudioSource &);
diff --git a/media/tests/benchmark/src/native/common/Android.bp b/media/tests/benchmark/src/native/common/Android.bp
index 718d217..7988979 100644
--- a/media/tests/benchmark/src/native/common/Android.bp
+++ b/media/tests/benchmark/src/native/common/Android.bp
@@ -94,10 +94,6 @@
"libmediabenchmark_soft_sanitize_all-defaults",
],
- include_dirs: [
- "frameworks/av/media/codec2/hidl/client/include",
- ],
-
shared_libs: [
"libcodec2_client",
"libmediandk",
diff --git a/services/Android.mk b/services/Android.mk
new file mode 100644
index 0000000..c86a226
--- /dev/null
+++ b/services/Android.mk
@@ -0,0 +1 @@
+$(eval $(call declare-1p-copy-files,frameworks/av/services/audiopolicy,))
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 479906f..eb3c164 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -105,7 +105,7 @@
namespace android {
-#define MAX_AAUDIO_PROPERTY_DEVICE_HAL_VERSION 7.0
+#define MAX_AAUDIO_PROPERTY_DEVICE_HAL_VERSION 7.1
using ::android::base::StringPrintf;
using media::IEffectClient;
@@ -2360,11 +2360,12 @@
if (mDevicesFactoryHal->getHalVersion() > MAX_AAUDIO_PROPERTY_DEVICE_HAL_VERSION) {
if (int32_t mixerBursts = dev->getAAudioMixerBurstCount();
- mixerBursts > mAAudioBurstsPerBuffer) {
+ mixerBursts > 0 && mixerBursts > mAAudioBurstsPerBuffer) {
mAAudioBurstsPerBuffer = mixerBursts;
}
if (int32_t hwBurstMinMicros = dev->getAAudioHardwareBurstMinUsec();
- hwBurstMinMicros < mAAudioHwBurstMinMicros || mAAudioHwBurstMinMicros == 0) {
+ hwBurstMinMicros > 0
+ && (hwBurstMinMicros < mAAudioHwBurstMinMicros || mAAudioHwBurstMinMicros == 0)) {
mAAudioHwBurstMinMicros = hwBurstMinMicros;
}
}
diff --git a/services/audiopolicy/common/managerdefinitions/include/AudioInputDescriptor.h b/services/audiopolicy/common/managerdefinitions/include/AudioInputDescriptor.h
index 856ae66..c26ea10 100644
--- a/services/audiopolicy/common/managerdefinitions/include/AudioInputDescriptor.h
+++ b/services/audiopolicy/common/managerdefinitions/include/AudioInputDescriptor.h
@@ -144,6 +144,7 @@
AudioPolicyClientInterface * const mClientInterface;
int32_t mGlobalActiveCount = 0; // non-client-specific activity ref count
EffectDescriptorCollection mEnabledEffects;
+ audio_input_flags_t& mFlags = AudioPortConfig::mFlags.input;
};
class AudioInputCollection :
diff --git a/services/audiopolicy/common/managerdefinitions/include/AudioOutputDescriptor.h b/services/audiopolicy/common/managerdefinitions/include/AudioOutputDescriptor.h
index 69082ac..b5373cb 100644
--- a/services/audiopolicy/common/managerdefinitions/include/AudioOutputDescriptor.h
+++ b/services/audiopolicy/common/managerdefinitions/include/AudioOutputDescriptor.h
@@ -316,6 +316,7 @@
AudioPolicyClientInterface * const mClientInterface;
uint32_t mGlobalActiveCount = 0; // non-client-specific active count
audio_patch_handle_t mPatchHandle = AUDIO_PATCH_HANDLE_NONE;
+ audio_output_flags_t& mFlags = AudioPortConfig::mFlags.output;
// The ActiveClients shows the clients that contribute to the @VolumeSource counts
// and may include upstream clients from a duplicating thread.
@@ -424,7 +425,7 @@
const sp<IOProfile> mProfile; // I/O profile this output derives from
audio_io_handle_t mIoHandle; // output handle
uint32_t mLatency; //
- audio_output_flags_t mFlags; //
+ using AudioOutputDescriptor::mFlags;
sp<SwAudioOutputDescriptor> mOutput1; // used by duplicated outputs: first output
sp<SwAudioOutputDescriptor> mOutput2; // used by duplicated outputs: second output
uint32_t mDirectOpenCount; // number of clients using this output (direct outputs only)
diff --git a/services/audiopolicy/common/managerdefinitions/src/AudioInputDescriptor.cpp b/services/audiopolicy/common/managerdefinitions/src/AudioInputDescriptor.cpp
index 966b8cb..6f71ac5 100644
--- a/services/audiopolicy/common/managerdefinitions/src/AudioInputDescriptor.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/AudioInputDescriptor.cpp
@@ -39,6 +39,7 @@
if (profile->getGains().size() > 0) {
profile->getGains()[0]->getDefaultConfig(&mGain);
}
+ mFlags = (audio_input_flags_t)profile->getFlags();
}
}
@@ -77,8 +78,7 @@
{
ALOG_ASSERT(mProfile != 0,
"toAudioPortConfig() called on input with null profile %d", mIoHandle);
- dstConfig->config_mask = AUDIO_PORT_CONFIG_SAMPLE_RATE|AUDIO_PORT_CONFIG_CHANNEL_MASK|
- AUDIO_PORT_CONFIG_FORMAT|AUDIO_PORT_CONFIG_GAIN;
+ dstConfig->config_mask = AUDIO_PORT_CONFIG_ALL;
if (srcConfig != NULL) {
dstConfig->config_mask |= srcConfig->config_mask;
}
@@ -512,8 +512,13 @@
void AudioInputDescriptor::dump(String8 *dst, int spaces, const char* extraInfo) const
{
- dst->appendFormat("Port ID: %d%s%s\n",
- getId(), extraInfo != nullptr ? "; " : "", extraInfo != nullptr ? extraInfo : "");
+ std::string flagsLiteral = toString(mFlags);
+ if (!flagsLiteral.empty()) {
+ flagsLiteral = " (" + flagsLiteral + ")";
+ }
+ dst->appendFormat("Port ID: %d; 0x%04x%s%s%s\n",
+ getId(), mFlags, flagsLiteral.c_str(),
+ extraInfo != nullptr ? "; " : "", extraInfo != nullptr ? extraInfo : "");
dst->appendFormat("%*s%s; %d; Channel mask: 0x%x\n", spaces, "",
audio_format_to_string(mFormat), mSamplingRate, mChannelMask);
dst->appendFormat("%*sDevices: %s\n", spaces, "",
diff --git a/services/audiopolicy/common/managerdefinitions/src/AudioOutputDescriptor.cpp b/services/audiopolicy/common/managerdefinitions/src/AudioOutputDescriptor.cpp
index 663c80a..9979392 100644
--- a/services/audiopolicy/common/managerdefinitions/src/AudioOutputDescriptor.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/AudioOutputDescriptor.cpp
@@ -202,8 +202,7 @@
void AudioOutputDescriptor::toAudioPortConfig(struct audio_port_config *dstConfig,
const struct audio_port_config *srcConfig) const
{
- dstConfig->config_mask = AUDIO_PORT_CONFIG_SAMPLE_RATE|AUDIO_PORT_CONFIG_CHANNEL_MASK|
- AUDIO_PORT_CONFIG_FORMAT|AUDIO_PORT_CONFIG_GAIN;
+ dstConfig->config_mask = AUDIO_PORT_CONFIG_ALL;
if (srcConfig != NULL) {
dstConfig->config_mask |= srcConfig->config_mask;
}
@@ -298,7 +297,6 @@
AudioPolicyClientInterface *clientInterface)
: AudioOutputDescriptor(profile, clientInterface),
mProfile(profile), mIoHandle(AUDIO_IO_HANDLE_NONE), mLatency(0),
- mFlags((audio_output_flags_t)0),
mOutput1(0), mOutput2(0), mDirectOpenCount(0),
mDirectClientSession(AUDIO_SESSION_NONE)
{
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index cc36c08..4bade63 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -1709,6 +1709,28 @@
}
}
+bool AudioPolicyManager::msdHasPatchesToAllDevices(const AudioDeviceTypeAddrVector& devices) {
+ DeviceVector devicesToCheck = mOutputDevicesAll.getDevicesFromDeviceTypeAddrVec(devices);
+ AudioPatchCollection msdPatches = getMsdOutputPatches();
+ for (size_t i = 0; i < msdPatches.size(); i++) {
+ const auto& patch = msdPatches[i];
+ for (size_t j = 0; j < patch->mPatch.num_sinks; ++j) {
+ const struct audio_port_config *sink = &patch->mPatch.sinks[j];
+ if (sink->type == AUDIO_PORT_TYPE_DEVICE) {
+ const auto& foundDevice = devicesToCheck.getDevice(
+ sink->ext.device.type, String8(sink->ext.device.address), AUDIO_FORMAT_DEFAULT);
+ if (foundDevice != nullptr) {
+ devicesToCheck.remove(foundDevice);
+ if (devicesToCheck.isEmpty()) {
+ return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
+}
+
audio_io_handle_t AudioPolicyManager::selectOutput(const SortedVector<audio_io_handle_t>& outputs,
audio_output_flags_t flags,
audio_format_t format,
@@ -3895,31 +3917,41 @@
}
for (const auto& hwModule : mHwModules) {
- for (const auto& curProfile : hwModule->getOutputProfiles()) {
- if (!curProfile->asAudioPort()->isDirectOutput()) {
+ // the MSD module checks for different conditions
+ if (strcmp(hwModule->getName(), AUDIO_HARDWARE_MODULE_ID_MSD) == 0) {
+ continue;
+ }
+ for (const auto& outputProfile : hwModule->getOutputProfiles()) {
+ if (!outputProfile->asAudioPort()->isDirectOutput()) {
continue;
}
- // Allow only profiles that support all the available and routed devices
- DeviceVector supportedDevices = curProfile->getSupportedDevices();
- if (supportedDevices.getDevicesFromDeviceTypeAddrVec(devices).size()
+ // allow only profiles that support all the available and routed devices
+ if (outputProfile->getSupportedDevices().getDevicesFromDeviceTypeAddrVec(devices).size()
!= devices.size()) {
continue;
}
-
- const auto audioProfiles = curProfile->asAudioPort()->getAudioProfiles();
- ALOGV("%s: found direct profile (%s) with %zu audio profiles.",
- __func__, curProfile->getTagName().c_str(), audioProfiles.size());
- for (const auto& audioProfile : audioProfiles) {
- if (audioProfile->isValid() && !audioProfilesVector.contains(audioProfile)
- // TODO - why do we have same PCM format with both dynamic and non dynamic format
- && audioProfile->isDynamicFormat()) {
- ALOGV("%s: adding audio profile with encoding (%d).",
- __func__, audioProfile->getFormat());
- audioProfilesVector.add(audioProfile);
- }
- }
+ audioProfilesVector.addAllValidProfiles(
+ outputProfile->asAudioPort()->getAudioProfiles());
}
}
+
+ // add the direct profiles from MSD if present and has audio patches to all the output(s)
+ const auto& msdModule = mHwModules.getModuleFromName(AUDIO_HARDWARE_MODULE_ID_MSD);
+ if (msdModule != nullptr) {
+ if (msdHasPatchesToAllDevices(devices)) {
+ ALOGV("%s: MSD audio patches set to all output devices.", __func__);
+ for (const auto& outputProfile : msdModule->getOutputProfiles()) {
+ if (!outputProfile->asAudioPort()->isDirectOutput()) {
+ continue;
+ }
+ audioProfilesVector.addAllValidProfiles(
+ outputProfile->asAudioPort()->getAudioProfiles());
+ }
+ } else {
+ ALOGV("%s: MSD audio patches NOT set to all output devices.", __func__);
+ }
+ }
+
return NO_ERROR;
}
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.h b/services/audiopolicy/managerdefault/AudioPolicyManager.h
index a145c70..587dd60 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.h
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.h
@@ -909,6 +909,7 @@
PatchBuilder buildMsdPatch(bool msdIsSource, const sp<DeviceDescriptor> &device) const;
status_t setMsdOutputPatches(const DeviceVector *outputDevices = nullptr);
void releaseMsdOutputPatches(const DeviceVector& devices);
+ bool msdHasPatchesToAllDevices(const AudioDeviceTypeAddrVector& devices);
// Overload of setDeviceConnectionState()
status_t setDeviceConnectionState(audio_devices_t deviceType,
@@ -1120,6 +1121,10 @@
bool isOffloadPossible(const audio_offload_info_t& offloadInfo,
bool durationIgnored = false);
+ // adds the profiles from the outputProfile to the passed audioProfilesVector
+ // without duplicating them if already present
+ void addPortProfilesToVector(sp<IOProfile> outputProfile,
+ AudioProfileVector& audioProfilesVector);
};
};
diff --git a/services/audiopolicy/service/AudioPolicyService.cpp b/services/audiopolicy/service/AudioPolicyService.cpp
index 8263ad1..61e2af6 100644
--- a/services/audiopolicy/service/AudioPolicyService.cpp
+++ b/services/audiopolicy/service/AudioPolicyService.cpp
@@ -1587,14 +1587,6 @@
spm.addSensorPrivacyListener(this);
}
-void AudioPolicyService::SensorPrivacyPolicy::registerSelfForMicrophoneOnly(int userId) {
- SensorPrivacyManager spm;
- mSensorPrivacyEnabled = spm.isIndividualSensorPrivacyEnabled(userId,
- SensorPrivacyManager::INDIVIDUAL_SENSOR_MICROPHONE);
- spm.addIndividualSensorPrivacyListener(userId,
- SensorPrivacyManager::INDIVIDUAL_SENSOR_MICROPHONE, this);
-}
-
void AudioPolicyService::SensorPrivacyPolicy::unregisterSelf() {
SensorPrivacyManager spm;
spm.removeSensorPrivacyListener(this);
@@ -1604,7 +1596,8 @@
return mSensorPrivacyEnabled;
}
-binder::Status AudioPolicyService::SensorPrivacyPolicy::onSensorPrivacyChanged(bool enabled) {
+binder::Status AudioPolicyService::SensorPrivacyPolicy::onSensorPrivacyChanged(
+ int toggleType __unused, int sensor __unused, bool enabled) {
mSensorPrivacyEnabled = enabled;
sp<AudioPolicyService> service = mService.promote();
if (service != nullptr) {
diff --git a/services/audiopolicy/service/AudioPolicyService.h b/services/audiopolicy/service/AudioPolicyService.h
index ae65a65..4944497 100644
--- a/services/audiopolicy/service/AudioPolicyService.h
+++ b/services/audiopolicy/service/AudioPolicyService.h
@@ -488,12 +488,12 @@
: mService(service) {}
void registerSelf();
- void registerSelfForMicrophoneOnly(int userId);
void unregisterSelf();
bool isSensorPrivacyEnabled();
- binder::Status onSensorPrivacyChanged(bool enabled);
+ binder::Status onSensorPrivacyChanged(int toggleType, int sensor,
+ bool enabled);
private:
wp<AudioPolicyService> mService;
diff --git a/services/audiopolicy/tests/audiopolicymanager_tests.cpp b/services/audiopolicy/tests/audiopolicymanager_tests.cpp
index 9c1adc6..551f5e9 100644
--- a/services/audiopolicy/tests/audiopolicymanager_tests.cpp
+++ b/services/audiopolicy/tests/audiopolicymanager_tests.cpp
@@ -137,6 +137,8 @@
audio_port_handle_t *portId = nullptr);
PatchCountCheck snapshotPatchCount() { return PatchCountCheck(mClient.get()); }
+ void getAudioPorts(audio_port_type_t type, audio_port_role_t role,
+ std::vector<audio_port_v7>* ports);
// Tries to find a device port. If 'foundPort' isn't nullptr,
// will generate a failure if the port hasn't been found.
bool findDevicePort(audio_port_role_t role, audio_devices_t deviceType,
@@ -255,21 +257,26 @@
ASSERT_NE(AUDIO_PORT_HANDLE_NONE, *portId);
}
-bool AudioPolicyManagerTest::findDevicePort(audio_port_role_t role,
- audio_devices_t deviceType, const std::string &address, audio_port_v7 *foundPort) {
+void AudioPolicyManagerTest::getAudioPorts(audio_port_type_t type, audio_port_role_t role,
+ std::vector<audio_port_v7>* ports) {
uint32_t numPorts = 0;
uint32_t generation1;
status_t ret;
- ret = mManager->listAudioPorts(role, AUDIO_PORT_TYPE_DEVICE, &numPorts, nullptr, &generation1);
- EXPECT_EQ(NO_ERROR, ret) << "mManager->listAudioPorts returned error";
- if (HasFailure()) return false;
+ ret = mManager->listAudioPorts(role, type, &numPorts, nullptr, &generation1);
+ ASSERT_EQ(NO_ERROR, ret) << "mManager->listAudioPorts returned error";
uint32_t generation2;
- struct audio_port_v7 ports[numPorts];
- ret = mManager->listAudioPorts(role, AUDIO_PORT_TYPE_DEVICE, &numPorts, ports, &generation2);
- EXPECT_EQ(NO_ERROR, ret) << "mManager->listAudioPorts returned error";
- EXPECT_EQ(generation1, generation2) << "Generations changed during ports retrieval";
+ ports->resize(numPorts);
+ ret = mManager->listAudioPorts(role, type, &numPorts, ports->data(), &generation2);
+ ASSERT_EQ(NO_ERROR, ret) << "mManager->listAudioPorts returned error";
+ ASSERT_EQ(generation1, generation2) << "Generations changed during ports retrieval";
+}
+
+bool AudioPolicyManagerTest::findDevicePort(audio_port_role_t role,
+ audio_devices_t deviceType, const std::string &address, audio_port_v7 *foundPort) {
+ std::vector<audio_port_v7> ports;
+ getAudioPorts(AUDIO_PORT_TYPE_DEVICE, role, &ports);
if (HasFailure()) return false;
for (const auto &port : ports) {
@@ -373,6 +380,7 @@
protected:
void SetUpManagerConfig() override;
void TearDown() override;
+ AudioProfileVector getDirectProfilesForAttributes(const audio_attributes_t& attr);
sp<DeviceDescriptor> mMsdOutputDevice;
sp<DeviceDescriptor> mMsdInputDevice;
@@ -502,6 +510,13 @@
AudioPolicyManagerTest::TearDown();
}
+AudioProfileVector AudioPolicyManagerTestMsd::getDirectProfilesForAttributes(
+ const audio_attributes_t& attr) {
+ AudioProfileVector audioProfilesVector;
+ mManager->getDirectProfilesForAttributes(&attr, audioProfilesVector);
+ return audioProfilesVector;
+}
+
TEST_P(AudioPolicyManagerTestMsd, InitSuccess) {
ASSERT_TRUE(mMsdOutputDevice);
ASSERT_TRUE(mMsdInputDevice);
@@ -642,6 +657,48 @@
ASSERT_EQ(1, patchCount.deltaFromSnapshot());
}
+TEST_P(AudioPolicyManagerTestMsd, GetDirectProfilesForAttributesWithMsd) {
+ const audio_attributes_t attr = {
+ AUDIO_CONTENT_TYPE_UNKNOWN, AUDIO_USAGE_UNKNOWN,
+ AUDIO_SOURCE_DEFAULT, AUDIO_FLAG_NONE, ""};
+
+ // count expected direct profiles for the default device
+ int countDirectProfilesPrimary = 0;
+ const auto& primary = mManager->getConfig().getHwModules()
+ .getModuleFromName(AUDIO_HARDWARE_MODULE_ID_PRIMARY);
+ for (const auto outputProfile : primary->getOutputProfiles()) {
+ if (outputProfile->asAudioPort()->isDirectOutput()) {
+ countDirectProfilesPrimary += outputProfile->asAudioPort()->getAudioProfiles().size();
+ }
+ }
+
+ // count expected direct profiles for the msd device
+ int countDirectProfilesMsd = 0;
+ const auto& msd = mManager->getConfig().getHwModules()
+ .getModuleFromName(AUDIO_HARDWARE_MODULE_ID_MSD);
+ for (const auto outputProfile : msd->getOutputProfiles()) {
+ if (outputProfile->asAudioPort()->isDirectOutput()) {
+ countDirectProfilesMsd += outputProfile->asAudioPort()->getAudioProfiles().size();
+ }
+ }
+
+ // before setting up MSD audio patches we only have the primary hal direct profiles
+ ASSERT_EQ(countDirectProfilesPrimary, getDirectProfilesForAttributes(attr).size());
+
+ DeviceVector outputDevices = mManager->getAvailableOutputDevices();
+ // Remove MSD output device to avoid patching to itself
+ outputDevices.remove(mMsdOutputDevice);
+ mManager->setMsdOutputPatches(&outputDevices);
+
+ // after setting up MSD audio patches the MSD direct profiles are added
+ ASSERT_EQ(countDirectProfilesPrimary + countDirectProfilesMsd,
+ getDirectProfilesForAttributes(attr).size());
+
+ mManager->releaseMsdOutputPatches(outputDevices);
+ // releasing the MSD audio patches gets us back to the primary hal direct profiles only
+ ASSERT_EQ(countDirectProfilesPrimary, getDirectProfilesForAttributes(attr).size());
+}
+
class AudioPolicyManagerTestWithConfigurationFile : public AudioPolicyManagerTest {
protected:
void SetUpManagerConfig() override;
@@ -671,6 +728,44 @@
dumpToLog();
}
+TEST_F(AudioPolicyManagerTestWithConfigurationFile, ListAudioPortsHasFlags) {
+ // Create an input for VOIP TX because it's not opened automatically like outputs are.
+ audio_port_handle_t selectedDeviceId = AUDIO_PORT_HANDLE_NONE;
+ audio_port_handle_t mixPortId = AUDIO_PORT_HANDLE_NONE;
+ audio_source_t source = AUDIO_SOURCE_VOICE_COMMUNICATION;
+ audio_attributes_t attr = {
+ AUDIO_CONTENT_TYPE_UNKNOWN, AUDIO_USAGE_UNKNOWN, source, AUDIO_FLAG_NONE, ""};
+ ASSERT_NO_FATAL_FAILURE(getInputForAttr(attr, 1, &selectedDeviceId, AUDIO_FORMAT_PCM_16_BIT,
+ AUDIO_CHANNEL_IN_MONO, 8000, AUDIO_INPUT_FLAG_VOIP_TX, &mixPortId));
+
+ std::vector<audio_port_v7> ports;
+ ASSERT_NO_FATAL_FAILURE(
+ getAudioPorts(AUDIO_PORT_TYPE_MIX, AUDIO_PORT_ROLE_NONE, &ports));
+ EXPECT_NE(0, ports.size());
+ bool hasFlags = false, foundPrimary = false, foundVoipRx = false, foundVoipTx = false;
+ for (const auto& port : ports) {
+ if ((port.active_config.config_mask & AUDIO_PORT_CONFIG_FLAGS) != 0) {
+ hasFlags = true;
+ if (port.role == AUDIO_PORT_ROLE_SOURCE) {
+ if ((port.active_config.flags.output & AUDIO_OUTPUT_FLAG_PRIMARY) != 0) {
+ foundPrimary = true;
+ }
+ if ((port.active_config.flags.output & AUDIO_OUTPUT_FLAG_VOIP_RX) != 0) {
+ foundVoipRx = true;
+ }
+ } else if (port.role == AUDIO_PORT_ROLE_SINK) {
+ if ((port.active_config.flags.input & AUDIO_INPUT_FLAG_VOIP_TX) != 0) {
+ foundVoipTx = true;
+ }
+ }
+ }
+ }
+ EXPECT_TRUE(hasFlags);
+ EXPECT_TRUE(foundPrimary);
+ EXPECT_TRUE(foundVoipRx);
+ EXPECT_TRUE(foundVoipTx);
+}
+
using PolicyMixTuple = std::tuple<audio_usage_t, audio_source_t, uint32_t>;
class AudioPolicyManagerTestDynamicPolicy : public AudioPolicyManagerTestWithConfigurationFile {
diff --git a/services/audiopolicy/tests/resources/test_audio_policy_configuration.xml b/services/audiopolicy/tests/resources/test_audio_policy_configuration.xml
index 41ed70c..5e1822a 100644
--- a/services/audiopolicy/tests/resources/test_audio_policy_configuration.xml
+++ b/services/audiopolicy/tests/resources/test_audio_policy_configuration.xml
@@ -14,7 +14,7 @@
limitations under the License.
-->
-<audioPolicyConfiguration version="1.0" xmlns:xi="http://www.w3.org/2001/XInclude">
+<audioPolicyConfiguration version="7.0" xmlns:xi="http://www.w3.org/2001/XInclude">
<globalConfiguration speaker_drc_enabled="true"/>
<modules>
@@ -41,8 +41,18 @@
</mixPort>
<mixPort name="mixport_bt_hfp_input" role="sink">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
- samplingRates="8000,11025,16000,44100,48000"
- channelMasks="AUDIO_CHANNEL_IN_STEREO,AUDIO_CHANNEL_IN_MONO"/>
+ samplingRates="8000 11025 16000 44100 48000"
+ channelMasks="AUDIO_CHANNEL_IN_STEREO AUDIO_CHANNEL_IN_MONO"/>
+ </mixPort>
+ <mixPort name="voip_tx" role="sink"
+ flags="AUDIO_INPUT_FLAG_VOIP_TX">
+ <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
+ samplingRates="8000 16000 32000 48000" channelMasks="AUDIO_CHANNEL_IN_MONO"/>
+ </mixPort>
+ <mixPort name="voip_rx" role="source"
+ flags="AUDIO_OUTPUT_FLAG_VOIP_RX">
+ <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
+ samplingRates="8000 16000 32000 48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
</mixPort>
</mixPorts>
<devicePorts>
@@ -64,13 +74,15 @@
</devicePorts>
<routes>
<route type="mix" sink="Speaker"
- sources="primary output"/>
+ sources="primary output,voip_rx"/>
<route type="mix" sink="primary input"
sources="Built-In Mic,Hdmi-In Mic"/>
+ <route type="mix" sink="voip_tx"
+ sources="Built-In Mic"/>
<route type="mix" sink="Hdmi"
sources="primary output"/>
<route type="mix" sink="BT SCO"
- sources="mixport_bt_hfp_output"/>
+ sources="mixport_bt_hfp_output,voip_rx"/>
<route type="mix" sink="mixport_bt_hfp_input"
sources="BT SCO Headset Mic"/>
</routes>
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index 271cfec..0ba1b28 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -1895,7 +1895,7 @@
// Set camera muting behavior
bool isCameraPrivacyEnabled =
- mSensorPrivacyPolicy->isCameraPrivacyEnabled(multiuser_get_user_id(clientUid));
+ mSensorPrivacyPolicy->isCameraPrivacyEnabled();
if (client->supportsCameraMute()) {
client->setCameraMute(
mOverrideCameraMuteMode || isCameraPrivacyEnabled);
@@ -3404,8 +3404,7 @@
bool isUidActive = sCameraService->mUidPolicy->isUidActive(mClientUid,
mClientPackageName);
bool isCameraPrivacyEnabled =
- sCameraService->mSensorPrivacyPolicy->isCameraPrivacyEnabled(
- multiuser_get_user_id(mClientUid));
+ sCameraService->mSensorPrivacyPolicy->isCameraPrivacyEnabled();
if (!isUidActive || !isCameraPrivacyEnabled) {
ALOGI("Camera %s: Access for \"%s\" has been restricted",
mCameraIdStr.string(), String8(mClientPackageName).string());
@@ -3587,8 +3586,7 @@
} else if (res == AppOpsManager::MODE_IGNORED) {
bool isUidActive = sCameraService->mUidPolicy->isUidActive(mClientUid, mClientPackageName);
bool isCameraPrivacyEnabled =
- sCameraService->mSensorPrivacyPolicy->isCameraPrivacyEnabled(
- multiuser_get_user_id(mClientUid));
+ sCameraService->mSensorPrivacyPolicy->isCameraPrivacyEnabled();
ALOGI("Camera %s: Access for \"%s\" has been restricted, isUidTrusted %d, isUidActive %d",
mCameraIdStr.string(), String8(mClientPackageName).string(),
mUidIsTrusted, isUidActive);
@@ -3900,18 +3898,18 @@
return mSensorPrivacyEnabled;
}
-bool CameraService::SensorPrivacyPolicy::isCameraPrivacyEnabled(userid_t userId) {
+bool CameraService::SensorPrivacyPolicy::isCameraPrivacyEnabled() {
if (!hasCameraPrivacyFeature()) {
return false;
}
- return mSpm.isIndividualSensorPrivacyEnabled(userId,
- SensorPrivacyManager::INDIVIDUAL_SENSOR_CAMERA);
+ return mSpm.isToggleSensorPrivacyEnabled(SensorPrivacyManager::TOGGLE_SENSOR_CAMERA);
}
-binder::Status CameraService::SensorPrivacyPolicy::onSensorPrivacyChanged(bool enabled) {
+binder::Status CameraService::SensorPrivacyPolicy::onSensorPrivacyChanged(
+ int toggleType __unused, int sensor __unused, bool enabled) {
{
Mutex::Autolock _l(mSensorPrivacyLock);
- mSensorPrivacyEnabled = enabled;
+ mSensorPrivacyEnabled = mSpm.isToggleSensorPrivacyEnabled(SensorPrivacyManager::TOGGLE_SENSOR_CAMERA);
}
// if sensor privacy is enabled then block all clients from accessing the camera
if (enabled) {
@@ -3930,7 +3928,11 @@
}
bool CameraService::SensorPrivacyPolicy::hasCameraPrivacyFeature() {
- return mSpm.supportsSensorToggle(SensorPrivacyManager::INDIVIDUAL_SENSOR_CAMERA);
+ bool supportsSoftwareToggle = mSpm.supportsSensorToggle(
+ SensorPrivacyManager::TOGGLE_TYPE_SOFTWARE, SensorPrivacyManager::TOGGLE_SENSOR_CAMERA);
+ bool supportsHardwareToggle = mSpm.supportsSensorToggle(
+ SensorPrivacyManager::TOGGLE_TYPE_HARDWARE, SensorPrivacyManager::TOGGLE_SENSOR_CAMERA);
+ return supportsSoftwareToggle || supportsHardwareToggle;
}
// ----------------------------------------------------------------------------
diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h
index 95d5101..6346f50 100644
--- a/services/camera/libcameraservice/CameraService.h
+++ b/services/camera/libcameraservice/CameraService.h
@@ -739,9 +739,10 @@
void unregisterSelf();
bool isSensorPrivacyEnabled();
- bool isCameraPrivacyEnabled(userid_t userId);
+ bool isCameraPrivacyEnabled();
- binder::Status onSensorPrivacyChanged(bool enabled);
+ binder::Status onSensorPrivacyChanged(int toggleType, int sensor,
+ bool enabled);
// IBinder::DeathRecipient implementation
virtual void binderDied(const wp<IBinder> &who);
diff --git a/services/camera/libcameraservice/api2/CameraDeviceClient.cpp b/services/camera/libcameraservice/api2/CameraDeviceClient.cpp
index 223935d..1020c13 100644
--- a/services/camera/libcameraservice/api2/CameraDeviceClient.cpp
+++ b/services/camera/libcameraservice/api2/CameraDeviceClient.cpp
@@ -2004,13 +2004,15 @@
nsecs_t startTime = systemTime();
ALOGV("Camera %s: Stopping processors", mCameraIdStr.string());
- mFrameProcessor->removeListener(camera2::FrameProcessorBase::FRAME_PROCESSOR_LISTENER_MIN_ID,
- camera2::FrameProcessorBase::FRAME_PROCESSOR_LISTENER_MAX_ID,
- /*listener*/this);
- mFrameProcessor->requestExit();
- ALOGV("Camera %s: Waiting for threads", mCameraIdStr.string());
- mFrameProcessor->join();
- ALOGV("Camera %s: Disconnecting device", mCameraIdStr.string());
+ if (mFrameProcessor.get() != nullptr) {
+ mFrameProcessor->removeListener(
+ camera2::FrameProcessorBase::FRAME_PROCESSOR_LISTENER_MIN_ID,
+ camera2::FrameProcessorBase::FRAME_PROCESSOR_LISTENER_MAX_ID, /*listener*/this);
+ mFrameProcessor->requestExit();
+ ALOGV("Camera %s: Waiting for threads", mCameraIdStr.string());
+ mFrameProcessor->join();
+ ALOGV("Camera %s: Disconnecting device", mCameraIdStr.string());
+ }
// WORKAROUND: HAL refuses to disconnect while there's streams in flight
{
diff --git a/services/camera/libcameraservice/device3/aidl/AidlCamera3Device.cpp b/services/camera/libcameraservice/device3/aidl/AidlCamera3Device.cpp
index 9ace0f9..452c9f9 100644
--- a/services/camera/libcameraservice/device3/aidl/AidlCamera3Device.cpp
+++ b/services/camera/libcameraservice/device3/aidl/AidlCamera3Device.cpp
@@ -734,7 +734,11 @@
ATRACE_NAME("AidlCameraHal::repeatingRequestEnd");
if (!valid()) return INVALID_OPERATION;
- mAidlSession->repeatingRequestEnd(frameNumber, streamIds);
+ auto err = mAidlSession->repeatingRequestEnd(frameNumber, streamIds);
+ if (!err.isOk()) {
+ ALOGE("%s: Transaction error: %s", __FUNCTION__, err.getMessage());
+ return AidlProviderInfo::mapToStatusT(err);
+ }
return OK;
}