summaryrefslogtreecommitdiff
path: root/src/lib/xiph
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2016-05-09 16:29:04 +0200
committerMax Kellermann <max@duempel.org>2016-05-09 16:29:04 +0200
commitf26159a0e39b3d8c031d62db57f2313a95c7107d (patch)
treec7957fd917660fef902ddae7c2e01ff1609c58bf /src/lib/xiph
parent675e8667c21cb342cc4e07e30acf011a7cf44ed8 (diff)
lib/xiph/OggUtil: move code into class OggSyncState
Diffstat (limited to 'src/lib/xiph')
-rw-r--r--src/lib/xiph/OggSyncState.cxx (renamed from src/lib/xiph/OggUtil.cxx)20
-rw-r--r--src/lib/xiph/OggSyncState.hxx23
-rw-r--r--src/lib/xiph/OggUtil.hxx70
3 files changed, 17 insertions, 96 deletions
diff --git a/src/lib/xiph/OggUtil.cxx b/src/lib/xiph/OggSyncState.cxx
index fa102fc88..ec60bf2f4 100644
--- a/src/lib/xiph/OggUtil.cxx
+++ b/src/lib/xiph/OggSyncState.cxx
@@ -18,11 +18,11 @@
*/
#include "config.h"
-#include "OggUtil.hxx"
+#include "OggSyncState.hxx"
#include "fs/io/Reader.hxx"
bool
-OggFeed(ogg_sync_state &oy, Reader &reader, size_t size)
+OggSyncState::Feed(size_t size)
{
char *buffer = ogg_sync_buffer(&oy, size);
if (buffer == nullptr)
@@ -37,23 +37,23 @@ OggFeed(ogg_sync_state &oy, Reader &reader, size_t size)
}
bool
-OggExpectPage(ogg_sync_state &oy, ogg_page &page, Reader &reader)
+OggSyncState::ExpectPage(ogg_page &page)
{
while (true) {
int r = ogg_sync_pageout(&oy, &page);
if (r != 0)
return r > 0;
- if (!OggFeed(oy, reader, 1024))
+ if (!Feed(1024))
return false;
}
}
bool
-OggExpectPageIn(ogg_sync_state &oy, ogg_stream_state &os, Reader &reader)
+OggSyncState::ExpectPageIn(ogg_stream_state &os)
{
ogg_page page;
- if (!OggExpectPage(oy, page, reader))
+ if (!ExpectPage(page))
return false;
ogg_stream_pagein(&os, &page);
@@ -61,7 +61,7 @@ OggExpectPageIn(ogg_sync_state &oy, ogg_stream_state &os, Reader &reader)
}
bool
-OggExpectPageSeek(ogg_sync_state &oy, ogg_page &page, Reader &reader)
+OggSyncState::ExpectPageSeek(ogg_page &page)
{
size_t remaining_skipped = 32768;
@@ -82,16 +82,16 @@ OggExpectPageSeek(ogg_sync_state &oy, ogg_page &page, Reader &reader)
continue;
}
- if (!OggFeed(oy, reader, 1024))
+ if (!Feed(1024))
return false;
}
}
bool
-OggExpectPageSeekIn(ogg_sync_state &oy, ogg_stream_state &os, Reader &reader)
+OggSyncState::ExpectPageSeekIn(ogg_stream_state &os)
{
ogg_page page;
- if (!OggExpectPageSeek(oy, page, reader))
+ if (!ExpectPageSeek(page))
return false;
ogg_stream_pagein(&os, &page);
diff --git a/src/lib/xiph/OggSyncState.hxx b/src/lib/xiph/OggSyncState.hxx
index 10eef11eb..329510af1 100644
--- a/src/lib/xiph/OggSyncState.hxx
+++ b/src/lib/xiph/OggSyncState.hxx
@@ -21,12 +21,13 @@
#define MPD_OGG_SYNC_STATE_HXX
#include "check.h"
-#include "OggUtil.hxx"
#include <ogg/ogg.h>
#include <stddef.h>
+class Reader;
+
/**
* Wrapper for an ogg_sync_state.
*/
@@ -52,25 +53,15 @@ public:
ogg_sync_reset(&oy);
}
- bool Feed(size_t size) {
- return OggFeed(oy, reader, size);
- }
+ bool Feed(size_t size);
- bool ExpectPage(ogg_page &page) {
- return OggExpectPage(oy, page, reader);
- }
+ bool ExpectPage(ogg_page &page);
- bool ExpectPageIn(ogg_stream_state &os) {
- return OggExpectPageIn(oy, os, reader);
- }
+ bool ExpectPageIn(ogg_stream_state &os);
- bool ExpectPageSeek(ogg_page &page) {
- return OggExpectPageSeek(oy, page, reader);
- }
+ bool ExpectPageSeek(ogg_page &page);
- bool ExpectPageSeekIn(ogg_stream_state &os) {
- return OggExpectPageSeekIn(oy, os, reader);
- }
+ bool ExpectPageSeekIn(ogg_stream_state &os);
};
#endif
diff --git a/src/lib/xiph/OggUtil.hxx b/src/lib/xiph/OggUtil.hxx
deleted file mode 100644
index bd3cb2f23..000000000
--- a/src/lib/xiph/OggUtil.hxx
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2003-2016 The Music Player Daemon Project
- * http://www.musicpd.org
- *
- * This program 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.
- *
- * This program 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.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef MPD_OGG_UTIL_HXX
-#define MPD_OGG_UTIL_HXX
-
-#include "check.h"
-
-#include <ogg/ogg.h>
-
-#include <stddef.h>
-
-class Reader;
-
-/**
- * Feed data from the #InputStream into the #ogg_sync_state.
- *
- * @return false on error or end-of-file
- */
-bool
-OggFeed(ogg_sync_state &oy, Reader &reader, size_t size);
-
-/**
- * Feed into the #ogg_sync_state until a page gets available. Garbage
- * data at the beginning is considered a fatal error.
- *
- * @return true if a page is available
- */
-bool
-OggExpectPage(ogg_sync_state &oy, ogg_page &page, Reader &reader);
-
-/**
- * Combines OggExpectPage() and ogg_stream_pagein().
- *
- * @return true if a page was delivered to the stream
- */
-bool
-OggExpectPageIn(ogg_sync_state &oy, ogg_stream_state &os, Reader &reader);
-
-/**
- * Like OggExpectPage(), but allow skipping garbage (after seeking).
- */
-bool
-OggExpectPageSeek(ogg_sync_state &oy, ogg_page &page, Reader &reader);
-
-/**
- * Combines OggExpectPageSeek() and ogg_stream_pagein().
- *
- * @return true if a page was delivered to the stream
- */
-bool
-OggExpectPageSeekIn(ogg_sync_state &oy, ogg_stream_state &os, Reader &reader);
-
-#endif