]> git.ktnx.net Git - mpd-feeder.git/log
mpd-feeder.git
2 years agoadd CHANGES.txt
Damyan Ivanov [Thu, 2 Dec 2021 17:50:56 +0000 (17:50 +0000)]
add CHANGES.txt

2 years agofix license statement
Damyan Ivanov [Thu, 2 Dec 2021 17:48:32 +0000 (17:48 +0000)]
fix license statement

2 years agomore docs
Damyan Ivanov [Thu, 2 Dec 2021 17:33:01 +0000 (17:33 +0000)]
more docs

2 years agotypo in option name
Damyan Ivanov [Sun, 28 Nov 2021 21:41:33 +0000 (21:41 +0000)]
typo in option name

2 years agoadd some docs, license under GPL-2
Damyan Ivanov [Sun, 28 Nov 2021 21:41:23 +0000 (21:41 +0000)]
add some docs, license under GPL-2

2 years agoadd systemd integration (optional)
Damyan Ivanov [Sat, 27 Nov 2021 07:36:48 +0000 (07:36 +0000)]
add systemd integration (optional)

2 years agomore log priority adjustments
Damyan Ivanov [Sat, 27 Nov 2021 07:05:30 +0000 (09:05 +0200)]
more log priority adjustments

2 years agomore log priorities
Damyan Ivanov [Fri, 26 Nov 2021 15:57:43 +0000 (15:57 +0000)]
more log priorities

2 years agoadjust some log priorities
Damyan Ivanov [Fri, 26 Nov 2021 15:30:13 +0000 (15:30 +0000)]
adjust some log priorities

2 years agoset autoflush on stderr so that logging to systemd's journal (via UNIX socket) is...
Damyan Ivanov [Fri, 26 Nov 2021 12:00:16 +0000 (12:00 +0000)]
set autoflush on stderr so that logging to systemd's journal (via UNIX socket) is more real-time

2 years agodrop WorkQueue (abandoned idea)
Damyan Ivanov [Fri, 26 Nov 2021 11:28:04 +0000 (11:28 +0000)]
drop WorkQueue (abandoned idea)

2 years agodirect stderr to the journal
Damyan Ivanov [Fri, 26 Nov 2021 11:20:06 +0000 (11:20 +0000)]
direct stderr to the journal

2 years agoinstall sql/ into share
Damyan Ivanov [Fri, 26 Nov 2021 10:39:24 +0000 (10:39 +0000)]
install sql/ into share

2 years agofix ExecStart directive name
Damyan Ivanov [Fri, 26 Nov 2021 10:34:04 +0000 (10:34 +0000)]
fix ExecStart directive name

2 years agodeclare systemd service as of type 'exec'
Damyan Ivanov [Fri, 26 Nov 2021 10:33:53 +0000 (10:33 +0000)]
declare systemd service as of type 'exec'

that is, considered running after fork() and execve()

2 years agoadd systemd sysusers config
Damyan Ivanov [Fri, 26 Nov 2021 08:35:48 +0000 (08:35 +0000)]
add systemd sysusers config

2 years agomore systemd: require config file, run as a separate user, install
Damyan Ivanov [Fri, 26 Nov 2021 08:09:55 +0000 (08:09 +0000)]
more systemd: require config file, run as a separate user, install

2 years agocope with no $idler right after idle is done
Damyan Ivanov [Thu, 25 Nov 2021 20:59:08 +0000 (20:59 +0000)]
cope with no $idler right after idle is done

might be undef'd by an event handler

2 years agokeep $loop variable at closure reach
Damyan Ivanov [Thu, 25 Nov 2021 20:58:17 +0000 (20:58 +0000)]
keep $loop variable at closure reach

otherwise it can't be stopped from within the closure, and $mpd->loop
may be the thing from re-init-ed $mpd (after a reconnect)

2 years agoadd systemd service file
Damyan Ivanov [Thu, 25 Nov 2021 07:44:28 +0000 (07:44 +0000)]
add systemd service file

