Commit graph

144 commits

Author SHA1 Message Date
Aidan Epstein
9c479659b2 Increment playlist_version when a track is consumed.
This fixes the playlist not updating when in consume mode, at least in
ncmpcpp.
2019-11-24 19:27:09 -08:00
FichteFoll
9631616b53
Replace a couple URLs that don't point to anything
I'm unsure regarding the pygst tutorial, so I just added another URL
of the best resource I could find with a quick web search.
2019-06-05 23:08:18 +02:00
Carl Suster
62aa358ce7 bpd: bump protocol version to 0.16 2019-06-02 23:37:07 +10:00
Carl Suster
d8be83bc0d bpd: support ranges in playlistid 2019-06-02 23:37:07 +10:00
Carl Suster
dc7e3b9b6a bpd: support nextsong in status 2019-06-02 23:37:07 +10:00
Carl Suster
fdd809fd36 bpd: support more tagtypes 2019-06-02 23:37:07 +10:00
Carl Suster
cc2c35221d bpd: avoid sending playlist events on navigation 2019-06-02 23:37:07 +10:00
Carl Suster
5187100294 bpd: accept all idle events 2019-06-02 23:37:07 +10:00
Carl Suster
27c462d287 bpd: make noidle a no-op outside idle mode
The real MPD ignores `noidle` when the client is not idle. It doesn't
even send a successful response, just ignores the command. Although
I don't understand why a client would fail to keep track of its own
state, it seems that this is necessary to get ncmpcpp working.
2019-06-02 23:37:07 +10:00
Carl Suster
e708d28f85 bpd: allow fractional seconds in seek
The documented type is float, not integer, and clients like mpDris2 send
fractional seconds, causing them to crash if these values ar enot
accepted.
2019-06-02 23:37:07 +10:00
Carl Suster
1a5263b68f bpd: support volume command for real 2019-06-02 23:37:07 +10:00
Carl Suster
59c506990a bpd: fix bug in playlistid
The playlistid command is supposed to list the whole playlist if no
argument is provided, but we were accidentally trying to look up an
impossible negative id in that case causing an error to always be
returned.
2019-06-02 23:37:07 +10:00
Carl Suster
64ed54330b bpd: mention control socket address in log 2019-06-02 23:37:07 +10:00
Carl Suster
546bf3af7e mediafile: import from standalone module 2019-05-29 09:35:14 +10:00
Carl Suster
3da23167ca bpd: support decoders command
This uses GStreamer APIs to extract a list of audio decoders and the
relevant MIME types and file extensions. Some clients like ncmpcpp use
this command to fetch a list of supported file extensions.
2019-04-19 16:08:05 +10:00
Carl Suster
9182f18e6f bpd: support short form of list command for albums
Some clients list the albums belonging to an artist by issuing the
command `list album <ARTIST NAME>`. This change inserts the tag `artist`
before the artist name so that this succeeds. Fixes #3007
2019-04-15 13:25:02 +10:00
Carl Suster
826244777e bpd: minor control socket refactor 2019-04-10 15:52:47 +10:00
Carl Suster
d55f061f0b bpd: add control socket
A new `ControlConnection` is created each time a client connects over
a new control socket. This is used to forward events from the player,
and also for debugging utilities that are not part of the real MPD
protocol.

