mirror of
https://github.com/AxioDL/boo.git
synced 2025-12-09 21:47:57 +00:00
Massive fmtlib refactor
This commit is contained in:
@@ -74,7 +74,7 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine {
|
||||
argSize = sizeof(devId);
|
||||
if (AudioObjectGetPropertyData(kAudioObjectSystemObject, &propertyAddress, sizeof(devName), &devName, &argSize,
|
||||
&devId) != noErr) {
|
||||
Log.report(logvisor::Error, "unable to resolve audio device UID %s, using default",
|
||||
Log.report(logvisor::Error, fmt("unable to resolve audio device UID %s, using default"),
|
||||
CFStringGetCStringPtr(devName, kCFStringEncodingUTF8));
|
||||
argSize = sizeof(devId);
|
||||
propertyAddress.mSelector = kAudioHardwarePropertyDefaultOutputDevice;
|
||||
@@ -84,7 +84,7 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine {
|
||||
deviceAddress.mSelector = kAudioDevicePropertyDeviceUID;
|
||||
AudioObjectGetPropertyData(devId, &deviceAddress, 0, NULL, &argSize, &m_devName);
|
||||
} else {
|
||||
Log.report(logvisor::Fatal, "unable determine default audio device");
|
||||
Log.report(logvisor::Fatal, fmt("unable determine default audio device"));
|
||||
return {AudioChannelSet::Unknown, 48000.0};
|
||||
}
|
||||
}
|
||||
@@ -250,9 +250,7 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine {
|
||||
if (!(nameCstr = CFStringGetCStringPtr(namestr.get(), kCFStringEncodingUTF8)))
|
||||
continue;
|
||||
|
||||
char idStr[9];
|
||||
snprintf(idStr, 9, "%08X\n", idNum);
|
||||
ret.push_back(std::make_pair(std::string(idStr), std::string(nameCstr)));
|
||||
ret.push_back(std::make_pair(fmt::format(fmt("{:08X}"), idNum), std::string(nameCstr)));
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -271,9 +269,7 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine {
|
||||
if (MIDIObjectGetIntegerProperty(dev, kMIDIPropertyUniqueID, &idNum))
|
||||
continue;
|
||||
|
||||
char idStr[9];
|
||||
snprintf(idStr, 9, "%08X\n", idNum);
|
||||
if (strcmp(idStr, name))
|
||||
if (fmt::format(fmt("{:08X}"), idNum) != name)
|
||||
continue;
|
||||
|
||||
return dev;
|
||||
@@ -464,15 +460,15 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine {
|
||||
if (!ret)
|
||||
return {};
|
||||
|
||||
char name[256];
|
||||
std::string name;
|
||||
auto appName = APP->getFriendlyName();
|
||||
if (!m_midiInCounter)
|
||||
snprintf(name, 256, "%s MIDI-In", appName.data());
|
||||
name = fmt::format(fmt("{} MIDI-In"), appName);
|
||||
else
|
||||
snprintf(name, 256, "%s MIDI-In %u", appName.data(), m_midiInCounter);
|
||||
name = fmt::format(fmt("{} MIDI-In {}"), appName, m_midiInCounter);
|
||||
m_midiInCounter++;
|
||||
CFPointer<CFStringRef> midiName = CFPointer<CFStringRef>::adopt(
|
||||
CFStringCreateWithCStringNoCopy(nullptr, name, kCFStringEncodingUTF8, kCFAllocatorNull));
|
||||
CFStringCreateWithCStringNoCopy(nullptr, name.c_str(), kCFStringEncodingUTF8, kCFAllocatorNull));
|
||||
OSStatus stat;
|
||||
if ((stat = MIDIDestinationCreate(m_midiClient, midiName.get(), MIDIReadProc(MIDIReceiveProc),
|
||||
static_cast<IMIDIReceiver*>(ret.get()), &static_cast<MIDIIn&>(*ret).m_midi)))
|
||||
@@ -489,15 +485,15 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine {
|
||||
if (!ret)
|
||||
return {};
|
||||
|
||||
char name[256];
|
||||
std::string name;
|
||||
auto appName = APP->getFriendlyName();
|
||||
if (!m_midiOutCounter)
|
||||
snprintf(name, 256, "%s MIDI-Out", appName.data());
|
||||
name = fmt::format(fmt("{} MIDI-Out"), appName);
|
||||
else
|
||||
snprintf(name, 256, "%s MIDI-Out %u", appName.data(), m_midiOutCounter);
|
||||
name = fmt::format(fmt("{} MIDI-Out {}"), appName, m_midiOutCounter);
|
||||
m_midiOutCounter++;
|
||||
CFPointer<CFStringRef> midiName = CFPointer<CFStringRef>::adopt(
|
||||
CFStringCreateWithCStringNoCopy(nullptr, name, kCFStringEncodingUTF8, kCFAllocatorNull));
|
||||
CFStringCreateWithCStringNoCopy(nullptr, name.c_str(), kCFStringEncodingUTF8, kCFAllocatorNull));
|
||||
if (MIDISourceCreate(m_midiClient, midiName.get(), &static_cast<MIDIOut&>(*ret).m_midi))
|
||||
ret.reset();
|
||||
|
||||
@@ -512,15 +508,15 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine {
|
||||
if (!ret)
|
||||
return {};
|
||||
|
||||
char name[256];
|
||||
std::string name;
|
||||
auto appName = APP->getFriendlyName();
|
||||
if (!m_midiInCounter)
|
||||
snprintf(name, 256, "%s MIDI-In", appName.data());
|
||||
name = fmt::format(fmt("{} MIDI-In"), appName);
|
||||
else
|
||||
snprintf(name, 256, "%s MIDI-In %u", appName.data(), m_midiInCounter);
|
||||
name = fmt::format(fmt("{} MIDI-In {}"), appName, m_midiInCounter);
|
||||
m_midiInCounter++;
|
||||
CFPointer<CFStringRef> midiName = CFPointer<CFStringRef>::adopt(
|
||||
CFStringCreateWithCStringNoCopy(nullptr, name, kCFStringEncodingUTF8, kCFAllocatorNull));
|
||||
CFStringCreateWithCStringNoCopy(nullptr, name.c_str(), kCFStringEncodingUTF8, kCFAllocatorNull));
|
||||
if (MIDIDestinationCreate(m_midiClient, midiName.get(), MIDIReadProc(MIDIReceiveProc),
|
||||
static_cast<IMIDIReceiver*>(ret.get()), &static_cast<MIDIInOut&>(*ret).m_midiIn))
|
||||
ret.reset();
|
||||
@@ -529,12 +525,12 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine {
|
||||
return {};
|
||||
|
||||
if (!m_midiOutCounter)
|
||||
snprintf(name, 256, "%s MIDI-Out", appName.data());
|
||||
name = fmt::format(fmt("{} MIDI-Out"), appName);
|
||||
else
|
||||
snprintf(name, 256, "%s MIDI-Out %u", appName.data(), m_midiOutCounter);
|
||||
name = fmt::format(fmt("{} MIDI-Out {}"), appName, m_midiOutCounter);
|
||||
m_midiOutCounter++;
|
||||
midiName = CFPointer<CFStringRef>::adopt(
|
||||
CFStringCreateWithCStringNoCopy(nullptr, name, kCFStringEncodingUTF8, kCFAllocatorNull));
|
||||
CFStringCreateWithCStringNoCopy(nullptr, name.c_str(), kCFStringEncodingUTF8, kCFAllocatorNull));
|
||||
if (MIDISourceCreate(m_midiClient, midiName.get(), &static_cast<MIDIInOut&>(*ret).m_midiOut))
|
||||
ret.reset();
|
||||
|
||||
@@ -553,10 +549,9 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine {
|
||||
if (!ret)
|
||||
return {};
|
||||
|
||||
char mname[256];
|
||||
snprintf(mname, 256, "Boo MIDI Real In %u", m_midiInCounter++);
|
||||
std::string mname = fmt::format(fmt("Boo MIDI Real In {}"), m_midiInCounter++);
|
||||
CFPointer<CFStringRef> midiName = CFPointer<CFStringRef>::adopt(
|
||||
CFStringCreateWithCStringNoCopy(nullptr, mname, kCFStringEncodingUTF8, kCFAllocatorNull));
|
||||
CFStringCreateWithCStringNoCopy(nullptr, mname.c_str(), kCFStringEncodingUTF8, kCFAllocatorNull));
|
||||
if (MIDIInputPortCreate(m_midiClient, midiName.get(), MIDIReadProc(MIDIReceiveProc),
|
||||
static_cast<IMIDIReceiver*>(ret.get()), &static_cast<MIDIIn&>(*ret).m_midiPort))
|
||||
ret.reset();
|
||||
@@ -578,10 +573,9 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine {
|
||||
if (!ret)
|
||||
return {};
|
||||
|
||||
char mname[256];
|
||||
snprintf(mname, 256, "Boo MIDI Real Out %u", m_midiOutCounter++);
|
||||
std::string mname = fmt::format(fmt("Boo MIDI Real Out {}"), m_midiOutCounter++);
|
||||
CFPointer<CFStringRef> midiName = CFPointer<CFStringRef>::adopt(
|
||||
CFStringCreateWithCStringNoCopy(nullptr, mname, kCFStringEncodingUTF8, kCFAllocatorNull));
|
||||
CFStringCreateWithCStringNoCopy(nullptr, mname.c_str(), kCFStringEncodingUTF8, kCFAllocatorNull));
|
||||
if (MIDIOutputPortCreate(m_midiClient, midiName.get(), &static_cast<MIDIOut&>(*ret).m_midiPort))
|
||||
ret.reset();
|
||||
else
|
||||
@@ -606,10 +600,9 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine {
|
||||
if (!ret)
|
||||
return {};
|
||||
|
||||
char mname[256];
|
||||
snprintf(mname, 256, "Boo MIDI Real In %u", m_midiInCounter++);
|
||||
std::string mname = fmt::format(fmt("Boo MIDI Real In {}"), m_midiInCounter++);
|
||||
CFPointer<CFStringRef> midiName = CFPointer<CFStringRef>::adopt(
|
||||
CFStringCreateWithCStringNoCopy(nullptr, mname, kCFStringEncodingUTF8, kCFAllocatorNull));
|
||||
CFStringCreateWithCStringNoCopy(nullptr, mname.c_str(), kCFStringEncodingUTF8, kCFAllocatorNull));
|
||||
if (MIDIInputPortCreate(m_midiClient, midiName.get(), MIDIReadProc(MIDIReceiveProc),
|
||||
static_cast<IMIDIReceiver*>(ret.get()), &static_cast<MIDIInOut&>(*ret).m_midiPortIn))
|
||||
ret.reset();
|
||||
@@ -619,9 +612,9 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine {
|
||||
if (!ret)
|
||||
return {};
|
||||
|
||||
snprintf(mname, 256, "Boo MIDI Real Out %u", m_midiOutCounter++);
|
||||
mname = fmt::format(fmt("Boo MIDI Real Out {}"), m_midiOutCounter++);
|
||||
midiName = CFPointer<CFStringRef>::adopt(
|
||||
CFStringCreateWithCStringNoCopy(nullptr, mname, kCFStringEncodingUTF8, kCFAllocatorNull));
|
||||
CFStringCreateWithCStringNoCopy(nullptr, mname.c_str(), kCFStringEncodingUTF8, kCFAllocatorNull));
|
||||
if (MIDIOutputPortCreate(m_midiClient, midiName.get(), &static_cast<MIDIInOut&>(*ret).m_midiPortOut))
|
||||
ret.reset();
|
||||
else
|
||||
@@ -661,13 +654,13 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine {
|
||||
OSStatus err;
|
||||
if ((err = AudioQueueNewOutput(&desc, AudioQueueOutputCallback(Callback), this, CFRunLoopGetCurrent(),
|
||||
m_runLoopMode.get(), 0, &m_queue))) {
|
||||
Log.report(logvisor::Fatal, "unable to create output audio queue");
|
||||
Log.report(logvisor::Fatal, fmt("unable to create output audio queue"));
|
||||
return;
|
||||
}
|
||||
|
||||
CFStringRef devName = m_devName.get();
|
||||
if ((err = AudioQueueSetProperty(m_queue, kAudioQueueProperty_CurrentDevice, &devName, sizeof(devName)))) {
|
||||
Log.report(logvisor::Fatal, "unable to set current device into audio queue");
|
||||
Log.report(logvisor::Fatal, fmt("unable to set current device into audio queue"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -685,7 +678,7 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine {
|
||||
AudioChannelLayout layout;
|
||||
UInt32 layoutSz = sizeof(layout);
|
||||
if (AudioQueueGetProperty(m_queue, kAudioQueueProperty_ChannelLayout, &layout, &layoutSz)) {
|
||||
Log.report(logvisor::Warning, "unable to get channel layout from audio queue; using count's default");
|
||||
Log.report(logvisor::Warning, fmt("unable to get channel layout from audio queue; using count's default"));
|
||||
switch (m_mixInfo.m_channels) {
|
||||
case AudioChannelSet::Stereo:
|
||||
default:
|
||||
@@ -766,7 +759,7 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine {
|
||||
chMapOut.m_channels[4] = AudioChannel::FrontCenter;
|
||||
break;
|
||||
default:
|
||||
Log.report(logvisor::Warning, "unknown channel layout %u; using stereo", layout.mChannelLayoutTag);
|
||||
Log.report(logvisor::Warning, fmt("unknown channel layout %u; using stereo"), layout.mChannelLayoutTag);
|
||||
chMapOut.m_channelCount = 2;
|
||||
chMapOut.m_channels[0] = AudioChannel::FrontLeft;
|
||||
chMapOut.m_channels[1] = AudioChannel::FrontRight;
|
||||
@@ -784,7 +777,7 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine {
|
||||
m_mixInfo.m_periodFrames = m_5msFrames;
|
||||
for (int i = 0; i < AQS_NUM_BUFFERS; ++i)
|
||||
if (AudioQueueAllocateBuffer(m_queue, m_mixInfo.m_periodFrames * chCount * 4, &m_buffers[i])) {
|
||||
Log.report(logvisor::Fatal, "unable to create audio queue buffer");
|
||||
Log.report(logvisor::Fatal, fmt("unable to create audio queue buffer"));
|
||||
AudioQueueDispose(m_queue, false);
|
||||
m_queue = nullptr;
|
||||
return;
|
||||
@@ -834,7 +827,7 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine {
|
||||
deviceAddress.mSelector = kAudioDevicePropertyDeviceUID;
|
||||
AudioObjectGetPropertyData(defaultDeviceId, &deviceAddress, 0, NULL, &argSize, &m_devName);
|
||||
} else {
|
||||
Log.report(logvisor::Fatal, "unable determine default audio device");
|
||||
Log.report(logvisor::Fatal, fmt("unable determine default audio device"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ template int32_t* AudioSubmix::_getMergeBuf<int32_t>(size_t frames);
|
||||
template float* AudioSubmix::_getMergeBuf<float>(size_t frames);
|
||||
|
||||
template <typename T>
|
||||
static inline T ClampInt(float in) {
|
||||
constexpr T ClampInt(float in) {
|
||||
if (std::is_floating_point<T>()) {
|
||||
return in; // Allow subsequent mixing stages to work with over-saturated values
|
||||
} else {
|
||||
|
||||
@@ -27,7 +27,7 @@ void AudioVoice::_setPitchRatio(double ratio, bool slew) {
|
||||
m_sampleRatio = ratio * m_sampleRateIn / m_sampleRateOut;
|
||||
soxr_error_t err = soxr_set_io_ratio(m_src, m_sampleRatio, slew ? m_head->m_5msFrames : 0);
|
||||
if (err) {
|
||||
Log.report(logvisor::Fatal, "unable to set resampler rate: %s", soxr_strerror(err));
|
||||
Log.report(logvisor::Fatal, fmt("unable to set resampler rate: {}"), soxr_strerror(err));
|
||||
m_setPitchRatio = false;
|
||||
return;
|
||||
}
|
||||
@@ -74,7 +74,7 @@ void AudioVoiceMono::_resetSampleRate(double sampleRate) {
|
||||
m_src = soxr_create(sampleRate, rateOut, 1, &err, &ioSpec, &qSpec, nullptr);
|
||||
|
||||
if (err) {
|
||||
Log.report(logvisor::Fatal, "unable to create soxr resampler: %s", soxr_strerror(err));
|
||||
Log.report(logvisor::Fatal, fmt("unable to create soxr resampler: {}"), soxr_strerror(err));
|
||||
m_resetSampleRate = false;
|
||||
return;
|
||||
}
|
||||
@@ -195,7 +195,7 @@ void AudioVoiceStereo::_resetSampleRate(double sampleRate) {
|
||||
m_src = soxr_create(sampleRate, rateOut, 2, &err, &ioSpec, &qSpec, nullptr);
|
||||
|
||||
if (!m_src) {
|
||||
Log.report(logvisor::Fatal, "unable to create soxr resampler: %s", soxr_strerror(err));
|
||||
Log.report(logvisor::Fatal, fmt("unable to create soxr resampler: {}"), soxr_strerror(err));
|
||||
m_resetSampleRate = false;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -45,11 +45,10 @@ struct LinuxMidi : BaseAudioVoiceEngine {
|
||||
|
||||
while (card >= 0) {
|
||||
snd_ctl_t* ctl;
|
||||
char name[32];
|
||||
int device = -1;
|
||||
int status;
|
||||
sprintf(name, "hw:%d", card);
|
||||
if ((status = snd_ctl_open(&ctl, name, 0)) < 0)
|
||||
std::string name = fmt::format(fmt("hw:{}"), card);
|
||||
if ((status = snd_ctl_open(&ctl, name.c_str(), 0)) < 0)
|
||||
continue;
|
||||
|
||||
do {
|
||||
@@ -57,7 +56,7 @@ struct LinuxMidi : BaseAudioVoiceEngine {
|
||||
if (status < 0)
|
||||
break;
|
||||
if (device >= 0) {
|
||||
sprintf(name + strlen(name), ",%d", device);
|
||||
name += fmt::format(fmt(",{}"), device);
|
||||
auto search = m_openHandles.find(name);
|
||||
if (search != m_openHandles.cend()) {
|
||||
ret.push_back(std::make_pair(name, search->second->description()));
|
||||
@@ -65,7 +64,7 @@ struct LinuxMidi : BaseAudioVoiceEngine {
|
||||
}
|
||||
|
||||
snd_rawmidi_t* midi;
|
||||
if (!snd_rawmidi_open(&midi, nullptr, name, SND_RAWMIDI_NONBLOCK)) {
|
||||
if (!snd_rawmidi_open(&midi, nullptr, name.c_str(), SND_RAWMIDI_NONBLOCK)) {
|
||||
snd_rawmidi_info(midi, info);
|
||||
ret.push_back(std::make_pair(name, snd_rawmidi_info_get_name(info)));
|
||||
snd_rawmidi_close(midi);
|
||||
@@ -102,7 +101,7 @@ struct LinuxMidi : BaseAudioVoiceEngine {
|
||||
int rdBytes = snd_rawmidi_read(midi, buf, 512);
|
||||
if (rdBytes < 0) {
|
||||
if (rdBytes != -EINTR) {
|
||||
ALSALog.report(logvisor::Error, "MIDI connection lost");
|
||||
ALSALog.report(logvisor::Error, fmt("MIDI connection lost"));
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
|
||||
@@ -31,7 +31,7 @@ inline T ClampFull(float in) {
|
||||
#endif
|
||||
|
||||
#if USE_LPF
|
||||
static constexpr int FirTaps = 27;
|
||||
constexpr int FirTaps = 27;
|
||||
|
||||
FIRFilter12k::FIRFilter12k(int windowFrames, double sampleRate) {
|
||||
Ipp64f* taps = ippsMalloc_64f(FirTaps);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
namespace boo {
|
||||
|
||||
static inline uint8_t clamp7(uint8_t val) { return std::max(0, std::min(127, int(val))); }
|
||||
constexpr uint8_t clamp7(uint8_t val) { return std::max(0, std::min(127, int(val))); }
|
||||
|
||||
bool MIDIDecoder::_readContinuedValue(std::vector<uint8_t>::const_iterator& it,
|
||||
std::vector<uint8_t>::const_iterator end, uint32_t& valOut) {
|
||||
|
||||
@@ -68,7 +68,7 @@ struct PulseAudioVoiceEngine : LinuxMidi {
|
||||
pa_operation_unref(op);
|
||||
|
||||
if (m_sampleSpec.format == PA_SAMPLE_INVALID) {
|
||||
Log.report(logvisor::Error, "Unable to setup audio stream");
|
||||
Log.report(logvisor::Error, fmt("Unable to setup audio stream"));
|
||||
goto err;
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ struct PulseAudioVoiceEngine : LinuxMidi {
|
||||
m_mixInfo.m_bitsPerSample = 32;
|
||||
m_mixInfo.m_periodFrames = m_5msFrames;
|
||||
if (!(m_stream = pa_stream_new(m_ctx, "master", &m_sampleSpec, &m_chanMap))) {
|
||||
Log.report(logvisor::Error, "Unable to pa_stream_new(): %s", pa_strerror(pa_context_errno(m_ctx)));
|
||||
Log.report(logvisor::Error, fmt("Unable to pa_stream_new(): {}"), pa_strerror(pa_context_errno(m_ctx)));
|
||||
goto err;
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ struct PulseAudioVoiceEngine : LinuxMidi {
|
||||
if (pa_stream_connect_playback(m_stream, m_sinkName.c_str(), &bufAttr,
|
||||
pa_stream_flags_t(PA_STREAM_START_UNMUTED | PA_STREAM_EARLY_REQUESTS), nullptr,
|
||||
nullptr)) {
|
||||
Log.report(logvisor::Error, "Unable to pa_stream_connect_playback()");
|
||||
Log.report(logvisor::Error, fmt("Unable to pa_stream_connect_playback()"));
|
||||
goto err;
|
||||
}
|
||||
|
||||
@@ -114,18 +114,16 @@ struct PulseAudioVoiceEngine : LinuxMidi {
|
||||
|
||||
PulseAudioVoiceEngine() {
|
||||
if (!(m_mainloop = pa_mainloop_new())) {
|
||||
Log.report(logvisor::Error, "Unable to pa_mainloop_new()");
|
||||
Log.report(logvisor::Error, fmt("Unable to pa_mainloop_new()"));
|
||||
return;
|
||||
}
|
||||
|
||||
pa_mainloop_api* mlApi = pa_mainloop_get_api(m_mainloop);
|
||||
pa_proplist* propList = pa_proplist_new();
|
||||
pa_proplist_sets(propList, PA_PROP_APPLICATION_ICON_NAME, APP->getUniqueName().data());
|
||||
char pidStr[16];
|
||||
snprintf(pidStr, 16, "%d", int(getpid()));
|
||||
pa_proplist_sets(propList, PA_PROP_APPLICATION_PROCESS_ID, pidStr);
|
||||
pa_proplist_sets(propList, PA_PROP_APPLICATION_PROCESS_ID, fmt::format(fmt("{}"), int(getpid())).c_str());
|
||||
if (!(m_ctx = pa_context_new_with_proplist(mlApi, APP->getFriendlyName().data(), propList))) {
|
||||
Log.report(logvisor::Error, "Unable to pa_context_new_with_proplist()");
|
||||
Log.report(logvisor::Error, fmt("Unable to pa_context_new_with_proplist()"));
|
||||
pa_mainloop_free(m_mainloop);
|
||||
m_mainloop = nullptr;
|
||||
return;
|
||||
@@ -134,7 +132,7 @@ struct PulseAudioVoiceEngine : LinuxMidi {
|
||||
pa_operation* op;
|
||||
|
||||
if (pa_context_connect(m_ctx, nullptr, PA_CONTEXT_NOFLAGS, nullptr)) {
|
||||
Log.report(logvisor::Error, "Unable to pa_context_connect()");
|
||||
Log.report(logvisor::Error, fmt("Unable to pa_context_connect()"));
|
||||
goto err;
|
||||
}
|
||||
|
||||
@@ -341,17 +339,16 @@ struct PulseAudioVoiceEngine : LinuxMidi {
|
||||
size_t nbytes = writablePeriods * periodSz;
|
||||
if (pa_stream_begin_write(m_stream, &data, &nbytes)) {
|
||||
pa_stream_state_t st = pa_stream_get_state(m_stream);
|
||||
Log.report(logvisor::Error, "Unable to pa_stream_begin_write(): %s %d", pa_strerror(pa_context_errno(m_ctx)), st);
|
||||
Log.report(logvisor::Error, fmt("Unable to pa_stream_begin_write(): {} {}"), pa_strerror(pa_context_errno(m_ctx)), st);
|
||||
_doIterate();
|
||||
return;
|
||||
}
|
||||
|
||||
writablePeriods = nbytes / periodSz;
|
||||
size_t periodSamples = m_mixInfo.m_periodFrames * m_mixInfo.m_channelMap.m_channelCount;
|
||||
_pumpAndMixVoices(m_mixInfo.m_periodFrames * writablePeriods, reinterpret_cast<float*>(data));
|
||||
|
||||
if (pa_stream_write(m_stream, data, nbytes, nullptr, 0, PA_SEEK_RELATIVE))
|
||||
Log.report(logvisor::Error, "Unable to pa_stream_write()");
|
||||
Log.report(logvisor::Error, fmt("Unable to pa_stream_write()"));
|
||||
|
||||
_doIterate();
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ struct WASAPIAudioVoiceEngine : BaseAudioVoiceEngine {
|
||||
#if !WINDOWS_STORE
|
||||
if (!m_device) {
|
||||
if (FAILED(m_enumerator->GetDevice(MBSTWCS(m_sinkName.c_str()).c_str(), &m_device))) {
|
||||
Log.report(logvisor::Error, "unable to obtain audio device %s", m_sinkName.c_str());
|
||||
Log.report(logvisor::Error, fmt("unable to obtain audio device %s"), m_sinkName.c_str());
|
||||
m_device.Reset();
|
||||
return;
|
||||
}
|
||||
@@ -200,7 +200,7 @@ struct WASAPIAudioVoiceEngine : BaseAudioVoiceEngine {
|
||||
chMapOut.m_channels[7] = AudioChannel::SideRight;
|
||||
break;
|
||||
default:
|
||||
Log.report(logvisor::Warning, "unknown channel layout %u; using stereo", pwfx->Format.nChannels);
|
||||
Log.report(logvisor::Warning, fmt("unknown channel layout %u; using stereo"), pwfx->Format.nChannels);
|
||||
chMapOut.m_channelCount = 2;
|
||||
chMapOut.m_channels[0] = AudioChannel::FrontLeft;
|
||||
chMapOut.m_channels[1] = AudioChannel::FrontRight;
|
||||
@@ -468,7 +468,7 @@ struct WASAPIAudioVoiceEngine : BaseAudioVoiceEngine {
|
||||
bool setCurrentAudioOutput(const char* name) {
|
||||
ComPtr<IMMDevice> newDevice;
|
||||
if (FAILED(m_enumerator->GetDevice(MBSTWCS(name).c_str(), &newDevice))) {
|
||||
Log.report(logvisor::Error, "unable to obtain audio device %s", name);
|
||||
Log.report(logvisor::Error, fmt("unable to obtain audio device %s"), name);
|
||||
return false;
|
||||
}
|
||||
m_device = newDevice;
|
||||
@@ -514,34 +514,32 @@ struct WASAPIAudioVoiceEngine : BaseAudioVoiceEngine {
|
||||
ret.reserve(numInDevices);
|
||||
|
||||
for (UINT i = 0; i < numInDevices; ++i) {
|
||||
char name[256];
|
||||
snprintf(name, 256, "in%u", i);
|
||||
std::string name = fmt::format(fmt("in{}"), i);
|
||||
|
||||
MIDIINCAPS caps;
|
||||
if (FAILED(midiInGetDevCaps(i, &caps, sizeof(caps))))
|
||||
continue;
|
||||
|
||||
#ifdef UNICODE
|
||||
ret.push_back(std::make_pair(std::string(name), WCSTMBS(caps.szPname)));
|
||||
ret.push_back(std::make_pair(std::move(name), WCSTMBS(caps.szPname)));
|
||||
#else
|
||||
ret.push_back(std::make_pair(std::string(name), std::string(caps.szPname)));
|
||||
ret.push_back(std::make_pair(std::move(name), std::string(caps.szPname)));
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
for (UINT i=0 ; i<numOutDevices ; ++i)
|
||||
{
|
||||
char name[256];
|
||||
snprintf(name, 256, "out%u", i);
|
||||
std::string name = fmt::format(fmt("out{}"), i);
|
||||
|
||||
MIDIOUTCAPS caps;
|
||||
if (FAILED(midiOutGetDevCaps(i, &caps, sizeof(caps))))
|
||||
continue;
|
||||
|
||||
#ifdef UNICODE
|
||||
ret.push_back(std::make_pair(std::string(name), WCSTMBS(caps.szPname)));
|
||||
ret.push_back(std::make_pair(std::move(name), WCSTMBS(caps.szPname)));
|
||||
#else
|
||||
ret.push_back(std::make_pair(std::string(name), std::string(caps.szPname)));
|
||||
ret.push_back(std::make_pair(std::move(name), std::string(caps.szPname)));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user