mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 10:42:36 +01:00
Fix issue from #567 that stopped videos from working. Clean up some code.
This commit is contained in:
parent
6bd044f9be
commit
82536b298c
@ -153,13 +153,7 @@ bool rFile::Open(const std::string &filename, rFile::OpenMode mode, int access)
|
||||
|
||||
bool rFile::Exists(const std::string &file)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
std::wstring wstr = ConvertUTF8ToWString(file);
|
||||
return GetFileAttributes(wstr.c_str()) != 0xFFFFFFFF;
|
||||
#else
|
||||
struct stat buffer;
|
||||
return (stat (file.c_str(), &buffer) == 0);
|
||||
#endif
|
||||
rExists(file);
|
||||
}
|
||||
|
||||
bool rFile::IsOpened() const
|
||||
@ -215,6 +209,27 @@ bool rRmdir(const std::string &dir)
|
||||
#endif
|
||||
}
|
||||
|
||||
bool rRename(const std::string &from, const std::string &to)
|
||||
{
|
||||
// TODO: Deal with case-sensitivity
|
||||
#ifdef _WIN32
|
||||
return (MoveFile(ConvertUTF8ToWString(from).c_str(), ConvertUTF8ToWString(to).c_str()) == TRUE);
|
||||
#else
|
||||
return (0 == rename(from.c_str(), to.c_str()));
|
||||
#endif
|
||||
}
|
||||
|
||||
bool rExists(const std::string &file)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
std::wstring wstr = ConvertUTF8ToWString(file);
|
||||
return GetFileAttributes(wstr.c_str()) != 0xFFFFFFFF;
|
||||
#else
|
||||
struct stat buffer;
|
||||
return (stat (file.c_str(), &buffer) == 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool rDirExists(const std::string &path)
|
||||
{
|
||||
return wxDirExists(fmt::FromUTF8(path));
|
||||
@ -288,8 +303,6 @@ bool rDir::GetNext(std::string *filename) const
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
rFileName::rFileName()
|
||||
{
|
||||
handle = reinterpret_cast<void*>(new wxFileName());
|
||||
|
@ -45,6 +45,8 @@ std::string rGetCwd();
|
||||
bool rRmdir(const std::string& dir);
|
||||
bool rMkdir(const std::string& dir);
|
||||
bool rMkpath(const std::string& path);
|
||||
bool rRename(const std::string &from, const std::string &to);
|
||||
bool rExists(const std::string &path);
|
||||
bool rDirExists(const std::string &path);
|
||||
bool rFileExists(const std::string &path);
|
||||
bool rRemoveFile(const std::string &path);
|
||||
|
@ -8,6 +8,9 @@ vfsDir::vfsDir()
|
||||
: vfsDirBase(nullptr)
|
||||
, m_stream(nullptr)
|
||||
{
|
||||
// TODO: proper implementation
|
||||
// m_stream is nullptr here. So open root until a proper dir is given
|
||||
Open("/");
|
||||
}
|
||||
|
||||
vfsDir::vfsDir(const std::string& path)
|
||||
@ -33,7 +36,7 @@ bool vfsDir::Create(const std::string& path)
|
||||
|
||||
bool vfsDir::IsExists(const std::string& path) const
|
||||
{
|
||||
return m_stream->IsExists(path); // Crash (Access violation reading location 0x0000000000000000)
|
||||
return m_stream->IsExists(path);
|
||||
}
|
||||
|
||||
const std::vector<DirEntryInfo>& vfsDir::GetEntries() const
|
||||
|
@ -159,31 +159,31 @@ int cellVpostExec(u32 handle, const u32 inPicBuff_addr, const mem_ptr_t<CellVpos
|
||||
picInfo->reserved2 = 0;
|
||||
|
||||
u64 stamp0 = get_system_time();
|
||||
auto pY = std::unique_ptr<u8[]>{ new u8[w*h] }.get(); // color planes
|
||||
auto pU = std::unique_ptr<u8[]>{ new u8[w*h/4] }.get();
|
||||
auto pV = std::unique_ptr<u8[]>{ new u8[w*h/4] }.get();
|
||||
auto pA = std::unique_ptr<u8[]>{ new u8[w*h] }.get();
|
||||
auto res = std::unique_ptr<u32[]>{ new u32[ow*oh*4] }.get(); // RGBA interleaved output
|
||||
std::unique_ptr<u8[]> pY(new u8[w*h]); // color planes
|
||||
std::unique_ptr<u8[]> pU(new u8[w*h/4]);
|
||||
std::unique_ptr<u8[]> pV(new u8[w*h/4]);
|
||||
std::unique_ptr<u8[]> pA(new u8[w*h]);
|
||||
std::unique_ptr<u32[]> res(new u32[ow*oh*4]); // RGBA interleaved output
|
||||
|
||||
if (!Memory.CopyToReal(pY, inPicBuff_addr, w*h))
|
||||
if (!Memory.CopyToReal(pY.get(), inPicBuff_addr, w*h))
|
||||
{
|
||||
cellVpost->Error("cellVpostExec: data copying failed(pY)");
|
||||
Emu.Pause();
|
||||
}
|
||||
|
||||
if (!Memory.CopyToReal(pU, inPicBuff_addr + w*h, w*h/4))
|
||||
if (!Memory.CopyToReal(pU.get(), inPicBuff_addr + w*h, w*h/4))
|
||||
{
|
||||
cellVpost->Error("cellVpostExec: data copying failed(pU)");
|
||||
Emu.Pause();
|
||||
}
|
||||
|
||||
if (!Memory.CopyToReal(pV, inPicBuff_addr + w*h + w*h/4, w*h/4))
|
||||
if (!Memory.CopyToReal(pV.get(), inPicBuff_addr + w*h + w*h/4, w*h/4))
|
||||
{
|
||||
cellVpost->Error("cellVpostExec: data copying failed(pV)");
|
||||
Emu.Pause();
|
||||
}
|
||||
|
||||
memset(pA, (const u8)ctrlParam->outAlpha, w*h);
|
||||
memset(pA.get(), (const u8)ctrlParam->outAlpha, w*h);
|
||||
|
||||
u64 stamp1 = get_system_time();
|
||||
|
||||
@ -191,9 +191,9 @@ int cellVpostExec(u32 handle, const u32 inPicBuff_addr, const mem_ptr_t<CellVpos
|
||||
|
||||
u64 stamp2 = get_system_time();
|
||||
|
||||
u8* in_data[4] = { pY, pU, pV, pA };
|
||||
u8* in_data[4] = { pY.get(), pU.get(), pV.get(), pA.get() };
|
||||
int in_line[4] = { w, w/2, w/2, w };
|
||||
u8* out_data[4] = { (u8*)res, NULL, NULL, NULL };
|
||||
u8* out_data[4] = { (u8*)res.get(), NULL, NULL, NULL };
|
||||
int out_line[4] = { static_cast<int>(ow*4), 0, 0, 0 };
|
||||
|
||||
sws_scale(sws, in_data, in_line, 0, h, out_data, out_line);
|
||||
@ -202,7 +202,7 @@ int cellVpostExec(u32 handle, const u32 inPicBuff_addr, const mem_ptr_t<CellVpos
|
||||
|
||||
u64 stamp3 = get_system_time();
|
||||
|
||||
if (!Memory.CopyFromReal(outPicBuff_addr, res, ow*oh*4))
|
||||
if (!Memory.CopyFromReal(outPicBuff_addr, res.get(), ow*oh*4))
|
||||
{
|
||||
cellVpost->Error("cellVpostExec: data copying failed(result)");
|
||||
Emu.Pause();
|
||||
|
@ -19,17 +19,9 @@ enum
|
||||
IDFlag_Dir = 2,
|
||||
};
|
||||
|
||||
struct FsRingBuffer
|
||||
{
|
||||
u64 m_ringbuf_size;
|
||||
u64 m_block_size;
|
||||
u64 m_transfer_rate;
|
||||
u32 m_copy;
|
||||
};
|
||||
|
||||
struct FsRingBufferConfig
|
||||
{
|
||||
FsRingBuffer m_ring_buffer;
|
||||
CellFsRingBuffer m_ring_buffer; // Currently unused after assignment
|
||||
u32 m_buffer;
|
||||
u64 m_fs_status;
|
||||
u64 m_regid;
|
||||
@ -41,15 +33,9 @@ struct FsRingBufferConfig
|
||||
, m_regid(0)
|
||||
, m_alloc_mem_size(0)
|
||||
, m_current_addr(0)
|
||||
{
|
||||
memset(&m_ring_buffer, 0, sizeof(FsRingBuffer));
|
||||
}
|
||||
, m_ring_buffer() { }
|
||||
|
||||
~FsRingBufferConfig()
|
||||
{
|
||||
memset(&m_ring_buffer, 0, sizeof(FsRingBuffer));
|
||||
}
|
||||
} m_fs_config;
|
||||
} fs_config;
|
||||
|
||||
|
||||
s32 cellFsOpen(u32 path_addr, s32 flags, mem32_t fd, mem32_t arg, u64 size)
|
||||
@ -563,22 +549,17 @@ s32 cellFsStReadInit(u32 fd, mem_ptr_t<CellFsRingBuffer> ringbuf)
|
||||
if(!ringbuf.IsGood())
|
||||
return CELL_EFAULT;
|
||||
|
||||
FsRingBuffer& buffer = m_fs_config.m_ring_buffer;
|
||||
fs_config.m_ring_buffer = *ringbuf;
|
||||
|
||||
buffer.m_block_size = ringbuf->block_size;
|
||||
buffer.m_copy = ringbuf->copy;
|
||||
buffer.m_ringbuf_size = ringbuf->ringbuf_size;
|
||||
buffer.m_transfer_rate = ringbuf->transfer_rate;
|
||||
|
||||
if(buffer.m_ringbuf_size < 0x40000000) // If the size is less than 1MB
|
||||
m_fs_config.m_alloc_mem_size = ((ringbuf->ringbuf_size + 64 * 1024 - 1) / (64 * 1024)) * (64 * 1024);
|
||||
m_fs_config.m_alloc_mem_size = ((ringbuf->ringbuf_size + 1024 * 1024 - 1) / (1024 * 1024)) * (1024 * 1024);
|
||||
if(ringbuf->ringbuf_size < 0x40000000) // If the size is less than 1MB
|
||||
fs_config.m_alloc_mem_size = ((ringbuf->ringbuf_size + 64 * 1024 - 1) / (64 * 1024)) * (64 * 1024);
|
||||
fs_config.m_alloc_mem_size = ((ringbuf->ringbuf_size + 1024 * 1024 - 1) / (1024 * 1024)) * (1024 * 1024);
|
||||
|
||||
// alloc memory
|
||||
m_fs_config.m_buffer = Memory.Alloc(m_fs_config.m_alloc_mem_size, 1024);
|
||||
memset(Memory + m_fs_config.m_buffer, 0, m_fs_config.m_alloc_mem_size);
|
||||
fs_config.m_buffer = Memory.Alloc(fs_config.m_alloc_mem_size, 1024);
|
||||
memset(Memory + fs_config.m_buffer, 0, fs_config.m_alloc_mem_size);
|
||||
|
||||
m_fs_config.m_fs_status = CELL_FS_ST_INITIALIZED;
|
||||
fs_config.m_fs_status = CELL_FS_ST_INITIALIZED;
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
@ -590,8 +571,8 @@ s32 cellFsStReadFinish(u32 fd)
|
||||
vfsStream* file;
|
||||
if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH;
|
||||
|
||||
Memory.Free(m_fs_config.m_buffer);
|
||||
m_fs_config.m_fs_status = CELL_FS_ST_NOT_INITIALIZED;
|
||||
Memory.Free(fs_config.m_buffer);
|
||||
fs_config.m_fs_status = CELL_FS_ST_NOT_INITIALIZED;
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
@ -606,15 +587,10 @@ s32 cellFsStReadGetRingBuf(u32 fd, mem_ptr_t<CellFsRingBuffer> ringbuf)
|
||||
if(!ringbuf.IsGood())
|
||||
return CELL_EFAULT;
|
||||
|
||||
FsRingBuffer& buffer = m_fs_config.m_ring_buffer;
|
||||
*ringbuf = fs_config.m_ring_buffer;
|
||||
|
||||
ringbuf->block_size = buffer.m_block_size;
|
||||
ringbuf->copy = buffer.m_copy;
|
||||
ringbuf->ringbuf_size = buffer.m_ringbuf_size;
|
||||
ringbuf->transfer_rate = buffer.m_transfer_rate;
|
||||
|
||||
sys_fs->Warning("*** fs stream config: block_size=0x%llx, copy=%d, ringbuf_size = 0x%llx, transfer_rate = 0x%llx", ringbuf->block_size, ringbuf->copy,
|
||||
ringbuf->ringbuf_size, ringbuf->transfer_rate);
|
||||
sys_fs->Warning("*** fs stream config: block_size=0x%llx, copy=%d, ringbuf_size = 0x%llx, transfer_rate = 0x%llx",
|
||||
ringbuf->block_size, ringbuf->copy,ringbuf->ringbuf_size, ringbuf->transfer_rate);
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
@ -625,7 +601,7 @@ s32 cellFsStReadGetStatus(u32 fd, mem64_t status)
|
||||
vfsStream* file;
|
||||
if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH;
|
||||
|
||||
status = m_fs_config.m_fs_status;
|
||||
status = fs_config.m_fs_status;
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
@ -637,7 +613,7 @@ s32 cellFsStReadGetRegid(u32 fd, mem64_t regid)
|
||||
vfsStream* file;
|
||||
if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH;
|
||||
|
||||
regid = m_fs_config.m_regid;
|
||||
regid = fs_config.m_regid;
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
@ -649,8 +625,8 @@ s32 cellFsStReadStart(u32 fd, u64 offset, u64 size)
|
||||
vfsStream* file;
|
||||
if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH;
|
||||
|
||||
m_fs_config.m_current_addr = m_fs_config.m_buffer + (u32)offset;
|
||||
m_fs_config.m_fs_status = CELL_FS_ST_PROGRESS;
|
||||
fs_config.m_current_addr = fs_config.m_buffer + (u32)offset;
|
||||
fs_config.m_fs_status = CELL_FS_ST_PROGRESS;
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
@ -662,7 +638,7 @@ s32 cellFsStReadStop(u32 fd)
|
||||
vfsStream* file;
|
||||
if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH;
|
||||
|
||||
m_fs_config.m_fs_status = CELL_FS_ST_STOP;
|
||||
fs_config.m_fs_status = CELL_FS_ST_STOP;
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
@ -676,8 +652,8 @@ s32 cellFsStRead(u32 fd, u32 buf_addr, u64 size, mem64_t rsize)
|
||||
|
||||
if (rsize.GetAddr() && !rsize.IsGood()) return CELL_EFAULT;
|
||||
|
||||
m_fs_config.m_regid += size;
|
||||
rsize = m_fs_config.m_regid;
|
||||
fs_config.m_regid += size;
|
||||
rsize = fs_config.m_regid;
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user