Skip to content

Commit

Permalink
Fixes after rebase with master
Browse files Browse the repository at this point in the history
  • Loading branch information
arkq committed Feb 7, 2025
1 parent 0928715 commit 0aaf9e9
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
8 changes: 4 additions & 4 deletions utils/aplay/alsa-pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ static int alsa_pcm_set_sw_params(

snd_pcm_sw_params_alloca(&params);

if ((err = snd_pcm_sw_params_current(pcm, params)) != 0) {
if ((err = snd_pcm_sw_params_current(snd_pcm, params)) != 0) {
snprintf(buf, sizeof(buf), "Get current sw params: %s", snd_strerror(err));
goto fail;
}
Expand All @@ -131,7 +131,7 @@ static int alsa_pcm_set_sw_params(
goto fail;
}

if ((err = snd_pcm_sw_params(pcm, params)) != 0) {
if ((err = snd_pcm_sw_params(snd_pcm, params)) != 0) {
snprintf(buf, sizeof(buf), "Set sw params: %s", snd_strerror(err));
goto fail;
}
Expand Down Expand Up @@ -175,7 +175,7 @@ int alsa_pcm_open(
}

pcm->format = actual_format;
if ((err = alsa_pcm_set_hw_params(pcm->pcm, format_1, format_2,
if ((err = alsa_pcm_set_hw_params(pcm, format_1, format_2,
&actual_format, channels, &actual_rate, exact_rate,
&actual_buffer_time, &actual_period_time, &tmp)) != 0) {
snprintf(buf, sizeof(buf), "Set HW params: %s", tmp);
Expand All @@ -195,7 +195,7 @@ int alsa_pcm_open(
if (start_threshold > buffer_size)
start_threshold = buffer_size;

if ((err = alsa_pcm_set_sw_params(pcm->pcm, start_threshold, &tmp)) != 0) {
if ((err = alsa_pcm_set_sw_params(pcm, start_threshold, &tmp)) != 0) {
snprintf(buf, sizeof(buf), "Set SW params: %s", tmp);
goto fail;
}
Expand Down
13 changes: 8 additions & 5 deletions utils/aplay/aplay.c
Original file line number Diff line number Diff line change
Expand Up @@ -807,8 +807,6 @@ static void *io_worker_routine(struct io_worker *w) {
if (!w->ba_pcm.running)
goto device_inactive;

size_t delay_frames = w->alsa_pcm.delay;

if (w->alsa_pcm.underrun) {
/* Reset moving delay window buffer. */
delay_report_reset(&dr);
Expand All @@ -819,12 +817,17 @@ static void *io_worker_routine(struct io_worker *w) {
if (w->alsa_pcm.underrun)
resampler_reset(resampler, 0);

delay_frames += ffb_len_out(write_buffer) / w->ba_pcm.channels;
delay_frames /= resampler_current_rate_ratio(resampler);
size_t resample_delay_frames;
resample_delay_frames = ffb_len_out(write_buffer) / w->ba_pcm.channels;
resample_delay_frames /= resampler_current_rate_ratio(resampler);
}
#endif

if (!delay_report_update(&dr, &w->alsa_pcm, w->ba_pcm_fd, &read_buffer, &err)) {
if (!delay_report_update(&dr, &w->alsa_pcm,
#if ENABLE_APLAY_RESAMPLER
resample_delay_frames,
#endif
w->ba_pcm_fd, &read_buffer, &err)) {
error("Couldn't update BlueALSA PCM client delay: %s", err.message);
dbus_error_free(&err);
goto fail;
Expand Down
6 changes: 6 additions & 0 deletions utils/aplay/delay-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ void delay_report_reset(
bool delay_report_update(
struct delay_report *dr,
struct alsa_pcm *pcm,
#if ENABLE_APLAY_RESAMPLER
size_t resample_delay_frames,
#endif
int ba_pcm_fd,
ffb_t *buffer,
DBusError *err) {
Expand All @@ -59,6 +62,9 @@ bool delay_report_update(
const size_t num_values = ARRAYSIZE(dr->values);
/* Store the delay calculated from all components. */
dr->values[dr->values_i % num_values] = pcm->delay + ba_pcm_frames + buffer_frames;
#if ENABLE_APLAY_RESAMPLER
dr->values[dr->values_i % num_values] += resample_delay_frames;
#endif
dr->values_i++;

struct timespec ts_now;
Expand Down
7 changes: 7 additions & 0 deletions utils/aplay/delay-report.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
#ifndef BLUEALSA_APLAY_DELAYREPORT_H_
#define BLUEALSA_APLAY_DELAYREPORT_H_

#if HAVE_CONFIG_H
# include <config.h>
#endif

#include <stdbool.h>
#include <sys/time.h>

Expand Down Expand Up @@ -48,6 +52,9 @@ void delay_report_reset(
bool delay_report_update(
struct delay_report *dr,
struct alsa_pcm *pcm,
#if ENABLE_APLAY_RESAMPLER
size_t resample_delay_frames,
#endif
int ba_pcm_fd,
ffb_t *buffer,
DBusError *err);
Expand Down

0 comments on commit 0aaf9e9

Please sign in to comment.