Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

82 lines (67 sloc) 2.372 kB
#ifndef NODE_TAGLIB_H
#define NODE_TAGLIB_H
#include <fileref.h>
#include <tag.h>
#include <node.h>
#include <uv.h>
#include <sys/time.h>
#include <node_version.h>
#if NODE_VERSION_AT_LEAST(0, 7, 0)
#define ENABLE_RESOLVERS
#endif
namespace node_taglib {
class Tag;
class BufferStream;
/**
* Note: This uses TagLib's internal file type resolvers
* use CreateFileRef with a FileStream if the format is known
*/
int CreateFileRefPath(TagLib::FileName path, TagLib::FileRef **ref);
int CreateFileRef(TagLib::IOStream *stream, TagLib::String format, TagLib::FileRef **ref);
static TagLib::File *createFile(TagLib::IOStream *stream, TagLib::String format);
v8::Handle<v8::String> ErrorToString(int error);
v8::Handle<v8::Value> TagLibStringToString( TagLib::String s );
TagLib::String NodeStringToTagLibString( v8::Local<v8::Value> s );
v8::Handle<v8::Value> AsyncReadFile(const v8::Arguments &args);
void AsyncReadFileDo(uv_work_t *req);
void AsyncReadFileAfter(uv_work_t *req);
struct AsyncBaton {
uv_work_t request;
v8::Persistent<v8::Function> callback;
int error;
TagLib::FileName path; /* only used by read/tag, not save */
// OR
TagLib::String format;
BufferStream *stream; // File takes over ownership of the stream
// and FileRef takes over ownership of the File
// so don't do BufferStream deletion
TagLib::FileRef *fileRef; /* only used by taglib.read */
Tag *tag; /* only used by taglib.tag */
};
#ifdef ENABLE_RESOLVERS
v8::Handle<v8::Value> AddResolvers(const v8::Arguments &args);
class CallbackResolver;
struct AsyncResolverBaton {
uv_async_t request;
uv_mutex_t mutex;
#ifdef _WIN32
CONDITION_VARIABLE cv;
#else
pthread_cond_t cv;
#endif
const CallbackResolver *resolver;
TagLib::FileName fileName;
TagLib::String type;
};
class CallbackResolver : public TagLib::FileRef::FileTypeResolver {
v8::Persistent<v8::Function> resolverFunc;
const uv_thread_t created_in;
public:
CallbackResolver(v8::Persistent<v8::Function> func);
TagLib::File *createFile(TagLib::FileName fileName, bool readAudioProperties, TagLib::AudioProperties::ReadStyle audioPropertiesStyle) const;
static void invokeResolverCb(uv_async_t *handle, int status);
static void invokeResolver(AsyncResolverBaton *baton);
};
#endif
}
#endif
Jump to Line
Something went wrong with that request. Please try again.