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

Commit 116687f5 authored by Andy Hung's avatar Andy Hung
Browse files

GenericSource: close unused file descriptor

Test: dumpsys media.player with photos, ringtone
Bug: 37792834
Change-Id: I04e0f05ea642e3bfe5e6af12bfabea69838716b4
parent abbb6772
Loading
Loading
Loading
Loading
+8 −1
Original line number Original line Diff line number Diff line
@@ -379,6 +379,11 @@ void NuPlayer::GenericSource::onPrepareAsync() {
                            source.get(), mFd, (long long)mOffset, (long long)mLength);
                            source.get(), mFd, (long long)mOffset, (long long)mLength);
                    if (source.get() != nullptr) {
                    if (source.get() != nullptr) {
                        mDataSource = DataSource::CreateFromIDataSource(source);
                        mDataSource = DataSource::CreateFromIDataSource(source);
                        if (mDataSource != nullptr) {
                            // Close the local file descriptor as it is not needed anymore.
                            close(mFd);
                            mFd = -1;
                        }
                    } else {
                    } else {
                        ALOGW("extractor service cannot make data source");
                        ALOGW("extractor service cannot make data source");
                    }
                    }
@@ -390,7 +395,9 @@ void NuPlayer::GenericSource::onPrepareAsync() {
                ALOGD("FileSource local");
                ALOGD("FileSource local");
                mDataSource = new FileSource(mFd, mOffset, mLength);
                mDataSource = new FileSource(mFd, mOffset, mLength);
            }
            }

            // TODO: close should always be done on mFd, see the lines following
            // DataSource::CreateFromIDataSource above,
            // and the FileSource constructor should dup the mFd argument as needed.
            mFd = -1;
            mFd = -1;
        }
        }