Minor cleanup

This commit is contained in:
Nekotekina 2015-03-11 18:30:50 +03:00
parent db7bde0a6f
commit a3d400b5cc
20 changed files with 195 additions and 145 deletions

View file

@ -604,19 +604,17 @@ void SPUThread::set_ch_value(u32 ch, u32 value)
if (!queue)
{
LOG_WARNING(SPU, "sys_spu_thread_send_event(spup=%d, data0=0x%x, data1=0x%x): event queue not connected", spup, (value & 0x00ffffff), data);
ch_in_mbox.push_uncond(CELL_ENOTCONN); // TODO: check error passing
return;
return ch_in_mbox.push_uncond(CELL_ENOTCONN); // TODO: check error passing
}
if (queue->events.size() >= queue->size)
{
ch_in_mbox.push_uncond(CELL_EBUSY);
return;
return ch_in_mbox.push_uncond(CELL_EBUSY);
}
queue->push(SYS_SPU_THREAD_EVENT_USER_KEY, GetId(), ((u64)spup << 32) | (value & 0x00ffffff), data);
ch_in_mbox.push_uncond(CELL_OK);
return;
return ch_in_mbox.push_uncond(CELL_OK);
}
else if (code < 128)
{
@ -685,20 +683,22 @@ void SPUThread::set_ch_value(u32 ch, u32 value)
if (!Emu.GetIdManager().GetIDData(data, ef))
{
ch_in_mbox.push_uncond(CELL_ESRCH);
return;
return ch_in_mbox.push_uncond(CELL_ESRCH);
}
while (ef->waiters < 0)
while (ef->cancelled)
{
ef->cv.wait_for(lv2_lock, std::chrono::milliseconds(1));
}
ef->flags |= 1ull << flag;
ef->cv.notify_all();
ch_in_mbox.push_uncond(CELL_OK);
return;
if (ef->waiters)
{
ef->cv.notify_all();
}
return ch_in_mbox.push_uncond(CELL_OK);
}
else if (code == 192)
{
@ -732,13 +732,18 @@ void SPUThread::set_ch_value(u32 ch, u32 value)
return;
}
while (ef->waiters < 0)
while (ef->cancelled)
{
ef->cv.wait_for(lv2_lock, std::chrono::milliseconds(1));
}
ef->flags |= 1ull << flag;
ef->cv.notify_all();
if (ef->waiters)
{
ef->cv.notify_all();
}
return;
}
else
@ -958,8 +963,7 @@ void SPUThread::stop_and_signal(u32 code)
if (ch_in_mbox.get_count())
{
LOG_ERROR(SPU, "sys_spu_thread_receive_event(spuq=0x%x): In_MBox is not empty", spuq);
ch_in_mbox.push_uncond(CELL_EBUSY);
return;
return ch_in_mbox.push_uncond(CELL_EBUSY);
}
if (Ini.HLELogging.GetValue())
@ -986,20 +990,17 @@ void SPUThread::stop_and_signal(u32 code)
if (!queue)
{
ch_in_mbox.push_uncond(CELL_EINVAL); // TODO: check error value
return;
return ch_in_mbox.push_uncond(CELL_EINVAL); // TODO: check error value
}
// protocol is ignored in current implementation
queue->waiters++; assert(queue->waiters > 0);
queue->waiters++;
while (queue->events.empty())
{
if (queue->waiters < 0)
if (queue->cancelled)
{
queue->waiters--; assert(queue->waiters < 0);
ch_in_mbox.push_uncond(CELL_ECANCELED);
return;
return ch_in_mbox.push_uncond(CELL_ECANCELED);
}
if (Emu.IsStopped())
@ -1018,7 +1019,7 @@ void SPUThread::stop_and_signal(u32 code)
ch_in_mbox.push_uncond((u32)event.data3);
queue->events.pop_front();
queue->waiters--; assert(queue->waiters >= 0);
queue->waiters--;
if (queue->events.size())
{