[PATCH] access/avio: report FASTSEEK capability based on scheme and seekability
Namit Chugh <[email protected]> Mon, 20 Apr 2026 03:45:43 +0530
| Newsgroups | gmane.comp.video.videolan.vlc.devel |
|---|---|
| Message-ID | <CAK7qhSTXdV+1H=BQY-J206UiOg-_h3J14HLc5sw+b53otzeciQ@mail.gmail.com> |
--===============2321055233363133826==
Content-Type: multipart/alternative; boundary="000000000000aa60b7064fd786ca"
--000000000000aa60b7064fd786ca
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
STREAM_CAN_FASTSEEK was hardcoded to false regardless of the
underlying source. For local files opened via libavformat, random
access is O(1) and fast seek should be advertised correctly =E2=80=94 VLC
uses this flag to decide whether to attempt seek-ahead buffering
optimisations.
The fix ties STREAM_CAN_FASTSEEK to two conditions: libavformat
reports the context as seekable, and the access scheme is "file".
Network schemes like http or rtsp can seek but not cheaply, so they
correctly continue to return false.
STREAM_CAN_SEEK is unchanged =E2=80=94 it already reads sys->context->seeka=
ble
directly and covers the general case.
--- a/modules/access/avio.c
+++ b/modules/access/avio.c
@@ -322,7 +322,8 @@ static int Control(stream_t *access, int query, va_list
args)
case STREAM_CAN_FASTSEEK:
b =3D va_arg(args, bool *);
- *b =3D false;
+ *b =3D sys->context->seekable &&
+ !strcmp(access->psz_name, "file");
return VLC_SUCCESS;
--000000000000aa60b7064fd786ca
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div dir=3D"ltr">STREAM_CAN_FASTSEEK was hardcoded to fals=
e regardless of the<br>underlying source. For local files opened via libavf=
ormat, random<br>access is O(1) and fast seek should be advertised correctl=
y =E2=80=94 VLC<br>uses this flag to decide whether to attempt seek-ahead b=
uffering<br>optimisations.<br><br>The fix ties STREAM_CAN_FASTSEEK to two c=
onditions: libavformat<br>reports the context as seekable, and the access s=
cheme is "file".<br>Network schemes like http or rtsp can seek bu=
t not cheaply, so they<br>correctly continue to return false.<br><br>STREAM=
_CAN_SEEK is unchanged =E2=80=94 it already reads sys->context->seeka=
ble<br>directly and covers the general case.<div><br></div><div>--- a/modul=
es/access/avio.c<br>+++ b/modules/access/avio.c<br>@@ -322,7 +322,8 @@ stat=
ic int Control(stream_t *access, int query, va_list args)<br>=C2=A0 =C2=A0 =
=C2=A0case STREAM_CAN_FASTSEEK:<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0b =3D =
va_arg(args, bool *);<br>- =C2=A0 =C2=A0 =C2=A0 =C2=A0*b =3D false;<br>+ =
=C2=A0 =C2=A0 =C2=A0 =C2=A0*b =3D sys->context->seekable &&<b=
r>+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 !strcmp(access->psz_name, =
"file");<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return VLC_SUCCESS;=
</div></div>
</div>
--000000000000aa60b7064fd786ca--
--===============2321055233363133826==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
vlc-devel mailing list
To unsubscribe or modify your subscription options:
https://mailman.videolan.org/listinfo/vlc-devel
--===============2321055233363133826==--