Hi, > - The output from the sound card is accompanied by periodic > white noise. I do not know why this is happening. I tried > debugging it by writing the buffers to a new wav file and > sure enough the contents of the file were different at > some places, but I couldn't find what must be causing it. > (Relevant patches: #19, #20, #21 and #25.) What steps should > I take for debugging this?
Hmm, I'd try to simplify the code. The two helper functions virtio_snd_pcm_get_buf() + virtio_snd_pcm_handle_buf_written() look rather complex to me. I'd suggest to make them handle a single virtqueue element only. That should make the logic simpler. The loop in virtio_snd_output_cb() will need to take a few more rounds then, and virtio_snd_pcm_get_buf() would probably have to return the number of bytes it actually placed in the buffer so you can pass on that value to AUD_write(). For actual debugging I typically use trace points or temporary debug printfs or a combination of both. I'd suggest logging the buffer handling, filling them from virt queue, writing to AUD, also log the offset, maybe something goes wrong with partial writes. > - What is the suggested way of waiting? When the driver issues > the VIRTIO_SND_PCM_STOP ctrl command I want to wait for the > buffers existing in tx vq to be consumed before closing the > stream. Store a pointer to the virtqueue element, then complete it when virtio_snd_output_cb() processed all pending buffers. take care, Gerd
