diff options
Diffstat (limited to 'drivers/alsa')
-rw-r--r-- | drivers/alsa/audio_driver_alsa.cpp | 40 | ||||
-rw-r--r-- | drivers/alsa/audio_driver_alsa.h | 13 |
2 files changed, 17 insertions, 36 deletions
diff --git a/drivers/alsa/audio_driver_alsa.cpp b/drivers/alsa/audio_driver_alsa.cpp index 48e694dd3a..414b0c28e0 100644 --- a/drivers/alsa/audio_driver_alsa.cpp +++ b/drivers/alsa/audio_driver_alsa.cpp @@ -147,7 +147,6 @@ Error AudioDriverALSA::init_device() { } Error AudioDriverALSA::init() { - active = false; thread_exited = false; exit_thread = false; @@ -161,11 +160,9 @@ Error AudioDriverALSA::init() { } void AudioDriverALSA::thread_func(void *p_udata) { - AudioDriverALSA *ad = (AudioDriverALSA *)p_udata; while (!ad->exit_thread) { - ad->lock(); ad->start_counting_ticks(); @@ -237,30 +234,27 @@ void AudioDriverALSA::thread_func(void *p_udata) { } void AudioDriverALSA::start() { - active = true; } int AudioDriverALSA::get_mix_rate() const { - return mix_rate; } AudioDriver::SpeakerMode AudioDriverALSA::get_speaker_mode() const { - return speaker_mode; } Array AudioDriverALSA::get_device_list() { - Array list; list.push_back("Default"); void **hints; - if (snd_device_name_hint(-1, "pcm", &hints) < 0) + if (snd_device_name_hint(-1, "pcm", &hints) < 0) { return list; + } for (void **n = hints; *n != nullptr; n++) { char *name = snd_device_name_get_hint(*n, "NAME"); @@ -274,10 +268,12 @@ Array AudioDriverALSA::get_device_list() { } } - if (desc != nullptr) + if (desc != nullptr) { free(desc); - if (name != nullptr) + } + if (name != nullptr) { free(name); + } } snd_device_name_free_hint(hints); @@ -285,33 +281,30 @@ Array AudioDriverALSA::get_device_list() { } String AudioDriverALSA::get_device() { - return device_name; } void AudioDriverALSA::set_device(String device) { - lock(); new_device = device; unlock(); } void AudioDriverALSA::lock() { - - if (!thread) + if (!thread) { return; + } mutex.lock(); } void AudioDriverALSA::unlock() { - - if (!thread) + if (!thread) { return; + } mutex.unlock(); } void AudioDriverALSA::finish_device() { - if (pcm_handle) { snd_pcm_close(pcm_handle); pcm_handle = nullptr; @@ -319,7 +312,6 @@ void AudioDriverALSA::finish_device() { } void AudioDriverALSA::finish() { - if (thread) { exit_thread = true; Thread::wait_to_finish(thread); @@ -331,14 +323,4 @@ void AudioDriverALSA::finish() { finish_device(); } -AudioDriverALSA::AudioDriverALSA() : - thread(nullptr), - pcm_handle(nullptr), - device_name("Default"), - new_device("Default") { -} - -AudioDriverALSA::~AudioDriverALSA() { -} - -#endif +#endif // ALSA_ENABLED diff --git a/drivers/alsa/audio_driver_alsa.h b/drivers/alsa/audio_driver_alsa.h index 50bd9e853d..7aec0c4071 100644 --- a/drivers/alsa/audio_driver_alsa.h +++ b/drivers/alsa/audio_driver_alsa.h @@ -40,14 +40,13 @@ #include <alsa/asoundlib.h> class AudioDriverALSA : public AudioDriver { - - Thread *thread; + Thread *thread = nullptr; Mutex mutex; - snd_pcm_t *pcm_handle; + snd_pcm_t *pcm_handle = nullptr; - String device_name; - String new_device; + String device_name = "Default"; + String new_device = "Default"; Vector<int32_t> samples_in; Vector<int16_t> samples_out; @@ -85,8 +84,8 @@ public: virtual void unlock(); virtual void finish(); - AudioDriverALSA(); - ~AudioDriverALSA(); + AudioDriverALSA() {} + ~AudioDriverALSA() {} }; #endif // AUDIO_DRIVER_ALSA_H |