The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
audio.h File Reference

the sound output core: /dev/dsp, /dev/mixer and the driver interface. More...

#include "common/stdint.h"

Go to the source code of this file.

Data Structures

struct  audio_ops_t
struct  audio_device
struct  audio_status_t
 the state for /proc/audio. More...

Typedefs

typedef struct audio_device audio_device_t

Functions

bool audio_register (audio_device_t *dev)
 register the sound device (one, the first one wins) and make /dev/dsp and /dev/mixer.
uint32_t audio_pull (audio_device_t *dev, void *dst, uint32_t bytes)
 fill a DMA period from the ring buffer, with silence after the data.
void audio_status (audio_status_t *status)
void audio_mix_add (int32_t *sums, const uint8_t *frames, uint32_t samples)
 add 16-bit little-endian samples to sums (the mixing of the streams).
void audio_mix_out (uint8_t *out, const int32_t *sums, uint32_t samples)
 write sums as 16-bit little-endian samples, clipped to the 16-bit range.

Detailed Description

the sound output core: /dev/dsp, /dev/mixer and the driver interface.

a program writes PCM to /dev/dsp. the core converts it to the device format (signed 16-bit little-endian stereo, at the device rate) and keeps it in a ring buffer. the driver plays from DMA buffers split in periods; when the device has played a period, the driver interrupt calls audio_pull to fill it again. if the ring is empty, the period is filled with silence and counted as an underrun (/proc/audio).

several programs can open /dev/dsp at once (up to 8): each has its own ring, and the core adds them together for the device.

Typedef Documentation

◆ audio_device_t

typedef struct audio_device audio_device_t

Function Documentation

◆ audio_register()

bool audio_register ( audio_device_t * dev)

register the sound device (one, the first one wins) and make /dev/dsp and /dev/mixer.

Returns
false if a device is already registered.

◆ audio_pull()

uint32_t audio_pull ( audio_device_t * dev,
void * dst,
uint32_t bytes )

fill a DMA period from the ring buffer, with silence after the data.

call it from the driver interrupt (or from start).

Parameters
dstthe period.
bytesits size (a multiple of 4).
Returns
the bytes of real sound in it.

◆ audio_status()

void audio_status ( audio_status_t * status)

◆ audio_mix_add()

void audio_mix_add ( int32_t * sums,
const uint8_t * frames,
uint32_t samples )

add 16-bit little-endian samples to sums (the mixing of the streams).

◆ audio_mix_out()

void audio_mix_out ( uint8_t * out,
const int32_t * sums,
uint32_t samples )

write sums as 16-bit little-endian samples, clipped to the 16-bit range.