pa_assert(r);
pa_assert(u);
+ pa_log_debug("Suspending source %s, because another application requested us to release the device.", u->source->name);
+
if (pa_source_suspend(u->source, TRUE, PA_SUSPEND_APPLICATION) < 0)
return PA_HOOK_CANCEL;
}
static pa_hook_result_t monitor_cb(pa_reserve_monitor_wrapper *w, void* busy, struct userdata *u) {
- pa_bool_t b;
-
pa_assert(w);
pa_assert(u);
- b = PA_PTR_TO_UINT(busy) && !u->reserve;
+ if (PA_PTR_TO_UINT(busy) && !u->reserve) {
+ pa_log_debug("Suspending source %s, because another application is blocking the access to the device.", u->source->name);
+ pa_source_suspend(u->source, true, PA_SUSPEND_APPLICATION);
+ } else {
+ pa_log_debug("Resuming source %s, because other applications aren't blocking access to the device any more.", u->source->name);
+ pa_source_suspend(u->source, false, PA_SUSPEND_APPLICATION);
+ }
- pa_source_suspend(u->source, b, PA_SUSPEND_APPLICATION);
return PA_HOOK_OK;
}
int err;
pa_usec_t now1 = 0, now2;
snd_pcm_status_t *status;
+ snd_htimestamp_t htstamp = { 0, 0 };
snd_pcm_status_alloca(&status);
/* Let's update the time smoother */
- if (PA_UNLIKELY((err = pa_alsa_safe_delay(u->pcm_handle, &delay, u->hwbuf_size, &u->source->sample_spec, TRUE)) < 0)) {
+ if (PA_UNLIKELY((err = pa_alsa_safe_delay(u->pcm_handle, status, &delay, u->hwbuf_size, &u->source->sample_spec, TRUE)) < 0)) {
pa_log_warn("Failed to get delay: %s", pa_alsa_strerror(err));
return;
}
- if (PA_UNLIKELY((err = snd_pcm_status(u->pcm_handle, status)) < 0))
- pa_log_warn("Failed to get timestamp: %s", pa_alsa_strerror(err));
- else {
- snd_htimestamp_t htstamp = { 0, 0 };
- snd_pcm_status_get_htstamp(status, &htstamp);
- now1 = pa_timespec_load(&htstamp);
- }
+ snd_pcm_status_get_htstamp(status, &htstamp);
+ now1 = pa_timespec_load(&htstamp);
/* Hmm, if the timestamp is 0, then it wasn't set and we take the current time */
if (now1 <= 0)
pa_log_info("Disabling latency range changes on overrun");
}
- u->rates = pa_alsa_get_supported_rates(u->pcm_handle);
+ u->rates = pa_alsa_get_supported_rates(u->pcm_handle, ss.rate);
if (!u->rates) {
pa_log_error("Failed to find any supported sample rates.");
goto fail;