Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/io/source_sndfile.c

    rd5745af r48ebc3b  
    1919*/
    2020
    21 
    22 #include "config.h"
     21#include "aubio_priv.h"
    2322
    2423#ifdef HAVE_SNDFILE
     
    2625#include <sndfile.h>
    2726
    28 #include "aubio_priv.h"
    2927#include "fvec.h"
    3028#include "fmat.h"
     
    3331#include "temporal/resampler.h"
    3432
    35 #define MAX_CHANNELS 6
    3633#define MAX_SIZE 4096
    37 #define MAX_SAMPLES MAX_CHANNELS * MAX_SIZE
     34#define MAX_SAMPLES AUBIO_MAX_CHANNELS * MAX_SIZE
    3835
    3936#if !HAVE_AUBIO_DOUBLE
     
    141138    if (s->ratio > 1) {
    142139      // we would need to add a ring buffer for these
    143       if ( (uint_t)(s->input_hop_size * s->ratio + .5)  != s->hop_size ) {
     140      if ( (uint_t)FLOOR(s->input_hop_size * s->ratio + .5)  != s->hop_size ) {
    144141        AUBIO_ERR("source_sndfile: can not upsample %s from %d to %d\n", s->path,
    145142            s->input_samplerate, s->samplerate);
     
    298295uint_t aubio_source_sndfile_seek (aubio_source_sndfile_t * s, uint_t pos) {
    299296  uint_t resampled_pos = (uint_t)ROUND(pos / s->ratio);
    300   sf_count_t sf_ret = sf_seek (s->handle, resampled_pos, SEEK_SET);
     297  sf_count_t sf_ret;
     298  if (s->handle == NULL) {
     299    AUBIO_ERR("source_sndfile: failed seeking in %s (file not opened?)\n",
     300        s->path);
     301    return AUBIO_FAIL;
     302  }
     303  if ((sint_t)pos < 0) {
     304    AUBIO_ERR("source_sndfile: could not seek %s at %d (seeking position"
     305       " should be >= 0)\n", s->path, pos);
     306    return AUBIO_FAIL;
     307  }
     308  sf_ret = sf_seek (s->handle, resampled_pos, SEEK_SET);
    301309  if (sf_ret == -1) {
    302310    AUBIO_ERR("source_sndfile: Failed seeking %s at %d: %s\n", s->path, pos, sf_strerror (NULL));
     
    313321uint_t aubio_source_sndfile_close (aubio_source_sndfile_t *s) {
    314322  if (!s->handle) {
    315     return AUBIO_FAIL;
     323    return AUBIO_OK;
    316324  }
    317325  if(sf_close(s->handle)) {
Note: See TracChangeset for help on using the changeset viewer.