Changeset 85e20fa for src/io/ioutils.c


Ignore:
Timestamp:
Dec 20, 2018, 5:21:19 PM (2 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/timestretch, master
Children:
14a5b9a
Parents:
b2e1740
Message:

[io] add helpers to check source output sizes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/io/ioutils.c

    rb2e1740 r85e20fa  
    5454
    5555uint_t
     56aubio_source_validate_input_length(const char_t *kind, const char_t *path,
     57    uint_t hop_size, uint_t read_data_length)
     58{
     59  uint_t length = hop_size;
     60  if (hop_size < read_data_length) {
     61    AUBIO_WRN("%s: partial read from %s, trying to read %d frames, but"
     62        " hop_size is %d\n", kind, path, read_data_length, hop_size);
     63  } else if (hop_size > read_data_length) {
     64    AUBIO_WRN("%s: partial read from %s, trying to read %d frames into"
     65        " a buffer of length %d\n", kind, path, hop_size, read_data_length);
     66    length = read_data_length;
     67  }
     68  return length;
     69}
     70
     71uint_t
     72aubio_source_validate_input_channels(const char_t *kind, const char_t *path,
     73    uint_t source_channels, uint_t read_data_height)
     74{
     75  uint_t channels = source_channels;
     76  if (read_data_height < source_channels) {
     77    AUBIO_WRN("%s: partial read from %s, trying to read %d channels,"
     78        " but found output of height %d\n", kind, path, source_channels,
     79        read_data_height);
     80    channels = read_data_height;
     81  } else if (read_data_height > source_channels) {
     82    // do not show a warning when trying to read into more channels than
     83    // the input source.
     84#if 0
     85    AUBIO_WRN("%s: partial read from %s, trying to read %d channels,"
     86        " but found output of height %d\n", kind, path, source_channels,
     87        read_data_height);
     88#endif
     89    channels = source_channels;
     90  }
     91  return channels;
     92}
     93
     94uint_t
    5695aubio_sink_validate_input_length(const char_t *kind, const char_t *path,
    5796    uint_t max_size, uint_t write_data_length, uint_t write)
Note: See TracChangeset for help on using the changeset viewer.