Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
7e3eaa59
Commit
7e3eaa59
authored
Jan 27, 2020
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib/xiph/OggSyncState: keep track of the Reader offset
parent
6fe4068c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
2 deletions
+31
-2
OggSyncState.cxx
src/lib/xiph/OggSyncState.cxx
+11
-2
OggSyncState.hxx
src/lib/xiph/OggSyncState.hxx
+20
-0
No files found.
src/lib/xiph/OggSyncState.cxx
View file @
7e3eaa59
...
...
@@ -40,8 +40,13 @@ OggSyncState::ExpectPage(ogg_page &page)
{
while
(
true
)
{
int
r
=
ogg_sync_pageout
(
&
oy
,
&
page
);
if
(
r
!=
0
)
if
(
r
!=
0
)
{
if
(
r
>
0
)
{
start_offset
=
offset
;
offset
+=
r
;
}
return
r
>
0
;
}
if
(
!
Feed
(
1024
))
return
false
;
...
...
@@ -66,12 +71,16 @@ OggSyncState::ExpectPageSeek(ogg_page &page)
while
(
true
)
{
int
r
=
ogg_sync_pageseek
(
&
oy
,
&
page
);
if
(
r
>
0
)
if
(
r
>
0
)
{
start_offset
=
offset
;
offset
+=
r
;
return
true
;
}
if
(
r
<
0
)
{
/* skipped -r bytes */
size_t
nbytes
=
-
r
;
offset
+=
nbytes
;
if
(
nbytes
>
remaining_skipped
)
/* still no ogg page - we lost our
patience, abort */
...
...
src/lib/xiph/OggSyncState.hxx
View file @
7e3eaa59
...
...
@@ -23,6 +23,7 @@
#include <ogg/ogg.h>
#include <stddef.h>
#include <stdint.h>
class
Reader
;
...
...
@@ -34,6 +35,17 @@ class OggSyncState {
Reader
&
reader
;
/**
* Keeps track of the end offset of the most recently returned
* page.
*/
uint64_t
offset
=
0
;
/**
* The start offset of the most recently returned page.
*/
uint64_t
start_offset
=
0
;
public
:
explicit
OggSyncState
(
Reader
&
_reader
)
:
reader
(
_reader
)
{
...
...
@@ -51,6 +63,14 @@ public:
ogg_sync_reset
(
&
oy
);
}
void
SetOffset
(
uint64_t
_offset
)
noexcept
{
offset
=
_offset
;
}
uint64_t
GetStartOffset
()
const
noexcept
{
return
start_offset
;
}
bool
Feed
(
size_t
size
);
bool
ExpectPage
(
ogg_page
&
page
);
...
...
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