From: Mike McKnight Date: Thu, 31 Mar 2016 14:04:58 +0000 (-0600) Subject: Merge upstream and rebase local mods to development X-Git-Tag: 2.9.5.7~18^2 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F260%2Fhead;p=thirdparty%2Fshairport-sync.git Merge upstream and rebase local mods to development --- 9323e65df8000617de1f5e3a76f2439d71717478 diff --cc mdns_avahi.c index 55a8e0c4,8d5e60f7..016c7b8a --- a/mdns_avahi.c +++ b/mdns_avahi.c @@@ -42,50 -42,12 +42,50 @@@ static AvahiThreadedPoll *tpoll = NULL static char *name = NULL; static int port = 0; +static void register_service( AvahiClient *c ); + static void egroup_callback(AvahiEntryGroup *g, AvahiEntryGroupState state, AVAHI_GCC_UNUSED void *userdata) { - if (state == AVAHI_ENTRY_GROUP_COLLISION) - warn("Service name already exists on network!"); - if (state == AVAHI_ENTRY_GROUP_FAILURE) - warn("Avahi entry group failure!"); + switch ( state ) + { + case AVAHI_ENTRY_GROUP_ESTABLISHED: + /* The entry group has been established successfully */ + inform("Service '%s' successfully established.\n", name ); + break; + + case AVAHI_ENTRY_GROUP_COLLISION: + { + char *n; + + /* A service name collision with a remote service + * happened. Let's pick a new name */ + n = avahi_alternative_service_name( name ); + avahi_free( name ); + name = n; + + warn( "Service name collision, renaming service to '%s'\n", name ); + + /* And recreate the services */ + register_service( avahi_entry_group_get_client( g ) ); + break; + } + + case AVAHI_ENTRY_GROUP_FAILURE: - die( "Entry group failure: %s\n", avahi_strerror( avahi_client_errno( avahi_entry_group_get_client( g ) ) ) ); ++ warn( "Entry group failure: %s\n", avahi_strerror( avahi_client_errno( avahi_entry_group_get_client( g ) ) ) ); + break; + + case AVAHI_ENTRY_GROUP_UNCOMMITED: + debug(1, "Service '%s' group is not yet commited.\n", name ); + break; + + case AVAHI_ENTRY_GROUP_REGISTERING: + inform( "Service '%s' group is registering.\n", name ); + break; + + default: + warn( "Unhandled avahi egroup state: %d\n", state ); + break; + } } static void register_service(AvahiClient *c) { @@@ -126,30 -91,22 +129,30 @@@ static void client_callback(AvahiClient *c, AvahiClientState state, AVAHI_GCC_UNUSED void *userdata) { switch (state) { - case AVAHI_CLIENT_S_REGISTERING: - if (group) - avahi_entry_group_reset(group); - break; - - case AVAHI_CLIENT_S_RUNNING: - register_service(c); - break; - - case AVAHI_CLIENT_FAILURE: - case AVAHI_CLIENT_S_COLLISION: - debug(1,"avahi client failure"); - break; - - case AVAHI_CLIENT_CONNECTING: - break; + case AVAHI_CLIENT_S_REGISTERING: + if (group) + avahi_entry_group_reset(group); + break; + + case AVAHI_CLIENT_S_RUNNING: + register_service(c); + break; + + case AVAHI_CLIENT_FAILURE: - die("avahi client failure"); ++ warn("avahi client failure"); + break; + + case AVAHI_CLIENT_S_COLLISION: + warn( "Avahi state is AVAHI_CLIENT_S_COLLISION...needs a rename: %s\n", name ); + break; + + case AVAHI_CLIENT_CONNECTING: + inform( "Received AVAHI_CLIENT_CONNECTING\n" ); + break; + + default: + warn( "Unhandled avahi client state: %d\n", state ); + break; } } diff --cc player.c index 77658a70,3a29a666..2ef63832 --- a/player.c +++ b/player.c @@@ -935,12 -957,10 +957,12 @@@ static void *player_thread_func(void *a int64_t tsum_of_sync_errors, tsum_of_corrections, tsum_of_insertions_and_deletions, tsum_of_drifts; int64_t previous_sync_error, previous_correction; - int64_t minimum_dac_queue_size = 1000000; - int32_t minimum_buffer_occupancy = BUFFER_FRAMES; - int32_t maximum_buffer_occupancy = 0; + int64_t minimum_dac_queue_size = INT64_MAX; + int32_t minimum_buffer_occupancy = INT32_MAX; + int32_t maximum_buffer_occupancy = INT32_MIN; + time_t playstart = time(NULL); + buffer_occupancy = 0; int play_samples; @@@ -1219,23 -1277,32 +1279,33 @@@ // if ((play_number/print_interval)%20==0) if (config.statistics_requested) { if (at_least_one_frame_seen) { - if (config.output->delay) - inform("Sync error: %.1f (frames); net correction: %.1f (ppm); corrections: %.1f " - "(ppm); total packets %d; missing packets %llu; late packets %llu; too late packets %llu; " - "resend requests %llu; min DAC queue size %lli, min and max buffer occupancy " - "%d and %d.", - moving_average_sync_error, moving_average_correction * 1000000 / 352, - moving_average_insertions_plus_deletions * 1000000 / 352, - play_number, missing_packets, - late_packets, too_late_packets, resend_requests, minimum_dac_queue_size, - minimum_buffer_occupancy, maximum_buffer_occupancy); - else - inform("Synchronisation disabled. total packets %d; missing packets %llu; late packets %llu; too late packets %llu; " - "resend requests %llu; min and max buffer occupancy " - "%d and %d.", - play_number, missing_packets, - late_packets, too_late_packets, resend_requests, - minimum_buffer_occupancy, maximum_buffer_occupancy); + if ((config.output->delay)) { + if (config.no_sync==0) { + inform("Sync error: %.1f (frames); net correction: %.1f (ppm); corrections: %.1f " - "(ppm); missing packets %llu; late packets %llu; too late packets %llu; " ++ "(ppm); total packets %d; missing packets %llu; late packets %llu; too late packets %llu; " + "resend requests %llu; min DAC queue size %lli, min and max buffer occupancy " + "%d and %d.", + moving_average_sync_error, moving_average_correction * 1000000 / 352, - moving_average_insertions_plus_deletions * 1000000 / 352, missing_packets, ++ moving_average_insertions_plus_deletions * 1000000 / 352, play_number, missing_packets, + late_packets, too_late_packets, resend_requests, minimum_dac_queue_size, + minimum_buffer_occupancy, maximum_buffer_occupancy); + } else { - inform("Synchronisation disabled. Sync error: %.1f (frames); missing packets %llu; late packets %llu; too late packets %llu; " ++ inform("Synchronisation disabled. Sync error: %.1f (frames); total packets %d; " ++ "missing packets %llu; late packets %llu; too late packets %llu; " + "resend requests %llu; min DAC queue size %lli, min and max buffer occupancy " + "%d and %d.", - moving_average_sync_error, missing_packets, ++ moving_average_sync_error, play_number, missing_packets, + late_packets, too_late_packets, resend_requests, minimum_dac_queue_size, + minimum_buffer_occupancy, maximum_buffer_occupancy); + } + } else { - inform("Synchronisation disabled. Missing packets %llu; late packets %llu; too late packets %llu; " - "resend requests %llu; min and max buffer occupancy " - "%d and %d.", - missing_packets, - late_packets, too_late_packets, resend_requests, - minimum_buffer_occupancy, maximum_buffer_occupancy); ++ inform("Synchronisation disabled. Total packets %d; missing packets %llu; late packets %llu; too late packets %llu; " ++ "resend requests %llu; min and max buffer occupancy " ++ "%d and %d.", ++ play_number, missing_packets, ++ late_packets, too_late_packets, resend_requests, ++ minimum_buffer_occupancy, maximum_buffer_occupancy); + } } else { inform("No frames received in the last sampling interval."); } @@@ -1248,13 -1315,6 +1318,15 @@@ } } } + - int rawSeconds = (int) difftime( time( NULL ), playstart ); - int elapsedHours = rawSeconds / 3600; - int elapsedMin = (rawSeconds / 60) % 60; - int elapsedSec = rawSeconds % 60; - inform( "Playback Stopped. Total playing time %02d:%02d:%02d\n", elapsedHours, elapsedMin, elapsedSec ); ++ if (config.statistics_requested) { ++ int rawSeconds = (int) difftime( time( NULL ), playstart ); ++ int elapsedHours = rawSeconds / 3600; ++ int elapsedMin = (rawSeconds / 60) % 60; ++ int elapsedSec = rawSeconds % 60; ++ inform( "Playback Stopped. Total playing time %02d:%02d:%02d\n", elapsedHours, elapsedMin, elapsedSec ); ++ } + if (config.output->stop) config.output->stop(); usleep(100000); // allow this time to (?) allow the alsa subsystem to finish cleaning up after itself. 50 ms seems too short