return android::INVALID_OPERATION;
}
+ // There are 3 cases:
+ // mAPlayer != 0 && mAudioTrack == 0 means playing decoded audio
+ // mAPlayer == 0 && mAudioTrack != 0 means playing PCM audio
+ // mAPlayer == 0 && mAudioTrack == 0 means player not fully configured yet
+ // The asserts document and verify this.
+ if (ap->mAPlayer != 0) {
+ assert(ap->mAudioTrack == 0);
+ if (attach) {
+ ap->mAPlayer->attachAuxEffect(pFx->id());
+ ap->mAPlayer->setAuxEffectSendLevel( sles_to_android_amplification(sendLevel) );
+ } else {
+ ap->mAPlayer->attachAuxEffect(0);
+ }
+ return android::NO_ERROR;
+ }
+
if (ap->mAudioTrack == 0) {
// the player doesn't have an AudioTrack at the moment, so store this info to use it
// when the AudioTrack becomes available
// we keep track of the send level, independently of the current audio player level
ap->mAuxSendLevel = sendLevel - ap->mVolume.mLevel;
+ if (ap->mAPlayer != 0) {
+ assert(ap->mAudioTrack == 0);
+ ap->mAPlayer->setAuxEffectSendLevel( sles_to_android_amplification(sendLevel) );
+ return android::NO_ERROR;
+ }
+
if (ap->mAudioTrack == 0) {
return android::NO_ERROR;
}
}
+void GenericMediaPlayer::onAttachAuxEffect(const sp<AMessage> &msg) {
+ SL_LOGD("GenericMediaPlayer::onAttachAuxEffect()");
+ int32_t effectId = 0;
+ if (msg->findInt32(WHATPARAM_ATTACHAUXEFFECT, &effectId)) {
+ if (mPlayer != 0) {
+ status_t status;
+ status = mPlayer->attachAuxEffect(effectId);
+ // attachAuxEffect returns a status but we have no way to report it back to app
+ (void) status;
+ }
+ }
+}
+
+
+void GenericMediaPlayer::onSetAuxEffectSendLevel(const sp<AMessage> &msg) {
+ SL_LOGD("GenericMediaPlayer::onSetAuxEffectSendLevel()");
+ float level = 0.0f;
+ if (msg->findFloat(WHATPARAM_SETAUXEFFECTSENDLEVEL, &level)) {
+ if (mPlayer != 0) {
+ status_t status;
+ status = mPlayer->setAuxEffectSendLevel(level);
+ // setAuxEffectSendLevel returns a status but we have no way to report it back to app
+ (void) status;
+ }
+ }
+}
+
+
void GenericMediaPlayer::onBufferingUpdate(const sp<AMessage> &msg) {
int32_t fillLevel = 0;
if (msg->findInt32(WHATPARAM_BUFFERING_UPDATE, &fillLevel)) {
virtual void onVolumeUpdate();
virtual void onBufferingUpdate(const sp<AMessage> &msg);
virtual void onGetMediaPlayerInfo();
+ virtual void onAttachAuxEffect(const sp<AMessage> &msg);
+ virtual void onSetAuxEffectSendLevel(const sp<AMessage> &msg);
bool mHasVideo;
int32_t mSeekTimeMsec;
//--------------------------------------------------
+void GenericPlayer::attachAuxEffect(int32_t effectId)
+{
+ SL_LOGV("GenericPlayer::attachAuxEffect(id=%d)", effectId);
+ sp<AMessage> msg = new AMessage(kWhatAttachAuxEffect, id());
+ msg->setInt32(WHATPARAM_ATTACHAUXEFFECT, effectId);
+ msg->post();
+}
+
+
+//--------------------------------------------------
+void GenericPlayer::setAuxEffectSendLevel(float level)
+{
+ SL_LOGV("GenericPlayer::setAuxEffectSendLevel(level=%g)", level);
+ sp<AMessage> msg = new AMessage(kWhatSetAuxEffectSendLevel, id());
+ msg->setFloat(WHATPARAM_SETAUXEFFECTSENDLEVEL, level);
+ msg->post();
+}
+
+
+//--------------------------------------------------
/*
* post-condition: mDataLocatorType == kDataLocatorNone
*
onSetBufferingUpdateThreshold(msg);
break;
+ case kWhatAttachAuxEffect:
+ SL_LOGV("kWhatAttachAuxEffect");
+ onAttachAuxEffect(msg);
+ break;
+
+ case kWhatSetAuxEffectSendLevel:
+ SL_LOGV("kWhatSetAuxEffectSendLevel");
+ onSetAuxEffectSendLevel(msg);
+ break;
+
default:
SL_LOGV("kWhatPlay");
TRESPASS();
}
+void GenericPlayer::onAttachAuxEffect(const sp<AMessage> &msg) {
+ SL_LOGV("GenericPlayer::onAttachAuxEffect()");
+}
+
+
+void GenericPlayer::onSetAuxEffectSendLevel(const sp<AMessage> &msg) {
+ SL_LOGV("GenericPlayer::onSetAuxEffectSendLevel()");
+}
+
+
//-------------------------------------------------
void GenericPlayer::notifyStatus() {
SL_LOGV("GenericPlayer::notifyStatus");
#define WHATPARAM_LOOP_LOOPING "looping"
#define WHATPARAM_BUFFERING_UPDATE "bufferingUpdate"
#define WHATPARAM_BUFFERING_UPDATETHRESHOLD_PERCENT "buffUpdateThreshold"
+#define WHATPARAM_ATTACHAUXEFFECT "attachAuxEffect"
+#define WHATPARAM_SETAUXEFFECTSENDLEVEL "setAuxEffectSendLevel"
namespace android {
virtual void getSampleRate(uint32_t* hz);// hz != NULL, UNKNOWN_SAMPLERATE if unknown
void setVolume(bool mute, bool useStereoPos, XApermille stereoPos, XAmillibel volume);
+ void attachAuxEffect(int32_t effectId);
+ void setAuxEffectSendLevel(float level);
protected:
// mutex used for set vs use of volume and cache (fill, threshold) settings
kWhatVolumeUpdate = 'volu',
kWhatBufferingUpdate = 'bufu',
kWhatBuffUpdateThres = 'buut',
- kWhatMediaPlayerInfo = 'mpin'
+ kWhatMediaPlayerInfo = 'mpin',
+ kWhatAttachAuxEffect = 'aaux',
+ kWhatSetAuxEffectSendLevel = 'saux',
};
// Send a notification to one of the event listeners
virtual void onSeekComplete();
virtual void onBufferingUpdate(const sp<AMessage> &msg);
virtual void onSetBufferingUpdateThreshold(const sp<AMessage> &msg);
+ virtual void onAttachAuxEffect(const sp<AMessage> &msg);
+ virtual void onSetAuxEffectSendLevel(const sp<AMessage> &msg);
// Convenience methods
// for async notifications of prefetch status and cache fill level, needs to be called