mirror of
				https://github.com/alsa-project/alsa-lib.git
				synced 2025-10-29 05:40:25 -04:00 
			
		
		
		
	- added asym plugin.
This commit is contained in:
		
							parent
							
								
									73365bd766
								
							
						
					
					
						commit
						b833982c70
					
				
					 5 changed files with 124 additions and 3 deletions
				
			
		|  | @ -59,6 +59,7 @@ INPUT            = index.doxygen \ | |||
| 		   ../src/pcm/pcm_direct.c \ | ||||
| 		   ../src/pcm/pcm_meter.c \ | ||||
| 		   ../src/pcm/pcm_ladspa.c \ | ||||
| 		   ../src/pcm/pcm_asym.c \ | ||||
| 		   ../src/pcm/pcm_misc.c \ | ||||
| 		   ../src/rawmidi \ | ||||
| 		   ../src/timer \ | ||||
|  |  | |||
|  | @ -11,7 +11,7 @@ libpcm_la_SOURCES = atomic.c mask.c interval.c \ | |||
| 	            pcm_shm.c pcm_file.c pcm_null.c pcm_share.c \ | ||||
| 		    pcm_meter.c pcm_hooks.c pcm_lfloat.c pcm_ladspa.c \ | ||||
| 		    pcm_direct.c pcm_dmix.c pcm_dsnoop.c pcm_dshare.c \ | ||||
| 		    pcm_symbols.c | ||||
| 		    pcm_asym.c pcm_symbols.c | ||||
| noinst_HEADERS = pcm_local.h pcm_plugin.h mask.h mask_inline.h \ | ||||
| 	         interval.h interval_inline.h plugin_ops.h ladspa.h \ | ||||
| 		 pcm_direct.h pcm_dmix_i386.h pcm_dmix_x86_64.h | ||||
|  |  | |||
|  | @ -1782,7 +1782,7 @@ snd_pcm_t *snd_async_handler_get_pcm(snd_async_handler_t *handler) | |||
| static char *build_in_pcms[] = { | ||||
| 	"adpcm", "alaw", "copy", "dmix", "file", "hooks", "hw", "ladspa", "lfloat", | ||||
| 	"linear", "meter", "mulaw", "multi", "null", "plug", "rate", "route", "share", | ||||
| 	"shm", "dsnoop", "dshare", NULL | ||||
| 	"shm", "dsnoop", "dshare", "asym", NULL | ||||
| }; | ||||
| 
 | ||||
| static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name, | ||||
|  |  | |||
							
								
								
									
										118
									
								
								src/pcm/pcm_asym.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										118
									
								
								src/pcm/pcm_asym.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,118 @@ | |||
| /**
 | ||||
|  * \file pcm/pcm_asym.c | ||||
|  * \ingroup PCM_Plugins | ||||
|  * \brief PCM Asymmetrical Plugin Interface | ||||
|  * \author Takashi Iwai <tiwai@suse.de> | ||||
|  * \date 2003 | ||||
|  */ | ||||
| 
 | ||||
| #include "pcm_local.h" | ||||
| 
 | ||||
| #ifndef PIC | ||||
| /* entry for static linking */ | ||||
| const char *_snd_module_pcm_asym = ""; | ||||
| #endif | ||||
| 
 | ||||
| /*! \page pcm_plugins
 | ||||
| 
 | ||||
| \section pcm_plugins_asym Plugin: asym | ||||
| 
 | ||||
| This plugin is a combination of playback and capture PCM streams. | ||||
| Slave PCMs can be defined asymmetrically for both directions. | ||||
| 
 | ||||
| \code | ||||
| pcm.name { | ||||
|         type asym               # Asym PCM | ||||
|         playback STR            # Playback slave name | ||||
|         # or | ||||
|         playback {              # Playback slave definition | ||||
|                 pcm STR         # Slave PCM name | ||||
|                 # or | ||||
|                 pcm { }         # Slave PCM definition | ||||
|         } | ||||
|         capture STR             # Capture slave name | ||||
|         # or | ||||
|         capture {               # Capture slave definition | ||||
|                 pcm STR         # Slave PCM name | ||||
|                 # or | ||||
|                 pcm { }         # Slave PCM definition | ||||
|         } | ||||
| } | ||||
| \endcode | ||||
| 
 | ||||
| For example, you can combine a dmix plugin and a dsnoop plugin as | ||||
| as a single PCM for playback and capture directions, respectively. | ||||
| \code | ||||
| pcm.duplex { | ||||
| 	type asym | ||||
| 	playback.pcm "dmix" | ||||
| 	capture.pcm "dsnoop" | ||||
| } | ||||
| \endcode | ||||
| 
 | ||||
| By defining only a single direction, the resultant PCM becomes | ||||
| half-duplex. | ||||
| 
 | ||||
| \subsection pcm_plugins_asym_funcref Function reference | ||||
| 
 | ||||
| <UL> | ||||
|   <LI>_snd_pcm_asym_open() | ||||
| </UL> | ||||
| 
 | ||||
| */ | ||||
| 
 | ||||
