Check if mpd is connected before running/playing

This commit is contained in:
zvon 2020-05-31 13:29:55 +02:00
parent 5b5ebb4736
commit 1e9428e2e9

View File

@ -74,6 +74,8 @@ void mpdStop( struct mpd_connection *mpd_connection ) {
}
enum mpd_state mpdStatus( struct mpd_connection *mpd_connection ) {
if( mpd_connection == NULL )
return -1;
struct mpd_status *status = mpd_run_status( mpd_connection );
if ( status == NULL )
return -1;
@ -84,7 +86,7 @@ enum mpd_state mpdStatus( struct mpd_connection *mpd_connection ) {
bool mpdRunning( struct mpd_connection *mpd_connection ) {
enum mpd_state state = mpdStatus( mpd_connection );
return state != MPD_STATE_STOP && state != MPD_STATE_UNKNOWN;
return state == MPD_STATE_PAUSE || state == MPD_STATE_PLAY;
}
bool mpdPlaying( struct mpd_connection *mpd_connection ) {