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

View file

@ -106,7 +106,7 @@ int CPUThread::ThreadStatus()
return CPUThread_Step; return CPUThread_Step;
} }
if (TestDestroy()) if (TestDestroy() || IsPaused())
{ {
return CPUThread_Break; return CPUThread_Break;
} }

View file

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

View file

@ -91,7 +91,7 @@ struct AudioPortConfig
AudioPortConfig(); AudioPortConfig();
~AudioPortConfig(); void finalize();
}; };
struct AudioConfig //custom structure struct AudioConfig //custom structure
@ -127,15 +127,15 @@ struct AudioConfig //custom structure
AudioPortConfig::AudioPortConfig() AudioPortConfig::AudioPortConfig()
: m_is_audio_port_started(false) : m_is_audio_port_started(false)
, m_buffer(Memory.Alloc(1024 * 128, 1024)) , m_buffer(Memory.Alloc(1024 * 128, 1024)) // max 128K size
, m_index(Memory.Alloc(16, 16)) , m_index(Memory.Alloc(16, 16)) // allocation for u64 value "read index"
{ {
m_config.m_port_in_use++; m_config.m_port_in_use++;
mem64_t index(m_index); mem64_t index(m_index);
index = 0; index = 0;
} }
AudioPortConfig::~AudioPortConfig() void AudioPortConfig::finalize()
{ {
m_config.m_port_in_use--; m_config.m_port_in_use--;
Memory.Free(m_buffer); Memory.Free(m_buffer);
@ -330,12 +330,11 @@ int cellAudioGetPortConfig(u32 portNum, mem_ptr_t<CellAudioPortConfig> portConfi
portConfig->status = CELL_AUDIO_STATUS_READY; portConfig->status = CELL_AUDIO_STATUS_READY;
portConfig->nChannel = ref.nChannel; portConfig->nChannel = ref.nChannel;
portConfig->nBlock = ref.nBlock; 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->portAddr = m_config.m_ports[portNum]->m_buffer; // 0x20020000
portConfig->readIndexAddr = m_config.m_ports[portNum]->m_index; // 0x20010010 on ps3 portConfig->readIndexAddr = m_config.m_ports[portNum]->m_index; // 0x20010010 on ps3
// portAddr - readIndexAddr == 0xFFF0 on ps3 // portAddr - readIndexAddr == 0xFFF0 on ps3
// Memory.Write64(portConfig->readIndexAddr, 1);
} }
return CELL_OK; return CELL_OK;
@ -361,6 +360,25 @@ int cellAudioPortStart(u32 portNum)
} }
m_config.m_ports[portNum]->m_is_audio_port_started = true; 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; return CELL_OK;
} }
@ -378,8 +396,8 @@ int cellAudioPortClose(u32 portNum)
return CELL_AUDIO_ERROR_PORT_NOT_OPEN; return CELL_AUDIO_ERROR_PORT_NOT_OPEN;
} }
delete m_config.m_ports[portNum]; m_config.m_ports[portNum]->finalize();
m_config.m_ports[portNum] = nullptr; safe_delete(m_config.m_ports[portNum]);
return CELL_OK; return CELL_OK;
} }
@ -449,7 +467,7 @@ int cellAudioSetNotifyEventQueue(u64 key)
return CELL_AUDIO_ERROR_PARAM; return CELL_AUDIO_ERROR_PARAM;
} }
eq->events.push(0, 0, 0, 0); // eq->events.push(0, 0, 0, 0);
return CELL_OK; return CELL_OK;
} }

View file

