mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-12-16 08:56:42 -05:00
Added a call to XRUN ioctl to update correctly PCM state
This commit is contained in:
parent
20bfec221e
commit
9b0eebbcb7
1 changed files with 13 additions and 2 deletions
|
|
@ -50,7 +50,10 @@ const char *_snd_module_pcm_hw = "";
|
||||||
#define F_SETSIG 10
|
#define F_SETSIG 10
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define SND_PCM_IOCTL_XRUN _IO('A', 0x48)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
int version;
|
||||||
int fd;
|
int fd;
|
||||||
int card, device, subdevice;
|
int card, device, subdevice;
|
||||||
int mmap_emulation;
|
int mmap_emulation;
|
||||||
|
|
@ -65,7 +68,7 @@ typedef struct {
|
||||||
|
|
||||||
#define SNDRV_FILE_PCM_STREAM_PLAYBACK "/dev/snd/pcmC%iD%ip"
|
#define SNDRV_FILE_PCM_STREAM_PLAYBACK "/dev/snd/pcmC%iD%ip"
|
||||||
#define SNDRV_FILE_PCM_STREAM_CAPTURE "/dev/snd/pcmC%iD%ic"
|
#define SNDRV_FILE_PCM_STREAM_CAPTURE "/dev/snd/pcmC%iD%ic"
|
||||||
#define SNDRV_PCM_VERSION_MAX SNDRV_PROTOCOL_VERSION(2, 0, 0)
|
#define SNDRV_PCM_VERSION_MAX SNDRV_PROTOCOL_VERSION(2, 0, 1)
|
||||||
|
|
||||||
/* update appl_ptr with driver */
|
/* update appl_ptr with driver */
|
||||||
#define UPDATE_SHADOW_PTR(hw) \
|
#define UPDATE_SHADOW_PTR(hw) \
|
||||||
|
|
@ -635,8 +638,15 @@ static snd_pcm_sframes_t snd_pcm_hw_avail_update(snd_pcm_t *pcm)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (avail >= pcm->stop_threshold)
|
if (avail >= pcm->stop_threshold) {
|
||||||
|
/* SNDRV_PCM_IOCTL_XRUN ioctl has been implemented since PCM kernel API 2.0.1 */
|
||||||
|
if (SNDRV_PROTOCOL_VERSION(2, 0, 1) <= hw->version) {
|
||||||
|
if (ioctl(hw->fd, SND_PCM_IOCTL_XRUN) < 0)
|
||||||
|
return -errno;
|
||||||
|
}
|
||||||
|
/* everything is ok, state == SND_PCM_STATE_XRUN at the moment */
|
||||||
return -EPIPE;
|
return -EPIPE;
|
||||||
|
}
|
||||||
return avail;
|
return avail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -781,6 +791,7 @@ int snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name,
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
hw->version = ver;
|
||||||
hw->card = card;
|
hw->card = card;
|
||||||
hw->device = device;
|
hw->device = device;
|
||||||
hw->subdevice = subdevice;
|
hw->subdevice = subdevice;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue