mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-12-16 08:56:40 -05:00
protocol-esound/http/simple: Make sure callers can handle iochannel_write changes
With the new behaviour, you will not always get a callback after a successful write. Make sure the callers can properly handle this. Signed-off-by: David Henningsson <david.henningsson@canonical.com>
This commit is contained in:
parent
97da92d894
commit
8127f8f9c5
3 changed files with 23 additions and 12 deletions
|
|
@ -1196,10 +1196,6 @@ static int do_write(connection *c) {
|
||||||
|
|
||||||
pa_assert(c->write_data_index < c->write_data_length);
|
pa_assert(c->write_data_index < c->write_data_length);
|
||||||
if ((r = pa_iochannel_write(c->io, (uint8_t*) c->write_data+c->write_data_index, c->write_data_length-c->write_data_index)) < 0) {
|
if ((r = pa_iochannel_write(c->io, (uint8_t*) c->write_data+c->write_data_index, c->write_data_length-c->write_data_index)) < 0) {
|
||||||
|
|
||||||
if (r < 0 && (errno == EINTR || errno == EAGAIN))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
pa_log("write(): %s", pa_cstrerror(errno));
|
pa_log("write(): %s", pa_cstrerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -1208,6 +1204,8 @@ static int do_write(connection *c) {
|
||||||
if (c->write_data_index >= c->write_data_length)
|
if (c->write_data_index >= c->write_data_length)
|
||||||
c->write_data_length = c->write_data_index = 0;
|
c->write_data_length = c->write_data_index = 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
|
||||||
} else if (c->state == ESD_STREAMING_DATA && c->source_output) {
|
} else if (c->state == ESD_STREAMING_DATA && c->source_output) {
|
||||||
pa_memchunk chunk;
|
pa_memchunk chunk;
|
||||||
ssize_t r;
|
ssize_t r;
|
||||||
|
|
@ -1231,6 +1229,7 @@ static int do_write(connection *c) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pa_memblockq_drop(c->output_memblockq, (size_t) r);
|
pa_memblockq_drop(c->output_memblockq, (size_t) r);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -1254,9 +1253,13 @@ static void do_work(connection *c) {
|
||||||
* here, instead of simply waiting for read() to return 0. */
|
* here, instead of simply waiting for read() to return 0. */
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (pa_iochannel_is_writable(c->io))
|
while (pa_iochannel_is_writable(c->io)) {
|
||||||
if (do_write(c) < 0)
|
int r = do_write(c);
|
||||||
|
if (r < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
if (r == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -168,7 +168,7 @@ static int do_write(struct connection *c) {
|
||||||
|
|
||||||
pa_memblockq_drop(c->output_memblockq, (size_t) r);
|
pa_memblockq_drop(c->output_memblockq, (size_t) r);
|
||||||
|
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called from main context */
|
/* Called from main context */
|
||||||
|
|
@ -178,9 +178,13 @@ static void do_work(struct connection *c) {
|
||||||
if (pa_iochannel_is_hungup(c->io))
|
if (pa_iochannel_is_hungup(c->io))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (pa_iochannel_is_writable(c->io))
|
while (pa_iochannel_is_writable(c->io)) {
|
||||||
if (do_write(c) < 0)
|
int r = do_write(c);
|
||||||
|
if (r < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
if (r == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -235,7 +235,7 @@ static int do_write(connection *c) {
|
||||||
|
|
||||||
pa_memblockq_drop(c->output_memblockq, (size_t) r);
|
pa_memblockq_drop(c->output_memblockq, (size_t) r);
|
||||||
|
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_work(connection *c) {
|
static void do_work(connection *c) {
|
||||||
|
|
@ -251,9 +251,13 @@ static void do_work(connection *c) {
|
||||||
if (!c->sink_input && pa_iochannel_is_hungup(c->io))
|
if (!c->sink_input && pa_iochannel_is_hungup(c->io))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (pa_iochannel_is_writable(c->io))
|
while (pa_iochannel_is_writable(c->io)) {
|
||||||
if (do_write(c) < 0)
|
int r = do_write(c);
|
||||||
|
if (r < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
if (r == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue