#include <errno.h> // errno
#include <time.h> // time
+#define MAX_SIZE 2048
+
struct _aubio_sink_vorbis_t {
FILE *fid; // file id
ogg_stream_state os; // stream
uint_t write)
{
uint_t c, v;
- float **buffer = vorbis_analysis_buffer(&s->vd, (long)write);
+ uint_t length = aubio_sink_validate_input_length("sink_vorbis", s->path,
+ MAX_SIZE, write_data->length, write);
+ float **buffer = vorbis_analysis_buffer(&s->vd, (long)length);
// fill buffer
if (!write) {
return;
return;
} else {
for (c = 0; c < s->channels; c++) {
- for (v = 0; v < write; v++) {
+ for (v = 0; v < length; v++) {
buffer[c][v] = write_data->data[v];
}
}
// tell vorbis how many frames were written
- vorbis_analysis_wrote(&s->vd, (long)write);
+ vorbis_analysis_wrote(&s->vd, (long)length);
}
// write to file
aubio_sink_vorbis_write(s);
uint_t write)
{
uint_t c, v;
- uint_t channels = MIN(s->channels, write_data->height);
- float **buffer = vorbis_analysis_buffer(&s->vd, (long)write);
+ uint_t channels = aubio_sink_validate_input_channels("sink_vorbis", s->path,
+ s->channels, write_data->height);
+ uint_t length = aubio_sink_validate_input_length("sink_vorbis", s->path,
+ MAX_SIZE, write_data->length, write);
+ float **buffer = vorbis_analysis_buffer(&s->vd, (long)length);
// fill buffer
if (!write) {
return;
return;
} else {
for (c = 0; c < channels; c++) {
- for (v = 0; v < write; v++) {
+ for (v = 0; v < length; v++) {
buffer[c][v] = write_data->data[c][v];
}
}