aaudio: fix wrong latency assignment

Due to (likely) copy-pasted code between input and output stream initialisation, the input stream latency was assigned to the output stream structure.

Input and output latency values are actually different, for example on my machine:
```
Latencies for device Digital Mic: in=40 out=42
Latencies for device Codec Output: in=6 out=41
Latencies for device Speaker: in=8 out=19
Latencies for device Bridge Loopback: in=13 out=30
Latencies for device Codec Input: in=47 out=0
```

This may or may not also fix the following, previously common error message: (e.g.)  `aaudio aaudio: invalid position: , pos = 53211761056, buffer size = 16640, period size = 1`. At least, it hasn't appeared since I applied this change. 

Also corrects typos in macro names and an error message.
This commit is contained in:
Antoine Sidem
2026-02-25 01:40:46 +01:00
committed by GitHub
parent bbdfac953c
commit 8d8e0f7971
+11 -11
View File
@@ -272,10 +272,10 @@ static void aaudio_init_dev(struct aaudio_device *a, aaudio_device_id_t dev_id)
dev_err(a->dev, "Failed to get input stream list for device %llx\n", dev_id);
goto fail;
}
if (stream_cnt > AAUDIO_DEIVCE_MAX_INPUT_STREAMS) {
if (stream_cnt > AAUDIO_DEVICE_MAX_INPUT_STREAMS) {
dev_warn(a->dev, "Device %s input stream count %llu is larger than the supported count of %u\n",
sdev->uid, stream_cnt, AAUDIO_DEIVCE_MAX_INPUT_STREAMS);
stream_cnt = AAUDIO_DEIVCE_MAX_INPUT_STREAMS;
sdev->uid, stream_cnt, AAUDIO_DEVICE_MAX_INPUT_STREAMS);
stream_cnt = AAUDIO_DEVICE_MAX_INPUT_STREAMS;
}
sdev->in_stream_cnt = stream_cnt;
for (i = 0; i < stream_cnt; i++) {
@@ -289,17 +289,17 @@ static void aaudio_init_dev(struct aaudio_device *a, aaudio_device_id_t dev_id)
dev_err(a->dev, "Failed to get output stream list for device %llx\n", dev_id);
goto fail;
}
if (stream_cnt > AAUDIO_DEIVCE_MAX_OUTPUT_STREAMS) {
dev_warn(a->dev, "Device %s input stream count %llu is larger than the supported count of %u\n",
sdev->uid, stream_cnt, AAUDIO_DEIVCE_MAX_OUTPUT_STREAMS);
stream_cnt = AAUDIO_DEIVCE_MAX_OUTPUT_STREAMS;
if (stream_cnt > AAUDIO_DEVICE_MAX_OUTPUT_STREAMS) {
dev_warn(a->dev, "Device %s output stream count %llu is larger than the supported count of %u\n",
sdev->uid, stream_cnt, AAUDIO_DEVICE_MAX_OUTPUT_STREAMS);
stream_cnt = AAUDIO_DEVICE_MAX_OUTPUT_STREAMS;
}
sdev->out_stream_cnt = stream_cnt;
for (i = 0; i < stream_cnt; i++) {
sdev->out_streams[i].id = stream_list[i];
sdev->out_streams[i].buffer_cnt = 0;
aaudio_init_stream_info(sdev, &sdev->out_streams[i]);
sdev->out_streams[i].latency += sdev->in_latency;
sdev->out_streams[i].latency += sdev->out_latency;
}
if (sdev->is_pcm)
@@ -454,10 +454,10 @@ static void aaudio_init_bs_stream(struct aaudio_device *a, struct aaudio_stream
{
size_t i;
strm->buffer_cnt = bs_strm->num_buffers;
if (bs_strm->num_buffers > AAUDIO_DEIVCE_MAX_BUFFER_COUNT) {
if (bs_strm->num_buffers > AAUDIO_DEVICE_MAX_BUFFER_COUNT) {
dev_warn(a->dev, "BufferStruct buffer count %u exceeds driver limit of %u\n", bs_strm->num_buffers,
AAUDIO_DEIVCE_MAX_BUFFER_COUNT);
strm->buffer_cnt = AAUDIO_DEIVCE_MAX_BUFFER_COUNT;
AAUDIO_DEVICE_MAX_BUFFER_COUNT);
strm->buffer_cnt = AAUDIO_DEVICE_MAX_BUFFER_COUNT;
}
if (!strm->buffer_cnt)
return;