diff --git a/pcsx2/USB/usb-mic/audiodev-cubeb.cpp b/pcsx2/USB/usb-mic/audiodev-cubeb.cpp index 118d542689..5b84234ba7 100644 --- a/pcsx2/USB/usb-mic/audiodev-cubeb.cpp +++ b/pcsx2/USB/usb-mic/audiodev-cubeb.cpp @@ -249,17 +249,6 @@ namespace usb_mic ResetBuffers(); } - bool CubebAudioDevice::Compare(AudioDevice* compare) const - { - if (compare) - { - CubebAudioDevice* src = static_cast(compare); - if (src && mDeviceName == src->mDeviceName) - return true; - } - return false; - } - void CubebAudioDevice::ResetBuffers() { // TODO: Do we want to make the buffer size adjustable? Currently 100ms max. diff --git a/pcsx2/USB/usb-mic/audiodev-cubeb.h b/pcsx2/USB/usb-mic/audiodev-cubeb.h index 0882ddbe5a..3dbd063b61 100644 --- a/pcsx2/USB/usb-mic/audiodev-cubeb.h +++ b/pcsx2/USB/usb-mic/audiodev-cubeb.h @@ -42,7 +42,6 @@ namespace usb_mic void SetResampling(int samplerate) override; bool Start() override; void Stop() override; - bool Compare(AudioDevice* compare) const override; protected: void ResetBuffers(); diff --git a/pcsx2/USB/usb-mic/audiodev-noop.h b/pcsx2/USB/usb-mic/audiodev-noop.h index 3e89dfbe1f..37cc068675 100644 --- a/pcsx2/USB/usb-mic/audiodev-noop.h +++ b/pcsx2/USB/usb-mic/audiodev-noop.h @@ -43,8 +43,6 @@ namespace usb_mic } uint32_t SetBuffer(int16_t* inBuf, uint32_t inFrames) override { return inFrames; } void SetResampling(int samplerate) override {} - - bool Compare(AudioDevice* compare) const override { return false; } }; } // namespace audiodev_noop } // namespace usb_mic \ No newline at end of file diff --git a/pcsx2/USB/usb-mic/audiodev.h b/pcsx2/USB/usb-mic/audiodev.h index dc16e16e0e..787647a32f 100644 --- a/pcsx2/USB/usb-mic/audiodev.h +++ b/pcsx2/USB/usb-mic/audiodev.h @@ -76,9 +76,6 @@ public: virtual bool Start() = 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 CreateDevice(u32 port, AudioDir dir, u32 channels, std::string devname, s32 latency); static std::unique_ptr CreateNoopDevice(u32 port, AudioDir dir, u32 channels); static std::vector> GetInputDeviceList(); diff --git a/pcsx2/USB/usb-mic/usb-mic-singstar.cpp b/pcsx2/USB/usb-mic/usb-mic-singstar.cpp index f89b982384..94b54304fd 100644 --- a/pcsx2/USB/usb-mic/usb-mic-singstar.cpp +++ b/pcsx2/USB/usb-mic/usb-mic-singstar.cpp @@ -730,10 +730,28 @@ namespace usb_mic std::string dev1(USB::GetConfigString(si, port, devtype, "player2_device_name")); const s32 latency = USB::GetConfigInt(si, port, devtype, "input_latency", AudioDevice::DEFAULT_LATENCY); - 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); + if (!dev0.empty() && dev0 == dev1) + { + // Try to open a single device with two channels. This might not work if it's only a mono mic. + 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 { @@ -741,6 +759,8 @@ namespace usb_mic const s32 latency0 = USB::GetConfigInt(si, port, devtype, "input_latency", AudioDevice::DEFAULT_LATENCY); if (!dev0.empty()) 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]) @@ -749,16 +769,10 @@ namespace usb_mic goto fail; } - if (s->audsrc[0] && s->audsrc[1] && s->audsrc[0]->Compare(s->audsrc[1].get())) - { - s->f.mode = MIC_MODE_SHARED; - // And don't capture the same source twice - 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; + Console.WriteLn("USB-Mic Mode: %s", + (s->f.mode == MIC_MODE_SHARED ? "shared" : (s->f.mode == MIC_MODE_SEPARATE ? "separate" : "single"))); + Console.WriteLn("USB-Mic Source 0: %s", s->audsrc[0] ? "opened" : "not opened"); + Console.WriteLn("USB-Mic Source 1: %s", s->audsrc[1] ? "opened" : "not opened"); for (int i = 0; i < 2; i++) {