aviocat: Check for output write errors

Message ID 20170903101649.8025-1-martin@martin.st
State Committed
Commit f19fbfbdc637e08ad5c980807ede2d023f20c049
Headers show

Commit Message

Martin Storsjö Sept. 3, 2017, 10:16 a.m.
---
 tools/aviocat.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Luca Barbato Sept. 3, 2017, 2:26 p.m. | #1
On 03/09/2017 12:16, Martin Storsjö wrote:
> ---
>   tools/aviocat.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/tools/aviocat.c b/tools/aviocat.c
> index 3e49a61801..73104da174 100644
> --- a/tools/aviocat.c
> +++ b/tools/aviocat.c
> @@ -107,6 +107,11 @@ int main(int argc, char **argv)
>           if (n <= 0)
>               break;
>           avio_write(output, buf, n);
> +        if (output->error) {
> +            av_strerror(output->error, errbuf, sizeof(errbuf));
> +            fprintf(stderr, "Unable to write %s: %s\n", output_url, errbuf);
> +            break;
> +        }
>           stream_pos += n;
>           if (bps) {
>               avio_flush(output);
> 

Sure :)

Patch

diff --git a/tools/aviocat.c b/tools/aviocat.c
index 3e49a61801..73104da174 100644
--- a/tools/aviocat.c
+++ b/tools/aviocat.c
@@ -107,6 +107,11 @@  int main(int argc, char **argv)
         if (n <= 0)
             break;
         avio_write(output, buf, n);
+        if (output->error) {
+            av_strerror(output->error, errbuf, sizeof(errbuf));
+            fprintf(stderr, "Unable to write %s: %s\n", output_url, errbuf);
+            break;
+        }
         stream_pos += n;
         if (bps) {
             avio_flush(output);