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

Commit b3de207e authored by Simon Bowden's avatar Simon Bowden
Browse files

Propagate haptic channels metadata through MediaFormat in MediaPlayer so that

the presence of haptic channels can be determined without re-opening the
source with a MediaExtractor.

Test: manual
Bug: 240621827
Change-Id: I4bb1c74a82306f2bcc3d50c92503b73e20e6f0f1
parent f519bbc2
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -992,6 +992,11 @@ sp<AMessage> NuPlayer::GenericSource::getTrackInfo(size_t trackIndex) const {
        format->setInt32("auto", !!isAutoselect);
        format->setInt32("default", !!isDefault);
        format->setInt32("forced", !!isForced);
    } else if (trackType == MEDIA_TRACK_TYPE_AUDIO) {
        int32_t hapticChannelCount;
        if (meta->findInt32(kKeyHapticChannelCount, &hapticChannelCount)) {
            format->setInt32("haptic-channel-count", hapticChannelCount);
        }
    }

    return format;
+7 −0
Original line number Diff line number Diff line
@@ -555,6 +555,13 @@ void NuPlayer::writeTrackInfo(
        reply->writeInt32(isAuto);
        reply->writeInt32(isDefault);
        reply->writeInt32(isForced);
    } else if (trackType == MEDIA_TRACK_TYPE_AUDIO) {
        int32_t hapticChannelCount;
        bool hasHapticChannels = format->findInt32("haptic-channel-count", &hapticChannelCount);
        reply->writeInt32(hasHapticChannels);
        if (hasHapticChannels) {
            reply->writeInt32(hapticChannelCount);
        }
    }
}