The mpg123 input plug-in for XMMS displays an incorrect song length for some VBR files. Usually, the length is around two times the correct length.
Created attachment 71329 [details, diff] xmms-mpg123.patch Patch to fix the problem described above. This patch must be applied after the Gentoo patches.
While researching the implications of your patch I came upon two VBR related bugs[1][2] on the xmms bugzilla[3]. One has a patch[4] for the mpg123_get_first_frame function in mpg123.c, the same function your patch changes. The one thing that the patches both have in common is that they stop the program from overwriting the contents of frm, which has the decoded frame header information for the first frame, with the decoded frame header information of the second frame. (Why would they want frm to have the second frame header information when the function is called mpg123_get_first_frame and the returned 'buffer' contains the first frame's data?) The reason why overwriting frm causes the problem for some files and not others is that the part which reads the frame into 'buffer' uses frm->framesize. If 'frm' is overwritten with the decoded second header, then the framesize for the second frame is used. If the second frame is smaller than the first framesize, then not all of the first frame will be stored in 'buffer'. It should be noted that when I write framesize in this bug report and when the code says framesize, it really means frame length. The framesize member of the frame struct is calculated and used for seek()'ing. Therefore, it refers to frame length. See this[5] for the difference between frame size and frame length. I haven't been able to reproduce the problem that you are having, so I cannot test the patch, but I believe, from studying the code, that a problem does exist. Could you please attach to this bug a small VBR file that exhibits the problem you are having? Thanks for the patch! ~tcort [1] When playing a VBR stream title info isn't working properly http://bugs.xmms.org/show_bug.cgi?id=397 [2] Bitrate info and VBR (mp3) http://bugs.xmms.org/show_bug.cgi?id=2186 [3] XMMS Bugzilla http://bugs.xmms.org [4] mpg123_get_first_frame.patch http://bugs.xmms.org/attachment.cgi?id=325&action=view [5] See the "How to calculate frame length" section http://www.dv.co.yu/mpgscript/mpeghdr.htm
commited in the new patchset that is available on 1.2.10-r16