Changes in src/io/sink_sndfile.c [d2be104:33d0242]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/io/sink_sndfile.c
rd2be104 r33d0242 20 20 21 21 22 #include " config.h"22 #include "aubio_priv.h" 23 23 24 24 #ifdef HAVE_SNDFILE … … 26 26 #include <sndfile.h> 27 27 28 #include "aubio_priv.h"29 28 #include "fvec.h" 30 29 #include "fmat.h" 31 30 #include "io/sink_sndfile.h" 32 33 #define MAX_CHANNELS 6 31 #include "io/ioutils.h" 32 34 33 #define MAX_SIZE 4096 35 34 … … 70 69 s->channels = 0; 71 70 72 // negative samplerate given, abort73 if ((sint_t)samplerate < 0) goto beach;74 71 // zero samplerate given. do not open yet 75 if ((sint_t)samplerate == 0) return s; 72 if ((sint_t)samplerate == 0) { 73 return s; 74 } 75 // invalid samplerate given, abort 76 if (aubio_io_validate_samplerate("sink_sndfile", s->path, samplerate)) { 77 goto beach; 78 } 76 79 77 80 s->samplerate = samplerate; … … 90 93 uint_t aubio_sink_sndfile_preset_samplerate(aubio_sink_sndfile_t *s, uint_t samplerate) 91 94 { 92 if ((sint_t)(samplerate) <= 0) return AUBIO_FAIL; 95 if (aubio_io_validate_samplerate("sink_sndfile", s->path, samplerate)) { 96 return AUBIO_FAIL; 97 } 93 98 s->samplerate = samplerate; 94 99 // automatically open when both samplerate and channels have been set … … 101 106 uint_t aubio_sink_sndfile_preset_channels(aubio_sink_sndfile_t *s, uint_t channels) 102 107 { 103 if ((sint_t)(channels) <= 0) return AUBIO_FAIL; 108 if (aubio_io_validate_channels("sink_sndfile", s->path, channels)) { 109 return AUBIO_FAIL; 110 } 104 111 s->channels = channels; 105 112 // automatically open when both samplerate and channels have been set … … 133 140 if (s->handle == NULL) { 134 141 /* show libsndfile err msg */ 135 AUBIO_ERR("sink_sndfile: Failed opening %s. %s\n", s->path, sf_strerror (NULL)); 142 AUBIO_ERR("sink_sndfile: Failed opening \"%s\" with %d channels, %dHz: %s\n", 143 s->path, s->channels, s->samplerate, sf_strerror (NULL)); 136 144 return AUBIO_FAIL; 137 145 } … … 139 147 s->scratch_size = s->max_size*s->channels; 140 148 /* allocate data for de/interleaving reallocated when needed. */ 141 if (s->scratch_size >= MAX_SIZE * MAX_CHANNELS) { 149 if (s->scratch_size >= MAX_SIZE * AUBIO_MAX_CHANNELS) { 150 abort(); 142 151 AUBIO_ERR("sink_sndfile: %d x %d exceeds maximum aubio_sink_sndfile buffer size %d\n", 143 s->max_size, s->channels, MAX_ CHANNELS *MAX_CHANNELS);152 s->max_size, s->channels, MAX_SIZE * AUBIO_MAX_CHANNELS); 144 153 return AUBIO_FAIL; 145 154 }
Note: See TracChangeset
for help on using the changeset viewer.