Formatting

This commit is contained in:
zvon 2020-05-29 20:54:05 +02:00
parent 4ff070b731
commit a3a7947975
5 changed files with 39 additions and 38 deletions

View File

@ -147,7 +147,8 @@ struct song_metadata dbusGetSong( DBusConnection *conn, const char *player ) {
dbus_message_iter_recurse( &variant, &artists );
dbus_message_iter_get_basic( &artists, &meta_val );
ret.artist = strdup( meta_val );
} else if ( dbus_message_iter_get_arg_type( &variant ) == DBUS_TYPE_STRING ) {
} else if ( dbus_message_iter_get_arg_type( &variant ) ==
DBUS_TYPE_STRING ) {
dbus_message_iter_get_basic( &variant, &meta_val );
if ( !strcmp( meta_name, "xesam:title" ) )
ret.title = strdup( meta_val );
@ -230,7 +231,7 @@ bool dbusPlaying( DBusConnection *conn, const char *player ) {
}
void dbusFreePlyaers( char **dbus_players ) {
for( char **player = dbus_players; *player; ++player ) {
for ( char **player = dbus_players; *player; ++player ) {
free( *player );
}
free( dbus_players );

40
main.c
View File

@ -70,7 +70,7 @@ int main( int argc, char **argv ) {
if ( sources & DBUS_FLAG ) {
for ( char **player = dbus_players; *player; ++player ) {
if( !dbusPlaying( dbus_connection, *player ) )
if ( !dbusPlaying( dbus_connection, *player ) )
continue;
song = dbusGetSong( dbus_connection, *player );
if ( requests & SONG_FLAG )
@ -82,51 +82,51 @@ int main( int argc, char **argv ) {
freeSong( &song );
}
if( requests & RUNNING_FLAG ) {
if ( requests & RUNNING_FLAG ) {
ret = EXIT_FAILURE;
if( sources & MPD_FLAG && mpdRunning( mpd_connection ) )
if ( sources & MPD_FLAG && mpdRunning( mpd_connection ) )
ret = EXIT_SUCCESS;
if( sources & DBUS_FLAG ) {
for( char **player = dbus_players; *player; ++player ) {
if( dbusRunning( dbus_connection, *player ) )
if ( sources & DBUS_FLAG ) {
for ( char **player = dbus_players; *player; ++player ) {
if ( dbusRunning( dbus_connection, *player ) )
ret = EXIT_SUCCESS;
}
}
}
if( requests & NEXT_FLAG ) {
if( sources & MPD_FLAG )
if ( requests & NEXT_FLAG ) {
if ( sources & MPD_FLAG )
mpdNext( mpd_connection );
if( sources & DBUS_FLAG ) {
for( char **player = dbus_players; *player; ++player ) {
if ( sources & DBUS_FLAG ) {
for ( char **player = dbus_players; *player; ++player ) {
dbusNext( dbus_connection, *player );
}
}
}
if( requests & PREV_FLAG ) {
if( sources & MPD_FLAG )
if ( requests & PREV_FLAG ) {
if ( sources & MPD_FLAG )
mpdPrev( mpd_connection );
if( sources & DBUS_FLAG ) {
for( char **player = dbus_players; *player; ++player ) {
if ( sources & DBUS_FLAG ) {
for ( char **player = dbus_players; *player; ++player ) {
dbusPrev( dbus_connection, *player );
}
}
}
if( requests & PLAY_FLAG ) {
if( sources & MPD_FLAG )
if ( requests & PLAY_FLAG ) {
if ( sources & MPD_FLAG )
mpdPlayPause( mpd_connection );
if( sources & DBUS_FLAG ) {
for( char **player = dbus_players; *player; ++player ) {
if ( sources & DBUS_FLAG ) {
for ( char **player = dbus_players; *player; ++player ) {
dbusPlayPause( dbus_connection, *player );
}
}
}
if( sources & DBUS_FLAG ) {
if ( sources & DBUS_FLAG ) {
dbusFreePlyaers( dbus_players );
dbusDisconnect( dbus_connection );
}
if( sources & MPD_FLAG ) {
if ( sources & MPD_FLAG ) {
mpdDisconnect( mpd_connection );
}

View File

@ -24,16 +24,16 @@ void printMeta( struct song_metadata *song ) {
}
void freeSong( struct song_metadata *song ) {
free( (void*)song->art_uri );
free( ( void * )song->art_uri );
song->art_uri = NULL;
free( (void*)song->file );
free( ( void * )song->file );
song->file = NULL;
free( (void*)song->year );
free( ( void * )song->year );
song->year = NULL;
free( (void*)song->artist );
free( ( void * )song->artist );
song->artist = NULL;
free( (void*)song->album );
free( ( void * )song->album );
song->album = NULL;
free( (void*)song->title );
free( ( void * )song->title );
song->title = NULL;
}

View File

@ -2,12 +2,12 @@
#define METADATA_H
struct song_metadata {
const char *title;
const char *artist;
const char *album;
const char *year;
const char *file;
const char *art_uri;
const char *title;
const char *artist;
const char *album;
const char *year;
const char *file;
const char *art_uri;
};
void printSong( struct song_metadata *song );

View File

@ -33,13 +33,13 @@ struct song_metadata mpdGetSong( struct mpd_connection *mpd_connection ) {
// TODO check return values
ret.title = strdup( copy );
copy = mpd_song_get_tag( song, MPD_TAG_ARTIST, 0 );
if( copy != NULL )
if ( copy != NULL )
ret.artist = strdup( copy );
copy = mpd_song_get_tag( song, MPD_TAG_ALBUM, 0 );
if( copy != NULL )
if ( copy != NULL )
ret.album = strdup( copy );
copy = mpd_song_get_tag( song, MPD_TAG_DATE, 0 );
if( copy != NULL )
if ( copy != NULL )
ret.year = strdup( copy );
ret.file = strdup( mpd_song_get_uri( song ) );
@ -67,7 +67,7 @@ void mpdStop( struct mpd_connection *mpd_connection ) {
enum mpd_state mpdStatus( struct mpd_connection *mpd_connection ) {
struct mpd_status *status = mpd_run_status( mpd_connection );
if( status == NULL )
if ( status == NULL )
return -1;
enum mpd_state ret = mpd_status_get_state( status );
mpd_status_free( status );