Mercurial > audlegacy-plugins
changeset 1501:04f8c7624ea3
Support Wavpack ".exe" executables, by using the Wavpack decoder to validate.
This bumps our required version of libwavpack to 4.4.
author | William Pitcock <nenolod@atheme-project.org> |
---|---|
date | Fri, 17 Aug 2007 11:40:30 -0500 |
parents | ae78c9753da8 |
children | 45e2325fd07f |
files | src/wavpack/libwavpack.cxx |
diffstat | 1 files changed, 20 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/wavpack/libwavpack.cxx Mon Aug 13 06:08:08 2007 -0500 +++ b/src/wavpack/libwavpack.cxx Fri Aug 17 11:40:30 2007 -0500 @@ -204,6 +204,18 @@ return true; } + bool attach(gchar *filename, VFSFile *wv_Input) + { + vfs_dup(wv_Input); + + ctx = WavpackOpenFileInputEx(&reader, wv_Input, NULL, error_buff, OPEN_TAGS, 0); + + if (ctx == NULL) + return false; + + return true; + } + bool attach_to_play(const char *filename) { wv_Input = vfs_fopen(filename, "rb"); @@ -216,9 +228,8 @@ ctx = WavpackOpenFileInputEx(&reader, wv_Input, wvc_Input, error_buff, OPEN_TAGS | OPEN_WVC, 0); - if (ctx == NULL) { + if (ctx == NULL) return false; - } sample_rate = WavpackGetSampleRate(ctx); num_channels = WavpackGetNumChannels(ctx); @@ -238,9 +249,10 @@ void process_buffer(size_t num_samples) { - for (int i = 0; i < num_samples * num_channels; i++) { + /* TODO: dithering */ + for (int i = 0; i < num_samples * num_channels; i++) output[i] = input[i]; - } + produce_audio(mod->output->output_time(), FMT_S16_NE, num_channels, num_samples * num_channels * sizeof(int16_t), @@ -256,10 +268,11 @@ static int wv_is_our_fd(gchar *filename, VFSFile *file) { - gchar magic[4]; - vfs_fread(magic,1,4,file); - if (!memcmp(magic,"wvpk",4)) + WavpackDecoder d(&mod); + + if (d.attach(filename, file)) return TRUE; + return FALSE; }