2 years agoworking re-connection on disconnection
Damyan Ivanov [Thu, 25 Nov 2021 07:44:11 +0000 (07:44 +0000)]
working re-connection on disconnection

it is not enough to cancel the idle future and then re-connect.

Net::Async::MPD is just not suited for such a scenario due to its
internal state not refrecting the loss of connection

so, upon disconnect, abandon the N:A:MPD instance and create a new one

2 years agorework event looping, allows for graceful (re-)connection to MPD
Damyan Ivanov [Wed, 24 Nov 2021 06:39:36 +0000 (06:39 +0000)]
rework event looping, allows for graceful (re-)connection to MPD

the MPD may be down, not yet started (possibly on another host, so no
way to avoid this via systemd service dependencies)

3 years agoadd TODO about tracking song play moment
Damyan Ivanov [Wed, 24 Nov 2021 06:25:02 +0000 (06:25 +0000)]
add TODO about tracking song play moment

3 years agoadd dist.ini and sample mpd-feeder.conf
Damyan Ivanov [Sun, 21 Nov 2021 09:00:14 +0000 (09:00 +0000)]
add dist.ini and sample mpd-feeder.conf

3 years agofixup idle rework: add WorkQueue
Damyan Ivanov [Sun, 21 Nov 2021 08:47:55 +0000 (08:47 +0000)]
fixup idle rework: add WorkQueue

3 years agowhitespace
Damyan Ivanov [Sun, 21 Nov 2021 08:47:38 +0000 (08:47 +0000)]
whitespace

3 years agoconvert Feeder to unit-level class too
Damyan Ivanov [Sun, 21 Nov 2021 08:46:30 +0000 (08:46 +0000)]
convert Feeder to unit-level class too

3 years agorework idling again, walking around Net::Async::MPD interface
Damyan Ivanov [Sun, 21 Nov 2021 08:44:35 +0000 (08:44 +0000)]
rework idling again, walking around Net::Async::MPD interface

thing is, that the ->noidle() call places readers on the mpd handle,
because it uses ->send(). this interferes with the expected protocol
flow like this:

idle() is called, a reader/parser is queued by ->send()
when noidle is called, it calls send(), which queues another reader/parser
MPD sees the 'noidle' command and responds with plain 'OK', which is
consumed by the readers queued by idle(). this by itself causes a crash
because the is no "result" and ->{changes} is invoked on undefined value

it the undef deref is fixed, the protocol still hangs, because of the
extra readers queued, which consumes the reply of the next command
issued (e.g. 'playlist')

the other thing that doesn't work is the link check in mpd-feeder. on
timer, it wants to break out of 'idle' waiting just to be sure that the
connection is alive. this also causes dereferencing of an undefined
value and protocol lock up.

so, instead, the idle/noidle is implemented half under-the-table.
idle is implemented via ordinary send(), and broken by a crude call to
mpd->{mpd_handle}->write(), breaking API. this serves two purposes.
first, the readers queued by send() see toe 'OK' resulting from noidle
and return empty result, which is handled by Feeder without crashing.
second, sending a low-level 'noidle' command via the connection handle
avoids queuing extra reader which would cause protocol hang.

the result is that periodic connection checks (leaving and re-entering
idle) work, idle events (which put MPD out of idle mode) are handled
outside of 'idleness' as they should be, asynchronous signals
(TERM, INT, etc.) work as expected outside of 'idleness'. happy camping
all around!

3 years agoconvert to unit-type class definition
Damyan Ivanov [Sun, 21 Nov 2021 08:32:22 +0000 (08:32 +0000)]
convert to unit-type class definition

3 years agoperiodically break out of idle mode to see if the connection to MPD is intact
Damyan Ivanov [Thu, 18 Nov 2021 06:17:19 +0000 (06:17 +0000)]
periodically break out of idle mode to see if the connection to MPD is intact

