mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-29 05:40:25 -04:00
changed result type from int to snd_pcm_sframes_t for snd_pcm_mmap_commit; removed snd_pcm_mmap_commit_partial
This commit is contained in:
parent
155e6822d2
commit
cd29f8b860
2 changed files with 27 additions and 49 deletions
|
|
@ -791,13 +791,9 @@ int snd_pcm_mmap_begin(snd_pcm_t *pcm,
|
||||||
const snd_pcm_channel_area_t **areas,
|
const snd_pcm_channel_area_t **areas,
|
||||||
snd_pcm_uframes_t *offset,
|
snd_pcm_uframes_t *offset,
|
||||||
snd_pcm_uframes_t *frames);
|
snd_pcm_uframes_t *frames);
|
||||||
int snd_pcm_mmap_commit(snd_pcm_t *pcm,
|
snd_pcm_sframes_t snd_pcm_mmap_commit(snd_pcm_t *pcm,
|
||||||
snd_pcm_uframes_t offset,
|
snd_pcm_uframes_t offset,
|
||||||
snd_pcm_uframes_t frames);
|
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_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size);
|
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_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);
|
snd_pcm_sframes_t snd_pcm_mmap_writen(snd_pcm_t *pcm, void **bufs, snd_pcm_uframes_t size);
|
||||||
|
|
|
||||||
|
|
@ -5005,7 +5005,7 @@ int snd_pcm_mmap_begin(snd_pcm_t *pcm,
|
||||||
* \param pcm PCM handle
|
* \param pcm PCM handle
|
||||||
* \param offset area offset in area steps (== frames)
|
* \param offset area offset in area steps (== frames)
|
||||||
* \param size area portion size in 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
|
* You should pass this function the offset value that
|
||||||
* snd_pcm_mmap_begin() returned. The frames parameter should hold the
|
* 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
|
\code
|
||||||
double phase = 0;
|
double phase = 0;
|
||||||
const snd_pcm_area_t *areas;
|
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;
|
snd_pcm_uframes_t offset, frames;
|
||||||
|
int err;
|
||||||
|
|
||||||
avail = snd_pcm_avail_update(pcm);
|
avail = snd_pcm_avail_update(pcm);
|
||||||
if (avail < 0)
|
if (avail < 0)
|
||||||
|
|
@ -5039,9 +5040,9 @@ int snd_pcm_mmap_begin(snd_pcm_t *pcm,
|
||||||
error(err);
|
error(err);
|
||||||
// this function fills the areas from offset with count of frames
|
// this function fills the areas from offset with count of frames
|
||||||
generate_sine(areas, offset, frames, &phase);
|
generate_sine(areas, offset, frames, &phase);
|
||||||
err = snd_pcm_mmap_commit(pcm_handle, offset, frames);
|
commitres = snd_pcm_mmap_commit(pcm_handle, offset, frames);
|
||||||
if (err < 0)
|
if (commitres < 0 || commitres != frames)
|
||||||
error(err);
|
error(commitres >= 0 ? -EPIPE : commitres);
|
||||||
|
|
||||||
size -= frames;
|
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
|
* Look to the \ref example_test_pcm "Sine-wave generator" example
|
||||||
* for more details about the generate_sine function.
|
* for more details about the generate_sine function.
|
||||||
*/
|
*/
|
||||||
int snd_pcm_mmap_commit(snd_pcm_t *pcm, snd_pcm_uframes_t offset,
|
snd_pcm_sframes_t snd_pcm_mmap_commit(snd_pcm_t *pcm,
|
||||||
snd_pcm_uframes_t frames)
|
snd_pcm_uframes_t offset,
|
||||||
|
snd_pcm_uframes_t frames)
|
||||||
{
|
{
|
||||||
|
int res;
|
||||||
|
snd_pcm_uframes_t appl_ptr;
|
||||||
|
|
||||||
assert(pcm);
|
assert(pcm);
|
||||||
assert(offset == *pcm->appl_ptr % pcm->buffer_size);
|
assert(offset == *pcm->appl_ptr % pcm->buffer_size);
|
||||||
assert(frames <= snd_pcm_mmap_avail(pcm));
|
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)
|
|
||||||
{
|
|
||||||
int err;
|
|
||||||
snd_pcm_uframes_t appl_ptr;
|
|
||||||
|
|
||||||
assert(pcm && commited);
|
|
||||||
assert(offset == *pcm->appl_ptr % pcm->buffer_size);
|
|
||||||
assert(frames <= snd_pcm_mmap_avail(pcm));
|
|
||||||
appl_ptr = *pcm->appl_ptr;
|
appl_ptr = *pcm->appl_ptr;
|
||||||
err = pcm->fast_ops->mmap_commit(pcm->fast_op_arg, offset, frames);
|
res = pcm->fast_ops->mmap_commit(pcm->fast_op_arg, offset, frames);
|
||||||
if (err < 0) {
|
if (res < 0) {
|
||||||
*commited = *pcm->appl_ptr - appl_ptr;
|
snd_pcm_sframes_t diff;
|
||||||
assert(*commited <= pcm->buffer_size);
|
|
||||||
return err;
|
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 frames;
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef DOC_HIDDEN
|
#ifndef DOC_HIDDEN
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue