|
XenevaOS
|
#include <Sound/sndproxy.h>#include <Sound/sound.h>#include <Fs/Dev/devhw.h>#include <Fs/Dev/devfs.h>#include <Fs/vfs.h>#include <Cred/group.h>#include <Mm/kmalloc.h>#include <Mm/pmmngr.h>#include <Mm/vmmngr.h>#include <Drivers/uart.h>#include <Hal/AA64/aa64lowlevel.h>#include <Hal/AA64/sched.h>#include <Sync/spinlock.h>#include <Serv/sysserv.h>#include <sndsrv.h>#include <string.h>#include <_null.h>
Macros | |
| #define | PX_DETACH_WAIT_MS 200 |
| #define | PX_CARRY_MAX_AGE_MS 1500 |
| #define | PX_BYTES_PER_MS 192 /* 48 kHz * 2 channels * 2 bytes */ |
| #define | PX_TARGET_PERIODS 2 /* backlog the writer may keep queued */ |
| #define | PX_PACE_MAX_MS 80 |
Functions | |
| uint64_t | AuGetCurrentMS () |
| void | AuSndProxyOwnerGone (AuProcess *proc) |
| AuSndProxyOwnerGone – detach if proc owns the proxy; called before that process's DMA memory is freed. | |
| void | AuSndProxyInitialize (void) |
| AuSndProxyInitialize – register /dev/sndsrv. | |
| #define PX_BYTES_PER_MS 192 /* 48 kHz * 2 channels * 2 bytes */ |
| #define PX_CARRY_MAX_AGE_MS 1500 |
| #define PX_DETACH_WAIT_MS 200 |
| #define PX_PACE_MAX_MS 80 |
| #define PX_TARGET_PERIODS 2 /* backlog the writer may keep queued */ |
|
extern |
sndproxy.c – kernel half of a user-space sound driver.
A server process (Process/sndsrv) that owns the sound hardware through /dev/hwdev passes the kernel a shared ring (see BaseHdr/sndsrv.h). The kernel then registers an ordinary sound card, "virtio-sound", whose write() copies the mixer's PCM into that ring instead of touching hardware. The rest of the sound stack (mixer, DSP clients) cannot tell the difference.
Safety rules:
| void AuSndProxyInitialize | ( | void | ) |
AuSndProxyInitialize – register /dev/sndsrv.
| void AuSndProxyOwnerGone | ( | AuProcess * | proc | ) |
AuSndProxyOwnerGone – detach if proc owns the proxy; called before that process's DMA memory is freed.
| volatile bool attached |
| uint64_t calls |
| AuSound card |
| uint8_t* carry |
| uint32_t carry_len |
| uint64_t carry_ms |
| uint8_t* data |
| uint64_t dropped |
| SndRingHdr* hdr |
| volatile int inflight |
| AuProcess* owner | ( | void | ) |
| uint64_t written |