aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/backends
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-11-15 06:23:01 -0800
committerChris Robinson <[email protected]>2018-11-15 06:23:01 -0800
commit7b3a2085aac8eac47f9968f331d3991167793e85 (patch)
tree5566b15f7a90fe8e0fb2b280c4f8b83c80247f4f /Alc/backends
parentab9f8162b84870161948ddd27d29483206dd4e57 (diff)
Use a regular char* for the device's name
Diffstat (limited to 'Alc/backends')
-rw-r--r--Alc/backends/alsa.cpp10
-rw-r--r--Alc/backends/coreaudio.cpp6
-rw-r--r--Alc/backends/dsound.cpp6
-rw-r--r--Alc/backends/jack.cpp7
-rw-r--r--Alc/backends/loopback.cpp3
-rw-r--r--Alc/backends/null.cpp3
-rw-r--r--Alc/backends/opensl.cpp6
-rw-r--r--Alc/backends/oss.cpp6
-rw-r--r--Alc/backends/portaudio.cpp6
-rw-r--r--Alc/backends/pulseaudio.cpp16
-rw-r--r--Alc/backends/qsa.cpp6
-rw-r--r--Alc/backends/sdl2.cpp3
-rw-r--r--Alc/backends/sndio.cpp6
-rw-r--r--Alc/backends/solaris.cpp3
-rw-r--r--Alc/backends/wasapi.cpp22
-rw-r--r--Alc/backends/wave.cpp3
-rw-r--r--Alc/backends/winmm.cpp6
17 files changed, 74 insertions, 44 deletions
diff --git a/Alc/backends/alsa.cpp b/Alc/backends/alsa.cpp
index 5a389eab..23e33e6b 100644
--- a/Alc/backends/alsa.cpp
+++ b/Alc/backends/alsa.cpp
@@ -684,7 +684,8 @@ static ALCenum ALCplaybackAlsa_open(ALCplaybackAlsa *self, const ALCchar *name)
snd_config_update_free_global();
ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice;
- alstr_copy_cstr(&device->DeviceName, name);
+ al_free(device->DeviceName);
+ device->DeviceName = alstrdup(name);
return ALC_NO_ERROR;
}
@@ -719,7 +720,7 @@ static ALCboolean ALCplaybackAlsa_reset(ALCplaybackAlsa *self)
break;
}
- bool allowmmap{!!GetConfigValueBool(alstr_get_cstr(device->DeviceName), "alsa", "mmap", 1)};
+ bool allowmmap{!!GetConfigValueBool(device->DeviceName, "alsa", "mmap", 1)};
ALuint periods{device->NumUpdates};
ALuint periodLen{static_cast<ALuint>(device->UpdateSize * U64(1000000) / device->Frequency)};
ALuint bufferLen{periodLen * periods};
@@ -790,7 +791,7 @@ static ALCboolean ALCplaybackAlsa_reset(ALCplaybackAlsa *self)
}
CHECK(snd_pcm_hw_params_set_channels(self->pcmHandle, hp, ChannelsFromDevFmt(device->FmtChans, device->AmbiOrder)));
/* set rate (implicitly constrains period/buffer parameters) */
- if(!GetConfigValueBool(alstr_get_cstr(device->DeviceName), "alsa", "allow-resampler", 0) ||
+ if(!GetConfigValueBool(device->DeviceName, "alsa", "allow-resampler", 0) ||
!(device->Flags&DEVICE_FREQUENCY_REQUEST))
{
if(snd_pcm_hw_params_set_rate_resample(self->pcmHandle, hp, 0) < 0)
@@ -1082,7 +1083,8 @@ static ALCenum ALCcaptureAlsa_open(ALCcaptureAlsa *self, const ALCchar *name)
}
}
- alstr_copy_cstr(&device->DeviceName, name);
+ al_free(device->DeviceName);
+ device->DeviceName = alstrdup(name);
return ALC_NO_ERROR;
diff --git a/Alc/backends/coreaudio.cpp b/Alc/backends/coreaudio.cpp
index 83ea4d5f..1a3f2ab1 100644
--- a/Alc/backends/coreaudio.cpp
+++ b/Alc/backends/coreaudio.cpp
@@ -143,7 +143,8 @@ static ALCenum ALCcoreAudioPlayback_open(ALCcoreAudioPlayback *self, const ALCch
return ALC_INVALID_VALUE;
}
- alstr_copy_cstr(&device->DeviceName, name);
+ al_free(device->DeviceName);
+ device->DeviceName = alstrdup(name);
return ALC_NO_ERROR;
}
@@ -673,7 +674,8 @@ static ALCenum ALCcoreAudioCapture_open(ALCcoreAudioCapture *self, const ALCchar
);
if(!self->ring) goto error;
- alstr_copy_cstr(&device->DeviceName, name);
+ al_free(device->DeviceName);
+ device->DeviceName = alstrdup(name);
return ALC_NO_ERROR;
diff --git a/Alc/backends/dsound.cpp b/Alc/backends/dsound.cpp
index 50e956ea..478bdf9a 100644
--- a/Alc/backends/dsound.cpp
+++ b/Alc/backends/dsound.cpp
@@ -396,7 +396,8 @@ static ALCenum ALCdsoundPlayback_open(ALCdsoundPlayback *self, const ALCchar *de
return ALC_INVALID_VALUE;
}
- alstr_copy_cstr(&device->DeviceName, deviceName);
+ al_free(device->DeviceName);
+ device->DeviceName = alstrdup(deviceName);
return ALC_NO_ERROR;
}
@@ -862,7 +863,8 @@ static ALCenum ALCdsoundCapture_open(ALCdsoundCapture *self, const ALCchar *devi
self->BufferBytes = DSCBDescription.dwBufferBytes;
SetDefaultWFXChannelOrder(device);
- alstr_copy_cstr(&device->DeviceName, deviceName);
+ al_free(device->DeviceName);
+ device->DeviceName = alstrdup(deviceName);
return ALC_NO_ERROR;
}
diff --git a/Alc/backends/jack.cpp b/Alc/backends/jack.cpp
index 4aa6cd78..9db75537 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(alstr_get_cstr(device->DeviceName), "jack", "buffer-size", &bufsize))
+ if(ConfigValueUInt(device->DeviceName, "jack", "buffer-size", &bufsize))
bufsize = maxu(NextPowerOf2(bufsize), device->UpdateSize);
device->NumUpdates = (bufsize+device->UpdateSize) / device->UpdateSize;
@@ -368,7 +368,8 @@ 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);
- alstr_copy_cstr(&device->DeviceName, name);
+ al_free(device->DeviceName);
+ device->DeviceName = alstrdup(name);
return ALC_NO_ERROR;
}
@@ -394,7 +395,7 @@ static ALCboolean ALCjackPlayback_reset(ALCjackPlayback *self)
device->NumUpdates = 2;
bufsize = device->UpdateSize;
- if(ConfigValueUInt(alstr_get_cstr(device->DeviceName), "jack", "buffer-size", &bufsize))
+ if(ConfigValueUInt(device->DeviceName, "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 3726463c..2eb4c935 100644
--- a/Alc/backends/loopback.cpp
+++ b/Alc/backends/loopback.cpp
@@ -62,7 +62,8 @@ static ALCenum ALCloopback_open(ALCloopback *self, const ALCchar *name)
{
ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice;
- alstr_copy_cstr(&device->DeviceName, name);
+ al_free(device->DeviceName);
+ device->DeviceName = alstrdup(name);
return ALC_NO_ERROR;
}
diff --git a/Alc/backends/null.cpp b/Alc/backends/null.cpp
index c8523c88..30d80b76 100644
--- a/Alc/backends/null.cpp
+++ b/Alc/backends/null.cpp
@@ -141,7 +141,8 @@ static ALCenum ALCnullBackend_open(ALCnullBackend *self, const ALCchar *name)
return ALC_INVALID_VALUE;
device = STATIC_CAST(ALCbackend, self)->mDevice;
- alstr_copy_cstr(&device->DeviceName, name);
+ al_free(device->DeviceName);
+ device->DeviceName = alstrdup(name);
return ALC_NO_ERROR;
}
diff --git a/Alc/backends/opensl.cpp b/Alc/backends/opensl.cpp
index 9d938ba4..689c02af 100644
--- a/Alc/backends/opensl.cpp
+++ b/Alc/backends/opensl.cpp
@@ -375,7 +375,8 @@ static ALCenum ALCopenslPlayback_open(ALCopenslPlayback *self, const ALCchar *na
return ALC_INVALID_VALUE;
}
- alstr_copy_cstr(&device->DeviceName, name);
+ al_free(device->DeviceName);
+ device->DeviceName = alstrdup(name);
return ALC_NO_ERROR;
}
@@ -900,7 +901,8 @@ static ALCenum ALCopenslCapture_open(ALCopenslCapture *self, const ALCchar *name
return ALC_INVALID_VALUE;
}
- alstr_copy_cstr(&device->DeviceName, name);
+ al_free(device->DeviceName);
+ device->DeviceName = alstrdup(name);
return ALC_NO_ERROR;
}
diff --git a/Alc/backends/oss.cpp b/Alc/backends/oss.cpp
index 618730b3..4f320b69 100644
--- a/Alc/backends/oss.cpp
+++ b/Alc/backends/oss.cpp
@@ -391,7 +391,8 @@ static ALCenum ALCplaybackOSS_open(ALCplaybackOSS *self, const ALCchar *name)
return ALC_INVALID_VALUE;
}
- alstr_copy_cstr(&device->DeviceName, name);
+ al_free(device->DeviceName);
+ device->DeviceName = alstrdup(name);
return ALC_NO_ERROR;
}
@@ -722,7 +723,8 @@ static ALCenum ALCcaptureOSS_open(ALCcaptureOSS *self, const ALCchar *name)
return ALC_OUT_OF_MEMORY;
}
- alstr_copy_cstr(&device->DeviceName, name);
+ al_free(device->DeviceName);
+ device->DeviceName = alstrdup(name);
return ALC_NO_ERROR;
}
diff --git a/Alc/backends/portaudio.cpp b/Alc/backends/portaudio.cpp
index 03194c05..7b21669a 100644
--- a/Alc/backends/portaudio.cpp
+++ b/Alc/backends/portaudio.cpp
@@ -249,7 +249,8 @@ retry_open:
return ALC_INVALID_VALUE;
}
- alstr_copy_cstr(&device->DeviceName, name);
+ al_free(device->DeviceName);
+ device->DeviceName = alstrdup(name);
return ALC_NO_ERROR;
@@ -440,7 +441,8 @@ static ALCenum ALCportCapture_open(ALCportCapture *self, const ALCchar *name)
return ALC_INVALID_VALUE;
}
- alstr_copy_cstr(&device->DeviceName, name);
+ al_free(device->DeviceName);
+ device->DeviceName = alstrdup(name);
return ALC_NO_ERROR;
}
diff --git a/Alc/backends/pulseaudio.cpp b/Alc/backends/pulseaudio.cpp
index 77719e3c..4569b91a 100644
--- a/Alc/backends/pulseaudio.cpp
+++ b/Alc/backends/pulseaudio.cpp
@@ -800,7 +800,8 @@ static void PulsePlayback_sinkNameCallback(pa_context *UNUSED(context), const pa
}
ALCdevice *device{STATIC_CAST(ALCbackend,self)->mDevice};
- alstr_copy_cstr(&device->DeviceName, info->description);
+ al_free(device->DeviceName);
+ device->DeviceName = alstrdup(info->description);
}
@@ -980,7 +981,8 @@ static ALCenum PulsePlayback_open(PulsePlayback *self, const ALCchar *name)
else
{
ALCdevice *device{STATIC_CAST(ALCbackend,self)->mDevice};
- alstr_copy_cstr(&device->DeviceName, dev_name);
+ al_free(device->DeviceName);
+ device->DeviceName = alstrdup(dev_name);
}
return ALC_NO_ERROR;
@@ -1011,7 +1013,7 @@ static 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(alstr_get_cstr(device->DeviceName), "pulse", "fix-rate", 0) ||
+ if(GetConfigValueBool(device->DeviceName, "pulse", "fix-rate", 0) ||
!(device->Flags&DEVICE_FREQUENCY_REQUEST))
flags |= PA_STREAM_FIX_RATE;
@@ -1418,7 +1420,8 @@ static void PulseCapture_sourceNameCallback(pa_context *UNUSED(context), const p
}
ALCdevice *device{STATIC_CAST(ALCbackend,self)->mDevice};
- alstr_copy_cstr(&device->DeviceName, info->description);
+ al_free(device->DeviceName);
+ device->DeviceName = alstrdup(info->description);
}
@@ -1490,7 +1493,8 @@ static ALCenum PulseCapture_open(PulseCapture *self, const ALCchar *name)
if(iter == CaptureDevices.cend())
return ALC_INVALID_VALUE;
pulse_name = iter->device_name.c_str();
- alstr_copy_cstr(&device->DeviceName, iter->name.c_str());
+ al_free(device->DeviceName);
+ device->DeviceName = alstrdup(iter->name.c_str());
}
std::tie(self->loop, self->context) = pulse_open(PulseCapture_contextStateCallback, self);
@@ -1593,7 +1597,7 @@ static 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(alstr_empty(device->DeviceName))
+ if(!device->DeviceName || device->DeviceName[0] == 0)
{
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 7afd3214..3a99d71e 100644
--- a/Alc/backends/qsa.cpp
+++ b/Alc/backends/qsa.cpp
@@ -328,7 +328,8 @@ static ALCenum qsa_open_playback(PlaybackWrapper *self, const ALCchar* deviceNam
return ALC_INVALID_DEVICE;
}
- alstr_copy_cstr(&device->DeviceName, deviceName);
+ al_free(device->DeviceName);
+ device->DeviceName = alstrdup(deviceName);
self->ExtraData = data;
return ALC_NO_ERROR;
@@ -735,7 +736,8 @@ static ALCenum qsa_open_capture(CaptureWrapper *self, const ALCchar *deviceName)
return ALC_INVALID_DEVICE;
}
- alstr_copy_cstr(&device->DeviceName, deviceName);
+ al_free(device->DeviceName);
+ device->DeviceName = alstrdup(deviceName);
self->ExtraData = data;
switch (device->FmtType)
diff --git a/Alc/backends/sdl2.cpp b/Alc/backends/sdl2.cpp
index 82c350e1..c918b57c 100644
--- a/Alc/backends/sdl2.cpp
+++ b/Alc/backends/sdl2.cpp
@@ -174,7 +174,8 @@ static ALCenum ALCsdl2Backend_open(ALCsdl2Backend *self, const ALCchar *name)
self->FmtType = device->FmtType;
self->UpdateSize = device->UpdateSize;
- alstr_copy_cstr(&device->DeviceName, name ? name : defaultDeviceName);
+ al_free(device->DeviceName);
+ device->DeviceName = alstrdup(name ? name : defaultDeviceName);
return ALC_NO_ERROR;
}
diff --git a/Alc/backends/sndio.cpp b/Alc/backends/sndio.cpp
index c97226a6..f1e678cf 100644
--- a/Alc/backends/sndio.cpp
+++ b/Alc/backends/sndio.cpp
@@ -148,7 +148,8 @@ static ALCenum SndioPlayback_open(SndioPlayback *self, const ALCchar *name)
return ALC_INVALID_VALUE;
}
- alstr_copy_cstr(&device->DeviceName, name);
+ al_free(device->DeviceName);
+ device->DeviceName = alstrdup(name);
return ALC_NO_ERROR;
}
@@ -488,7 +489,8 @@ static ALCenum SndioCapture_open(SndioCapture *self, const ALCchar *name)
SetDefaultChannelOrder(device);
- alstr_copy_cstr(&device->DeviceName, name);
+ al_free(device->DeviceName);
+ device->DeviceName = alstrdup(name);
return ALC_NO_ERROR;
}
diff --git a/Alc/backends/solaris.cpp b/Alc/backends/solaris.cpp
index b63a85e8..20dda617 100644
--- a/Alc/backends/solaris.cpp
+++ b/Alc/backends/solaris.cpp
@@ -188,7 +188,8 @@ static ALCenum ALCsolarisBackend_open(ALCsolarisBackend *self, const ALCchar *na
}
device = STATIC_CAST(ALCbackend,self)->mDevice;
- alstr_copy_cstr(&device->DeviceName, name);
+ al_free(device->DeviceName);
+ device->DeviceName = alstrdup(name);
return ALC_NO_ERROR;
}
diff --git a/Alc/backends/wasapi.cpp b/Alc/backends/wasapi.cpp
index 64e7d43c..4fb0f317 100644
--- a/Alc/backends/wasapi.cpp
+++ b/Alc/backends/wasapi.cpp
@@ -719,7 +719,8 @@ static ALCenum ALCwasapiPlayback_open(ALCwasapiPlayback *self, const ALCchar *de
{
ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice;
self->mDevId = iter->devid;
- alstr_copy_range(&device->DeviceName, &*iter->name.cbegin(), &*iter->name.cend());
+ al_free(device->DeviceName);
+ device->DeviceName = alstrdup(iter->name.c_str());
hr = S_OK;
}
}
@@ -775,11 +776,11 @@ HRESULT ALCwasapiPlayback::openProxy()
if(SUCCEEDED(hr))
{
mClient = reinterpret_cast<IAudioClient*>(ptr);
- if(alstr_empty(device->DeviceName))
+ if(!device->DeviceName || device->DeviceName[0] == 0)
{
- std::string devname;
- std::tie(devname, std::ignore) = get_device_name_and_guid(mMMDev);
- alstr_copy_range(&device->DeviceName, &*devname.cbegin(), &*devname.cend());
+ std::string devname{get_device_name_and_guid(mMMDev).first};
+ al_free(device->DeviceName);
+ device->DeviceName = alstrdup(devname.c_str());
}
}
@@ -1385,7 +1386,8 @@ static ALCenum ALCwasapiCapture_open(ALCwasapiCapture *self, const ALCchar *devi
{
ALCdevice *device = STATIC_CAST(ALCbackend,self)->mDevice;
self->mDevId = iter->devid;
- alstr_copy_range(&device->DeviceName, &*iter->name.cbegin(), &*iter->name.cend());
+ al_free(device->DeviceName);
+ device->DeviceName = alstrdup(iter->name.c_str());
hr = S_OK;
}
}
@@ -1460,11 +1462,11 @@ HRESULT ALCwasapiCapture::openProxy()
if(SUCCEEDED(hr))
{
mClient = reinterpret_cast<IAudioClient*>(ptr);
- if(alstr_empty(device->DeviceName))
+ if(!device->DeviceName || device->DeviceName[0] == 0)
{
- std::string devname;
- std::tie(devname, std::ignore) = get_device_name_and_guid(mMMDev);
- alstr_copy_range(&device->DeviceName, &*devname.cbegin(), &*devname.cend());
+ std::string devname{get_device_name_and_guid(mMMDev).first};
+ al_free(device->DeviceName);
+ device->DeviceName = alstrdup(devname.c_str());
}
}
diff --git a/Alc/backends/wave.cpp b/Alc/backends/wave.cpp
index 48b3e911..ea4af146 100644
--- a/Alc/backends/wave.cpp
+++ b/Alc/backends/wave.cpp
@@ -242,7 +242,8 @@ static ALCenum ALCwaveBackend_open(ALCwaveBackend *self, const ALCchar *name)
}
ALCdevice *device{STATIC_CAST(ALCbackend, self)->mDevice};
- alstr_copy_cstr(&device->DeviceName, name);
+ al_free(device->DeviceName);
+ device->DeviceName = alstrdup(name);
return ALC_NO_ERROR;
}
diff --git a/Alc/backends/winmm.cpp b/Alc/backends/winmm.cpp
index 6e43ff79..0c625e27 100644
--- a/Alc/backends/winmm.cpp
+++ b/Alc/backends/winmm.cpp
@@ -286,7 +286,8 @@ retry_open:
return ALC_INVALID_VALUE;
}
- alstr_copy_cstr(&device->DeviceName, PlaybackDevices[DeviceID].c_str());
+ al_free(device->DeviceName);
+ device->DeviceName = alstrdup(PlaybackDevices[DeviceID].c_str());
return ALC_NO_ERROR;
}
@@ -606,7 +607,8 @@ static ALCenum ALCwinmmCapture_open(ALCwinmmCapture *self, const ALCchar *device
self->WaveBuffer[i].dwBufferLength = self->WaveBuffer[i-1].dwBufferLength;
}
- alstr_copy_cstr(&device->DeviceName, CaptureDevices[DeviceID].c_str());
+ al_free(device->DeviceName);
+ device->DeviceName = alstrdup(CaptureDevices[DeviceID].c_str());
return ALC_NO_ERROR;
}