]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - wav_filter.c
Add btr support to filter code.
[paraslash.git] / wav_filter.c
index b7329c48bce647b113638a5609b39de698ef81fd..eada2434d8be0dc08a1c7d9cacef8e386278d037 100644 (file)
@@ -6,11 +6,15 @@
 
 /** \file wav_filter.c A filter that inserts a wave header. */
 
-#include "para.h"
+#include <regex.h>
+#include <stdbool.h>
 
+#include "para.h"
+#include "error.h"
 #include "list.h"
 #include "sched.h"
 #include "ggo.h"
+#include "buffer_tree.h"
 #include "filter.h"
 #include "string.h"
 #include "portable_io.h"
@@ -31,7 +35,6 @@ static void make_wav_header(unsigned int channels, unsigned int samplerate,
        int bytespersec = channels * samplerate * BITS / 8;
        int align = channels * BITS / 8;
 
-       assert(channels);
        PARA_DEBUG_LOG("writing wave header: %d channels, %d KHz\n", channels, samplerate);
        memset(headbuf, 0, WAV_HEADER_LEN);
        memcpy(headbuf, "RIFF", 4);
@@ -57,6 +60,10 @@ static ssize_t wav_convert(char *inbuf, size_t len, struct filter_node *fn)
        if (*bof) {
                if (!len)
                        return 0;
+               if (!fn->fc->channels || !fn->fc->samplerate) {
+                       PARA_ERROR_LOG("%s\n", para_strerror(E_WAV_BAD_FC));
+                       return -E_WAV_BAD_FC;
+               }
                make_wav_header(fn->fc->channels, fn->fc->samplerate, fn);
                fn->loaded = WAV_HEADER_LEN;
                *bof = 0;