Merge "Codec2: add argument for C2Buffer::unregisterNotify"
diff --git a/media/libstagefright/codec2/include/C2Buffer.h b/media/libstagefright/codec2/include/C2Buffer.h
index 020fa09..9580449 100644
--- a/media/libstagefright/codec2/include/C2Buffer.h
+++ b/media/libstagefright/codec2/include/C2Buffer.h
@@ -1236,7 +1236,7 @@
* \retval C2_NOT_FOUND the notification was not found
* \retval C2_CORRUPTED an unknown error prevented the registration (unexpected)
*/
- C2Error unregisterOnDestroyNotify(OnDestroyNotify onDestroyNotify);
+ C2Error unregisterOnDestroyNotify(OnDestroyNotify onDestroyNotify, void *arg = nullptr);
///@}
diff --git a/media/libstagefright/codec2/tests/vndk/C2BufferTest.cpp b/media/libstagefright/codec2/tests/vndk/C2BufferTest.cpp
index 97c4a7d..18d0841 100644
--- a/media/libstagefright/codec2/tests/vndk/C2BufferTest.cpp
+++ b/media/libstagefright/codec2/tests/vndk/C2BufferTest.cpp
@@ -475,9 +475,10 @@
destroyed = false;
ASSERT_EQ(C2_OK, buffer->registerOnDestroyNotify(&DestroyCallback, &arg));
EXPECT_FALSE(destroyed);
- ASSERT_EQ(C2_OK, buffer->unregisterOnDestroyNotify(&DestroyCallback));
+ ASSERT_EQ(C2_NOT_FOUND, buffer->unregisterOnDestroyNotify(&DestroyCallback, nullptr));
+ ASSERT_EQ(C2_OK, buffer->unregisterOnDestroyNotify(&DestroyCallback, &arg));
EXPECT_FALSE(destroyed);
- ASSERT_EQ(C2_NOT_FOUND, buffer->unregisterOnDestroyNotify(&DestroyCallback));
+ ASSERT_EQ(C2_NOT_FOUND, buffer->unregisterOnDestroyNotify(&DestroyCallback, &arg));
buffer.reset();
EXPECT_FALSE(destroyed);
diff --git a/media/libstagefright/codec2/vndk/C2Buffer.cpp b/media/libstagefright/codec2/vndk/C2Buffer.cpp
index 1a0b55c..92ccfd1 100644
--- a/media/libstagefright/codec2/vndk/C2Buffer.cpp
+++ b/media/libstagefright/codec2/vndk/C2Buffer.cpp
@@ -1344,7 +1344,7 @@
const C2BufferData &data() const { return mData; }
- C2Error registerOnDestroyNotify(OnDestroyNotify onDestroyNotify, void *arg = nullptr) {
+ C2Error registerOnDestroyNotify(OnDestroyNotify onDestroyNotify, void *arg) {
auto it = std::find_if(
mNotify.begin(), mNotify.end(),
[onDestroyNotify, arg] (const auto &pair) {
@@ -1357,11 +1357,11 @@
return C2_OK;
}
- C2Error unregisterOnDestroyNotify(OnDestroyNotify onDestroyNotify) {
+ C2Error unregisterOnDestroyNotify(OnDestroyNotify onDestroyNotify, void *arg) {
auto it = std::find_if(
mNotify.begin(), mNotify.end(),
- [onDestroyNotify] (const auto &pair) {
- return pair.first == onDestroyNotify;
+ [onDestroyNotify, arg] (const auto &pair) {
+ return pair.first == onDestroyNotify && pair.second == arg;
});
if (it == mNotify.end()) {
return C2_NOT_FOUND;
@@ -1418,8 +1418,8 @@
return mImpl->registerOnDestroyNotify(onDestroyNotify, arg);
}
-C2Error C2Buffer::unregisterOnDestroyNotify(OnDestroyNotify onDestroyNotify) {
- return mImpl->unregisterOnDestroyNotify(onDestroyNotify);
+C2Error C2Buffer::unregisterOnDestroyNotify(OnDestroyNotify onDestroyNotify, void *arg) {
+ return mImpl->unregisterOnDestroyNotify(onDestroyNotify, arg);
}
const std::list<std::shared_ptr<const C2Info>> C2Buffer::infos() const {