huceke/omxplayer — pull request #127 by pasky (2013-03-02 16:03:58+00:00)
Title: Add support for almost-seamless playback of multiple streams (optionally, in a loop)

Hi! The code in pasky/omxplayer branch multiplestreams adds support for:

(i) Loop option (similar to another fork)

(ii) Multiple filenames on the command line

While running omxplayer in a shell loop causes gaps of about 2s between videos and dark screen with bunch of text in the meantime, with this patch the last frame of previous video is frozen for about 200ms (unless there is other load) before next video starts. The next video in the queue is opened and scanned by ffmpeg on the background while the current video is playing.

This is probably not ready for prime-time yet; at the very least, we should make some effort to gracefully handle (likely just by reinitializing OMX state) transitions between streams with different parameters.

Also, the current code contains not-so-few gotos and other ugly things. This is the main purpose of this pull request at this point, I would like to propose significant refactoring of the current main() function so that the above mentioned can be implemented much more sanely and maintainably. Basically, my idea is to create class OMXPlayer that will handle playback of a single file. Then, the main() function would just parse parameters (setting OMXPlayer attributes appropriately), take care of setting up OMXReader, call the OMXPlayer loop function, interpret keystrokes. All the stream-handling, feeding and synchronizing logic would be in the OMXPlayer class.

Does that sound sane? Would you accept a pull request containing such changes? Or would you prefer a different approach?