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

Commit 5439c7da authored by Ray Essick's avatar Ray Essick
Browse files

Change worker thread name for easier debugging

Apply stylistic changes to some function names

Bug: 260950919
Bug: 199822700
Test: 'ps -A -T' on updated system
Change-Id: I1ddf3f8643cd062b4f317c247d7e9761c8f7c8be
parent 57f8d983
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -102,7 +102,12 @@ static std::list<sp<DataSource>> pending;
static std::mutex pending_mutex;
static std::condition_variable pending_added;

static void* closing_thread_func(void *arg) {
static void* closingThreadWorker(void *arg) {
    // simplifies debugging to name the thread
    if (pthread_setname_np(pthread_self(), "mediaCloser")) {
        ALOGW("Failed to set thread name on thread for closing data sources");
    }

    while (true) {
        sp<DataSource> ds = nullptr;
        std::unique_lock _lk(pending_mutex);
@@ -124,7 +129,7 @@ static void* closing_thread_func(void *arg) {

// this can be '&ds' as long as the pending.push_back() bumps the
// reference counts to ensure the object lives long enough
static void start_close_thread(sp<DataSource> &ds) {
static void asyncDataSourceClose(sp<DataSource> &ds) {

    // make sure we have our (single) worker thread
    static std::once_flag sCheckOnce;
@@ -132,7 +137,7 @@ static void start_close_thread(sp<DataSource> &ds) {
        pthread_attr_t attr;
        pthread_attr_init(&attr);
        pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
        pthread_create(&myThread, &attr, closing_thread_func, nullptr);
        pthread_create(&myThread, &attr, closingThreadWorker, nullptr);
        pthread_attr_destroy(&attr);
    });

@@ -149,7 +154,7 @@ RemoteMediaExtractor::~RemoteMediaExtractor() {
    int8_t new_scheme = property_get_bool("debug.mediaextractor.delayedclose", 1);
    if (new_scheme != 0) {
        ALOGV("deferred close()");
        start_close_thread(mSource);
        asyncDataSourceClose(mSource);
        mSource.clear();
    } else {
        ALOGV("immediate close()");