dbrgn / orochi

Orochi is an interactive command line client for 8tracks.com.
GNU General Public License v3.0
86 stars 17 forks source link

Move to MPD #45

Open dbrgn opened 10 years ago

dbrgn commented 10 years ago

I think it would be best if we replace Mplayer with MPD. One of the advantages is that it features a much better IPC API than the hack we're doing currently with the mplayer subprocess. Additionally the configurability is much better. A challenge will be to handle remote control by 3rd party applications, but I guess we can just ignore that feature and declare it as not supported.

I hope to find time to work on this in February.

darnir commented 10 years ago

I completely back your move here. A switch to MPD would be an excellent choice and may remove a lot of the headaches caused by various Mplayer crashes. MPD is extremely stable and a great choice for this project.

Remote control may be a problem, but that can be fixed at a later date. I'd like to help if possible to this shift. Once we decide on the design specifics, I'll try contributing as much as possible.

mindstorms6 commented 10 years ago

Agreed. I am glad to help with a part of this.

dbrgn commented 10 years ago

Great. I'll make some initial drafts in a separate branch in the next few days. Then we can start the discussion.

dbrgn commented 10 years ago

Here's the first design decision: Should we communicate with the mpd directly via TCP, or should we use a client library like https://github.com/Mic92/python-mpd2? Any opinions? :)

Right now I tend to use the TCP based protocol directly, as we won't use most of the features anyways. All we need is to enqueue a song, and standard playback control like pausing, skipping and volume control.

On the other hand, a library would abstract away things like error handling...


Edit: What speaks for python-mpd2 is that it's well tested, actively developed and it does all the connection handling stuff like timeouts etc... Maybe it wouldn't be a bad idea to use it after all.

dbrgn commented 10 years ago

Never mind, I took a quick look at the library and it looks really nice. It saves us all the connection checking, timeout handling etc. So I'll use it.

I'll push a few first drafts to the mpd branch soon.

What do you think about creating a generic interface with abstract methods (load, playpause, stop, volume and terminate) to couple the player more loosely with the rest of the client? On one hand it's a great way to allow future backends to be created, on the other hand it might be a case of YAGNI and overly complex design...

dbrgn commented 10 years ago

Current design idea:

Current problems:

dbrgn commented 10 years ago

Two possibilities to handle the connection timeout:

It doesn't appear that connecting/disconnecting is a big overhead, so I'd suggest using the context manager in the link above. If someone thinks pings are the better solution, let me know.

dbrgn commented 9 years ago

I tried to continue with the development today. Unfortunately there's a problem with the signals.

The signal handlers execute code that can cause reentrancy problems. That means the following can happen:

The signal handlers should not call any non-reentrant code. For that, we probably need an event loop of some sort.