Skip to content

Commit

Permalink
Microphone implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
RipleyTom committed Jan 12, 2019
1 parent e18e990 commit 5062286
Show file tree
Hide file tree
Showing 8 changed files with 846 additions and 136 deletions.
132 changes: 106 additions & 26 deletions rpcs3/Emu/Cell/Modules/cellAvconfExt.cpp
@@ -1,4 +1,4 @@
#include "stdafx.h"
#include "stdafx.h"
#include "Emu/System.h"
#include "Emu/Cell/PPUModule.h"
#include "Emu/IdManager.h"
Expand All @@ -11,6 +11,80 @@

LOG_CHANNEL(cellAvconfExt);

enum class device_in
{
camera,
standard_microphone,
singstar_microphone,
};

void set_input_device_info(device_in device_type, vm::ptr<CellAudioInDeviceInfo> info, u8 device_number)
{
memset(info.get_ptr(), 0, sizeof(CellAudioInDeviceInfo));

switch (device_type)
{
case device_in::camera:
info->portType = CELL_AUDIO_IN_PORT_USB;
info->availableModeCount = 0;
info->state = CELL_AUDIO_IN_DEVICE_STATE_AVAILABLE;
info->deviceId = 0xDEADBEEF;
info->type = 0xBEEFDEAD; // Some games check if deviceId and type are the same.
info->availableModes[0].type = CELL_AUDIO_IN_CODING_TYPE_LPCM;
info->availableModes[0].channel = CELL_AUDIO_IN_CHNUM_NONE;
info->availableModes[0].fs = CELL_AUDIO_IN_FS_8KHZ | CELL_AUDIO_IN_FS_12KHZ | CELL_AUDIO_IN_FS_16KHZ | CELL_AUDIO_IN_FS_24KHZ | CELL_AUDIO_IN_FS_32KHZ | CELL_AUDIO_IN_FS_48KHZ;
strcpy(info->name, "USB Camera");
break;
case device_in::standard_microphone:
info->portType = CELL_AUDIO_IN_PORT_USB;
info->availableModeCount = 2;
info->state = CELL_AUDIO_IN_DEVICE_STATE_AVAILABLE;
info->deviceId = 0xE11CC0DE;
info->type = 0xC0DEE11C; // Some games check if deviceId and type are the same.
info->availableModes[0].type = CELL_AUDIO_IN_CODING_TYPE_LPCM;
info->availableModes[0].channel = CELL_AUDIO_IN_CHNUM_2;
info->availableModes[0].fs = CELL_AUDIO_IN_FS_8KHZ | CELL_AUDIO_IN_FS_12KHZ | CELL_AUDIO_IN_FS_16KHZ | CELL_AUDIO_IN_FS_24KHZ | CELL_AUDIO_IN_FS_32KHZ | CELL_AUDIO_IN_FS_48KHZ;
strcpy(info->name, "Standard Microphone");
break;
case device_in::singstar_microphone:
info->portType = CELL_AUDIO_IN_PORT_USB;
info->availableModeCount = 2;
info->state = CELL_AUDIO_IN_DEVICE_STATE_AVAILABLE;
info->deviceId = 0x57A3C0DE;
info->type = 0xC0DE57A3; // Some games check if deviceId and type are the same.
info->availableModes[0].type = CELL_AUDIO_IN_CODING_TYPE_LPCM;
info->availableModes[0].channel = CELL_AUDIO_IN_CHNUM_2;
info->availableModes[0].fs = CELL_AUDIO_IN_FS_8KHZ | CELL_AUDIO_IN_FS_12KHZ | CELL_AUDIO_IN_FS_16KHZ | CELL_AUDIO_IN_FS_24KHZ | CELL_AUDIO_IN_FS_32KHZ | CELL_AUDIO_IN_FS_48KHZ;
strcpy(info->name, "Singstar Microphone");
break;
default:
break;
}

info->deviceNumber = device_number;
}

std::vector<device_in> get_vec_input_devices()
{
std::vector<device_in> list_devices;

if (g_cfg.io.camera != camera_handler::null) list_devices.push_back(device_in::camera);

switch (g_cfg.io.microphone)
{
case microphone_handler::standard:
list_devices.push_back(device_in::standard_microphone);
break;
case microphone_handler::singstar:
list_devices.push_back(device_in::singstar_microphone);
break;
default:
break;
}

return list_devices;
}

