From: Mike Brady Date: Sun, 19 Nov 2017 21:41:11 +0000 (+0000) Subject: Clang-format X-Git-Tag: 3.2d13~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bafdd94e338944cfea33430ea35922f95cc224f9;p=thirdparty%2Fshairport-sync.git Clang-format --- diff --git a/common.h b/common.h index ed69d6db..719ff702 100644 --- a/common.h +++ b/common.h @@ -36,7 +36,7 @@ #if defined(HAVE_DBUS) || defined(HAVE_MPRIS) enum dbus_session_type { DBT_system = 0, // use the session bus - DBT_session, // use the system bus + DBT_session, // use the system bus } dbt_type; #endif diff --git a/dbus-service.c b/dbus-service.c index 6fb9f1ab..6d1a72c8 100644 --- a/dbus-service.c +++ b/dbus-service.c @@ -177,9 +177,10 @@ static gboolean on_handle_remote_command(ShairportSync *skeleton, GDBusMethodInv return TRUE; } -static void on_dbus_name_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data) { +static void on_dbus_name_acquired(GDBusConnection *connection, const gchar *name, + gpointer user_data) { - debug(1,"Well-known interface name \"%s\" acquired for %s.",name,config.appName); + debug(1, "Well-known interface name \"%s\" acquired for %s.", name, config.appName); shairportSyncSkeleton = shairport_sync_skeleton_new(); g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(shairportSyncSkeleton), connection, @@ -201,35 +202,40 @@ static void on_dbus_name_acquired(GDBusConnection *connection, const gchar *name G_CALLBACK(notify_loudness_filter_active_callback), NULL); g_signal_connect(shairportSyncSkeleton, "notify::loudness-threshold", G_CALLBACK(notify_loudness_threshold_callback), NULL); - g_signal_connect(shairportSyncSkeleton, "notify::volume", G_CALLBACK(notify_volume_callback), NULL); - g_signal_connect(shairportSyncSkeleton, "handle-remote-command", G_CALLBACK(on_handle_remote_command), NULL); - debug(1,"Shairport Sync D-BUS service started on interface \"%s\".",name); + g_signal_connect(shairportSyncSkeleton, "notify::volume", G_CALLBACK(notify_volume_callback), + NULL); + g_signal_connect(shairportSyncSkeleton, "handle-remote-command", + G_CALLBACK(on_handle_remote_command), NULL); + debug(1, "Shairport Sync D-BUS service started on interface \"%s\".", name); } -static void on_dbus_name_lost_again(GDBusConnection *connection, const gchar *name, gpointer user_data) { +static void on_dbus_name_lost_again(GDBusConnection *connection, const gchar *name, + gpointer user_data) { warn("Could not acquire an Shairport Sync D-BUS interface."); } static void on_dbus_name_lost(GDBusConnection *connection, const gchar *name, gpointer user_data) { - debug(1,"Could not acquire well-known interface name \"%s\" -- will try adding the process number to the end of it.",name); + debug(1, "Could not acquire well-known interface name \"%s\" -- will try adding the process " + "number to the end of it.", + name); pid_t pid = getpid(); char interface_name[256] = ""; - sprintf(interface_name,"org.gnome.ShairportSync.i%d",pid); + sprintf(interface_name, "org.gnome.ShairportSync.i%d", pid); GBusType dbus_bus_type = G_BUS_TYPE_SYSTEM; - if (config.dbus_service_bus_type==DBT_session) + if (config.dbus_service_bus_type == DBT_session) dbus_bus_type = G_BUS_TYPE_SESSION; - debug(1,"Looking for well-known interface name \"%s\".",interface_name); + debug(1, "Looking for well-known interface name \"%s\".", interface_name); g_bus_own_name(dbus_bus_type, interface_name, G_BUS_NAME_OWNER_FLAGS_NONE, NULL, - on_dbus_name_acquired, on_dbus_name_lost_again, NULL, NULL); + on_dbus_name_acquired, on_dbus_name_lost_again, NULL, NULL); } int start_dbus_service() { shairportSyncSkeleton = NULL; GBusType dbus_bus_type = G_BUS_TYPE_SYSTEM; - if (config.dbus_service_bus_type==DBT_session) + if (config.dbus_service_bus_type == DBT_session) dbus_bus_type = G_BUS_TYPE_SESSION; - debug(1,"Looking for well-known name \"org.gnome.ShairportSync\"."); + debug(1, "Looking for well-known name \"org.gnome.ShairportSync\"."); g_bus_own_name(dbus_bus_type, "org.gnome.ShairportSync", G_BUS_NAME_OWNER_FLAGS_NONE, NULL, - on_dbus_name_acquired, on_dbus_name_lost, NULL, NULL); + on_dbus_name_acquired, on_dbus_name_lost, NULL, NULL); return 0; // this is just to quieten a compiler warning } diff --git a/mpris-service.c b/mpris-service.c index c96a7749..bed5e836 100644 --- a/mpris-service.c +++ b/mpris-service.c @@ -12,11 +12,11 @@ #include "dacp.h" #include "mpris-service.h" -int send_simple_dacp_command(const char* command) { +int send_simple_dacp_command(const char *command) { int reply = 0; if (playing_conn) { char server_reply[2000]; - debug(1,"Sending command \"%s\".",command); + debug(1, "Sending command \"%s\".", command); ssize_t reply_size = dacp_send_client_command(playing_conn, command, server_reply, sizeof(server_reply)); if (reply_size >= 0) { @@ -52,40 +52,39 @@ int send_simple_dacp_command(const char* command) { } static gboolean on_handle_stop(MediaPlayer2Player *skeleton, GDBusMethodInvocation *invocation, - gpointer user_data) { + gpointer user_data) { send_simple_dacp_command("stop"); media_player2_player_complete_stop(skeleton, invocation); return TRUE; } static gboolean on_handle_pause(MediaPlayer2Player *skeleton, GDBusMethodInvocation *invocation, - gpointer user_data) { + gpointer user_data) { send_simple_dacp_command("pause"); media_player2_player_complete_pause(skeleton, invocation); return TRUE; } -static gboolean on_handle_play_pause(MediaPlayer2Player *skeleton, GDBusMethodInvocation *invocation, - gpointer user_data) { +static gboolean on_handle_play_pause(MediaPlayer2Player *skeleton, + GDBusMethodInvocation *invocation, gpointer user_data) { send_simple_dacp_command("playpause"); media_player2_player_complete_play_pause(skeleton, invocation); return TRUE; } static gboolean on_handle_play(MediaPlayer2Player *skeleton, GDBusMethodInvocation *invocation, - gpointer user_data) { + gpointer user_data) { send_simple_dacp_command("play"); media_player2_player_complete_play(skeleton, invocation); return TRUE; } -static void on_mpris_name_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data) { +static void on_mpris_name_acquired(GDBusConnection *connection, const gchar *name, + gpointer user_data) { -const char* empty_string_array[] = { - NULL -}; + const char *empty_string_array[] = {NULL}; - debug(1,"MPRIS well-known interface name \"%s\" acquired for %s.",name,config.appName); + debug(1, "MPRIS well-known interface name \"%s\" acquired for %s.", name, config.appName); mprisPlayerSkeleton = media_player2_skeleton_new(); mprisPlayerPlayerSkeleton = media_player2_player_skeleton_new(); @@ -93,62 +92,67 @@ const char* empty_string_array[] = { "/org/mpris/MediaPlayer2", NULL); g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(mprisPlayerPlayerSkeleton), connection, "/org/mpris/MediaPlayer2", NULL); - + media_player2_set_desktop_entry(mprisPlayerSkeleton, "shairport-sync"); media_player2_set_identity(mprisPlayerSkeleton, "Shairport Sync"); media_player2_set_can_quit(mprisPlayerSkeleton, FALSE); media_player2_set_can_raise(mprisPlayerSkeleton, FALSE); media_player2_set_has_track_list(mprisPlayerSkeleton, FALSE); - media_player2_set_supported_uri_schemes (mprisPlayerSkeleton,empty_string_array); - media_player2_set_supported_mime_types (mprisPlayerSkeleton, empty_string_array); - - media_player2_player_set_playback_status (mprisPlayerPlayerSkeleton, "stop"); - media_player2_player_set_loop_status (mprisPlayerPlayerSkeleton, "off"); - media_player2_player_set_volume (mprisPlayerPlayerSkeleton, 0.5); - media_player2_player_set_minimum_rate (mprisPlayerPlayerSkeleton,1.0); - media_player2_player_set_maximum_rate (mprisPlayerPlayerSkeleton,1.0); - media_player2_player_set_can_go_next (mprisPlayerPlayerSkeleton,FALSE); - media_player2_player_set_can_go_previous (mprisPlayerPlayerSkeleton,FALSE); - media_player2_player_set_can_play (mprisPlayerPlayerSkeleton, TRUE); - media_player2_player_set_can_pause (mprisPlayerPlayerSkeleton,TRUE); - media_player2_player_set_can_seek (mprisPlayerPlayerSkeleton, FALSE); - media_player2_player_set_can_control (mprisPlayerPlayerSkeleton, TRUE); - + media_player2_set_supported_uri_schemes(mprisPlayerSkeleton, empty_string_array); + media_player2_set_supported_mime_types(mprisPlayerSkeleton, empty_string_array); + + media_player2_player_set_playback_status(mprisPlayerPlayerSkeleton, "stop"); + media_player2_player_set_loop_status(mprisPlayerPlayerSkeleton, "off"); + media_player2_player_set_volume(mprisPlayerPlayerSkeleton, 0.5); + media_player2_player_set_minimum_rate(mprisPlayerPlayerSkeleton, 1.0); + media_player2_player_set_maximum_rate(mprisPlayerPlayerSkeleton, 1.0); + media_player2_player_set_can_go_next(mprisPlayerPlayerSkeleton, FALSE); + media_player2_player_set_can_go_previous(mprisPlayerPlayerSkeleton, FALSE); + media_player2_player_set_can_play(mprisPlayerPlayerSkeleton, TRUE); + media_player2_player_set_can_pause(mprisPlayerPlayerSkeleton, TRUE); + media_player2_player_set_can_seek(mprisPlayerPlayerSkeleton, FALSE); + media_player2_player_set_can_control(mprisPlayerPlayerSkeleton, TRUE); + g_signal_connect(mprisPlayerPlayerSkeleton, "handle-play", G_CALLBACK(on_handle_play), NULL); g_signal_connect(mprisPlayerPlayerSkeleton, "handle-pause", G_CALLBACK(on_handle_pause), NULL); - g_signal_connect(mprisPlayerPlayerSkeleton, "handle-play-pause", G_CALLBACK(on_handle_play_pause), NULL); + g_signal_connect(mprisPlayerPlayerSkeleton, "handle-play-pause", G_CALLBACK(on_handle_play_pause), + NULL); g_signal_connect(mprisPlayerPlayerSkeleton, "handle-stop", G_CALLBACK(on_handle_stop), NULL); - - debug(1,"Shairport Sync D-BUS service started on interface \"%s\".",name); - debug(1,"MPRIS service started on interface \"%s\".",name); + debug(1, "Shairport Sync D-BUS service started on interface \"%s\".", name); + + debug(1, "MPRIS service started on interface \"%s\".", name); } -static void on_mpris_name_lost_again(GDBusConnection *connection, const gchar *name, gpointer user_data) { +static void on_mpris_name_lost_again(GDBusConnection *connection, const gchar *name, + gpointer user_data) { warn("Could not acquire an MPRIS interface."); } static void on_mpris_name_lost(GDBusConnection *connection, const gchar *name, gpointer user_data) { - debug(1,"Could not acquire well-known interface name \"%s\" -- will try adding the process number to the end of it.",name); + debug(1, "Could not acquire well-known interface name \"%s\" -- will try adding the process " + "number to the end of it.", + name); pid_t pid = getpid(); char interface_name[256] = ""; - sprintf(interface_name,"org.mpris.MediaPlayer2.ShairportSync.i%d",pid); + sprintf(interface_name, "org.mpris.MediaPlayer2.ShairportSync.i%d", pid); GBusType mpris_bus_type = G_BUS_TYPE_SYSTEM; - if (config.mpris_service_bus_type==DBT_session) + if (config.mpris_service_bus_type == DBT_session) mpris_bus_type = G_BUS_TYPE_SESSION; - debug(1,"Looking for well-known interface name \"%s\".",interface_name); + debug(1, "Looking for well-known interface name \"%s\".", interface_name); g_bus_own_name(mpris_bus_type, interface_name, G_BUS_NAME_OWNER_FLAGS_NONE, NULL, - on_mpris_name_acquired, on_mpris_name_lost_again, NULL, NULL); + on_mpris_name_acquired, on_mpris_name_lost_again, NULL, NULL); } int start_mpris_service() { mprisPlayerSkeleton = NULL; mprisPlayerPlayerSkeleton = NULL; GBusType mpris_bus_type = G_BUS_TYPE_SYSTEM; - if (config.mpris_service_bus_type==DBT_session) + if (config.mpris_service_bus_type == DBT_session) mpris_bus_type = G_BUS_TYPE_SESSION; - debug(1,"Looking for well-known name \"org.mpris.MediaPlayer2.ShairportSync\"."); - g_bus_own_name(mpris_bus_type, "org.mpris.MediaPlayer2.ShairportSync", G_BUS_NAME_OWNER_FLAGS_NONE, NULL, - on_mpris_name_acquired, on_mpris_name_lost, NULL, NULL); + debug(1, "Looking for well-known name \"org.mpris.MediaPlayer2.ShairportSync\"."); + g_bus_own_name(mpris_bus_type, "org.mpris.MediaPlayer2.ShairportSync", + G_BUS_NAME_OWNER_FLAGS_NONE, NULL, on_mpris_name_acquired, on_mpris_name_lost, + NULL, NULL); return 0; // this is just to quieten a compiler warning } diff --git a/player.c b/player.c index e7b3ce65..f2c55eff 100644 --- a/player.c +++ b/player.c @@ -69,8 +69,8 @@ #endif #if defined(HAVE_DBUS) || defined(HAVE_MPRIS) -#include #include "dacp.h" +#include #endif #ifdef HAVE_DBUS @@ -80,8 +80,8 @@ #ifdef HAVE_MPRIS #include "mpris-interface.h" -#include "mpris-service.h" #include "mpris-player-interface.h" +#include "mpris-service.h" #endif #include "common.h" @@ -1045,13 +1045,12 @@ static abuf_t *buffer_get_frame(rtsp_conn_info *conn) { 0); // "resume", but don't wait if the queue is locked #endif #if defined(HAVE_MPRIS) - if ((conn->play_state!=SST_stopped) && (conn->play_state!=SST_playing)) { - conn->play_state=SST_playing; + if ((conn->play_state != SST_stopped) && (conn->play_state != SST_playing)) { + conn->play_state = SST_playing; debug(1, "MPRIS Playing"); - media_player2_player_set_playback_status (mprisPlayerPlayerSkeleton, "Playing"); + media_player2_player_set_playback_status(mprisPlayerPlayerSkeleton, "Playing"); } #endif - } } } @@ -2517,10 +2516,10 @@ void player_flush(int64_t timestamp, rtsp_conn_info *conn) { send_ssnc_metadata('pfls', NULL, 0, 1); #endif #if defined(HAVE_MPRIS) - if ((conn->play_state!=SST_stopped) && (conn->play_state!=SST_paused)) - conn->play_state=SST_paused; - debug(1, "MPRIS Paused"); - media_player2_player_set_playback_status (mprisPlayerPlayerSkeleton, "Paused"); + if ((conn->play_state != SST_stopped) && (conn->play_state != SST_paused)) + conn->play_state = SST_paused; + debug(1, "MPRIS Paused"); + media_player2_player_set_playback_status(mprisPlayerPlayerSkeleton, "Paused"); #endif } @@ -2548,10 +2547,10 @@ int player_play(rtsp_conn_info *conn) { pthread_create(pt, &tattr, player_thread_func, (void *)conn); pthread_attr_destroy(&tattr); #if defined(HAVE_MPRIS) - if (conn->play_state!=SST_playing) - conn->play_state=SST_playing; + if (conn->play_state != SST_playing) + conn->play_state = SST_playing; debug(1, "MPRIS Playing (play)"); - media_player2_player_set_playback_status (mprisPlayerPlayerSkeleton, "Playing"); + media_player2_player_set_playback_status(mprisPlayerPlayerSkeleton, "Playing"); #endif return 0; } @@ -2569,10 +2568,10 @@ void player_stop(rtsp_conn_info *conn) { free(conn->player_thread); conn->player_thread = NULL; #if defined(HAVE_MPRIS) - if (conn->play_state!=SST_stopped) - conn->play_state=SST_stopped; + if (conn->play_state != SST_stopped) + conn->play_state = SST_stopped; debug(1, "MPRIS Stopped"); - media_player2_player_set_playback_status (mprisPlayerPlayerSkeleton, "Stopped"); + media_player2_player_set_playback_status(mprisPlayerPlayerSkeleton, "Stopped"); #endif } else { diff --git a/player.h b/player.h index d3e83c89..b0e923ea 100644 --- a/player.h +++ b/player.h @@ -28,12 +28,11 @@ #if defined(HAVE_DBUS) || defined(HAVE_MPRIS) enum session_status_type { SST_stopped = 0, // not playing anything - SST_paused, // paused + SST_paused, // paused SST_playing, } sst_type; #endif - typedef struct time_ping_record { uint64_t local_to_remote_difference; uint64_t dispersion; diff --git a/rtsp.c b/rtsp.c index d36c5ce0..420851f4 100644 --- a/rtsp.c +++ b/rtsp.c @@ -958,7 +958,7 @@ static void handle_set_parameter_parameter(rtsp_conn_info *conn, rtsp_message *r // `clip` -- the payload is the IP number of the client, i.e. the sender of audio. // Can be an IPv4 or an IPv6 number. // `dapo` -- the payload is the port number (as text) on the server to which remote -//control commands should be sent. It is 3689 for iTunes but varies for iOS devices. +// control commands should be sent. It is 3689 for iTunes but varies for iOS devices. // A special sub-protocol is used for sending large data items over UDP // If the payload exceeded 4 MB, it is chunked using the following format: diff --git a/shairport-sync-mpris-test-client.c b/shairport-sync-mpris-test-client.c index e4418bf0..310ffe23 100644 --- a/shairport-sync-mpris-test-client.c +++ b/shairport-sync-mpris-test-client.c @@ -55,26 +55,26 @@ int main(void) { MediaPlayer2 *proxy; MediaPlayer2Player *proxy2; - + GError *error = NULL; -/* - proxy = media_player2_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, - "org.mpris.MediaPlayer2.ShairportSync", - "/org/mpris/MediaPlayer2", NULL, &error); - g_signal_connect(proxy, "g-properties-changed", G_CALLBACK(on_properties_changed), NULL); -*/ + /* + proxy = media_player2_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, + "org.mpris.MediaPlayer2.ShairportSync", + "/org/mpris/MediaPlayer2", NULL, &error); + g_signal_connect(proxy, "g-properties-changed", G_CALLBACK(on_properties_changed), NULL); + */ proxy2 = media_player2_player_proxy_new_for_bus_sync(G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, - "org.mpris.MediaPlayer2.ShairportSync", - "/org/mpris/MediaPlayer2", NULL, &error); + "org.mpris.MediaPlayer2.ShairportSync", + "/org/mpris/MediaPlayer2", NULL, &error); g_signal_connect(proxy2, "g-properties-changed", G_CALLBACK(on_properties_changed), NULL); - //sleep(120); - //g_main_loop_quit(loop); + // sleep(120); + // g_main_loop_quit(loop); pthread_join(dbus_thread, NULL); printf("exiting program.\n"); -// g_object_unref(proxy); + // g_object_unref(proxy); g_object_unref(proxy2); return 0; diff --git a/shairport.c b/shairport.c index 7731bd95..b2a94649 100644 --- a/shairport.c +++ b/shairport.c @@ -66,7 +66,6 @@ #include "mpris-service.h" #endif - #include "common.h" #include "mdns.h" #include "rtp.h" @@ -865,30 +864,31 @@ int parse_options(int argc, char **argv) { } } #if defined(HAVE_DBUS) - /* Get the dbus service sbus setting. */ - if (config_lookup_string(config.cfg, "general.dbus_service_bus", &str)) { - if (strcasecmp(str, "system") == 0) - config.dbus_service_bus_type = DBT_system; - else if (strcasecmp(str, "session") == 0) - config.dbus_service_bus_type = DBT_session; - else - die("Invalid dbus_service_bus option choice \"%s\". It should be \"system\" (default) or \"session\""); - } + /* Get the dbus service sbus setting. */ + if (config_lookup_string(config.cfg, "general.dbus_service_bus", &str)) { + if (strcasecmp(str, "system") == 0) + config.dbus_service_bus_type = DBT_system; + else if (strcasecmp(str, "session") == 0) + config.dbus_service_bus_type = DBT_session; + else + die("Invalid dbus_service_bus option choice \"%s\". It should be \"system\" (default) or " + "\"session\""); + } #endif #if defined(HAVE_MPRIS) - /* Get the mpris service sbus setting. */ - if (config_lookup_string(config.cfg, "general.mpris_service_bus", &str)) { - if (strcasecmp(str, "system") == 0) - config.mpris_service_bus_type = DBT_system; - else if (strcasecmp(str, "session") == 0) - config.mpris_service_bus_type = DBT_session; - else - die("Invalid mpris_service_bus option choice \"%s\". It should be \"system\" (default) or \"session\""); - } + /* Get the mpris service sbus setting. */ + if (config_lookup_string(config.cfg, "general.mpris_service_bus", &str)) { + if (strcasecmp(str, "system") == 0) + config.mpris_service_bus_type = DBT_system; + else if (strcasecmp(str, "session") == 0) + config.mpris_service_bus_type = DBT_session; + else + die("Invalid mpris_service_bus option choice \"%s\". It should be \"system\" (default) or " + "\"session\""); + } #endif - free(config_file_real_path); } @@ -1065,7 +1065,7 @@ const char *pid_file_proc(void) { } void exit_function() { - debug(1,"exit function called..."); + debug(1, "exit function called..."); if (config.cfg) config_destroy(config.cfg); if (config.appName)