XenevaOS
Loading...
Searching...
No Matches
Macros | Functions
sndproxy.c File Reference
#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>
Include dependency graph for sndproxy.c:

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.
 

Macro Definition Documentation

◆ PX_BYTES_PER_MS

#define PX_BYTES_PER_MS   192 /* 48 kHz * 2 channels * 2 bytes */

◆ PX_CARRY_MAX_AGE_MS

#define PX_CARRY_MAX_AGE_MS   1500

◆ PX_DETACH_WAIT_MS

#define PX_DETACH_WAIT_MS   200

◆ PX_PACE_MAX_MS

#define PX_PACE_MAX_MS   80

◆ PX_TARGET_PERIODS

#define PX_TARGET_PERIODS   2 /* backlog the writer may keep queued */

Function Documentation

◆ AuGetCurrentMS()

uint64_t AuGetCurrentMS ( )
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:

  • the ring must be one of the caller's own hwdev DMA buffers (AuHwdevOwnsDma)
  • write() never spins or waits on the server: it paces itself by sleeping, and if the server stops draining, data is dropped rather than hanging
  • when the server's device handle goes away (exit/crash) the card is removed and in-flight writers are drained BEFORE its memory is freed

◆ AuSndProxyInitialize()

void AuSndProxyInitialize ( void  )

AuSndProxyInitialize – register /dev/sndsrv.

◆ AuSndProxyOwnerGone()

void AuSndProxyOwnerGone ( AuProcess *  proc)

AuSndProxyOwnerGone – detach if proc owns the proxy; called before that process's DMA memory is freed.

Variable Documentation

◆ attached

volatile bool attached

◆ calls

uint64_t calls

◆ card

AuSound card

◆ carry

uint8_t* carry

◆ carry_len

uint32_t carry_len

◆ carry_ms

uint64_t carry_ms

◆ data

uint8_t* data

◆ dropped

uint64_t dropped

◆ hdr

SndRingHdr* hdr

◆ inflight

volatile int inflight

◆ owner

AuProcess* owner ( void  )

◆ written

uint64_t written