static void flush(void) {
// debug(2,"audio_alsa flush called.");
+ int oldState;
+ pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldState);
pthread_cleanup_debug_mutex_lock(&alsa_mutex, 10000, 1);
int derr;
do_mute(1);
}
debug_mutex_unlock(&alsa_mutex, 3);
pthread_cleanup_pop(0); // release the mutex
+ pthread_setcancelstate(oldState, NULL);
}
static void stop(void) {
conn->initial_reference_time = 0;
conn->initial_reference_timestamp = 0;
} else {
+ /*
if ((conn->flush_rtp_timestamp != 0) &&
(modulo_32_offset(conn->flush_rtp_timestamp, actual_timestamp) > conn->input_rate / 5) &&
(modulo_32_offset(conn->flush_rtp_timestamp, actual_timestamp) < conn->input_rate)) {
debug(2, "Dropping flush request in player_put_packet");
conn->flush_rtp_timestamp = 0;
}
+ */
abuf_t *abuf = 0;
debug(1, "Inconsistent sequence numbers detected");
}
}
-
+
+ //if (conn->flush_rtp_timestamp != 0)
+ // debug(2,"flush_rtp_timestamp is %" PRIx32 " and curframe->given_timestamp is %" PRIx32 ".", conn->flush_rtp_timestamp , curframe->given_timestamp);
+
if ((conn->flush_rtp_timestamp != 0) &&
(curframe->given_timestamp != conn->flush_rtp_timestamp) &&
(modulo_32_offset(curframe->given_timestamp, conn->flush_rtp_timestamp) <
conn->first_packet_time_to_play = should_be_time;
- if (local_time_now >= conn->first_packet_time_to_play) {
+ if (local_time_now > conn->first_packet_time_to_play) {
+ uint64_t lateness = local_time_now - conn->first_packet_time_to_play;
+ lateness = (lateness * 1000000) >> 32; // microseconds
debug(
1,
- "First packet is late! It should have played before now. Flushing 0.5 seconds");
- player_flush(conn->first_packet_timestamp + 5 * 4410 * conn->output_sample_ratio,
+ "First packet is %" PRIu64 " microseconds late! Flushing 0.5 seconds",lateness);
+ do_flush(conn->first_packet_timestamp + 5 * 4410,
conn);
}
}
// dynamic adjustment
int64_t filler_size = max_dac_delay;
- if (local_time_now >= conn->first_packet_time_to_play) {
- // debug(1,"Gone past starting time");
+ if (local_time_now > conn->first_packet_time_to_play) {
+ uint64_t lateness = local_time_now - conn->first_packet_time_to_play;
+ lateness = (lateness * 1000000) >> 32; // microseconds
+ debug(1,"Gone past starting time by %" PRIu64 " microseconds.", lateness);
have_sent_prefiller_silence = 1;
conn->ab_buffering = 0;