Skip to contentSkip to conversation

Audio stream handling in QEMU device model

Qemu-devel Harry Cruise 2 participants 4 messages Sep 4, 2014 – Sep 6, 2014

lore
Share & tools
lore
#0 lore raw

Hello,

I am trying to comprehend QEMU AUDIO backend functionality and need to implementing device which has few audio channels from which it receives audio streams (sampled at some specific frequency), and further process that data stream like mixing two stream.

I am new for the QEMU, Please help me in following queries:

1) Please suggest some document and example/device implement which has use qemu audio backend.

2) To implement audio
stream read/write functionality, can anyone please suggest pseudocode for the implementation in which audio stream data (samples at some specific frequency ) is stored into some device buffers.

3) What steps I need to add into device to setup audio support as per the requirement I mentioned above ?

4) what is the basic working flow of audio backend and accessing audio streams using dma ?

#1 lore raw
Quoted 9 lines · Harry Cruise

Hello,

I am trying to comprehend QEMU AUDIO backend functionality and need to implementing device which has few audio channels from which it receives audio streams (sampled at some specific frequency), and further process that data stream like mixing two stream.

Quoted 5 lines

I am new for the QEMU, Please help me in following queries:

1) Please suggest some document and example/device implement which has use qemu audio backend.

hw/usb/dev-audio.c (implementing usb speaker emulation) is probably the best sample code for that.

Quoted 2 lines

3) What steps I need to add into device to setup audio support as per the requirement I mentioned above ?

You can just create multiple streams. AUD_open_* returns a handle so you can disturgist them.

Quoted 2 lines

4) what is the basic working flow of audio backend and accessing audio streams using dma ?

Nothing special for audio here, they do dma like any other device. You don't see that in hw/usb/dev-audio.c though as DMA is handled elsewhere (uhci/ehci/xhci usb host adapter emulation). You might want to look at intel-hda for pci dma sample code.

HTH,
Gerd

#2 lore raw

Hi,

Thanks for the reply.. Kindly help me with few more queries..

I tried to understand the audio implementation in qemu from the sources you have suggested. Now, I am confused how audio emulation actually works. The subject

On Thursday, September 4, 2014 1:32 PM, Gerd Hoffmann <[email protected]> wrote:

Quoted 9 lines · Harry Cruise

Hello,

I am trying to comprehend QEMU AUDIO backend functionality and need to implementing device which has few audio channels from which it receives audio streams (sampled at some specific frequency), and further process that data stream like mixing two stream.

Quoted 5 lines

I am new for the QEMU, Please help me in following queries:

1) Please suggest some document and example/device implement which has use qemu audio backend.

hw/usb/dev-audio.c (implementing usb speaker emulation) is probably the best sample code for that.

Quoted 2 lines

3) What steps I need to add into device to setup audio support as per the requirement I mentioned above ?

You can just create multiple streams. AUD_open_* returns a handle so you can disturgist them.

Quoted 2 lines

4) what is the basic working flow of audio backend and accessing audio streams using dma ?

Nothing special for audio here, they do dma like any other device. You don't see that in hw/usb/dev-audio.c though as DMA is handled elsewhere (uhci/ehci/xhci usb host adapter emulation). You might want to look at intel-hda for pci dma sample code.

HTH,
Gerd

is that I need to read the audio streams sampled at particular frequency into some device buffers, then do some process on data buffers and generate some output audio stream.

There are some API's and structs which I believe can be useful for above subject. But I could not understand what exactly it does, or simply how it works ?

1) AUD_read --> As fas as I understand this reads data from some HWVoiceIn structure member associated with SWVoiceIn structure. Please help me in understanding what it does ?
Does it read data from some hardware (i.e. mic) , how I can test this in QEMU ?

2) AUD_write -> Does it sends data to the hardware (i.e., speaker) ?, again how I can test this in QEMU ?

For , above what I understand is that any hardware might have associated buffer, and AUD_read/write api's read/write data from/to that buffers, and drivers associated with the hardware might managing it.

Is it possible that I can associate multiple SWVoiceOut to a single HWVoiceOut ? What is the use of this structures:
SWVoiceIn/Out
HWVoiceIn/Out

