mirror of https://github.com/PCSX2/pcsx2.git
USB: Audio devices don't need port numbers
This commit is contained in:
parent
047b8593ac
commit
8c9a65d094
|
@ -85,8 +85,8 @@ namespace usb_mic
|
||||||
{
|
{
|
||||||
namespace audiodev_cubeb
|
namespace audiodev_cubeb
|
||||||
{
|
{
|
||||||
CubebAudioDevice::CubebAudioDevice(u32 port, AudioDir dir, u32 channels, std::string devname, s32 latency)
|
CubebAudioDevice::CubebAudioDevice(AudioDir dir, u32 channels, std::string devname, s32 latency)
|
||||||
: AudioDevice(port, dir, channels)
|
: AudioDevice(dir, channels)
|
||||||
, mLatency(latency)
|
, mLatency(latency)
|
||||||
, mDeviceName(std::move(devname))
|
, mDeviceName(std::move(devname))
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace usb_mic
|
||||||
class CubebAudioDevice final : public AudioDevice
|
class CubebAudioDevice final : public AudioDevice
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CubebAudioDevice(u32 port, AudioDir dir, u32 channels, std::string devname, s32 latency);
|
CubebAudioDevice(AudioDir dir, u32 channels, std::string devname, s32 latency);
|
||||||
~CubebAudioDevice();
|
~CubebAudioDevice();
|
||||||
|
|
||||||
static std::vector<std::pair<std::string, std::string>> GetDeviceList(bool input);
|
static std::vector<std::pair<std::string, std::string>> GetDeviceList(bool input);
|
||||||
|
|
|
@ -12,9 +12,8 @@ namespace usb_mic
|
||||||
class NoopAudioDevice : public AudioDevice
|
class NoopAudioDevice : public AudioDevice
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NoopAudioDevice(
|
NoopAudioDevice(AudioDir dir, u32 channels)
|
||||||
u32 port, AudioDir dir, u32 channels)
|
: AudioDevice(dir, channels)
|
||||||
: AudioDevice(port, dir, channels)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
~NoopAudioDevice() override {}
|
~NoopAudioDevice() override {}
|
||||||
|
|
|
@ -34,15 +34,13 @@ public:
|
||||||
static constexpr s32 DEFAULT_LATENCY = 100;
|
static constexpr s32 DEFAULT_LATENCY = 100;
|
||||||
static constexpr const char* DEFAULT_LATENCY_STR = "100";
|
static constexpr const char* DEFAULT_LATENCY_STR = "100";
|
||||||
|
|
||||||
AudioDevice(u32 port, AudioDir dir, u32 channels)
|
AudioDevice(AudioDir dir, u32 channels)
|
||||||
: mPort(port)
|
: mAudioDir(dir)
|
||||||
, mAudioDir(dir)
|
|
||||||
, mChannels(channels)
|
, mChannels(channels)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
u32 mPort;
|
|
||||||
s32 mSubDevice;
|
s32 mSubDevice;
|
||||||
AudioDir mAudioDir;
|
AudioDir mAudioDir;
|
||||||
u32 mChannels;
|
u32 mChannels;
|
||||||
|
@ -64,8 +62,8 @@ public:
|
||||||
virtual bool Start() = 0;
|
virtual bool Start() = 0;
|
||||||
virtual void Stop() = 0;
|
virtual void Stop() = 0;
|
||||||
|
|
||||||
static std::unique_ptr<AudioDevice> CreateDevice(u32 port, AudioDir dir, u32 channels, std::string devname, s32 latency);
|
static std::unique_ptr<AudioDevice> CreateDevice(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(AudioDir dir, u32 channels);
|
||||||
static std::vector<std::pair<std::string, std::string>> GetInputDeviceList();
|
static std::vector<std::pair<std::string, std::string>> GetInputDeviceList();
|
||||||
static std::vector<std::pair<std::string, std::string>> GetOutputDeviceList();
|
static std::vector<std::pair<std::string, std::string>> GetOutputDeviceList();
|
||||||
};
|
};
|
||||||
|
|
|
@ -898,14 +898,14 @@ namespace usb_mic
|
||||||
const s32 output_latency = USB::GetConfigInt(si, port, TypeName(), "output_latency", AudioDevice::DEFAULT_LATENCY);
|
const s32 output_latency = USB::GetConfigInt(si, port, TypeName(), "output_latency", AudioDevice::DEFAULT_LATENCY);
|
||||||
|
|
||||||
if (!input_devname.empty())
|
if (!input_devname.empty())
|
||||||
s->audsrc = AudioDevice::CreateDevice(port, AUDIODIR_SOURCE, 1, std::move(input_devname), input_latency);
|
s->audsrc = AudioDevice::CreateDevice(AUDIODIR_SOURCE, 1, std::move(input_devname), input_latency);
|
||||||
else
|
else
|
||||||
s->audsrc = AudioDevice::CreateNoopDevice(port, AUDIODIR_SOURCE, 1);
|
s->audsrc = AudioDevice::CreateNoopDevice(AUDIODIR_SOURCE, 1);
|
||||||
|
|
||||||
if (!output_devname.empty())
|
if (!output_devname.empty())
|
||||||
s->audsink = AudioDevice::CreateDevice(port, AUDIODIR_SINK, 2, std::move(output_devname), output_latency);
|
s->audsink = AudioDevice::CreateDevice(AUDIODIR_SINK, 2, std::move(output_devname), output_latency);
|
||||||
else
|
else
|
||||||
s->audsink = AudioDevice::CreateNoopDevice(port, AUDIODIR_SINK, 2);
|
s->audsink = AudioDevice::CreateNoopDevice(AUDIODIR_SINK, 2);
|
||||||
|
|
||||||
s->f.mode = MIC_MODE_SINGLE;
|
s->f.mode = MIC_MODE_SINGLE;
|
||||||
|
|
||||||
|
|
|
@ -720,11 +720,11 @@ namespace usb_mic
|
||||||
{
|
{
|
||||||
// Try to open a single device with two channels. This might not work if it's only a mono mic.
|
// 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());
|
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);
|
s->audsrc[0] = AudioDevice::CreateDevice(AUDIODIR_SOURCE, 2, dev0, latency);
|
||||||
if (!s->audsrc[0])
|
if (!s->audsrc[0])
|
||||||
{
|
{
|
||||||
Console.Error("USB-Mic: Failed to get stereo source, mic '%s' might only be mono", dev0.c_str());
|
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->audsrc[0] = AudioDevice::CreateDevice(AUDIODIR_SOURCE, 1, std::move(dev0), latency);
|
||||||
}
|
}
|
||||||
|
|
||||||
s->f.mode = MIC_MODE_SHARED;
|
s->f.mode = MIC_MODE_SHARED;
|
||||||
|
@ -732,9 +732,9 @@ namespace usb_mic
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!dev0.empty())
|
if (!dev0.empty())
|
||||||
s->audsrc[0] = AudioDevice::CreateDevice(port, AUDIODIR_SOURCE, 1, std::move(dev0), latency);
|
s->audsrc[0] = AudioDevice::CreateDevice(AUDIODIR_SOURCE, 1, std::move(dev0), latency);
|
||||||
if (!dev1.empty())
|
if (!dev1.empty())
|
||||||
s->audsrc[1] = AudioDevice::CreateDevice(port, AUDIODIR_SOURCE, 1, std::move(dev1), latency);
|
s->audsrc[1] = AudioDevice::CreateDevice(AUDIODIR_SOURCE, 1, std::move(dev1), latency);
|
||||||
|
|
||||||
s->f.mode = (s->audsrc[0] && s->audsrc[1]) ? MIC_MODE_SEPARATE : MIC_MODE_SINGLE;
|
s->f.mode = (s->audsrc[0] && s->audsrc[1]) ? MIC_MODE_SEPARATE : MIC_MODE_SINGLE;
|
||||||
}
|
}
|
||||||
|
@ -744,7 +744,7 @@ namespace usb_mic
|
||||||
std::string dev0(USB::GetConfigString(si, port, devtype, "input_device_name"));
|
std::string dev0(USB::GetConfigString(si, port, devtype, "input_device_name"));
|
||||||
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(AUDIODIR_SOURCE, 1, std::move(dev0), latency0);
|
||||||
|
|
||||||
s->f.mode = MIC_MODE_SINGLE;
|
s->f.mode = MIC_MODE_SINGLE;
|
||||||
}
|
}
|
||||||
|
@ -890,14 +890,14 @@ namespace usb_mic
|
||||||
}
|
}
|
||||||
} // namespace usb_mic
|
} // namespace usb_mic
|
||||||
|
|
||||||
std::unique_ptr<AudioDevice> AudioDevice::CreateNoopDevice(u32 port, AudioDir dir, u32 channels)
|
std::unique_ptr<AudioDevice> AudioDevice::CreateNoopDevice(AudioDir dir, u32 channels)
|
||||||
{
|
{
|
||||||
return std::make_unique<usb_mic::audiodev_noop::NoopAudioDevice>(port, dir, channels);
|
return std::make_unique<usb_mic::audiodev_noop::NoopAudioDevice>(dir, channels);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<AudioDevice> AudioDevice::CreateDevice(u32 port, AudioDir dir, u32 channels, std::string devname, s32 latency)
|
std::unique_ptr<AudioDevice> AudioDevice::CreateDevice(AudioDir dir, u32 channels, std::string devname, s32 latency)
|
||||||
{
|
{
|
||||||
return std::make_unique<usb_mic::audiodev_cubeb::CubebAudioDevice>(port, dir, channels, std::move(devname), latency);
|
return std::make_unique<usb_mic::audiodev_cubeb::CubebAudioDevice>(dir, channels, std::move(devname), latency);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::pair<std::string, std::string>> AudioDevice::GetInputDeviceList()
|
std::vector<std::pair<std::string, std::string>> AudioDevice::GetInputDeviceList()
|
||||||
|
|
Loading…
Reference in New Issue