From: Mike Brady Date: Tue, 6 Mar 2018 08:50:34 +0000 (+0000) Subject: Add lots of debug messages, begin to use correctly sized PRId64 and friends in sprint... X-Git-Tag: 3.2d29~41 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=73bf006c122564a6643724fc0fddc0f3e10d97ef;p=thirdparty%2Fshairport-sync.git Add lots of debug messages, begin to use correctly sized PRId64 and friends in sprintf commands, begin to remove some simple causes of warnings. --- diff --git a/dacp.c b/dacp.c index 500b9365..daffc4a6 100644 --- a/dacp.c +++ b/dacp.c @@ -40,6 +40,7 @@ #include #include #include +#include #include "metadata_hub.h" #include "tinyhttp/http.h" @@ -279,7 +280,7 @@ void set_dacp_server_information(rtsp_conn_info *conn) { // tell the DACP conver void *dacp_monitor_thread_code(void *na) { int scan_index = 0; - char server_reply[10000]; + // char server_reply[10000]; // debug(1, "DACP monitor thread started."); // wait until we get a valid port number to begin monitoring it int32_t revision_number = 1; @@ -321,17 +322,17 @@ void *dacp_monitor_thread_code(void *na) { metadata_store.playerstatusupdates_are_received = 1; sp -= item_size; // drop down into the array -- don't skip over it le -= 8; - char typestring[5]; + // char typestring[5]; // we need to acquire the metadata data structure and possibly update it while (le >= 8) { uint32_t type = dacp_tlv_crawl(&sp, &item_size); le -= item_size + 8; char *t; - char u; - char *st; + // char u; + // char *st; int32_t r; - uint64_t s, v; - int i; + // uint64_t v; + // int i; switch (type) { case 'cmsr': // revision number @@ -615,6 +616,7 @@ uint32_t dacp_tlv_crawl(char **p, int32_t *length) { } int dacp_get_client_volume(int32_t *result) { + debug(1,"dacp_get_client_volume"); char *server_reply = NULL; int32_t overall_volume = -1; ssize_t reply_size; @@ -646,16 +648,19 @@ int dacp_get_client_volume(int32_t *result) { } /* else { debug(1, "Unexpected response %d to dacp volume control request", response); } */ - if (result) + if (result) { *result=overall_volume; + debug(1,"dacp_get_client_volume returns: %" PRId32 ".",overall_volume); + } return response; } int dacp_set_include_speaker_volume(int64_t machine_number, int32_t vo) { + debug(1,"dacp_set_include_speaker_volume to %" PRId32 ".",vo); char message[1000]; memset(message, 0, sizeof(message)); - sprintf(message, "setproperty?include-speaker-id=%ld&dmcp.volume=%d", machine_number, vo); - // debug(1,"sending \"%s\"",message); + sprintf(message, "setproperty?include-speaker-id=%" PRId64 "&dmcp.volume=%" PRId32 "", machine_number, vo); + debug(1,"sending \"%s\"",message); return send_simple_dacp_command(message); // should return 204 } @@ -663,14 +668,14 @@ int dacp_set_include_speaker_volume(int64_t machine_number, int32_t vo) { int dacp_set_speaker_volume(int64_t machine_number, int32_t vo) { char message[1000]; memset(message, 0, sizeof(message)); - sprintf(message, "setproperty?speaker-id=%ld&dmcp.volume=%d", machine_number, vo); - // debug(1,"sending \"%s\"",message); + sprintf(message, "setproperty?speaker-id=%" PRId64 "&dmcp.volume=%" PRId32 "", machine_number, vo); + debug(1,"sending \"%s\"",message); return send_simple_dacp_command(message); // should return 204 } int dacp_get_speaker_list(dacp_spkr_stuff *speaker_info, int max_size_of_array, int *actual_speaker_count) { - char typestring[5]; + // char typestring[5]; char *server_reply = NULL; int speaker_index = -1; // will be incremented before use int speaker_count = -1; // will be fixed if there is no problem @@ -701,7 +706,7 @@ int dacp_get_speaker_list(dacp_spkr_stuff *speaker_info, int max_size_of_array, } else { le -= item_size + 8; char *t; - char u; + // char u; int32_t r; int64_t s, v; switch (type) { @@ -790,11 +795,10 @@ int dacp_get_volume(int32_t *the_actual_volume) { int32_t overall_volume = 0; int32_t actual_volume = 0; int http_response = dacp_get_client_volume(&overall_volume); - // debug(1, "DACP Volume: %d.", overall_volume); if (http_response==200) { + debug(1,"Overall volume is: %u.",overall_volume); int speaker_count = 0; http_response = dacp_get_speaker_list((dacp_spkr_stuff *)&speaker_info, 50,&speaker_count); - // debug(1,"DACP Speaker Count: %d.",speaker_count); if (http_response==200) { // get our machine number uint16_t *hn = (uint16_t *)config.hw_addr; @@ -808,19 +812,18 @@ int dacp_get_volume(int32_t *the_actual_volume) { int32_t relative_volume = 0; for (i = 0; i < speaker_count; i++) { if (speaker_info[i].speaker_number == machine_number) { - // debug(1,"Our speaker number found: %ld.",machine_number); relative_volume = speaker_info[i].volume; - /* + debug(1,"Our speaker was found with a relative volume of: %u.",relative_volume); + if (speaker_info[i].active) debug(1,"Our speaker is active."); else debug(1,"Our speaker is inactive."); - */ + } } actual_volume = (overall_volume * relative_volume + 50) / 100; - // debug(1,"Overall volume: %d, relative volume: %d%, actual volume: - // %d.",overall_volume,relative_volume,actual_volume); + debug(1,"Overall volume: %d, relative volume: %d%, actual volume: %d.",overall_volume,relative_volume,actual_volume); // debug(1,"Our actual speaker volume is %d.",actual_volume); //metadata_hub_modify_prolog(); //metadata_store.speaker_volume = actual_volume; @@ -828,10 +831,12 @@ int dacp_get_volume(int32_t *the_actual_volume) { } else { debug(1,"Unexpected return code %d from dacp_get_speaker_list.",http_response); } - } /* else { + } else { debug(1,"Unexpected return code %d from dacp_get_client_volume.",http_response); - } */ - if (the_actual_volume) + } + if (the_actual_volume) { + debug(1,"dacp_get_volume returns %d.",actual_volume); *the_actual_volume = actual_volume; - return http_response; + } + return http_response; } diff --git a/dbus-service.c b/dbus-service.c index 524bbb3f..473a9293 100644 --- a/dbus-service.c +++ b/dbus-service.c @@ -44,13 +44,14 @@ gboolean notify_loudness_threshold_callback(ShairportSync *skeleton, gpointer us } gboolean notify_volume_callback(ShairportSync *skeleton, gpointer user_data) { - gint vo = shairport_sync_get_volume(skeleton); + gint gvo = shairport_sync_get_volume(skeleton); + int32_t vo = gvo; if ((vo >= 0) && (vo <= 100)) { if (playing_conn) { if (vo != playing_conn ->dacp_volume) { // this is to stop an infinite loop of setting->checking->setting... - // debug(1, "Remote-setting volume to %d.", vo); + debug(1, "Remote-setting volume to %d.", vo); // get the information we need -- the absolute volume, the speaker list, our ID struct dacp_speaker_stuff speaker_info[50]; int32_t overall_volume; @@ -67,12 +68,10 @@ gboolean notify_volume_callback(ShairportSync *skeleton, gpointer user_data) { // Let's find our own speaker in the array and pick up its relative volume int i; - int32_t relative_volume = 0; int32_t active_speakers = 0; for (i = 0; i < speaker_count; i++) { if (speaker_info[i].speaker_number == machine_number) { - // debug(1,"Our speaker number found: %ld.",machine_number); - relative_volume = speaker_info[i].volume; + debug(1,"Our speaker number found: %ld with relative volume.",machine_number,speaker_info[i].volume); } if (speaker_info[i].active == 1) { active_speakers++; @@ -81,13 +80,14 @@ gboolean notify_volume_callback(ShairportSync *skeleton, gpointer user_data) { if (active_speakers == 1) { // must be just this speaker + debug(1, "Remote-setting volume to %d on just one speaker.", vo); dacp_set_include_speaker_volume(machine_number, vo); } else if (active_speakers == 0) { debug(1, "No speakers!"); } else { - // debug(1, "Speakers: %d, active: %d",speaker_count,active_speakers); + debug(1, "Speakers: %d, active: %d",speaker_count,active_speakers); if (vo >= overall_volume) { - // debug(1,"Multiple speakers active, but desired new volume is highest"); + debug(1,"Multiple speakers active, but desired new volume is highest"); dacp_set_include_speaker_volume(machine_number, vo); } else { // the desired volume is less than the current overall volume and there is more than one @@ -112,32 +112,29 @@ gboolean notify_volume_callback(ShairportSync *skeleton, gpointer user_data) { } highest_other_volume = (highest_other_volume * overall_volume + 50) / 100; if (highest_other_volume <= vo) { - // debug(1,"Highest other volume %d is less than or equal to the desired new volume - // %d.",highest_other_volume,vo); + debug(1,"Highest other volume %d is less than or equal to the desired new volume %d.",highest_other_volume,vo); dacp_set_include_speaker_volume(machine_number, vo); } else { - // debug(1,"Highest other volume %d is greater than the desired new volume - // %d.",highest_other_volume,vo); + debug(1,"Highest other volume %d is greater than the desired new volume %d.",highest_other_volume,vo); // if the present overall volume is higher than the highest other volume at present, // then bring it down to it. if (overall_volume > highest_other_volume) { - // debug(1,"Lower overall volume to new highest volume."); + debug(1,"Lower overall volume to new highest volume."); dacp_set_include_speaker_volume( machine_number, highest_other_volume); // set the overall volume to the highest one } int32_t desired_relative_volume = (vo * 100 + (highest_other_volume / 2)) / highest_other_volume; - // debug(1,"Set our speaker volume relative to the highest volume."); + debug(1,"Set our speaker volume relative to the highest volume."); dacp_set_speaker_volume( machine_number, desired_relative_volume); // set the overall volume to the highest one } } } - // } else { - // debug(1, "No need to remote-set volume to %d, as it is already set to this - // value.",playing_conn->dacp_volume); + } else { + debug(1, "No need to remote-set volume to %d, as it is already set to this value.",playing_conn->dacp_volume); } } else debug(1, "no thread playing -- ignored."); diff --git a/mdns.h b/mdns.h index b720c6a9..96241df7 100644 --- a/mdns.h +++ b/mdns.h @@ -26,10 +26,11 @@ typedef struct { #define METADATA_EXPRESSION config.get_coverart ? "md=0,1,2" : "md=0,2" -// #define MDNS_RECORD_WITH_METADATA \ -// "tp=UDP", "sm=false", "ek=1", "et=0,1", "cn=0,1", "ch=2", METADATA_EXPRESSION, "ss=16", \ -// "sr=44100", "vn=3", "txtvers=1", config.password ? "pw=true" : "pw=false" - +/* + #define MDNS_RECORD_WITH_METADATA \ + "tp=UDP", "sm=false", "ek=1", "et=0,1", "cn=0,1", "ch=2", METADATA_EXPRESSION, "ss=16", \ + "sr=44100", "vn=3", "txtvers=1", config.password ? "pw=true" : "pw=false" +*/ #define MDNS_RECORD_WITH_METADATA \ "sf=0x4", "fv=76400.10", "am=ShairportSync", "vs=105.1", "tp=TCP,UDP", "vn=65537", \ METADATA_EXPRESSION, "ss=16", "sr=44100", "da=true", "sv=false", "et=0,1", "ek=1", "cn=0,1", \ @@ -37,9 +38,11 @@ typedef struct { #endif -// #define MDNS_RECORD_WITHOUT_METADATA \ -// "tp=UDP", "sm=false", "ek=1", "et=0,1", "cn=0,1", "ch=2", METADATA_EXPRESSION, "ss=16", "sr=44100", "vn=3", \ -// "txtvers=1", config.password ? "pw=true" : "pw=false" +/* + #define MDNS_RECORD_WITHOUT_METADATA \ + "tp=UDP", "sm=false", "ek=1", "et=0,1", "cn=0,1", "ch=2", METADATA_EXPRESSION, "ss=16", "sr=44100", "vn=3", \ + "txtvers=1", config.password ? "pw=true" : "pw=false" +*/ #define MDNS_RECORD_WITHOUT_METADATA \ "sf=0x4", "fv=76400.10", "am=ShairportSync", "vs=105.1", "tp=TCP,UDP", "vn=65537", "ss=16", \ diff --git a/rtp.c b/rtp.c index 530c7c58..cb38c4bb 100644 --- a/rtp.c +++ b/rtp.c @@ -43,6 +43,9 @@ #include "player.h" #include "rtp.h" +uint64_t static local_to_remote_time_jitters; +uint64_t static local_to_remote_time_jitters_count; + void memory_barrier(); void rtp_initialise(rtsp_conn_info *conn) { diff --git a/rtp.h b/rtp.h index 641d9623..c89f7e56 100644 --- a/rtp.h +++ b/rtp.h @@ -22,7 +22,4 @@ void get_reference_timestamp_stuff(int64_t *timestamp, uint64_t *timestamp_time, uint64_t *remote_timestamp_time, rtsp_conn_info *conn); void clear_reference_timestamp(rtsp_conn_info *conn); -uint64_t static local_to_remote_time_jitters; -uint64_t static local_to_remote_time_jitters_count; - #endif // _RTP_H diff --git a/shairport.c b/shairport.c index 76762dea..92a8589a 100644 --- a/shairport.c +++ b/shairport.c @@ -288,7 +288,7 @@ int parse_options(int argc, char **argv) { char *raw_service_name = NULL; /* Used to pick up the service name before possibly expanding it */ char *stuffing = NULL; /* used for picking up the stuffing option */ signed char c; /* used for argument parsing */ - int i = 0; /* used for tracking options */ + // int i = 0; /* used for tracking options */ int fResyncthreshold = (int)(config.resyncthreshold * 44100); int fTolerance = (int)(config.tolerance * 44100); poptContext optCon; /* context for parsing command-line options */ @@ -396,7 +396,7 @@ int parse_options(int argc, char **argv) { config.cover_art_cache_dir = "/tmp/shairport-sync/.cache/coverart"; #endif - config_setting_t *setting; + // config_setting_t *setting; const char *str = 0; int value = 0; double dvalue = 0.0;