Clean up statistics display for backends with no sync. Flush pipe and stdout backends when play stops.

This commit is contained in:
Mike Brady
2020-05-24 09:45:03 +01:00
parent 5b24dddecd
commit 9280e1430b
3 changed files with 17 additions and 13 deletions
+4 -2
View File
@@ -86,8 +86,10 @@ static int play(void *buf, int samples) {
static void stop(void) {
// Don't close the pipe just because a play session has stopped.
// if (fd > 0)
// close(fd);
// Flush it instead
if (fd > 0)
if (fsync(fd) != 0)
debug(1, "Error flushing pipe when play stopped: \"%s\".", strerror(errno));
}
static int init(int argc, char **argv) {
+4 -1
View File
@@ -56,7 +56,10 @@ static int play(void *buf, int samples) {
}
static void stop(void) {
// don't close stdout
// Flush stdout when play stops instead
if (fd > 0)
if (fsync(fd) != 0)
debug(1, "Error flushing STDOUT when play stopped: \"%s\".", strerror(errno));
}
static int init(__attribute__((unused)) int argc, __attribute__((unused)) char **argv) {
+9 -10
View File
@@ -1927,8 +1927,7 @@ void *player_thread_func(void *arg) {
"source clock drift sample count");
}
} else {
inform("sync error in milliseconds, "
"total packets, "
inform("total packets, "
"missing packets, "
"late packets, "
"too late packets, "
@@ -2094,7 +2093,8 @@ void *player_thread_func(void *arg) {
die("Shairport Sync only supports 16 bit input");
}
inbuflength *= conn->output_sample_ratio;
at_least_one_frame_seen = 1;
// We have a frame of data. We need to see if we want to add or remove a frame from it to
// keep in sync.
@@ -2106,6 +2106,7 @@ void *player_thread_func(void *arg) {
// now, go back as far as the total latency less, say, 100 ms, and check the presence of
// frames from then onwards
inbuflength *= conn->output_sample_ratio;
uint32_t reference_timestamp;
uint64_t reference_timestamp_time, remote_reference_timestamp_time;
get_reference_timestamp_stuff(&reference_timestamp, &reference_timestamp_time,
@@ -2147,6 +2148,9 @@ void *player_thread_func(void *arg) {
if (conn->buffer_occupancy > maximum_buffer_occupancy)
maximum_buffer_occupancy = conn->buffer_occupancy;
// here, we want to check (a) if we are meant to do synchronisation,
// (b) if we have a delay procedure, (c) if we can get the delay.
@@ -2252,10 +2256,6 @@ void *player_thread_func(void *arg) {
sync_error = 0; // say the error was fixed!
}
}
at_least_one_frame_seen = 1;
// not too sure if abs() is implemented for int64_t, so we'll do it manually
int64_t abs_sync_error = sync_error;
if (abs_sync_error < 0)
@@ -2713,8 +2713,7 @@ void *player_thread_func(void *arg) {
conn->local_to_remote_time_gradient_sample_count);
}
} else {
inform("%*.2f," /* Sync error in milliseconds */
"%*d," /* total packets */
inform("%*d," /* total packets */
"%*" PRIu64 "," /* missing packets */
"%*" PRIu64 "," /* late packets */
"%*" PRIu64 "," /* too late packets */
@@ -2725,7 +2724,7 @@ void *player_thread_func(void *arg) {
"%*.2f," /* source actual (average) frame rate */
"%*.2f," /* source clock drift */
"%*d", /* source clock drift sample count */
10, 1000 * moving_average_sync_error / config.output_rate, 12, play_number,
12, play_number,
7, conn->missing_packets, 7, conn->late_packets, 7, conn->too_late_packets,
7, conn->resend_requests, 5, minimum_buffer_occupancy, 5,
maximum_buffer_occupancy, 11, conn->remote_frame_rate, 11,