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

Commit 6c848ad9 authored by Eric Laurent's avatar Eric Laurent Committed by Android Git Automerger
Browse files

am a8dc93ef: Merge "mediaplayer: fix audio attributes override by stream type" into mnc-dev

* commit 'a8dc93ef':
  mediaplayer: fix audio attributes override by stream type
parents 73a9195d a8dc93ef
Loading
Loading
Loading
Loading
+14 −9
Original line number Diff line number Diff line
@@ -260,9 +260,10 @@ status_t MediaPlayer::setVideoSurfaceTexture(
status_t MediaPlayer::prepareAsync_l()
{
    if ( (mPlayer != 0) && ( mCurrentState & (MEDIA_PLAYER_INITIALIZED | MEDIA_PLAYER_STOPPED) ) ) {
        mPlayer->setAudioStreamType(mStreamType);
        if (mAudioAttributesParcel != NULL) {
            mPlayer->setParameter(KEY_PARAMETER_AUDIO_ATTRIBUTES, *mAudioAttributesParcel);
        } else {
            mPlayer->setAudioStreamType(mStreamType);
        }
        mCurrentState = MEDIA_PLAYER_PREPARING;
        return mPlayer->prepareAsync();
@@ -734,24 +735,28 @@ status_t MediaPlayer::checkStateForKeySet_l(int key)
status_t MediaPlayer::setParameter(int key, const Parcel& request)
{
    ALOGV("MediaPlayer::setParameter(%d)", key);
    status_t status = INVALID_OPERATION;
    Mutex::Autolock _l(mLock);
    if (checkStateForKeySet_l(key) != OK) {
        return INVALID_OPERATION;
    }
    if (mPlayer != NULL) {
        return  mPlayer->setParameter(key, request);
        return status;
    }
    switch (key) {
    case KEY_PARAMETER_AUDIO_ATTRIBUTES:
        // no player, save the marshalled audio attributes
        // save the marshalled audio attributes
        if (mAudioAttributesParcel != NULL) { delete mAudioAttributesParcel; };
        mAudioAttributesParcel = new Parcel();
        mAudioAttributesParcel->appendFrom(&request, 0, request.dataSize());
        return OK;
        status = OK;
        break;
    default:
        ALOGV("setParameter: no active player");
        return INVALID_OPERATION;
        ALOGV_IF(mPlayer == NULL, "setParameter: no active player");
        break;
    }

    if (mPlayer != NULL) {
        status = mPlayer->setParameter(key, request);
    }
    return status;
}

status_t MediaPlayer::getParameter(int key, Parcel *reply)
+16 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@
#include <utils/Timers.h>
#include <utils/Vector.h>

#include <media/AudioPolicyHelper.h>
#include <media/IMediaHTTPService.h>
#include <media/IRemoteDisplay.h>
#include <media/IRemoteDisplayClient.h>
@@ -1350,6 +1351,10 @@ MediaPlayerService::AudioOutput::AudioOutput(int sessionId, int uid, int pid,
      mFlags(AUDIO_OUTPUT_FLAG_NONE)
{
    ALOGV("AudioOutput(%d)", sessionId);
    if (attr != NULL) {
        mStreamType = audio_attributes_to_stream_type(attr);
    }

    setMinBufferCount();
}

@@ -1463,6 +1468,17 @@ String8 MediaPlayerService::AudioOutput::getParameters(const String8& keys)
void MediaPlayerService::AudioOutput::setAudioAttributes(const audio_attributes_t * attributes) {
    Mutex::Autolock lock(mLock);
    mAttributes = attributes;
    if (attributes != NULL) {
        mStreamType = audio_attributes_to_stream_type(attributes);
    }
}

void MediaPlayerService::AudioOutput::setAudioStreamType(audio_stream_type_t streamType)
{
    // do not allow direct stream type modification if attributes have been set
    if (mAttributes == NULL) {
        mStreamType = streamType;
    }
}

void MediaPlayerService::AudioOutput::deleteRecycledTrack_l()
+1 −2
Original line number Diff line number Diff line
@@ -107,8 +107,7 @@ class MediaPlayerService : public BnMediaPlayerService
        virtual void            flush();
        virtual void            pause();
        virtual void            close();
                void            setAudioStreamType(audio_stream_type_t streamType) {
                                                                        mStreamType = streamType; }
                void            setAudioStreamType(audio_stream_type_t streamType);
        virtual audio_stream_type_t getAudioStreamType() const { return mStreamType; }
                void            setAudioAttributes(const audio_attributes_t * attributes);