From 4eb7cc7bc9e458ba3aa6d1338b5710d45a42927e Mon Sep 17 00:00:00 2001 From: David Bryant Date: Fri, 28 May 2010 20:18:46 -0700 Subject: add support for WavPack correction files --- plugins/wavpack/wavpack.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'plugins/wavpack') diff --git a/plugins/wavpack/wavpack.c b/plugins/wavpack/wavpack.c index e2f9e43b..d0e743f4 100644 --- a/plugins/wavpack/wavpack.c +++ b/plugins/wavpack/wavpack.c @@ -34,7 +34,7 @@ static DB_functions_t *deadbeef; typedef struct { DB_fileinfo_t info; - DB_FILE *file; + DB_FILE *file, *c_file; WavpackContext *ctx; int startsample; int endsample; @@ -105,8 +105,15 @@ wv_init (DB_fileinfo_t *_info, DB_playItem_t *it) { if (!info->file) { return -1; } + + char *c_fname = malloc (strlen (it->fname) + 10); + strcpy (c_fname, it->fname); + strcat (c_fname, "c"); + info->c_file = deadbeef->fopen (c_fname); + free (c_fname); + char error[80]; - info->ctx = WavpackOpenFileInputEx (&wsr, info->file, NULL, error, OPEN_2CH_MAX/*|OPEN_WVC*/, 0); + info->ctx = WavpackOpenFileInputEx (&wsr, info->file, info->c_file, error, OPEN_2CH_MAX, 0); if (!info->ctx) { fprintf (stderr, "wavpack error: %s\n", error); return -1; @@ -138,6 +145,10 @@ wv_free (DB_fileinfo_t *_info) { deadbeef->fclose (info->file); info->file = NULL; } + if (info->c_file) { + deadbeef->fclose (info->c_file); + info->c_file = NULL; + } if (info->ctx) { WavpackCloseFile (info->ctx); info->ctx = NULL; -- cgit v1.2.3