mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-01 22:58:47 -04:00
padsp: Fix flush and improve error handling
read() can return a number of bytes read less than k in addition, handle EAGAIN and EOF CID 1137981
This commit is contained in:
parent
114a429cf4
commit
c99efbffd6
1 changed files with 9 additions and 2 deletions
|
|
@ -1768,11 +1768,18 @@ static int dsp_flush_fd(int fd) {
|
|||
while (l > 0) {
|
||||
char buf[1024];
|
||||
size_t k;
|
||||
ssize_t r;
|
||||
|
||||
k = (size_t) l > sizeof(buf) ? sizeof(buf) : (size_t) l;
|
||||
if (read(fd, buf, k) < 0)
|
||||
r = read(fd, buf, k);
|
||||
if (r < 0) {
|
||||
if (errno == EAGAIN)
|
||||
break;
|
||||
debug(DEBUG_LEVEL_NORMAL, __FILE__": read(): %s\n", strerror(errno));
|
||||
l -= k;
|
||||
return -1;
|
||||
} else if (r == 0)
|
||||
break;
|
||||
l -= r;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue