alsa音频架构1 (二)

2014-11-24 02:34:44 · 作者: · 浏览: 21
*/
int shutdown; /* this card is going down */
int free_on_last_close; /* free in context of file_release */
wait_queue_head_t shutdown_sleep;
struct device *dev; //设备文件
struct device *card_dev; //声卡设备文件
#ifdef CONFIG_PM
unsigned int power_state; /* power state */
struct mutex power_lock; /* power lock */
wait_queue_head_t power_sleep;
#endif
#if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE)
struct snd_mixer_oss *mixer_oss;
int mixer_oss_change_count;
#endif
};

struct snd_card {
int number; //声卡索引号
char id[16]; //id识别字串
char driver[16]; //驱动名
char shortname[32]; //短名
char longname[80]; //长名
char mixername[80]; /* mixer name */
char components[128]; /* card components delimited with space */
struct module *module; //模块所有者
void *private_data; /* private data for soundcard */
void (*private_free) (struct snd_card *card); /* callback for freeing of private data */
struct list_head devices; //设备链表
unsigned int last_numid; /* last used numeric ID */
struct rw_semaphore controls_rwsem; /* controls list lock */
rwlock_t ctl_files_rwlock; /* ctl_files list lock */
int controls_count; /* count of all controls */
int user_ctl_count; /* count of all user controls */
struct list_head controls; //控制链表
struct list_head ctl_files; /* active control files */
struct snd_info_entry *proc_root; /* root for soundcard specific files */
struct snd_info_entry *proc_id; /* the card id */
struct proc_dir_entry *proc_root_link; /* number link to real id */
struct list_head files_list; /* all files associated to this card */
struct snd_shutdown_f_ops *s_f_ops; /* file operations in the shutdown state */
spinlock_t files_lock; /* lock the files for this card */
int shutdown; /* this card is going down */
int free_on_last_close; /* free in context of file_release */
wait_queue_head_t shutdown_sleep;
struct device *dev; //设备文件
struct device *card_dev; //声卡设备文件
#ifdef CONFIG_PM
unsigned int power_state; /* power state */
struct mutex power_lock; /* power lock */
wait_queue_head_t power_sleep;
#endif
#if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE)
struct snd_mixer_oss *mixer_oss;
int mixer_oss_change_count;
#endif
};
2.1.全局变量snd_cards

在"/sound/core/init.c"

[cpp]
struct snd_card *snd_cards[SNDRV_CARDS];

struct snd_card *snd_cards[SNDRV_CARDS];SNDRV_CARDS为8也就是声卡最多8个

3.声卡设备结构体

[cpp]
struct snd_device {
struct list_head list; //链表
struct snd_card *card; //所属的声卡
snd_device_state_t state; //设备状态
snd_device_type_t type; //设备类型
void *device_data; /* device structure */
struct snd_device_ops *ops; //声卡设备操作函数集
};

struct snd_device {
struct list_head list; //链表
struct snd_card *card; //所属的声卡
snd_device_state_t state; //设备状态
snd_device_type_t type; //设备类型
void *device_data; /* device structure */
struct snd_device_ops *ops; //声卡设备操作函数集
};3.1 设备状态的值

[cpp]
#define SNDRV_DEV_BUILD ((__force snd_device_state_t) 0)//创建
#define SNDRV_DEV_REGISTERED ((__force snd_device_state_t) 1)//注册
#define SNDRV_DEV_DISCONNECTED ((__force snd_device_state_t) 2)//断开连接

#define SNDRV_DEV_BUILD ((__force snd_device_state_t) 0)//创建
#define SNDRV_DEV_REGISTERED ((__force snd_device_state_t) 1)//注