it may be hanging if for example the local system was suspended. in
this situation mpd would detect the missing peer (us) when e.g. reporting
idle changes and close the tcp socket. later, the local system resumes
and the local tcp connection is still open and waiting for an idle result
forever

3 years agono warnings on undef usage when idle waiting results in no changes
Damyan Ivanov [Thu, 18 Nov 2021 06:14:09 +0000 (06:14 +0000)]
no warnings on undef usage when idle waiting results in no changes

this is normal when the idle mode is stopped with 'noidle'

3 years agomove 'connect' method next to the 'disconnect' method
Damyan Ivanov [Tue, 16 Nov 2021 06:25:39 +0000 (06:25 +0000)]
move 'connect' method next to the 'disconnect' method

3 years agoimplement unwanted album list manipulation
Damyan Ivanov [Tue, 16 Nov 2021 06:25:22 +0000 (06:25 +0000)]
implement unwanted album list manipulation

3 years agodo not crash when the playlist is cleared
Damyan Ivanov [Tue, 16 Nov 2021 06:02:29 +0000 (06:02 +0000)]
do not crash when the playlist is cleared

the 'playlist' idle event returns no result in this case which lead to
an attempt to dereference undefined value

3 years agorework DB update using COPY and a PostgreSQL function for maximum speed
Damyan Ivanov [Mon, 15 Nov 2021 06:12:09 +0000 (06:12 +0000)]
rework DB update using COPY and a PostgreSQL function for maximum speed

COPY is the most effective data loading mechanism, and using a function
reduces the number of requests to just one

3 years agodrop "run" method which became a wrapper around prepare_to_wait_idle
Damyan Ivanov [Sat, 13 Nov 2021 07:44:24 +0000 (07:44 +0000)]
drop "run" method which became a wrapper around prepare_to_wait_idle

3 years agosubscribe to "close" event only once, after connecting to mpd
Damyan Ivanov [Sat, 13 Nov 2021 07:43:55 +0000 (07:43 +0000)]
subscribe to "close" event only once, after connecting to mpd

3 years agoadd list-unwanted-artists command
Damyan Ivanov [Fri, 12 Nov 2021 09:37:43 +0000 (09:37 +0000)]
add list-unwanted-artists command

3 years agofix DB interaction from commands after DB split-out
Damyan Ivanov [Fri, 12 Nov 2021 09:37:25 +0000 (09:37 +0000)]
fix DB interaction from commands after DB split-out

3 years agoa second HIP/INT signal causes a hard exit()
Damyan Ivanov [Fri, 12 Nov 2021 09:03:56 +0000 (09:03 +0000)]
a second HIP/INT signal causes a hard exit()

3 years agosplit out DB operations in a module
Damyan Ivanov [Fri, 12 Nov 2021 08:26:48 +0000 (08:26 +0000)]
split out DB operations in a module

3 years agoshow command line upon re-exec (log_level=trace)
Damyan Ivanov [Fri, 12 Nov 2021 07:26:48 +0000 (07:26 +0000)]
show command line upon re-exec (log_level=trace)

3 years agoexit cleanly on SIGTERM and SIGINT
Damyan Ivanov [Fri, 12 Nov 2021 07:23:36 +0000 (07:23 +0000)]
exit cleanly on SIGTERM and SIGINT

3 years agosplit command execution into App::MPD::Feeder::Command
Damyan Ivanov [Fri, 12 Nov 2021 07:12:23 +0000 (07:12 +0000)]
split command execution into App::MPD::Feeder::Command

avoids having dead code in RAM when the main loop is operating

3 years agoturn on :utf8 everywhere with utf8::all
Damyan Ivanov [Fri, 12 Nov 2021 06:42:53 +0000 (06:42 +0000)]
turn on :utf8 everywhere with utf8::all

now that sources are declared and decoded as utf8, output needs to be
encoded

3 years agofix DB stats retrieval when no songs were queued recently
Damyan Ivanov [Fri, 12 Nov 2021 06:42:35 +0000 (06:42 +0000)]
fix DB stats retrieval when no songs were queued recently

