mirror of https://github.com/PCSX2/pcsx2.git
USB: Support stereo input for Singstar Mic
This commit is contained in:
parent
db4d721b93
commit
dda1665b9c
|
@ -249,17 +249,6 @@ namespace usb_mic
|
||||||
ResetBuffers();
|
ResetBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CubebAudioDevice::Compare(AudioDevice* compare) const
|
|
||||||
{
|
|
||||||
if (compare)
|
|
||||||
{
|
|
||||||
CubebAudioDevice* src = static_cast<CubebAudioDevice*>(compare);
|
|
||||||
if (src && mDeviceName == src->mDeviceName)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CubebAudioDevice::ResetBuffers()
|
void CubebAudioDevice::ResetBuffers()
|
||||||
{
|
{
|
||||||
// TODO: Do we want to make the buffer size adjustable? Currently 100ms max.
|
// TODO: Do we want to make the buffer size adjustable? Currently 100ms max.
|
||||||
|
|
|
@ -42,7 +42,6 @@ namespace usb_mic
|
||||||
void SetResampling(int samplerate) override;
|
void SetResampling(int samplerate) override;
|
||||||
bool Start() override;
|
bool Start() override;
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
bool Compare(AudioDevice* compare) const override;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void ResetBuffers();
|
void ResetBuffers();
|
||||||
|
|
|
@ -43,8 +43,6 @@ namespace usb_mic
|
||||||
}
|
}
|
||||||
uint32_t SetBuffer(int16_t* inBuf, uint32_t inFrames) override { return inFrames; }
|
uint32_t SetBuffer(int16_t* inBuf, uint32_t inFrames) override { return inFrames; }
|
||||||
void SetResampling(int samplerate) override {}
|
void SetResampling(int samplerate) override {}
|
||||||
|
|
||||||
bool Compare(AudioDevice* compare) const override { return false; }
|
|
||||||
};
|
};
|
||||||
} // namespace audiodev_noop
|
} // namespace audiodev_noop
|
||||||
} // namespace usb_mic
|
} // namespace usb_mic
|
|
@ -76,9 +76,6 @@ public:
|
||||||
virtual bool Start() = 0;
|
virtual bool Start() = 0;
|
||||||
virtual void Stop() = 0;
|
virtual void Stop() = 0;
|
||||||
|
|
||||||
// Compare if another instance is using the same device
|
|
||||||
virtual bool Compare(AudioDevice* compare) const = 0;
|
|
||||||
|
|
||||||
static std::unique_ptr<AudioDevice> CreateDevice(u32 port, AudioDir dir, u32 channels, std::string devname, s32 latency);
|
static std::unique_ptr<AudioDevice> CreateDevice(u32 port, AudioDir dir, u32 channels, std::string devname, s32 latency);
|
||||||
static std::unique_ptr<AudioDevice> CreateNoopDevice(u32 port, AudioDir dir, u32 channels);
|
static std::unique_ptr<AudioDevice> CreateNoopDevice(u32 port, AudioDir dir, u32 channels);
|
||||||
static std::vector<std::pair<std::string, std::string>> GetInputDeviceList();
|
static std::vector<std::pair<std::string, std::string>> GetInputDeviceList();
|
||||||
|
|
|
@ -730,10 +730,28 @@ namespace usb_mic
|
||||||
std::string dev1(USB::GetConfigString(si, port, devtype, "player2_device_name"));
|
std::string dev1(USB::GetConfigString(si, port, devtype, "player2_device_name"));
|
||||||
const s32 latency = USB::GetConfigInt(si, port, devtype, "input_latency", AudioDevice::DEFAULT_LATENCY);
|
const s32 latency = USB::GetConfigInt(si, port, devtype, "input_latency", AudioDevice::DEFAULT_LATENCY);
|
||||||
|
|
||||||
if (!dev0.empty())
|
if (!dev0.empty() && dev0 == dev1)
|
||||||
s->audsrc[0] = AudioDevice::CreateDevice(port, AUDIODIR_SOURCE, 1, std::move(dev0), latency);
|
{
|
||||||
if (!dev1.empty())
|
// Try to open a single device with two channels. This might not work if it's only a mono mic.
|
||||||
s->audsrc[1] = AudioDevice::CreateDevice(port, AUDIODIR_SOURCE, 1, std::move(dev1), latency);
|
Console.WriteLn("USB-Mic: Trying to open stereo single source dual mic: '%s'", dev0.c_str());
|
||||||
|
s->audsrc[0] = AudioDevice::CreateDevice(port, AUDIODIR_SOURCE, 2, dev0, latency);
|
||||||
|
if (!s->audsrc[0])
|
||||||
|
{
|
||||||
|
Console.Error("USB-Mic: Failed to get stereo source, mic '%s' might only be mono", dev0.c_str());
|
||||||
|
s->audsrc[0] = AudioDevice::CreateDevice(port, AUDIODIR_SOURCE, 1, std::move(dev0), latency);
|
||||||
|
}
|
||||||
|
|
||||||
|
s->f.mode = MIC_MODE_SHARED;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!dev0.empty())
|
||||||
|
s->audsrc[0] = AudioDevice::CreateDevice(port, AUDIODIR_SOURCE, 1, std::move(dev0), latency);
|
||||||
|
if (!dev1.empty())
|
||||||
|
s->audsrc[1] = AudioDevice::CreateDevice(port, AUDIODIR_SOURCE, 1, std::move(dev1), latency);
|
||||||
|
|
||||||
|
s->f.mode = (s->audsrc[0] && s->audsrc[1]) ? MIC_MODE_SEPARATE : MIC_MODE_SINGLE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -741,6 +759,8 @@ namespace usb_mic
|
||||||
const s32 latency0 = USB::GetConfigInt(si, port, devtype, "input_latency", AudioDevice::DEFAULT_LATENCY);
|
const s32 latency0 = USB::GetConfigInt(si, port, devtype, "input_latency", AudioDevice::DEFAULT_LATENCY);
|
||||||
if (!dev0.empty())
|
if (!dev0.empty())
|
||||||
s->audsrc[0] = AudioDevice::CreateDevice(port, AUDIODIR_SOURCE, 1, std::move(dev0), latency0);
|
s->audsrc[0] = AudioDevice::CreateDevice(port, AUDIODIR_SOURCE, 1, std::move(dev0), latency0);
|
||||||
|
|
||||||
|
s->f.mode = MIC_MODE_SINGLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!s->audsrc[0] && !s->audsrc[1])
|
if (!s->audsrc[0] && !s->audsrc[1])
|
||||||
|
@ -749,16 +769,10 @@ namespace usb_mic
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s->audsrc[0] && s->audsrc[1] && s->audsrc[0]->Compare(s->audsrc[1].get()))
|
Console.WriteLn("USB-Mic Mode: %s",
|
||||||
{
|
(s->f.mode == MIC_MODE_SHARED ? "shared" : (s->f.mode == MIC_MODE_SEPARATE ? "separate" : "single")));
|
||||||
s->f.mode = MIC_MODE_SHARED;
|
Console.WriteLn("USB-Mic Source 0: %s", s->audsrc[0] ? "opened" : "not opened");
|
||||||
// And don't capture the same source twice
|
Console.WriteLn("USB-Mic Source 1: %s", s->audsrc[1] ? "opened" : "not opened");
|
||||||
s->audsrc[1].reset();
|
|
||||||
}
|
|
||||||
else if (!s->audsrc[0] || !s->audsrc[1])
|
|
||||||
s->f.mode = MIC_MODE_SINGLE;
|
|
||||||
else
|
|
||||||
s->f.mode = MIC_MODE_SEPARATE;
|
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++)
|
for (int i = 0; i < 2; i++)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue