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

Commit 58c938ee authored by Steven Moreland's avatar Steven Moreland
Browse files

mediatranscoding: avoid double-ownership in test

SharedRefBase subclasses have an internal weak_ptr and AIDL code
promotes it internally. No error was seen from this, but because
SharedRefBase is being converted to be based on enable_shared_from_this,
this was causing compilation errors.

Bug: 194905504
Test: ./build_and_run_all_unit_tests.sh had some cases fail before and
  it fails now
Change-Id: I3dd5ad0feb9ed020073808c32fa1c5689a29e1b2
parent b6a99c1f
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -259,9 +259,7 @@ std::ostream& operator<<(std::ostream& str, const EventTracker::Event& v) {
static constexpr bool success = true;
static constexpr bool fail = false;

struct TestClientCallback : public BnTranscodingClientCallback,
                            public EventTracker,
                            public std::enable_shared_from_this<TestClientCallback> {
struct TestClientCallback : public BnTranscodingClientCallback, public EventTracker {
    TestClientCallback(const char* packageName, int32_t id)
          : mClientId(id), mClientPid(PID(id)), mClientUid(UID(id)), mPackageName(packageName) {
        ALOGI("TestClientCallback %d created: pid %d, uid %d", id, PID(id), UID(id));
@@ -348,8 +346,8 @@ struct TestClientCallback : public BnTranscodingClientCallback,
        ALOGD("registering %s with uid %d", packageName, mClientUid);

        std::shared_ptr<ITranscodingClient> client;
        Status status =
                service->registerClient(shared_from_this(), kClientName, packageName, &client);
        Status status = service->registerClient(ref<TestClientCallback>(), kClientName, packageName,
                                                &client);

        mClient = status.isOk() ? client : nullptr;
        return status;