diff options
author | Max Kellermann <max@duempel.org> | 2014-05-11 17:14:49 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-05-11 17:14:49 +0200 |
commit | d4b625b48e6bbac61b4128aeeaf44911b2e3e03b (patch) | |
tree | 67389c99a559c1b65bf6465c2361a4e3c01d4287 /src/input/plugins/AlsaInputPlugin.cxx | |
parent | 82337dec44347017ca04fe975e85e6d9e4edb635 (diff) | |
download | mpd-d4b625b48e6bbac61b4128aeeaf44911b2e3e03b.tar.gz mpd-d4b625b48e6bbac61b4128aeeaf44911b2e3e03b.tar.xz mpd-d4b625b48e6bbac61b4128aeeaf44911b2e3e03b.zip |
InputStream: make various methods abstract
Replace InputPlugin attributes.
Diffstat (limited to '')
-rw-r--r-- | src/input/plugins/AlsaInputPlugin.cxx | 44 |
1 files changed, 9 insertions, 35 deletions
diff --git a/src/input/plugins/AlsaInputPlugin.cxx b/src/input/plugins/AlsaInputPlugin.cxx index 2049c5635..b4673afcf 100644 --- a/src/input/plugins/AlsaInputPlugin.cxx +++ b/src/input/plugins/AlsaInputPlugin.cxx @@ -116,7 +116,13 @@ public: static InputStream *Create(const char *uri, Mutex &mutex, Cond &cond, Error &error); - bool Available() { + /* virtual methods from InputStream */ + + bool IsEOF() override { + return eof; + } + + bool IsAvailable() override { if (snd_pcm_avail(capture_handle) > frames_to_read) return true; @@ -126,11 +132,7 @@ public: return false; } - size_t Read(void *ptr, size_t size, Error &error); - - bool IsEOF() { - return eof; - } + size_t Read(void *ptr, size_t size, Error &error) override; private: static snd_pcm_t *OpenDevice(const char *device, int rate, @@ -181,7 +183,7 @@ AlsaInputStream::Create(const char *uri, Mutex &mutex, Cond &cond, handle, frame_size); } -inline size_t +size_t AlsaInputStream::Read(void *ptr, size_t read_size, Error &error) { assert(ptr != nullptr); @@ -373,37 +375,9 @@ alsa_input_open(const char *uri, Mutex &mutex, Cond &cond, Error &error) return AlsaInputStream::Create(uri, mutex, cond, error); } -static bool -alsa_input_available(InputStream *is) -{ - AlsaInputStream *ais = (AlsaInputStream *)is; - return ais->Available(); -} - -static size_t -alsa_input_read(InputStream *is, void *ptr, size_t size, Error &error) -{ - AlsaInputStream *ais = (AlsaInputStream *)is; - return ais->Read(ptr, size, error); -} - -static bool -alsa_input_eof(gcc_unused InputStream *is) -{ - AlsaInputStream *ais = (AlsaInputStream *)is; - return ais->IsEOF(); -} - const struct InputPlugin input_plugin_alsa = { "alsa", nullptr, nullptr, alsa_input_open, - nullptr, - nullptr, - nullptr, - alsa_input_available, - alsa_input_read, - alsa_input_eof, - nullptr, }; |