Not much for now.
KolibriOS sound system layers.
-
layers.PNG (21.28 KiB)
Viewed 5039 times
You can compare it with
this picture on
this page.
Application that wants to output sound have to
1. create buffer using
SND_CREATE_BUFF service routine of Infinity
2. set format of the buffer using
SND_SET_FORMAT service routine of Infinity
3. start playing using
SND_PLAY service routine of Infinity
4. Update the sound samples in the buffer
Infinity get samples from all sound buffers of all applications that output sound and mix them together in one buffer that is given to Infinity by sound.obj.
When the
Infinity is called for the first time it inits itself and then calling
sound.obj init it also.
Infinity call
DEV_CALLBACK servise routine of sound.obj to insert address of callback function to [ctrl.user_callback] variable.
Sound.obj is responsible for calling this callback function every time when
IRQ generated on end of processing buffer. So callback called in
IRQ handler tesing if interrupt comes on end of buffer event (there are can be different events on which the same interrupt is generated). There can be e.g. 2 buffers (like in
HDA) that
sound.obj is responsible to change one by one. One buffer is given to Infinity to refill it with new portion of samples, while the second is outputed by souncard.
Here is
HDA IRQ handler, where you can see piece of code that changes buffers and call callback function of
Infinity (I have selected that piece by ;!!!!!!!!!!! [ .... ;!!!!!!!!!!! ] brackets).
Code: Select all
align 4
proc hda_irq ;+
; if DEBUG_IRQ
; mov esi, msgIRQ
; call SysMsgBoardStr
; end if
mov edx, ICH6_REG_INTSTS
call azx_readl
test eax, eax
jnz @f
popa
ret
@@:
;!!!!!!!!!!! [
mov ebx, eax ; status
mov eax, 1 shl 4
test ebx, eax
jz @f
mov al, SD_INT_MASK
mov edx, ICH6_REG_SD_STS + SDO0_SD_OFFSET
call azx_writeb
mov eax, [civ_val]
inc eax
and eax, 1
mov [civ_val], eax
mov ebx, dword [buff_list+eax*4]
cmp [ctrl.user_callback], 0
je @f
stdcall [ctrl.user_callback], ebx[/b]
;!!!!!!!!!!! ]
@@:
; clear rirb int
mov edx, ICH6_REG_RIRBSTS
call azx_readb
test al, RIRB_INT_MASK
jz .l1
test al, RIRB_INT_RESPONSE
jz @f
call azx_update_rirb
@@:
mov al, RIRB_INT_MASK
mov edx, ICH6_REG_RIRBSTS
call azx_writeb
.l1:
ret
endp
Sound.obj also is responsible for creating that sound buffers that will be read by souncard and filled by
Infinity. Every buffer have to be page aligned and to have size = 16 Kb.
So for two buffers we have such a code
Code: Select all
stdcall KernelAlloc, 0x8000
mov [ctrl.buffer], eax
mov edi, eax
mov ecx, 0x8000/4
xor eax, eax
cld
rep stosd
Infinity need not know how the sound is outputed by the sound card it is the matter of
sound.obj to operate with it. All that
Infinity have to know is address of the sound buffer and when to fill it (all this information is given to it by
sound.obj). So such an approach gives us
HAL (hardware abstraction layer) that makes KolibriOS sound system universal and usefull for any soundcard.
This what I can say you in brief about KolibriOS sound system.
Later I will tell you about
HDA controller, codecs and output devices interraction.