mirror of
				https://github.com/alsa-project/alsa-lib.git
				synced 2025-11-03 09:01:52 -05:00 
			
		
		
		
	Added missing rawmidi functions. Cleaned PCM use of masks
This commit is contained in:
		
							parent
							
								
									a7561a9c7e
								
							
						
					
					
						commit
						4c9fd35a60
					
				
					 14 changed files with 159 additions and 135 deletions
				
			
		| 
						 | 
				
			
			@ -316,17 +316,15 @@ static int snd_pcm_adpcm_hw_refine_cprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t
 | 
			
		|||
{
 | 
			
		||||
	snd_pcm_adpcm_t *adpcm = pcm->private;
 | 
			
		||||
	int err;
 | 
			
		||||
	snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof());
 | 
			
		||||
	snd_mask_load(access_mask, SND_PCM_ACCBIT_PLUGIN);
 | 
			
		||||
	snd_pcm_access_mask_t access_mask = { SND_PCM_ACCBIT_PLUGIN };
 | 
			
		||||
	err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_ACCESS,
 | 
			
		||||
				     access_mask);
 | 
			
		||||
					 &access_mask);
 | 
			
		||||
	if (err < 0)
 | 
			
		||||
		return err;
 | 
			
		||||
	if (adpcm->sformat == SND_PCM_FORMAT_IMA_ADPCM) {
 | 
			
		||||
		snd_pcm_format_mask_t *format_mask = alloca(snd_pcm_format_mask_sizeof());
 | 
			
		||||
		snd_mask_load(format_mask, SND_PCM_FMTBIT_LINEAR);
 | 
			
		||||
		snd_pcm_format_mask_t format_mask = { SND_PCM_FMTBIT_LINEAR };
 | 
			
		||||
		err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_FORMAT,
 | 
			
		||||
						 format_mask);
 | 
			
		||||
						 &format_mask);
 | 
			
		||||
	} else {
 | 
			
		||||
		err = _snd_pcm_hw_params_set_format(params,
 | 
			
		||||
						   SND_PCM_FORMAT_IMA_ADPCM);
 | 
			
		||||
| 
						 | 
				
			
			@ -344,11 +342,10 @@ static int snd_pcm_adpcm_hw_refine_cprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t
 | 
			
		|||
static int snd_pcm_adpcm_hw_refine_sprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *sparams)
 | 
			
		||||
{
 | 
			
		||||
	snd_pcm_adpcm_t *adpcm = pcm->private;
 | 
			
		||||
	snd_pcm_access_mask_t *saccess_mask = alloca(snd_pcm_access_mask_sizeof());
 | 
			
		||||
	snd_mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
 | 
			
		||||
	snd_pcm_access_mask_t saccess_mask = { SND_PCM_ACCBIT_MMAP };
 | 
			
		||||
	_snd_pcm_hw_params_any(sparams);
 | 
			
		||||
	_snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
 | 
			
		||||
				saccess_mask);
 | 
			
		||||
				   &saccess_mask);
 | 
			
		||||
	_snd_pcm_hw_params_set_format(sparams, adpcm->sformat);
 | 
			
		||||
	_snd_pcm_hw_params_set_subformat(sparams, SND_PCM_SUBFORMAT_STD);
 | 
			
		||||
	return 0;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -215,17 +215,15 @@ static int snd_pcm_alaw_hw_refine_cprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *
 | 
			
		|||
{
 | 
			
		||||
	snd_pcm_alaw_t *alaw = pcm->private;
 | 
			
		||||
	int err;
 | 
			
		||||
	snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof());
 | 
			
		||||
	snd_mask_load(access_mask, SND_PCM_ACCBIT_PLUGIN);
 | 
			
		||||
	snd_pcm_access_mask_t access_mask = { SND_PCM_ACCBIT_PLUGIN };
 | 
			
		||||
	err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_ACCESS,
 | 
			
		||||
				     access_mask);
 | 
			
		||||
					 &access_mask);
 | 
			
		||||
	if (err < 0)
 | 
			
		||||
		return err;
 | 
			
		||||
	if (alaw->sformat == SND_PCM_FORMAT_A_LAW) {
 | 
			
		||||
		snd_pcm_format_mask_t *format_mask = alloca(snd_pcm_format_mask_sizeof());
 | 
			
		||||
		snd_mask_load(format_mask, SND_PCM_FMTBIT_LINEAR);
 | 
			
		||||
		snd_pcm_format_mask_t format_mask = { SND_PCM_FMTBIT_LINEAR };
 | 
			
		||||
		err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_FORMAT,
 | 
			
		||||
						 format_mask);
 | 
			
		||||
						 &format_mask);
 | 
			
		||||
	} else {
 | 
			
		||||
		err = _snd_pcm_hw_params_set_format(params, 
 | 
			
		||||
						   SND_PCM_FORMAT_A_LAW);
 | 
			
		||||
| 
						 | 
				
			
			@ -242,11 +240,10 @@ static int snd_pcm_alaw_hw_refine_cprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *
 | 
			
		|||
static int snd_pcm_alaw_hw_refine_sprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *sparams)
 | 
			
		||||
{
 | 
			
		||||
	snd_pcm_alaw_t *alaw = pcm->private;
 | 
			
		||||
	snd_pcm_access_mask_t *saccess_mask = alloca(snd_pcm_access_mask_sizeof());
 | 
			
		||||
	snd_mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
 | 
			
		||||
	snd_pcm_access_mask_t saccess_mask = { SND_PCM_ACCBIT_MMAP };
 | 
			
		||||
	_snd_pcm_hw_params_any(sparams);
 | 
			
		||||
	_snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
 | 
			
		||||
				saccess_mask);
 | 
			
		||||
				   &saccess_mask);
 | 
			
		||||
	_snd_pcm_hw_params_set_format(sparams, alaw->sformat);
 | 
			
		||||
	_snd_pcm_hw_params_set_subformat(sparams, SND_PCM_SUBFORMAT_STD);
 | 
			
		||||
	return 0;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -31,10 +31,9 @@ typedef struct {
 | 
			
		|||
static int snd_pcm_copy_hw_refine_cprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params)
 | 
			
		||||
{
 | 
			
		||||
	int err;
 | 
			
		||||
	snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof());
 | 
			
		||||
	snd_mask_load(access_mask, SND_PCM_ACCBIT_PLUGIN);
 | 
			
		||||
	snd_pcm_access_mask_t access_mask = { SND_PCM_ACCBIT_PLUGIN };
 | 
			
		||||
	err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_ACCESS,
 | 
			
		||||
					 access_mask);
 | 
			
		||||
					 &access_mask);
 | 
			
		||||
	if (err < 0)
 | 
			
		||||
		return err;
 | 
			
		||||
	params->info &= ~(SND_PCM_INFO_MMAP | SND_PCM_INFO_MMAP_VALID);
 | 
			
		||||
