Fix converting audio data. Implemented some cellFsStRead functions.

This commit is contained in:
O1L 2014-03-11 20:45:15 +03:00
parent d5e94d4cd9
commit a31160fe99
7 changed files with 308 additions and 7 deletions

View File

@ -69,7 +69,7 @@ void OpenALThread::Stop()
void OpenALThread::Open(const void* src, ALsizei size)
{
alGenSources(1, &mSource); // WARNING: Memory leaks!
alGenSources(1, &mSource);
checkForAlError("alGenSources");
alSourcei(mSource, AL_LOOPING, AL_FALSE);

View File

@ -24,8 +24,6 @@ void AudioDumper::WriteHeader()
size_t AudioDumper::WriteData(const void* buffer, size_t size)
{
size_t ret = m_output.Write(buffer, size);
return ret;
}

View File

@ -120,7 +120,7 @@ int cellAudioInit()
buffer[i] = buffer2[i];
// convert the data from float to u16
oal_buffer[i] = (u16)((float)buffer[i] * (1 << 16));
oal_buffer[i] = (u16)((float)buffer[i] * (1 << 15));
}
first_mix = false;
}
@ -131,7 +131,7 @@ int cellAudioInit()
buffer[i] = (buffer[i] + buffer2[i]) * 0.5; // TODO: valid mixing
// convert the data from float to u16
oal_buffer[i] = (u16)((float)buffer[i] * (1 << 16));
oal_buffer[i] = (u16)((float)buffer[i] * (1 << 15));
}
}
}

View File

@ -295,5 +295,19 @@ void sys_fs_init()
sys_fs.AddFunc(0x9f951810, cellFsAioFinish);
sys_fs.AddFunc(0x1a108ab7, cellFsGetBlockSize);
sys_fs.AddFunc(0xaa3b4bcd, cellFsGetFreeSize);
sys_fs.AddFunc(0x9b882495, cellFsGetDirectoryEntries);
sys_fs.AddFunc(0x2664c8ae, cellFsStReadInit);
sys_fs.AddFunc(0xd73938df, cellFsStReadFinish);
sys_fs.AddFunc(0xb3afee8b, cellFsStReadGetRingBuf);
sys_fs.AddFunc(0xcf34969c, cellFsStReadGetStatus);
sys_fs.AddFunc(0xbd273a88, cellFsStReadGetRegid);
sys_fs.AddFunc(0x8df28ff9, cellFsStReadStart);
sys_fs.AddFunc(0xf8e5d9a0, cellFsStReadStop);
sys_fs.AddFunc(0x27800c6b, cellFsStRead);
sys_fs.AddFunc(0x190912f6, cellFsStReadGetCurrentAddr);
sys_fs.AddFunc(0x81f33783, cellFsStReadPutCurrentAddr);
sys_fs.AddFunc(0x8f71c5b2, cellFsStReadWait);
sys_fs.AddFunc(0x866f6aec, cellFsStReadWaitCallback);
aio_init = false;
}

View File

@ -262,6 +262,19 @@ extern int cellFsTruncate(u32 path_addr, u64 size);
extern int cellFsFGetBlockSize(u32 fd, mem64_t sector_size, mem64_t block_size);
extern int cellFsGetBlockSize(u32 path_addr, mem64_t sector_size, mem64_t block_size);
extern int cellFsGetFreeSize(u32 path_addr, mem32_t block_size, mem64_t block_count);
extern int cellFsGetDirectoryEntries(u32 fd, mem_ptr_t<CellFsDirectoryEntry> entries, u32 entries_size, mem32_t data_count);
extern int cellFsStReadInit(u32 fd, mem_ptr_t<CellFsRingBuffer> ringbuf);
extern int cellFsStReadFinish(u32 fd);
extern int cellFsStReadGetRingBuf(u32 fd, mem_ptr_t<CellFsRingBuffer> ringbuf);
extern int cellFsStReadGetStatus(u32 fd, mem64_t status);
extern int cellFsStReadGetRegid(u32 fd, mem64_t regid);
extern int cellFsStReadStart(u32 fd, u64 offset, u64 size);
extern int cellFsStReadStop(u32 fd);
extern int cellFsStRead(u32 fd, u32 buf_addr, u64 size, mem64_t rsize);
extern int cellFsStReadGetCurrentAddr(u32 fd, mem32_t addr_addr, mem64_t size);
extern int cellFsStReadPutCurrentAddr(u32 fd, u32 addr_addr, u64 size);
extern int cellFsStReadWait(u32 fd, u64 size);
extern int cellFsStReadWaitCallback(u32 fd, u64 size, mem_func_ptr_t<void (*)(int xfd, u64 xsize)> func);
//cellVideo
extern int cellVideoOutGetState(u32 videoOut, u32 deviceIndex, u32 state_addr);

