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

Commit 65fdcf74 authored by Wei Jia's avatar Wei Jia
Browse files

MediaPlayer2: remove unused code.

Test: MediaPlayer2 plays
Bug: 63934228
Change-Id: I046c7be126a329dfd8f11cdc7471a7ec70a1c64f
parent a97e318d
Loading
Loading
Loading
Loading
+0 −169
Original line number Diff line number Diff line
@@ -82,7 +82,6 @@ using android::OK;
using android::BAD_VALUE;
using android::NOT_ENOUGH_DATA;
using android::Parcel;
using android::media::VolumeShaper;

// Max number of entries in the filter.
const int kMaxFilterSize = 64;  // I pulled that out of thin air.
@@ -503,7 +502,6 @@ MediaPlayer2Manager::Client::Client(
    mStatus = NO_INIT;
    mAudioSessionId = audioSessionId;
    mUid = uid;
    mRetransmitEndpointValid = false;
    mAudioAttributes = NULL;

#if CALLBACK_ANTAGONIZER
@@ -605,14 +603,6 @@ status_t MediaPlayer2Manager::Client::setDataSource(
        return status;
    }

    // Set the re-transmission endpoint if one was chosen.
    if (mRetransmitEndpointValid) {
        status = p->setRetransmitEndpoint(&mRetransmitEndpoint);
        if (status != NO_ERROR) {
            ALOGE("setRetransmitEndpoint error: %d", status);
        }
    }

    return status;
}

@@ -927,34 +917,6 @@ status_t MediaPlayer2Manager::Client::setNextPlayer(const sp<MediaPlayer2Engine>
    return OK;
}

VolumeShaper::Status MediaPlayer2Manager::Client::applyVolumeShaper(
        const sp<VolumeShaper::Configuration>& configuration,
        const sp<VolumeShaper::Operation>& operation) {
    // for hardware output, call player instead
    ALOGV("Client::applyVolumeShaper(%p)", this);
    sp<MediaPlayer2Interface> p = getPlayer();
    {
        Mutex::Autolock l(mLock);
        if (mAudioOutput.get() != nullptr) {
            return mAudioOutput->applyVolumeShaper(configuration, operation);
        }
    }
    return VolumeShaper::Status(INVALID_OPERATION);
}

sp<VolumeShaper::State> MediaPlayer2Manager::Client::getVolumeShaperState(int id) {
    // for hardware output, call player instead
    ALOGV("Client::getVolumeShaperState(%p)", this);
    sp<MediaPlayer2Interface> p = getPlayer();
    {
        Mutex::Autolock l(mLock);
        if (mAudioOutput.get() != nullptr) {
            return mAudioOutput->getVolumeShaperState(id);
        }
    }
    return nullptr;
}

