diff options
Diffstat (limited to 'apps/codecs/libpcm/itut_g711.c')
-rw-r--r-- | apps/codecs/libpcm/itut_g711.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/apps/codecs/libpcm/itut_g711.c b/apps/codecs/libpcm/itut_g711.c index 4644a9c694..097dd5cc25 100644 --- a/apps/codecs/libpcm/itut_g711.c +++ b/apps/codecs/libpcm/itut_g711.c @@ -112,6 +112,12 @@ static bool set_format(struct pcm_format *format) { fmt = format; + if (fmt->channels == 0) + { + DEBUGF("CODEC_ERROR: channels is 0\n"); + return false; + } + if (fmt->bitspersample != 8) { DEBUGF("CODEC_ERROR: alaw and mulaw must have 8 bitspersample: %d\n", @@ -119,13 +125,12 @@ static bool set_format(struct pcm_format *format) return false; } - if (fmt->totalsamples == 0) - { - fmt->bytespersample = 1; - fmt->totalsamples = fmt->numbytes / (fmt->bytespersample * fmt->channels); - } + fmt->bytespersample = 1; + + if (fmt->blockalign == 0) + fmt->blockalign = fmt->channels; - fmt->samplesperblock = fmt->blockalign / (fmt->bytespersample * fmt->channels); + fmt->samplesperblock = fmt->blockalign / fmt->channels; /* chunksize = about 1/50[sec] data */ fmt->chunksize = (ci->id3->frequency / (50 * fmt->samplesperblock)) |