summaryrefslogtreecommitdiff
path: root/apps/codecs/libpcm/linear_pcm.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libpcm/linear_pcm.c')
-rw-r--r--apps/codecs/libpcm/linear_pcm.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/apps/codecs/libpcm/linear_pcm.c b/apps/codecs/libpcm/linear_pcm.c
index 82c70eb3b6..e58856efe8 100644
--- a/apps/codecs/libpcm/linear_pcm.c
+++ b/apps/codecs/libpcm/linear_pcm.c
@@ -38,6 +38,18 @@ 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 == 0)
+ {
+ DEBUGF("CODEC_ERROR: bitspersample is 0\n");
+ return false;
+ }
+
if (fmt->bitspersample > 32)
{
DEBUGF("CODEC_ERROR: pcm with more than 32 bitspersample "
@@ -47,8 +59,8 @@ static bool set_format(struct pcm_format *format)
fmt->bytespersample = fmt->bitspersample >> 3;
- if (fmt->totalsamples == 0)
- fmt->totalsamples = fmt->numbytes/fmt->bytespersample;
+ if (fmt->blockalign == 0)
+ fmt->blockalign = fmt->bytespersample * fmt->channels;
fmt->samplesperblock = fmt->blockalign / (fmt->bytespersample * fmt->channels);