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

Commit 88b4ca8d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add key for haptic channel count in metadata."

parents 91ecf9f7 9e0ad027
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -1280,7 +1280,7 @@ void MyOggExtractor::parseFileMetaData() {
        //ALOGI("comment #%d: '%s'", i + 1, mVc.user_comments[i]);
    }

    AMediaFormat_getInt32(mFileMeta, "haptic", &mHapticChannelCount);
    AMediaFormat_getInt32(mFileMeta, AMEDIAFORMAT_KEY_HAPTIC_CHANNEL_COUNT, &mHapticChannelCount);
}

void MyOggExtractor::setChannelMask(int channelCount) {
@@ -1297,6 +1297,8 @@ void MyOggExtractor::setChannelMask(int channelCount) {
            const audio_channel_mask_t channelMask = audio_channel_out_mask_from_count(
                    audioChannelCount) | hapticChannelMask;
            AMediaFormat_setInt32(mMeta, AMEDIAFORMAT_KEY_CHANNEL_MASK, channelMask);
            AMediaFormat_setInt32(
                    mMeta, AMEDIAFORMAT_KEY_HAPTIC_CHANNEL_COUNT, mHapticChannelCount);
        }
    } else {
        AMediaFormat_setInt32(mMeta, AMEDIAFORMAT_KEY_CHANNEL_MASK,
+1 −0
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ static const char *AMediaFormatKeyGroupInt32[] = {
    AMEDIAFORMAT_KEY_FLAC_COMPRESSION_LEVEL,
    AMEDIAFORMAT_KEY_GRID_COLUMNS,
    AMEDIAFORMAT_KEY_GRID_ROWS,
    AMEDIAFORMAT_KEY_HAPTIC_CHANNEL_COUNT,
    AMEDIAFORMAT_KEY_HEIGHT,
    AMEDIAFORMAT_KEY_INTRA_REFRESH_PERIOD,
    AMEDIAFORMAT_KEY_IS_ADTS,
+3 −4
Original line number Diff line number Diff line
@@ -309,7 +309,6 @@ static void extractAlbumArt(
void parseVorbisComment(
        AMediaFormat *fileMeta, const char *comment, size_t commentLength) {
    // Haptic tag is only kept here as it will only be used in extractor to generate channel mask.
    const char* const haptic = "haptic";
    struct {
        const char *const mTag;
        const char *mKey;
@@ -330,7 +329,7 @@ void parseVorbisComment(
        { "LYRICIST", AMEDIAFORMAT_KEY_LYRICIST },
        { "METADATA_BLOCK_PICTURE", AMEDIAFORMAT_KEY_ALBUMART },
        { "ANDROID_LOOP", AMEDIAFORMAT_KEY_LOOP },
        { "ANDROID_HAPTIC", haptic },
        { "ANDROID_HAPTIC", AMEDIAFORMAT_KEY_HAPTIC_CHANNEL_COUNT },
    };

        for (size_t j = 0; j < sizeof(kMap) / sizeof(kMap[0]); ++j) {
@@ -346,12 +345,12 @@ void parseVorbisComment(
                    if (!strcasecmp(&comment[tagLen + 1], "true")) {
                        AMediaFormat_setInt32(fileMeta, AMEDIAFORMAT_KEY_LOOP, 1);
                    }
                } else if (kMap[j].mKey == haptic) {
                } else if (kMap[j].mKey == AMEDIAFORMAT_KEY_HAPTIC_CHANNEL_COUNT) {
                    char *end;
                    errno = 0;
                    const int hapticChannelCount = strtol(&comment[tagLen + 1], &end, 10);
                    if (errno == 0) {
                        AMediaFormat_setInt32(fileMeta, haptic, hapticChannelCount);
                        AMediaFormat_setInt32(fileMeta, kMap[j].mKey, hapticChannelCount);
                    } else {
                        ALOGE("Error(%d) when parsing haptic channel count", errno);
                    }
+10 −0
Original line number Diff line number Diff line
@@ -967,6 +967,11 @@ status_t convertMetaDataToMessage(
        if (meta->findInt32(kKeyPcmEncoding, &pcmEncoding)) {
            msg->setInt32("pcm-encoding", pcmEncoding);
        }

        int32_t hapticChannelCount;
        if (meta->findInt32(kKeyHapticChannelCount, &hapticChannelCount)) {
            msg->setInt32("haptic-channel-count", hapticChannelCount);
        }
    }

    int32_t maxInputSize;
@@ -1708,6 +1713,11 @@ void convertMessageToMetaData(const sp<AMessage> &msg, sp<MetaData> &meta) {
        if (msg->findInt32("pcm-encoding", &pcmEncoding)) {
            meta->setInt32(kKeyPcmEncoding, pcmEncoding);
        }

        int32_t hapticChannelCount;
        if (msg->findInt32("haptic-channel-count", &hapticChannelCount)) {
            meta->setInt32(kKeyHapticChannelCount, hapticChannelCount);
        }
    }

    int32_t maxInputSize;
+2 −0
Original line number Diff line number Diff line
@@ -236,6 +236,8 @@ enum {
    kKeyOpaqueCSD0       = 'csd0',
    kKeyOpaqueCSD1       = 'csd1',
    kKeyOpaqueCSD2       = 'csd2',

    kKeyHapticChannelCount = 'hapC',
};

enum {
Loading