| 
						 | 
				
			
			@ -43,11 +42,10 @@ static int snd_pcm_copy_hw_refine_cprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_
 | 
			
		|||
 | 
			
		||||
static int snd_pcm_copy_hw_refine_sprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *sparams)
 | 
			
		||||
{
 | 
			
		||||
	snd_pcm_access_mask_t *saccess_mask = alloca(snd_pcm_access_mask_sizeof());
 | 
			
		||||
	snd_mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
 | 
			
		||||
	snd_pcm_access_mask_t saccess_mask = { SND_PCM_ACCBIT_MMAP };
 | 
			
		||||
	_snd_pcm_hw_params_any(sparams);
 | 
			
		||||
	_snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
 | 
			
		||||
			       saccess_mask);
 | 
			
		||||
				   &saccess_mask);
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -133,16 +133,14 @@ void snd_pcm_linear_convert(const snd_pcm_channel_area_t *dst_areas, snd_pcm_ufr
 | 
			
		|||
static int snd_pcm_linear_hw_refine_cprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params)
 | 
			
		||||
{
 | 
			
		||||
	int err;
 | 
			
		||||
	snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof());
 | 
			
		||||
	snd_pcm_format_mask_t *format_mask = alloca(snd_pcm_format_mask_sizeof());
 | 
			
		||||
	snd_mask_load(access_mask, SND_PCM_ACCBIT_PLUGIN);
 | 
			
		||||
	snd_mask_load(format_mask, SND_PCM_FMTBIT_LINEAR);
 | 
			
		||||
	snd_pcm_access_mask_t access_mask = { SND_PCM_ACCBIT_PLUGIN };
 | 
			
		||||
	snd_pcm_format_mask_t format_mask = { SND_PCM_FMTBIT_LINEAR };
 | 
			
		||||
	err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_ACCESS,
 | 
			
		||||
				     access_mask);
 | 
			
		||||
					 &access_mask);
 | 
			
		||||
	if (err < 0)
 | 
			
		||||
		return err;
 | 
			
		||||
	err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_FORMAT,
 | 
			
		||||
					 format_mask);
 | 
			
		||||
					 &format_mask);
 | 
			
		||||
	if (err < 0)
 | 
			
		||||
		return err;
 | 
			
		||||
	err = _snd_pcm_hw_params_set_subformat(params, SND_PCM_SUBFORMAT_STD);
 | 
			
		||||
| 
						 | 
				
			
			@ -155,11 +153,10 @@ static int snd_pcm_linear_hw_refine_cprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, sn
 | 
			
		|||
static int snd_pcm_linear_hw_refine_sprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *sparams)
 | 
			
		||||
{
 | 
			
		||||
	snd_pcm_linear_t *linear = pcm->private;
 | 
			
		||||
	snd_pcm_access_mask_t *saccess_mask = alloca(snd_pcm_access_mask_sizeof());
 | 
			
		||||
	snd_mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
 | 
			
		||||
	snd_pcm_access_mask_t saccess_mask = { SND_PCM_ACCBIT_MMAP };
 | 
			
		||||
	_snd_pcm_hw_params_any(sparams);
 | 
			
		||||
	_snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
 | 
			
		||||
			       saccess_mask);
 | 
			
		||||
				   &saccess_mask);
 | 
			
		||||
	_snd_pcm_hw_params_set_format(sparams, linear->sformat);
 | 
			
		||||
	_snd_pcm_hw_params_set_subformat(sparams, SND_PCM_SUBFORMAT_STD);
 | 
			
		||||
	return 0;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -232,17 +232,15 @@ static int snd_pcm_mulaw_hw_refine_cprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t
 | 
			
		|||
{
 | 
			
		||||
	snd_pcm_mulaw_t *mulaw = pcm->private;
 | 
			
		||||
	int err;
 | 
			
		||||
	snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof());
 | 
			
		||||
	snd_mask_load(access_mask, SND_PCM_ACCBIT_PLUGIN);
 | 
			
		||||
	snd_pcm_access_mask_t access_mask = { SND_PCM_ACCBIT_PLUGIN };
 | 
			
		||||
	err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_ACCESS,
 | 
			
		||||
				     access_mask);
 | 
			
		||||
					 &access_mask);
 | 
			
		||||
	if (err < 0)
 | 
			
		||||
		return err;
 | 
			
		||||
	if (mulaw->sformat == SND_PCM_FORMAT_MU_LAW) {
 | 
			
		||||
		snd_pcm_format_mask_t *format_mask = alloca(snd_pcm_format_mask_sizeof());
 | 
			
		||||
		snd_mask_load(format_mask, SND_PCM_FMTBIT_LINEAR);
 | 
			
		||||
		snd_pcm_format_mask_t format_mask= { SND_PCM_FMTBIT_LINEAR };
 | 
			
		||||
		err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_FORMAT,
 | 
			
		||||
					     format_mask);
 | 
			
		||||
						 &format_mask);
 | 
			
		||||
	} else {
 | 
			
		||||
		err = _snd_pcm_hw_params_set_format(params,
 | 
			
		||||
						   SND_PCM_FORMAT_MU_LAW);
 | 
			
		||||
| 
						 | 
				
			
			@ -257,11 +255,10 @@ static int snd_pcm_mulaw_hw_refine_cprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t
 | 
			
		|||
static int snd_pcm_mulaw_hw_refine_sprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *sparams)
 | 
			
		||||
{
 | 
			
		||||
	snd_pcm_mulaw_t *mulaw = pcm->private;
 | 
			
		||||
	snd_pcm_access_mask_t *saccess_mask = alloca(snd_pcm_access_mask_sizeof());
 | 
			
		||||
	snd_mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
 | 
			
		||||
	snd_pcm_access_mask_t saccess_mask = { SND_PCM_ACCBIT_MMAP };
 | 
			
		||||
	_snd_pcm_hw_params_any(sparams);
 | 
			
		||||
	_snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
 | 
			
		||||
				   saccess_mask);
 | 
			
		||||
				   &saccess_mask);
 | 
			
		||||
	_snd_pcm_hw_params_set_format(sparams, mulaw->sformat);
 | 
			
		||||
	_snd_pcm_hw_params_set_subformat(sparams, SND_PCM_SUBFORMAT_STD);
 | 
			
		||||
	return 0;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -96,12 +96,12 @@ static int snd_pcm_multi_info(snd_pcm_t *pcm, snd_pcm_info_t *info)
 | 
			
		|||
static int snd_pcm_multi_hw_refine_cprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
 | 
			
		||||
{
 | 
			
		||||
	snd_pcm_multi_t *multi = pcm->private;
 | 
			
		||||
	snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof());
 | 
			
		||||
	snd_pcm_access_mask_t access_mask;
 | 
			
		||||
	int err;
 | 
			
		||||
	snd_pcm_access_mask_any(access_mask);
 | 
			
		||||
	snd_pcm_access_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_INTERLEAVED);
 | 
			
		||||
	snd_pcm_access_mask_any(&access_mask);
 | 
			
		||||
	snd_pcm_access_mask_reset(&access_mask, SND_PCM_ACCESS_MMAP_INTERLEAVED);
 | 
			
		||||
	err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_ACCESS,
 | 
			
		||||
				     access_mask);
 | 
			
		||||
					 &access_mask);
 | 
			
		||||
	if (err < 0)
 | 
			
		||||
		return err;
 | 
			
		||||
	err = _snd_pcm_hw_param_set(params, SND_PCM_HW_PARAM_CHANNELS,
 | 
			
		||||
| 
						 | 
				
			
			@ -117,11 +117,10 @@ static int snd_pcm_multi_hw_refine_sprepare(snd_pcm_t *pcm, int slave_idx,
 | 
			
		|||
{
 | 
			
		||||
	snd_pcm_multi_t *multi = pcm->private;
 | 
			
		||||
	snd_pcm_multi_slave_t *slave = &multi->slaves[slave_idx];
 | 
			
		||||
	snd_pcm_access_mask_t *saccess_mask = alloca(snd_pcm_access_mask_sizeof());
 | 
			
		||||
	snd_mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
 | 
			
		||||
	snd_pcm_access_mask_t saccess_mask = { SND_PCM_ACCBIT_MMAP };
 | 
			
		||||
	_snd_pcm_hw_params_any(sparams);
 | 
			
		||||
	_snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
 | 
			
		||||
			       saccess_mask);
 | 
			
		||||
				   &saccess_mask);
 | 
			
		||||
	_snd_pcm_hw_param_set(sparams, SND_PCM_HW_PARAM_CHANNELS,
 | 
			
		||||
			      slave->channels_count, 0);
 | 
			
		||||
	return 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -146,11 +145,11 @@ static int snd_pcm_multi_hw_refine_schange(snd_pcm_t *pcm ATTRIBUTE_UNUSED,
 | 
			
		|||
	if (!snd_pcm_access_mask_test(access_mask, SND_PCM_ACCESS_RW_INTERLEAVED) &&
 | 
			
		||||
	    !snd_pcm_access_mask_test(access_mask, SND_PCM_ACCESS_RW_NONINTERLEAVED) &&
 | 
			
		||||
	    !snd_pcm_access_mask_test(access_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED)) {
 | 
			
		||||
		snd_pcm_access_mask_t *saccess_mask = alloca(snd_pcm_access_mask_sizeof());
 | 
			
		||||
		snd_pcm_access_mask_any(saccess_mask);
 | 
			
		||||
		snd_pcm_access_mask_reset(saccess_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED);
 | 
			
		||||
		snd_pcm_access_mask_t saccess_mask;
 | 
			
		||||
		snd_pcm_access_mask_any(&saccess_mask);
 | 
			
		||||
		snd_pcm_access_mask_reset(&saccess_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED);
 | 
			
		||||
		err = _snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
 | 
			
		||||
					     saccess_mask);
 | 
			
		||||
						 &saccess_mask);
 | 
			
		||||
		if (err < 0)
 | 
			
		||||
			return err;
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -175,17 +174,17 @@ static int snd_pcm_multi_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED,
 | 
			
		|||
			      SND_PCM_HW_PARBIT_BUFFER_SIZE |
 | 
			
		||||
			      SND_PCM_HW_PARBIT_BUFFER_TIME |
 | 
			
		||||
			      SND_PCM_HW_PARBIT_TICK_TIME);
 | 
			
		||||
	snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof());
 | 
			
		||||
	snd_pcm_access_mask_t access_mask;
 | 
			
		||||
	const snd_pcm_access_mask_t *saccess_mask = snd_pcm_hw_param_get_mask(sparams, SND_PCM_HW_PARAM_ACCESS);
 | 
			
		||||
	snd_pcm_access_mask_any(access_mask);
 | 
			
		||||
	snd_pcm_access_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_INTERLEAVED);
 | 
			
		||||
	snd_pcm_access_mask_any(&access_mask);
 | 
			
		||||
	snd_pcm_access_mask_reset(&access_mask, SND_PCM_ACCESS_MMAP_INTERLEAVED);
 | 
			
		||||
	if (!snd_pcm_access_mask_test(saccess_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED))
 | 
			
		||||
		snd_pcm_access_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED);
 | 
			
		||||
		snd_pcm_access_mask_reset(&access_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED);
 | 
			
		||||
	if (!snd_pcm_access_mask_test(saccess_mask, SND_PCM_ACCESS_MMAP_COMPLEX) &&
 | 
			
		||||
	    !snd_pcm_access_mask_test(saccess_mask, SND_PCM_ACCESS_MMAP_INTERLEAVED))
 | 
			
		||||
		snd_pcm_access_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_COMPLEX);
 | 
			
		||||
		snd_pcm_access_mask_reset(&access_mask, SND_PCM_ACCESS_MMAP_COMPLEX);
 | 
			
		||||
	err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_ACCESS,
 | 
			
		||||
				     access_mask);
 | 
			
		||||
					 &access_mask);
 | 
			
		||||
	if (err < 0)
 | 
			
		||||
		return err;
 | 
			
		||||
	err = _snd_pcm_hw_params_refine(params, links, sparams);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -116,11 +116,10 @@ static snd_pcm_format_t nonlinear_preferred_formats[] = {
 | 
			
		|||
static snd_pcm_format_t snd_pcm_plug_slave_format(snd_pcm_format_t format, const snd_pcm_format_mask_t *format_mask)
 | 
			
		||||
{
 | 
			
		||||
	int w, u, e, wid, w1, dw;
 | 
			
		||||
	snd_mask_t *lin = alloca(snd_mask_sizeof());
 | 
			
		||||
	snd_pcm_format_mask_t lin = { SND_PCM_FMTBIT_LINEAR };
 | 
			
		||||
	if (snd_pcm_format_mask_test(format_mask, format))
 | 
			
		||||
		return format;
 | 
			
		||||
	snd_mask_load(lin, SND_PCM_FMTBIT_LINEAR);
 | 
			
		||||
	if (!snd_pcm_format_mask_test(lin, format)) {
 | 
			
		||||
	if (!snd_pcm_format_mask_test(&lin, format)) {
 | 
			
		||||
		unsigned int i;
 | 
			
		||||
		switch (snd_enum_to_int(format)) {
 | 
			
		||||
		case SND_PCM_FORMAT_MU_LAW:
 | 
			
		||||
| 
						 | 
				
			
			@ -137,8 +136,8 @@ static snd_pcm_format_t snd_pcm_plug_slave_format(snd_pcm_format_t format, const
 | 
			
		|||
		}
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
	snd_mask_intersect(lin, format_mask);
 | 
			
		||||
	if (snd_mask_empty(lin)) {
 | 
			
		||||
	snd_mask_intersect(&lin, format_mask);
 | 
			
		||||
	if (snd_mask_empty(&lin)) {
 | 
			
		||||
		unsigned int i;
 | 
			
		||||
		for (i = 0; i < sizeof(nonlinear_preferred_formats) / sizeof(nonlinear_preferred_formats[0]); ++i) {
 | 
			
		||||
			snd_pcm_format_t f = nonlinear_preferred_formats[i];
 | 
			
		||||
| 
						 | 
				
			
			@ -415,7 +414,7 @@ static int snd_pcm_plug_hw_refine_schange(snd_pcm_t *pcm, snd_pcm_hw_params_t *p
 | 
			
		|||
	unsigned int links = (SND_PCM_HW_PARBIT_PERIOD_TIME |
 | 
			
		||||
			      SND_PCM_HW_PARBIT_TICK_TIME);
 | 
			
		||||
	const snd_pcm_format_mask_t *format_mask, *sformat_mask;
 | 
			
		||||
	snd_mask_t *sfmt_mask = alloca(snd_mask_sizeof());
 | 
			
		||||
	snd_pcm_format_mask_t sfmt_mask;
 | 
			
		||||
	int err;
 | 
			
		||||
	snd_pcm_format_t format;
 | 
			
		||||
	snd_interval_t t, buffer_size;
 | 
			
		||||
| 
						 | 
				
			
			@ -428,7 +427,7 @@ static int snd_pcm_plug_hw_refine_schange(snd_pcm_t *pcm, snd_pcm_hw_params_t *p
 | 
			
		|||
						   SND_PCM_HW_PARAM_FORMAT);
 | 
			
		||||
	sformat_mask = snd_pcm_hw_param_get_mask(sparams,
 | 
			
		||||
						    SND_PCM_HW_PARAM_FORMAT);
 | 
			
		||||
	snd_mask_none(sfmt_mask);
 | 
			
		||||
	snd_mask_none(&sfmt_mask);
 | 
			
		||||
	for (format = 0; format <= SND_PCM_FORMAT_LAST; snd_enum_incr(format)) {
 | 
			
		||||
		snd_pcm_format_t f;
 | 
			
		||||
		if (!snd_pcm_format_mask_test(format_mask, format))
 | 
			
		||||
| 
						 | 
				
			
			@ -440,21 +439,20 @@ static int snd_pcm_plug_hw_refine_schange(snd_pcm_t *pcm, snd_pcm_hw_params_t *p
 | 
			
		|||
			if (f == SND_PCM_FORMAT_NONE)
 | 
			
		||||
				continue;
 | 
			
		||||
		}
 | 
			
		||||
		snd_pcm_format_mask_set(sfmt_mask, f);
 | 
			
		||||
		snd_pcm_format_mask_set(&sfmt_mask, f);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	err = snd_pcm_hw_param_set_mask(slave, sparams, SND_CHANGE,
 | 
			
		||||
					SND_PCM_HW_PARAM_FORMAT, sfmt_mask);
 | 
			
		||||
					SND_PCM_HW_PARAM_FORMAT, &sfmt_mask);
 | 
			
		||||
	assert(err >= 0);
 | 
			
		||||
 | 
			
		||||
	if (snd_pcm_hw_param_never_eq(params, SND_PCM_HW_PARAM_FORMAT, sparams) ||
 | 
			
		||||
	    snd_pcm_hw_param_never_eq(params, SND_PCM_HW_PARAM_CHANNELS, sparams) ||
 | 
			
		||||
	    snd_pcm_hw_param_never_eq(params, SND_PCM_HW_PARAM_RATE, sparams) ||
 | 
			
		||||
	    snd_pcm_hw_param_never_eq(params, SND_PCM_HW_PARAM_ACCESS, sparams)) {
 | 
			
		||||
		snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof());
 | 
			
		||||
		snd_mask_load(access_mask, SND_PCM_ACCBIT_MMAP);
 | 
			
		||||
		snd_pcm_access_mask_t access_mask = { SND_PCM_ACCBIT_MMAP };
 | 
			
		||||
		_snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
 | 
			
		||||
				       access_mask);
 | 
			
		||||
					   &access_mask);
 | 
			
		||||
	}
 | 
			
		||||
	snd_interval_copy(&buffer_size, snd_pcm_hw_param_get_interval(params, SND_PCM_HW_PARAM_BUFFER_SIZE));
 | 
			
		||||
	snd_interval_unfloor(&buffer_size);
 | 
			
		||||
| 
						 | 
				
			
			@ -477,7 +475,7 @@ static int snd_pcm_plug_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED,
 | 
			
		|||
	unsigned int links = (SND_PCM_HW_PARBIT_PERIOD_TIME |
 | 
			
		||||
			      SND_PCM_HW_PARBIT_TICK_TIME);
 | 
			
		||||
	const snd_pcm_format_mask_t *format_mask, *sformat_mask;
 | 
			
		||||
	snd_mask_t *fmt_mask = alloca(snd_mask_sizeof());
 | 
			
		||||
	snd_pcm_format_mask_t fmt_mask;
 | 
			
		||||
	int err;
 | 
			
		||||
	snd_pcm_format_t format;
 | 
			
		||||
	snd_interval_t t;
 | 
			
		||||
| 
						 | 
				
			
			@ -489,7 +487,7 @@ static int snd_pcm_plug_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED,
 | 
			
		|||
						   SND_PCM_HW_PARAM_FORMAT);
 | 
			
		||||
	sformat_mask = snd_pcm_hw_param_get_mask(sparams,
 | 
			
		||||
						    SND_PCM_HW_PARAM_FORMAT);
 | 
			
		||||
	snd_mask_none(fmt_mask);
 | 
			
		||||
	snd_mask_none(&fmt_mask);
 | 
			
		||||
	for (format = 0; format <= SND_PCM_FORMAT_LAST; snd_enum_incr(format)) {
 | 
			
		||||
		snd_pcm_format_t f;
 | 
			
		||||
		if (!snd_pcm_format_mask_test(format_mask, format))
 | 
			
		||||
| 
						 | 
				
			
			@ -501,11 +499,11 @@ static int snd_pcm_plug_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED,
 | 
			
		|||
			if (f == SND_PCM_FORMAT_NONE)
 | 
			
		||||
				continue;
 | 
			
		||||
		}
 | 
			
		||||
		snd_pcm_format_mask_set(fmt_mask, format);
 | 
			
		||||
		snd_pcm_format_mask_set(&fmt_mask, format);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	err = _snd_pcm_hw_param_set_mask(params, 
 | 
			
		||||
				     SND_PCM_HW_PARAM_FORMAT, fmt_mask);
 | 
			
		||||
					 SND_PCM_HW_PARAM_FORMAT, &fmt_mask);
 | 
			
		||||
	if (err < 0)
 | 
			
		||||
		return err;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -226,16 +226,14 @@ snd_pcm_uframes_t snd_pcm_rate_shrink(const snd_pcm_channel_area_t *dst_areas,
 | 
			
		|||
static int snd_pcm_rate_hw_refine_cprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params)
 | 
			
		||||
{
 | 
			
		||||
	int err;
 | 
			
		||||
	snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof());
 | 
			
		||||
	snd_pcm_format_mask_t *format_mask = alloca(snd_pcm_format_mask_sizeof());
 | 
			
		||||
	snd_mask_load(access_mask, SND_PCM_ACCBIT_PLUGIN);
 | 
			
		||||
	snd_mask_load(format_mask, SND_PCM_FMTBIT_LINEAR);
 | 
			
		||||
	snd_pcm_access_mask_t access_mask = { SND_PCM_ACCBIT_PLUGIN };
 | 
			
		||||
	snd_pcm_format_mask_t format_mask = { SND_PCM_FMTBIT_LINEAR };
 | 
			
		||||
	err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_ACCESS,
 | 
			
		||||
				     access_mask);
 | 
			
		||||
					 &access_mask);
 | 
			
		||||
	if (err < 0)
 | 
			
		||||
		return err;
 | 
			
		||||
	err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_FORMAT,
 | 
			
		||||
				     format_mask);
 | 
			
		||||
					 &format_mask);
 | 
			
		||||
	if (err < 0)
 | 
			
		||||
		return err;
 | 
			
		||||
	err = _snd_pcm_hw_params_set_subformat(params, SND_PCM_SUBFORMAT_STD);
 | 
			
		||||
