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

Commit 320f7d2c authored by Andy Hung's avatar Andy Hung
Browse files

AudioFlinger: move pthread_mutex_timedlock into audio_utils::mutex

Using a class method avoids external usage of
audio_utils::mutex native_handle().

Test: adb shell dumpsys media.audio_flinger
Bug: 307398860
Change-Id: If131279a6f14249d2058254a3c331adfcdc9b25a
parent b2cb48a6
Loading
Loading
Loading
Loading
+1 −8
Original line number Original line Diff line number Diff line
@@ -19,7 +19,6 @@


#include <audio_utils/mutex.h>
#include <audio_utils/mutex.h>
#include <utils/Mutex.h>
#include <utils/Mutex.h>
#include <utils/Timers.h>


namespace android::afutils {
namespace android::afutils {


@@ -36,13 +35,7 @@ inline bool dumpTryLock(Mutex& mutex)
inline bool dumpTryLock(audio_utils::mutex& mutex) TRY_ACQUIRE(true, mutex)
inline bool dumpTryLock(audio_utils::mutex& mutex) TRY_ACQUIRE(true, mutex)
{
{
    static constexpr int64_t kDumpLockTimeoutNs = 1'000'000'000;
    static constexpr int64_t kDumpLockTimeoutNs = 1'000'000'000;

    return mutex.try_lock(kDumpLockTimeoutNs);
    const int64_t timeoutNs = kDumpLockTimeoutNs + systemTime(SYSTEM_TIME_REALTIME);
    const struct timespec ts = {
        .tv_sec = static_cast<time_t>(timeoutNs / 1000000000),
        .tv_nsec = static_cast<long>(timeoutNs % 1000000000),
    };
    return pthread_mutex_timedlock(mutex.native_handle(), &ts) == 0;
}
}


}  // android::afutils
}  // android::afutils