Skip to content

Commit

Permalink
avr: use calloc to avoid set 0 and no warning
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Dec 16, 2013
1 parent 509d61b commit 28920f4
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/AudioResamplerLibav.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,35 +180,31 @@ bool AudioResamplerLibav::prepare()
double *matrix = 0;
if (d.out_format.channelLayout() == AudioFormat::ChannelLayout_Left) {
remix = true;
matrix = new double[in_c*out_c];
memset(matrix, 0, sizeof(matrix));
matrix = (double*)calloc(in_c*out_c, sizeof(double));
for (int o = 0; o < out_c; ++o) {
matrix[0 + in_c * o] = 1;
}
}
if (d.out_format.channelLayout() == AudioFormat::ChannelLayout_Right) {
remix = true;
matrix = new double[in_c*out_c];
memset(matrix, 0, sizeof(matrix));
matrix = (double*)calloc(in_c*out_c, sizeof(double));
for (int o = 0; o < out_c; ++o) {
matrix[1 + in_c * o] = 1;
}
}
if (!remix && in_c < out_c) {
remix = true;
//double matrix[in_c*out_c]; //C99, VLA
matrix = new double[in_c*out_c];
memset(matrix, 0, sizeof(matrix));
matrix = (double*)calloc(in_c*out_c, sizeof(double));
for (int i = 0, o = 0; o < out_c; ++o) {
matrix[i + in_c * o] = 1;
i = (i + i)%in_c;
}
}
if (remix && matrix) {
avresample_set_matrix(d.context, matrix, in_c);
delete [] matrix;
free(matrix);
}

#else
bool use_channel_map = false;
if (d.out_format.channelLayout() == AudioFormat::ChannelLayout_Left) {
Expand Down

0 comments on commit 28920f4

Please sign in to comment.