| 
						 | 
				
			
			@ -256,11 +254,10 @@ static int snd_pcm_rate_hw_refine_cprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_
 | 
			
		|||
static int snd_pcm_rate_hw_refine_sprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *sparams)
 | 
			
		||||
{
 | 
			
		||||
	snd_pcm_rate_t *rate = pcm->private;
 | 
			
		||||
	snd_pcm_access_mask_t *saccess_mask = alloca(snd_pcm_access_mask_sizeof());
 | 
			
		||||
	snd_mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
 | 
			
		||||
	snd_pcm_access_mask_t saccess_mask = { SND_PCM_ACCBIT_MMAP };
 | 
			
		||||
	_snd_pcm_hw_params_any(sparams);
 | 
			
		||||
	_snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
 | 
			
		||||
				saccess_mask);
 | 
			
		||||
				   &saccess_mask);
 | 
			
		||||
	if (rate->sformat != SND_PCM_FORMAT_NONE) {
 | 
			
		||||
		_snd_pcm_hw_params_set_format(sparams, rate->sformat);
 | 
			
		||||
		_snd_pcm_hw_params_set_subformat(sparams, SND_PCM_SUBFORMAT_STD);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -438,16 +438,14 @@ static int snd_pcm_route_close(snd_pcm_t *pcm)
 | 
			
		|||
static int snd_pcm_route_hw_refine_cprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params)
 | 
			
		||||
{
 | 
			
		||||
	int err;
 | 
			
		||||
	snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof());
 | 
			
		||||
	snd_pcm_format_mask_t *format_mask = alloca(snd_pcm_format_mask_sizeof());
 | 
			
		||||
	snd_mask_load(access_mask, SND_PCM_ACCBIT_PLUGIN);
 | 
			
		||||
	snd_mask_load(format_mask, SND_PCM_FMTBIT_LINEAR);
 | 
			
		||||
	snd_pcm_access_mask_t access_mask = { SND_PCM_ACCBIT_PLUGIN };
 | 
			
		||||
	snd_pcm_format_mask_t format_mask = { SND_PCM_FMTBIT_LINEAR };
 | 
			
		||||
	err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_ACCESS,
 | 
			
		||||
				     access_mask);
 | 
			
		||||
					 &access_mask);
 | 
			
		||||
	if (err < 0)
 | 
			
		||||
		return err;
 | 
			
		||||
	err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_FORMAT,
 | 
			
		||||
				     format_mask);
 | 
			
		||||
					 &format_mask);
 | 
			
		||||
	if (err < 0)
 | 
			
		||||
		return err;
 | 
			
		||||
	err = _snd_pcm_hw_params_set_subformat(params, SND_PCM_SUBFORMAT_STD);
 | 
			
		||||
