mirror of
				https://github.com/alsa-project/alsa-lib.git
				synced 2025-11-03 09:01:52 -05:00 
			
		
		
		
	pcm_hw: Always use delay ioctl in snd_pcm_delay()
As the result of snd_pcm_delay() is affected not only by hw_ptr and appl_ptr, but also by 'runtime->delay' property, either SNDRV_PCM_IOCTL_DELAY or SNDRV_PCM_IOCTL_STATUS ioctl must be used to get the correct result. Previously 'runtime->delay' was ignored in case 'hw->sync_ptr' was used. Signed-off-by: Kai Vehmanen <kvehmanen@eca.cx> Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
		
							parent
							
								
									a4e7033f8d
								
							
						
					
					
						commit
						ecf4b5af86
					
				
					 1 changed files with 0 additions and 22 deletions
				
			
		| 
						 | 
					@ -507,28 +507,6 @@ static int snd_pcm_hw_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	snd_pcm_hw_t *hw = pcm->private_data;
 | 
						snd_pcm_hw_t *hw = pcm->private_data;
 | 
				
			||||||
	int fd = hw->fd, err;
 | 
						int fd = hw->fd, err;
 | 
				
			||||||
	if (hw->sync_ptr) {
 | 
					 | 
				
			||||||
		err = sync_ptr1(hw, SNDRV_PCM_SYNC_PTR_HWSYNC);
 | 
					 | 
				
			||||||
		if (err < 0)
 | 
					 | 
				
			||||||
			return err;
 | 
					 | 
				
			||||||
		switch (FAST_PCM_STATE(hw)) {
 | 
					 | 
				
			||||||
		case SNDRV_PCM_STATE_RUNNING:
 | 
					 | 
				
			||||||
		case SNDRV_PCM_STATE_DRAINING:
 | 
					 | 
				
			||||||
		case SNDRV_PCM_STATE_PAUSED:
 | 
					 | 
				
			||||||
		case SNDRV_PCM_STATE_PREPARED:
 | 
					 | 
				
			||||||
		case SNDRV_PCM_STATE_SUSPENDED:
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		case SNDRV_PCM_STATE_XRUN:
 | 
					 | 
				
			||||||
			return -EPIPE;
 | 
					 | 
				
			||||||
		default:
 | 
					 | 
				
			||||||
			return -EBADFD;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		if (pcm->stream == SND_PCM_STREAM_PLAYBACK)
 | 
					 | 
				
			||||||
			*delayp = snd_pcm_mmap_playback_hw_avail(pcm);
 | 
					 | 
				
			||||||
		else
 | 
					 | 
				
			||||||
			*delayp = snd_pcm_mmap_capture_avail(pcm);
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if (ioctl(fd, SNDRV_PCM_IOCTL_DELAY, delayp) < 0) {
 | 
						if (ioctl(fd, SNDRV_PCM_IOCTL_DELAY, delayp) < 0) {
 | 
				
			||||||
		err = -errno;
 | 
							err = -errno;
 | 
				
			||||||
		SYSMSG("SNDRV_PCM_IOCTL_DELAY failed");
 | 
							SYSMSG("SNDRV_PCM_IOCTL_DELAY failed");
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue