2016-04-13 06:07:23 +00:00
|
|
|
#ifndef __URDE_CDVDFILE_HPP__
|
|
|
|
#define __URDE_CDVDFILE_HPP__
|
2015-08-23 06:42:29 +00:00
|
|
|
|
|
|
|
#include "RetroTypes.hpp"
|
|
|
|
|
2016-03-07 03:12:32 +00:00
|
|
|
#include <thread>
|
|
|
|
#include <mutex>
|
|
|
|
#include <condition_variable>
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
namespace urde
|
2015-08-23 06:42:29 +00:00
|
|
|
{
|
|
|
|
|
2016-02-11 19:18:14 +00:00
|
|
|
static const char* DecodeARAMFile(const char* name)
|
|
|
|
{
|
|
|
|
return (strncmp(name, "aram:", 5) == 0 ? name + 5 : name);
|
|
|
|
}
|
2015-08-23 06:42:29 +00:00
|
|
|
|
2015-11-21 01:16:07 +00:00
|
|
|
enum class ESeekOrigin
|
2015-08-23 06:42:29 +00:00
|
|
|
{
|
2015-11-21 01:16:07 +00:00
|
|
|
Begin = 0,
|
|
|
|
Cur = 1,
|
|
|
|
End = 2
|
2015-08-23 06:42:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct DVDFileInfo;
|
2015-10-29 07:52:15 +00:00
|
|
|
class IDvdRequest;
|
2015-08-23 06:42:29 +00:00
|
|
|
|
|
|
|
class CDvdFile
|
|
|
|
{
|
2015-08-23 23:58:07 +00:00
|
|
|
friend class CResLoader;
|
2016-03-07 03:12:32 +00:00
|
|
|
friend class CFileDvdRequest;
|
|
|
|
static hecl::ProjectPath m_DvdRoot;
|
|
|
|
static std::thread m_WorkerThread;
|
|
|
|
static std::mutex m_WorkerMutex;
|
|
|
|
static std::condition_variable m_WorkerCV;
|
2016-03-07 22:48:54 +00:00
|
|
|
static std::mutex m_WaitMutex;
|
2016-03-07 03:12:32 +00:00
|
|
|
static bool m_WorkerRun;
|
|
|
|
static std::vector<std::shared_ptr<IDvdRequest>> m_RequestQueue;
|
|
|
|
static void WorkerProc();
|
|
|
|
|
|
|
|
std::string x18_path;
|
|
|
|
athena::io::FileReader m_reader;
|
|
|
|
|
2015-08-23 06:42:29 +00:00
|
|
|
public:
|
2016-03-07 03:12:32 +00:00
|
|
|
static void Initialize(const hecl::ProjectPath& path);
|
|
|
|
static void Shutdown();
|
|
|
|
|
|
|
|
CDvdFile(const char* path)
|
|
|
|
: x18_path(path), m_reader(hecl::ProjectPath(m_DvdRoot, path).getAbsolutePath()) {}
|
|
|
|
void UpdateFilePos(int pos)
|
|
|
|
{
|
|
|
|
m_reader.seek(pos, athena::SeekOrigin::Begin);
|
|
|
|
}
|
|
|
|
static bool FileExists(const char* path)
|
|
|
|
{
|
|
|
|
return hecl::ProjectPath(m_DvdRoot, path).getPathType() != hecl::ProjectPath::Type::File;
|
|
|
|
}
|
|
|
|
void CloseFile()
|
|
|
|
{
|
|
|
|
m_reader.close();
|
|
|
|
}
|
|
|
|
std::shared_ptr<IDvdRequest> AsyncSeekRead(void* buf, u32 len, ESeekOrigin whence, int off);
|
|
|
|
void SyncSeekRead(void* buf, u32 len, ESeekOrigin whence, int offset)
|
|
|
|
{
|
|
|
|
m_reader.seek(offset, athena::SeekOrigin(whence));
|
|
|
|
m_reader.readBytesToBuf(buf, len);
|
|
|
|
}
|
|
|
|
std::shared_ptr<IDvdRequest> AsyncRead(void* buf, u32 len)
|
|
|
|
{
|
|
|
|
return AsyncSeekRead(buf, len, ESeekOrigin::Cur, 0);
|
|
|
|
}
|
|
|
|
void SyncRead(void* buf, u32 len)
|
|
|
|
{
|
|
|
|
m_reader.readBytesToBuf(buf, len);
|
|
|
|
}
|
2016-03-08 22:51:13 +00:00
|
|
|
u64 Length() {return m_reader.length();}
|
2015-08-23 06:42:29 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-04-13 06:07:23 +00:00
|
|
|
#endif // __URDE_CDVDFILE_HPP__
|