audio/pcmconv: check number of input channels

This commit is contained in:
cinap_lenrek 2012-12-11 21:02:14 +01:00
parent 45a5074b10
commit bedfd8f361

View file

@ -421,6 +421,9 @@ main(int argc, char *argv[])
exits(0); exits(0);
} }
if(i.channels > nelem(ch))
sysfatal("too many input channels %d", i.channels);
switch(i.fmt){ switch(i.fmt){
case 's': iconv = siconv; break; case 's': iconv = siconv; break;
case 'u': iconv = uiconv; break; case 'u': iconv = uiconv; break;
@ -444,14 +447,14 @@ main(int argc, char *argv[])
obuf = sbrk(o.framesz * m); obuf = sbrk(o.framesz * m);
memset(ch, 0, sizeof(ch)); memset(ch, 0, sizeof(ch));
for(k=0; k < i.channels && k < nelem(ch); k++) for(k=0; k < i.channels; k++)
chaninit(&ch[k], i.rate, o.rate, n); chaninit(&ch[k], i.rate, o.rate, n);
for(;;){ for(;;){
if(l >= 0 && l < r) if(l >= 0 && l < r)
r = l; r = l;
n = cread(0, ibuf, r, i.framesz); n = cread(0, ibuf, r, i.framesz);
if(n < 0 || n > sizeof(ibuf)) if(n < 0)
sysfatal("read: %r"); sysfatal("read: %r");
if(l > 0) if(l > 0)
l -= n; l -= n;