mirror of
				https://github.com/alsa-project/alsa-lib.git
				synced 2025-11-03 09:01:52 -05:00 
			
		
		
		
	Added snd_pcm_type_name()
Fixed rate conversion plugin (SIGSEGV) - rounding problem
This commit is contained in:
		
							parent
							
								
									c8fab38b67
								
							
						
					
					
						commit
						157107491c
					
				
					 5 changed files with 54 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -348,6 +348,7 @@ enum _snd_pcm_type {
 | 
			
		|||
	SND_PCM_TYPE_DMIX,
 | 
			
		||||
	/** Jack Audio Connection Kit plugin */
 | 
			
		||||
	SND_PCM_TYPE_JACK,
 | 
			
		||||
	SND_PCM_TYPE_LAST = SND_PCM_TYPE_JACK
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** PCM type */
 | 
			
		||||
| 
						 | 
				
			
			@ -947,6 +948,7 @@ snd_pcm_uframes_t snd_pcm_status_get_overrange(const snd_pcm_status_t *obj);
 | 
			
		|||
 * \{
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
const char *snd_pcm_type_name(snd_pcm_state_t state);
 | 
			
		||||
const char *snd_pcm_stream_name(const snd_pcm_stream_t stream);
 | 
			
		||||
const char *snd_pcm_access_name(const snd_pcm_access_t _access);
 | 
			
		||||
const char *snd_pcm_format_name(const snd_pcm_format_t format);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -92,6 +92,7 @@ ALSA_0.9.0rc8 {
 | 
			
		|||
ALSA_0.9.0 {
 | 
			
		||||
  global:
 | 
			
		||||
 | 
			
		||||
    snd_pcm_type_name;
 | 
			
		||||
    snd_timer_query_info;
 | 
			
		||||
    snd_timer_query_params;
 | 
			
		||||
    snd_timer_query_status;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1217,6 +1217,7 @@ int snd_pcm_poll_descriptors_revents(snd_pcm_t *pcm, struct pollfd *pfds, unsign
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
#ifndef DOC_HIDDEN
 | 
			
		||||
#define PCMTYPE(v) [SND_PCM_TYPE_##v] = #v
 | 
			
		||||
#define STATE(v) [SND_PCM_STATE_##v] = #v
 | 
			
		||||
#define STREAM(v) [SND_PCM_STREAM_##v] = #v
 | 
			
		||||
#define READY(v) [SND_PCM_READY_##v] = #v
 | 
			
		||||
| 
						 | 
				
			
			@ -1233,6 +1234,7 @@ int snd_pcm_poll_descriptors_revents(snd_pcm_t *pcm, struct pollfd *pfds, unsign
 | 
			
		|||
#define FORMATD(v, d) [SND_PCM_FORMAT_##v] = d
 | 
			
		||||
#define SUBFORMATD(v, d) [SND_PCM_SUBFORMAT_##v] = d 
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static const char *snd_pcm_stream_names[] = {
 | 
			
		||||
	STREAM(PLAYBACK),
 | 
			
		||||
	STREAM(CAPTURE),
 | 
			
		||||
| 
						 | 
				
			
			@ -1339,6 +1341,33 @@ static const char *snd_pcm_format_descriptions[] = {
 | 
			
		|||
	FORMATD(U18_3BE, "Unsigned 18 bit Big Endian in 3bytes"),
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static const char *snd_pcm_type_names[] = {
 | 
			
		||||
	PCMTYPE(HW), 
 | 
			
		||||
	PCMTYPE(HOOKS), 
 | 
			
		||||
	PCMTYPE(MULTI), 
 | 
			
		||||
	PCMTYPE(FILE), 
 | 
			
		||||
	PCMTYPE(NULL), 
 | 
			
		||||
	PCMTYPE(SHM), 
 | 
			
		||||
	PCMTYPE(INET), 
 | 
			
		||||
	PCMTYPE(COPY), 
 | 
			
		||||
	PCMTYPE(LINEAR), 
 | 
			
		||||
	PCMTYPE(ALAW), 
 | 
			
		||||
	PCMTYPE(MULAW), 
 | 
			
		||||
	PCMTYPE(ADPCM), 
 | 
			
		||||
	PCMTYPE(RATE), 
 | 
			
		||||
	PCMTYPE(ROUTE), 
 | 
			
		||||
	PCMTYPE(PLUG), 
 | 
			
		||||
	PCMTYPE(SHARE), 
 | 
			
		||||
	PCMTYPE(METER), 
 | 
			
		||||
	PCMTYPE(MIX), 
 | 
			
		||||
	PCMTYPE(DROUTE), 
 | 
			
		||||
	PCMTYPE(LBSERVER), 
 | 
			
		||||
	PCMTYPE(LINEAR_FLOAT), 
 | 
			
		||||
	PCMTYPE(LADSPA), 
 | 
			
		||||
	PCMTYPE(DMIX), 
 | 
			
		||||
	PCMTYPE(JACK), 
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static const char *snd_pcm_subformat_names[] = {
 | 
			
		||||
	SUBFORMAT(STD), 
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			@ -1511,6 +1540,23 @@ const char *snd_pcm_state_name(snd_pcm_state_t state)
 | 
			
		|||
	return snd_pcm_state_names[state];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * \brief get name of PCM type
 | 
			
		||||
 * \param type PCM type
 | 
			
		||||
 * \return ascii name of PCM type
 | 
			
		||||
 */
 | 
			
		||||
#ifndef DOXYGEN
 | 
			
		||||
const char *INTERNAL(snd_pcm_type_name)(snd_pcm_type_t type)
 | 
			
		||||
#else
 | 
			
		||||
const char *snd_pcm_type_name(snd_pcm_type_t type)
 | 
			
		||||
#endif
 | 
			
		||||
{
 | 
			
		||||
	if (type > SND_PCM_TYPE_LAST)
 | 
			
		||||
		return NULL;
 | 
			
		||||
	return snd_pcm_type_names[type];
 | 
			
		||||
}
 | 
			
		||||
default_symbol_version(__snd_pcm_type_name, snd_pcm_type_name, ALSA_0.9.0);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * \brief Dump current hardware setup for PCM
 | 
			
		||||
 * \param pcm PCM handle
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -351,6 +351,7 @@ static snd_pcm_sframes_t snd_pcm_plugin_write_areas(snd_pcm_t *pcm,
 | 
			
		|||
	snd_pcm_t *slave = plugin->slave;
 | 
			
		||||
	snd_pcm_uframes_t xfer = 0;
 | 
			
		||||
	snd_pcm_sframes_t result;
 | 
			
		||||
	int err;
 | 
			
		||||
 | 
			
		||||
	while (size > 0) {
 | 
			
		||||
		snd_pcm_uframes_t frames = size;
 | 
			
		||||
| 
						 | 
				
			
			@ -358,8 +359,8 @@ static snd_pcm_sframes_t snd_pcm_plugin_write_areas(snd_pcm_t *pcm,
 | 
			
		|||
		snd_pcm_uframes_t slave_offset;
 | 
			
		||||
		snd_pcm_uframes_t slave_frames = ULONG_MAX;
 | 
			
		||||
		
 | 
			
		||||
		snd_pcm_mmap_begin(slave, &slave_areas, &slave_offset, &slave_frames);
 | 
			
		||||
		if (slave_frames == 0)
 | 
			
		||||
		err = snd_pcm_mmap_begin(slave, &slave_areas, &slave_offset, &slave_frames);
 | 
			
		||||
		if (err < 0 || slave_frames == 0)
 | 
			
		||||
			break;
 | 
			
		||||
		frames = plugin->write(pcm, areas, offset, frames,
 | 
			
		||||
				       slave_areas, slave_offset, &slave_frames);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -458,11 +458,13 @@ static int snd_pcm_rate_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t * params)
 | 
			
		|||
	}
 | 
			
		||||
	params->boundary = boundary1;
 | 
			
		||||
	sparams.boundary = boundary2;
 | 
			
		||||
#if 0
 | 
			
		||||
	if (pcm->stream == SND_PCM_STREAM_PLAYBACK) {
 | 
			
		||||
		rate->pitch = (((u_int64_t)boundary2 * DIV) + boundary1 / 2) / boundary1;
 | 
			
		||||
	} else {
 | 
			
		||||
		rate->pitch = (((u_int64_t)boundary1 * DIV) + boundary2 / 2) / boundary2;
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
	recalc(pcm, &sparams.avail_min);
 | 
			
		||||
	recalc(pcm, &sparams.xfer_align);
 | 
			
		||||
	recalc(pcm, &sparams.start_threshold);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue