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

Commit 5b1bd7fb authored by Homin Lee's avatar Homin Lee
Browse files

libmedia: Fixed bug on mix-encoded tag of Korean mp3s.

There are some Korean mp3s which not only one encoding used in their tag,
like album title in UTF-8 and everything else (like artist, title and etc)
in EUC-KR. and, only UTF-8 values was shown correctly.

Change-Id: Ie95efaf05ee4a08ee3859df0234fdd9ac3fbd413
parent 65fa8dff
Loading
Loading
Loading
Loading
+31 −12
Original line number Diff line number Diff line
@@ -200,14 +200,32 @@ void MediaScannerClient::endFile()
{
    if (mLocaleEncoding != kEncodingNone) {
        int size = mNames->size();
        uint32_t encoding = kEncodingAll;
        uint32_t tmpEnc;
        uint32_t encodings = kEncodingAll;

        // guess proper encoding for non-ASCII values
        int i = 0;
        while (mNames->getEntry(i) != NULL) {
            tmpEnc = possibleEncodings(mValues->getEntry(i));

            if (mLocaleEncoding == kEncodingEUCKR && tmpEnc == kEncodingNone) {
                // there are some Korean mp3s which use EUC-KR and utf-8 together in their tag
                // this case means the value's encoding is utf-8. so, don't count them
                if (!handleStringTag(mNames->getEntry(i), mValues->getEntry(i)))
                    break;
                mNames->erase(i);
                mValues->erase(i);
            } else {
                // to find more accurate encoding,
                // compute a bit mask containing all possible encodings
        for (int i = 0; i < mNames->size(); i++)
            encoding &= possibleEncodings(mValues->getEntry(i));
                encodings &= tmpEnc;
                i += 1;
            }
        }

        // if the locale encoding matches, then assume we have a native encoding.
        if (encoding & mLocaleEncoding)
        if (mNames->size() > 0) {
            // if the locale encoding matches, then assume we have a native encoding
            if (encodings & mLocaleEncoding)
                convertValues(mLocaleEncoding);

            // finally, push all name/value pairs to the client
@@ -216,6 +234,7 @@ void MediaScannerClient::endFile()
                    break;
            }
        }
    }
    // else addStringTag() has done all the work so we have nothing to do

    delete mNames;