Skip to content

Commit

Permalink
silence spurious warning from CodeQL
Browse files Browse the repository at this point in the history
  • Loading branch information
borine committed Jan 6, 2025
1 parent 3d45cda commit 5f7d524
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/asound/bluealsa-pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -867,18 +867,25 @@ static int bluealsa_hw_params(snd_pcm_ioplug_t *io, snd_pcm_hw_params_t *params)
if (pcm->hwcompat == BA_HWCOMPAT_SILENCE) {
/* Try to ensure the FIFO is at least twice the period size */
int target_capacity = 2 * io->period_size * pcm->frame_size;
int max_capacity;
int max_capacity = 1048576; /* Linux default max pipe size */
FILE *proc_file = fopen("/proc/sys/fs/pipe-max-size", "r");
if (fscanf(proc_file, "%d", &max_capacity) != 1) {
debug("Unable to read pipe max size: %s", strerror(errno));
max_capacity = 1048576; /* Linux default max pipe size */
if (proc_file != NULL) {
if (fscanf(proc_file, "%d", &max_capacity) != 1)
debug("Unable to read pipe max size: %s", strerror(errno));
fclose(proc_file);
}
fclose(proc_file);
if (target_capacity > max_capacity)
target_capacity = max_capacity;
int capacity = fcntl(pcm->ba_pcm_fd, F_GETPIPE_SZ);
if (capacity < target_capacity)
fcntl(pcm->ba_pcm_fd, F_SETPIPE_SZ, target_capacity);
if (capacity < target_capacity) {
capacity = fcntl(pcm->ba_pcm_fd, F_SETPIPE_SZ, target_capacity);
if (capacity < 0)
warn("Unable to increase pipe capacity to 2 periods");
else
debug("Increased pipe capacity to %d", capacity);
}
else
debug("Pipe capacity = %d", capacity);
}
if ((ret = fcntl(pcm->ba_pcm_fd, F_GETPIPE_SZ)) == -1) {
SNDERR("Unable to read pipe size: %s", strerror(errno));
Expand Down

0 comments on commit 5f7d524

Please sign in to comment.