diff options
author | Jaroslav Kysela <perex@perex.cz> | 2001-12-11 15:27:26 +0000 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2001-12-11 15:27:26 +0000 |
commit | cd29f8b860f38145319a29544f8e8fe31d8e8b34 (patch) | |
tree | c825efd31c9db6810c8969a5a9e2cbb0a23cbfdc | |
parent | 155e6822d2f114485771c9d76097128c06cb6b86 (diff) | |
download | alsa-lib-cd29f8b860f38145319a29544f8e8fe31d8e8b34.tar.gz |
changed result type from int to snd_pcm_sframes_t for snd_pcm_mmap_commit; removed snd_pcm_mmap_commit_partial
-rw-r--r-- | include/pcm.h | 10 | ||||
-rw-r--r-- | src/pcm/pcm.c | 64 |
2 files changed, 26 insertions, 48 deletions
diff --git a/include/pcm.h b/include/pcm.h index 3fdf2810..e0598db7 100644 --- a/include/pcm.h +++ b/include/pcm.h @@ -791,13 +791,9 @@ int snd_pcm_mmap_begin(snd_pcm_t *pcm, const snd_pcm_channel_area_t **areas, snd_pcm_uframes_t *offset, snd_pcm_uframes_t *frames); -int snd_pcm_mmap_commit(snd_pcm_t *pcm, - snd_pcm_uframes_t offset, - snd_pcm_uframes_t frames); -int snd_pcm_mmap_commit_partial(snd_pcm_t *pcm, - snd_pcm_uframes_t offset, - snd_pcm_uframes_t frames, - snd_pcm_uframes_t *commited); +snd_pcm_sframes_t snd_pcm_mmap_commit(snd_pcm_t *pcm, + snd_pcm_uframes_t offset, + snd_pcm_uframes_t frames); snd_pcm_sframes_t snd_pcm_mmap_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size); snd_pcm_sframes_t snd_pcm_mmap_readi(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t size); snd_pcm_sframes_t snd_pcm_mmap_writen(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size); diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c index bb6e53b9..0307965e 100644 --- a/src/pcm/pcm.c +++ b/src/pcm/pcm.c @@ -5005,7 +5005,7 @@ int snd_pcm_mmap_begin(snd_pcm_t *pcm, * \param pcm PCM handle * \param offset area offset in area steps (== frames) * \param size area portion size in frames - * \return 0 on success otherwise a negative error code + * \return count of transferred frames otherwise a negative error code * * You should pass this function the offset value that * snd_pcm_mmap_begin() returned. The frames parameter should hold the @@ -5018,8 +5018,9 @@ int snd_pcm_mmap_begin(snd_pcm_t *pcm, \code double phase = 0; const snd_pcm_area_t *areas; - snd_pcm_sframes_t avail, size; + snd_pcm_sframes_t avail, size, commitres; snd_pcm_uframes_t offset, frames; + int err; avail = snd_pcm_avail_update(pcm); if (avail < 0) @@ -5039,9 +5040,9 @@ int snd_pcm_mmap_begin(snd_pcm_t *pcm, error(err); // this function fills the areas from offset with count of frames generate_sine(areas, offset, frames, &phase); - err = snd_pcm_mmap_commit(pcm_handle, offset, frames); - if (err < 0) - error(err); + commitres = snd_pcm_mmap_commit(pcm_handle, offset, frames); + if (commitres < 0 || commitres != frames) + error(commitres >= 0 ? -EPIPE : commitres); size -= frames; } @@ -5051,49 +5052,30 @@ int snd_pcm_mmap_begin(snd_pcm_t *pcm, * Look to the \ref example_test_pcm "Sine-wave generator" example * for more details about the generate_sine function. */ -int snd_pcm_mmap_commit(snd_pcm_t *pcm, snd_pcm_uframes_t offset, - snd_pcm_uframes_t frames) -{ - assert(pcm); - assert(offset == *pcm->appl_ptr % pcm->buffer_size); - assert(frames <= snd_pcm_mmap_avail(pcm)); - return pcm->fast_ops->mmap_commit(pcm->fast_op_arg, offset, frames); -} - -/** - * \brief Application has completed the access to area requested with #snd_pcm_mmap_begin - * \param pcm PCM handle - * \param offset area offset in area steps (== frames) - * \param size area portion size in frames - * \param commited count of successfully commited frames - * \return 0 on success otherwise a negative error code - * - * See snd_pcm_mmap_commit() function. The only difference is the - * #commited parameter returning count of successfully commited frames - * when an error occured. This parameter is equal to frames when - * no error occured. This function is a helper for more precise xrun - * recovery algorithms. - */ -int snd_pcm_mmap_commit_partial(snd_pcm_t *pcm, - snd_pcm_uframes_t offset, - snd_pcm_uframes_t frames, - snd_pcm_uframes_t *commited) +snd_pcm_sframes_t snd_pcm_mmap_commit(snd_pcm_t *pcm, + snd_pcm_uframes_t offset, + snd_pcm_uframes_t frames) { - int err; + int res; snd_pcm_uframes_t appl_ptr; - assert(pcm && commited); + assert(pcm); assert(offset == *pcm->appl_ptr % pcm->buffer_size); assert(frames <= snd_pcm_mmap_avail(pcm)); appl_ptr = *pcm->appl_ptr; - err = pcm->fast_ops->mmap_commit(pcm->fast_op_arg, offset, frames); - if (err < 0) { - *commited = *pcm->appl_ptr - appl_ptr; - assert(*commited <= pcm->buffer_size); - return err; + res = pcm->fast_ops->mmap_commit(pcm->fast_op_arg, offset, frames); + if (res < 0) { + snd_pcm_sframes_t diff; + + if (appl_ptr == *pcm->appl_ptr) + return res; + diff = *pcm->appl_ptr - appl_ptr; + if (diff < 0) + diff += pcm->boundary; + assert(diff >= 0 && (snd_pcm_uframes_t)diff < pcm->boundary); + return diff; } - *commited = frames; - return err; + return frames; } #ifndef DOC_HIDDEN |