size_t mp3_read ( struct audio_file fd,
int16_t *  buf,
size_t  len 
)

Read data from the mp3 file and place it in buf.

Definition at line 365 of file audio_format_mp3.c.

00366 {
00367         struct mp3_drv_data *data = fd->drv_data;
00368         size_t written = 0;
00369         int i;
00370 
00371         do {
00372                 /* Get a new frame when we haven't go one */
00373                 if (data->cursample == 0) {
00374                         if (mp3_read_frame(fd) != 0)
00375                                 goto done;
00376                         if (mad_frame_decode(&data->mframe, &data->mstream) == -1)
00377                                 continue;
00378 
00379                         /* We can now set the sample rate */
00380                         fd->srate = data->mframe.header.samplerate;
00381                         fd->channels = MAD_NCHANNELS(&data->mframe.header);
00382 
00383                         mad_synth_frame(&data->msynth, &data->mframe);
00384                 }
00385 
00386                 while ((data->cursample < data->msynth.pcm.length) &&
00387                     (written < len)) {
00388                         /* Write out all channels */
00389                         for (i = 0; i < MAD_NCHANNELS(&data->mframe.header); i++) {
00390                                 buf[written++] = mp3_fixed_to_short(
00391                                     data->msynth.pcm.samples[i][data->cursample]);
00392                         }
00393 
00394                         data->cursample++;
00395                 }
00396 
00397                 /* Move on to the next frame */
00398                 if (data->cursample == data->msynth.pcm.length)
00399                         data->cursample = 0;
00400 
00401         } while (written < len);
00402 
00403 done:
00404         return (written);
00405 }

Here is the call graph for this function:

 All Data Structures Files Functions Variables Defines
Generated on Mon Mar 15 04:45:04 2010 for herrie by  doxygen 1.6.3