use references to ogg_page instead of pointers

This commit is contained in:
Frédéric Mangano
2016-02-20 13:55:25 +01:00
parent a8a6552f29
commit 390c9268a7
2 changed files with 6 additions and 13 deletions

View File

@@ -33,14 +33,14 @@ void delete_tags(ogg::Reader *reader, opustags::ogg::Writer *writer, long select
s->type = ogg::UNKNOWN_STREAM;
// fall through
case ogg::RAW_READY:
writer->write_raw_page(s->current_page);
writer->write_raw_page(reader->current_page);
break;
case ogg::TAGS_READY:
// only streams selected at HEADER_READY reach this point
writer->write_tags(s->stream.serialno, ogg::Tags());
break;
case ogg::DATA_READY:
writer->write_page(s->current_page);
writer->write_page(reader->current_page);
break;
default:
;

View File

@@ -35,15 +35,7 @@ namespace ogg
// Called by Reader once a page was read.
// Return true if it's ready, false if it expects more data.
// In the latter case, Reader::read_page will keep reading.
bool page_in(ogg_page*);
// The structure is stored into the Reader, and the memory inside is
// managed by ogg_sync_state (maybe).
// It's not a big deal since it should be used right after read_page()
// was called, and is meant to be forwarded to the Writer.
// TODO make sure it's allocated as expected, because the libogg
// specification isn't entirely clear.
ogg_page *current_page;
bool page_in(const ogg_page&);
StreamState state;
StreamType type;
@@ -66,6 +58,7 @@ namespace ogg
std::istream input;
ogg_sync_state sync;
ogg_page current_page;
std::map<int, Stream> streams;
};
@@ -74,12 +67,12 @@ namespace ogg
Writer(std::ostream&&);
~Writer();
void write_page(ogg_page*);
void write_page(const ogg_page&);
// Write the page without even ensuring its page number is correct.
// It would be an efficient way to copy a stream identically, and also
// needed for write_page.
void write_raw_page(ogg_page*);
void write_raw_page(const ogg_page&);
void write_tags(int serialno, const Tags&);