hda codec issue
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 6 lines
cc Volker Rümelin
==========================================
so I was curious about:
1. why using wpos, rpos which will increasing along the time, which may overflow in the feature time?
wpos and rpos are 64 bit integers. At a sample rate of 96kHz and with 32 bit stereo audio frames they overflow after 2^63 bytes / (8 bytes/frame * 96000 frames/s) = 1.2E13 s = 380561.23 years. I don't think you will notice an overflow.
But you're right anyway. The wanted_rpos and wanted_wpos calculation overflows quite early. At a sample rate of 44100kHz and with 16 bit stereo samples the multiplication hda_bytes_per_second(st) * (now - buft_start) overflows after 2^63 bytes / 176400 bytes/ns = 5,23E13 ns = 14.58 hours.
I don't think your fix below is correct. There are certainly ways to prevent the overflow without resetting the buffer.
Quoted 1 line
2. how to fix the
wanted_wposorwanted_rpos, I current don't understand thewanted_posmean and how it work to optimize the codec
This is a jitter-buffer implementation to decouple the audio backend updates from the hda device updates. The code splits large >10ms sized audio packets into 1ms sized audio packets.
With best regards,
Volker
Quoted 43 lines
=======================================================================================================
Currently I got Playback and Capture issue
I test Playing and recoding for a very long time, Playback issue is hard to reproduce, Capture issue is easy to reproduce for recording about 14 hours
Playback issue current can only be found on qemu 2.11, which I found the code below (remove some unnecessary)
wanted_wposoverflow, and is always little then the wpos,(current wpos
- rpos = 0) so qemu will no long get data from vm, as a resultstatic void
hda_audio_output_timer(void *opaque)
{
.............
int64_twanted_wpos=hda_bytes_per_second(st)* (now -buft_start) ============> overflow here /NANOSECONDS_PER_SECOND;
wanted_wpos&= -4; /* IMPORTANT! clip to frames */if (
wanted_wpos<= wpos) {
/* we already received the data */
gotoout_timer;
}
}Capture issue: Just record all the time
(i using qemu 6.0 to test) I add code below to the input callback function like below, the issue dispearhda_audio_input_cb
if (wpos - rpos ==B_SIZE) {
/* drop buffer, reset timer adjust */
st->rpos= 0;
st->wpos= 0;
st->buft_start=qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
error_report("input drop buffer, reset timer adjust\n");
return;
}