diff options
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/alc.cpp | 33 | ||||
-rw-r--r-- | Alc/backends/alsa.cpp | 10 | ||||
-rw-r--r-- | Alc/backends/coreaudio.cpp | 7 | ||||
-rw-r--r-- | Alc/backends/dsound.cpp | 8 | ||||
-rw-r--r-- | Alc/backends/jack.cpp | 8 | ||||
-rw-r--r-- | Alc/backends/loopback.cpp | 3 | ||||
-rw-r--r-- | Alc/backends/null.cpp | 3 | ||||
-rw-r--r-- | Alc/backends/opensl.cpp | 8 | ||||
-rw-r--r-- | Alc/backends/oss.cpp | 8 | ||||
-rw-r--r-- | Alc/backends/portaudio.cpp | 8 | ||||
-rw-r--r-- | Alc/backends/pulseaudio.cpp | 16 | ||||
-rw-r--r-- | Alc/backends/qsa.cpp | 6 | ||||
-rw-r--r-- | Alc/backends/sdl2.cpp | 4 | ||||
-rw-r--r-- | Alc/backends/sndio.cpp | 8 | ||||
-rw-r--r-- | Alc/backends/solaris.cpp | 3 | ||||
-rw-r--r-- | Alc/backends/wasapi.cpp | 22 | ||||
-rw-r--r-- | Alc/backends/wave.cpp | 3 | ||||
-rw-r--r-- | Alc/backends/winmm.cpp | 6 | ||||
-rw-r--r-- | Alc/panning.cpp | 18 |
19 files changed, 64 insertions, 118 deletions
diff --git a/Alc/alc.cpp b/Alc/alc.cpp index 5de72b4c..e2f562a1 100644 --- a/Alc/alc.cpp +++ b/Alc/alc.cpp @@ -1952,7 +1952,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) } #undef TRACE_ATTR - ConfigValueUInt(device->DeviceName, nullptr, "frequency", &freq); + ConfigValueUInt(device->DeviceName.c_str(), nullptr, "frequency", &freq); freq = maxu(freq, MIN_OUTPUT_RATE); device->UpdateSize = (ALuint64)device->UpdateSize * freq / @@ -1966,7 +1966,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) if(numMono > INT_MAX-numStereo) numMono = INT_MAX-numStereo; numMono += numStereo; - if(ConfigValueInt(device->DeviceName, nullptr, "sources", &numMono)) + if(ConfigValueInt(device->DeviceName.c_str(), nullptr, "sources", &numMono)) { if(numMono <= 0) numMono = 256; @@ -1980,7 +1980,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) device->NumMonoSources = numMono; device->NumStereoSources = numStereo; - if(ConfigValueInt(device->DeviceName, nullptr, "sends", &new_sends)) + if(ConfigValueInt(device->DeviceName.c_str(), nullptr, "sends", &new_sends)) new_sends = mini(numSends, clampi(new_sends, 0, MAX_SENDS)); else new_sends = numSends; @@ -2022,7 +2022,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) if(device->Type != Loopback) { const char *hrtf; - if(ConfigValueStr(device->DeviceName, nullptr, "hrtf", &hrtf)) + if(ConfigValueStr(device->DeviceName.c_str(), nullptr, "hrtf", &hrtf)) { if(strcasecmp(hrtf, "true") == 0) hrtf_userreq = Hrtf_Enable; @@ -2038,7 +2038,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) if(VECTOR_SIZE(device->HrtfList) == 0) { VECTOR_DEINIT(device->HrtfList); - device->HrtfList = EnumerateHrtf(device->DeviceName); + device->HrtfList = EnumerateHrtf(device->DeviceName.c_str()); } if(VECTOR_SIZE(device->HrtfList) > 0) { @@ -2150,10 +2150,10 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) device->AuxiliaryEffectSlotMax, device->NumAuxSends); device->DitherDepth = 0.0f; - if(GetConfigValueBool(device->DeviceName, nullptr, "dither", 1)) + if(GetConfigValueBool(device->DeviceName.c_str(), nullptr, "dither", 1)) { ALint depth = 0; - ConfigValueInt(device->DeviceName, nullptr, "dither-depth", &depth); + ConfigValueInt(device->DeviceName.c_str(), nullptr, "dither-depth", &depth); if(depth <= 0) { switch(device->FmtType) @@ -2186,7 +2186,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) device->DitherDepth); device->LimiterState = gainLimiter; - if(ConfigValueBool(device->DeviceName, nullptr, "output-limiter", &val)) + if(ConfigValueBool(device->DeviceName.c_str(), nullptr, "output-limiter", &val)) gainLimiter = val ? ALC_TRUE : ALC_FALSE; /* Valid values for gainLimiter are ALC_DONT_CARE_SOFT, ALC_TRUE, and @@ -2473,9 +2473,6 @@ ALCdevice_struct::~ALCdevice_struct() ChannelDelay[i].Buffer = nullptr; } - al_free(DeviceName); - DeviceName = nullptr; - al_free(Dry.Buffer); Dry.Buffer = nullptr; Dry.NumChannels = 0; @@ -2995,7 +2992,7 @@ ALC_API const ALCchar* ALC_APIENTRY alcGetString(ALCdevice *Device, ALCenum para case ALC_ALL_DEVICES_SPECIFIER: if(VerifyDevice(&Device)) { - value = Device->DeviceName; + value = Device->DeviceName.c_str(); ALCdevice_DecRef(Device); } else @@ -3008,7 +3005,7 @@ ALC_API const ALCchar* ALC_APIENTRY alcGetString(ALCdevice *Device, ALCenum para case ALC_CAPTURE_DEVICE_SPECIFIER: if(VerifyDevice(&Device)) { - value = Device->DeviceName; + value = Device->DeviceName.c_str(); ALCdevice_DecRef(Device); } else @@ -3375,7 +3372,7 @@ static ALCsizei GetIntegerv(ALCdevice *device, ALCenum param, ALCsizei size, ALC case ALC_NUM_HRTF_SPECIFIERS_SOFT: almtx_lock(&device->BackendLock); FreeHrtfList(&device->HrtfList); - device->HrtfList = EnumerateHrtf(device->DeviceName); + device->HrtfList = EnumerateHrtf(device->DeviceName.c_str()); values[0] = (ALCint)VECTOR_SIZE(device->HrtfList); almtx_unlock(&device->BackendLock); return 1; @@ -3715,7 +3712,7 @@ ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCin InitContext(ALContext); - if(ConfigValueFloat(device->DeviceName, nullptr, "volume-adjust", &valf)) + if(ConfigValueFloat(device->DeviceName.c_str(), nullptr, "volume-adjust", &valf)) { if(!std::isfinite(valf)) ERR("volume-adjust must be finite: %f\n", valf); @@ -4022,7 +4019,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) return nullptr; } - if(ConfigValueStr(device->DeviceName, nullptr, "ambi-format", &fmt)) + if(ConfigValueStr(device->DeviceName.c_str(), nullptr, "ambi-format", &fmt)) { if(strcasecmp(fmt, "fuma") == 0) { @@ -4050,7 +4047,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) } while(!DeviceList.compare_exchange_weak(head, device)); } - TRACE("Created device %p, \"%s\"\n", device, device->DeviceName); + TRACE("Created device %p, \"%s\"\n", device, device->DeviceName.c_str()); return device; } @@ -4174,7 +4171,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *deviceName, } while(!DeviceList.compare_exchange_weak(head, device)); } - TRACE("Created device %p, \"%s\"\n", device, device->DeviceName); + TRACE("Created device %p, \"%s\"\n", device, device->DeviceName.c_str()); return device; } diff --git a/Alc/backends/alsa.cpp b/Alc/backends/alsa.cpp index bcc13a66..b3adfafa 100644 --- a/Alc/backends/alsa.cpp +++ b/Alc/backends/alsa.cpp @@ -681,8 +681,7 @@ ALCenum ALCplaybackAlsa_open(ALCplaybackAlsa *self, const ALCchar *name) snd_config_update_free_global(); ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; - al_free(device->DeviceName); - device->DeviceName = alstrdup(name); + device->DeviceName = name; return ALC_NO_ERROR; } @@ -717,7 +716,7 @@ ALCboolean ALCplaybackAlsa_reset(ALCplaybackAlsa *self) break; } - bool allowmmap{!!GetConfigValueBool(device->DeviceName, "alsa", "mmap", 1)}; + bool allowmmap{!!GetConfigValueBool(device->DeviceName.c_str(), "alsa", "mmap", 1)}; ALuint periods{device->NumUpdates}; ALuint periodLen{static_cast<ALuint>(device->UpdateSize * U64(1000000) / device->Frequency)}; ALuint bufferLen{periodLen * periods}; @@ -788,7 +787,7 @@ ALCboolean ALCplaybackAlsa_reset(ALCplaybackAlsa *self) } CHECK(snd_pcm_hw_params_set_channels(self->pcmHandle, hp, ChannelsFromDevFmt(device->FmtChans, device->mAmbiOrder))); /* set rate (implicitly constrains period/buffer parameters) */ - if(!GetConfigValueBool(device->DeviceName, "alsa", "allow-resampler", 0) || + if(!GetConfigValueBool(device->DeviceName.c_str(), "alsa", "allow-resampler", 0) || !(device->Flags&DEVICE_FREQUENCY_REQUEST)) { if(snd_pcm_hw_params_set_rate_resample(self->pcmHandle, hp, 0) < 0) @@ -1080,8 +1079,7 @@ ALCenum ALCcaptureAlsa_open(ALCcaptureAlsa *self, const ALCchar *name) } } - al_free(device->DeviceName); - device->DeviceName = alstrdup(name); + device->DeviceName = name; return ALC_NO_ERROR; diff --git a/Alc/backends/coreaudio.cpp b/Alc/backends/coreaudio.cpp index a7d5445e..158331f1 100644 --- a/Alc/backends/coreaudio.cpp +++ b/Alc/backends/coreaudio.cpp @@ -143,8 +143,7 @@ static ALCenum ALCcoreAudioPlayback_open(ALCcoreAudioPlayback *self, const ALCch return ALC_INVALID_VALUE; } - al_free(device->DeviceName); - device->DeviceName = alstrdup(name); + device->DeviceName = name; return ALC_NO_ERROR; } @@ -674,9 +673,7 @@ static ALCenum ALCcoreAudioCapture_open(ALCcoreAudioCapture *self, const ALCchar ); if(!self->ring) goto error; - al_free(device->DeviceName); - device->DeviceName = alstrdup(name); - + device->DeviceName = name; return ALC_NO_ERROR; error: diff --git a/Alc/backends/dsound.cpp b/Alc/backends/dsound.cpp index b642dfea..6a8b0754 100644 --- a/Alc/backends/dsound.cpp +++ b/Alc/backends/dsound.cpp @@ -398,9 +398,7 @@ ALCenum ALCdsoundPlayback_open(ALCdsoundPlayback *self, const ALCchar *deviceNam return ALC_INVALID_VALUE; } - al_free(device->DeviceName); - device->DeviceName = alstrdup(deviceName); - + device->DeviceName = deviceName; return ALC_NO_ERROR; } @@ -864,9 +862,7 @@ ALCenum ALCdsoundCapture_open(ALCdsoundCapture *self, const ALCchar *deviceName) self->BufferBytes = DSCBDescription.dwBufferBytes; SetDefaultWFXChannelOrder(device); - al_free(device->DeviceName); - device->DeviceName = alstrdup(deviceName); - + device->DeviceName = deviceName; return ALC_NO_ERROR; } diff --git a/Alc/backends/jack.cpp b/Alc/backends/jack.cpp index ed404a19..c72958e7 100644 --- a/Alc/backends/jack.cpp +++ b/Alc/backends/jack.cpp @@ -224,7 +224,7 @@ static int ALCjackPlayback_bufferSizeNotify(jack_nframes_t numframes, void *arg) device->NumUpdates = 2; bufsize = device->UpdateSize; - if(ConfigValueUInt(device->DeviceName, "jack", "buffer-size", &bufsize)) + if(ConfigValueUInt(device->DeviceName.c_str(), "jack", "buffer-size", &bufsize)) bufsize = maxu(NextPowerOf2(bufsize), device->UpdateSize); device->NumUpdates = (bufsize+device->UpdateSize) / device->UpdateSize; @@ -368,9 +368,7 @@ static ALCenum ALCjackPlayback_open(ALCjackPlayback *self, const ALCchar *name) jack_set_process_callback(self->Client, ALCjackPlayback_process, self); jack_set_buffer_size_callback(self->Client, ALCjackPlayback_bufferSizeNotify, self); - al_free(device->DeviceName); - device->DeviceName = alstrdup(name); - + device->DeviceName = name; return ALC_NO_ERROR; } @@ -395,7 +393,7 @@ static ALCboolean ALCjackPlayback_reset(ALCjackPlayback *self) device->NumUpdates = 2; bufsize = device->UpdateSize; - if(ConfigValueUInt(device->DeviceName, "jack", "buffer-size", &bufsize)) + if(ConfigValueUInt(device->DeviceName.c_str(), "jack", "buffer-size", &bufsize)) bufsize = maxu(NextPowerOf2(bufsize), device->UpdateSize); device->NumUpdates = (bufsize+device->UpdateSize) / device->UpdateSize; diff --git a/Alc/backends/loopback.cpp b/Alc/backends/loopback.cpp index 843cb18e..5a6e14b5 100644 --- a/Alc/backends/loopback.cpp +++ b/Alc/backends/loopback.cpp @@ -64,8 +64,7 @@ ALCenum ALCloopback_open(ALCloopback *self, const ALCchar *name) { ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice; - al_free(device->DeviceName); - device->DeviceName = alstrdup(name); + device->DeviceName = name; return ALC_NO_ERROR; } diff --git a/Alc/backends/null.cpp b/Alc/backends/null.cpp index 7c27e22c..255aa01f 100644 --- a/Alc/backends/null.cpp +++ b/Alc/backends/null.cpp @@ -140,8 +140,7 @@ ALCenum ALCnullBackend_open(ALCnullBackend *self, const ALCchar *name) return ALC_INVALID_VALUE; device = STATIC_CAST(ALCbackend, self)->mDevice; - al_free(device->DeviceName); - device->DeviceName = alstrdup(name); + device->DeviceName = name; return ALC_NO_ERROR; } diff --git a/Alc/backends/opensl.cpp b/Alc/backends/opensl.cpp index e292dfe4..d0b1a7b1 100644 --- a/Alc/backends/opensl.cpp +++ b/Alc/backends/opensl.cpp @@ -375,9 +375,7 @@ static ALCenum ALCopenslPlayback_open(ALCopenslPlayback *self, const ALCchar *na return ALC_INVALID_VALUE; } - al_free(device->DeviceName); - device->DeviceName = alstrdup(name); - + device->DeviceName = name; return ALC_NO_ERROR; } @@ -901,9 +899,7 @@ static ALCenum ALCopenslCapture_open(ALCopenslCapture *self, const ALCchar *name return ALC_INVALID_VALUE; } - al_free(device->DeviceName); - device->DeviceName = alstrdup(name); - + device->DeviceName = name; return ALC_NO_ERROR; } diff --git a/Alc/backends/oss.cpp b/Alc/backends/oss.cpp index 38d1c40d..32ee1022 100644 --- a/Alc/backends/oss.cpp +++ b/Alc/backends/oss.cpp @@ -380,9 +380,7 @@ ALCenum ALCplaybackOSS_open(ALCplaybackOSS *self, const ALCchar *name) return ALC_INVALID_VALUE; } - al_free(device->DeviceName); - device->DeviceName = alstrdup(name); - + device->DeviceName = name; return ALC_NO_ERROR; } @@ -712,9 +710,7 @@ ALCenum ALCcaptureOSS_open(ALCcaptureOSS *self, const ALCchar *name) return ALC_OUT_OF_MEMORY; } - al_free(device->DeviceName); - device->DeviceName = alstrdup(name); - + device->DeviceName = name; return ALC_NO_ERROR; } diff --git a/Alc/backends/portaudio.cpp b/Alc/backends/portaudio.cpp index f8506baa..1a74250e 100644 --- a/Alc/backends/portaudio.cpp +++ b/Alc/backends/portaudio.cpp @@ -251,9 +251,7 @@ retry_open: return ALC_INVALID_VALUE; } - al_free(device->DeviceName); - device->DeviceName = alstrdup(name); - + device->DeviceName = name; return ALC_NO_ERROR; } @@ -443,9 +441,7 @@ ALCenum ALCportCapture_open(ALCportCapture *self, const ALCchar *name) return ALC_INVALID_VALUE; } - al_free(device->DeviceName); - device->DeviceName = alstrdup(name); - + device->DeviceName = name; return ALC_NO_ERROR; } diff --git a/Alc/backends/pulseaudio.cpp b/Alc/backends/pulseaudio.cpp index bf98c757..d0c1c229 100644 --- a/Alc/backends/pulseaudio.cpp +++ b/Alc/backends/pulseaudio.cpp @@ -798,8 +798,7 @@ void PulsePlayback_sinkNameCallback(pa_context *UNUSED(context), const pa_sink_i } ALCdevice *device{STATIC_CAST(ALCbackend,self)->mDevice}; - al_free(device->DeviceName); - device->DeviceName = alstrdup(info->description); + device->DeviceName = info->description; } @@ -979,8 +978,7 @@ ALCenum PulsePlayback_open(PulsePlayback *self, const ALCchar *name) else { ALCdevice *device{STATIC_CAST(ALCbackend,self)->mDevice}; - al_free(device->DeviceName); - device->DeviceName = alstrdup(dev_name); + device->DeviceName = dev_name; } return ALC_NO_ERROR; @@ -1011,7 +1009,7 @@ ALCboolean PulsePlayback_reset(PulsePlayback *self) PA_STREAM_INTERPOLATE_TIMING | PA_STREAM_AUTO_TIMING_UPDATE}; if(!GetConfigValueBool(nullptr, "pulse", "allow-moves", 0)) flags |= PA_STREAM_DONT_MOVE; - if(GetConfigValueBool(device->DeviceName, "pulse", "fix-rate", 0) || + if(GetConfigValueBool(device->DeviceName.c_str(), "pulse", "fix-rate", 0) || !(device->Flags&DEVICE_FREQUENCY_REQUEST)) flags |= PA_STREAM_FIX_RATE; @@ -1418,8 +1416,7 @@ void PulseCapture_sourceNameCallback(pa_context *UNUSED(context), const pa_sourc } ALCdevice *device{STATIC_CAST(ALCbackend,self)->mDevice}; - al_free(device->DeviceName); - device->DeviceName = alstrdup(info->description); + device->DeviceName = info->description; } @@ -1491,8 +1488,7 @@ ALCenum PulseCapture_open(PulseCapture *self, const ALCchar *name) if(iter == CaptureDevices.cend()) return ALC_INVALID_VALUE; pulse_name = iter->device_name.c_str(); - al_free(device->DeviceName); - device->DeviceName = alstrdup(iter->name.c_str()); + device->DeviceName = iter->name; } std::tie(self->loop, self->context) = pulse_open(PulseCapture_contextStateCallback, self); @@ -1595,7 +1591,7 @@ ALCenum PulseCapture_open(PulseCapture *self, const ALCchar *name) pa_stream_set_state_callback(self->stream, PulseCapture_streamStateCallback, self); self->device_name = pa_stream_get_device_name(self->stream); - if(!device->DeviceName || device->DeviceName[0] == 0) + if(device->DeviceName.empty()) { pa_operation *op{pa_context_get_source_info_by_name(self->context, self->device_name.c_str(), PulseCapture_sourceNameCallback, self diff --git a/Alc/backends/qsa.cpp b/Alc/backends/qsa.cpp index e171fb92..6db480d9 100644 --- a/Alc/backends/qsa.cpp +++ b/Alc/backends/qsa.cpp @@ -326,8 +326,7 @@ static ALCenum qsa_open_playback(PlaybackWrapper *self, const ALCchar* deviceNam return ALC_INVALID_DEVICE; } - al_free(device->DeviceName); - device->DeviceName = alstrdup(deviceName); + device->DeviceName = deviceName; self->ExtraData = data; return ALC_NO_ERROR; @@ -734,8 +733,7 @@ static ALCenum qsa_open_capture(CaptureWrapper *self, const ALCchar *deviceName) return ALC_INVALID_DEVICE; } - al_free(device->DeviceName); - device->DeviceName = alstrdup(deviceName); + device->DeviceName = deviceName; self->ExtraData = data; switch (device->FmtType) diff --git a/Alc/backends/sdl2.cpp b/Alc/backends/sdl2.cpp index 2ef7d852..d643faa3 100644 --- a/Alc/backends/sdl2.cpp +++ b/Alc/backends/sdl2.cpp @@ -174,9 +174,7 @@ static ALCenum ALCsdl2Backend_open(ALCsdl2Backend *self, const ALCchar *name) self->FmtType = device->FmtType; self->UpdateSize = device->UpdateSize; - al_free(device->DeviceName); - device->DeviceName = alstrdup(name ? name : defaultDeviceName); - + device->DeviceName = name ? name : defaultDeviceName; return ALC_NO_ERROR; } diff --git a/Alc/backends/sndio.cpp b/Alc/backends/sndio.cpp index be6cd2e3..958bc2ff 100644 --- a/Alc/backends/sndio.cpp +++ b/Alc/backends/sndio.cpp @@ -148,9 +148,7 @@ static ALCenum SndioPlayback_open(SndioPlayback *self, const ALCchar *name) return ALC_INVALID_VALUE; } - al_free(device->DeviceName); - device->DeviceName = alstrdup(name); - + device->DeviceName = name; return ALC_NO_ERROR; } @@ -489,9 +487,7 @@ static ALCenum SndioCapture_open(SndioCapture *self, const ALCchar *name) SetDefaultChannelOrder(device); - al_free(device->DeviceName); - device->DeviceName = alstrdup(name); - + device->DeviceName = name; return ALC_NO_ERROR; } diff --git a/Alc/backends/solaris.cpp b/Alc/backends/solaris.cpp index d306a0c5..86120491 100644 --- a/Alc/backends/solaris.cpp +++ b/Alc/backends/solaris.cpp @@ -188,8 +188,7 @@ static ALCenum ALCsolarisBackend_open(ALCsolarisBackend *self, const ALCchar *na } device = STATIC_CAST(ALCbackend,self)->mDevice; - al_free(device->DeviceName); - device->DeviceName = alstrdup(name); + device->DeviceName = name; return ALC_NO_ERROR; } diff --git a/Alc/backends/wasapi.cpp b/Alc/backends/wasapi.cpp index 76d5f1ef..751c56d8 100644 --- a/Alc/backends/wasapi.cpp +++ b/Alc/backends/wasapi.cpp @@ -716,8 +716,7 @@ ALCenum ALCwasapiPlayback_open(ALCwasapiPlayback *self, const ALCchar *deviceNam { ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice; self->mDevId = iter->devid; - al_free(device->DeviceName); - device->DeviceName = alstrdup(iter->name.c_str()); + device->DeviceName = iter->name; hr = S_OK; } } @@ -773,12 +772,8 @@ HRESULT ALCwasapiPlayback::openProxy() if(SUCCEEDED(hr)) { mClient = reinterpret_cast<IAudioClient*>(ptr); - if(!device->DeviceName || device->DeviceName[0] == 0) - { - std::string devname{get_device_name_and_guid(mMMDev).first}; - al_free(device->DeviceName); - device->DeviceName = alstrdup(devname.c_str()); - } + if(device->DeviceName.empty()) + device->DeviceName = get_device_name_and_guid(mMMDev).first; } if(FAILED(hr)) @@ -1383,8 +1378,7 @@ ALCenum ALCwasapiCapture_open(ALCwasapiCapture *self, const ALCchar *deviceName) { ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice; self->mDevId = iter->devid; - al_free(device->DeviceName); - device->DeviceName = alstrdup(iter->name.c_str()); + device->DeviceName = iter->name; hr = S_OK; } } @@ -1459,12 +1453,8 @@ HRESULT ALCwasapiCapture::openProxy() if(SUCCEEDED(hr)) { mClient = reinterpret_cast<IAudioClient*>(ptr); - if(!device->DeviceName || device->DeviceName[0] == 0) - { - std::string devname{get_device_name_and_guid(mMMDev).first}; - al_free(device->DeviceName); - device->DeviceName = alstrdup(devname.c_str()); - } + if(device->DeviceName.empty()) + device->DeviceName = get_device_name_and_guid(mMMDev).first; } if(FAILED(hr)) diff --git a/Alc/backends/wave.cpp b/Alc/backends/wave.cpp index af1fd768..3f8d8c97 100644 --- a/Alc/backends/wave.cpp +++ b/Alc/backends/wave.cpp @@ -240,8 +240,7 @@ ALCenum ALCwaveBackend_open(ALCwaveBackend *self, const ALCchar *name) } ALCdevice *device{STATIC_CAST(ALCbackend, self)->mDevice}; - al_free(device->DeviceName); - device->DeviceName = alstrdup(name); + device->DeviceName = name; return ALC_NO_ERROR; } diff --git a/Alc/backends/winmm.cpp b/Alc/backends/winmm.cpp index 8b97daab..9da3e4c3 100644 --- a/Alc/backends/winmm.cpp +++ b/Alc/backends/winmm.cpp @@ -285,8 +285,7 @@ retry_open: return ALC_INVALID_VALUE; } - al_free(device->DeviceName); - device->DeviceName = alstrdup(PlaybackDevices[DeviceID].c_str()); + device->DeviceName = PlaybackDevices[DeviceID]; return ALC_NO_ERROR; } @@ -606,8 +605,7 @@ ALCenum ALCwinmmCapture_open(ALCwinmmCapture *self, const ALCchar *deviceName) self->WaveBuffer[i].dwBufferLength = self->WaveBuffer[i-1].dwBufferLength; } - al_free(device->DeviceName); - device->DeviceName = alstrdup(CaptureDevices[DeviceID].c_str()); + device->DeviceName = CaptureDevices[DeviceID]; return ALC_NO_ERROR; } diff --git a/Alc/panning.cpp b/Alc/panning.cpp index 0d62e086..020d8237 100644 --- a/Alc/panning.cpp +++ b/Alc/panning.cpp @@ -379,7 +379,7 @@ static const ChannelMap MonoCfg[1] = { static void InitNearFieldCtrl(ALCdevice *device, ALfloat ctrl_dist, ALsizei order, const ALsizei *RESTRICT chans_per_order) { - const char *devname = device->DeviceName; + const char *devname = device->DeviceName.c_str(); ALsizei i; if(GetConfigValueBool(devname, "decoder", "nfc", 1) && ctrl_dist > 0.0f) @@ -399,7 +399,7 @@ static void InitNearFieldCtrl(ALCdevice *device, ALfloat ctrl_dist, ALsizei orde static void InitDistanceComp(ALCdevice *device, const AmbDecConf *conf, const ALsizei speakermap[MAX_OUTPUT_CHANNELS]) { - const char *devname = device->DeviceName; + const char *devname = device->DeviceName.c_str(); ALfloat maxdist = 0.0f; size_t total = 0; ALsizei i; @@ -512,7 +512,7 @@ static void InitPanning(ALCdevice *device) if(device->FmtChans == DevFmtAmbi3D) { - const char *devname = device->DeviceName; + const char *devname = device->DeviceName.c_str(); const ALsizei *acnmap = (device->mAmbiLayout == AmbiLayout_FuMa) ? FuMa2ACN : ACN2ACN; const ALfloat *n3dscale = (device->mAmbiScale == AmbiNorm_FuMa) ? FuMa2N3DScale : (device->mAmbiScale == AmbiNorm_SN3D) ? SN3D2N3DScale : @@ -966,7 +966,7 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, enum HrtfRequestMode hrtf if(hrtf_appreq == Hrtf_Enable) device->HrtfStatus = ALC_HRTF_UNSUPPORTED_FORMAT_SOFT; - devname = device->DeviceName; + devname = device->DeviceName.c_str(); switch(device->FmtChans) { case DevFmtQuad: layout = "quad"; break; @@ -1072,7 +1072,7 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, enum HrtfRequestMode hrtf if(device->Type != Loopback) { const char *mode; - if(ConfigValueStr(device->DeviceName, NULL, "stereo-mode", &mode)) + if(ConfigValueStr(device->DeviceName.c_str(), NULL, "stereo-mode", &mode)) { if(strcasecmp(mode, "headphones") == 0) headphones = true; @@ -1107,7 +1107,7 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, enum HrtfRequestMode hrtf if(VECTOR_SIZE(device->HrtfList) == 0) { VECTOR_DEINIT(device->HrtfList); - device->HrtfList = EnumerateHrtf(device->DeviceName); + device->HrtfList = EnumerateHrtf(device->DeviceName.c_str()); } if(hrtf_id >= 0 && (size_t)hrtf_id < VECTOR_SIZE(device->HrtfList)) @@ -1143,7 +1143,7 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, enum HrtfRequestMode hrtf old_hrtf = NULL; device->Render_Mode = HrtfRender; - if(ConfigValueStr(device->DeviceName, NULL, "hrtf-mode", &mode)) + if(ConfigValueStr(device->DeviceName.c_str(), NULL, "hrtf-mode", &mode)) { if(strcasecmp(mode, "full") == 0) device->Render_Mode = HrtfRender; @@ -1187,7 +1187,7 @@ no_hrtf: bs2blevel = ((headphones && hrtf_appreq != Hrtf_Disable) || (hrtf_appreq == Hrtf_Enable)) ? 5 : 0; if(device->Type != Loopback) - ConfigValueInt(device->DeviceName, NULL, "cf_level", &bs2blevel); + ConfigValueInt(device->DeviceName.c_str(), NULL, "cf_level", &bs2blevel); if(bs2blevel > 0 && bs2blevel <= 6) { device->Bs2b = reinterpret_cast<struct bs2b*>(al_calloc(16, sizeof(*device->Bs2b))); @@ -1199,7 +1199,7 @@ no_hrtf: TRACE("BS2B disabled\n"); - if(ConfigValueStr(device->DeviceName, NULL, "stereo-encoding", &mode)) + if(ConfigValueStr(device->DeviceName.c_str(), NULL, "stereo-encoding", &mode)) { if(strcasecmp(mode, "uhj") == 0) device->Render_Mode = NormalRender; |