Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3d762515 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Codec2: add argument for C2Buffer::unregisterNotify"

parents f1cb8fa8 084f8e11
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1236,7 +1236,7 @@ public:
     * \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);

    ///@}

+3 −2
Original line number Diff line number Diff line
@@ -475,9 +475,10 @@ TEST_F(C2BufferTest, BufferTest) {
    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);

+6 −6
Original line number Diff line number Diff line
@@ -1344,7 +1344,7 @@ public:

    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 @@ public:
        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 @@ C2Error C2Buffer::registerOnDestroyNotify(OnDestroyNotify onDestroyNotify, void
    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 {