3) Reading a audio streams.. how it differs if we read some file data (like reading from *.wav/*.mp4 etc) ? Do we still need to use AUD_read ?

Thanks in advance !!

#3 lore raw

Hi,

Thanks for the reply.. Kindly help me with few more queries..

I tried to understand the audio implementation in qemu from the sources
you have suggested. Now, I am confused how audio emulation actually
works.
The subject is that I need to read the audio streams sampled at particular frequency into some device buffers, then do some process on data buffers and generate some output audio stream.

There
are some API's and structs which I believe can be useful for above
subject. But I could not understand what exactly it does, or simply how it works ?

1) AUD_read --> As fas as
I understand this reads data from some HWVoiceIn structure member
associated with SWVoiceIn structure.
Please help me in understanding what it does ?
Does it read data from some hardware (i.e. mic) , how I can test this in QEMU ?

2) AUD_write -> Does it sends data to the hardware (i.e., speaker) ?, again how I can test this in QEMU ?

For
, above what I understand is that any hardware might have associated buffer, and AUD_read/write api's read/write data from/to
that buffers, and drivers associated with the hardware might managing it.

Is it possible that I can associate multiple SWVoiceOut to a single HWVoiceOut ? What is the use of this structures:
SWVoiceIn/Out
HWVoiceIn/Out

3)
Reading a audio streams.. how it differs if we read some file data
(like reading from *.wav/*.mp4 etc) ? Do we still need to use AUD_read ?

4) What does audfmt_e enumeraion signifies ? is it for audio data in signed or unsigned form ?

5) What os the significance of channels parameter in audsettings structure ?

Thanks in advance !!

On Friday, September 5, 2014 5:28 PM, Harry Cruise <[email protected]> wrote:

Hi,

Thanks for the reply.. Kindly help me with few more queries..

I tried to understand the audio implementation in qemu from the sources you have suggested. Now, I am confused how audio emulation actually works. The subject

On Thursday, September 4, 2014 1:32 PM, Gerd Hoffmann <[email protected]> wrote:

Quoted 9 lines · Harry Cruise

Hello,

I am trying to comprehend QEMU AUDIO backend functionality and need to implementing device which has few audio channels from which it receives audio streams (sampled at some specific frequency), and further process that data stream like mixing two stream.

Quoted 5 lines

I am new for the QEMU, Please help me in following queries:

1) Please suggest some document and example/device implement which has use qemu audio backend.

hw/usb/dev-audio.c (implementing usb speaker emulation) is probably the best
sample code for that.

Quoted 2 lines

3) What steps I need to add into device to setup audio support as per the requirement I mentioned above ?

You can just create multiple streams. AUD_open_* returns a handle so you can disturgist them.

Quoted 2 lines

4) what is the basic working flow of audio backend and accessing audio streams using dma ?

Nothing special for audio here, they do dma like any other device. You don't see that in hw/usb/dev-audio.c though as DMA is handled elsewhere (uhci/ehci/xhci usb host adapter emulation). You might want to look at intel-hda for pci dma sample code.

HTH,
Gerd

is that I need to read the audio streams sampled at particular frequency into some device buffers, then do some process on data buffers and generate some output audio stream.

There are some API's and structs which I believe can be useful for above subject. But I could not understand what exactly it does, or simply how it works ?

1) AUD_read --> As fas as I understand this reads data from some HWVoiceIn structure member associated with SWVoiceIn structure. Please help me in understanding what it does ?
Does it read data from some hardware (i.e. mic) , how I can test this in QEMU ?

2) AUD_write -> Does it sends data to the hardware (i.e., speaker) ?, again how I can test this in QEMU ?

For , above what I understand is that any hardware might have
associated buffer, and AUD_read/write api's read/write data from/to that buffers, and drivers associated with the hardware might managing it.

Is it possible that I can associate multiple SWVoiceOut to a single HWVoiceOut ? What is the use of this structures:
SWVoiceIn/Out
HWVoiceIn/Out

3) Reading a audio streams.. how it differs if we read some file data (like reading from *.wav/*.mp4 etc) ? Do we still need to use AUD_read ?

Thanks in advance !!