diff options
Diffstat (limited to 'media')
-rw-r--r-- | media/libmedia/mediaplayer.cpp | 23 | ||||
-rw-r--r-- | media/libmediaplayerservice/MediaPlayerService.cpp | 16 | ||||
-rw-r--r-- | media/libmediaplayerservice/MediaPlayerService.h | 3 |
3 files changed, 31 insertions, 11 deletions
diff --git a/media/libmedia/mediaplayer.cpp b/media/libmedia/mediaplayer.cpp index 81a5e8c..c215abf 100644 --- a/media/libmedia/mediaplayer.cpp +++ b/media/libmedia/mediaplayer.cpp @@ -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) diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp index 0ecfb1e..abbbc20 100644 --- a/media/libmediaplayerservice/MediaPlayerService.cpp +++ b/media/libmediaplayerservice/MediaPlayerService.cpp @@ -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> @@ -1351,6 +1352,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(); } @@ -1464,6 +1469,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() diff --git a/media/libmediaplayerservice/MediaPlayerService.h b/media/libmediaplayerservice/MediaPlayerService.h index 9e6ca52..1c32597 100644 --- a/media/libmediaplayerservice/MediaPlayerService.h +++ b/media/libmediaplayerservice/MediaPlayerService.h @@ -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); |