mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	alsa: Probe sink/source sample rates
This probes sink and source sample rates and uses this information to validate rate changes and check incoming passthrough formats.
This commit is contained in:
		
							parent
							
								
									3555634e6e
								
							
						
					
					
						commit
						e67440e220
					
				
					 4 changed files with 107 additions and 5 deletions
				
			
		| 
						 | 
				
			
			@ -1327,6 +1327,42 @@ char *pa_alsa_get_reserve_name(const char *device) {
 | 
			
		|||
    return pa_sprintf_malloc("Audio%i", i);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
unsigned int *pa_alsa_get_supported_rates(snd_pcm_t *pcm) {
 | 
			
		||||
    static unsigned int all_rates[] = { 8000, 11025, 16000, 22050, 32000, 44100, 48000, 88200, 96000, 176400, 192000, 384000 };
 | 
			
		||||
    pa_bool_t supported[PA_ELEMENTSOF(all_rates)] = { FALSE, };
 | 
			
		||||
    snd_pcm_hw_params_t *hwparams;
 | 
			
		||||
    unsigned int i, j, n, *rates = NULL;
 | 
			
		||||
    int ret;
 | 
			
		||||
 | 
			
		||||
    snd_pcm_hw_params_alloca(&hwparams);
 | 
			
		||||
 | 
			
		||||
    if ((ret = snd_pcm_hw_params_any(pcm, hwparams)) < 0) {
 | 
			
		||||
        pa_log_debug("snd_pcm_hw_params_any() failed: %s", pa_alsa_strerror(ret));
 | 
			
		||||
        return NULL;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    for (i = 0, n = 0; i < PA_ELEMENTSOF(all_rates); i++) {
 | 
			
		||||
        if (snd_pcm_hw_params_test_rate(pcm, hwparams, all_rates[i], 0) == 0) {
 | 
			
		||||
            supported[i] = TRUE;
 | 
			
		||||
            n++;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (n == 0)
 | 
			
		||||
        return NULL;
 | 
			
		||||
 | 
			
		||||
    rates = pa_xnew(unsigned int, n + 1);
 | 
			
		||||
 | 
			
		||||
    for (i = 0, j = 0; i < PA_ELEMENTSOF(all_rates); i++) {
 | 
			
		||||
        if (supported[i])
 | 
			
		||||
            rates[j++] = all_rates[i];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    rates[j] = 0;
 | 
			
		||||
 | 
			
		||||
    return rates;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pa_bool_t pa_alsa_pcm_is_hw(snd_pcm_t *pcm) {
 | 
			
		||||
    snd_pcm_info_t* info;
 | 
			
		||||
    snd_pcm_info_alloca(&info);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue