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_apple_audio.c

    rc8e08c2 rcf19b8a  
    2727#include "fmat.h"
    2828#include "io/sink_apple_audio.h"
     29#include "io/ioutils.h"
    2930
    3031// CFURLRef, CFURLCreateWithFileSystemPath, ...
     
    7475  s->channels = 0;
    7576
    76   // negative samplerate given, abort
    77   if ((sint_t)samplerate < 0) goto beach;
    7877  // zero samplerate given. do not open yet
    79   if ((sint_t)samplerate == 0) return s;
     78  if ((sint_t)samplerate == 0) {
     79    return s;
     80  }
     81  // invalid samplerate given, abort
     82  if (aubio_io_validate_samplerate("sink_apple_audio", s->path, samplerate)) {
     83    goto beach;
     84  }
    8085
    8186  s->samplerate = samplerate;
     
    95100uint_t aubio_sink_apple_audio_preset_samplerate(aubio_sink_apple_audio_t *s, uint_t samplerate)
    96101{
    97   if ((sint_t)(samplerate) <= 0) return AUBIO_FAIL;
     102  if (aubio_io_validate_samplerate("sink_apple_audio", s->path, samplerate)) {
     103    return AUBIO_FAIL;
     104  }
    98105  s->samplerate = samplerate;
    99106  // automatically open when both samplerate and channels have been set
     
    106113uint_t aubio_sink_apple_audio_preset_channels(aubio_sink_apple_audio_t *s, uint_t channels)
    107114{
    108   if ((sint_t)(channels) <= 0) return AUBIO_FAIL;
     115  if (aubio_io_validate_channels("sink_apple_audio", s->path, channels)) {
     116    return AUBIO_FAIL;
     117  }
    109118  s->channels = channels;
    110119  // automatically open when both samplerate and channels have been set
Note: See TracChangeset for help on using the changeset viewer.