Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic Microphone support on Windows. #13229

Merged
merged 8 commits into from
Aug 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Core/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ struct Config {
std::string sVulkanDevice;
std::string sD3D11Device; // Windows only
std::string sCameraDevice;
std::string sMicDevice;

bool bSoftwareRendering;
bool bHardwareTransform; // only used in the GLES backend
Expand Down
8 changes: 7 additions & 1 deletion Core/HLE/sceAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "Core/HLE/FunctionWrappers.h"
#include "Core/HLE/sceKernelThread.h"
#include "Core/HLE/sceAudio.h"
#include "Core/HLE/sceUsbMic.h"
#include "Core/HLE/__sceAudio.h"
#include "Core/Reporting.h"

Expand Down Expand Up @@ -471,6 +472,11 @@ static u32 sceAudioSRCOutputBlocking(u32 vol, u32 buf) {
return hleLogSuccessI(SCEAUDIO, result);
}

static int sceAudioInputBlocking(u32 maxSamples, u32 sampleRate, u32 bufAddr) {
ERROR_LOG(HLE, "UNIMPL sceAudioInputBlocking: maxSamples: %d, samplerate: %d, bufAddr: %08x", maxSamples, sampleRate, bufAddr);
return __MicInputBlocking(maxSamples, sampleRate, bufAddr);
}

static u32 sceAudioRoutingSetMode(u32 mode) {
ERROR_LOG_REPORT(SCEAUDIO, "sceAudioRoutingSetMode(%08x)", mode);
int previousMode = defaultRoutingMode;
Expand Down Expand Up @@ -535,7 +541,7 @@ const HLEFunction sceAudio[] =
{0X7DE61688, nullptr, "sceAudioInputInit", '?', "" },
{0XE926D3FB, nullptr, "sceAudioInputInitEx", '?', "" },
{0X6D4BEC68, nullptr, "sceAudioInput", '?', "" },
{0X086E5895, nullptr, "sceAudioInputBlocking", '?', "" },
{0X086E5895, &WrapI_UUU<sceAudioInputBlocking>, "sceAudioInputBlocking", 'i', "xxx" },
{0XA708C6A6, nullptr, "sceAudioGetInputLength", '?', "" },
{0XA633048E, nullptr, "sceAudioPollInputEnd", '?', "" },
{0X87B2E651, nullptr, "sceAudioWaitInputEnd", '?', "" },
Expand Down
6 changes: 5 additions & 1 deletion Core/HLE/sceKernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,13 @@
#include "sceImpose.h"
#include "sceUsb.h"
#include "sceUsbGps.h"
#include "sceUsbCam.h"
#include "sceUsbMic.h"
#include "scePspNpDrm_user.h"
#include "sceVaudio.h"
#include "sceHeap.h"
#include "sceDmac.h"
#include "sceMp4.h"
#include "sceUsbCam.h"

#include "../Util/PPGeDraw.h"

Expand Down Expand Up @@ -146,6 +147,7 @@ void __KernelInit()
__VideoPmpInit();
__UsbGpsInit();
__UsbCamInit();
__UsbMicInit();

SaveState::Init(); // Must be after IO, as it may create a directory
Reporting::Init();
Expand All @@ -170,6 +172,7 @@ void __KernelShutdown()
kernelObjects.Clear();

__UsbCamShutdown();
__UsbMicShutdown();
__UsbGpsShutdown();

__AudioCodecShutdown();
Expand Down Expand Up @@ -278,6 +281,7 @@ void __KernelDoState(PointerWrap &p)
__VideoPmpDoState(p);
__AACDoState(p);
__UsbGpsDoState(p);
__UsbMicDoState(p);

// IMPORTANT! Add new sections last!
}
Expand Down
1 change: 1 addition & 0 deletions Core/HLE/sceKernelThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ const WaitTypeNames waitTypeNames[] = {
{ WAITTYPE_TLSPL, "TLS" },
{ WAITTYPE_VMEM, "Volatile Mem" },
{ WAITTYPE_ASYNCIO, "AsyncIO" },
{ WAITTYPE_MICINPUT, "Microphone input"},
};

const char *getWaitTypeName(WaitType type)
Expand Down
1 change: 1 addition & 0 deletions Core/HLE/sceKernelThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ enum WaitType : int
WAITTYPE_TLSPL = 21,
WAITTYPE_VMEM = 22,
WAITTYPE_ASYNCIO = 23,
WAITTYPE_MICINPUT = 24, // fake

NUM_WAITTYPES
};
Expand Down
2 changes: 1 addition & 1 deletion Core/HLE/sceUsb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ static int sceUsbGetState() {
| (usbConnected ? USB_STATUS_CONNECTED : USB_STATUS_DISCONNECTED)
| (usbActivated ? USB_STATUS_ACTIVATED : USB_STATUS_DEACTIVATED);
}
INFO_LOG(HLE, "sceUsbGetState: 0x%x", state);
DEBUG_LOG(HLE, "sceUsbGetState: 0x%x", state);
return state;
}

Expand Down
11 changes: 3 additions & 8 deletions Core/HLE/sceUsbCam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "Common/ChunkFile.h"
#include "Core/HLE/HLE.h"
#include "Core/HLE/sceUsbCam.h"
#include "Core/HLE/sceUsbMic.h"
#include "Core/HW/Camera.h"
#include "Core/MemMapHelpers.h"

Expand Down Expand Up @@ -112,7 +113,7 @@ static int getCameraResolution(Camera::ConfigType type, int *width, int *height)


static int sceUsbCamSetupMic(u32 paramAddr, u32 workareaAddr, int wasize) {
INFO_LOG(HLE, "UNIMPL sceUsbCamSetupMic");
INFO_LOG(HLE, "sceUsbCamSetupMic");
if (Memory::IsValidRange(paramAddr, sizeof(PspUsbCamSetupMicParam))) {
Memory::ReadStruct(paramAddr, &config->micParam);
}
Expand All @@ -131,13 +132,7 @@ static int sceUsbCamStopMic() {

static int sceUsbCamReadMicBlocking(u32 bufAddr, u32 size) {
INFO_LOG(HLE, "UNIMPL sceUsbCamReadMicBlocking: size: %d", size);
for (unsigned int i = 0; i < size; i++) {
if (Memory::IsValidAddress(bufAddr + i)) {
Memory::Write_U8(i & 0xFF, bufAddr + i);
}
}
hleEatMicro(1000000 / config->micParam.frequency * (size / 2));
return size;
return __MicInputBlocking(size >> 1, config->micParam.frequency, bufAddr);
}

static int sceUsbCamSetupVideo(u32 paramAddr, u32 workareaAddr, int wasize) {
Expand Down
Loading