Commit 6c8d86bb authored by Max Kellermann's avatar Max Kellermann

output/sndio: rename the "sio_hdl" variable to avoid clash with struct name

parent b253a6b7
......@@ -50,7 +50,7 @@ class SndioOutput {
AudioOutput base;
const char *const device;
const unsigned buffer_time; /* in ms */
struct sio_hdl *sio_hdl;
struct sio_hdl *hdl;
public:
SndioOutput(const ConfigBlock &block);
......@@ -80,16 +80,14 @@ SndioOutput::Create(const ConfigBlock &block)
static bool
sndio_test_default_device()
{
struct sio_hdl *sio_hdl;
sio_hdl = sio_open(SIO_DEVANY, SIO_PLAY, 0);
if (!sio_hdl) {
auto *hdl = sio_open(SIO_DEVANY, SIO_PLAY, 0);
if (!hdl) {
FormatError(sndio_output_domain,
"Error opening default sndio device");
return false;
}
sio_close(sio_hdl);
sio_close(hdl);
return true;
}
......@@ -99,8 +97,8 @@ SndioOutput::Open(AudioFormat &audio_format)
struct sio_par par;
unsigned bits, rate, chans;
sio_hdl = sio_open(device, SIO_PLAY, 0);
if (!sio_hdl)
hdl = sio_open(device, SIO_PLAY, 0);
if (!hdl)
throw std::runtime_error("Failed to open default sndio device");
switch (audio_format.format) {
......@@ -130,9 +128,9 @@ SndioOutput::Open(AudioFormat &audio_format)
par.le = SIO_LE_NATIVE;
par.appbufsz = rate * buffer_time / 1000;
if (!sio_setpar(sio_hdl, &par) ||
!sio_getpar(sio_hdl, &par)) {
sio_close(sio_hdl);
if (!sio_setpar(hdl, &par) ||
!sio_getpar(hdl, &par)) {
sio_close(hdl);
throw std::runtime_error("Failed to set/get audio params");
}
......@@ -142,12 +140,12 @@ SndioOutput::Open(AudioFormat &audio_format)
par.pchan != chans ||
par.sig != 1 ||
par.le != SIO_LE_NATIVE) {
sio_close(sio_hdl);
sio_close(hdl);
throw std::runtime_error("Requested audio params cannot be satisfied");
}
if (!sio_start(sio_hdl)) {
sio_close(sio_hdl);
if (!sio_start(hdl)) {
sio_close(hdl);
throw std::runtime_error("Failed to start audio device");
}
}
......@@ -155,7 +153,7 @@ SndioOutput::Open(AudioFormat &audio_format)
void
SndioOutput::Close()
{
sio_close(sio_hdl);
sio_close(hdl);
}
size_t
......@@ -163,8 +161,8 @@ SndioOutput::Play(const void *chunk, size_t size)
{
size_t n;
n = sio_write(sio_hdl, chunk, size);
if (n == 0 && sio_eof(sio_hdl) != 0)
n = sio_write(hdl, chunk, size);
if (n == 0 && sio_eof(hdl) != 0)
throw std::runtime_error("sndio write failed");
return n;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment