int mute(int do_mute); // returns true if it actually is allowed to use the mute
static double set_volume;
static int output_method_signalled = 0; // for reporting whether it's using mmap or not
+int delay_type_notifier = -1; // used for reporting the type of delay
audio_output audio_alsa = {
.name = "alsa",
*using_update_timestamps = YNDK_YES;
}
-/*
+
if (update_timestamp_ns == 0) {
if (delay_type_notifier != 1) {
inform("Note: this output device does not provide timed delay updates via snd_pcm_status_get_*_htstamp(). Is it a virtual rather than a real device? Disable_standby is not available.");
delay_type_notifier = 0;
}
}
-*/
-
+
if (update_timestamp_ns == 0) {
ret = snd_pcm_delay (alsa_handle,delay);
} else {
}
}
} else {
-
- debug(1, "alsa: error %d writing %d samples to alsa device.", ret, samples);
frame_index = 0;
measurement_data_is_valid = 0;
if (ret == -EPIPE) { /* underrun */
+ debug(1, "alsa: underrun while writing %d samples to alsa device.", samples);
ret = snd_pcm_recover(alsa_handle, ret, debuglev > 0 ? 1 : 0);
if (ret < 0) {
warn("alsa: can't recover from SND_PCM_STATE_XRUN: %s.", snd_strerror(ret));
}
} else if (ret == -ESTRPIPE) { /* suspended */
+ debug(1, "alsa: suspended while writing %d samples to alsa device.", samples);
while ((ret = snd_pcm_resume(alsa_handle)) == -EAGAIN) {
sleep(1); /* wait until the suspend flag is released */
if (ret < 0) {
snd_strerror(ret));
}
}
+ } else {
+ char errorstring[1024];
+ strerror_r(-ret, (char *)errorstring, sizeof(errorstring));
+ debug(1, "alsa: error %d (\"%s\") writing %d samples to alsa device.", ret, (char *)errorstring, samples);
}
+
}
}
} else {
conn);
conn->first_packet_time_to_play = should_be_time;
+
+ // we want the frames of silence sent at the start to be fairly large in case the output
+ // device's minimum buffer size is large. But they can't be greater than the silent lead_in time
+ // which is either the agreed latency or the silent lead-in time specified by the setting
+ // In fact, if should be some fraction of them, to allow for adjustment.
+
+ int64_t max_dac_delay = conn->latency;
+ if (config.audio_backend_silent_lead_in_time >= 0)
+ max_dac_delay =
+ (int64_t)(config.audio_backend_silent_lead_in_time * conn->input_rate);
+
+ max_dac_delay = max_dac_delay / 4;
+
+ // debug(1,"max_dac_delay is %" PRIu64 " frames.", max_dac_delay);
// now, the size of the initial silence must be affected by the lead-in time.
// it must be somewhat less than the lead-in time so that dynamic adjustments can be
// to compensate for delays due to paging, etc.
// The suggestion is that it should be at least 100 ms less than the lead-in time.
- int64_t max_dac_delay = config.output_rate / 10; // so the lead-in time must be greater
+ // int64_t max_dac_delay = config.output_rate / 3; // so the lead-in time must be greater
// than this, say 0.2 sec, to allow for
// dynamic adjustment
int64_t filler_size = max_dac_delay;