s32 cellAudioOutUnregisterDevice(u32 deviceNumber)
{
cellAvconfExt.todo("cellAudioOutUnregisterDevice(deviceNumber=0x%x)", deviceNumber);
Expand Down Expand Up @@ -38,17 +112,16 @@ s32 cellVideoOutSetupDisplay()
s32 cellAudioInGetDeviceInfo(u32 deviceNumber, u32 deviceIndex, vm::ptr<CellAudioInDeviceInfo> info)
{
cellAvconfExt.todo("cellAudioInGetDeviceInfo(deviceNumber=0x%x, deviceIndex=0x%x, info=*0x%x)", deviceNumber, deviceIndex, info);
info->portType = CELL_AUDIO_IN_PORT_USB;
info->availableModeCount = 1;
info->state = CELL_AUDIO_IN_DEVICE_STATE_AVAILABLE;
info->deviceNumber = 0;
// Some games check if deviceId and type are the same.
info->deviceId = 0xDEADBEEF;
info->type = 0xBEEFDEAD;
info->availableModes[0].type = CELL_AUDIO_IN_CODING_TYPE_LPCM;
info->availableModes[0].channel = CELL_AUDIO_IN_CHNUM_NONE;
info->availableModes[0].fs = CELL_AUDIO_IN_FS_8KHZ | CELL_AUDIO_IN_FS_12KHZ | CELL_AUDIO_IN_FS_16KHZ | CELL_AUDIO_IN_FS_24KHZ | CELL_AUDIO_IN_FS_32KHZ | CELL_AUDIO_IN_FS_48KHZ;
strcpy(info->name, "USB Camera");

std::vector<device_in> ain_devices = get_vec_input_devices();

if (deviceNumber + 1 > ain_devices.size())
{
return CELL_AUDIO_OUT_ERROR_DEVICE_NOT_FOUND;
}

set_input_device_info(ain_devices[deviceNumber], info, deviceNumber);

return CELL_OK;
}

Expand All @@ -73,21 +146,27 @@ s32 cellVideoOutGetGamma(u32 videoOut, vm::ptr<f32> gamma)
return CELL_OK;
}

s32 cellAudioInGetAvailableDeviceInfo(u32 count, vm::ptr<CellAudioInDeviceInfo> info)
s32 cellAudioInGetAvailableDeviceInfo(u32 count, vm::ptr<CellAudioInDeviceInfo> device_info)
{
cellAvconfExt.todo("cellAudioInGetAvailableDeviceInfo(count=0x%x, info=*0x%x)", count, info);
info->portType = CELL_AUDIO_IN_PORT_USB;
info->availableModeCount = 1;
info->state = CELL_AUDIO_IN_DEVICE_STATE_AVAILABLE;
info->deviceNumber = 0;
// Some games check if deviceId and type are the same.
info->deviceId = 0xDEADBEEF;
info->type = 0xBEEFDEAD;
info->availableModes[0].type = CELL_AUDIO_IN_CODING_TYPE_LPCM;
info->availableModes[0].channel = CELL_AUDIO_IN_CHNUM_NONE;
info->availableModes[0].fs = CELL_AUDIO_IN_FS_8KHZ | CELL_AUDIO_IN_FS_12KHZ | CELL_AUDIO_IN_FS_16KHZ | CELL_AUDIO_IN_FS_24KHZ | CELL_AUDIO_IN_FS_32KHZ | CELL_AUDIO_IN_FS_48KHZ;
strcpy(info->name, "USB Camera");
return 1; // number of available devices
cellAvconfExt.todo("cellAudioInGetAvailableDeviceInfo(count=0x%x, info=*0x%x)", count, device_info);

if (count > 16 || !device_info.addr())
{
return CELL_AUDIO_IN_ERROR_ILLEGAL_PARAMETER;
}

std::vector<device_in> ain_devices = get_vec_input_devices();

vm::ptr<CellAudioInDeviceInfo> curinfo = device_info;

u32 index;
for (index = 0; index < count && index < ain_devices.size(); index++)
{
set_input_device_info(ain_devices[index], curinfo, (u8)index);
curinfo++;
}

return index;
}

s32 cellAudioOutGetAvailableDeviceInfo(u32 count, vm::ptr<CellAudioOutDeviceInfo2> info)
Expand Down Expand Up @@ -137,6 +216,7 @@ s32 cellAudioInSetDeviceMode(u32 deviceMode)
s32 cellAudioInRegisterDevice(u64 deviceType, vm::cptr<char> name, vm::ptr<CellAudioInRegistrationOption> option, vm::ptr<CellAudioInDeviceConfiguration> config)
{
cellAvconfExt.todo("cellAudioInRegisterDevice(deviceType=0x%llx, name=%s, option=*0x%x, config=*0x%x)", deviceType, name, option, config);

return 0; // device number
}

Expand Down

0 comments on commit 5062286

Please sign in to comment.