Check wheter player is running before trying to report on a song

This commit is contained in:
zvon 2020-05-29 22:10:42 +02:00
parent 5663c2a8c1
commit 5b5ebb4736

4
main.c
View File

@ -67,7 +67,7 @@ int main( int argc, char **argv ) {
if ( requests & SONG_FLAG || requests & META_FLAG ) { if ( requests & SONG_FLAG || requests & META_FLAG ) {
struct song_metadata song = { 0 }; struct song_metadata song = { 0 };
if ( sources & MPD_FLAG ) { if ( sources & MPD_FLAG && mpdRunning( mpd_connection ) ) {
song = mpdGetSong( mpd_connection ); song = mpdGetSong( mpd_connection );
if ( requests & SONG_FLAG ) if ( requests & SONG_FLAG )
printSong( &song ); printSong( &song );
@ -77,6 +77,8 @@ int main( int argc, char **argv ) {
if ( sources & DBUS_FLAG ) { if ( sources & DBUS_FLAG ) {
for ( char **player = dbus_players; *player; ++player ) { for ( char **player = dbus_players; *player; ++player ) {
if ( !dbusRunning( dbus_connection, *player ) )
continue;
song = dbusGetSong( dbus_connection, *player ); song = dbusGetSong( dbus_connection, *player );
if ( requests & SONG_FLAG ) if ( requests & SONG_FLAG )
printSong( &song ); printSong( &song );