mirror of https://github.com/PCSX2/pcsx2.git
CDVD: Purge AsyncFileReader interface
Everything goes through ThreadedFileReader now.
This commit is contained in:
parent
7587bb8a07
commit
d099f7afd6
|
@ -1,43 +0,0 @@
|
||||||
// SPDX-FileCopyrightText: 2002-2023 PCSX2 Dev Team
|
|
||||||
// SPDX-License-Identifier: LGPL-3.0+
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "common/Pcsx2Defs.h"
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
class Error;
|
|
||||||
|
|
||||||
class AsyncFileReader
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
AsyncFileReader() = default;
|
|
||||||
|
|
||||||
std::string m_filename;
|
|
||||||
|
|
||||||
u32 m_dataoffset = 0;
|
|
||||||
u32 m_blocksize = 2048;
|
|
||||||
|
|
||||||
public:
|
|
||||||
virtual ~AsyncFileReader(){};
|
|
||||||
|
|
||||||
virtual bool Open(std::string filename, Error* error) = 0;
|
|
||||||
|
|
||||||
virtual int ReadSync(void* pBuffer, u32 sector, u32 count) = 0;
|
|
||||||
|
|
||||||
virtual void BeginRead(void* pBuffer, u32 sector, u32 count) = 0;
|
|
||||||
virtual int FinishRead() = 0;
|
|
||||||
virtual void CancelRead() = 0;
|
|
||||||
|
|
||||||
virtual void Close() = 0;
|
|
||||||
|
|
||||||
virtual u32 GetBlockCount() const = 0;
|
|
||||||
|
|
||||||
virtual void SetBlockSize(u32 bytes) {}
|
|
||||||
virtual void SetDataOffset(u32 bytes) {}
|
|
||||||
|
|
||||||
const std::string& GetFilename() const { return m_filename; }
|
|
||||||
u32 GetBlockSize() const { return m_blocksize; }
|
|
||||||
};
|
|
|
@ -20,7 +20,7 @@ enum isoFlags
|
||||||
|
|
||||||
static constexpr u32 BlockDumpHeaderSize = 16;
|
static constexpr u32 BlockDumpHeaderSize = 16;
|
||||||
|
|
||||||
bool BlockdumpFileReader::DetectBlockdump(AsyncFileReader* reader)
|
bool BlockdumpFileReader::DetectBlockdump(ThreadedFileReader* reader)
|
||||||
{
|
{
|
||||||
u32 oldbs = reader->GetBlockSize();
|
u32 oldbs = reader->GetBlockSize();
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ public:
|
||||||
|
|
||||||
u32 GetBlockCount() const override;
|
u32 GetBlockCount() const override;
|
||||||
|
|
||||||
static bool DetectBlockdump(AsyncFileReader* reader);
|
static bool DetectBlockdump(ThreadedFileReader* reader);
|
||||||
|
|
||||||
s32 GetBlockOffset() { return m_blockofs; }
|
s32 GetBlockOffset() { return m_blockofs; }
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
// SPDX-License-Identifier: LGPL-3.0+
|
// SPDX-License-Identifier: LGPL-3.0+
|
||||||
|
|
||||||
#include "IsoFileFormats.h"
|
#include "IsoFileFormats.h"
|
||||||
#include "AsyncFileReader.h"
|
|
||||||
#include "CDVD/CDVD.h"
|
#include "CDVD/CDVD.h"
|
||||||
|
|
||||||
#include "common/Assertions.h"
|
#include "common/Assertions.h"
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// SPDX-FileCopyrightText: 2002-2023 PCSX2 Dev Team
|
// SPDX-FileCopyrightText: 2002-2023 PCSX2 Dev Team
|
||||||
// SPDX-License-Identifier: LGPL-3.0+
|
// SPDX-License-Identifier: LGPL-3.0+
|
||||||
|
|
||||||
#include "AsyncFileReader.h"
|
|
||||||
#include "CompressedFileReader.h"
|
#include "CompressedFileReader.h"
|
||||||
#include "ChdFileReader.h"
|
#include "ChdFileReader.h"
|
||||||
#include "CsoFileReader.h"
|
#include "CsoFileReader.h"
|
||||||
|
@ -14,7 +13,7 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
|
||||||
AsyncFileReader* CompressedFileReader::GetNewReader(const std::string& fileName)
|
ThreadedFileReader* CompressedFileReader::GetNewReader(const std::string& fileName)
|
||||||
{
|
{
|
||||||
if (!FileSystem::FileExists(fileName.c_str()))
|
if (!FileSystem::FileExists(fileName.c_str()))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
class ThreadedFileReader;
|
||||||
|
|
||||||
// Factory - creates an AsyncFileReader derived instance which can read a compressed file
|
// Factory - creates an AsyncFileReader derived instance which can read a compressed file
|
||||||
class CompressedFileReader
|
class CompressedFileReader
|
||||||
{
|
{
|
||||||
|
@ -12,7 +14,7 @@ public:
|
||||||
// If no matching handler is found, NULL is returned.
|
// If no matching handler is found, NULL is returned.
|
||||||
// The returned instance still needs ->Open(filename) before usage.
|
// The returned instance still needs ->Open(filename) before usage.
|
||||||
// Open(filename) may still fail.
|
// Open(filename) may still fail.
|
||||||
static AsyncFileReader* GetNewReader(const std::string& fileName);
|
static ThreadedFileReader* GetNewReader(const std::string& fileName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual ~CompressedFileReader() = 0;
|
virtual ~CompressedFileReader() = 0;
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
// SPDX-FileCopyrightText: 2002-2023 PCSX2 Dev Team
|
// SPDX-FileCopyrightText: 2002-2023 PCSX2 Dev Team
|
||||||
// SPDX-License-Identifier: LGPL-3.0+
|
// SPDX-License-Identifier: LGPL-3.0+
|
||||||
|
|
||||||
#include "AsyncFileReader.h"
|
#include "CDVD/CsoFileReader.h"
|
||||||
#include "CsoFileReader.h"
|
|
||||||
|
|
||||||
#include "common/Assertions.h"
|
#include "common/Assertions.h"
|
||||||
#include "common/Console.h"
|
#include "common/Console.h"
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
// SPDX-License-Identifier: LGPL-3.0+
|
// SPDX-License-Identifier: LGPL-3.0+
|
||||||
|
|
||||||
#include "CDVD/BlockdumpFileReader.h"
|
#include "CDVD/BlockdumpFileReader.h"
|
||||||
|
#include "CDVD/CompressedFileReader.h"
|
||||||
#include "CDVD/FlatFileReader.h"
|
#include "CDVD/FlatFileReader.h"
|
||||||
#include "CDVD/IsoFileFormats.h"
|
#include "CDVD/IsoFileFormats.h"
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
@ -316,13 +317,11 @@ bool InputIsoFile::Detect(bool readType)
|
||||||
{
|
{
|
||||||
m_type = ISOTYPE_ILLEGAL;
|
m_type = ISOTYPE_ILLEGAL;
|
||||||
|
|
||||||
AsyncFileReader* headpart = m_reader;
|
|
||||||
|
|
||||||
// First sanity check: no sane CD image has less than 16 sectors, since that's what
|
// First sanity check: no sane CD image has less than 16 sectors, since that's what
|
||||||
// we need simply to contain a TOC. So if the file size is not large enough to
|
// we need simply to contain a TOC. So if the file size is not large enough to
|
||||||
// accommodate that, it is NOT a CD image --->
|
// accommodate that, it is NOT a CD image --->
|
||||||
|
|
||||||
int sectors = headpart->GetBlockCount();
|
int sectors = m_reader->GetBlockCount();
|
||||||
|
|
||||||
if (sectors < 17)
|
if (sectors < 17)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -3,9 +3,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "CDVD.h"
|
#include "CDVD/CDVD.h"
|
||||||
#include "AsyncFileReader.h"
|
#include "CDVD/ThreadedFileReader.h"
|
||||||
#include "CompressedFileReader.h"
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -37,7 +36,7 @@ protected:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::string m_filename;
|
std::string m_filename;
|
||||||
AsyncFileReader* m_reader;
|
ThreadedFileReader* m_reader;
|
||||||
|
|
||||||
u32 m_current_lsn;
|
u32 m_current_lsn;
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,28 @@
|
||||||
// SPDX-FileCopyrightText: 2002-2023 PCSX2 Dev Team
|
// SPDX-FileCopyrightText: 2002-2024 PCSX2 Dev Team
|
||||||
// SPDX-License-Identifier: LGPL-3.0+
|
// SPDX-License-Identifier: LGPL-3.0+
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "AsyncFileReader.h"
|
#include "common/Pcsx2Defs.h"
|
||||||
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
|
|
||||||
|
class Error;
|
||||||
|
|
||||||
/// A file reader for use with compressed formats
|
/// A file reader for use with compressed formats
|
||||||
/// Calls decompression code on a separate thread to make a synchronous decompression API async
|
/// Calls decompression code on a separate thread to make a synchronous decompression API async
|
||||||
class ThreadedFileReader : public AsyncFileReader
|
class ThreadedFileReader
|
||||||
{
|
{
|
||||||
ThreadedFileReader(ThreadedFileReader&&) = delete;
|
ThreadedFileReader(ThreadedFileReader&&) = delete;
|
||||||
protected:
|
protected:
|
||||||
|
std::string m_filename;
|
||||||
|
|
||||||
|
u32 m_dataoffset = 0;
|
||||||
|
u32 m_blocksize = 2048;
|
||||||
|
|
||||||
struct Chunk
|
struct Chunk
|
||||||
{
|
{
|
||||||
/// Negative block IDs indicate invalid blocks
|
/// Negative block IDs indicate invalid blocks
|
||||||
|
@ -39,7 +46,6 @@ protected:
|
||||||
virtual void Close2() = 0;
|
virtual void Close2() = 0;
|
||||||
|
|
||||||
ThreadedFileReader();
|
ThreadedFileReader();
|
||||||
~ThreadedFileReader();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_amtRead;
|
int m_amtRead;
|
||||||
|
@ -96,12 +102,19 @@ private:
|
||||||
bool TryCachedRead(void*& buffer, u64& offset, u32& size, const std::lock_guard<std::mutex>&);
|
bool TryCachedRead(void*& buffer, u64& offset, u32& size, const std::lock_guard<std::mutex>&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool Open(std::string filename, Error* error) final override;
|
virtual ~ThreadedFileReader();
|
||||||
int ReadSync(void* pBuffer, u32 sector, u32 count) final override;
|
|
||||||
void BeginRead(void* pBuffer, u32 sector, u32 count) final override;
|
const std::string& GetFilename() const { return m_filename; }
|
||||||
int FinishRead() final override;
|
u32 GetBlockSize() const { return m_blocksize; }
|
||||||
void CancelRead() final override;
|
|
||||||
void Close() final override;
|
virtual u32 GetBlockCount() const = 0;
|
||||||
void SetBlockSize(u32 bytes) final override;
|
|
||||||
void SetDataOffset(u32 bytes) final override;
|
bool Open(std::string filename, Error* error);
|
||||||
|
int ReadSync(void* pBuffer, u32 sector, u32 count);
|
||||||
|
void BeginRead(void* pBuffer, u32 sector, u32 count);
|
||||||
|
int FinishRead();
|
||||||
|
void CancelRead();
|
||||||
|
void Close();
|
||||||
|
void SetBlockSize(u32 bytes);
|
||||||
|
void SetDataOffset(u32 bytes);
|
||||||
};
|
};
|
||||||
|
|
|
@ -140,7 +140,6 @@ set(pcsx2Sources
|
||||||
# Main pcsx2 header
|
# Main pcsx2 header
|
||||||
set(pcsx2Headers
|
set(pcsx2Headers
|
||||||
Achievements.h
|
Achievements.h
|
||||||
AsyncFileReader.h
|
|
||||||
Cache.h
|
Cache.h
|
||||||
Common.h
|
Common.h
|
||||||
Config.h
|
Config.h
|
||||||
|
|
|
@ -460,7 +460,6 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Achievements.h" />
|
<ClInclude Include="Achievements.h" />
|
||||||
<ClInclude Include="AsyncFileReader.h" />
|
|
||||||
<ClInclude Include="CDVD\BlockdumpFileReader.h" />
|
<ClInclude Include="CDVD\BlockdumpFileReader.h" />
|
||||||
<ClInclude Include="CDVD\CDVDdiscReader.h" />
|
<ClInclude Include="CDVD\CDVDdiscReader.h" />
|
||||||
<ClInclude Include="CDVD\CompressedFileReader.h" />
|
<ClInclude Include="CDVD\CompressedFileReader.h" />
|
||||||
|
|
|
@ -1628,9 +1628,6 @@
|
||||||
<ClInclude Include="x86\microVU_Profiler.h">
|
<ClInclude Include="x86\microVU_Profiler.h">
|
||||||
<Filter>System\Ps2\EmotionEngine\VU\Dynarec\microVU</Filter>
|
<Filter>System\Ps2\EmotionEngine\VU\Dynarec\microVU</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="AsyncFileReader.h">
|
|
||||||
<Filter>System\ISO</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="DebugTools\SymbolMap.h">
|
<ClInclude Include="DebugTools\SymbolMap.h">
|
||||||
<Filter>System\Ps2\Debug</Filter>
|
<Filter>System\Ps2\Debug</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|
Loading…
Reference in New Issue