| 
						 | 
				
			
			@ -463,11 +461,10 @@ static int snd_pcm_route_hw_refine_cprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd
 | 
			
		|||
static int snd_pcm_route_hw_refine_sprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *sparams)
 | 
			
		||||
{
 | 
			
		||||
	snd_pcm_route_t *route = pcm->private;
 | 
			
		||||
	snd_pcm_access_mask_t *saccess_mask = alloca(snd_pcm_access_mask_sizeof());
 | 
			
		||||
	snd_mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
 | 
			
		||||
	snd_pcm_access_mask_t saccess_mask = { SND_PCM_ACCBIT_MMAP };
 | 
			
		||||
	_snd_pcm_hw_params_any(sparams);
 | 
			
		||||
	_snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
 | 
			
		||||
				saccess_mask);
 | 
			
		||||
				   &saccess_mask);
 | 
			
		||||
	if (route->sformat != SND_PCM_FORMAT_NONE) {
 | 
			
		||||
		_snd_pcm_hw_params_set_format(sparams, route->sformat);
 | 
			
		||||
		_snd_pcm_hw_params_set_subformat(sparams, SND_PCM_SUBFORMAT_STD);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -457,12 +457,12 @@ static int snd_pcm_share_hw_refine_cprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t
 | 
			
		|||
{
 | 
			
		||||
	snd_pcm_share_t *share = pcm->private;
 | 
			
		||||
	snd_pcm_share_slave_t *slave = share->slave;
 | 
			
		||||
	snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof());
 | 
			
		||||
	snd_pcm_access_mask_t access_mask;
 | 
			
		||||
	int err;
 | 
			
		||||
	snd_pcm_access_mask_any(access_mask);
 | 
			
		||||
	snd_pcm_access_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_INTERLEAVED);
 | 
			
		||||
	snd_pcm_access_mask_any(&access_mask);
 | 
			
		||||
	snd_pcm_access_mask_reset(&access_mask, SND_PCM_ACCESS_MMAP_INTERLEAVED);
 | 
			
		||||
	err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_ACCESS,
 | 
			
		||||
				     access_mask);
 | 
			
		||||
					 &access_mask);
 | 
			
		||||
	if (err < 0)
 | 
			
		||||
		return err;
 | 
			
		||||
	err = _snd_pcm_hw_param_set(params, SND_PCM_HW_PARAM_CHANNELS,
 | 
			
		||||
| 
						 | 
				
			
			@ -489,11 +489,10 @@ static int snd_pcm_share_hw_refine_sprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t
 | 
			
		|||
{
 | 
			
		||||
	snd_pcm_share_t *share = pcm->private;
 | 
			
		||||
	snd_pcm_share_slave_t *slave = share->slave;
 | 
			
		||||
	snd_pcm_access_mask_t *saccess_mask = alloca(snd_pcm_access_mask_sizeof());
 | 
			
		||||
	snd_mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
 | 
			
		||||
	snd_pcm_access_mask_t saccess_mask = { SND_PCM_ACCBIT_MMAP };
 | 
			
		||||
	_snd_pcm_hw_params_any(sparams);
 | 
			
		||||
	_snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
 | 
			
		||||
			       saccess_mask);
 | 
			
		||||
				   &saccess_mask);
 | 
			
		||||
	_snd_pcm_hw_param_set(sparams, SND_PCM_HW_PARAM_CHANNELS,
 | 
			
		||||
			      slave->channels_count, 0);
 | 
			
		||||
	return 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -516,11 +515,11 @@ static int snd_pcm_share_hw_refine_schange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_
 | 
			
		|||
	if (!snd_pcm_access_mask_test(access_mask, SND_PCM_ACCESS_RW_INTERLEAVED) &&
 | 
			
		||||
	    !snd_pcm_access_mask_test(access_mask, SND_PCM_ACCESS_RW_NONINTERLEAVED) &&
 | 
			
		||||
	    !snd_pcm_access_mask_test(access_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED)) {
 | 
			
		||||
		snd_pcm_access_mask_t *saccess_mask = alloca(snd_pcm_access_mask_sizeof());
 | 
			
		||||
		snd_pcm_access_mask_any(saccess_mask);
 | 
			
		||||
		snd_pcm_access_mask_reset(saccess_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED);
 | 
			
		||||
		snd_pcm_access_mask_t saccess_mask;
 | 
			
		||||
		snd_pcm_access_mask_any(&saccess_mask);
 | 
			
		||||
		snd_pcm_access_mask_reset(&saccess_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED);
 | 
			
		||||
		err = _snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
 | 
			
		||||
					     saccess_mask);
 | 
			
		||||
						 &saccess_mask);
 | 
			
		||||
		if (err < 0)
 | 
			
		||||
			return err;
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -543,17 +542,17 @@ static int snd_pcm_share_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_
 | 
			
		|||
			      SND_PCM_HW_PARBIT_BUFFER_TIME |
 | 
			
		||||
			      SND_PCM_HW_PARBIT_PERIODS |
 | 
			
		||||
			      SND_PCM_HW_PARBIT_TICK_TIME);
 | 
			
		||||
	snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof());
 | 
			
		||||
	snd_pcm_access_mask_t access_mask;
 | 
			
		||||
	const snd_pcm_access_mask_t *saccess_mask = snd_pcm_hw_param_get_mask(sparams, SND_PCM_HW_PARAM_ACCESS);
 | 
			
		||||
	snd_pcm_access_mask_any(access_mask);
 | 
			
		||||
	snd_pcm_access_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_INTERLEAVED);
 | 
			
		||||
	snd_pcm_access_mask_any(&access_mask);
 | 
			
		||||
	snd_pcm_access_mask_reset(&access_mask, SND_PCM_ACCESS_MMAP_INTERLEAVED);
 | 
			
		||||
	if (!snd_pcm_access_mask_test(saccess_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED))
 | 
			
		||||
		snd_pcm_access_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED);
 | 
			
		||||
		snd_pcm_access_mask_reset(&access_mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED);
 | 
			
		||||
	if (!snd_pcm_access_mask_test(saccess_mask, SND_PCM_ACCESS_MMAP_COMPLEX) &&
 | 
			
		||||
	    !snd_pcm_access_mask_test(saccess_mask, SND_PCM_ACCESS_MMAP_INTERLEAVED))
 | 
			
		||||
		snd_pcm_access_mask_reset(access_mask, SND_PCM_ACCESS_MMAP_COMPLEX);
 | 
			
		||||
		snd_pcm_access_mask_reset(&access_mask, SND_PCM_ACCESS_MMAP_COMPLEX);
 | 
			
		||||
	err = _snd_pcm_hw_param_set_mask(params, SND_PCM_HW_PARAM_ACCESS,
 | 
			
		||||
				     access_mask);
 | 
			
		||||
					 &access_mask);
 | 
			
		||||
	if (err < 0)
 | 
			
		||||
		return err;
 | 
			
		||||
	err = _snd_pcm_hw_params_refine(params, links, sparams);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -154,11 +154,10 @@ static int snd_pcm_shm_hw_refine_cprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_p
 | 
			
		|||
 | 
			
		||||
