From 9cb9a862483c8013baee597393b64496729b0761 Mon Sep 17 00:00:00 2001 From: o1 Date: Wed, 7 Jan 2015 15:09:29 +0300 Subject: [PATCH 1/3] Updated project settings --- .../Opus/Opus.xcodeproj/project.pbxproj | 10 +++ .../xcschemes/Distribution.xcscheme | 2 +- .../xcshareddata/xcschemes/Sparkle.xcscheme | 2 +- .../macosx/Vorbis.xcodeproj/project.pbxproj | 10 ++- .../VorbisNoDot.xcodeproj/project.pbxproj | 10 ++- .../vgmstream.xcodeproj/project.pbxproj | 31 +++++++++ .../BASSMODS.xcodeproj/project.pbxproj | 5 +- Plugins/Opus/Opus.xcodeproj/project.pbxproj | 10 +++ .../TagLib/TagLib.xcodeproj/project.pbxproj | 14 +++- Plugins/TagLib/TagLibMetadataReader.m | 12 ++-- .../Vorbis/Vorbis.xcodeproj/project.pbxproj | 69 +++++++++++++++++-- .../modplay/modplay.xcodeproj/project.pbxproj | 4 +- .../vgmstream.xcodeproj/project.pbxproj | 22 ++++++ 13 files changed, 177 insertions(+), 24 deletions(-) diff --git a/Frameworks/Opus/Opus.xcodeproj/project.pbxproj b/Frameworks/Opus/Opus.xcodeproj/project.pbxproj index 451085abe..9bdafddef 100644 --- a/Frameworks/Opus/Opus.xcodeproj/project.pbxproj +++ b/Frameworks/Opus/Opus.xcodeproj/project.pbxproj @@ -1184,6 +1184,11 @@ HAVE_CONFIG_H, "$(inherited)", ); + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + ../../Frameworks/Ogg/include, + ); INFOPLIST_FILE = "Opus/Opus-Info.plist"; INSTALL_PATH = "@loader_path/../Frameworks"; OTHER_LDFLAGS = ( @@ -1211,6 +1216,11 @@ FRAMEWORK_VERSION = A; GCC_PRECOMPILE_PREFIX_HEADER = NO; GCC_PREPROCESSOR_DEFINITIONS = HAVE_CONFIG_H; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + ../../Frameworks/Ogg/include, + ); INFOPLIST_FILE = "Opus/Opus-Info.plist"; INSTALL_PATH = "@loader_path/../Frameworks"; OTHER_LDFLAGS = ( diff --git a/Frameworks/Sparkle/Sparkle.xcodeproj/xcshareddata/xcschemes/Distribution.xcscheme b/Frameworks/Sparkle/Sparkle.xcodeproj/xcshareddata/xcschemes/Distribution.xcscheme index 11b73b52e..9d6cba27c 100644 --- a/Frameworks/Sparkle/Sparkle.xcodeproj/xcshareddata/xcschemes/Distribution.xcscheme +++ b/Frameworks/Sparkle/Sparkle.xcodeproj/xcshareddata/xcschemes/Distribution.xcscheme @@ -1,6 +1,6 @@ -#import -#import -#import -#import -#import +#import +#import +#import +#import +#import +#import @implementation TagLibMetadataReader diff --git a/Plugins/Vorbis/Vorbis.xcodeproj/project.pbxproj b/Plugins/Vorbis/Vorbis.xcodeproj/project.pbxproj index 0971a92c8..3e6325c3f 100644 --- a/Plugins/Vorbis/Vorbis.xcodeproj/project.pbxproj +++ b/Plugins/Vorbis/Vorbis.xcodeproj/project.pbxproj @@ -11,6 +11,7 @@ 17C93D360B8FDA66008627D6 /* VorbisDecoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 17C93D340B8FDA66008627D6 /* VorbisDecoder.m */; }; 17F563820C3BDB670019975C /* Vorbis.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 17F562F70C3BDAAC0019975C /* Vorbis.framework */; }; 17F563850C3BDB6C0019975C /* Vorbis.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 17F562F70C3BDAAC0019975C /* Vorbis.framework */; }; + 48D2EEA31A51E5C8007D6D07 /* Ogg.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 48D2EEA21A51E5C8007D6D07 /* Ogg.framework */; }; 8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; }; /* End PBXBuildFile section */ @@ -26,9 +27,30 @@ isa = PBXContainerItemProxy; containerPortal = 17F562EF0C3BDAAC0019975C /* Vorbis.xcodeproj */; proxyType = 1; - remoteGlobalIDString = 8DC2EF4F0486A6940098B216; + remoteGlobalIDString = 730F23A1091827B100AB638C; remoteInfo = Vorbis; }; + 48D2EE9C1A51E4D4007D6D07 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 17F562EF0C3BDAAC0019975C /* Vorbis.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 738835E40B18F870005C7A69; + remoteInfo = "libvorbis (static)"; + }; + 48D2EE9E1A51E4D4007D6D07 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 17F562EF0C3BDAAC0019975C /* Vorbis.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 738836130B190488005C7A69; + remoteInfo = "libvorbisenc (static)"; + }; + 48D2EEA01A51E4D4007D6D07 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 17F562EF0C3BDAAC0019975C /* Vorbis.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 738836220B1905E5005C7A69; + remoteInfo = "libvorbisfile (static)"; + }; /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -54,6 +76,7 @@ 17C93D340B8FDA66008627D6 /* VorbisDecoder.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = VorbisDecoder.m; sourceTree = ""; }; 17F562EF0C3BDAAC0019975C /* Vorbis.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Vorbis.xcodeproj; path = ../../Frameworks/Vorbis/macosx/Vorbis.xcodeproj; sourceTree = SOURCE_ROOT; }; 32DBCF630370AF2F00C91783 /* Vorbis_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Vorbis_Prefix.pch; sourceTree = ""; }; + 48D2EEA21A51E5C8007D6D07 /* Ogg.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Ogg.framework; path = "../../../../../Library/Developer/Xcode/DerivedData/Cog-aktkhaftjdfmnlcckzpefotmcrlq/Build/Products/Debug/Ogg.framework"; sourceTree = ""; }; 8384913418081A3900E7332D /* Logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Logging.h; path = ../../Utils/Logging.h; sourceTree = ""; }; 8D5B49B6048680CD000E48DA /* Vorbis.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Vorbis.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; 8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -65,6 +88,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 48D2EEA31A51E5C8007D6D07 /* Ogg.framework in Frameworks */, 17F563820C3BDB670019975C /* Vorbis.framework in Frameworks */, 8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */, ); @@ -76,6 +100,7 @@ 089C166AFE841209C02AAC07 /* Vorbis */ = { isa = PBXGroup; children = ( + 48D2EEA21A51E5C8007D6D07 /* Ogg.framework */, 08FB77AFFE84173DC02AAC07 /* Classes */, 32C88E010371C26100C91783 /* Other Sources */, 089C167CFE841241C02AAC07 /* Resources */, @@ -136,6 +161,9 @@ isa = PBXGroup; children = ( 17F562F70C3BDAAC0019975C /* Vorbis.framework */, + 48D2EE9D1A51E4D4007D6D07 /* libvorbis.a */, + 48D2EE9F1A51E4D4007D6D07 /* libvorbisenc.a */, + 48D2EEA11A51E4D4007D6D07 /* libvorbisfile.a */, ); name = Products; sourceTree = ""; @@ -185,7 +213,7 @@ 089C1669FE841209C02AAC07 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0500; + LastUpgradeCheck = 0610; }; buildConfigurationList = 1DEB913E08733D840010E9CD /* Build configuration list for PBXProject "Vorbis" */; compatibilityVersion = "Xcode 3.2"; @@ -217,6 +245,27 @@ remoteRef = 17F562F60C3BDAAC0019975C /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; + 48D2EE9D1A51E4D4007D6D07 /* libvorbis.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libvorbis.a; + remoteRef = 48D2EE9C1A51E4D4007D6D07 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 48D2EE9F1A51E4D4007D6D07 /* libvorbisenc.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libvorbisenc.a; + remoteRef = 48D2EE9E1A51E4D4007D6D07 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 48D2EEA11A51E4D4007D6D07 /* libvorbisfile.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libvorbisfile.a; + remoteRef = 48D2EEA01A51E4D4007D6D07 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; /* End PBXReferenceProxy section */ /* Begin PBXResourcesBuildPhase section */ @@ -259,6 +308,7 @@ "$(FRAMEWORK_SEARCH_PATHS_QUOTED_1)", "$(FRAMEWORK_SEARCH_PATHS_QUOTED_2)", "$(FRAMEWORK_SEARCH_PATHS_QUOTED_3)", + "$(USER_LIBRARY_DIR)/Developer/Xcode/DerivedData/Cog-aktkhaftjdfmnlcckzpefotmcrlq/Build/Products/Debug", ); GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_FIX_AND_CONTINUE = YES; @@ -266,13 +316,16 @@ GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = Vorbis_Prefix.pch; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + ../../Frameworks/Ogg/include, + ); INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Library/Bundles"; OTHER_LDFLAGS = ( "-weak_framework", Vorbis, - "-weak_framework", - ogg, ); PRODUCT_NAME = Vorbis; SKIP_INSTALL = YES; @@ -290,17 +343,21 @@ "$(FRAMEWORK_SEARCH_PATHS_QUOTED_1)", "$(FRAMEWORK_SEARCH_PATHS_QUOTED_2)", "$(FRAMEWORK_SEARCH_PATHS_QUOTED_3)", + "$(USER_LIBRARY_DIR)/Developer/Xcode/DerivedData/Cog-aktkhaftjdfmnlcckzpefotmcrlq/Build/Products/Debug", ); GCC_MODEL_TUNING = G5; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = Vorbis_Prefix.pch; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + ../../Frameworks/Ogg/include, + ); INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Library/Bundles"; OTHER_LDFLAGS = ( "-weak_framework", Vorbis, - "-weak_framework", - ogg, ); PRODUCT_NAME = Vorbis; SKIP_INSTALL = YES; diff --git a/Plugins/modplay/modplay.xcodeproj/project.pbxproj b/Plugins/modplay/modplay.xcodeproj/project.pbxproj index 81dd232e2..a6687eb88 100644 --- a/Plugins/modplay/modplay.xcodeproj/project.pbxproj +++ b/Plugins/modplay/modplay.xcodeproj/project.pbxproj @@ -388,7 +388,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Bundles"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", - /Users/Chris/Source/Repos/cog/ThirdParty/BASS, + "$(PROJECT_DIR)/../../ThirdParty/BASS", ); PRODUCT_NAME = modplay; WRAPPER_EXTENSION = bundle; @@ -405,7 +405,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Bundles"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", - /Users/Chris/Source/Repos/cog/ThirdParty/BASS, + "$(PROJECT_DIR)/../../ThirdParty/BASS", ); PRODUCT_NAME = modplay; WRAPPER_EXTENSION = bundle; diff --git a/Plugins/vgmstream/vgmstream.xcodeproj/project.pbxproj b/Plugins/vgmstream/vgmstream.xcodeproj/project.pbxproj index 92fb29afe..3a97cc57d 100644 --- a/Plugins/vgmstream/vgmstream.xcodeproj/project.pbxproj +++ b/Plugins/vgmstream/vgmstream.xcodeproj/project.pbxproj @@ -261,6 +261,11 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + ../Vorbis/include, + ); MACOSX_DEPLOYMENT_TARGET = 10.7; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; @@ -293,6 +298,11 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + ../Vorbis/include, + ); MACOSX_DEPLOYMENT_TARGET = 10.7; SDKROOT = macosx; }; @@ -305,6 +315,12 @@ COMBINE_HIDPI_IMAGES = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "vgmstream/vgmstream-Prefix.pch"; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + ../../Frameworks/Vorbis/include, + ../../Frameworks/Ogg/include, + ); INFOPLIST_FILE = "vgmstream/vgmstream-Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Bundles"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -320,6 +336,12 @@ COMBINE_HIDPI_IMAGES = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "vgmstream/vgmstream-Prefix.pch"; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + ../../Frameworks/Vorbis/include, + ../../Frameworks/Ogg/include, + ); INFOPLIST_FILE = "vgmstream/vgmstream-Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Bundles"; PRODUCT_NAME = "$(TARGET_NAME)"; From b3072709e448388e38ed52196889d1ea414e3110 Mon Sep 17 00:00:00 2001 From: o1 Date: Wed, 7 Jan 2015 15:10:33 +0300 Subject: [PATCH 2/3] Fixed possible track idx overflow causing crash --- Playlist/PlaylistController.m | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/Playlist/PlaylistController.m b/Playlist/PlaylistController.m index 7a9a2c470..078a9a985 100644 --- a/Playlist/PlaylistController.m +++ b/Playlist/PlaylistController.m @@ -500,19 +500,14 @@ { RepeatMode repeat = [self repeat]; - if (i < 0) - { - if (repeat != RepeatNone) + if (i < 0 || i >= [[self arrangedObjects] count] ) { + if ( repeat != RepeatNone ) + return nil; + + while ( i < 0 ) i += [[self arrangedObjects] count]; - else - return nil; - } - else if (i >= [[self arrangedObjects] count]) - { - if (repeat != RepeatNone) - i -= [[self arrangedObjects] count]; - else - return nil; + if ( i >= [[self arrangedObjects] count]) + i %= [[self arrangedObjects] count]; } return [[self arrangedObjects] objectAtIndex:i]; From 3c4cecd1e4900630613dce0d20df068b23a95e40 Mon Sep 17 00:00:00 2001 From: o1 Date: Thu, 15 Jan 2015 09:02:24 +0300 Subject: [PATCH 3/3] Fighting mp3 tag charset problem: * id3v1 tags are now displayed in default windows charset rather than always being latin1 * only reading required bits from encoding byte (cures some faulty tag problem) * faulty utf16 headers without endianness will now display correctly as well --- .../TagLib/TagLib.xcodeproj/project.pbxproj | 4 + .../id3v2/frames/textidentificationframe.cpp | 2 +- .../TagLib/taglib/taglib/toolkit/tstring.cpp | 73 +++++++++++++++++-- .../TagLib/taglib/taglib/toolkit/tstring.h | 1 + Plugins/TagLib/TagLibMetadataReader.m | 35 +++++++++ 5 files changed, 108 insertions(+), 7 deletions(-) diff --git a/Frameworks/TagLib/TagLib.xcodeproj/project.pbxproj b/Frameworks/TagLib/TagLib.xcodeproj/project.pbxproj index b32188357..db6b6b884 100644 --- a/Frameworks/TagLib/TagLib.xcodeproj/project.pbxproj +++ b/Frameworks/TagLib/TagLib.xcodeproj/project.pbxproj @@ -174,6 +174,7 @@ 32AE5AFF14E70ED700420CA0 /* taglib_config.h in Headers */ = {isa = PBXBuildFile; fileRef = 32AE5A5914E70ED600420CA0 /* taglib_config.h */; settings = {ATTRIBUTES = (Public, ); }; }; 32AE5B0014E70F4700420CA0 /* tlist.tcc in Headers */ = {isa = PBXBuildFile; fileRef = 32AE5A4614E70ED600420CA0 /* tlist.tcc */; settings = {ATTRIBUTES = (Public, ); }; }; 32AE5B0114E70F4A00420CA0 /* tmap.tcc in Headers */ = {isa = PBXBuildFile; fileRef = 32AE5A4814E70ED600420CA0 /* tmap.tcc */; settings = {ATTRIBUTES = (Public, ); }; }; + 4872B8881A675CCB00674347 /* libiconv.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 4872B8871A675CCB00674347 /* libiconv.dylib */; }; 83790D241809E8CA0073CF51 /* opusfile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83790D201809E8CA0073CF51 /* opusfile.cpp */; }; 83790D251809E8CA0073CF51 /* opusfile.h in Headers */ = {isa = PBXBuildFile; fileRef = 83790D211809E8CA0073CF51 /* opusfile.h */; }; 83790D261809E8CA0073CF51 /* opusproperties.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83790D221809E8CA0073CF51 /* opusproperties.cpp */; }; @@ -350,6 +351,7 @@ 32AE5A5714E70ED600420CA0 /* wavpackproperties.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wavpackproperties.cpp; sourceTree = ""; }; 32AE5A5814E70ED600420CA0 /* wavpackproperties.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wavpackproperties.h; sourceTree = ""; }; 32AE5A5914E70ED600420CA0 /* taglib_config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = taglib_config.h; path = taglib/taglib_config.h; sourceTree = ""; }; + 4872B8871A675CCB00674347 /* libiconv.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libiconv.dylib; path = usr/lib/libiconv.dylib; sourceTree = SDKROOT; }; 83790D201809E8CA0073CF51 /* opusfile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = opusfile.cpp; sourceTree = ""; }; 83790D211809E8CA0073CF51 /* opusfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = opusfile.h; sourceTree = ""; }; 83790D221809E8CA0073CF51 /* opusproperties.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = opusproperties.cpp; sourceTree = ""; }; @@ -363,6 +365,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 4872B8881A675CCB00674347 /* libiconv.dylib in Frameworks */, 174C7A370F4FD43100E18B0F /* libz.dylib in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -381,6 +384,7 @@ 0867D691FE84028FC02AAC07 /* TagLib */ = { isa = PBXGroup; children = ( + 4872B8871A675CCB00674347 /* libiconv.dylib */, 8E75700C09F318D70080F1EE /* Source */, 089C1665FE841158C02AAC07 /* Resources */, 0867D69AFE84028FC02AAC07 /* External Frameworks and Libraries */, diff --git a/Frameworks/TagLib/taglib/taglib/mpeg/id3v2/frames/textidentificationframe.cpp b/Frameworks/TagLib/taglib/taglib/mpeg/id3v2/frames/textidentificationframe.cpp index 7c2ab9095..e1c1bf43d 100644 --- a/Frameworks/TagLib/taglib/taglib/mpeg/id3v2/frames/textidentificationframe.cpp +++ b/Frameworks/TagLib/taglib/taglib/mpeg/id3v2/frames/textidentificationframe.cpp @@ -105,7 +105,7 @@ void TextIdentificationFrame::parseFields(const ByteVector &data) // read the string data type (the first byte of the field data) - d->textEncoding = String::Type(data[0]); + d->textEncoding = String::Type(data[0]&3); // split the byte array into chunks based on the string type (two byte delimiter // for unicode encodings) diff --git a/Frameworks/TagLib/taglib/taglib/toolkit/tstring.cpp b/Frameworks/TagLib/taglib/taglib/toolkit/tstring.cpp index 57d17fea2..b20b2b625 100644 --- a/Frameworks/TagLib/taglib/taglib/toolkit/tstring.cpp +++ b/Frameworks/TagLib/taglib/taglib/toolkit/tstring.cpp @@ -32,7 +32,12 @@ #include #include +#include + + namespace TagLib { + char default_ascii_encoding[] = "latin1"; + char ascii_encoding[256] = ""; inline unsigned short byteSwap(unsigned short x) { @@ -161,17 +166,61 @@ String::String(char c, Type t) prepare(t); } + String::String(const ByteVector &v, Type t) { d = new StringPrivate; if(v.isEmpty()) return; - - if(t == Latin1 || t == UTF8) { - - int length = 0; - d->data.resize(v.size()); + + iconv_t encoder = (iconv_t)-1; + if ( t == Latin1 ) { + encoder = iconv_open("utf-8",(*ascii_encoding)?ascii_encoding:default_ascii_encoding); + if ( encoder == (iconv_t)-1 ) + encoder = iconv_open("utf-8",default_ascii_encoding); + } + + if ( t == Latin1 && encoder != (iconv_t)-1 ) { + size_t srclen = v.size(); + char *src = new char[srclen+1]; + size_t dstlen = v.size()*6; + char *dst = new char[dstlen+1]; + int n=0; + + char *src_param = src; + char *dst_param = dst; + size_t src_remaining = srclen; + size_t dst_remaining = dstlen; + + for(ByteVector::ConstIterator it = v.begin(); it != v.end() && (*it); ++it) + src[n++] = *it; + src[n++] = 0; + + iconv(encoder, &src_param, &src_remaining, &dst_param, &dst_remaining); + t = UTF8; + + int length = 0; + + d->data.resize(dstlen); + wstring::iterator targetIt = d->data.begin(); + for ( int i=0; idata.resize(length); + + delete[] src; + delete[] dst; + + iconv_close(encoder); + + t = UTF8; + } else if ( t == UTF8 || ( t == Latin1 && encoder == (iconv_t)-1) ) { // UTF8 string or encoder failed to start + int length = 0; + d->data.resize(v.size()*2); wstring::iterator targetIt = d->data.begin(); for(ByteVector::ConstIterator it = v.begin(); it != v.end() && (*it); ++it) { *targetIt = uchar(*it); @@ -183,7 +232,19 @@ String::String(const ByteVector &v, Type t) else { d->data.resize(v.size() / 2); wstring::iterator targetIt = d->data.begin(); - + + // Cure some faulty UTF16 headers without endianness: insert endianness byte into the beginning of the dst string. + if ( v.size() > 1 ) { + wchar w = combine(v.data()[0], v.data()[1]); + if ( w != 0xfeff && w != 0xfffe ) { + d->data.resize(v.size()/2 + 1); + targetIt = d->data.begin(); + *targetIt = 0xfffe; + ++targetIt; + // String append will continue in the loop below. + } + } + for(ByteVector::ConstIterator it = v.begin(); it != v.end() && it + 1 != v.end() && combine(*it, *(it + 1)); it += 2) diff --git a/Frameworks/TagLib/taglib/taglib/toolkit/tstring.h b/Frameworks/TagLib/taglib/taglib/toolkit/tstring.h index 2e1931f51..665e4a64c 100644 --- a/Frameworks/TagLib/taglib/taglib/toolkit/tstring.h +++ b/Frameworks/TagLib/taglib/taglib/toolkit/tstring.h @@ -55,6 +55,7 @@ #define TStringToQString(s) QString::fromUtf8(s.toCString(true)) namespace TagLib { + extern char ascii_encoding[]; //! A \e wide string class suitable for unicode. diff --git a/Plugins/TagLib/TagLibMetadataReader.m b/Plugins/TagLib/TagLibMetadataReader.m index 3bd0f01da..cc6a6712a 100644 --- a/Plugins/TagLib/TagLibMetadataReader.m +++ b/Plugins/TagLib/TagLibMetadataReader.m @@ -24,6 +24,41 @@ NSMutableDictionary *dict = [[NSMutableDictionary alloc] init]; + if ( !*TagLib::ascii_encoding ) { + NSStringEncoding enc = [NSString defaultCStringEncoding]; + CFStringEncoding cfenc = CFStringConvertNSStringEncodingToEncoding(enc); + NSString *ref = (NSString *)CFStringConvertEncodingToIANACharSetName(cfenc); + UInt32 cp = CFStringConvertEncodingToWindowsCodepage(cfenc); + + // Most tags are using windows codepage, so remap OS X codepage to Windows one. + + static struct { + UInt32 from, to; + } codepage_remaps[] = { + { 10001, 932 }, // Japanese Shift-JIS + { 10002, 950 }, // Traditional Chinese + { 10003, 949 }, // Korean + { 10004, 1256 }, // Arabic + { 10005, 1255 }, // Hebrew + { 10006, 1253 }, // Greek + { 10007, 1251 }, // Cyrillic + { 10008, 936 }, // Simplified Chinese + { 10029, 1250 }, // Central European (latin2) + }; + + int i; + int max = sizeof(codepage_remaps)/sizeof(codepage_remaps[0]); + for ( i=0; i