summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Brady <mikebrady@eircom.net>2018-08-13 14:44:22 +0100
committerMike Brady <mikebrady@eircom.net>2018-08-13 14:44:22 +0100
commit2f588562686c8eaeee794a510b49f4eba2471bf5 (patch)
treeb2fdf3ad9f7ba44faddc09303795564c7ca17c84
parenta8cfc9915f05e3fcb8dc725dd89f0197bb4ee234 (diff)
Add source rate calculation based on source frame and timing information, calculated from start of play session.
-rw-r--r--player.c15
-rw-r--r--player.h5
-rw-r--r--rtp.c11
3 files changed, 27 insertions, 4 deletions
diff --git a/player.c b/player.c
index f2e1a7f..0d86706 100644
--- a/player.c
+++ b/player.c
@@ -1785,9 +1785,10 @@ void *player_thread_func(void *arg) {
"min DAC queue size, "
"min buffer occupancy, "
"max buffer occupancy, "
- "input frames per second, "
+ "source frames per second, "
+ "average input frames per second, "
"output frames per second, "
- "drift client vs local clock in ppm");
+ "client:local clock drift in ppm");
} else {
inform("sync error in milliseconds, "
"total packets, "
@@ -2414,7 +2415,8 @@ void *player_thread_func(void *arg) {
"%*lli," /* min DAC queue size */
"%*d," /* min buffer occupancy */
"%*d," /* max buffer occupancy */
- "%*.2f," /* input frame rate */
+ "%*.2f," /* remote frame rate */
+ "%*.2f," /* actual (average) input frame rate */
"%*.2f," /* output frame rate */
"%*.2f," /* output frame rate */
"%*d", /* sample count */
@@ -2426,7 +2428,12 @@ void *player_thread_func(void *arg) {
12, play_number, 7, conn->missing_packets, 7, conn->late_packets, 7,
conn->too_late_packets, 7, conn->resend_requests, 7,
minimum_dac_queue_size, 5, minimum_buffer_occupancy, 5,
- maximum_buffer_occupancy, 11, conn->input_frame_rate, 11, conn->frame_rate , 10, (1.0-conn->local_to_remote_time_gradient)*1000000, 6, conn->local_to_remote_time_gradient_sample_count);
+ maximum_buffer_occupancy,
+ 11, conn->remote_frame_rate,
+ 11, conn->input_frame_rate,
+ 11, conn->frame_rate ,
+ 10, (1.0-conn->local_to_remote_time_gradient)*1000000,
+ 6, conn->local_to_remote_time_gradient_sample_count);
} else {
inform("%*.2f," /* Sync error in milliseconds */
"%*d," /* total packets */
diff --git a/player.h b/player.h
index a7d961a..783c516 100644
--- a/player.h
+++ b/player.h
@@ -191,6 +191,11 @@ typedef struct {
uint64_t remote_reference_timestamp_time;
+ // used as the initials values for calculating the rate at which the source thinks it's sending frames
+ int64_t initial_reference_timestamp;
+ uint64_t initial_reference_time;
+ double remote_frame_rate;
+
// the ratio of the following should give us the operating rate, nominally 44,100
int64_t reference_to_previous_frame_difference;
uint64_t reference_to_previous_time_difference;
diff --git a/rtp.c b/rtp.c
index 96bb0fc..6747724 100644
--- a/rtp.c
+++ b/rtp.c
@@ -356,6 +356,17 @@ void *rtp_control_receiver(void *arg) {
}
debug_mutex_lock(&conn->reference_time_mutex, 1000, 1);
+
+ if (conn->initial_reference_time==0) {
+ conn->initial_reference_time = remote_time_of_sync;
+ conn->initial_reference_timestamp = sync_rtp_timestamp;
+ } else {
+ uint64_t remote_frame_time_interval = conn->remote_reference_timestamp_time - conn->initial_reference_time; // here, this should never be zero
+ if (remote_frame_time_interval) {
+ conn->remote_frame_rate = (1.0 * (conn->reference_timestamp - conn->initial_reference_timestamp)) / remote_frame_time_interval; // an IEEE double calculation with two 64-bit integers
+ conn->remote_frame_rate = conn->remote_frame_rate * (uint64_t)0x100000000; // this should just change the [binary] exponent in the IEEE FP representation; the mantissa should be unaffected.
+ }
+ }
// this is for debugging
uint64_t old_remote_reference_time = conn->remote_reference_timestamp_time;