Ignore:
Timestamp:
Nov 29, 2016, 12:06:21 PM (7 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, sampler, yinfft+
Children:
bb96d02
Parents:
c8e08c2
Message:

src/io/ioutils.h: add functions to check samplerate and channels, use in sink_*.c

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/io/sink_sndfile.c

    rc8e08c2 rcf19b8a  
    3030#include "fmat.h"
    3131#include "io/sink_sndfile.h"
     32#include "io/ioutils.h"
    3233
    3334#define MAX_CHANNELS 6
     
    7071  s->channels = 0;
    7172
    72   // negative samplerate given, abort
    73   if ((sint_t)samplerate < 0) goto beach;
    7473  // zero samplerate given. do not open yet
    75   if ((sint_t)samplerate == 0) return s;
     74  if ((sint_t)samplerate == 0) {
     75    return s;
     76  }
     77  // invalid samplerate given, abort
     78  if (aubio_io_validate_samplerate("sink_sndfile", s->path, samplerate)) {
     79    goto beach;
     80  }
    7681
    7782  s->samplerate = samplerate;
     
    9095uint_t aubio_sink_sndfile_preset_samplerate(aubio_sink_sndfile_t *s, uint_t samplerate)
    9196{
    92   if ((sint_t)(samplerate) <= 0) return AUBIO_FAIL;
     97  if (aubio_io_validate_samplerate("sink_sndfile", s->path, samplerate)) {
     98    return AUBIO_FAIL;
     99  }
    93100  s->samplerate = samplerate;
    94101  // automatically open when both samplerate and channels have been set
     
    101108uint_t aubio_sink_sndfile_preset_channels(aubio_sink_sndfile_t *s, uint_t channels)
    102109{
    103   if ((sint_t)(channels) <= 0) return AUBIO_FAIL;
     110  if (aubio_io_validate_channels("sink_sndfile", s->path, channels)) {
     111    return AUBIO_FAIL;
     112  }
    104113  s->channels = channels;
    105114  // automatically open when both samplerate and channels have been set
Note: See TracChangeset for help on using the changeset viewer.