From 6c8d86bb9097a117de5f2c4dc7d10b1f981d9018 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 19 Sep 2017 18:49:33 +0200 Subject: [PATCH] output/sndio: rename the "sio_hdl" variable to avoid clash with struct name --- src/output/plugins/SndioOutputPlugin.cxx | 32 +++++++++++------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/src/output/plugins/SndioOutputPlugin.cxx b/src/output/plugins/SndioOutputPlugin.cxx index b0050d6ae..4f5df4981 100644 --- a/src/output/plugins/SndioOutputPlugin.cxx +++ b/src/output/plugins/SndioOutputPlugin.cxx @@ -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; }