-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement VirtIO sound device #50
Comments
Can you illustrate the progress and the potential integration considerations? |
Hi @jserv , For the progress:
For potential integration considerations:
|
Hi @jserv , For the supporting operations mentioned in #53, to let |
Yes, go ahead. |
For this issue, I am going to implement VirtIO sound device supporting these operations:
|
Update:
I am going to solve the sound card endpoint issue first. |
Update:
|
Statue update:
|
Do you think whether if single-threaded queue manipulation is enough. I am not sure that such TX queue can be operated without extra threads. |
For my current findings, qemu and rust-vmm do not use any extra threads to operate TX queue. |
Statue update:
|
Statue update:
|
Update:
Actions:
|
No, I was intentionally referring to him.
Go ahead. |
Hi @jserv , I am going to summarize the recent work in this comment. Past
Ongoing
|
For my clarity, I would like to confirm the workflow works as:
I have some concern on the third step since I see TX thread send interrupt right after finishing step 2 (correct me if I'm wrong). Typically, sound card sends interrupt every period and ALSA driver polls that interrupt to update hardware pointer for the buffer. If the interrupt is sent right after step 2, audio server may have nothing to play because the driver (guest Linux OS) thinks it has already been played. The driver may think audio under-run is happening and may address it. From my understanding, the length of period normally depends on the capability of sound card hardware and buffer size. So we may use the length that reflects the real hardware. Or we may adjust it for other reasons like batch/fine-grained submission, as long as it won't cause under/over-run or long latency. For sending interrupt every period we may use SIGALRM? It could be too tedious to hook into real hardware interrupts. I've read comments above saying that the driver may prepare arbitrary size of PCM frame data. So to introduce period, we may need to tidy PCM frame data as chunks per period. Edit: fix typo |
Hi @idoleat , I would like to make some statements of the workflows you are concerning for, all based on my understanding of VirtIO standard. So if you think there are still some rooms of uncertainty, just let me know. I will make my observations for interacting with VirtIO standard and VirtIO sound driver (namely, guest Linux OS with Linux Kernel version 6.1) in each list and some statements you have mentioned. Before we begin, let's look about the Virtqueues that a VirtIO sound device will use for communicating with VirtIO sound driver (from Virtqueue section in sound device):
Then, let me reply the list you have mentioned.
By the VirtIO standard, the driver prepares PCM frames in memory, then sends these PCM frames via txq to the device.
This is not mentioned in the VirtIO standard. For my implementation, as we are using MMIO, I use a TX thread to receive PCM frames sent from the driver so that the main thread of device won't just hang for merely receiving PCM frames.
For my understanding, there are two ways to interrupt the driver:
Sorry for my dumb writings, it should be as follows: the driver sends arbitrary number of virtqueue descriptors (for instance of receiving PCM frames from the driver, it may send the virtqueue descriptors like one request, then follow two payloads consisting of PCM frames--the summation size of these payloads will be the size of buffer_bytes set by |
Currently, semu lacks of sound playing feature.
To implement, we can use VirtIO sound with ALSA architecture.
The text was updated successfully, but these errors were encountered: