summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2009-08-30 22:44:39 +0200
committerGravatar waker <wakeroid@gmail.com>2009-08-30 22:44:39 +0200
commit19dddccb75541dcb8317f73bfbef31e0a357bea5 (patch)
treef4c8ffe25a870315031f2246c70df2538a4a4804 /plugins
parent7bb028b001df308a1934eaf5566c45c13dca6044 (diff)
ape support WIP
Diffstat (limited to 'plugins')
-rw-r--r--plugins/ape/Makefile.am7
-rw-r--r--plugins/ape/ape.c55
-rw-r--r--plugins/ape/apewrapper.cpp39
-rw-r--r--plugins/ape/apewrapper.h73
4 files changed, 174 insertions, 0 deletions
diff --git a/plugins/ape/Makefile.am b/plugins/ape/Makefile.am
new file mode 100644
index 00000000..b7d0b805
--- /dev/null
+++ b/plugins/ape/Makefile.am
@@ -0,0 +1,7 @@
+apedir = $(libdir)/$(PACKAGE)
+pkglib_LTLIBRARIES = ape.la
+ape_la_SOURCES = ape.c apewrapper.cpp apewrapper.h
+ape_la_LDFLAGS = -module
+
+ape_la_LIBADD = $(LDADD) $(APE_DEPS_LIBS) -lmac
+AM_CFLAGS = $(APE_DEPS_CFLAGS) -std=c99
diff --git a/plugins/ape/ape.c b/plugins/ape/ape.c
new file mode 100644
index 00000000..8a84a248
--- /dev/null
+++ b/plugins/ape/ape.c
@@ -0,0 +1,55 @@
+#include "../../deadbeef.h"
+
+static DB_decoder_t plugin;
+static DB_functions_t *deadbeef;
+
+int
+ape_init (DB_playItem_t *it) {
+ return 0;
+}
+
+void
+ape_free (void) {
+}
+
+int
+ape_read (char *buffer, int size) {
+ return 0;
+}
+
+int
+ape_seek (float seconds) {
+}
+
+DB_playItem_t *
+ape_insert (DB_playItem_t *after, const char *fname) {
+}
+
+static const char * exts[] = { "ape", NULL };
+static const char *filetypes[] = { "APE", NULL };
+
+// define plugin interface
+static DB_decoder_t plugin = {
+ .plugin.version_major = 0,
+ .plugin.version_minor = 1,
+ .plugin.type = DB_PLUGIN_DECODER,
+ .plugin.name = "Monkey's Audio decoder",
+ .plugin.author = "Alexey Yakovenko",
+ .plugin.email = "waker@users.sourceforge.net",
+ .plugin.website = "http://deadbeef.sf.net",
+ .init = ape_init,
+ .free = ape_free,
+ .read_int16 = ape_read,
+ .seek = ape_seek,
+ .insert = ape_insert,
+ .exts = exts,
+ .id = "stdape",
+ .filetypes = filetypes
+};
+
+DB_plugin_t *
+oggvorbis_load (DB_functions_t *api) {
+ deadbeef = api;
+ return DB_PLUGIN (&plugin);
+}
+
diff --git a/plugins/ape/apewrapper.cpp b/plugins/ape/apewrapper.cpp
new file mode 100644
index 00000000..8cb46268
--- /dev/null
+++ b/plugins/ape/apewrapper.cpp
@@ -0,0 +1,39 @@
+#include <mac/All.h>
+#include <mac/GlobalFunctions.h>
+#include <mac/MACLib.h>
+#include <mac/CharacterHelper.h>
+#include <mac/APETag.h>
+#include "apewrapper.h"
+
+void *
+ape_decompress_create (const char *fname) {
+ int ret;
+ CSmartPtr<wchar_t> str;
+ str.Assign (GetUTF16FromUTF8 ((const str_utf8 *)fname), TRUE);
+ IAPEDecompress *dec = CreateIAPEDecompress(str, &ret);
+ return dec;
+}
+
+void
+ape_decompress_destroy (void *d) {
+ IAPEDecompress *dec = (IAPEDecompress *)d;
+ delete dec;
+}
+
+int
+ape_decompress_info (void *d, int id) {
+ IAPEDecompress *dec = (IAPEDecompress *)d;
+ return dec->GetInfo ((APE_DECOMPRESS_FIELDS)id);
+}
+
+int
+ape_decompress_getdata (void *d, char *buffer, int nblocks, int *retr) {
+ IAPEDecompress *dec = (IAPEDecompress *)d;
+ return dec->GetData (buffer, nblocks, retr);
+}
+
+int
+ape_decompress_seek (void *d, int nblockoffs) {
+ IAPEDecompress *dec = (IAPEDecompress *)d;
+ return dec->Seek (nblockoffs);
+}
diff --git a/plugins/ape/apewrapper.h b/plugins/ape/apewrapper.h
new file mode 100644
index 00000000..a5675798
--- /dev/null
+++ b/plugins/ape/apewrapper.h
@@ -0,0 +1,73 @@
+#ifndef __APEWRAPPER_H
+#define __APEWRAPPER_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef APE_MACLIB_H
+enum APE_DECOMPRESS_FIELDS
+{
+ APE_INFO_FILE_VERSION = 1000, // version of the APE file * 1000 (3.93 = 3930) [ignored, ignored]
+ APE_INFO_COMPRESSION_LEVEL = 1001, // compression level of the APE file [ignored, ignored]
+ APE_INFO_FORMAT_FLAGS = 1002, // format flags of the APE file [ignored, ignored]
+ APE_INFO_SAMPLE_RATE = 1003, // sample rate (Hz) [ignored, ignored]
+ APE_INFO_BITS_PER_SAMPLE = 1004, // bits per sample [ignored, ignored]
+ APE_INFO_BYTES_PER_SAMPLE = 1005, // number of bytes per sample [ignored, ignored]
+ APE_INFO_CHANNELS = 1006, // channels [ignored, ignored]
+ APE_INFO_BLOCK_ALIGN = 1007, // block alignment [ignored, ignored]
+ APE_INFO_BLOCKS_PER_FRAME = 1008, // number of blocks in a frame (frames are used internally) [ignored, ignored]
+ APE_INFO_FINAL_FRAME_BLOCKS = 1009, // blocks in the final frame (frames are used internally) [ignored, ignored]
+ APE_INFO_TOTAL_FRAMES = 1010, // total number frames (frames are used internally) [ignored, ignored]
+ APE_INFO_WAV_HEADER_BYTES = 1011, // header bytes of the decompressed WAV [ignored, ignored]
+ APE_INFO_WAV_TERMINATING_BYTES = 1012, // terminating bytes of the decompressed WAV [ignored, ignored]
+ APE_INFO_WAV_DATA_BYTES = 1013, // data bytes of the decompressed WAV [ignored, ignored]
+ APE_INFO_WAV_TOTAL_BYTES = 1014, // total bytes of the decompressed WAV [ignored, ignored]
+ APE_INFO_APE_TOTAL_BYTES = 1015, // total bytes of the APE file [ignored, ignored]
+ APE_INFO_TOTAL_BLOCKS = 1016, // total blocks of audio data [ignored, ignored]
+ APE_INFO_LENGTH_MS = 1017, // length in ms (1 sec = 1000 ms) [ignored, ignored]
+ APE_INFO_AVERAGE_BITRATE = 1018, // average bitrate of the APE [ignored, ignored]
+ APE_INFO_FRAME_BITRATE = 1019, // bitrate of specified APE frame [frame index, ignored]
+ APE_INFO_DECOMPRESSED_BITRATE = 1020, // bitrate of the decompressed WAV [ignored, ignored]
+ APE_INFO_PEAK_LEVEL = 1021, // peak audio level (obsolete) (-1 is unknown) [ignored, ignored]
+ APE_INFO_SEEK_BIT = 1022, // bit offset [frame index, ignored]
+ APE_INFO_SEEK_BYTE = 1023, // byte offset [frame index, ignored]
+ APE_INFO_WAV_HEADER_DATA = 1024, // error code [buffer *, max bytes]
+ APE_INFO_WAV_TERMINATING_DATA = 1025, // error code [buffer *, max bytes]
+ APE_INFO_WAVEFORMATEX = 1026, // error code [waveformatex *, ignored]
+ APE_INFO_IO_SOURCE = 1027, // I/O source (CIO *) [ignored, ignored]
+ APE_INFO_FRAME_BYTES = 1028, // bytes (compressed) of the frame [frame index, ignored]
+ APE_INFO_FRAME_BLOCKS = 1029, // blocks in a given frame [frame index, ignored]
+ APE_INFO_TAG = 1030, // point to tag (CAPETag *) [ignored, ignored]
+
+ APE_DECOMPRESS_CURRENT_BLOCK = 2000, // current block location [ignored, ignored]
+ APE_DECOMPRESS_CURRENT_MS = 2001, // current millisecond location [ignored, ignored]
+ APE_DECOMPRESS_TOTAL_BLOCKS = 2002, // total blocks in the decompressors range [ignored, ignored]
+ APE_DECOMPRESS_LENGTH_MS = 2003, // total blocks in the decompressors range [ignored, ignored]
+ APE_DECOMPRESS_CURRENT_BITRATE = 2004, // current bitrate [ignored, ignored]
+ APE_DECOMPRESS_AVERAGE_BITRATE = 2005, // average bitrate (works with ranges) [ignored, ignored]
+
+ APE_INTERNAL_INFO = 3000 // for internal use -- don't use (returns APE_FILE_INFO *) [ignored, ignored]
+};
+#endif
+
+void *
+ape_decompress_create (const char *fname);
+
+void
+ape_decompress_destroy (void *d);
+
+int
+ape_decompress_info (void *d, int id);
+
+int
+ape_decompress_getdata (void *d, char *buffer, int nblocks, int *retr);
+
+int
+ape_decompress_seek (void *d, int nblockoffs);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // __APEWRAPPER_H