MSCOMMON.C:
void Ms_init () {
....
/* Register BUILTIN msfilter ' s *//Register all built-in filter
for (i=0;ms_filter_descs[i]!=null;i++) {
Ms_filter_register (Ms_filter_descs[i]);
}
。。。
********************************
Alldesc.h
Among them Ms_filter_descs are as follows:
The desc of the filter in the array has no order
MSFILTERDESC * ms_filter_descs[]={
&ms_alaw_dec_desc,
&ms_alaw_enc_desc,
Panax Notoginseng &ms_ulaw_dec_desc,
&ms_ulaw_enc_desc,
&ms_file_player_desc,
&ms_rtp_send_desc,
&ms_rtp_recv_desc,
&ms_dtmf_gen_desc,
&ms_file_rec_desc,
&ms_speex_dec_desc,
&ms_speex_enc_desc,
&ms_gsm_dec_desc,
&ms_gsm_enc_desc,
&ms_speex_ec_desc,
&ms_tee_desc,
&ms_conf_desc,
Wuyi//&alsa_write_desc,
//&alsa_read_desc,
//&oss_read_desc,
//&oss_write_desc,
//&ms_arts_read_desc,
//&ms_arts_write_desc,
//&ms_v4l_desc,
//&ms_sdl_out_desc,
//&ms_h263_enc_desc,
//&ms_h263_dec_desc,
&ms_join_desc,
#ifndef disable_resample
&ms_resample_desc,
#endif
&ms_volume_desc,
&ms_ice_desc,
&ms_equalizer_desc,
NULL
69};
******************
In Ms_filter_register (Ms_filter_descs[i]), there is a very important method:
Ms_message ("Registering All soundcard handlers");
Cm=ms_snd_card_manager_get (); Get the sound card manager mssndcardmanager
for (i=0;ms_snd_card_descs[i]!=null;i++) {
Ms_snd_card_manager_register_desc (Cm,ms_snd_card_descs[i]); Register a series of sound cards by describing the array with the sound card
}
All of the following analysis is for the Ms_snd_card_manager_register_desc method *********************
Register your sound card to register your sound card to the sound card Manager by using the sound card description Mssndcardmanager
Let's take a look at the Ms_snd_card_manager_register_desc method (MSSNDCARD.C 113 lines)
void Ms_snd_card_manager_register_desc (Mssndcardmanager *m, Mssndcarddesc *desc) {
M->descs=ms_list_append (M->DESCS,DESC);
Card_detect (M,DESC);
}
Continue
static void Card_detect (Mssndcardmanager *m, Mssndcarddesc *desc) {
if (desc->detect!=null)
Desc->detect (m);
}
Detect is a pointer function of the structure _MSSNDCARDDESC. Please see->mssndcard.h 101 line:
struct _mssndcarddesc{
const char *driver_type;
Mssndcarddetectfunc detect;
Mssndcardinitfunc Init;
Mssndcardsetlevelfunc Set_level;
Mssndcardgetlevelfunc Get_level;
Mssndcardsetcapturefunc set_capture;
Mssndcardsetcontrolfunc Set_control;
Mssndcardgetcontrolfunc Get_control;
Mssndcardcreatereaderfunc Create_reader;
Mssndcardcreatewriterfunc Create_writer;
Mssndcarduninitfunc UnInit;
Mssndcardduplicatefunc Duplicate;
Mssndcardunloadfunc unload;
};
In 88 rows there are: typedef void (*MSSNDCARDDETECTFUNC) (Mssndcardmanager *obj);
Ms_snd_card_descs is defined in MSCOMMON.C, see
Static Mssndcarddesc * ms_snd_card_descs[]={
#ifdef __alsa_enabled__
&alsa_card_desc,
#endif
#ifdef Have_sys_soundcard_h
&oss_card_desc,
#endif
#ifdef __arts_enabled__
&arts_card_desc,
#endif
#ifdef WIN32
&winsnd_card_desc,
#endif
#ifdef __directsound_enabled__
&winsndds_card_desc,
#endif
#ifdef __portaudio_enabled__
&pasnd_card_desc,
#endif
#ifdef __macsnd_enabled__
&ca_card_desc,
#endif
#ifdef __pulseaudio_enabled__
&pulse_card_desc,
#endif
#if Target_os_iphone
&au_card_desc,
#endif
#ifdef __mac_aq_enabled__
&aq_card_desc,
#endif
#ifdef ANDROID
&msandroid_sound_card_desc,
#endif
Null
};
A description of the Android sound card was found in line482 (note that this is a global variable)
#ifdef ANDROID
extern Mssndcarddesc Msandroid_sound_card_desc;
#endif
An assignment operation for Msandroid_sound_card_desc was found in Msandroid.cpp.
Mssndcarddesc Msandroid_sound_card_desc = {
/*.driver_type=*/"ANDROID SND",
/*.detect=*/msandroid_sound_detect,
/*.init=*/msandroid_sound_init,
/*.set_level=*/msandroid_sound_set_level,
/*.get_level=*/msandroid_sound_get_level,
/*.set_capture=*/msandroid_sound_set_source,
/*.set_control=*/null,
/*.get_control=*/null,
/*.create_reader=*/msandroid_sound_read_new,
/*.create_writer=*/msandroid_sound_write_new,
/*.uninit=*/msandroid_sound_uninit,
/*.duplicate=*/msandroid_sound_duplicate
};
OK, the Android sound card description finally found, and now look back to see the MSSNDCARD.C in the
static void Card_detect (Mssndcardmanager *m, Mssndcarddesc *desc) {
if (desc->detect!=null)
Desc->detect (m);
}
The value of detect in Msandroid_sound_card_desc is: msandroid_sound_detect
Then find this method in Msandroid.cpp:
void Msandroid_sound_detect (Mssndcardmanager *m) {
Ms_debug ("Msandroid_sound_detect");
Mssndcard *card=msandroid_sound_card_new ();
Ms_snd_card_manager_add_card (M,card);
}
First look at msandroid_sound_card_new ();
Mssndcard *msandroid_sound_card_new () {
Mssndcard *card=ms_snd_card_new (&MSANDROID_SOUND_CARD_DESC);
Card->name=ms_strdup ("Android sound card");
return card;
}
To view the Ms_snd_card_new method in MSSNDCARD.C:
Mssndcard * Ms_snd_card_new (Mssndcarddesc *desc) {
Return Ms_snd_card_new_with_name (Desc,null);
}
Mssndcard * Ms_snd_card_new_with_name (mssndcarddesc *desc,const char* name) {
Mssndcard *obj= (Mssndcard *) ms_new (mssndcard,1);
obj->desc=desc;
Obj->name=name?ms_strdup (name): NULL;
obj->data=null;
obj->id=null;
obj->capabilities=ms_snd_card_cap_capture|ms_snd_card_cap_playback;
if (desc->init!=null)
Desc->init (obj);
return obj;
}
It turns out that the Init method in Msandroid.cpp was eventually transferred:
Unfortunately, it's a pity that!!!!! The init value of Msandroid_sound_card_desc in Msandroid.cpp is Msandroid_sound_init, and its method body
is empty!!!
void Msandroid_sound_init (Mssndcard *card) {
}
Dumbfounded!!!! , although Init is empty, but, after all, a mssndcard is created, in method Ms_snd_card_new_with_name,
And the value of desc,name,capabilities is initialized in this mssndcard. Just not init!!
All right, first stop, back in the msandroid.cpp.
void Msandroid_sound_detect (Mssndcardmanager *m) {
Ms_debug ("Msandroid_sound_detect");
Mssndcard *card=msandroid_sound_card_new ();
Ms_snd_card_manager_add_card (M,card);
}
From the track msandroid_sound_card_new down, found that the card is a value, and now the sound card to add to the sound card manager:
At MSSNDCARD.C 103
void Ms_snd_card_manager_add_card (Mssndcardmanager *m, Mssndcard *c) {
Ms_message ("Card '%s ' added", ms_snd_card_get_string_id (c));
M->cards=ms_list_append (M->CARDS,C);
}
Analysis technique of Ms_snd_card_manager_register_desc method in Ms_init method *********************
MEDIASTREAM2 Source Analysis-1 initialization