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

Commit 707eadef authored by Marco Nelissen's avatar Marco Nelissen
Browse files

Don't autoloop notifications

Some apps think it's cool to use ringtones as notification sounds, but
ringtones often loop, which is not appropriate for notifications.

Bug: 15929273
Change-Id: I77c4277801cb2561743f8c676ef76ab4d1668b08
parent 35b0f709
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -625,6 +625,16 @@ void NuPlayerDriver::notifyListener_l(
        case MEDIA_PLAYBACK_COMPLETE:
        {
            if (mState != STATE_RESET_IN_PROGRESS) {
                if (mAutoLoop) {
                    audio_stream_type_t streamType = AUDIO_STREAM_MUSIC;
                    if (mAudioSink != NULL) {
                        streamType = mAudioSink->getAudioStreamType();
                    }
                    if (streamType == AUDIO_STREAM_NOTIFICATION) {
                        ALOGW("disabling auto-loop for notification");
                        mAutoLoop = false;
                    }
                }
                if (mLooping || (mAutoLoop
                        && (mAudioSink == NULL || mAudioSink->realtime()))) {
                    mPlayer->seekToAsync(0);
+10 −0
Original line number Diff line number Diff line
@@ -878,6 +878,16 @@ void AwesomePlayer::onStreamDone() {
        return;
    }

    if (mFlags & AUTO_LOOPING) {
        audio_stream_type_t streamType = AUDIO_STREAM_MUSIC;
        if (mAudioSink != NULL) {
            streamType = mAudioSink->getAudioStreamType();
        }
        if (streamType == AUDIO_STREAM_NOTIFICATION) {
            ALOGW("disabling auto-loop for notification");
            modifyFlags(AUTO_LOOPING, CLEAR);
        }
    }
    if ((mFlags & LOOPING)
            || ((mFlags & AUTO_LOOPING)
                && (mAudioSink == NULL || mAudioSink->realtime()))) {