mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
client: limit block size for zero-copy operations to mempool block size
This commit is contained in:
parent
e7ca058427
commit
211d0f3dcb
2 changed files with 18 additions and 6 deletions
|
|
@ -1207,6 +1207,17 @@ int pa_stream_begin_write(
|
||||||
PA_CHECK_VALIDITY(s->context, data, PA_ERR_INVALID);
|
PA_CHECK_VALIDITY(s->context, data, PA_ERR_INVALID);
|
||||||
PA_CHECK_VALIDITY(s->context, nbytes && *nbytes != 0, PA_ERR_INVALID);
|
PA_CHECK_VALIDITY(s->context, nbytes && *nbytes != 0, PA_ERR_INVALID);
|
||||||
|
|
||||||
|
if (*nbytes != (size_t) -1) {
|
||||||
|
size_t m, fs;
|
||||||
|
|
||||||
|
m = pa_mempool_block_size_max(s->context->mempool);
|
||||||
|
fs = pa_frame_size(&s->sample_spec);
|
||||||
|
|
||||||
|
m = (m / fs) * fs;
|
||||||
|
if (*nbytes > m)
|
||||||
|
*nbytes = m;
|
||||||
|
}
|
||||||
|
|
||||||
if (!s->write_memblock) {
|
if (!s->write_memblock) {
|
||||||
s->write_memblock = pa_memblock_new(s->context->mempool, *nbytes);
|
s->write_memblock = pa_memblock_new(s->context->mempool, *nbytes);
|
||||||
s->write_data = pa_memblock_acquire(s->write_memblock);
|
s->write_data = pa_memblock_acquire(s->write_memblock);
|
||||||
|
|
|
||||||
|
|
@ -425,7 +425,7 @@ int pa_stream_disconnect(pa_stream *s);
|
||||||
* to a pointer and an address of the number of bytes you want to
|
* to a pointer and an address of the number of bytes you want to
|
||||||
* write. On return the two values will contain a pointer where you
|
* write. On return the two values will contain a pointer where you
|
||||||
* can place the data to write and the maximum number of bytes you can
|
* can place the data to write and the maximum number of bytes you can
|
||||||
* write. On return *nbytes can be larger or have the same value as
|
* write. On return *nbytes can be smaller or have the same value as
|
||||||
* you passed in. You need to be able to handle both cases. Accessing
|
* you passed in. You need to be able to handle both cases. Accessing
|
||||||
* memory beyond the returned *nbytes value is invalid. Acessing the
|
* memory beyond the returned *nbytes value is invalid. Acessing the
|
||||||
* memory returned after the following pa_stream_write() or
|
* memory returned after the following pa_stream_write() or
|
||||||
|
|
@ -442,7 +442,7 @@ int pa_stream_disconnect(pa_stream *s);
|
||||||
* amount of time pass after calling pa_stream_begin_write() and
|
* amount of time pass after calling pa_stream_begin_write() and
|
||||||
* before calling pa_stream_write(). If you want to cancel a
|
* before calling pa_stream_write(). If you want to cancel a
|
||||||
* previously called pa_stream_begin_write() without calling
|
* previously called pa_stream_begin_write() without calling
|
||||||
* pa_stream_write() use pa_stream_cancel_write() instead. Calling
|
* pa_stream_write() use pa_stream_cancel_write(). Calling
|
||||||
* pa_stream_begin_write() twice without calling pa_stream_write() or
|
* pa_stream_begin_write() twice without calling pa_stream_write() or
|
||||||
* pa_stream_cancel_write() in between will return exactly the same
|
* pa_stream_cancel_write() in between will return exactly the same
|
||||||
* pointer/nbytes values.\since 0.9.16 */
|
* pointer/nbytes values.\since 0.9.16 */
|
||||||
|
|
@ -492,10 +492,11 @@ int pa_stream_write(
|
||||||
pa_seek_mode_t seek /**< Seek mode, must be PA_SEEK_RELATIVE for upload streams */);
|
pa_seek_mode_t seek /**< Seek mode, must be PA_SEEK_RELATIVE for upload streams */);
|
||||||
|
|
||||||
/** Read the next fragment from the buffer (for recording streams).
|
/** Read the next fragment from the buffer (for recording streams).
|
||||||
* data will point to the actual data and length will contain the size
|
* data will point to the actual data and nbytes will contain the size
|
||||||
* of the data in bytes (which can be less than a complete framgnet).
|
* of the data in bytes (which can be less or more than a complete
|
||||||
* Use pa_stream_drop() to actually remove the data from the
|
* fragment). Use pa_stream_drop() to actually remove the data from
|
||||||
* buffer. If no data is available will return a NULL pointer */
|
* the buffer. If no data is available this will return a NULL
|
||||||
|
* pointer */
|
||||||
int pa_stream_peek(
|
int pa_stream_peek(
|
||||||
pa_stream *p /**< The stream to use */,
|
pa_stream *p /**< The stream to use */,
|
||||||
const void **data /**< Pointer to pointer that will point to data */,
|
const void **data /**< Pointer to pointer that will point to data */,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue