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

Commit 628baafe authored by Chong Zhang's avatar Chong Zhang
Browse files

trancoding: lazy-start transcoding service

bug: 186387244
test: atest MediaTranscodeManagerTest; unit tests
Change-Id: I80bb476abf919b908ac9b79c32b09bdc90876cf0
parent 24ea4949
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -8,4 +8,5 @@ service media.transcoding /apex/com.android.media/bin/mediatranscoding
    ioprio rt 4
    # Restrict to little cores only with system-background cpuset.
    writepid /dev/cpuset/system-background/tasks
    interface aidl media.transcoding
    disabled
+0 −6
Original line number Diff line number Diff line
@@ -7,9 +7,3 @@ service media /system/bin/mediaserver
    group audio camera inet net_bt net_bt_admin net_bw_acct drmrpc mediadrm
    ioprio rt 4
    task_profiles ProcessCapacityHigh HighPerformance

# media.transcoding service is defined on com.android.media apex which goes back
# to API29, but we only want it started on API31+ devices. So we declare it as
# "disabled" and start it explicitly on boot.
on boot
    start media.transcoding
+4 −4
Original line number Diff line number Diff line
@@ -131,10 +131,10 @@ binder_status_t MediaTranscodingService::dump(int fd, const char** /*args*/, uin
void MediaTranscodingService::instantiate() {
    std::shared_ptr<MediaTranscodingService> service =
            ::ndk::SharedRefBase::make<MediaTranscodingService>();
    binder_status_t status =
            AServiceManager_addService(service->asBinder().get(), getServiceName());
    if (status != STATUS_OK) {
        return;
    if (__builtin_available(android __TRANSCODING_MIN_API__, *)) {
        // Once service is started, we want it to stay even is client side perished.
        AServiceManager_forceLazyServicesPersist(true /*persist*/);
        (void)AServiceManager_registerLazyService(service->asBinder().get(), getServiceName());
    }
}

+1 −1
Original line number Diff line number Diff line
@@ -481,7 +481,7 @@ public:
        // Need thread pool to receive callbacks, otherwise oneway callbacks are
        // silently ignored.
        ABinderProcess_startThreadPool();
        ::ndk::SpAIBinder binder(AServiceManager_getService("media.transcoding"));
        ::ndk::SpAIBinder binder(AServiceManager_waitForService("media.transcoding"));
        mService = IMediaTranscodingService::fromBinder(binder);
        if (mService == nullptr) {
            ALOGE("Failed to connect to the media.trascoding service.");