strangely one of the totals was getting undef and broke the division
perhaps the UNION is not working as expected?

3 years agofixup split of App::MPD::Feeder
Damyan Ivanov [Fri, 12 Nov 2021 06:34:15 +0000 (06:34 +0000)]
fixup split of App::MPD::Feeder

3 years agomove mail event loop to Feeder
Damyan Ivanov [Fri, 12 Nov 2021 06:33:44 +0000 (06:33 +0000)]
move mail event loop to Feeder

3 years agosplit-out App::MPD::Feeder -- the main application module
Damyan Ivanov [Fri, 12 Nov 2021 06:22:54 +0000 (06:22 +0000)]
split-out App::MPD::Feeder -- the main application module

3 years agomove Options in a stand-alone module
Damyan Ivanov [Thu, 11 Nov 2021 21:12:53 +0000 (21:12 +0000)]
move Options in a stand-alone module

3 years agoshow counts of available songs/albums/artist
Damyan Ivanov [Thu, 11 Nov 2021 20:12:03 +0000 (20:12 +0000)]
show counts of available songs/albums/artist

for now in log_level=debug

3 years agoconnect to the DB early when in feeder mode
Damyan Ivanov [Thu, 11 Nov 2021 20:11:05 +0000 (20:11 +0000)]
connect to the DB early when in feeder mode

this way any problems in the connection will show at startup instead
of later when a new song needs to be queued

3 years agofix two instances of hanging open statements
Damyan Ivanov [Thu, 11 Nov 2021 20:06:45 +0000 (20:06 +0000)]
fix two instances of hanging open statements

when a cursor is exhausted with while (sth->fetch) {...} there is no
problem. Single row fetches, however need an explicit sth->finish or
the cursor remains open. this is not a big problem, but it is annoying
to see the warnings when the statement is reused (due to caching) or the
connection is shut down

3 years agofix filtering on album last queue time
Damyan Ivanov [Thu, 11 Nov 2021 20:04:58 +0000 (20:04 +0000)]
fix filtering on album last queue time

joining on the full PK of albums table avoids multiple matches
and erroneous extra results

3 years agofix filling album information
Damyan Ivanov [Thu, 11 Nov 2021 20:03:47 +0000 (20:03 +0000)]
fix filling album information

some songs have Artist, some have AlbumArtist. mpd-feeder prefers the
later, but takes the former too

3 years agokey artists by AlbumArtists
Damyan Ivanov [Thu, 11 Nov 2021 15:11:26 +0000 (15:11 +0000)]
key artists by AlbumArtists

removes a favouring of compilation albums

perhaps en even better approach would be to consider both AlbumArtist
and Artist

3 years agoinclude wanted playlist size when reporting its current state
Damyan Ivanov [Thu, 11 Nov 2021 14:47:06 +0000 (14:47 +0000)]
include wanted playlist size when reporting its current state

3 years agodump configuration to STDERR on SIGUSR1
Damyan Ivanov [Thu, 11 Nov 2021 14:46:46 +0000 (14:46 +0000)]
dump configuration to STDERR on SIGUSR1

3 years agoparse wanted playlist length as an integer
Damyan Ivanov [Thu, 11 Nov 2021 14:46:05 +0000 (14:46 +0000)]
parse wanted playlist length as an integer

3 years agoinitially, log only errors
Damyan Ivanov [Thu, 11 Nov 2021 14:44:57 +0000 (14:44 +0000)]
initially, log only errors

no need to always see details on command line/options parsing

3 years agore-exec on SIGHUP, picking up configuration file changes
Damyan Ivanov [Thu, 11 Nov 2021 14:43:57 +0000 (14:43 +0000)]
re-exec on SIGHUP, picking up configuration file changes

my first approach was to just re-read the config, but could not make
the idle/playlist loop  behave. it gets stuck with responses getting
lost and eventually is disconnected my MPD due to timeout

