1
0
forked from mirrors/0ad

Remove unused OpenOggStream method

OpenOggStream was previously used to stream Ogg files directly from the
file system. It operated on raw file paths (OsPath) and assumed
uncompressed, unarchived files, which made it unsuitable for working
with files inside archives or VFS layers.

However, its usage has been fully replaced by OpenOggNonstream, which:
- Reads the entire file into memory (non-streaming),
- Works with virtual file systems (VFS),
- Supports both archived and compressed assets,

Is already used consistently across debug and release builds.

There are no remaining references to OpenOggStream in the codebase, so
this commit removes the unused function and its associated logic.
This commit is contained in:
trompetin17
2025-06-19 14:50:15 -05:00
parent 406565f3c4
commit 336ff333ed
2 changed files with 2 additions and 88 deletions
+1 -85
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2024 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -66,79 +66,6 @@ static Status LibErrorFromVorbis(int err)
}
}
//-----------------------------------------------------------------------------
class VorbisFileAdapter
{
public:
VorbisFileAdapter(const PFile& openedFile)
: file(openedFile)
, size(FileSize(openedFile->Pathname()))
, offset(0)
{
}
static size_t Read(void* bufferToFill, size_t itemSize, size_t numItems, void* context)
{
VorbisFileAdapter* adapter = static_cast<VorbisFileAdapter*>(context);
const off_t sizeRequested = numItems*itemSize;
const off_t sizeRemaining = adapter->size - adapter->offset;
const size_t sizeToRead = (size_t)std::min(sizeRequested, sizeRemaining);
io::Operation op(*adapter->file.get(), bufferToFill, sizeToRead, adapter->offset);
if(io::Run(op) == INFO::OK)
{
adapter->offset += sizeToRead;
return sizeToRead;
}
errno = EIO;
return 0;
}
static int Seek(void* context, ogg_int64_t offset, int whence)
{
VorbisFileAdapter* adapter = static_cast<VorbisFileAdapter*>(context);
off_t origin = 0;
switch(whence)
{
case SEEK_SET:
origin = 0;
break;
case SEEK_CUR:
origin = adapter->offset;
break;
case SEEK_END:
origin = adapter->size+1;
break;
NODEFAULT;
}
adapter->offset = Clamp(off_t(origin+offset), off_t(0), adapter->size);
return 0;
}
static int Close(void* context)
{
VorbisFileAdapter* adapter = static_cast<VorbisFileAdapter*>(context);
adapter->file.reset();
return 0; // return value is ignored
}
static long Tell(void* context)
{
VorbisFileAdapter* adapter = static_cast<VorbisFileAdapter*>(context);
return adapter->offset;
}
private:
PFile file;
off_t size;
off_t offset;
};
//-----------------------------------------------------------------------------
class VorbisBufferAdapter
@@ -315,17 +242,6 @@ private:
//-----------------------------------------------------------------------------
Status OpenOggStream(const OsPath& pathname, OggStreamPtr& stream)
{
PFile file(new File);
RETURN_STATUS_IF_ERR(file->Open(pathname, L'r'));
std::shared_ptr<OggStreamImpl<VorbisFileAdapter>> tmp = std::make_shared<OggStreamImpl<VorbisFileAdapter>>(VorbisFileAdapter(file));
RETURN_STATUS_IF_ERR(tmp->Open());
stream = tmp;
return INFO::OK;
}
Status OpenOggNonstream(const PIVFS& vfs, const VfsPath& pathname, OggStreamPtr& stream)
{
std::shared_ptr<u8> contents;
+1 -3
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2021 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -42,8 +42,6 @@ public:
typedef std::shared_ptr<OggStream> OggStreamPtr;
extern Status OpenOggStream(const OsPath& pathname, OggStreamPtr& stream);
/**
* A non-streaming OggStream (reading the whole file in advance)
* that can cope with archived/compressed files.