diff options
author | wm4 <wm4@nowhere> | 2017-06-19 16:07:42 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2017-06-19 16:10:10 +0200 |
commit | e0c50289d6dc579bcf0eb8dbc9f0a68138d29aa8 (patch) | |
tree | 3524a549b24800630cbec31cbf55d7cc288f825b /stream | |
parent | 2e84934be7d419da91c2bc0682d71087439d66ad (diff) |
stream: change license to LGPL
All relevant authors have agreed.
There are two exceptions, patches by authors who could not be reached.
This commit tries to remove their copyright.
a0f08fbe: messes with the seeking code corner cases. The EOF flag logic
was changed at some point, and always had a flaky history (see e.g.
347cf972 50274ca3 70411f27 5999efb9 0d5e6084 ff08d0c3 2e2f77e3 de5566f0
9554a844, all which happened after that patch, MPlayer ones without that
patch). I claim that all of the copyright the patch might have added is
gone. Except the message in stream_seek(), which this commit removes.
The other code removed/changed in stream_seek() is probably not from
that patch, but it doesn't hurt to be sure, and also makes it more
readable. (It might change the behavior so that sometimes the eof flag
is set after a seek, but it doesn't matter here.)
2aa6acd9: it looks like the seek_forward() modified by this patch was
later moved to stream.c and renamed to stream_skip_read() in a790f2133.
(Looking closer at it, it was actually modified again a bunch of times,
fixing the logic.) I rewrote it in this commit. The code ended up rather
similar, which probably could lead to doubts whether this was done
properly, but I guess the reader of this will just have to believe me. I
knew what stream_skip_read() was supposed to do (which was reinforced
when I tried to replace it on the caller side), without reading the
pre-existing code in detail. I had to "relearn" the logic how buf_pos
and bug_len work - it was actually easy to see from stream_read_char()
how to skip the data, essentially by generalizing its logic from 1 byte
to N bytes. From the old code I only "used" the fact that it's obviously
a while(len>0) look, that has to call stream_fill_buffer repeatedly to
make progress. At first I actually didn't use stream_fill_buffer_by(),
but the variant without _by, but readded it when I checked why the old
code used it (see cd7ec016e7). This has to be good enough. In the end,
it's hard to argue that this could be implemented in a way not using
such a loop.
Other than this, I could add the usual remarks about how this code was
not modularized in the past, and how stream.c contained DVD code, and
how this was later modularized, moving the copyright to other files, and
so on. Also, if someone wrote a stream module, and was not asked about
LGPL relicensing, we don't consider the entry in stream_list[]
copyrightable.
Diffstat (limited to 'stream')
-rw-r--r-- | stream/stream.c | 40 | ||||
-rw-r--r-- | stream/stream.h | 14 |
2 files changed, 26 insertions, 28 deletions
diff --git a/stream/stream.c b/stream/stream.c index 2636c16248..d4dea4486f 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -1,18 +1,18 @@ /* * This file is part of mpv. * - * mpv is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * mpv is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * * mpv is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with mpv. If not, see <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU Lesser General Public + * License along with mpv. If not, see <http://www.gnu.org/licenses/>. */ #include <stdio.h> @@ -495,19 +495,21 @@ int stream_write_buffer(stream_t *s, unsigned char *buf, int len) return rd; } +// Drop len bytes form input, possibly reading more until all is skipped. If +// EOF or an error was encountered before all could be skipped, return false, +// otherwise return true. static bool stream_skip_read(struct stream *s, int64_t len) { while (len > 0) { - int x = s->buf_len - s->buf_pos; - if (x == 0) { - if (!stream_fill_buffer_by(s, len)) - return false; // EOF - x = s->buf_len - s->buf_pos; + unsigned int left = s->buf_len - s->buf_pos; + if (!left) { + if (!stream_fill_buffer_by(s, left)) + return false; + continue; } - if (x > len) - x = len; - s->buf_pos += x; - len -= x; + unsigned skip = MPMIN(len, left); + s->buf_pos += skip; + len -= skip; } return true; } @@ -581,11 +583,7 @@ bool stream_seek(stream_t *s, int64_t pos) return false; } - bool r = pos >= s->pos && stream_skip_read(s, pos - s->pos); - if (!r) - MP_VERBOSE(s, "Seek to/past EOF: no buffer preloaded.\n"); - s->eof = 0; - return r; + return stream_skip_read(s, pos - stream_tell(s)); } bool stream_skip(stream_t *s, int64_t len) diff --git a/stream/stream.h b/stream/stream.h index cc47184ea6..ba2b0ca2af 100644 --- a/stream/stream.h +++ b/stream/stream.h @@ -1,18 +1,18 @@ /* * This file is part of mpv. * - * mpv is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * mpv is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * * mpv is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License along - * with mpv. If not, see <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU Lesser General Public + * License along with mpv. If not, see <http://www.gnu.org/licenses/>. */ #ifndef MPLAYER_STREAM_H |