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

Commit fbe308d4 authored by Marco Nelissen's avatar Marco Nelissen Committed by Android (Google) Code Review
Browse files

Merge "Make mediascanner use filedescriptors instead of paths"

parents 25736fd2 a28976b0
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -18,6 +18,10 @@
#define LOG_TAG "StagefrightMediaScanner"
#include <utils/Log.h>

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#include <media/stagefright/StagefrightMediaScanner.h>

#include <media/mediametadataretriever.h>
@@ -139,7 +143,16 @@ MediaScanResult StagefrightMediaScanner::processFileInternal(

    sp<MediaMetadataRetriever> mRetriever(new MediaMetadataRetriever);

    status_t status = mRetriever->setDataSource(path);
    int fd = open(path, O_RDONLY | O_LARGEFILE);
    status_t status;
    if (fd < 0) {
        // couldn't open it locally, maybe the media server can?
        status = mRetriever->setDataSource(path);
    } else {
        status = mRetriever->setDataSource(fd, 0, 0x7ffffffffffffffL);
        close(fd);
    }

    if (status) {
        return MEDIA_SCAN_RESULT_ERROR;
    }