re-exec works, but there is a (very small) chance of missing a database
update between disconnection and re-connection to MPD.

3 years agodebug--
Damyan Ivanov [Thu, 11 Nov 2021 12:40:18 +0000 (12:40 +0000)]
debug--

3 years agoimplement {add,del}-unwanted-artist commands
Damyan Ivanov [Thu, 11 Nov 2021 12:37:15 +0000 (12:37 +0000)]
implement {add,del}-unwanted-artist commands

3 years agorename unwanted artist/album tables
Damyan Ivanov [Thu, 11 Nov 2021 12:35:37 +0000 (12:35 +0000)]
rename unwanted artist/album tables

3 years agodo not print Pg errors, RaiseError=>1 is enough
Damyan Ivanov [Thu, 11 Nov 2021 12:34:07 +0000 (12:34 +0000)]
do not print Pg errors, RaiseError=>1 is enough

3 years agopostpone db update for when it is really needed
Damyan Ivanov [Thu, 11 Nov 2021 11:15:38 +0000 (11:15 +0000)]
postpone db update for when it is really needed

would help lower the load when massive changes to the db are made

the db will be updated when a new song needs to be queued, and until
that need arises the db may be changed again

the (not that big) delay for db update when new song is needed is not
a problem, because it is about keeping the playlist full -- not an
urgent need

3 years agomake database update a synchronous operation
Damyan Ivanov [Thu, 11 Nov 2021 11:08:04 +0000 (11:08 +0000)]
make database update a synchronous operation

when someone calls for it, they rely that after the call to ->update_db
returns the database is fresh

there are tree callers - 'single', 'one-shot' and the database update
notification

3 years agomore on-demand connections
Damyan Ivanov [Thu, 11 Nov 2021 10:57:20 +0000 (10:57 +0000)]
more on-demand connections

3 years agorework command line handling - commands are commands, options are --options
Damyan Ivanov [Thu, 11 Nov 2021 10:39:08 +0000 (10:39 +0000)]
rework command line handling - commands are commands, options are --options

also, initializa connections only if/when needed

3 years agoLog::Any, proper idle looping
Damyan Ivanov [Thu, 11 Nov 2021 09:43:26 +0000 (09:43 +0000)]
Log::Any, proper idle looping

could not make Net::Async::MPD->idle work as expected, and the "manual"
method seems reliable

3 years agofix handling of database info
Damyan Ivanov [Thu, 11 Nov 2021 09:26:45 +0000 (09:26 +0000)]
fix handling of database info

3 years agoproper mpd connection initialization
Damyan Ivanov [Thu, 11 Nov 2021 09:25:27 +0000 (09:25 +0000)]
proper mpd connection initialization

3 years agomake feeder->mpd accessible
Damyan Ivanov [Thu, 11 Nov 2021 09:24:55 +0000 (09:24 +0000)]
make feeder->mpd accessible

3 years agodeclare used modules
Damyan Ivanov [Thu, 11 Nov 2021 09:24:18 +0000 (09:24 +0000)]
declare used modules

3 years agoadded --skip-db-update option
Damyan Ivanov [Thu, 11 Nov 2021 09:23:28 +0000 (09:23 +0000)]
added --skip-db-update option

skips initial database update

3 years agofix interval handling when finding suitable songs
Damyan Ivanov [Thu, 11 Nov 2021 09:22:15 +0000 (09:22 +0000)]
fix interval handling when finding suitable songs

3 years agofixed SQL param numbers
Damyan Ivanov [Thu, 11 Nov 2021 09:20:17 +0000 (09:20 +0000)]
fixed SQL param numbers

3 years agofixed database connection string
Damyan Ivanov [Thu, 11 Nov 2021 09:19:56 +0000 (09:19 +0000)]
fixed database connection string

3 years agoinitial source import
Damyan Ivanov [Wed, 10 Nov 2021 06:20:21 +0000 (06:20 +0000)]
initial source import

option/config parsing works, perhaps the db interactions too