diff --git a/musikr/src/main/cpp/JVMMetadataBuilder.cpp b/musikr/src/main/cpp/JVMMetadataBuilder.cpp index afb92a43b..d70279f45 100644 --- a/musikr/src/main/cpp/JVMMetadataBuilder.cpp +++ b/musikr/src/main/cpp/JVMMetadataBuilder.cpp @@ -87,30 +87,30 @@ void JVMMetadataBuilder::setMp4(const TagLib::MP4::Tag &tag) { auto type = itemValue.type(); std::string serializedValue; switch (type) { - // Normal expected MP4 items - case TagLib::MP4::Item::Type::StringList: - mp4AddImpl(mp4, itemName, itemValue.toStringList()); - break; - // Weird MP4 items I'm 90% sure I'll encounter. - case TagLib::MP4::Item::Type::Int: - serializedValue = std::to_string(itemValue.toInt()); - break; - case TagLib::MP4::Item::Type::UInt: - serializedValue = std::to_string(itemValue.toUInt()); - break; - case TagLib::MP4::Item::Type::LongLong: - serializedValue = std::to_string(itemValue.toLongLong()); - break; - case TagLib::MP4::Item::Type::IntPair: - // It's inefficient going from the integer representation back into - // a string, but I fully expect taggers to just write "NN/TT" strings - // anyway, and musikr doesn't have to do as much fiddly variant handling. - serializedValue = std::to_string(itemValue.toIntPair().first) + "/" - + std::to_string(itemValue.toIntPair().second); - break; - default: - // Don't care about the other types - continue; + // Normal expected MP4 items + case TagLib::MP4::Item::Type::StringList: + mp4AddImpl(mp4, itemName, itemValue.toStringList()); + break; + // Weird MP4 items I'm 90% sure I'll encounter. + case TagLib::MP4::Item::Type::Int: + serializedValue = std::to_string(itemValue.toInt()); + break; + case TagLib::MP4::Item::Type::UInt: + serializedValue = std::to_string(itemValue.toUInt()); + break; + case TagLib::MP4::Item::Type::LongLong: + serializedValue = std::to_string(itemValue.toLongLong()); + break; + case TagLib::MP4::Item::Type::IntPair: + // It's inefficient going from the integer representation back into + // a string, but I fully expect taggers to just write "NN/TT" strings + // anyway, and musikr doesn't have to do as much fiddly variant handling. + serializedValue = std::to_string(itemValue.toIntPair().first) + "/" + + std::to_string(itemValue.toIntPair().second); + break; + default: + // Don't care about the other types + continue; } mp4AddImpl(mp4, itemName, TagLib::String(serializedValue)); } diff --git a/musikr/src/main/cpp/JVMTagMap.cpp b/musikr/src/main/cpp/JVMTagMap.cpp index 272b33aec..d8030dea0 100644 --- a/musikr/src/main/cpp/JVMTagMap.cpp +++ b/musikr/src/main/cpp/JVMTagMap.cpp @@ -21,7 +21,8 @@ #include "util.h" JVMTagMap::JVMTagMap(JNIEnv *env) : env(env) { - jclass tagMapClass = env->FindClass("org/oxycblt/musikr/metadata/NativeTagMap"); + jclass tagMapClass = env->FindClass( + "org/oxycblt/musikr/metadata/NativeTagMap"); jmethodID init = env->GetMethodID(tagMapClass, "", "()V"); tagMap = env->NewObject(tagMapClass, init); tagMapAddIdSingleMethod = env->GetMethodID(tagMapClass, "addID", @@ -53,7 +54,8 @@ JVMTagMap::~JVMTagMap() { void JVMTagMap::add_id(TagLib::String &id, TagLib::String &value) { env->CallVoidMethod(tagMap, tagMapAddIdSingleMethod, - env->NewStringUTF(id.toCString(true)), env->NewStringUTF(value.toCString(true))); + env->NewStringUTF(id.toCString(true)), + env->NewStringUTF(value.toCString(true))); } void JVMTagMap::add_id(TagLib::String &id, TagLib::StringList &value) { @@ -68,10 +70,12 @@ void JVMTagMap::add_id(TagLib::String &id, TagLib::StringList &value) { void JVMTagMap::add_custom(TagLib::String &description, TagLib::String &value) { env->CallVoidMethod(tagMap, tagMapAddCustomSingleMethod, - env->NewStringUTF(description.toCString(true)), env->NewStringUTF(value.toCString(true))); + env->NewStringUTF(description.toCString(true)), + env->NewStringUTF(value.toCString(true))); } -void JVMTagMap::add_custom(TagLib::String &description, TagLib::StringList &value) { +void JVMTagMap::add_custom(TagLib::String &description, + TagLib::StringList &value) { jobject arrayList = env->NewObject(arrayListClass, arrayListInitMethod); for (auto &item : value) { env->CallBooleanMethod(arrayList, arrayListAddMethod, @@ -81,21 +85,24 @@ void JVMTagMap::add_custom(TagLib::String &description, TagLib::StringList &valu env->NewStringUTF(description.toCString(true)), arrayList); } -void JVMTagMap::add_combined(TagLib::String &id, TagLib::String &description, TagLib::String &value) { +void JVMTagMap::add_combined(TagLib::String &id, TagLib::String &description, + TagLib::String &value) { env->CallVoidMethod(tagMap, tagMapAddCombinedSingleMethod, - env->NewStringUTF(id.toCString(true)), env->NewStringUTF(description.toCString(true)), + env->NewStringUTF(id.toCString(true)), + env->NewStringUTF(description.toCString(true)), env->NewStringUTF(value.toCString(true))); } -void JVMTagMap::add_combined(TagLib::String &id, TagLib::String &description, TagLib::StringList &value) { +void JVMTagMap::add_combined(TagLib::String &id, TagLib::String &description, + TagLib::StringList &value) { jobject arrayList = env->NewObject(arrayListClass, arrayListInitMethod); for (auto &item : value) { env->CallBooleanMethod(arrayList, arrayListAddMethod, env->NewStringUTF(item.toCString(true))); } env->CallVoidMethod(tagMap, tagMapAddCombinedListMethod, - env->NewStringUTF(id.toCString(true)), env->NewStringUTF(description.toCString(true)), - arrayList); + env->NewStringUTF(id.toCString(true)), + env->NewStringUTF(description.toCString(true)), arrayList); } jobject JVMTagMap::getObject() { diff --git a/musikr/src/main/cpp/JVMTagMap.h b/musikr/src/main/cpp/JVMTagMap.h index c75067ef1..842f6872d 100644 --- a/musikr/src/main/cpp/JVMTagMap.h +++ b/musikr/src/main/cpp/JVMTagMap.h @@ -38,8 +38,10 @@ public: void add_custom(TagLib::String &description, TagLib::String &value); void add_custom(TagLib::String &description, TagLib::StringList &value); - void add_combined(TagLib::String &id, TagLib::String &description, TagLib::String &value); - void add_combined(TagLib::String &id, TagLib::String &description, TagLib::StringList &value); + void add_combined(TagLib::String &id, TagLib::String &description, + TagLib::String &value); + void add_combined(TagLib::String &id, TagLib::String &description, + TagLib::StringList &value); jobject getObject(); diff --git a/musikr/src/main/cpp/util.h b/musikr/src/main/cpp/util.h index 1c223a142..ce9ad7255 100644 --- a/musikr/src/main/cpp/util.h +++ b/musikr/src/main/cpp/util.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2024 Auxio Project - * log.h is part of Auxio. + * util.h is part of Auxio. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/musikr/src/main/java/org/oxycblt/musikr/metadata/NativeTagMap.kt b/musikr/src/main/java/org/oxycblt/musikr/metadata/NativeTagMap.kt index 7740fea51..022c9bdbd 100644 --- a/musikr/src/main/java/org/oxycblt/musikr/metadata/NativeTagMap.kt +++ b/musikr/src/main/java/org/oxycblt/musikr/metadata/NativeTagMap.kt @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2025 Auxio Project + * NativeTagMap.kt is part of Auxio. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package org.oxycblt.musikr.metadata import org.oxycblt.musikr.util.correctWhitespace @@ -32,4 +50,4 @@ class NativeTagMap { fun getObject(): Map> { return map } -} \ No newline at end of file +}