status_t MediaPlayer2Manager::Client::seekTo(int msec, MediaPlayer2SeekMode mode)
{
    ALOGV("[%d] seekTo(%d, %d)", mConnId, msec, mode);
@@ -966,7 +928,6 @@ status_t MediaPlayer2Manager::Client::seekTo(int msec, MediaPlayer2SeekMode mode
status_t MediaPlayer2Manager::Client::reset()
{
    ALOGV("[%d] reset", mConnId);
    mRetransmitEndpointValid = false;
    sp<MediaPlayer2Interface> p = getPlayer();
    if (p == 0) return UNKNOWN_ERROR;
    return p->reset();
@@ -1069,53 +1030,6 @@ status_t MediaPlayer2Manager::Client::getParameter(int key, Parcel *reply) {
    return p->getParameter(key, reply);
}

status_t MediaPlayer2Manager::Client::setRetransmitEndpoint(
        const struct sockaddr_in* endpoint) {

    if (NULL != endpoint) {
        uint32_t a = ntohl(endpoint->sin_addr.s_addr);
        uint16_t p = ntohs(endpoint->sin_port);
        ALOGV("[%d] setRetransmitEndpoint(%u.%u.%u.%u:%hu)", mConnId,
                (a >> 24), (a >> 16) & 0xFF, (a >> 8) & 0xFF, (a & 0xFF), p);
    } else {
        ALOGV("[%d] setRetransmitEndpoint = <none>", mConnId);
    }

    // Right now, the only valid time to set a retransmit endpoint is before
    // setDataSource.

    if (NULL != endpoint) {
        Mutex::Autolock lock(mLock);
        mRetransmitEndpoint = *endpoint;
        mRetransmitEndpointValid = true;
    } else {
        Mutex::Autolock lock(mLock);
        mRetransmitEndpointValid = false;
    }

    return NO_ERROR;
}

status_t MediaPlayer2Manager::Client::getRetransmitEndpoint(
        struct sockaddr_in* endpoint)
{
    if (NULL == endpoint)
        return BAD_VALUE;

    sp<MediaPlayer2Interface> p = getPlayer();

    if (p != NULL)
        return p->getRetransmitEndpoint(endpoint);

    Mutex::Autolock lock(mLock);
    if (!mRetransmitEndpointValid)
        return NO_INIT;

    *endpoint = mRetransmitEndpoint;

    return NO_ERROR;
}

void MediaPlayer2Manager::Client::notify(
        const wp<MediaPlayer2Engine> &listener, int msg, int ext1, int ext2, const Parcel *obj)
{
@@ -1319,7 +1233,6 @@ MediaPlayer2Manager::AudioOutput::AudioOutput(audio_session_t sessionId, uid_t u
      mSendLevel(0.0),
      mAuxEffectId(0),
      mFlags(AUDIO_OUTPUT_FLAG_NONE),
      mVolumeHandler(new media::VolumeHandler()),
      mSelectedDeviceId(AUDIO_PORT_HANDLE_NONE),
      mRoutedDeviceId(AUDIO_PORT_HANDLE_NONE),
      mDeviceCallbackEnabled(false),
@@ -1790,24 +1703,6 @@ status_t MediaPlayer2Manager::AudioOutput::open(
    ALOGV("setVolume");
    t->setVolume(mLeftVolume, mRightVolume);

    // Restore VolumeShapers for the MediaPlayer2 in case the track was recreated
    // due to an output sink error (e.g. offload to non-offload switch).
    mVolumeHandler->forall([&t](const VolumeShaper &shaper) -> VolumeShaper::Status {
        sp<VolumeShaper::Operation> operationToEnd =
                new VolumeShaper::Operation(shaper.mOperation);
        // TODO: Ideally we would restore to the exact xOffset position
        // as returned by getVolumeShaperState(), but we don't have that
        // information when restoring at the client unless we periodically poll
        // the server or create shared memory state.
        //
        // For now, we simply advance to the end of the VolumeShaper effect
        // if it has been started.
        if (shaper.isStarted()) {
            operationToEnd->setNormalizedTime(1.f);
        }
        return t->applyVolumeShaper(shaper.mConfiguration, operationToEnd);
    });

    mSampleRateHz = sampleRate;
    mFlags = flags;
    mMsecsPerFrame = 1E3f / (mPlaybackRate.mSpeed * sampleRate);
@@ -1852,9 +1747,6 @@ status_t MediaPlayer2Manager::AudioOutput::start()
        mTrack->setVolume(mLeftVolume, mRightVolume);
        mTrack->setAuxEffectSendLevel(mSendLevel);
        status_t status = mTrack->start();
        if (status == NO_ERROR) {
            mVolumeHandler->setStarted();
        }
        return status;
    }
    return NO_INIT;
@@ -2091,67 +1983,6 @@ status_t MediaPlayer2Manager::AudioOutput::enableAudioDeviceCallback(bool enable
    return NO_ERROR;
}

VolumeShaper::Status MediaPlayer2Manager::AudioOutput::applyVolumeShaper(
                const sp<VolumeShaper::Configuration>& configuration,
                const sp<VolumeShaper::Operation>& operation)
{
    Mutex::Autolock lock(mLock);
    ALOGV("AudioOutput::applyVolumeShaper");

    mVolumeHandler->setIdIfNecessary(configuration);

    VolumeShaper::Status status;
    if (mTrack != 0) {
        status = mTrack->applyVolumeShaper(configuration, operation);
        if (status >= 0) {
            (void)mVolumeHandler->applyVolumeShaper(configuration, operation);
            if (mTrack->isPlaying()) { // match local AudioTrack to properly restore.
                mVolumeHandler->setStarted();
            }
        }
    } else {
        // VolumeShapers are not affected when a track moves between players for
        // gapless playback (setNextMediaPlayer).
        // We forward VolumeShaper operations that do not change configuration
        // to the new player so that unducking may occur as expected.
        // Unducking is an idempotent operation, same if applied back-to-back.
        if (configuration->getType() == VolumeShaper::Configuration::TYPE_ID
                && mNextOutput != nullptr) {
            ALOGV("applyVolumeShaper: Attempting to forward missed operation: %s %s",
                    configuration->toString().c_str(), operation->toString().c_str());
            Mutex::Autolock nextLock(mNextOutput->mLock);

            // recycled track should be forwarded from this AudioSink by switchToNextOutput
            sp<AudioTrack> track = mNextOutput->mRecycledTrack;
            if (track != nullptr) {
                ALOGD("Forward VolumeShaper operation to recycled track %p", track.get());
                (void)track->applyVolumeShaper(configuration, operation);
            } else {
                // There is a small chance that the unduck occurs after the next
                // player has already started, but before it is registered to receive
                // the unduck command.
                track = mNextOutput->mTrack;
                if (track != nullptr) {
                    ALOGD("Forward VolumeShaper operation to track %p", track.get());
                    (void)track->applyVolumeShaper(configuration, operation);
                }
            }
        }
        status = mVolumeHandler->applyVolumeShaper(configuration, operation);
    }
    return status;
}

sp<VolumeShaper::State> MediaPlayer2Manager::AudioOutput::getVolumeShaperState(int id)
{
    Mutex::Autolock lock(mLock);
    if (mTrack != 0) {
        return mTrack->getVolumeShaperState(id);
    } else {
        return mVolumeHandler->getVolumeShaperState(id);
    }
}

// static
void MediaPlayer2Manager::AudioOutput::CallbackWrapper(
        int event, void *cookie, void *info) {
+0 −15
Original line number Diff line number Diff line
@@ -132,11 +132,6 @@ class MediaPlayer2Manager {
        virtual status_t        setParameters(const String8& keyValuePairs);
        virtual String8         getParameters(const String8& keys);

        virtual media::VolumeShaper::Status applyVolumeShaper(
                                        const sp<media::VolumeShaper::Configuration>& configuration,
                                        const sp<media::VolumeShaper::Operation>& operation) override;
        virtual sp<media::VolumeShaper::State> getVolumeShaperState(int id) override;

        // AudioRouting
        virtual status_t        setOutputDevice(audio_port_handle_t deviceId);
        virtual status_t        getRoutedDeviceId(audio_port_handle_t* deviceId);
@@ -170,7 +165,6 @@ class MediaPlayer2Manager {
        float                   mSendLevel;
        int                     mAuxEffectId;
        audio_output_flags_t    mFlags;
        sp<media::VolumeHandler>       mVolumeHandler;
        audio_port_handle_t     mSelectedDeviceId;
        audio_port_handle_t     mRoutedDeviceId;
        bool                    mDeviceCallbackEnabled;
@@ -278,15 +272,8 @@ private:
        virtual status_t        attachAuxEffect(int effectId);
        virtual status_t        setParameter(int key, const Parcel &request);
        virtual status_t        getParameter(int key, Parcel *reply);
        virtual status_t        setRetransmitEndpoint(const struct sockaddr_in* endpoint);
        virtual status_t        getRetransmitEndpoint(struct sockaddr_in* endpoint);
        virtual status_t        setNextPlayer(const sp<MediaPlayer2Engine>& player);

        virtual media::VolumeShaper::Status applyVolumeShaper(
                                        const sp<media::VolumeShaper::Configuration>& configuration,
                                        const sp<media::VolumeShaper::Operation>& operation) override;
        virtual sp<media::VolumeShaper::State> getVolumeShaperState(int id) override;

        virtual status_t        setDataSource(const sp<DataSourceDesc> &dsd);

        static  void            notify(const wp<MediaPlayer2Engine> &listener, int msg,
@@ -363,8 +350,6 @@ private:
                    audio_attributes_t *         mAudioAttributes;
                    uid_t                        mUid;
                    sp<ANativeWindowWrapper>     mConnectedWindow;
                    struct sockaddr_in           mRetransmitEndpoint;
                    bool                         mRetransmitEndpointValid;
                    sp<Client>                   mNextClient;

        // Metadata filters.
+0 −8
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@
#include <system/audio.h>

#include <media/MediaSource.h>
#include <media/VolumeShaper.h>

// Fwd decl to make sure everyone agrees that the scope of struct sockaddr_in is
// global, and not in android::
@@ -77,15 +76,8 @@ public:
    virtual status_t        attachAuxEffect(int effectId) = 0;
    virtual status_t        setParameter(int key, const Parcel& request) = 0;
    virtual status_t        getParameter(int key, Parcel* reply) = 0;
    virtual status_t        setRetransmitEndpoint(const struct sockaddr_in* endpoint) = 0;
    virtual status_t        getRetransmitEndpoint(struct sockaddr_in* endpoint) = 0;
    virtual status_t        setNextPlayer(const sp<MediaPlayer2Engine>& next) = 0;

    virtual media::VolumeShaper::Status applyVolumeShaper(
                                    const sp<media::VolumeShaper::Configuration>& configuration,
                                    const sp<media::VolumeShaper::Operation>& operation) = 0;
    virtual sp<media::VolumeShaper::State> getVolumeShaperState(int id) = 0;

    // Modular DRM
    virtual status_t        prepareDrm(const uint8_t uuid[16],
                                    const Vector<uint8_t>& drmSessionId) = 0;
+0 −12
Original line number Diff line number Diff line
@@ -138,11 +138,6 @@ public:
        virtual status_t    setParameters(const String8& /* keyValuePairs */) { return NO_ERROR; }
        virtual String8     getParameters(const String8& /* keys */) { return String8::empty(); }

        virtual media::VolumeShaper::Status applyVolumeShaper(
                                    const sp<media::VolumeShaper::Configuration>& configuration,
                                    const sp<media::VolumeShaper::Operation>& operation);
        virtual sp<media::VolumeShaper::State> getVolumeShaperState(int id);

        // AudioRouting
        virtual status_t    setOutputDevice(audio_port_handle_t deviceId);
        virtual status_t    getRoutedDeviceId(audio_port_handle_t* deviceId);
@@ -218,13 +213,6 @@ public:
    virtual status_t    setParameter(int key, const Parcel &request) = 0;
    virtual status_t    getParameter(int key, Parcel *reply) = 0;

    // default no-op implementation of optional extensions
    virtual status_t setRetransmitEndpoint(const struct sockaddr_in* /* endpoint */) {
        return INVALID_OPERATION;
    }
    virtual status_t getRetransmitEndpoint(struct sockaddr_in* /* endpoint */) {
        return INVALID_OPERATION;
    }
    virtual status_t setNextPlayer(const sp<MediaPlayer2Interface>& /* next */) {
        return OK;
    }
+0 −8
Original line number Diff line number Diff line
@@ -244,13 +244,8 @@ public:
            status_t        attachAuxEffect(int effectId);
            status_t        setParameter(int key, const Parcel& request);
            status_t        getParameter(int key, Parcel* reply);
            status_t        setRetransmitEndpoint(const char* addrString, uint16_t port);
            status_t        setNextMediaPlayer(const sp<MediaPlayer2>& player);

            media::VolumeShaper::Status applyVolumeShaper(
                                    const sp<media::VolumeShaper::Configuration>& configuration,
                                    const sp<media::VolumeShaper::Operation>& operation);
            sp<media::VolumeShaper::State> getVolumeShaperState(int id);
            // Modular DRM
            status_t        prepareDrm(const uint8_t uuid[16], const Vector<uint8_t>& drmSessionId);
            status_t        releaseDrm();
@@ -266,7 +261,6 @@ private:
            status_t        getDuration_l(int *msec);
            status_t        attachNewPlayer(const sp<MediaPlayer2Engine>& player);
            status_t        reset_l();
            status_t        doSetRetransmitEndpoint(const sp<MediaPlayer2Engine>& player);
            status_t        checkStateForKeySet_l(int key);

    sp<MediaPlayer2Engine>      mPlayer;
@@ -292,8 +286,6 @@ private:
    int                         mVideoHeight;
    audio_session_t             mAudioSessionId;
    float                       mSendLevel;
    struct sockaddr_in          mRetransmitEndpoint;
    bool                        mRetransmitEndpointValid;
};

}; // namespace android
Loading