diff --git a/taglib/toolkit/taglib.h b/taglib/toolkit/taglib.h index 65a0c0b2..a43cdb6d 100644 --- a/taglib/toolkit/taglib.h +++ b/taglib/toolkit/taglib.h @@ -44,6 +44,12 @@ #include +#ifdef __APPLE__ +#include +#elif defined(_MSC_VER) +#include +#endif + //! A namespace for all TagLib related classes and functions /*! @@ -81,11 +87,27 @@ namespace TagLib { { public: RefCounter() : refCount(1) {} + +#ifdef __APPLE__ + void ref() { OSAtomicIncrement32(&refCount); } + bool deref() { return ! OSAtomicDecrement32(&refCount); } + int32_t count() { return refCount; } + private: + volatile int32_t refCount; +#elif defined(_MSC_VER) + void ref() { InterlockedIncrement(&refCount); } + bool deref() { return ! InterlockedDecrement(&refCount); } + long count() { return refCount; } + private: + volatile long refCount; +#else void ref() { refCount++; } bool deref() { return ! --refCount ; } int count() { return refCount; } private: uint refCount; +#endif + }; #endif // DO_NOT_DOCUMENT diff --git a/taglib/toolkit/tfile.cpp b/taglib/toolkit/tfile.cpp index f0b3c80d..7ba4c00c 100644 --- a/taglib/toolkit/tfile.cpp +++ b/taglib/toolkit/tfile.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #ifdef _WIN32 # include @@ -115,7 +116,10 @@ File::FilePrivate::FilePrivate(FileName fileName) : file = fopen(name, "rb"); if(!file) + { debug("Could not open file " + String((const char *) name)); + std::cout<<"Could not open file"<