diff --git a/rpcs3/Emu/Cell/Modules/cellMic.cpp b/rpcs3/Emu/Cell/Modules/cellMic.cpp index 4179c9e582..44afdec689 100644 --- a/rpcs3/Emu/Cell/Modules/cellMic.cpp +++ b/rpcs3/Emu/Cell/Modules/cellMic.cpp @@ -1144,8 +1144,6 @@ error_code cellMicRemoveNotifyEventQueue(u64 key) error_code cell_mic_read(s32 dev_num, vm::ptr data, s32 max_bytes, /*CellMicSignalType*/u32 type) { - // TODO: CELL_MICIN_ERROR_PARAM - auto& mic_thr = g_fxo->get(); const std::lock_guard lock(mic_thr.mutex); if (!mic_thr.init) @@ -1159,16 +1157,19 @@ error_code cell_mic_read(s32 dev_num, vm::ptr data, s32 max_bytes, /*CellM if (!device.is_opened() || !(device.get_signal_types() & type)) return CELL_MICIN_ERROR_NOT_OPEN; + if (!data) + return not_an_error(0); + switch (type) { case CELLMIC_SIGTYPE_DSP: return not_an_error(device.read_dsp(vm::_ptr(data.addr()), max_bytes)); - case CELLMIC_SIGTYPE_AUX: return CELL_OK; // TODO + case CELLMIC_SIGTYPE_AUX: return not_an_error(0); // TODO case CELLMIC_SIGTYPE_RAW: return not_an_error(device.read_raw(vm::_ptr(data.addr()), max_bytes)); default: fmt::throw_exception("Invalid CELLMIC_SIGTYPE %d", type); } - return CELL_OK; + return not_an_error(0); } error_code cellMicReadRaw(s32 dev_num, vm::ptr data, s32 max_bytes) diff --git a/rpcs3/Emu/Cell/Modules/cellMic.h b/rpcs3/Emu/Cell/Modules/cellMic.h index 90a6a63fad..296d0673df 100644 --- a/rpcs3/Emu/Cell/Modules/cellMic.h +++ b/rpcs3/Emu/Cell/Modules/cellMic.h @@ -157,9 +157,8 @@ struct CellMicInputStream struct CellMicInputDefinition { - // TODO: Data types - volatile u32 uiDevId; - CellMicInputStream data; + be_t uiDevId; + CellMicInputStream data; CellMicInputFormatI aux_format; CellMicInputFormatI raw_format; CellMicInputFormatI sig_format; @@ -182,13 +181,13 @@ struct CellMicStatus // --- End of cell definitions --- -template +template class simple_ringbuf { public: simple_ringbuf() { - m_container.resize(S); + m_container.resize(Size); } bool has_data() const @@ -200,19 +199,19 @@ public: { ensure(buf); - u32 to_read = size > m_used ? m_used : size; + const u32 to_read = size > m_used ? m_used : size; if (!to_read) return 0; - u8* data = m_container.data(); - u32 new_tail = m_tail + to_read; + u8* data = m_container.data(); + const u32 new_tail = m_tail + to_read; - if (new_tail >= S) + if (new_tail >= Size) { - u32 first_chunk_size = S - m_tail; + const u32 first_chunk_size = Size - m_tail; std::memcpy(buf, data + m_tail, first_chunk_size); std::memcpy(buf + first_chunk_size, data, to_read - first_chunk_size); - m_tail = (new_tail - S); + m_tail = (new_tail - Size); } else { @@ -227,30 +226,32 @@ public: void write_bytes(const u8* buf, const u32 size) { - ensure(size <= S); + ensure(size <= Size); - if (u32 over_size = m_used + size; over_size > S) + const u32 over_size = m_used + size; + + if (over_size > Size) { - m_tail += (over_size - S); - if (m_tail > S) - m_tail -= S; + m_tail += (over_size - Size); + if (m_tail > Size) + m_tail -= Size; - m_used = S; + m_used = Size; } else { m_used = over_size; } - u8* data = m_container.data(); - u32 new_head = m_head + size; + u8* data = m_container.data(); + const u32 new_head = m_head + size; - if (new_head >= S) + if (new_head >= Size) { - u32 first_chunk_size = S - m_head; + const u32 first_chunk_size = Size - m_head; std::memcpy(data + m_head, buf, first_chunk_size); std::memcpy(data, buf + first_chunk_size, size - first_chunk_size); - m_head = (new_head - S); + m_head = (new_head - Size); } else {