Command handling:
1. Changed mpd_read_cb() to delegate to mpd_process_line() for each received
command line.
2. mpd_process_line() handles idle state and command list state and delegates
to mpd_process_command() to handle each command line.
If the command was successful it sends OK to the client according the the
command list state.
Error responses are sent by mpd_process_command().
3. mpd_process_command() parses the args and delegates to the individual
command handler.
mpd_input_filter:
1. Removed handling of command lists. They are handled by mpd_process_line().
2. Return BEV_OK if there's at least one complete line of input even if there's
more data in the input buffer.
Idle/noidle:
1. Changed mpd_command_idle() to never write OK to the output buffer.
Instead it is the responsibility of the caller to decide on the response.
2. Removed mpd_command_noidle() instead it is handled in mpd_process_line().
If the client is not in idle state noidle is ignored (no response sent)
If the client is in idle state then it changes idle state to false and sends
OK as the response to the idle command.
Command lists:
1. Added command list state to the client context so commands in the list are
buffered and only executed after receiving command_list_end.
Connection state:
1. Added is_closing flag in the client context to ignore messages received
after freeing the events buffer in intent to close the client connection.
Command arguments parsing:
1. Updated COMMAND_ARGV_MAX to 70 to match current MPD.
2. Changed mpd_pars_range_arg to handle open-ended range.
Command pause:
1. pause is ignored in stopped state instead returning error.
Command move:
1. Changed mpd_command_move() to support moving a range.
2. Added db_queue_move_bypos_range() to support moving a range.
Command password:
1. Password authentication flag set in handler mpd_command_password() instead
of in command processor.
Config:
1. Added config value: "max_command_list_size".
The maximum allowed size of buffered commands in command list.
Maintain the binary limit, and use the default MPD uses too. This comes
in handy when we are going to send binary responses such as in PR #1780
Signed-off-by: Fabian Groffen <grobian@gentoo.org>
Return MPD-compatible output of plugin type "httpd" when
enable_http_plugin in mpd section of the config is set.
Signed-off-by: Fabian Groffen <grobian@gentoo.org>
The plugin key is used by some clients to determine whether local
playback is possible via HTTP stream, so mimick it.
Signed-off-by: Fabian Groffen <grobian@gentoo.org>
Simply casting the speaker ID from a 64-bits int to an unsigned short
and hoping that there will be no clashes is just optimistic. Use an
ascending number instead which is what MPD does too. The MPD server
specifically documents no persistence in these IDs so we can simply
enumerate the speakers to meet the requirements.
Signed-off-by: Fabian Groffen <grobian@gentoo.org>
New default for "trusted_networks" = "lan". This will check peer addresses
against the addresses/netmasks of the interfaces to establish whether the peer
is local.
Fixes#1754
Automatically read/write ratings to files in the library, if options read_rating/
write_rating are enabled. Also adds a max_rating so the user can set the rating
scale.
Doesn't sync automatic rating updates, because that could lead to whole-playlist
file rewriting.
Closes#1678
---------
Co-authored-by: whatdoineed2do/Ray <whatdoineed2do@nospam.gmail.com>
Co-authored-by: ejurgensen <espenjurgensen@gmail.com>
socket() with SOCK_NONBLOCK (O_NONBLOCK) seems not to be possible on MacOS, it
yields 'Protocol wrong type for socket'. Switch to using fcntl() and O_NONBLOCK
instead, hopefully works better cross-platform.
Closes#1644
mpd is based on evhttp, so if httpd should use another backend they need to be
decoupled. No need to use httpd_send_reply/error, since CORS headers are not
relevant to MPD artwork serving.
(db upgrade to v22.00)
`scan_kind` identifies the library "scanner" component that created the
item and is responsible to keep it up to date (rescan).
The library update now supports passing a `scan_kind` to update only the
items of one particular "scanner". This allows e. g. to only update the
item from the Spotify library or only update the RSS feeds.
The OwnTone database is upgraded to v22.00 and the `scan_kind` columns
in `files`, `playlists`, `directories` are identified by:
1. Check if item is part of a RSS playlist (podcast RSS feed), they
belong to the "rssscanner"
2. Check if item has a Spotify `virtual_path`, they belong to the
"spotifyscanner"
3. Remaining items belong to the "filescanner"
Misc refactoring, e.g. alignment of how modules save tracks and playlists, incl
use of mfi and pli. Also try to avoid direct calls between library and player.
Also changes relative seeking behavior:
- seeking behind the the current track only switches to the previous
track, if we are not more than 3 seconds into the current track,
otherwise starts current track from the beginning
- seeking beyond the current track will start the next track from the
beginning
The previous solution would use subqueries to count the number of items and
streams in each playlist, which means that response time gets pretty slow if
there are many playlists.
This commit also includes a number of lesser db code changes.