Small cellAudio update

This commit is contained in:
Nekotekina 2014-02-15 00:08:02 +04:00
parent e94ea409fe
commit e066bcf261
6 changed files with 77 additions and 57 deletions

View File

@ -158,7 +158,7 @@ struct CellAudioOutConfiguration
u8 channel;
u8 encoder;
u8 reserved[10];
u32 downMixer;
be_t<u32> downMixer;
};
struct CellAudioOutSoundMode
@ -167,7 +167,7 @@ struct CellAudioOutSoundMode
u8 channel;
u8 fs;
u8 reserved;
u32 layout;
be_t<u32> layout;
};
struct CellAudioOutDeviceInfo
@ -175,9 +175,9 @@ struct CellAudioOutDeviceInfo
u8 portType;
u8 availableModeCount;
u8 state;
u8 reserved[3];
u16 latency;
CellAudioOutSoundMode availableModes[16];
u8 reserved[3];
be_t<u16> latency;
CellAudioOutSoundMode availableModes[16];
};
struct CellAudioOutState
@ -185,7 +185,7 @@ struct CellAudioOutState
u8 state;
u8 encoder;
u8 reserved[6];
u32 downMixer;
be_t<u32> downMixer;
CellAudioOutSoundMode soundMode;
};
@ -193,7 +193,7 @@ struct CellAudioOutSoundMode2
{
u8 type;
u8 channel;
u16 fs;
be_t<u16> fs;
u8 reserved[4];
};
@ -204,8 +204,8 @@ struct CellAudioOutDeviceInfo2
u8 state;
u8 deviceNumber;
u8 reserved[12];
u64 deviceId;
u64 type;
be_t<u64> deviceId;
be_t<u64> type;
char name[64];
CellAudioOutSoundMode2 availableModes2[16];
};
@ -229,7 +229,7 @@ struct CellAudioInSoundMode
{
u8 type;
u8 channel;
u16 fs;
be_t<u16> fs;
u8 reserved[4];
};
@ -240,8 +240,8 @@ struct CellAudioInDeviceInfo
u8 state;
u8 deviceNumber;
u8 reserved[12];
u64 deviceId;
u64 type;
be_t<u64> deviceId;
be_t<u64> type;
char name[64];
CellAudioInSoundMode availableModes[16];
};

View File

@ -96,7 +96,7 @@ bool CPUThread::Sync()
int CPUThread::ThreadStatus()
{
if(Emu.IsStopped() || IsStopped() )
if (Emu.IsStopped() || IsStopped())
{
return CPUThread_Stopped;
}
@ -106,12 +106,12 @@ int CPUThread::ThreadStatus()
return CPUThread_Step;
}
if (TestDestroy())
if (TestDestroy() || IsPaused())
{
return CPUThread_Break;
}
if(Emu.IsPaused() || Sync())
if (Emu.IsPaused() || Sync())
{
return CPUThread_Sleeping;
}

View File

@ -32,8 +32,11 @@ private:
//0 - 10
void STOP(u32 code)
{
ConLog.Warning("STOP: 0x%x (m_exit_status -> 0)", code);
CPU.SetExitStatus(0);
if (CPU.SPU.Out_MBox.GetCount()) // the real exit status is probably stored there
ConLog.Warning("STOP: 0x%x (message=0x%x)", code, CPU.SPU.Out_MBox.GetValue());
else
ConLog.Warning("STOP: 0x%x (no message)", code);
CPU.SetExitStatus(code);
CPU.Stop();
}
void LNOP()

View File

@ -91,7 +91,7 @@ struct AudioPortConfig
AudioPortConfig();
~AudioPortConfig();
void finalize();
};
struct AudioConfig //custom structure
@ -127,15 +127,15 @@ struct AudioConfig //custom structure
AudioPortConfig::AudioPortConfig()
: m_is_audio_port_started(false)
, m_buffer(Memory.Alloc(1024 * 128, 1024))
, m_index(Memory.Alloc(16, 16))
, m_buffer(Memory.Alloc(1024 * 128, 1024)) // max 128K size
, m_index(Memory.Alloc(16, 16)) // allocation for u64 value "read index"
{
m_config.m_port_in_use++;
mem64_t index(m_index);
index = 0;
}
AudioPortConfig::~AudioPortConfig()
void AudioPortConfig::finalize()
{
m_config.m_port_in_use--;
Memory.Free(m_buffer);
@ -330,12 +330,11 @@ int cellAudioGetPortConfig(u32 portNum, mem_ptr_t<CellAudioPortConfig> portConfi
portConfig->status = CELL_AUDIO_STATUS_READY;
portConfig->nChannel = ref.nChannel;
portConfig->nBlock = ref.nBlock;
portConfig->portSize = ref.nChannel * ref.nBlock * 256;
portConfig->portSize = ref.nChannel * ref.nBlock * 256 * sizeof(float);
portConfig->portAddr = m_config.m_ports[portNum]->m_buffer; // 0x20020000
portConfig->readIndexAddr = m_config.m_ports[portNum]->m_index; // 0x20010010 on ps3
// portAddr - readIndexAddr == 0xFFF0 on ps3
// Memory.Write64(portConfig->readIndexAddr, 1);
}
return CELL_OK;
@ -361,6 +360,25 @@ int cellAudioPortStart(u32 portNum)
}
m_config.m_ports[portNum]->m_is_audio_port_started = true;
std::string t_name = "AudioPort0";
t_name[9] += portNum;
thread t(t_name, [portNum]()
{
AudioPortConfig& ref = *m_config.m_ports[portNum];
mem64_t index(ref.m_index);
ConLog.Write("Port started");
while (ref.m_is_audio_port_started && !Emu.IsStopped())
{
Sleep(5);
index = (index.GetValue() + 1) % ref.m_param.nBlock;
}
ConLog.Write("Port finished");
});
t.detach();
return CELL_OK;
}
@ -378,8 +396,8 @@ int cellAudioPortClose(u32 portNum)
return CELL_AUDIO_ERROR_PORT_NOT_OPEN;
}
delete m_config.m_ports[portNum];
m_config.m_ports[portNum] = nullptr;
m_config.m_ports[portNum]->finalize();
safe_delete(m_config.m_ports[portNum]);
return CELL_OK;
}
@ -402,7 +420,7 @@ int cellAudioPortStop(u32 portNum)
return CELL_AUDIO_ERROR_PORT_NOT_RUN;
}
m_config.m_ports[portNum]->m_is_audio_port_started = false;
m_config.m_ports[portNum]->m_is_audio_port_started = false;
return CELL_OK;
}
@ -449,7 +467,7 @@ int cellAudioSetNotifyEventQueue(u64 key)
return CELL_AUDIO_ERROR_PARAM;
}
eq->events.push(0, 0, 0, 0);
// eq->events.push(0, 0, 0, 0);
return CELL_OK;
}

View File

@ -713,7 +713,7 @@ int cellRescSetConvertAndFlip(mem_ptr_t<CellGcmContextData> cntxt, s32 idx)
int cellRescSetWaitFlip()
{
cellResc.Log("cellRescSetWaitFlip()");
GSLockCurrent lock(GS_LOCK_WAIT_FLIP);
GSLockCurrent lock(GS_LOCK_WAIT_FLIP); // could stall on exit
return CELL_OK;
}

View File

