From 336ff333ed85c7dd941faaf538fc9b6f9393d990 Mon Sep 17 00:00:00 2001 From: trompetin17 Date: Thu, 19 Jun 2025 14:50:15 -0500 Subject: [PATCH] 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. --- source/soundmanager/data/ogg.cpp | 86 +------------------------------- source/soundmanager/data/ogg.h | 4 +- 2 files changed, 2 insertions(+), 88 deletions(-) diff --git a/source/soundmanager/data/ogg.cpp b/source/soundmanager/data/ogg.cpp index 6a0635b9cc..2fff8f4a89 100644 --- a/source/soundmanager/data/ogg.cpp +++ b/source/soundmanager/data/ogg.cpp @@ -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(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(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(context); - adapter->file.reset(); - return 0; // return value is ignored - } - - static long Tell(void* context) - { - VorbisFileAdapter* adapter = static_cast(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> tmp = std::make_shared>(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 contents; diff --git a/source/soundmanager/data/ogg.h b/source/soundmanager/data/ogg.h index 34612bd394..889abe0dba 100644 --- a/source/soundmanager/data/ogg.h +++ b/source/soundmanager/data/ogg.h @@ -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 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.