This new feature reuses as much infrastructure from the normal protocol
handling as possible (e.g. `Command` for parsing messages). While the
normal connection delegates to server `cmd_*` methods which are string
generators, the control connections delegate to `ctrl_*` methods defined
on the connection itself that are full coroutines.
2019-04-09 12:19:15 +10:00
Carl Suster
fa3813844c bpd: reimplement idle without polling 2019-04-08 16:33:34 +10:00
Carl Suster
6fbf3853f2 bpd: bump protocol version to 0.14.0 2019-04-08 11:40:24 +10:00
Carl Suster
699de94f4f bpd: send all relevant idle events 2019-04-08 11:40:24 +10:00
Carl Suster
7105c800aa bpd: implement the idle command
Getting this command puts the connection into a special mode where it
awaits MPD events (like the player changing state or the playlist
changing due to other clients interacting with the server.

The MPD specification states that events should queue while a client is
connected, and when it issues the `idle` command any matching events
should be sent immediately if there are any, or as soon as they happen
otherwise.
2019-04-08 11:40:24 +10:00
Carl Suster
ee0c31ba6a bpd: track and log client session details
Keep track of a list of currently-connected clients.

Use `socket.getpeername()` to get an identifier for each connection and
include this in each log message. This function is documented as not
being available on all systems, but it's unclear which systems this
involves.

Also log a message on client connect and disconnect events. If the
disconnection reason is because the client sent a blank line, match MPD
by returning a protocol error then hanging up. Escape curly braces.
2019-04-08 11:28:56 +10:00
Carl Suster
5b0a02eb31 bpd: don't send volume if zero in status 2019-04-08 10:52:15 +10:00
Carl Suster
f8a2c22e8d bpd: fix typo in comment 2019-04-08 10:52:15 +10:00
Carl Suster
95dd513b25 bpd: add flake8 exception for test command 2019-04-02 14:25:56 +11:00
Carl Suster
20e2f8beec bpd: output an info-level message when ready 2019-04-02 13:38:43 +11:00
Carl Suster
d074dac771 bpd: add comments to the error handling code 2019-04-02 13:37:40 +11:00
Carl Suster
28db7d3d33 bpd: provide precision time in status 2019-04-02 11:15:00 +11:00
Carl Suster
4be2e1b5e6 Remove beets.util.inspect wrapper 2019-04-02 10:22:47 +11:00
Carl Suster
36c85a8aeb Fix beets.util.inspect for Python 3
Under the original compatibility shim we weren't correctly inclusing
`self` in the argument list for bound methods.
2019-04-02 10:11:43 +11:00
Carl Suster
9622e7433b bpd: return real audio data 2019-04-02 09:44:34 +11:00
Carl Suster
e839e4ea19 bpd: improve exception handling
Check function signature instead of using TypeError to crudely guess
that the wrong number of arguments were provided.

Prevent bpd from crashing when trying to log a traceback. The
`traceback.format_exc` function takes an optional argument which is
supposed to be an integer restricting the length of the backtrace to
show. Instead we were passing the exception object to this function and
causing a new exception to be raised.
2019-04-02 09:39:07 +11:00
Carl Suster
146c5f5e13 bpd: fix repeat, consume and single in reverse
These flags are all relevant to the 'previous' command as well as the
'next' command.
2019-04-01 18:05:10 +11:00
Carl Suster
12e49b3c88 bpd: skipping backwards through zero keeps playing
Previously issuing the 'previous' command when at position 0 on the
playlist would cause bpd to stop playing. MPD instead just restarts the
currently playing song instead, so we now match this behaviour.
2019-04-01 17:51:21 +11:00
Carl Suster
a4fe6875a1 bpd: fix bug in bounds check of current song index
The songs are indexed starting from zero for the play command, however
the bound check was off by one. An index matching the length of the
playlist would crash the server instead of responding with an error
message over the protocol.
2019-04-01 17:41:25 +11:00
Carl Suster
0c3a63ef9f bpd: fix repeat mode behaviour
The repeat flag indicates that the entire playlist should be repeated.
If both the repeat and single flags are set then this triggers the old
behaviour of looping over a single track.
2019-04-01 17:39:35 +11:00
Carl Suster
b245c0e755 bpd: test fields returned by status command 2019-04-01 16:42:39 +11:00
Carl Suster
bae9c40600 bpd: support the single command
This command instructs bpd to stop playing when the current song
finishes. In the MPD 0.20 protocol this flag gains a value 'oneshot' but
for now we just support its older version with a boolean value.
2019-04-01 16:30:02 +11:00
Carl Suster
71e7621642 bpd: no-op support for persistent playlists
The real MPD offers persistent playlist manipulation, storing the
playlists in a directory set in the config file. If that directory is
not available then the feature is disabled and the relevant commands all
respond with errors. Based on this, the initial support in bpd just
returns errors matching the MPD server in the disabled mode.

For playlistadd, extend the _bpd_add helper to work with playlists other
than the queue in order to support testing the real implementations of
these commands in the future.
2019-04-01 16:30:02 +11:00
Carl Suster
859e16d1e3 bpd: support consume command 2019-04-01 16:30:02 +11:00
Carl Suster
e5851866d7 bpd: add replay_gain_* commands
There's a special status command for checking the replay gain mode,
which can be set to one of a short list of possible values. For now at
least we can ignore this feature, but track the setting anyway.
2019-04-01 14:49:27 +11:00
Carl Suster
67a0b38d20 bpd: add dummy command for volume
MPD supports a deprecated command 'volume' which was used to change the
volume by a relative amount unlike its replacement 'setvol' which uses
an absolute amount. As far as I can tell 'volume' always responds with a system
error message "No mixer".
2019-04-01 14:49:27 +11:00
Carl Suster
1511e313f7 bpd: add mixramp commands
These are a more sophisticated version of crossfade so we're free to
ignore them, at least for now. We now track the values of the two
settings, and show them in the status output. Like MPD, we suppress the
mixrampdb value if it's set to nan, which is how it signals that the
feature should be turned off.
2019-04-01 14:49:27 +11:00
Carl Suster
0f53ae9a87 bpd: error instead of crashing on extra argument
If an MPC client is expecting a command to take an argument that bpd
isn't expecting (e.g. because of a difference in protocol versions) then
bpd currently crashes completely. Instead, do what the real MPD does and
return an error message over the protocol.
2019-04-01 14:49:27 +11:00
Carl Suster
d94a5393b2 bpd: fix crossfade command
Although crossfade is not implemented in bpd, we can store the setting
and repeat is back to clients. Also log a warning that the operation is
not implemented.

The real MPD doesn't show the crossfade in status if it's zero since
that means no crossfade, so now we don't either.
2019-04-01 14:49:27 +11:00
Carl Suster
b4c4f3ca19 bpd: use plugin logger instead of global logger 2019-03-31 22:06:43 +11:00
Carl Suster
7557bb06d6 bpd: use log instead of stdout 2019-03-31 18:43:18 +11:00
Adrian Sampson
958ad430fc bpd: Use integers for time values (fix 2394) 2017-01-17 11:37:10 -08:00
Adrian Sampson
a063336446 Fix #2332: Unicode trouble in bpd 2016-12-20 15:16:46 -05:00