summaryrefslogtreecommitdiff
path: root/apps/codecs/libpcm/itut_g711.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libpcm/itut_g711.c')
-rw-r--r--apps/codecs/libpcm/itut_g711.c17
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)
112{ 112{
113 fmt = format; 113 fmt = format;
114 114
115 if (fmt->channels == 0)
116 {
117 DEBUGF("CODEC_ERROR: channels is 0\n");
118 return false;
119 }
120
115 if (fmt->bitspersample != 8) 121 if (fmt->bitspersample != 8)
116 { 122 {
117 DEBUGF("CODEC_ERROR: alaw and mulaw must have 8 bitspersample: %d\n", 123 DEBUGF("CODEC_ERROR: alaw and mulaw must have 8 bitspersample: %d\n",
@@ -119,13 +125,12 @@ static bool set_format(struct pcm_format *format)
119 return false; 125 return false;
120 } 126 }
121 127
122 if (fmt->totalsamples == 0) 128 fmt->bytespersample = 1;
123 { 129
124 fmt->bytespersample = 1; 130 if (fmt->blockalign == 0)
125 fmt->totalsamples = fmt->numbytes / (fmt->bytespersample * fmt->channels); 131 fmt->blockalign = fmt->channels;
126 }
127 132
128 fmt->samplesperblock = fmt->blockalign / (fmt->bytespersample * fmt->channels); 133 fmt->samplesperblock = fmt->blockalign / fmt->channels;
129 134
130 /* chunksize = about 1/50[sec] data */ 135 /* chunksize = about 1/50[sec] data */
131 fmt->chunksize = (ci->id3->frequency / (50 * fmt->samplesperblock)) 136 fmt->chunksize = (ci->id3->frequency / (50 * fmt->samplesperblock))