Re: [mpg123-devel] Help please...
Brought to you by:
sobukus
From: Clive C. <cl...@wi...> - 2012-02-01 11:30:29
|
Hi Thomas, > I was about to suggest using mpg123_replace_reader() ... apart from that, the mpg123_decode_frame() API should be somewhat intermixable with mpg123_feed(), but you should be careful with mixing it with mpg123_decode() as that one abstracts over frames. Oh, and you don't need that decode call to get the format. Just do mpg123_getformat(); nowadays that triggers the necessary inital parsing anyway. > I did look at mpg123_replace_reader() and decided that it was a little above my abilities right now. The way I was doing things meant that the seek didn't work but what I drew from that was the fact that it worked for the very first seek and that was interesting. So..... and this is where you may start to cringe a little.... I decided that I would create a new mpg123 instance for every seek..... What!....Yeah. Here is the code that sits in the scrollbar 'position changed' event of the application I am writing. sfifo_flush(fifo); int ret; off_t fNum; size_t bytes; if(hQplay != NULL) mpg123_close(hQplay); delete hQplay; hQplay = NULL; mpg123_init(); hQplay = mpg123_new(NULL, &ret); if(hQplay == NULL) return; initDecoder(hQplay, mp3Buffer, mp3size, false); mpg123_seek_frame(hQplay, currentPos - 2, SEEK_SET); for(int x = 0; x < 8; x++) { mpg123_decode_frame(hQplay, &fNum, &bbuff, &bytes); sfifo_write(fifo, bbuff, bytes); qDebug() << "Frame Read:" << fNum << " Length:" << bytes; } Error checking!... who needs error checking... ha ha (deal with that later) This works really well and you can see/hear the result here... http://youtu.be/lQMja5_awEE You may notice that I grabbed the same fifo buffer code mpg123 is using, that works really well. I have the latency down to under 2 frames, 0.05s. This does allow a limited slow play that makes it easy to visually and audibly get to the exact frame you want. I am also learning a whole lot about how mpg123 works while producing this application and I am already thinking of adding a function to mpg123 to allow a forced seek, but that is for later. I will be interested in any comments from anyone. Clive -- Infinity: A concept for those who cannot comprehend the big picture. () Arch Linux - For movers and shakers. () |