View File

@ -10,6 +10,39 @@ 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;
u32 m_buffer;
u64 m_fs_status;
u64 m_regid;
u32 m_alloc_mem_size;
u32 m_current_addr;
FsRingBufferConfig()
: m_fs_status(CELL_FS_ST_NOT_INITIALIZED)
, m_regid(0)
, m_alloc_mem_size(0)
, m_current_addr(0)
{
memset(&m_ring_buffer, 0, sizeof(FsRingBufferConfig));
}
~FsRingBufferConfig()
{
memset(&m_ring_buffer, 0, sizeof(FsRingBufferConfig));
}
} m_fs_config;
int cellFsOpen(u32 path_addr, int flags, mem32_t fd, mem32_t arg, u64 size)
{
const wxString& path = Memory.ReadString(path_addr);
@ -290,7 +323,7 @@ int cellFsMkdir(u32 path_addr, u32 mode)
{
const wxString& ps3_path = Memory.ReadString(path_addr);
sys_fs.Log("cellFsMkdir(path=\"%s\", mode=0x%x)", ps3_path.wx_str(), mode);
vfsDir dir;
if(dir.IsExists(ps3_path))
return CELL_EEXIST;
@ -484,3 +517,217 @@ int cellFsGetFreeSize(u32 path_addr, mem32_t block_size, mem64_t block_count)
return CELL_OK;
}
int cellFsGetDirectoryEntries(u32 fd, mem_ptr_t<CellFsDirectoryEntry> entries, u32 entries_size, mem32_t data_count)
{
sys_fs.Log("cellFsGetDirectoryEntries(fd=%d, entries_addr=0x%x, entries_size = 0x%x, data_count_addr=0x%x)", fd, entries.GetAddr(), entries_size, data_count.GetAddr());
vfsDirBase* directory;
if(!sys_fs.CheckId(fd, directory))
return CELL_ESRCH;
if(!entries.IsGood() || !data_count.IsGood())
return CELL_EFAULT;
const DirEntryInfo* info = directory->Read();
if(info)
{
data_count = 1;
Memory.WriteString(entries.GetAddr()+2, info->name.wx_str());
entries->entry_name.d_namlen = info->name.Length();
entries->entry_name.d_type = (info->flags & DirEntry_TypeFile) ? CELL_FS_TYPE_REGULAR : CELL_FS_TYPE_DIRECTORY;
entries->attribute.st_mode =
CELL_FS_S_IRUSR | CELL_FS_S_IWUSR | CELL_FS_S_IXUSR |
CELL_FS_S_IRGRP | CELL_FS_S_IWGRP | CELL_FS_S_IXGRP |
CELL_FS_S_IROTH | CELL_FS_S_IWOTH | CELL_FS_S_IXOTH;
entries->attribute.st_uid = 0;
entries->attribute.st_gid = 0;
entries->attribute.st_atime_ = 0; //TODO
entries->attribute.st_mtime_ = 0; //TODO
entries->attribute.st_ctime_ = 0; //TODO
entries->attribute.st_blksize = 4096;
}
else
{
data_count = 0;
}
return CELL_OK;
}
int cellFsStReadInit(u32 fd, mem_ptr_t<CellFsRingBuffer> ringbuf)
{
sys_fs.Warning("cellFsStReadInit(fd=%d, ringbuf_addr=0x%x)", fd, ringbuf.GetAddr());
vfsStream* file;
if(!sys_fs.CheckId(fd, file)) return CELL_ESRCH;
if(!ringbuf.IsGood())
return CELL_EFAULT;
FsRingBuffer& buffer = m_fs_config.m_ring_buffer;
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);
// 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);
m_fs_config.m_fs_status = CELL_FS_ST_INITIALIZED;
return CELL_OK;
}
int cellFsStReadFinish(u32 fd)
{
sys_fs.Warning("cellFsStReadFinish(fd=%d)", 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;
return CELL_OK;
}
int cellFsStReadGetRingBuf(u32 fd, mem_ptr_t<CellFsRingBuffer> ringbuf)
{
sys_fs.Warning("cellFsStReadGetRingBuf(fd=%d, ringbuf_addr=0x%x)", fd, ringbuf.GetAddr());
vfsStream* file;
if(!sys_fs.CheckId(fd, file)) return CELL_ESRCH;
if(!ringbuf.IsGood())
return CELL_EFAULT;
FsRingBuffer& buffer = m_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);
return CELL_OK;
}
int cellFsStReadGetStatus(u32 fd, mem64_t status)
{
sys_fs.Warning("cellFsStReadGetRingBuf(fd=%d, status_addr=0x%x)", fd, status.GetAddr());
vfsStream* file;
if(!sys_fs.CheckId(fd, file)) return CELL_ESRCH;
status = m_fs_config.m_fs_status;
return CELL_OK;
}
int cellFsStReadGetRegid(u32 fd, mem64_t regid)
{
sys_fs.Warning("cellFsStReadGetRingBuf(fd=%d, regid_addr=0x%x)", fd, regid.GetAddr());
vfsStream* file;
if(!sys_fs.CheckId(fd, file)) return CELL_ESRCH;
regid = m_fs_config.m_regid;
return CELL_OK;
}
int cellFsStReadStart(u32 fd, u64 offset, u64 size)
{
sys_fs.Warning("TODO: cellFsStReadStart(fd=%d, offset=0x%llx, size=0x%llx)", fd, offset, 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;
return CELL_OK;
}
int cellFsStReadStop(u32 fd)
{
sys_fs.Warning("cellFsStReadStop(fd=%d)", fd);
vfsStream* file;
if(!sys_fs.CheckId(fd, file)) return CELL_ESRCH;
m_fs_config.m_fs_status = CELL_FS_ST_STOP;
return CELL_OK;
}
int cellFsStRead(u32 fd, u32 buf_addr, u64 size, mem64_t rsize)
{
sys_fs.Warning("TODO: cellFsStRead(fd=%d, buf_addr=0x%x, size=0x%llx, rsize_addr = 0x%x)", fd, buf_addr, size, rsize.GetAddr());
vfsStream* file;
if(!sys_fs.CheckId(fd, file)) return CELL_ESRCH;
if (rsize.GetAddr() && !rsize.IsGood()) return CELL_EFAULT;
m_fs_config.m_regid += size;
rsize = m_fs_config.m_regid;
return CELL_OK;
}
int cellFsStReadGetCurrentAddr(u32 fd, mem32_t addr_addr, mem64_t size)
{
sys_fs.Warning("TODO: cellFsStReadGetCurrentAddr(fd=%d, addr_addr=0x%x, size_addr = 0x%x)", fd, addr_addr.GetAddr(), size.GetAddr());
vfsStream* file;
if(!sys_fs.CheckId(fd, file)) return CELL_ESRCH;
if (!addr_addr.IsGood() && !size.IsGood()) return CELL_EFAULT;
return CELL_OK;
}
int cellFsStReadPutCurrentAddr(u32 fd, u32 addr_addr, u64 size)
{
sys_fs.Warning("TODO: cellFsStReadPutCurrentAddr(fd=%d, addr_addr=0x%x, size = 0x%llx)", fd, addr_addr, size);
vfsStream* file;
if(!sys_fs.CheckId(fd, file)) return CELL_ESRCH;
if (!Memory.IsGoodAddr(addr_addr)) return CELL_EFAULT;
return CELL_OK;
}
int cellFsStReadWait(u32 fd, u64 size)
{
sys_fs.Warning("TODO: cellFsStReadWait(fd=%d, size = 0x%llx)", fd, size);
vfsStream* file;
if(!sys_fs.CheckId(fd, file)) return CELL_ESRCH;
return CELL_OK;
}
int cellFsStReadWaitCallback(u32 fd, u64 size, mem_func_ptr_t<void (*)(int xfd, u64 xsize)> func)
{
sys_fs.Warning("TODO: cellFsStReadWaitCallback(fd=%d, size = 0x%llx, func_addr = 0x%x)", fd, size, func.GetAddr());
if (!func.IsGood())
return CELL_EFAULT;
vfsStream* file;
if(!sys_fs.CheckId(fd, file)) return CELL_ESRCH;
return CELL_OK;
}

View File

@ -56,6 +56,21 @@ enum FsDirentType
CELL_FS_TYPE_SYMLINK = 3,
};
enum CellFsRingBufferCopy
{
CELL_FS_ST_COPY = 0,
CELL_FS_ST_COPYLESS = 1,
};
enum cellFsStStatus
{
CELL_FS_ST_INITIALIZED = 0x0001,
CELL_FS_ST_NOT_INITIALIZED = 0x0002,
CELL_FS_ST_STOP = 0x0100,
CELL_FS_ST_PROGRESS = 0x0200,
};
#pragma pack(4)
struct CellFsStat
@ -92,4 +107,18 @@ struct CellFsAio
be_t<u32> buf_addr;
be_t<u64> size;
be_t<u64> user_data;
};
};
struct CellFsDirectoryEntry
{
CellFsStat attribute;
CellFsDirent entry_name;
};
struct CellFsRingBuffer
{
be_t<u64> ringbuf_size;
be_t<u64> block_size;
be_t<u64> transfer_rate;
be_t<u32> copy;
};