[mad-dev] mad on arm processor -- strange problems.

Reza Naima reza@reza.net
Mon, 27 May 2002 15:58:49 -0700


Output of what?  The output of scale is a signed int, which then gets 
copied to a char array, then to a ringbuffer..

int rio_mad_output(void *ptr, struct mad_header const *header, struct
		mad_pcm *pcm) {
         unsigned int nchannels, nsamples;
         mad_fixed_t const *left_ch, *right_ch;
         char *outbuffer;
         int i;
         signed int sample;
         r_glue *g = ptr;

         /* pcm->samplerate contains the sampling frequency */

         if (g->decode_status == DECODE) {
                 nchannels = pcm->channels;
                 nsamples  = pcm->length;
                 left_ch   = pcm->samples[0];
                 right_ch  = pcm->samples[1];

                 outbuffer = (char*) malloc(sizeof(char) *
				nsamples * nchannels * 2);
			[ ..sanity checks.. ]
                 for (i=0; i<(nsamples*4); i+=4) {
                         sample = rio_mad_scale(*left_ch++);
                         outbuffer[i] = (sample >> 0) & 0xff;
                         outbuffer[i+1] = (sample >> 8) & 0xff;
                         if (nchannels == 2)
                                 sample = rio_mad_scale(*right_ch++);
                         outbuffer[i+2] = (sample >> 0) & 0xff;
                         outbuffer[i+3] = (sample >> 8) & 0xff;
                 }
                 rio_ringbuffer_write(g->ringbuffer, outbuffer,
				 nsamples*nchannels*2);
                 free(outbuffer);
                 return MAD_FLOW_CONTINUE;
         } else  if (g->decode_status == CLEAR) {
                 return MAD_FLOW_STOP;
         }
         return MAD_FLOW_BREAK;

}

It's probably something simple that I'm missing, and that's the worst 
part of it.

Reza

Joe Drew wrote:
> On Mon, 2002-05-27 at 18:01, Reza Naima wrote:
> 
>>However, it still sounds like shit.  It makes a clicking/swooshing sound 
>>at about 4Hz, but you can clearly hear the audio in the background. 
>>Could this be a result of the simplified scale() function in minimad 
>>(which I'm currently using?)
> 
> 
> Probably not. The scale() function isn't optimal, but isn't *that* bad.
> 
> I remember something similar happening with mpg321. Make sure you're
> using signed ints for output (I believe signed is the correct one). It's
> possibly just a one-bit error in all sound.
>