mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	initialize properties for ALSA sinks/sources more elaborately, re #277
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/glitch-free@2287 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
		
							parent
							
								
									c2c833c068
								
							
						
					
					
						commit
						8181db182b
					
				
					 4 changed files with 78 additions and 26 deletions
				
			
		| 
						 | 
				
			
			@ -973,3 +973,76 @@ void pa_alsa_redirect_errors_dec(void) {
 | 
			
		|||
    if (r == 1)
 | 
			
		||||
        snd_lib_error_set_handler(NULL);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void pa_alsa_init_proplist(pa_proplist *p, snd_pcm_info_t *pcm_info) {
 | 
			
		||||
 | 
			
		||||
    static const char * const alsa_class_table[SND_PCM_CLASS_LAST+1] = {
 | 
			
		||||
        [SND_PCM_CLASS_GENERIC] = "generic",
 | 
			
		||||
        [SND_PCM_CLASS_MULTI] = "multi",
 | 
			
		||||
        [SND_PCM_CLASS_MODEM] = "modem",
 | 
			
		||||
        [SND_PCM_CLASS_DIGITIZER] = "digitizer"
 | 
			
		||||
    };
 | 
			
		||||
    static const char * const class_table[SND_PCM_CLASS_LAST+1] = {
 | 
			
		||||
        [SND_PCM_CLASS_GENERIC] = "sound",
 | 
			
		||||
        [SND_PCM_CLASS_MULTI] = NULL,
 | 
			
		||||
        [SND_PCM_CLASS_MODEM] = "modem",
 | 
			
		||||
        [SND_PCM_CLASS_DIGITIZER] = NULL
 | 
			
		||||
    };
 | 
			
		||||
    static const char * const alsa_subclass_table[SND_PCM_SUBCLASS_LAST+1] = {
 | 
			
		||||
        [SND_PCM_SUBCLASS_GENERIC_MIX] = "generic-mix",
 | 
			
		||||
        [SND_PCM_SUBCLASS_MULTI_MIX] = "multi-mix"
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    snd_pcm_class_t class;
 | 
			
		||||
    snd_pcm_subclass_t subclass;
 | 
			
		||||
    const char *n, *id, *sdn;
 | 
			
		||||
    char *cn = NULL, *lcn = NULL;
 | 
			
		||||
    int card;
 | 
			
		||||
 | 
			
		||||
    pa_assert(p);
 | 
			
		||||
    pa_assert(pcm_info);
 | 
			
		||||
 | 
			
		||||
    pa_proplist_sets(p, PA_PROP_DEVICE_API, "alsa");
 | 
			
		||||
 | 
			
		||||
    class = snd_pcm_info_get_class(pcm_info);
 | 
			
		||||
    if (class <= SND_PCM_CLASS_LAST) {
 | 
			
		||||
        if (class_table[class])
 | 
			
		||||
            pa_proplist_sets(p, PA_PROP_DEVICE_CLASS, class_table[class]);
 | 
			
		||||
        if (alsa_class_table[class])
 | 
			
		||||
            pa_proplist_sets(p, "alsa.class", alsa_class_table[class]);
 | 
			
		||||
    }
 | 
			
		||||
    subclass = snd_pcm_info_get_subclass(pcm_info);
 | 
			
		||||
    if (subclass <= SND_PCM_SUBCLASS_LAST)
 | 
			
		||||
        if (alsa_subclass_table[subclass])
 | 
			
		||||
            pa_proplist_sets(p, "alsa.subclass", alsa_subclass_table[subclass]);
 | 
			
		||||
 | 
			
		||||
    if ((n = snd_pcm_info_get_name(pcm_info)))
 | 
			
		||||
        pa_proplist_sets(p, "alsa.name", n);
 | 
			
		||||
 | 
			
		||||
    if ((id = snd_pcm_info_get_id(pcm_info)))
 | 
			
		||||
        pa_proplist_sets(p, "alsa.id", id);
 | 
			
		||||
 | 
			
		||||
    pa_proplist_setf(p, "alsa.subdevice", "%u", snd_pcm_info_get_subdevice(pcm_info));
 | 
			
		||||
    if ((sdn = snd_pcm_info_get_subdevice_name(pcm_info)))
 | 
			
		||||
        pa_proplist_sets(p, "alsa.subdevice_name", sdn);
 | 
			
		||||
 | 
			
		||||
    pa_proplist_setf(p, "alsa.device", "%u", snd_pcm_info_get_device(pcm_info));
 | 
			
		||||
 | 
			
		||||
    if ((card = snd_pcm_info_get_card(pcm_info)) >= 0) {
 | 
			
		||||
        pa_proplist_setf(p, "card", "%i", card);
 | 
			
		||||
 | 
			
		||||
        if (snd_card_get_name(card, &cn) >= 0)
 | 
			
		||||
            pa_proplist_sets(p, "alsa.card_name", cn);
 | 
			
		||||
 | 
			
		||||
        if (snd_card_get_longname(card, &lcn) >= 0)
 | 
			
		||||
            pa_proplist_sets(p, "alsa.long_card_name", lcn);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (cn && n)
 | 
			
		||||
        pa_proplist_setf(p, PA_PROP_DEVICE_DESCRIPTION, "%s - %s", cn, n);
 | 
			
		||||
    else if (cn)
 | 
			
		||||
        pa_proplist_sets(p, PA_PROP_DEVICE_DESCRIPTION, cn);
 | 
			
		||||
    else if (n)
 | 
			
		||||
        pa_proplist_sets(p, PA_PROP_DEVICE_DESCRIPTION, n);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -29,8 +29,8 @@
 | 
			
		|||
 | 
			
		||||
#include <pulse/sample.h>
 | 
			
		||||
#include <pulse/mainloop-api.h>
 | 
			
		||||
 | 
			
		||||
#include <pulse/channelmap.h>
 | 
			
		||||
#include <pulse/proplist.h>
 | 
			
		||||
 | 
			
		||||
typedef struct pa_alsa_fdlist pa_alsa_fdlist;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -88,5 +88,6 @@ void pa_alsa_dump_status(snd_pcm_t *pcm);
 | 
			
		|||
void pa_alsa_redirect_errors_inc(void);
 | 
			
		||||
void pa_alsa_redirect_errors_dec(void);
 | 
			
		||||
 | 
			
		||||
void pa_alsa_init_proplist(pa_proplist *p, snd_pcm_info_t *pcm_info);
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -93,7 +93,7 @@ static const char* const valid_modargs[] = {
 | 
			
		|||
 | 
			
		||||
#define DEFAULT_DEVICE "default"
 | 
			
		||||
#define DEFAULT_TSCHED_BUFFER_USEC (10*PA_USEC_PER_SEC)           /* 10s */
 | 
			
		||||
#define DEFAULT_TSCHED_WATERMARK_USEC (200*PA_USEC_PER_MSEC)       /* 20ms */
 | 
			
		||||
#define DEFAULT_TSCHED_WATERMARK_USEC (10*PA_USEC_PER_MSEC)       /* 20ms */
 | 
			
		||||
 | 
			
		||||
struct userdata {
 | 
			
		||||
    pa_core *core;
 | 
			
		||||
| 
						 | 
				
			
			@ -1050,12 +1050,6 @@ int pa__init(pa_module*m) {
 | 
			
		|||
    pa_bool_t use_mmap = TRUE, b, use_tsched = TRUE, d, mixer_reset = TRUE;
 | 
			
		||||
    pa_usec_t usec;
 | 
			
		||||
    pa_sink_new_data data;
 | 
			
		||||
    static const char * const class_table[SND_PCM_CLASS_LAST+1] = {
 | 
			
		||||
        [SND_PCM_CLASS_GENERIC] = "sound",
 | 
			
		||||
        [SND_PCM_CLASS_MULTI] = NULL,
 | 
			
		||||
        [SND_PCM_CLASS_MODEM] = "modem",
 | 
			
		||||
        [SND_PCM_CLASS_DIGITIZER] = NULL
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    snd_pcm_info_alloca(&pcm_info);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1242,15 +1236,10 @@ int pa__init(pa_module*m) {
 | 
			
		|||
    pa_sink_new_data_set_sample_spec(&data, &ss);
 | 
			
		||||
    pa_sink_new_data_set_channel_map(&data, &map);
 | 
			
		||||
 | 
			
		||||
    pa_alsa_init_proplist(data.proplist, pcm_info);
 | 
			
		||||
    pa_proplist_sets(data.proplist, PA_PROP_DEVICE_STRING, u->device_name);
 | 
			
		||||
    pa_proplist_sets(data.proplist, PA_PROP_DEVICE_API, "alsa");
 | 
			
		||||
    pa_proplist_sets(data.proplist, PA_PROP_DEVICE_DESCRIPTION, snd_pcm_info_get_name(pcm_info));
 | 
			
		||||
    pa_proplist_setf(data.proplist, PA_PROP_DEVICE_BUFFERING_BUFFER_SIZE, "%lu", (unsigned long) (period_frames * frame_size * nfrags));
 | 
			
		||||
    pa_proplist_setf(data.proplist, PA_PROP_DEVICE_BUFFERING_FRAGMENT_SIZE, "%lu", (unsigned long) (period_frames * frame_size));
 | 
			
		||||
 | 
			
		||||
    if (class_table[snd_pcm_info_get_class(pcm_info)])
 | 
			
		||||
        pa_proplist_sets(data.proplist, PA_PROP_DEVICE_CLASS, class_table[snd_pcm_info_get_class(pcm_info)]);
 | 
			
		||||
 | 
			
		||||
    pa_proplist_sets(data.proplist, PA_PROP_DEVICE_ACCESS_MODE, u->use_tsched ? "mmap+timer" : (u->use_mmap ? "mmap" : "serial"));
 | 
			
		||||
 | 
			
		||||
    u->sink = pa_sink_new(m->core, &data, PA_SINK_HARDWARE|PA_SINK_LATENCY);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -880,12 +880,6 @@ int pa__init(pa_module*m) {
 | 
			
		|||
    pa_bool_t namereg_fail;
 | 
			
		||||
    pa_bool_t use_mmap = TRUE, b, use_tsched = TRUE, d, mixer_reset = TRUE;
 | 
			
		||||
    pa_source_new_data data;
 | 
			
		||||
    static const char * const class_table[SND_PCM_CLASS_LAST+1] = {
 | 
			
		||||
        [SND_PCM_CLASS_GENERIC] = "sound",
 | 
			
		||||
        [SND_PCM_CLASS_MULTI] = NULL,
 | 
			
		||||
        [SND_PCM_CLASS_MODEM] = "modem",
 | 
			
		||||
        [SND_PCM_CLASS_DIGITIZER] = NULL
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    snd_pcm_info_alloca(&pcm_info);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1067,15 +1061,10 @@ int pa__init(pa_module*m) {
 | 
			
		|||
    pa_source_new_data_set_sample_spec(&data, &ss);
 | 
			
		||||
    pa_source_new_data_set_channel_map(&data, &map);
 | 
			
		||||
 | 
			
		||||
    pa_alsa_init_proplist(data.proplist, pcm_info);
 | 
			
		||||
    pa_proplist_sets(data.proplist, PA_PROP_DEVICE_STRING, u->device_name);
 | 
			
		||||
    pa_proplist_sets(data.proplist, PA_PROP_DEVICE_API, "alsa");
 | 
			
		||||
    pa_proplist_sets(data.proplist, PA_PROP_DEVICE_DESCRIPTION, snd_pcm_info_get_name(pcm_info));
 | 
			
		||||
    pa_proplist_setf(data.proplist, PA_PROP_DEVICE_BUFFERING_BUFFER_SIZE, "%lu", (unsigned long) (period_frames * frame_size * nfrags));
 | 
			
		||||
    pa_proplist_setf(data.proplist, PA_PROP_DEVICE_BUFFERING_FRAGMENT_SIZE, "%lu", (unsigned long) (period_frames * frame_size));
 | 
			
		||||
 | 
			
		||||
    if (class_table[snd_pcm_info_get_class(pcm_info)])
 | 
			
		||||
        pa_proplist_sets(data.proplist, PA_PROP_DEVICE_CLASS, class_table[snd_pcm_info_get_class(pcm_info)]);
 | 
			
		||||
 | 
			
		||||
    pa_proplist_sets(data.proplist, PA_PROP_DEVICE_ACCESS_MODE, u->use_tsched ? "mmap_rewrite" : (u->use_mmap ? "mmap" : "serial"));
 | 
			
		||||
 | 
			
		||||
    u->source = pa_source_new(m->core, &data, PA_SOURCE_HARDWARE|PA_SOURCE_LATENCY);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue