c++11 fixups. Initialise to zero where possible. note: cellAudio looks quite messed up.

This commit is contained in:
Sacha 2014-07-14 17:26:31 +10:00
parent 582825934c
commit 6bd044f9be
5 changed files with 39 additions and 65 deletions

View File

@ -643,9 +643,8 @@ void GLVertexProgram::Compile()
if(r)
{
char* buf = new char[r+1];
char* buf = new char[r+1]();
GLsizei len;
memset(buf, 0, r+1);
glGetShaderInfoLog(id, r, &len, buf);
LOG_ERROR(RSX, "Failed to compile vertex shader: %s", buf);
delete[] buf;

View File

@ -110,8 +110,7 @@ int cellPadGetData(u32 port_no, u32 data_addr)
if(port_no >= rinfo.now_connect) return CELL_PAD_ERROR_NO_DEVICE;
Pad& pad = pads[port_no];
CellPadData data;
memset(&data, 0, sizeof(CellPadData));
CellPadData data = {};
u16 d1Initial, d2Initial;
d1Initial = pad.m_digital_1;
@ -301,8 +300,7 @@ int cellPadGetInfo(u32 info_addr)
sys_io->Log("cellPadGetInfo(info_addr=0x%x)", info_addr);
if(!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED;
CellPadInfo info;
memset(&info, 0, sizeof(CellPadInfo));
CellPadInfo info = {};
const PadInfo& rinfo = Emu.GetPadManager().GetInfo();
info.max_connect = rinfo.max_connect;
@ -333,8 +331,7 @@ int cellPadGetInfo2(u32 info_addr)
sys_io->Log("cellPadGetInfo2(info_addr=0x%x)", info_addr);
if(!Emu.GetPadManager().IsInited()) return CELL_PAD_ERROR_UNINITIALIZED;
CellPadInfo2 info;
memset(&info, 0, sizeof(CellPadInfo2));
CellPadInfo2 info = {};
const PadInfo& rinfo = Emu.GetPadManager().GetInfo();
info.max_connect = rinfo.max_connect;
@ -370,8 +367,7 @@ int cellPadGetCapabilityInfo(u32 port_no, mem32_t info_addr)
const std::vector<Pad>& pads = Emu.GetPadManager().GetPads();
CellCapabilityInfo data;
memset(&data, 0, sizeof(CellCapabilityInfo));
CellCapabilityInfo data = {};
//Should return the same as device capability mask, psl1ght has it backwards in pad.h
data.info[0] = pads[port_no].m_device_capability;

View File

@ -21,6 +21,8 @@ static const bool g_is_u16 = Ini.AudioConvertToU16.GetValue();
// libaudio Functions
#define BUFFER_NUM 32
#define BUFFER_SIZE 256
int cellAudioInit()
{
cellAudio->Warning("cellAudioInit()");
@ -57,30 +59,25 @@ int cellAudioInit()
if (Ini.AudioDumpToFile.GetValue())
m_dump.WriteHeader();
float buf2ch[2 * 256]; // intermediate buffer for 2 channels
float buf8ch[8 * 256]; // intermediate buffer for 8 channels
float buf2ch[2 * BUFFER_SIZE]; // intermediate buffer for 2 channels
float buf8ch[8 * BUFFER_SIZE]; // intermediate buffer for 8 channels
uint oal_buffer_offset = 0;
const uint oal_buffer_size = sizeof(buf2ch) / sizeof(float);
const uint oal_buffer_size = 2 * BUFFER_SIZE;
std::unique_ptr<s16[]> oal_buffer[32];
SQueue<s16*, 31> queue;
std::unique_ptr<s16[]> oal_buffer[BUFFER_NUM];
std::unique_ptr<float[]> oal_buffer_float[BUFFER_NUM];
std::unique_ptr<float[]> oal_buffer_float[32];
SQueue<float*, 31> queue_float;
for (u32 i = 0; i < sizeof(oal_buffer) / sizeof(oal_buffer[0]); i++)
for (u32 i = 0; i < BUFFER_NUM; i++)
{
oal_buffer[i] = std::unique_ptr<s16[]>(new s16[oal_buffer_size]);
memset(oal_buffer[i].get(), 0, oal_buffer_size * sizeof(s16));
oal_buffer[i] = std::unique_ptr<s16[]>(new s16[oal_buffer_size] {} );
oal_buffer_float[i] = std::unique_ptr<float[]>(new float[oal_buffer_size] {} );
}
SQueue<s16*, 31> queue;
queue.Clear();
for (u32 i = 0; i < sizeof(oal_buffer_float) / sizeof(oal_buffer_float[0]); i++)
{
oal_buffer_float[i] = std::unique_ptr<float[]>(new float[oal_buffer_size]);
memset(oal_buffer_float[i].get(), 0, oal_buffer_size * sizeof(float));
}
SQueue<float*, 31> queue_float;
queue_float.Clear();
std::vector<u64> keys;
@ -89,10 +86,11 @@ int cellAudioInit()
{
m_audio_out->Init();
// Note: What if the ini value changes?
if (g_is_u16)
m_audio_out->Open(oal_buffer[0].get(), oal_buffer_size * sizeof(s16));
m_audio_out->Open(oal_buffer_float[0].get(), oal_buffer_size * sizeof(float));
else
m_audio_out->Open(oal_buffer_float[0].get(), oal_buffer_size * sizeof(float));
}
m_config.start_time = get_system_time();
@ -108,34 +106,27 @@ int cellAudioInit()
if (g_is_u16)
queue.Pop(oal_buffer);
else
queue_float.Pop(oal_buffer_float);
queue_float.Pop(oal_buffer_float);
if (g_is_u16)
{
if (oal_buffer)
{
m_audio_out->AddData(oal_buffer, oal_buffer_size * sizeof(s16));
}
else
{
internal_finished = true;
return;
continue;
}
}
else
{
if (oal_buffer_float)
{
m_audio_out->AddData(oal_buffer_float, oal_buffer_size * sizeof(float));
}
else
{
internal_finished = true;
return;
continue;
}
}
internal_finished = true;
return;
}
});
iat.detach();
@ -161,8 +152,8 @@ int cellAudioInit()
m_config.counter++;
const u32 oal_pos = m_config.counter % (sizeof(oal_buffer) / sizeof(oal_buffer[0]));
const u32 oal_pos_float = m_config.counter % (sizeof(oal_buffer_float) / sizeof(oal_buffer_float[0]));
const u32 oal_pos = m_config.counter % BUFFER_NUM;
const u32 oal_pos_float = m_config.counter % BUFFER_NUM;
if (Emu.IsPaused())
{

View File

@ -148,8 +148,7 @@ int cellVideoOutGetState(u32 videoOut, u32 deviceIndex, u32 state_addr)
if(deviceIndex) return CELL_VIDEO_OUT_ERROR_DEVICE_NOT_FOUND;
CellVideoOutState state;
memset(&state, 0, sizeof(CellVideoOutState));
CellVideoOutState state = {};
switch(videoOut)
{
@ -246,8 +245,7 @@ int cellVideoOutGetConfiguration(u32 videoOut, u32 config_addr, u32 option_addr)
if(!Memory.IsGoodAddr(config_addr, sizeof(CellVideoOutConfiguration))) return CELL_EFAULT;
CellVideoOutConfiguration config;
memset(&config, 0, sizeof(CellVideoOutConfiguration));
CellVideoOutConfiguration config = {};
switch(videoOut)
{
@ -471,8 +469,7 @@ int cellAudioOutGetSoundAvailability2(u32 audioOut, u32 type, u32 fs, u32 ch, u3
int cellAudioOutGetState(u32 audioOut, u32 deviceIndex, u32 state_addr)
{
cellSysutil->Warning("cellAudioOutGetState(audioOut=0x%x,deviceIndex=0x%x,state_addr=0x%x)",audioOut,deviceIndex,state_addr);
CellAudioOutState state;
memset(&state, 0, sizeof(CellAudioOutState));
CellAudioOutState state = {};
switch(audioOut)
{
@ -541,8 +538,7 @@ int cellAudioOutGetConfiguration(u32 audioOut, u32 config_addr, u32 option_addr)
if(!Memory.IsGoodAddr(config_addr, sizeof(CellAudioOutConfiguration))) return CELL_EFAULT;
CellAudioOutConfiguration config;
memset(&config, 0, sizeof(CellAudioOutConfiguration));
CellAudioOutConfiguration config = {};
switch(audioOut)
{

View File

@ -159,13 +159,11 @@ int cellVpostExec(u32 handle, const u32 inPicBuff_addr, const mem_ptr_t<CellVpos
picInfo->reserved2 = 0;
u64 stamp0 = get_system_time();
u8* pY = (u8*)malloc(w*h); // color planes
u8* pU = (u8*)malloc(w*h/4);
u8* pV = (u8*)malloc(w*h/4);
u8* pA = (u8*)malloc(w*h);
u32* res = (u32*)malloc(ow*oh*4); // RGBA interleaved output
const u8 alpha = ctrlParam->outAlpha;
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
if (!Memory.CopyToReal(pY, inPicBuff_addr, w*h))
{
@ -185,7 +183,7 @@ int cellVpostExec(u32 handle, const u32 inPicBuff_addr, const mem_ptr_t<CellVpos
Emu.Pause();
}
memset(pA, alpha, w*h);
memset(pA, (const u8)ctrlParam->outAlpha, w*h);
u64 stamp1 = get_system_time();
@ -210,12 +208,6 @@ int cellVpostExec(u32 handle, const u32 inPicBuff_addr, const mem_ptr_t<CellVpos
Emu.Pause();
}
free(pY);
free(pU);
free(pV);
free(pA);
free(res);
//ConLog.Write("cellVpostExec() perf (access=%d, getContext=%d, scale=%d, finalize=%d)",
//stamp1 - stamp0, stamp2 - stamp1, stamp3 - stamp2, get_system_time() - stamp3);
return CELL_OK;