/* Called whenever a period elapses, it must return the current hardware position of the buffer. Also resets the read counter used to prevent overruns  */
static snd_pcm_uframes_t snd_card_saa7134_capture_pointer(struct snd_pcm_substream *substream)
/* Called whenever a period elapses, it must return the current hardware position of the buffer. Also resets the read counter used to prevent overruns  */
static snd_pcm_uframes_t snd_card_saa7134_capture_pointer(struct snd_pcm_substream *substream)
{
	struct snd_pcm_runtime *runtime = substream->runtime;
	snd_card_saa7134_pcm_t *pcm = runtime->private_data;
	struct saa7134_dev *dev=pcm->dev;
	if (dev->dmasound.read_count) {
		dev->dmasound.read_count  -= snd_pcm_lib_period_bytes(substream);
		dev->dmasound.read_offset += snd_pcm_lib_period_bytes(substream);
		if (dev->dmasound.read_offset == dev->dmasound.bufsize)
			dev->dmasound.read_offset = 0;
	}
	return bytes_to_frames(runtime, dev->dmasound.read_offset);
}