@ -641,11 +641,13 @@ int cellMsgDialogOpenErrorCode(u32 errorCode, mem_func_ptr_t<CellMsgDialogCallba
int cellAudioOutGetSoundAvailability(u32 audioOut, u32 type, u32 fs, u32 option)
{
cellSysutil.Warning("cellAudioOutGetSoundAvailability(audioOut=%d,type=%d,fs=%d,option=%d)",
audioOut,type,fs,option);
cellSysutil.Warning("cellAudioOutGetSoundAvailability(audioOut=%d, type=%d, fs=0x%x, option=%d)",
audioOut, type, fs, option);
option = 0;
int available = 2;
switch(fs)
{
case CELL_AUDIO_OUT_FS_32KHZ:
@ -662,17 +664,16 @@ int cellAudioOutGetSoundAvailability(u32 audioOut, u32 type, u32 fs, u32 option)
switch(type)
{
case CELL_AUDIO_OUT_CODING_TYPE_LPCM:
case CELL_AUDIO_OUT_CODING_TYPE_AC3:
case CELL_AUDIO_OUT_CODING_TYPE_DTS:
break;
case CELL_AUDIO_OUT_CODING_TYPE_LPCM: break;
case CELL_AUDIO_OUT_CODING_TYPE_AC3: available = 0; break;
case CELL_AUDIO_OUT_CODING_TYPE_DTS: available = 0; break;
default: return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_SOUND_MODE;
}
switch(audioOut)
{
case CELL_AUDIO_OUT_PRIMARY: return 2;
case CELL_AUDIO_OUT_PRIMARY: return available;
case CELL_AUDIO_OUT_SECONDARY: return 0;
}
@ -681,11 +682,13 @@ int cellAudioOutGetSoundAvailability(u32 audioOut, u32 type, u32 fs, u32 option)
int cellAudioOutGetSoundAvailability2(u32 audioOut, u32 type, u32 fs, u32 ch, u32 option)
{
cellSysutil.Warning("cellAudioOutGetSoundAvailability(audioOut=%d,type=%d,fs=%d,ch=%d,option=%d)",
audioOut,type,fs,ch,option);
cellSysutil.Warning("cellAudioOutGetSoundAvailability2(audioOut=%d, type=%d, fs=0x%x, ch=%d, option=%d)",
audioOut, type, fs, ch, option);
option = 0;
int available = 2;
switch(fs)
{
case CELL_AUDIO_OUT_FS_32KHZ:
@ -702,27 +705,25 @@ int cellAudioOutGetSoundAvailability2(u32 audioOut, u32 type, u32 fs, u32 ch, u3
switch(ch)
{
case 2:
case 6:
case 8:
break;
case 2: break;
case 6: available = 0; break;
case 8: available = 0; break;
default: return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_SOUND_MODE;
}
switch(type)
{
case CELL_AUDIO_OUT_CODING_TYPE_LPCM:
case CELL_AUDIO_OUT_CODING_TYPE_AC3:
case CELL_AUDIO_OUT_CODING_TYPE_DTS:
break;
case CELL_AUDIO_OUT_CODING_TYPE_LPCM: break;
case CELL_AUDIO_OUT_CODING_TYPE_AC3: available = 0; break;
case CELL_AUDIO_OUT_CODING_TYPE_DTS: available = 0; break;
default: return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_SOUND_MODE;
}
switch(audioOut)
{
case CELL_AUDIO_OUT_PRIMARY: return 1;
case CELL_AUDIO_OUT_PRIMARY: return available;
case CELL_AUDIO_OUT_SECONDARY: return 0;
}
@ -761,31 +762,29 @@ int cellAudioOutGetState(u32 audioOut, u32 deviceIndex, u32 state_addr)
return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_AUDIO_OUT;
}
int cellAudioOutConfigure(u32 audioOut, u32 config_addr, u32 option_addr, u32 waitForEvent)
int cellAudioOutConfigure(u32 audioOut, mem_ptr_t<CellAudioOutConfiguration> config, mem_ptr_t<CellAudioOutOption> option, u32 waitForEvent)
{
cellSysutil.Warning("cellAudioOutConfigure(audioOut=%d, config_addr=0x%x, option_addr=0x%x, waitForEvent=0x%x)",
audioOut, config_addr, option_addr, waitForEvent);
cellSysutil.Warning("cellAudioOutConfigure(audioOut=%d, config_addr=0x%x, option_addr=0x%x, (!)waitForEvent=%d)",
audioOut, config.GetAddr(), option.GetAddr(), waitForEvent);
if(!Memory.IsGoodAddr(config_addr, sizeof(CellAudioOutConfiguration)))
if (!config.IsGood())
{
return CELL_EFAULT;
}
CellAudioOutConfiguration& config = (CellAudioOutConfiguration&)Memory[config_addr];
switch(audioOut)
{
case CELL_AUDIO_OUT_PRIMARY:
if(config.channel)
if (config->channel)
{
Emu.GetAudioManager().GetInfo().mode.channel = config.channel;
Emu.GetAudioManager().GetInfo().mode.channel = config->channel;
}
Emu.GetAudioManager().GetInfo().mode.encoder = config.encoder;
Emu.GetAudioManager().GetInfo().mode.encoder = config->encoder;
if(config.downMixer)
if(config->downMixer)
{
Emu.GetAudioManager().GetInfo().mode.downMixer = config.downMixer;
Emu.GetAudioManager().GetInfo().mode.downMixer = config->downMixer;
}
return CELL_AUDIO_OUT_SUCCEEDED;