Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Libretro
Lutro
Commits
edf4096e
Unverified
Commit
edf4096e
authored
Mar 28, 2021
by
Jake Stine
Committed by
GitHub
Mar 28, 2021
Browse files
audio: avoid redundant calls to fseek (#185)
The overhead of fseek internally is unchecked and non-trivial.
parent
92d94da8
Changes
1
Hide whitespace changes
Inline
Side-by-side
decoder.c
View file @
edf4096e
...
...
@@ -244,6 +244,15 @@ bool decWav_seek(dec_WavData *data, intmax_t samplepos)
}
intmax_t
bytepos
=
samplepos
*
bps
;
// spurious calls to fseek have overhead, so early out if the internal managed
// seek pos matches
if
(
data
->
pos
==
bytepos
)
{
assert
(
ftell
(
data
->
fp
)
==
WAV_HEADER_SIZE
+
bytepos
);
return
1
;
}
if
(
fseek
(
data
->
fp
,
WAV_HEADER_SIZE
+
bytepos
,
SEEK_SET
))
{
// logging here could be unnecessarily spammy. If we add a log it should be gated by
...
...
@@ -251,7 +260,7 @@ bool decWav_seek(dec_WavData *data, intmax_t samplepos)
//fprintf(stderr, "WAV decoder seek failed: %s\n", strerror(errno));
return
0
;
}
data
->
pos
=
samplepos
*
bp
s
;
data
->
pos
=
bytepo
s
;
return
1
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment