2011年1月4日星期二

pulseaudio module-detect analyse

source code path:
src/modules/module-detect.c

1. run this function: "int pa__init(pa_module*m)"
"pa_bool_t just_one = FALSE;" allow more than 1 devices

function pa_modargs_new
in "pulsecore/modargs.c".
"modargs.c" analyse the input args, get the args' value such as: "u32, bool, s32..." and store in pa_hashmap list.

for ALSA,OSS,SOLARIS, each has different device node, so the have different codes.
and for WIN32, it does nothing except load module "module-waveout"

There only analyse ALSA.

#ifdef HAVE_ALSA--> use for alsa
2. "detect_alsa" function:

read info from this file "/proc/asound/devices", to get the device info.
("/dev/sndstat", "/proc/sndstat", "/proc/asound/oss/sndstat" these 3 for OSS)
in my PC, the file is:

------------>
2: : timer
3: : sequencer
4: [ 0- 1]: digital audio playback
5: [ 0- 0]: digital audio playback
6: [ 0- 0]: digital audio capture
7: [ 0- 2]: hardware dependent
8: [ 0] : control
<------------

The file above tells that my PC have one control channel, two PCM playback devices (DAC's), a PCM capture device (ADC's), a hardware dependent device, a MIDI sequencer, and a timer.

This function "sscanf(line, " %*i: [%u- %u]: ", &device, &subdevice)" is so insteresting.

3. Use funtion: "pa_module_load()" to load: "module-alsa-sink", "module-alsa-source" the two modules.

The end: unload the "module-detect" itself.

没有评论:

发表评论