[mpg123-users] MPG123_DONE occurring in different place after seek?
Brought to you by:
sobukus
From: Darren Lo <dar...@gm...> - 2009-11-07 04:55:46
|
Greetings, I'm seeing something unexpected with seeks, and I'm not sure if I'm doing something wrong. The situation is as follows: I open a gaplessly encoded MP3 with mpg123_open, call mpg123_read until I get MPG123_DONE, and add up the total number of decoded bytes. This number matches the length of the original PCM audio. Then I seek to offset 0 and repeat the process. This time MPG123_DONE will be returned in a different, later place (i.e., the new total number of bytes is larger). Further repetitions always give the new, larger number. However, I would expect that MPG123_DONE should always be returned after the same number of bytes. Here is an example of what I mean: for (iteration = 1; iteration <= maxiter; iteration++) { printf("Decoding %s (time %d of %d)...\n", filename, iteration, maxiter); total = 0; do { mpg123_err = mpg123_read(mh, buf, sizeof buf, &written); total += written; } while (mpg123_err != MPG123_DONE); printf("Got %u bytes in all.\n", total); mpg123_seek(mh, 0, SEEK_SET); } The output of this is: Decoding yuka.mp3 (time 1 of 5)... Got 12296384 bytes in all. // correct value Decoding yuka.mp3 (time 2 of 5)... Got 12298940 bytes in all. // incorrect Decoding yuka.mp3 (time 3 of 5)... Got 12298940 bytes in all. (...) If I compare the PCM output for the runs, they all compare identical except for extra data at the end for runs 2 and up. So, what is wrong here? |