mirror of
				https://github.com/alsa-project/alsa-lib.git
				synced 2025-11-03 09:01:52 -05:00 
			
		
		
		
	pcm: fix snd_pcm_avail_delay() function
For capture stream, the delay must be obtained as last, but we need to update the ring buffer pointers for the avail_update call. So, rearrange the code a bit and add hwsync call as first. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
		
							parent
							
								
									7c99bd24bc
								
							
						
					
					
						commit
						ba9332e919
					
				
					 1 changed files with 7 additions and 3 deletions
				
			
		| 
						 | 
					@ -2470,18 +2470,22 @@ int snd_pcm_avail_delay(snd_pcm_t *pcm,
 | 
				
			||||||
			snd_pcm_sframes_t *delayp)
 | 
								snd_pcm_sframes_t *delayp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	snd_pcm_sframes_t sf;
 | 
						snd_pcm_sframes_t sf;
 | 
				
			||||||
 | 
						int err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	assert(pcm && availp && delayp);
 | 
						assert(pcm && availp && delayp);
 | 
				
			||||||
	if (CHECK_SANITY(! pcm->setup)) {
 | 
						if (CHECK_SANITY(! pcm->setup)) {
 | 
				
			||||||
		SNDMSG("PCM not set up");
 | 
							SNDMSG("PCM not set up");
 | 
				
			||||||
		return -EIO;
 | 
							return -EIO;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	sf = pcm->fast_ops->delay(pcm->fast_op_arg, delayp);
 | 
						err = pcm->fast_ops->hwsync(pcm->fast_op_arg);
 | 
				
			||||||
	if (sf < 0)
 | 
						if (err < 0)
 | 
				
			||||||
		return (int)sf;
 | 
							return err;
 | 
				
			||||||
	sf = pcm->fast_ops->avail_update(pcm->fast_op_arg);
 | 
						sf = pcm->fast_ops->avail_update(pcm->fast_op_arg);
 | 
				
			||||||
	if (sf < 0)
 | 
						if (sf < 0)
 | 
				
			||||||
		return (int)sf;
 | 
							return (int)sf;
 | 
				
			||||||
 | 
						err = pcm->fast_ops->delay(pcm->fast_op_arg, delayp);
 | 
				
			||||||
 | 
						if (err < 0)
 | 
				
			||||||
 | 
							return err;
 | 
				
			||||||
	*availp = sf;
 | 
						*availp = sf;
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue