mirror of
				https://github.com/alsa-project/alsa-lib.git
				synced 2025-11-03 09:01:52 -05:00 
			
		
		
		
	pcm: Disable locking in async mode
When PCM is operated in async mode and an async handler calls some PCM functions with lock during other PCM operations, we may hit a deadlock. Although async mode is rarely used, it's still a possible use case. Disable the locking when the stream is opened in async mode or it's set to async mode via snd_pcm_async(). Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
		
							parent
							
								
									b5a2c06f6c
								
							
						
					
					
						commit
						e31a3273df
					
				
					 1 changed files with 6 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -799,6 +799,8 @@ int snd_pcm_async(snd_pcm_t *pcm, int sig, pid_t pid)
 | 
			
		|||
		sig = SIGIO;
 | 
			
		||||
	if (pid == 0)
 | 
			
		||||
		pid = getpid();
 | 
			
		||||
	/* async handler may lead to a deadlock; suppose no multi thread */
 | 
			
		||||
	pcm->lock_enabled = 0;
 | 
			
		||||
	return pcm->ops->async(pcm->op_arg, sig, pid);
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			@ -2597,7 +2599,10 @@ int snd_pcm_new(snd_pcm_t **pcmp, snd_pcm_type_t type, const char *name,
 | 
			
		|||
	 * each plugin may suppress this in its open call
 | 
			
		||||
	 */
 | 
			
		||||
	pcm->need_lock = 1;
 | 
			
		||||
	{
 | 
			
		||||
	if (mode & SND_PCM_ASYNC) {
 | 
			
		||||
		/* async handler may lead to a deadlock; suppose no MT */
 | 
			
		||||
		pcm->lock_enabled = 0;
 | 
			
		||||
	} else {
 | 
			
		||||
		/* set lock_enabled field depending on $LIBASOUND_THREAD_SAFE */
 | 
			
		||||
		static int do_lock_enable = -1; /* uninitialized */
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue