From d8e320c891fa3465eaaf11671a51c5624cffa725 Mon Sep 17 00:00:00 2001 From: hj kim Date: Tue, 9 Jun 2020 09:49:01 +0900 Subject: [PATCH] Add debug logs Change-Id: I45aa17d23566813005ae30fc0fbdbfd4d6d36584 --- src/metadata_editor.cpp | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/metadata_editor.cpp b/src/metadata_editor.cpp index 24b8d64..800aa77 100755 --- a/src/metadata_editor.cpp +++ b/src/metadata_editor.cpp @@ -553,14 +553,14 @@ static int __metadata_editor_get_picture_info(const char *path, char **picture, extern "C" int metadata_editor_create(metadata_editor_h *metadata) { - metadata_editor_retvm_if(metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "Invalid metadata"); + metadata_editor_debug_fenter(); + + metadata_editor_retvm_if(!metadata, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "Invalid metadata"); metadata_editor_s *_metadata = g_new0(metadata_editor_s, 1); - _metadata->file = NULL; - _metadata->filetype = METADATA_EDITOR_FORMAT_NOTYPE; // Specify file type out of range + _metadata->filetype = METADATA_EDITOR_FORMAT_NOTYPE; - // Save the structure in the metadata *metadata = (metadata_editor_h)_metadata; return METADATA_EDITOR_ERROR_NONE; @@ -592,6 +592,8 @@ extern "C" int metadata_editor_set_path(metadata_editor_h metadata, const char * metadata_editor_s *_metadata = (metadata_editor_s*)metadata; File *_file = NULL; + metadata_editor_debug_fenter(); + metadata_editor_retvm_if(!_metadata, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "Invalid metadata"); ret = __check_file_validity(path); @@ -834,10 +836,11 @@ static int __metadata_editor_get_wav_metadata(metadata_editor_s *metadata, metad extern "C" int metadata_editor_get_metadata(metadata_editor_h metadata, metadata_editor_attr_e attribute, char **value) { - metadata_editor_s *_metadata = (metadata_editor_s*)metadata; metadata_editor_retvm_if(!_metadata, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "Invalid metadata"); + metadata_editor_debug("file format [%d]", _metadata->filetype); + switch (_metadata->filetype) { case METADATA_EDITOR_FORMAT_MP3: return __metadata_editor_get_mp3_metadata(_metadata, attribute, value); @@ -1048,10 +1051,11 @@ static int __metadata_editor_set_wav_metadata(metadata_editor_s *metadata, metad extern "C" int metadata_editor_set_metadata(metadata_editor_h metadata, metadata_editor_attr_e attribute, const char *value) { - metadata_editor_s *_metadata = (metadata_editor_s*) metadata; metadata_editor_retvm_if(!_metadata, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "Invalid metadata"); + metadata_editor_debug("file format [%d]", _metadata->filetype); + switch (_metadata->filetype) { case METADATA_EDITOR_FORMAT_MP3: return __metadata_editor_set_mp3_metadata(_metadata, attribute, value); @@ -1087,6 +1091,8 @@ extern "C" int metadata_editor_update_metadata(metadata_editor_h metadata) ret = __check_metadata_set_parameter(_metadata); metadata_editor_retvm_if(ret != METADATA_EDITOR_ERROR_NONE, ret, "fail to __check_metadata_set_parameter() [%d]", ret); + metadata_editor_debug("file format [%d]", _metadata->filetype); + switch (_metadata->filetype) { case METADATA_EDITOR_FORMAT_MP3: { auto _file = dynamic_cast(_metadata->file); @@ -1263,6 +1269,8 @@ extern "C" int metadata_editor_get_picture(metadata_editor_h metadata, int index metadata_editor_retvm_if(!picture, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "Invalid picture"); metadata_editor_retvm_if(!size, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "Invalid size"); + metadata_editor_debug("file format [%d]", _metadata->filetype); + switch (_metadata->filetype) { // Process the file according to the specified file type case METADATA_EDITOR_FORMAT_MP3: return __get_mp3_picture(_metadata, index, picture, size, mime_type); @@ -1336,8 +1344,6 @@ static int __append_flac_picture(metadata_editor_s *metadata, const char *pictur auto frontCover = new FLAC::Picture; - metadata_editor_debug_fenter(); - frontCover->setData(ByteVector(picture, size)); frontCover->setType(FLAC::Picture::FrontCover); frontCover->setMimeType(mime_type); @@ -1371,6 +1377,8 @@ extern "C" int metadata_editor_append_picture(metadata_editor_h metadata, const ret = __metadata_editor_get_picture_info(path, &picture, &size, &mime_type); metadata_editor_retvm_if(ret != METADATA_EDITOR_ERROR_NONE, ret, "File does not exist or you have no rights to open it"); + metadata_editor_debug("file format [%d]", _metadata->filetype); + switch (_metadata->filetype) { case METADATA_EDITOR_FORMAT_MP3: ret = __append_mp3_picture(_metadata, picture, size, mime_type); @@ -1480,6 +1488,8 @@ extern "C" int metadata_editor_remove_picture(metadata_editor_h metadata, int in ret = __check_metadata_set_parameter(_metadata); metadata_editor_retvm_if(ret != METADATA_EDITOR_ERROR_NONE, ret, "fail to __check_metadata_set_parameter() [%d]", ret); + metadata_editor_debug("file format [%d]", _metadata->filetype); + switch (_metadata->filetype) { case METADATA_EDITOR_FORMAT_MP3: return __remove_mp3_picture(_metadata, index); @@ -1502,9 +1512,10 @@ extern "C" int metadata_editor_remove_picture(metadata_editor_h metadata, int in extern "C" int metadata_editor_destroy(metadata_editor_h metadata) { metadata_editor_s *_metadata = (metadata_editor_s*)metadata; - metadata_editor_retvm_if(!_metadata, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "Invalid metadata"); + metadata_editor_debug("file format [%d]", _metadata->filetype); + switch (_metadata->filetype) { case METADATA_EDITOR_FORMAT_MP3: delete dynamic_cast(_metadata->file); -- 2.34.1