Changeset 4eb48e6 for src


Ignore:
Timestamp:
Dec 16, 2018, 7:09:13 PM (5 months ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/timestretch, master
Children:
4f75d8a
Parents:
b5de3a9
Message:

[io] validate input in sink_apple_audio_do

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/io/sink_apple_audio.c

    rb5de3a9 r4eb48e6  
    176176  UInt32 c, v;
    177177  short *data = (short*)s->bufferList.mBuffers[0].mData;
    178   if (write > s->max_frames) {
    179     AUBIO_WRN("sink_apple_audio: trying to write %d frames, max %d\n", write, s->max_frames);
    180     write = s->max_frames;
    181   }
    182   smpl_t *buf = write_data->data;
    183 
    184   if (buf) {
    185       for (c = 0; c < s->channels; c++) {
    186           for (v = 0; v < write; v++) {
    187               data[v * s->channels + c] =
    188                   FLOAT_TO_SHORT(buf[ v * s->channels + c]);
    189           }
    190       }
    191   }
    192   aubio_sink_apple_audio_write(s, write);
     178  uint_t length = aubio_sink_validate_input_length("sink_apple_audio", s->path,
     179      s->max_frames, write_data->length, write);
     180
     181  for (c = 0; c < s->channels; c++) {
     182    for (v = 0; v < length; v++) {
     183      data[v * s->channels + c] = FLOAT_TO_SHORT(write_data->data[v]);
     184    }
     185  }
     186
     187  aubio_sink_apple_audio_write(s, length);
    193188}
    194189
     
    196191  UInt32 c, v;
    197192  short *data = (short*)s->bufferList.mBuffers[0].mData;
    198   if (write > s->max_frames) {
    199     AUBIO_WRN("sink_apple_audio: trying to write %d frames, max %d\n", write, s->max_frames);
    200     write = s->max_frames;
    201   }
    202   smpl_t **buf = write_data->data;
    203 
    204   if (buf) {
    205       for (c = 0; c < s->channels; c++) {
    206           for (v = 0; v < write; v++) {
    207               data[v * s->channels + c] =
    208                   FLOAT_TO_SHORT(buf[c][v]);
    209           }
    210       }
    211   }
    212   aubio_sink_apple_audio_write(s, write);
     193  uint_t channels = aubio_sink_validate_input_channels("sink_apple_audio",
     194      s->path, s->channels, write_data->height);
     195  uint_t length = aubio_sink_validate_input_length("sink_apple_audio", s->path,
     196      s->max_frames, write_data->length, write);
     197
     198  for (c = 0; c < channels; c++) {
     199    for (v = 0; v < length; v++) {
     200      data[v * s->channels + c] = FLOAT_TO_SHORT(write_data->data[c][v]);
     201    }
     202  }
     203
     204  aubio_sink_apple_audio_write(s, length);
    213205}
    214206
Note: See TracChangeset for help on using the changeset viewer.