if (alsa_handle == NULL) {
return -ENODEV;
} else {
- pthread_cleanup_debug_mutex_lock(&alsa_mutex, 10000, 1);
+ pthread_cleanup_debug_mutex_lock(&alsa_mutex, 10000, 0);
int derr;
snd_pcm_state_t dac_state = snd_pcm_state(alsa_handle);
if (dac_state == SND_PCM_STATE_RUNNING) {
// there's nothing in the pipeline, so we can't measure frame rate.
frame_index = 0; // we'll be starting over...
measurement_data_is_valid = 0;
+ } else if (*the_delay > 10000) {
+ debug(1,"long delay: %ld.",*the_delay);
}
}
} else {
}
}
}
- debug_mutex_unlock(&alsa_mutex, 3);
+ debug_mutex_unlock(&alsa_mutex, 0);
pthread_cleanup_pop(0);
// here, occasionally pretend there's a problem with pcm_get_delay()
// if ((random() % 100000) < 3) // keep it pretty rare
pthread_cleanup_pop(0); // release the mutex
}
if (ret == 0) {
- pthread_cleanup_debug_mutex_lock(&alsa_mutex, 10000, 1);
+ pthread_cleanup_debug_mutex_lock(&alsa_mutex, 10000, 0);
// snd_pcm_sframes_t current_delay = 0;
int err, err2;
if (snd_pcm_state(alsa_handle) == SND_PCM_STATE_XRUN) {
if (samples == 0)
debug(1, "empty buffer being passed to pcm_writei -- skipping it");
if ((samples != 0) && (buf != NULL)) {
+ debug(3,"write %d frames.",samples);
err = alsa_pcm_write(alsa_handle, buf, samples);
if (err < 0) {
frame_index = 0;
frame_index = 0;
measurement_data_is_valid = 0;
}
- debug_mutex_unlock(&alsa_mutex, 3);
+ debug_mutex_unlock(&alsa_mutex, 0);
pthread_cleanup_pop(0); // release the mutex
}
return ret;
if ((derr = snd_pcm_hw_free(alsa_handle)))
debug(1, "Error %d (\"%s\") freeing the output device hardware.", derr, snd_strerror(derr));
-
+
// flush also closes the device
if ((derr = snd_pcm_close(alsa_handle)))
debug(1, "Error %d (\"%s\") closing the output device.", derr, snd_strerror(derr));
debug_mutex_unlock(&conn->flush_mutex, 3);
}
- debug_mutex_lock(&conn->ab_mutex, 30000, 1);
+ debug_mutex_lock(&conn->ab_mutex, 30000, 0);
conn->packet_count++;
conn->packet_count_since_flush++;
conn->time_of_last_audio_packet = get_absolute_time_in_fp();
}
}
}
- debug_mutex_unlock(&conn->ab_mutex, 3);
+ debug_mutex_unlock(&conn->ab_mutex, 0);
}
int32_t rand_in_range(int32_t exclusive_range_limit) {
void buffer_get_frame_cleanup_handler(void *arg) {
rtsp_conn_info *conn = (rtsp_conn_info *)arg;
- debug_mutex_unlock(&conn->ab_mutex, 3);
+ debug_mutex_unlock(&conn->ab_mutex, 0);
}
// get the next frame, when available. return 0 if underrun/stream reset.
abuf_t *curframe = NULL;
int notified_buffer_empty = 0; // diagnostic only
- debug_mutex_lock(&conn->ab_mutex, 30000, 1);
+ debug_mutex_lock(&conn->ab_mutex, 30000, 0);
int wait;
long dac_delay = 0; // long because alsa returns a long
do {
// get the time
local_time_now = get_absolute_time_in_fp(); // type okay
- debug(3, "buffer_get_frame is iterating");
+ // debug(3, "buffer_get_frame is iterating");
int rco = get_requested_connection_state_to_output();
if (config.output->is_running)
if (config.output->is_running() != 0) { // if the back end isn't running for any reason
debug(3, "not running");
- debug_mutex_lock(&conn->flush_mutex, 1000, 1);
+ debug_mutex_lock(&conn->flush_mutex, 1000, 0);
conn->flush_requested = 1;
- debug_mutex_unlock(&conn->flush_mutex, 3);
+ debug_mutex_unlock(&conn->flush_mutex, 0);
}
- debug_mutex_lock(&conn->flush_mutex, 1000, 1);
+ debug_mutex_lock(&conn->flush_mutex, 1000, 0);
if (conn->flush_requested == 1) {
if (config.output->flush)
config.output->flush(); // no cancellation points
conn->time_since_play_started = 0;
conn->flush_requested = 0;
}
- debug_mutex_unlock(&conn->flush_mutex, 3);
+ debug_mutex_unlock(&conn->flush_mutex, 0);
if (conn->ab_synced) {
curframe = conn->audio_buffer + BUFIDX(conn->ab_read);
// update the watchdog
if ((config.dont_check_timeout == 0) && (config.timeout != 0)) {
uint64_t time_now = get_absolute_time_in_fp();
- debug_mutex_lock(&conn->watchdog_mutex, 1000, 1);
+ debug_mutex_lock(&conn->watchdog_mutex, 1000, 0);
conn->watchdog_bark_time = time_now;
- debug_mutex_unlock(&conn->watchdog_mutex, 3);
+ debug_mutex_unlock(&conn->watchdog_mutex, 0);
}
// debug(1,"Sync error %lld frames. Amount to stuff %d." ,sync_error,amount_to_stuff);
debug(3, "Connection %d: Check the player thread is doing something...",
conn->connection_number);
if ((config.dont_check_timeout == 0) && (config.timeout != 0)) {
- debug_mutex_lock(&conn->watchdog_mutex, 1000, 1);
+ debug_mutex_lock(&conn->watchdog_mutex, 1000, 0);
uint64_t last_watchdog_bark_time = conn->watchdog_bark_time;
- debug_mutex_unlock(&conn->watchdog_mutex, 3);
+ debug_mutex_unlock(&conn->watchdog_mutex, 0);
if (last_watchdog_bark_time != 0) {
uint64_t time_since_last_bark = (get_absolute_time_in_fp() - last_watchdog_bark_time) >> 32;
uint64_t ct = config.timeout; // go from int to 64-bit int
void get_reference_timestamp_stuff(uint32_t *timestamp, uint64_t *timestamp_time,
uint64_t *remote_timestamp_time, rtsp_conn_info *conn) {
// types okay
- debug_mutex_lock(&conn->reference_time_mutex, 1000, 1);
+ debug_mutex_lock(&conn->reference_time_mutex, 1000, 0);
*timestamp = conn->reference_timestamp;
*remote_timestamp_time = conn->remote_reference_timestamp_time;
*timestamp_time =
// if ((*timestamp == 0) && (*timestamp_time == 0)) {
// debug(1,"Reference timestamp is invalid.");
//}
- debug_mutex_unlock(&conn->reference_time_mutex, 3);
+ debug_mutex_unlock(&conn->reference_time_mutex, 0);
}
void clear_reference_timestamp(rtsp_conn_info *conn) {
// the reference timestamps are denominated in terms of the input rate
int frame_to_local_time(uint32_t timestamp, uint64_t *time, rtsp_conn_info *conn) {
- debug_mutex_lock(&conn->reference_time_mutex, 1000, 1);
+ debug_mutex_lock(&conn->reference_time_mutex, 1000, 0);
int result = 0;
uint64_t time_difference;
uint32_t frame_difference;
// on the specified fps.
}
*time = remote_time_of_timestamp - local_to_remote_time_difference_now(conn);
- debug_mutex_unlock(&conn->reference_time_mutex, 3);
+ debug_mutex_unlock(&conn->reference_time_mutex, 0);
return result;
}
int local_time_to_frame(uint64_t time, uint32_t *frame, rtsp_conn_info *conn) {
- debug_mutex_lock(&conn->reference_time_mutex, 1000, 1);
+ debug_mutex_lock(&conn->reference_time_mutex, 1000, 0);
int result = 0;
uint64_t time_difference;
// debug(1,"Frame interval is %" PRId64 " frames.",-frame_interval);
*frame = (conn->reference_timestamp - frame_interval);
}
- debug_mutex_unlock(&conn->reference_time_mutex, 3);
+ debug_mutex_unlock(&conn->reference_time_mutex, 0);
return result;
}