Skip to content

Commit

Permalink
aplay/alsa: remove 2 messages
Browse files Browse the repository at this point in the history
- do not inform about new API - it has been there a long time and obviously
the "new" API works fine
- do not warn that cannot get the latency - the procfs file is no longer
available so it is issued all the time. It works with the default value
24 ms just fine.
- regading the above, do not obtain the value at all - since it now works
fine, we do not need to depend on an external value that may potentially
break the stuff (it would be required to re-test if needed)
  • Loading branch information
MartinPulec committed Nov 25, 2024
1 parent 3e8100c commit 9cd1af1
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions src/audio/playback/alsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@
#define MOD_NAME "[ALSA play.] "
#define SCRATCHPAD_SIZE (1024*1024)

enum {
BUFFER_CHUNK_LEN_MS =
24, ///< audio buffer unit size (the amount that will be read from
///< the buffer at once, buffer will be allocated to hold 2x the
///< size)
};

/**
* Speex jitter buffer use is currently not stable and not ready for production use.
* Moreover, it is unclear whether is suitable for our use case.
Expand Down Expand Up @@ -153,7 +160,8 @@ static void audio_play_alsa_write_frame(void *state, const struct audio_frame *f
* the file /proc/sys/kernel/sched_latency_ns is no longer present
* in current Linuxes - remove the function?
*/
static long get_sched_latency_ns(void)
[[maybe_unused]] static long
get_sched_latency_ns(void)
{
const char *proc_file = "/proc/sys/kernel/sched_latency_ns";

Expand Down Expand Up @@ -841,14 +849,15 @@ static void * audio_play_alsa_init(const char *cfg)

struct state_alsa_playback *s = calloc(1, sizeof(struct state_alsa_playback));

long latency_ns = get_sched_latency_ns();
if (latency_ns > 0) {
s->sched_latency_ms = latency_ns / 1000 / 1000;
log_msg(LOG_LEVEL_VERBOSE, MOD_NAME "Sched latency: %ld ms.\n", s->sched_latency_ms);
} else {
s->sched_latency_ms = 24;
log_msg(LOG_LEVEL_WARNING, MOD_NAME "Unable to get latency, assuming %ld.\n", s->sched_latency_ms);
}
// long latency_ns = get_sched_latency_ns();
// if (latency_ns > 0) {
// s->sched_latency_ms = latency_ns / 1000 / 1000;
// log_msg(LOG_LEVEL_VERBOSE, MOD_NAME "Sched latency: %ld ms.\n", s->sched_latency_ms);
// } else {
// s->sched_latency_ms = 24;
// log_msg(LOG_LEVEL_WARNING, MOD_NAME "Unable to get latency, assuming %ld.\n", s->sched_latency_ms);
// }
s->sched_latency_ms = BUFFER_CHUNK_LEN_MS;

const char *use_api;
use_api = get_commandline_param("alsa-playback-api");
Expand All @@ -866,10 +875,6 @@ static void * audio_play_alsa_init(const char *cfg)
}
}

if (s->playback_mode == THREAD) {
log_msg(LOG_LEVEL_NOTICE, MOD_NAME "Using new API. In case of problems, you may try to use '--param alsa-playback-api=sync'.\n");
}

if (s->playback_mode == ASYNC) {
log_msg(LOG_LEVEL_WARNING, MOD_NAME "Async API is experimental, in case of problems use either \"thread\" or \"sync\" API\n");
}
Expand Down

0 comments on commit 9cd1af1

Please sign in to comment.