# HG changeset patch # User William Pitcock # Date 1187368830 18000 # Node ID 04f8c7624ea397be23e6cff21c7417e0313a28d3 # Parent ae78c9753da87ea714e860e84101a450cdf6db92 Support Wavpack ".exe" executables, by using the Wavpack decoder to validate. This bumps our required version of libwavpack to 4.4. diff -r ae78c9753da8 -r 04f8c7624ea3 src/wavpack/libwavpack.cxx --- 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; }