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

Commit 22df0f21 authored by Linus Nilsson's avatar Linus Nilsson
Browse files

Transcoder: Name transcoder threads for easier trace identification.

Bug: 183751395
Test: build_and_run_all_unit_tests.sh
Change-Id: I7b210d876584e3864540ba9991ed0e2a2de048e6
parent 0c465cf0
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include <android-base/logging.h>
#include <media/MediaSampleWriter.h>
#include <media/NdkMediaMuxer.h>
#include <sys/prctl.h>

namespace android {

@@ -173,6 +174,8 @@ bool MediaSampleWriter::start() {

    mState = STARTED;
    std::thread([this] {
        prctl(PR_SET_NAME, (unsigned long)"SampleWriterTrd", 0, 0, 0);

        bool wasStopped = false;
        media_status_t status = writeSamples(&wasStopped);
        if (auto callbacks = mCallbacks.lock()) {
+3 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
#include <media/NdkCommon.h>
#include <media/PassthroughTrackTranscoder.h>
#include <media/VideoTrackTranscoder.h>
#include <sys/prctl.h>
#include <unistd.h>

namespace android {
@@ -125,6 +126,8 @@ void MediaTranscoder::onThreadFinished(const void* thread, media_status_t thread
        std::thread asyncNotificationThread{[this, self = shared_from_this(),
                                             status = mTranscoderStatus,
                                             stopped = mTranscoderStopped] {
            prctl(PR_SET_NAME, (unsigned long)"TranscodCallbk", 0, 0, 0);

            // If the transcoder was stopped that means a caller is waiting in stop or pause
            // in which case we don't send a callback.
            if (status != AMEDIA_OK) {
+3 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@

#include <android-base/logging.h>
#include <media/PassthroughTrackTranscoder.h>
#include <sys/prctl.h>

namespace android {

@@ -94,6 +95,8 @@ media_status_t PassthroughTrackTranscoder::configureDestinationFormat(
}

media_status_t PassthroughTrackTranscoder::runTranscodeLoop(bool* stopped) {
    prctl(PR_SET_NAME, (unsigned long)"PassthruThread", 0, 0, 0);

    MediaSampleInfo info;
    std::shared_ptr<MediaSample> sample;
    bool eosReached = false;
+3 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#include <android-base/properties.h>
#include <media/NdkCommon.h>
#include <media/VideoTrackTranscoder.h>
#include <sys/prctl.h>

using namespace AMediaFormatUtils;

@@ -588,6 +589,8 @@ void VideoTrackTranscoder::updateTrackFormat(AMediaFormat* outputFormat, bool fr
}

media_status_t VideoTrackTranscoder::runTranscodeLoop(bool* stopped) {
    prctl(PR_SET_NAME, (unsigned long)"VideTranscodTrd", 0, 0, 0);

    // Push start decoder and encoder as two messages, so that these are subject to the
    // stop request as well. If the session is cancelled (or paused) immediately after start,
    // we don't need to waste time start then stop the codecs.