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

Commit 51207514 authored by Jiyong Park's avatar Jiyong Park
Browse files

unique_fd is passed by value in AIDL interfaces

FileDescriptor type in AIDL was translated into const unique_fd& in C++.
Now, it is unique_fd, i.e. passed by value, to make it easier to keep it
beyond the scope of the call.

Bug: 144943748
Test: m
Change-Id: Ic6b1a4cba71c0fedb206b5ca3fb65b9944bbd69f
parent fa12f52b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -418,7 +418,7 @@ void NuPlayer::GenericSource::onPrepareAsync() {
                    sp<IMediaExtractorService> mediaExService(
                            interface_cast<IMediaExtractorService>(binder));
                    sp<IDataSource> source;
                    mediaExService->makeIDataSource(mFd, mOffset, mLength, &source);
                    mediaExService->makeIDataSource(base::unique_fd(dup(mFd.get())), mOffset, mLength, &source);
                    ALOGV("IDataSource(FileSource): %p %d %lld %lld",
                            source.get(), mFd.get(), (long long)mOffset, (long long)mLength);
                    if (source.get() != nullptr) {
+2 −4
Original line number Diff line number Diff line
@@ -61,13 +61,11 @@ MediaExtractorService::~MediaExtractorService() {
}

::android::binder::Status MediaExtractorService::makeIDataSource(
        const base::unique_fd &fd,
        base::unique_fd fd,
        int64_t offset,
        int64_t length,
        ::android::sp<::android::IDataSource>* _aidl_return) {
    // the caller will close the fd owned by the unique_fd upon return of this function,
    // so we need to dup() it to retain it.
    sp<DataSource> source = DataSourceFactory::getInstance()->CreateFromFd(dup(fd.get()), offset, length);
    sp<DataSource> source = DataSourceFactory::getInstance()->CreateFromFd(fd.release(), offset, length);
    *_aidl_return = CreateIDataSourceFromDataSource(source);
    return binder::Status::ok();
}
+1 −1
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ public:
            ::android::sp<::android::IMediaExtractor>* _aidl_return);

    virtual ::android::binder::Status makeIDataSource(
            const base::unique_fd &fd,
            base::unique_fd fd,
            int64_t offset,
            int64_t length,
            ::android::sp<::android::IDataSource>* _aidl_return);