@ -713,7 +713,7 @@ int cellRescSetConvertAndFlip(mem_ptr_t<CellGcmContextData> cntxt, s32 idx)
int cellRescSetWaitFlip() int cellRescSetWaitFlip()
{ {
cellResc.Log("cellRescSetWaitFlip()"); cellResc.Log("cellRescSetWaitFlip()");
GSLockCurrent lock(GS_LOCK_WAIT_FLIP); GSLockCurrent lock(GS_LOCK_WAIT_FLIP); // could stall on exit
return CELL_OK; 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) int cellAudioOutGetSoundAvailability(u32 audioOut, u32 type, u32 fs, u32 option)
{ {
cellSysutil.Warning("cellAudioOutGetSoundAvailability(audioOut=%d,type=%d,fs=%d,option=%d)", cellSysutil.Warning("cellAudioOutGetSoundAvailability(audioOut=%d, type=%d, fs=0x%x, option=%d)",
audioOut, type, fs, option); audioOut, type, fs, option);
option = 0; option = 0;
int available = 2;
switch(fs) switch(fs)
{ {
case CELL_AUDIO_OUT_FS_32KHZ: case CELL_AUDIO_OUT_FS_32KHZ:
@ -662,17 +664,16 @@ int cellAudioOutGetSoundAvailability(u32 audioOut, u32 type, u32 fs, u32 option)
switch(type) switch(type)
{ {
case CELL_AUDIO_OUT_CODING_TYPE_LPCM: case CELL_AUDIO_OUT_CODING_TYPE_LPCM: break;
case CELL_AUDIO_OUT_CODING_TYPE_AC3: case CELL_AUDIO_OUT_CODING_TYPE_AC3: available = 0; break;
case CELL_AUDIO_OUT_CODING_TYPE_DTS: case CELL_AUDIO_OUT_CODING_TYPE_DTS: available = 0; break;
break;
default: return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_SOUND_MODE; default: return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_SOUND_MODE;
} }
switch(audioOut) switch(audioOut)
{ {
case CELL_AUDIO_OUT_PRIMARY: return 2; case CELL_AUDIO_OUT_PRIMARY: return available;
case CELL_AUDIO_OUT_SECONDARY: return 0; 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) 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)", cellSysutil.Warning("cellAudioOutGetSoundAvailability2(audioOut=%d, type=%d, fs=0x%x, ch=%d, option=%d)",
audioOut, type, fs, ch, option); audioOut, type, fs, ch, option);
option = 0; option = 0;
int available = 2;
switch(fs) switch(fs)
{ {
case CELL_AUDIO_OUT_FS_32KHZ: case CELL_AUDIO_OUT_FS_32KHZ:
@ -702,27 +705,25 @@ int cellAudioOutGetSoundAvailability2(u32 audioOut, u32 type, u32 fs, u32 ch, u3
switch(ch) switch(ch)
{ {
case 2: case 2: break;
case 6: case 6: available = 0; break;
case 8: case 8: available = 0; break;
break;
default: return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_SOUND_MODE; default: return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_SOUND_MODE;
} }
switch(type) switch(type)
{ {
case CELL_AUDIO_OUT_CODING_TYPE_LPCM: case CELL_AUDIO_OUT_CODING_TYPE_LPCM: break;
case CELL_AUDIO_OUT_CODING_TYPE_AC3: case CELL_AUDIO_OUT_CODING_TYPE_AC3: available = 0; break;
case CELL_AUDIO_OUT_CODING_TYPE_DTS: case CELL_AUDIO_OUT_CODING_TYPE_DTS: available = 0; break;
break;
default: return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_SOUND_MODE; default: return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_SOUND_MODE;
} }
switch(audioOut) switch(audioOut)
{ {
case CELL_AUDIO_OUT_PRIMARY: return 1; case CELL_AUDIO_OUT_PRIMARY: return available;
case CELL_AUDIO_OUT_SECONDARY: return 0; 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; 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)", cellSysutil.Warning("cellAudioOutConfigure(audioOut=%d, config_addr=0x%x, option_addr=0x%x, (!)waitForEvent=%d)",
audioOut, config_addr, option_addr, waitForEvent); audioOut, config.GetAddr(), option.GetAddr(), waitForEvent);
if(!Memory.IsGoodAddr(config_addr, sizeof(CellAudioOutConfiguration))) if (!config.IsGood())
{ {
return CELL_EFAULT; return CELL_EFAULT;
} }
CellAudioOutConfiguration& config = (CellAudioOutConfiguration&)Memory[config_addr];
switch(audioOut) switch(audioOut)
{ {
case CELL_AUDIO_OUT_PRIMARY: 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; return CELL_AUDIO_OUT_SUCCEEDED;