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

Commit 599f634d authored by Mingming Yin's avatar Mingming Yin
Browse files

libstagefright: add NULL pointer check for audio extended APIs

- Add NULL pointer check in ExtendedUtils for auido APIs

Change-Id: I41e0658acb5855e1708b729fbbf58038ad3c6983
CRs-Fixed: 768650
parent 472edc21
Loading
Loading
Loading
Loading
+18 −4
Original line number Diff line number Diff line
@@ -981,6 +981,9 @@ bool ExtendedUtils::is16bitPCMOffloadEnabled() {

bool ExtendedUtils::isRAWFormat(const sp<MetaData> &meta) {
    const char *mime = {0};
    if (meta == NULL) {
        return false;
    }
    CHECK(meta->findCString(kKeyMIMEType, &mime));
    if (!strncasecmp(mime, MEDIA_MIMETYPE_AUDIO_RAW, 9))
        return true;
@@ -990,6 +993,9 @@ bool ExtendedUtils::isRAWFormat(const sp<MetaData> &meta) {

bool ExtendedUtils::isRAWFormat(const sp<AMessage> &format) {
    AString mime;
    if (format == NULL) {
        return false;
    }
    CHECK(format->findString("mime", &mime));
    if (!strncasecmp(mime.c_str(), MEDIA_MIMETYPE_AUDIO_RAW, 9))
        return true;
@@ -999,25 +1005,33 @@ bool ExtendedUtils::isRAWFormat(const sp<AMessage> &format) {

int32_t ExtendedUtils::getPcmSampleBits(const sp<MetaData> &meta) {
    int32_t bitWidth = 16;
    if (meta != NULL) {
        meta->findInt32(kKeySampleBits, &bitWidth);
    }
    return bitWidth;
}

int32_t ExtendedUtils::getPcmSampleBits(const sp<AMessage> &format) {
    int32_t bitWidth = 16;
    if (format != NULL) {
        format->findInt32("sbit", &bitWidth);
    }
    return bitWidth;
}

int32_t ExtendedUtils::getPCMFormat(const sp<MetaData> &meta) {
    int32_t pcmFormat = AUDIO_FORMAT_PCM_16_BIT;
    if (meta != NULL) {
        meta->findInt32(kKeyPcmFormat, &pcmFormat);
    }
    return pcmFormat;
}

void ExtendedUtils::setKeyPCMFormat(const sp<MetaData> &meta, int32_t pcmFormat) {
    if (meta != NULL) {
        meta->setInt32(kKeyPcmFormat, pcmFormat);
    }
}

//- returns NULL if we dont really need a new extractor (or cannot),
//  valid extractor is returned otherwise