| 302 | vm::gvar<CellAdecCoreOps> g_cell_adec_core_ops_lpcm; |
| 303 | |
| 304 | void LpcmDecContext::exec(ppu_thread& ppu) |
| 305 | { |
| 306 | perf_meter<"LPCMDEC"_u64> perf0; |
| 307 | |
| 308 | switch (savestate) |
| 309 | { |
| 310 | case lpcm_dec_state::waiting_for_cmd_mutex_lock: break; |
| 311 | case lpcm_dec_state::waiting_for_cmd_cond_wait: break; |
| 312 | case lpcm_dec_state::waiting_for_output_mutex_lock: goto output_mutex_lock; |
| 313 | case lpcm_dec_state::waiting_for_output_cond_wait: goto output_cond_wait; |
| 314 | case lpcm_dec_state::queue_mutex_lock: goto queue_mutex_lock; |
| 315 | case lpcm_dec_state::executing_cmd: goto execute_cmd; |
| 316 | } |
| 317 | |
| 318 | for (; run_thread; cmd_counter++) |
| 319 | { |
| 320 | cellAdec.trace("Command counter: %llu, waiting for next command...", cmd_counter); |
| 321 | |
| 322 | // Wait for a command to become available |
| 323 | error_occurred |= static_cast<u32>(cmd_available.acquire(ppu, savestate) != CELL_OK); |
| 324 | |
| 325 | if (ppu.state & cpu_flag::again) |
| 326 | { |
| 327 | return; |
| 328 | } |
| 329 | |
| 330 | cellAdec.trace("Command available, waiting for output to be consumed..."); |
| 331 | |
| 332 | // Wait for the output to be consumed. |
| 333 | // The output has to be consumed even if the next command is not a decode command |
| 334 | savestate = lpcm_dec_state::waiting_for_output_mutex_lock; |
| 335 | output_mutex_lock: |
| 336 | |
| 337 | error_occurred |= static_cast<u32>(sys_mutex_lock(ppu, output_mutex, 0) != CELL_OK); |
| 338 | |
| 339 | if (ppu.state & cpu_flag::again) |
| 340 | { |
| 341 | return; |
| 342 | } |
| 343 | |
| 344 | while (output_locked) |
| 345 | { |
| 346 | savestate = lpcm_dec_state::waiting_for_output_cond_wait; |
| 347 | output_cond_wait: |
| 348 | |
| 349 | ensure(sys_cond_wait(ppu, output_consumed, 0) == CELL_OK); // Error code isn't checked on LLE |
| 350 | |
| 351 | if (ppu.state & cpu_flag::again) |
| 352 | { |
| 353 | return; |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | cellAdec.trace("Output consumed"); |
| 358 | |
| 359 | // Pop command from queue |
| 360 | savestate = lpcm_dec_state::queue_mutex_lock; |
| 361 | queue_mutex_lock: |
no test coverage detected