mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	alsa: unify alsa log handling and snd_config_update_free_global() handling in one place
This commit is contained in:
		
							parent
							
								
									25e5197f6a
								
							
						
					
					
						commit
						348dcd6a31
					
				
					 7 changed files with 13 additions and 20 deletions
				
			
		| 
						 | 
				
			
			@ -838,7 +838,6 @@ static int unsuspend(struct userdata *u) {
 | 
			
		|||
 | 
			
		||||
    pa_log_info("Trying resume...");
 | 
			
		||||
 | 
			
		||||
    snd_config_update_free_global();
 | 
			
		||||
    if ((err = snd_pcm_open(&u->pcm_handle, u->device_name, SND_PCM_STREAM_PLAYBACK,
 | 
			
		||||
                            /*SND_PCM_NONBLOCK|*/
 | 
			
		||||
                            SND_PCM_NO_AUTO_RESAMPLE|
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -787,8 +787,6 @@ static int unsuspend(struct userdata *u) {
 | 
			
		|||
 | 
			
		||||
    pa_log_info("Trying resume...");
 | 
			
		||||
 | 
			
		||||
    snd_config_update_free_global();
 | 
			
		||||
 | 
			
		||||
    if ((err = snd_pcm_open(&u->pcm_handle, u->device_name, SND_PCM_STREAM_CAPTURE,
 | 
			
		||||
                            /*SND_PCM_NONBLOCK|*/
 | 
			
		||||
                            SND_PCM_NO_AUTO_RESAMPLE|
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -735,20 +735,22 @@ static void alsa_error_handler(const char *file, int line, const char *function,
 | 
			
		|||
 | 
			
		||||
static pa_atomic_t n_error_handler_installed = PA_ATOMIC_INIT(0);
 | 
			
		||||
 | 
			
		||||
void pa_alsa_redirect_errors_inc(void) {
 | 
			
		||||
void pa_alsa_refcnt_inc(void) {
 | 
			
		||||
    /* This is not really thread safe, but we do our best */
 | 
			
		||||
 | 
			
		||||
    if (pa_atomic_inc(&n_error_handler_installed) == 0)
 | 
			
		||||
        snd_lib_error_set_handler(alsa_error_handler);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void pa_alsa_redirect_errors_dec(void) {
 | 
			
		||||
void pa_alsa_refcnt_dec(void) {
 | 
			
		||||
    int r;
 | 
			
		||||
 | 
			
		||||
    pa_assert_se((r = pa_atomic_dec(&n_error_handler_installed)) >= 1);
 | 
			
		||||
 | 
			
		||||
    if (r == 1)
 | 
			
		||||
    if (r == 1) {
 | 
			
		||||
        snd_lib_error_set_handler(NULL);
 | 
			
		||||
        snd_config_update_free_global();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pa_bool_t pa_alsa_init_description(pa_proplist *p) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -114,8 +114,8 @@ snd_pcm_t *pa_alsa_open_by_template(
 | 
			
		|||
void pa_alsa_dump(pa_log_level_t level, snd_pcm_t *pcm);
 | 
			
		||||
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_refcnt_inc(void);
 | 
			
		||||
void pa_alsa_refcnt_dec(void);
 | 
			
		||||
 | 
			
		||||
void pa_alsa_init_proplist_pcm_info(pa_core *c, pa_proplist *p, snd_pcm_info_t *pcm_info);
 | 
			
		||||
void pa_alsa_init_proplist_card(pa_core *c, pa_proplist *p, int card);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -287,8 +287,7 @@ int pa__init(pa_module *m) {
 | 
			
		|||
    const char *description;
 | 
			
		||||
    char *fn = NULL;
 | 
			
		||||
 | 
			
		||||
    pa_alsa_redirect_errors_inc();
 | 
			
		||||
    snd_config_update_free_global();
 | 
			
		||||
    pa_alsa_refcnt_inc();
 | 
			
		||||
 | 
			
		||||
    pa_assert(m);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -443,6 +442,5 @@ void pa__done(pa_module*m) {
 | 
			
		|||
    pa_xfree(u);
 | 
			
		||||
 | 
			
		||||
finish:
 | 
			
		||||
    snd_config_update_free_global();
 | 
			
		||||
    pa_alsa_redirect_errors_dec();
 | 
			
		||||
    pa_alsa_refcnt_dec();
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -82,8 +82,7 @@ int pa__init(pa_module*m) {
 | 
			
		|||
 | 
			
		||||
    pa_assert(m);
 | 
			
		||||
 | 
			
		||||
    pa_alsa_redirect_errors_inc();
 | 
			
		||||
    snd_config_update_free_global();
 | 
			
		||||
    pa_alsa_refcnt_inc();
 | 
			
		||||
 | 
			
		||||
    if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
 | 
			
		||||
        pa_log("Failed to parse module arguments");
 | 
			
		||||
| 
						 | 
				
			
			@ -124,6 +123,5 @@ void pa__done(pa_module*m) {
 | 
			
		|||
    if ((sink = m->userdata))
 | 
			
		||||
        pa_alsa_sink_free(sink);
 | 
			
		||||
 | 
			
		||||
    snd_config_update_free_global();
 | 
			
		||||
    pa_alsa_redirect_errors_dec();
 | 
			
		||||
    pa_alsa_refcnt_dec();
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -106,8 +106,7 @@ int pa__init(pa_module*m) {
 | 
			
		|||
 | 
			
		||||
    pa_assert(m);
 | 
			
		||||
 | 
			
		||||
    pa_alsa_redirect_errors_inc();
 | 
			
		||||
    snd_config_update_free_global();
 | 
			
		||||
    pa_alsa_refcnt_inc();
 | 
			
		||||
 | 
			
		||||
    if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
 | 
			
		||||
        pa_log("Failed to parse module arguments");
 | 
			
		||||
| 
						 | 
				
			
			@ -148,6 +147,5 @@ void pa__done(pa_module*m) {
 | 
			
		|||
    if ((source = m->userdata))
 | 
			
		||||
        pa_alsa_source_free(source);
 | 
			
		||||
 | 
			
		||||
    snd_config_update_free_global();
 | 
			
		||||
    pa_alsa_redirect_errors_dec();
 | 
			
		||||
    pa_alsa_refcnt_dec();
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue