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

Commit 0a7989f5 authored by Ronghua Wu's avatar Ronghua Wu Committed by Android (Google) Code Review
Browse files

Merge "libmediaplayerservice: try to open audio sink in offload mode in error." into mnc-dev

parents c5648e09 faeb0f29
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -183,6 +183,10 @@ public:
     * pid:                Process ID of the app which initially requested this AudioTrack
     *                     for power management tracking, or -1 for current process ID.
     * pAttributes:        If not NULL, supersedes streamType for use case selection.
     * doNotReconnect:     If set to true, AudioTrack won't automatically recreate the IAudioTrack
                           binder to AudioFlinger.
                           It will return an error instead.  The application will recreate
                           the track based on offloading or different channel configuration, etc.
     * threadCanCallJava:  Not present in parameter list, and so is fixed at false.
     */

@@ -200,7 +204,8 @@ public:
                                    const audio_offload_info_t *offloadInfo = NULL,
                                    int uid = -1,
                                    pid_t pid = -1,
                                    const audio_attributes_t* pAttributes = NULL);
                                    const audio_attributes_t* pAttributes = NULL,
                                    bool doNotReconnect = false);

    /* Creates an audio track and registers it with AudioFlinger.
     * With this constructor, the track is configured for static buffer mode.
@@ -228,7 +233,8 @@ public:
                                    const audio_offload_info_t *offloadInfo = NULL,
                                    int uid = -1,
                                    pid_t pid = -1,
                                    const audio_attributes_t* pAttributes = NULL);
                                    const audio_attributes_t* pAttributes = NULL,
                                    bool doNotReconnect = false);

    /* Terminates the AudioTrack and unregisters it from AudioFlinger.
     * Also destroys all resources associated with the AudioTrack.
@@ -272,7 +278,8 @@ public:
                            const audio_offload_info_t *offloadInfo = NULL,
                            int uid = -1,
                            pid_t pid = -1,
                            const audio_attributes_t* pAttributes = NULL);
                            const audio_attributes_t* pAttributes = NULL,
                            bool doNotReconnect = false);

    /* Result of constructing the AudioTrack. This must be checked for successful initialization
     * before using any AudioTrack API (except for set()), because using
@@ -877,6 +884,8 @@ protected:
        // const after set(), except for bits AUDIO_OUTPUT_FLAG_FAST and AUDIO_OUTPUT_FLAG_OFFLOAD.
        // mLock must be held to read or write those bits reliably.

    bool                    mDoNotReconnect;

    int                     mSessionId;
    int                     mAuxEffectId;

+2 −1
Original line number Diff line number Diff line
@@ -113,7 +113,8 @@ public:
                AudioCallback cb = NULL,
                void *cookie = NULL,
                audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE,
                const audio_offload_info_t *offloadInfo = NULL) = 0;
                const audio_offload_info_t *offloadInfo = NULL,
                bool doNotResuscitate = false) = 0;

        virtual status_t    start() = 0;

+10 −6
Original line number Diff line number Diff line
@@ -178,7 +178,8 @@ AudioTrack::AudioTrack(
        const audio_offload_info_t *offloadInfo,
        int uid,
        pid_t pid,
        const audio_attributes_t* pAttributes)
        const audio_attributes_t* pAttributes,
        bool doNotReconnect)
    : mStatus(NO_INIT),
      mIsTimed(false),
      mPreviousPriority(ANDROID_PRIORITY_NORMAL),
@@ -189,7 +190,7 @@ AudioTrack::AudioTrack(
    mStatus = set(streamType, sampleRate, format, channelMask,
            frameCount, flags, cbf, user, notificationFrames,
            0 /*sharedBuffer*/, false /*threadCanCallJava*/, sessionId, transferType,
            offloadInfo, uid, pid, pAttributes);
            offloadInfo, uid, pid, pAttributes, doNotReconnect);
}

AudioTrack::AudioTrack(
@@ -207,7 +208,8 @@ AudioTrack::AudioTrack(
        const audio_offload_info_t *offloadInfo,
        int uid,
        pid_t pid,
        const audio_attributes_t* pAttributes)
        const audio_attributes_t* pAttributes,
        bool doNotReconnect)
    : mStatus(NO_INIT),
      mIsTimed(false),
      mPreviousPriority(ANDROID_PRIORITY_NORMAL),
@@ -218,7 +220,7 @@ AudioTrack::AudioTrack(
    mStatus = set(streamType, sampleRate, format, channelMask,
            0 /*frameCount*/, flags, cbf, user, notificationFrames,
            sharedBuffer, false /*threadCanCallJava*/, sessionId, transferType, offloadInfo,
            uid, pid, pAttributes);
            uid, pid, pAttributes, doNotReconnect);
}

AudioTrack::~AudioTrack()
@@ -266,7 +268,8 @@ status_t AudioTrack::set(
        const audio_offload_info_t *offloadInfo,
        int uid,
        pid_t pid,
        const audio_attributes_t* pAttributes)
        const audio_attributes_t* pAttributes,
        bool doNotReconnect)
{
    ALOGV("set(): streamType %d, sampleRate %u, format %#x, channelMask %#x, frameCount %zu, "
          "flags #%x, notificationFrames %u, sessionId %d, transferType %d, uid %d, pid %d",
@@ -308,6 +311,7 @@ status_t AudioTrack::set(
    }
    mSharedBuffer = sharedBuffer;
    mTransfer = transferType;
    mDoNotReconnect = doNotReconnect;

    ALOGV_IF(sharedBuffer != 0, "sharedBuffer: %p, size: %d", sharedBuffer->pointer(),
            sharedBuffer->size());
@@ -2006,7 +2010,7 @@ status_t AudioTrack::restoreTrack_l(const char *from)
    // output parameters and new IAudioFlinger in createTrack_l()
    AudioSystem::clearAudioConfigCache();

    if (isOffloadedOrDirect_l()) {
    if (isOffloadedOrDirect_l() || mDoNotReconnect) {
        // FIXME re-creation of offloaded tracks is not yet implemented
        return DEAD_OBJECT;
    }
+6 −3
Original line number Diff line number Diff line
@@ -1489,7 +1489,8 @@ status_t MediaPlayerService::AudioOutput::open(
        audio_format_t format, int bufferCount,
        AudioCallback cb, void *cookie,
        audio_output_flags_t flags,
        const audio_offload_info_t *offloadInfo)
        const audio_offload_info_t *offloadInfo,
        bool doNotReconnect)
{
    mCallback = cb;
    mCallbackCookie = cookie;
@@ -1605,7 +1606,8 @@ status_t MediaPlayerService::AudioOutput::open(
                    offloadInfo,
                    mUid,
                    mPid,
                    mAttributes);
                    mAttributes,
                    doNotReconnect);
        } else {
            t = new AudioTrack(
                    mStreamType,
@@ -1622,7 +1624,8 @@ status_t MediaPlayerService::AudioOutput::open(
                    NULL, // offload info
                    mUid,
                    mPid,
                    mAttributes);
                    mAttributes,
                    doNotReconnect);
        }

        if ((t == 0) || (t->initCheck() != NO_ERROR)) {
+2 −1
Original line number Diff line number Diff line
@@ -97,7 +97,8 @@ class MediaPlayerService : public BnMediaPlayerService
                audio_format_t format, int bufferCount,
                AudioCallback cb, void *cookie,
                audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE,
                const audio_offload_info_t *offloadInfo = NULL);
                const audio_offload_info_t *offloadInfo = NULL,
                bool doNotReconnect = false);

        virtual status_t        start();
        virtual ssize_t         write(const void* buffer, size_t size, bool blocking = true);
Loading