musikr.metadata: wrap exceptions into log
Not ideal, but avoids a total catastrophic crash on failed metadata extractions.
This commit is contained in:
parent
b6bc065a4a
commit
c379174ffe
1 changed files with 39 additions and 34 deletions
|
@ -18,9 +18,9 @@
|
||||||
|
|
||||||
#include <jni.h>
|
#include <jni.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "JVMInputStream.h"
|
#include "JVMInputStream.h"
|
||||||
#include "JVMMetadataBuilder.h"
|
#include "JVMMetadataBuilder.h"
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
#include "taglib/fileref.h"
|
#include "taglib/fileref.h"
|
||||||
#include "taglib/flacfile.h"
|
#include "taglib/flacfile.h"
|
||||||
|
@ -34,6 +34,7 @@ extern "C" JNIEXPORT jobject JNICALL
|
||||||
Java_org_oxycblt_musikr_metadata_TagLibJNI_openNative(JNIEnv *env,
|
Java_org_oxycblt_musikr_metadata_TagLibJNI_openNative(JNIEnv *env,
|
||||||
jobject /* this */,
|
jobject /* this */,
|
||||||
jobject inputStream) {
|
jobject inputStream) {
|
||||||
|
try {
|
||||||
JVMInputStream stream {env, inputStream};
|
JVMInputStream stream {env, inputStream};
|
||||||
TagLib::FileRef fileRef {&stream};
|
TagLib::FileRef fileRef {&stream};
|
||||||
if (fileRef.isNull()) {
|
if (fileRef.isNull()) {
|
||||||
|
@ -69,6 +70,10 @@ Java_org_oxycblt_musikr_metadata_TagLibJNI_openNative(JNIEnv *env,
|
||||||
|
|
||||||
builder.setProperties(file->audioProperties());
|
builder.setProperties(file->audioProperties());
|
||||||
builder.setCover(file->tag()->complexProperties("PICTURE"));
|
builder.setCover(file->tag()->complexProperties("PICTURE"));
|
||||||
|
|
||||||
return builder.build();
|
return builder.build();
|
||||||
|
} catch (std::runtime_error e) {
|
||||||
|
LOGE("Error opening file: %s", e.what());
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue