mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-29 05:40:23 -04:00
stdout_callback: since the function 'pa_write' may not write all the data we asked it to, we will add an index field to each element of the queue.
This commit is contained in:
parent
6324d009b3
commit
4c7748b7a0
1 changed files with 13 additions and 6 deletions
|
|
@ -77,6 +77,7 @@ static size_t partialframe_len = 0;
|
|||
struct buffer_t {
|
||||
void *buffer;
|
||||
size_t length;
|
||||
size_t index;
|
||||
SIMPLEQ_ENTRY(buffer_t) next;
|
||||
};
|
||||
|
||||
|
|
@ -267,6 +268,7 @@ static void stream_read_callback(pa_stream *s, size_t length, void *userdata) {
|
|||
struct buffer_t *buf = pa_xmalloc(sizeof(struct buffer_t));
|
||||
buf->buffer = buffer;
|
||||
buf->length = length;
|
||||
buf->index = 0;
|
||||
SIMPLEQ_INSERT_TAIL(&buffer_head, buf, next);
|
||||
}
|
||||
|
||||
|
|
@ -610,8 +612,8 @@ static void stdout_callback(pa_mainloop_api*a, pa_io_event *e, int fd, pa_io_eve
|
|||
}
|
||||
|
||||
struct buffer_t *buf = SIMPLEQ_FIRST(&buffer_head);
|
||||
void *buffer = buf->buffer;
|
||||
size_t length = buf->length;
|
||||
void *buffer = buf->buffer + buf->index;
|
||||
size_t length = buf->length - buf->index;
|
||||
|
||||
if ((r = pa_write(fd, (uint8_t*) buffer, length, userdata)) <= 0) {
|
||||
pa_log(_("write() failed: %s"), strerror(errno));
|
||||
|
|
@ -621,10 +623,15 @@ static void stdout_callback(pa_mainloop_api*a, pa_io_event *e, int fd, pa_io_eve
|
|||
stdio_event = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
pa_xfree(buffer);
|
||||
SIMPLEQ_REMOVE_HEAD(&buffer_head, next);
|
||||
pa_xfree(buf);
|
||||
|
||||
buf->index += r;
|
||||
|
||||
if (buf->index == buf->length)
|
||||
{
|
||||
pa_xfree(buffer);
|
||||
SIMPLEQ_REMOVE_HEAD(&buffer_head, next);
|
||||
pa_xfree(buf);
|
||||
}
|
||||
}
|
||||
|
||||
/* UNIX signal to quit received */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue