Merge "aaudio: fix mmap result checking" into oc-dev
diff --git a/media/libaaudio/src/core/AudioStream.cpp b/media/libaaudio/src/core/AudioStream.cpp
index 9690848..598fbaa 100644
--- a/media/libaaudio/src/core/AudioStream.cpp
+++ b/media/libaaudio/src/core/AudioStream.cpp
@@ -52,6 +52,7 @@
mDataCallbackProc = builder.getDataCallbackProc();
mErrorCallbackProc = builder.getErrorCallbackProc();
mDataCallbackUserData = builder.getDataCallbackUserData();
+ mErrorCallbackUserData = builder.getErrorCallbackUserData();
// This is very helpful for debugging in the future.
ALOGI("AudioStream.open(): rate = %d, channels = %d, format = %d, sharing = %d",
diff --git a/media/libstagefright/SurfaceUtils.cpp b/media/libstagefright/SurfaceUtils.cpp
index b6b315d..b7c1598 100644
--- a/media/libstagefright/SurfaceUtils.cpp
+++ b/media/libstagefright/SurfaceUtils.cpp
@@ -91,9 +91,19 @@
return err;
}
- // Check if the ANativeWindow uses hardware protected buffers.
- if (queuesToNativeWindow != 1 && !(consumerUsage & GRALLOC_USAGE_PROTECTED)) {
- ALOGE("native window could not be authenticated");
+ // Check if the consumer end of the ANativeWindow can handle protected content.
+ int isConsumerProtected = 0;
+ err = nativeWindow->query(
+ nativeWindow, NATIVE_WINDOW_CONSUMER_IS_PROTECTED, &isConsumerProtected);
+ if (err != NO_ERROR) {
+ ALOGE("error query native window: %s (%d)", strerror(-err), -err);
+ return err;
+ }
+
+ // Deny queuing into native window if neither condition is satisfied.
+ if (queuesToNativeWindow != 1 && isConsumerProtected != 1) {
+ ALOGE("native window cannot handle protected buffers: the consumer should either be "
+ "a hardware composer or support hardware protection");
return PERMISSION_DENIED;
}
}