static int snd_pcm_shm_hw_refine_sprepare(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *sparams)
 | 
			
		||||
{
 | 
			
		||||
	snd_pcm_access_mask_t *saccess_mask = alloca(snd_pcm_access_mask_sizeof());
 | 
			
		||||
	snd_mask_load(saccess_mask, SND_PCM_ACCBIT_MMAP);
 | 
			
		||||
	snd_pcm_access_mask_t saccess_mask = { SND_PCM_ACCBIT_MMAP };
 | 
			
		||||
	_snd_pcm_hw_params_any(sparams);
 | 
			
		||||
	_snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
 | 
			
		||||
			       saccess_mask);
 | 
			
		||||
				   &saccess_mask);
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -186,12 +185,12 @@ static int snd_pcm_shm_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pc
 | 
			
		|||
{
 | 
			
		||||
	int err;
 | 
			
		||||
	unsigned int links = ~SND_PCM_HW_PARBIT_ACCESS;
 | 
			
		||||
	snd_pcm_access_mask_t *access_mask = alloca(snd_pcm_access_mask_sizeof());
 | 
			
		||||
	snd_mask_copy(access_mask, snd_pcm_hw_param_get_mask(sparams, SND_PCM_HW_PARAM_ACCESS));
 | 
			
		||||
	snd_pcm_access_mask_set(access_mask, SND_PCM_ACCESS_RW_INTERLEAVED);
 | 
			
		||||
	snd_pcm_access_mask_set(access_mask, SND_PCM_ACCESS_RW_NONINTERLEAVED);
 | 
			
		||||
	snd_pcm_access_mask_t access_mask;
 | 
			
		||||
	snd_mask_copy(&access_mask, snd_pcm_hw_param_get_mask(sparams, SND_PCM_HW_PARAM_ACCESS));
 | 
			
		||||
	snd_pcm_access_mask_set(&access_mask, SND_PCM_ACCESS_RW_INTERLEAVED);
 | 
			
		||||
	snd_pcm_access_mask_set(&access_mask, SND_PCM_ACCESS_RW_NONINTERLEAVED);
 | 
			
		||||
	err = _snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
 | 
			
		||||
				     access_mask);
 | 
			
		||||
					 &access_mask);
 | 
			
		||||
	if (err < 0)
 | 
			
		||||
		return err;
 | 
			
		||||
	err = _snd_pcm_hw_params_refine(params, links, sparams);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -26,6 +26,7 @@
 | 
			
		|||
