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

Commit 83b0fd99 authored by Marco Nelissen's avatar Marco Nelissen
Browse files

Optionally print name for fd

Add utility function to get the file name for a file descriptor,
and use it in various places.

Change-Id: I196b557a56d5ef0ef89e2020aab2699eafae61b0
parent 1277aea8
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -85,6 +85,8 @@ void writeToAMessage(sp<AMessage> msg, const AVSyncSettings &sync, float videoFp
void readFromAMessage(
void readFromAMessage(
        const sp<AMessage> &msg, AVSyncSettings *sync /* nonnull */, float *videoFps /* nonnull */);
        const sp<AMessage> &msg, AVSyncSettings *sync /* nonnull */, float *videoFps /* nonnull */);


AString nameForFd(int fd);

}  // namespace android
}  // namespace android


#endif  // UTILS_H_
#endif  // UTILS_H_
+3 −1
Original line number Original line Diff line number Diff line
@@ -58,6 +58,7 @@
#include <media/stagefright/MediaCodecList.h>
#include <media/stagefright/MediaCodecList.h>
#include <media/stagefright/MediaErrors.h>
#include <media/stagefright/MediaErrors.h>
#include <media/stagefright/AudioPlayer.h>
#include <media/stagefright/AudioPlayer.h>
#include <media/stagefright/Utils.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/ALooperRoster.h>
#include <media/stagefright/foundation/ALooperRoster.h>
#include <mediautils/BatteryNotifier.h>
#include <mediautils/BatteryNotifier.h>
@@ -730,7 +731,8 @@ status_t MediaPlayerService::Client::setDataSource(


status_t MediaPlayerService::Client::setDataSource(int fd, int64_t offset, int64_t length)
status_t MediaPlayerService::Client::setDataSource(int fd, int64_t offset, int64_t length)
{
{
    ALOGV("setDataSource fd=%d, offset=%lld, length=%lld", fd, offset, length);
    ALOGV("setDataSource fd=%d (%s), offset=%lld, length=%lld",
            fd, nameForFd(fd).c_str(), (long long) offset, (long long) length);
    struct stat sb;
    struct stat sb;
    int ret = fstat(fd, &sb);
    int ret = fstat(fd, &sb);
    if (ret != 0) {
    if (ret != 0) {
+3 −1
Original line number Original line Diff line number Diff line
@@ -35,6 +35,7 @@
#include <media/MediaMetadataRetrieverInterface.h>
#include <media/MediaMetadataRetrieverInterface.h>
#include <media/MediaPlayerInterface.h>
#include <media/MediaPlayerInterface.h>
#include <media/stagefright/DataSource.h>
#include <media/stagefright/DataSource.h>
#include <media/stagefright/Utils.h>
#include <private/media/VideoFrame.h>
#include <private/media/VideoFrame.h>
#include "MetadataRetrieverClient.h"
#include "MetadataRetrieverClient.h"
#include "StagefrightMetadataRetriever.h"
#include "StagefrightMetadataRetriever.h"
@@ -133,7 +134,8 @@ status_t MetadataRetrieverClient::setDataSource(


status_t MetadataRetrieverClient::setDataSource(int fd, int64_t offset, int64_t length)
status_t MetadataRetrieverClient::setDataSource(int fd, int64_t offset, int64_t length)
{
{
    ALOGV("setDataSource fd=%d, offset=%lld, length=%lld", fd, offset, length);
    ALOGV("setDataSource fd=%d (%s), offset=%lld, length=%lld",
            fd, nameForFd(fd).c_str(), (long long) offset, (long long) length);
    Mutex::Autolock lock(mLock);
    Mutex::Autolock lock(mLock);
    struct stat sb;
    struct stat sb;
    int ret = fstat(fd, &sb);
    int ret = fstat(fd, &sb);
+5 −0
Original line number Original line Diff line number Diff line
@@ -20,6 +20,7 @@


#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/FileSource.h>
#include <media/stagefright/FileSource.h>
#include <media/stagefright/Utils.h>
#include <sys/types.h>
#include <sys/types.h>
#include <unistd.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/types.h>
@@ -38,6 +39,7 @@ FileSource::FileSource(const char *filename)
      mDrmBufSize(0),
      mDrmBufSize(0),
      mDrmBuf(NULL){
      mDrmBuf(NULL){


    ALOGV("%s", filename);
    mFd = open(filename, O_LARGEFILE | O_RDONLY);
    mFd = open(filename, O_LARGEFILE | O_RDONLY);


    if (mFd >= 0) {
    if (mFd >= 0) {
@@ -56,6 +58,9 @@ FileSource::FileSource(int fd, int64_t offset, int64_t length)
      mDrmBufOffset(0),
      mDrmBufOffset(0),
      mDrmBufSize(0),
      mDrmBufSize(0),
      mDrmBuf(NULL){
      mDrmBuf(NULL){
    ALOGV("fd=%d (%s), offset=%lld, length=%lld",
            fd, nameForFd(fd).c_str(), (long long) offset, (long long) length);

    CHECK(offset >= 0);
    CHECK(offset >= 0);
    CHECK(length >= 0);
    CHECK(length >= 0);
}
}
+3 −0
Original line number Original line Diff line number Diff line
@@ -129,6 +129,9 @@ status_t NuMediaExtractor::setDataSource(


status_t NuMediaExtractor::setDataSource(int fd, off64_t offset, off64_t size) {
status_t NuMediaExtractor::setDataSource(int fd, off64_t offset, off64_t size) {


    ALOGV("setDataSource fd=%d (%s), offset=%lld, length=%lld",
            fd, nameForFd(fd).c_str(), (long long) offset, (long long) size);

    Mutex::Autolock autoLock(mLock);
    Mutex::Autolock autoLock(mLock);


    if (mImpl != NULL) {
    if (mImpl != NULL) {
Loading