| /**
 | ||||
|  * \brief Creates a new asym stream PCM | ||||
|  * \param pcmp Returns created PCM handle | ||||
|  * \param name Name of PCM | ||||
|  * \param root Root configuration node | ||||
|  * \param conf Configuration node with copy PCM description | ||||
|  * \param stream Stream type | ||||
|  * \param mode Stream mode | ||||
|  * \retval zero on success otherwise a negative error code | ||||
|  * \warning Using of this function might be dangerous in the sense | ||||
|  *          of compatibility reasons. The prototype might be freely | ||||
|  *          changed in future. | ||||
|  */ | ||||
| int _snd_pcm_asym_open(snd_pcm_t **pcmp, const char *name ATTRIBUTE_UNUSED, | ||||
| 			 snd_config_t *root, snd_config_t *conf, | ||||
| 			 snd_pcm_stream_t stream, int mode) | ||||
| { | ||||
| 	snd_config_iterator_t i, next; | ||||
| 	int err; | ||||
| 	snd_config_t *slave = NULL, *sconf; | ||||
| 	snd_config_for_each(i, next, conf) { | ||||
| 		snd_config_t *n = snd_config_iterator_entry(i); | ||||
| 		const char *id; | ||||
| 		if (snd_config_get_id(n, &id) < 0) | ||||
| 			continue; | ||||
| 		if (snd_pcm_conf_generic_id(id)) | ||||
| 			continue; | ||||
| 		if (strcmp(id, "playback") == 0) { | ||||
| 			if (stream == SND_PCM_STREAM_PLAYBACK) | ||||
| 				slave = n; | ||||
| 			continue; | ||||
| 		} | ||||
| 		if (strcmp(id, "capture") == 0) { | ||||
| 			if (stream == SND_PCM_STREAM_CAPTURE) | ||||
| 				slave = n; | ||||
| 			continue; | ||||
| 		} | ||||
| 		SNDERR("Unknown field %s", id); | ||||
| 		return -EINVAL; | ||||
| 	} | ||||
| 	if (! slave) { | ||||
| 		SNDERR("%s slave is not defined", | ||||
| 		       stream == SND_PCM_STREAM_PLAYBACK ? "playback" : "capture"); | ||||
| 		return -EINVAL; | ||||
| 	} | ||||
| 	err = snd_pcm_slave_conf(root, slave, &sconf, 0); | ||||
| 	if (err < 0) | ||||
| 		return err; | ||||
| 	err = snd_pcm_open_slave(pcmp, root, sconf, stream, mode); | ||||
| 	snd_config_delete(sconf); | ||||
| 	return err; | ||||
| } | ||||
| #ifndef DOC_HIDDEN | ||||
| SND_DLSYM_BUILD_VERSION(_snd_pcm_asym_open, SND_PCM_DLSYM_VERSION); | ||||
| #endif | ||||
|  | @ -43,6 +43,7 @@ extern const char *_snd_module_pcm_ladspa; | |||
| extern const char *_snd_module_pcm_dmix; | ||||
| extern const char *_snd_module_pcm_dsnoop; | ||||
| extern const char *_snd_module_pcm_dshare; | ||||
| extern const char *_snd_module_pcm_asym; | ||||
| 
 | ||||
| static const char **snd_pcm_open_objects[] = { | ||||
| 	&_snd_module_pcm_adpcm, | ||||
|  | @ -65,7 +66,8 @@ static const char **snd_pcm_open_objects[] = { | |||
| 	&_snd_module_pcm_ladspa, | ||||
| 	&_snd_module_pcm_dmix, | ||||
| 	&_snd_module_pcm_dsnoop, | ||||
| 	&_snd_module_pcm_dshare | ||||
| 	&_snd_module_pcm_dshare, | ||||
| 	&_snd_module_pcm_asym | ||||
| }; | ||||
| 	 | ||||
| void *snd_pcm_open_symbols(void) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Takashi Iwai
						Takashi Iwai