#include <string.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <dlfcn.h>
 | 
			
		||||
#include <asm/page.h>
 | 
			
		||||
#include "rawmidi_local.h"
 | 
			
		||||
 | 
			
		||||
static inline int snd_rawmidi_stream_ok(snd_rawmidi_t *rmidi, snd_rawmidi_stream_t stream)
 | 
			
		||||
| 
						 | 
				
			
			@ -85,10 +86,19 @@ int snd_rawmidi_params(snd_rawmidi_t *rmidi,
 | 
			
		|||
		       snd_rawmidi_stream_t stream,
 | 
			
		||||
		       snd_rawmidi_params_t * params)
 | 
			
		||||
{
 | 
			
		||||
	int err;
 | 
			
		||||
	snd_rawmidi_str_t *pstr;
 | 
			
		||||
	assert(snd_rawmidi_stream_ok(rmidi, stream));
 | 
			
		||||
	assert(params);
 | 
			
		||||
	params->stream = snd_enum_to_int(stream);
 | 
			
		||||
	return rmidi->ops->params(rmidi, params);
 | 
			
		||||
	err = rmidi->ops->params(rmidi, params);
 | 
			
		||||
	if (err < 0)
 | 
			
		||||
		return err;
 | 
			
		||||
	pstr = &rmidi->stream[snd_enum_to_int(stream)];
 | 
			
		||||
	pstr->buffer_size = params->buffer_size;
 | 
			
		||||
	pstr->avail_min = params->avail_min;
 | 
			
		||||
	pstr->no_active_sensing = params->no_active_sensing;
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int snd_rawmidi_status(snd_rawmidi_t *rmidi,
 | 
			
		||||
| 
						 | 
				
			
			@ -127,6 +137,28 @@ ssize_t snd_rawmidi_read(snd_rawmidi_t *rmidi, void *buffer, size_t size)
 | 
			
		|||
	return rmidi->ops->read(rmidi, buffer, size);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int snd_rawmidi_params_current(snd_rawmidi_t *rmidi, snd_rawmidi_stream_t stream, snd_rawmidi_params_t *params)
 | 
			
		||||
{
 | 
			
		||||
	snd_rawmidi_str_t *pstr;
 | 
			
		||||
	assert(snd_rawmidi_stream_ok(rmidi, SND_RAWMIDI_STREAM_OUTPUT));
 | 
			
		||||
	assert(params);
 | 
			
		||||
	pstr = &rmidi->stream[snd_enum_to_int(stream)];
 | 
			
		||||
	params->buffer_size = pstr->buffer_size;
 | 
			
		||||
	params->avail_min = pstr->avail_min;
 | 
			
		||||
	params->no_active_sensing = pstr->no_active_sensing;
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int snd_rawmidi_params_default(snd_rawmidi_t *rmidi, snd_rawmidi_stream_t stream, snd_rawmidi_params_t *params)
 | 
			
		||||
{
 | 
			
		||||
	assert(snd_rawmidi_stream_ok(rmidi, SND_RAWMIDI_STREAM_OUTPUT));
 | 
			
		||||
	assert(params);
 | 
			
		||||
	params->buffer_size = PAGE_SIZE;
 | 
			
		||||
	params->avail_min = 1;
 | 
			
		||||
	params->no_active_sensing = 0;
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int snd_rawmidi_open(snd_rawmidi_t **rawmidip, char *name, 
 | 
			
		||||
		     int streams, int mode)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -134,6 +166,8 @@ int snd_rawmidi_open(snd_rawmidi_t **rawmidip, char *name,
 | 
			
		|||
	int err;
 | 
			
		||||
	snd_config_t *rawmidi_conf, *conf, *type_conf;
 | 
			
		||||
	snd_config_iterator_t i;
 | 
			
		||||
	snd_rawmidi_params_t params;
 | 
			
		||||
	unsigned int stream;
 | 
			
		||||
	char *lib = NULL, *open = NULL;
 | 
			
		||||
	int (*open_func)(snd_rawmidi_t **rawmidip, char *name, snd_config_t *conf, 
 | 
			
		||||
			 int streams, int mode);
 | 
			
		||||
| 
						 | 
				
			
			@ -234,6 +268,16 @@ int snd_rawmidi_open(snd_rawmidi_t **rawmidip, char *name,
 | 
			
		|||
		ERR("symbol %s is not defined inside %s", open, lib);
 | 
			
		||||
		return -ENXIO;
 | 
			
		||||
	}
 | 
			
		||||
	return open_func(rawmidip, name, rawmidi_conf, streams, mode);
 | 
			
		||||
	err = open_func(rawmidip, name, rawmidi_conf, streams, mode);
 | 
			
		||||
	if (err < 0)
 | 
			
		||||
		return err;
 | 
			
		||||
	for (stream = 0; stream < 2; stream++) {
 | 
			
		||||
		if (!(streams & (1 << stream)))
 | 
			
		||||
			continue;
 | 
			
		||||
		snd_rawmidi_params_default(*rawmidip, snd_int_to_enum(stream), ¶ms);
 | 
			
		||||
		err = snd_rawmidi_params(*rawmidip, snd_int_to_enum(stream), ¶ms);
 | 
			
		||||
		assert(err >= 0);
 | 
			
		||||
	}
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -38,13 +38,21 @@ typedef struct {
 | 
			
		|||
	ssize_t (*read)(snd_rawmidi_t *rawmidi, void *buffer, size_t size);
 | 
			
		||||
} snd_rawmidi_ops_t;
 | 
			
		||||
 | 
			
		||||
typedef struct _snd_rawmidi_str {
 | 
			
		||||
	size_t buffer_size;
 | 
			
		||||
	size_t avail_min;
 | 
			
		||||
	unsigned int no_active_sensing: 1;
 | 
			
		||||
} snd_rawmidi_str_t;
 | 
			
		||||
 | 
			
		||||
struct _snd_rawmidi {
 | 
			
		||||
	char *name;
 | 
			
		||||
	snd_rawmidi_type_t type;
 | 
			
		||||
	int streams;
 | 
			
		||||
	int mode;
 | 
			
		||||
	int poll_fd;
 | 
			
		||||
	snd_rawmidi_str_t stream[2];
 | 
			
		||||
	snd_rawmidi_ops_t *ops;
 | 
			
		||||
  
 | 
			
		||||
	void *private;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue