static uint32_t appIoThreadEntry(uint32_t coreId, void *arg2) { auto queue = &sAppIo->queues[coreId]; OSInitMessageQueue(queue, &sAppIo->messages[coreId * MessagesPerCore], MessagesPerCore); while (true) { OSMessage msg; OSReceiveMessage(queue, &msg, OSMessageFlags::Blocking); auto funcType = static_cast<OSFunctionType>(msg.args[2].value()); switch (funcType) { case OSFunctionType::FsaCmdAsync: { auto result = FSAGetAsyncResult(&msg); if (result->userCallback) { result->userCallback(result->error, result->command, result->request, result->response, result->userContext); } break; } case OSFunctionType::FsCmdAsync: { auto result = FSGetAsyncResult(&msg); if (result->asyncData.userCallback) { result->asyncData.userCallback(result->client, result->block, result->status, result->asyncData.userContext); } break; } case OSFunctionType::FsCmdHandler: { fsCmdBlockHandleResult(reinterpret_cast<FSCmdBlockBody *>(msg.message.get())); break; } default: decaf_abort(fmt::format("Unimplemented OSFunctionType {}", funcType)); } } }
void WinSound::fillNextBuffer(void) { if (isStarted) { isFilling = TRUE; // check if the buffer is already prepared (should not !) if (waveHeader[currentBuffer].dwFlags & WHDR_PREPARED) waveOutUnprepareHeader(waveOut, &waveHeader[currentBuffer], sizeof(WAVEHDR)); // Call the user function to fill the buffer if (userCallback) { userCallback(soundBuffer[currentBuffer], bufferSize); } // Prepare the buffer to be sent to the WaveOut API waveHeader[currentBuffer].lpData = (char*) soundBuffer[currentBuffer]; waveHeader[currentBuffer].dwBufferLength = bufferSize; waveOutPrepareHeader(waveOut, &waveHeader[currentBuffer], sizeof(WAVEHDR)); // Send the buffer the the WaveOut queue waveOutWrite(waveOut, &waveHeader[currentBuffer], sizeof(WAVEHDR)); currentBuffer++; if (currentBuffer >= WINSOUND_BUFFERCOUNT) { currentBuffer = 0; } isFilling = FALSE; } }