diff --git a/include/AudioAlsaSetupWidget.h b/include/AudioAlsaSetupWidget.h index 748536a0e..304870f22 100644 --- a/include/AudioAlsaSetupWidget.h +++ b/include/AudioAlsaSetupWidget.h @@ -1,5 +1,5 @@ /* - * AudioDeviceSetupWidget.h - Implements a setup widget for ALSA-PCM-output + * AudioAlsaSetupWidget.h - Implements a setup widget for ALSA-PCM-output * * Copyright (c) 2004-2015 Tobias Doerffel * @@ -57,7 +57,7 @@ private: int m_selectedDevice; AudioAlsa::DeviceInfoCollection m_deviceInfos; -} ; +}; #endif diff --git a/include/AudioDeviceSetupWidget.h b/include/AudioDeviceSetupWidget.h index 369d4d23c..6e23b3153 100644 --- a/include/AudioDeviceSetupWidget.h +++ b/include/AudioDeviceSetupWidget.h @@ -31,24 +31,13 @@ class AudioDeviceSetupWidget : public TabWidget { public: - AudioDeviceSetupWidget( const QString & _caption, QWidget * _parent ) : - TabWidget( TabWidget::tr( "Settings for %1" ).arg( - TabWidget::tr( _caption.toLatin1() ) ). - toUpper(), _parent ) - { - } + AudioDeviceSetupWidget( const QString & _caption, QWidget * _parent ); - virtual ~AudioDeviceSetupWidget() - { - } + virtual ~AudioDeviceSetupWidget(); virtual void saveSettings() = 0; - virtual void show() - { - parentWidget()->show(); - QWidget::show(); - } + virtual void show(); }; diff --git a/include/AudioPortAudio.h b/include/AudioPortAudio.h index a52ba52be..ab9be60c1 100644 --- a/include/AudioPortAudio.h +++ b/include/AudioPortAudio.h @@ -52,6 +52,7 @@ public: #endif #include "AudioDevice.h" +#include "AudioDeviceSetupWidget.h" #if defined paNeverDropInput || defined paNonInterleaved # define PORTAUDIO_V19 @@ -81,7 +82,7 @@ public: unsigned long _framesPerBuffer ); - class setupWidget : public AudioDevice::setupWidget + class setupWidget : public AudioDeviceSetupWidget { public: setupWidget( QWidget * _parent ); diff --git a/src/core/audio/AudioAlsa.cpp b/src/core/audio/AudioAlsa.cpp index fe26edccb..e903b436c 100644 --- a/src/core/audio/AudioAlsa.cpp +++ b/src/core/audio/AudioAlsa.cpp @@ -142,63 +142,6 @@ QString AudioAlsa::probeDevice() -/** - * @brief Checks whether the ALSA device with the given name has the needed - * capabilities for LMMS. - * @param deviceName Name of the device that is checked. - * @return If the device is usable for LMMS true is returned. - */ -bool hasCapabilities(char *device_name) -{ - snd_pcm_t *pcm; // PCM handle - snd_pcm_hw_params_t *hw_params; - int err; - - // Implicit check for SND_PCM_STREAM_PLAYBACK - err = snd_pcm_open(&pcm, device_name, SND_PCM_STREAM_PLAYBACK, 0); - if (err < 0) - { - std::cerr << "Cannot open device '" << device_name << "': " << snd_strerror(err) << std::endl; - return false; - } - - snd_pcm_hw_params_alloca(&hw_params); - err = snd_pcm_hw_params_any(pcm, hw_params); - if (err < 0) - { - std::cerr << "Cannot get hardware parameters: " << snd_strerror(err) << std::endl; - snd_pcm_close(pcm); - return false; - } - - // Checks for SND_PCM_ACCESS_RW_INTERLEAVED - err = snd_pcm_hw_params_test_access(pcm, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED); - if (err < 0) - { - std::cerr << "Interleaved access not possible for '" << device_name << "': " << snd_strerror(err) << std::endl; - snd_pcm_close(pcm); - return false; - } - - // Check for SND_PCM_FORMAT_S16_LE or SND_PCM_FORMAT_S16_BE - bool validFormatFound = false; - - validFormatFound |= !snd_pcm_hw_params_test_format(pcm, hw_params, SND_PCM_FORMAT_S16_LE); - validFormatFound |= !snd_pcm_hw_params_test_format(pcm, hw_params, SND_PCM_FORMAT_S16_BE); - - if (!validFormatFound) - { - std::cerr << "Device " << device_name << " does not not support SND_PCM_FORMAT_S16_LE or SND_PCM_FORMAT_S16_BE!" << std::endl; - snd_pcm_close(pcm); - return false; - } - - snd_pcm_close(pcm); - - return true; -} - - /** * @brief Creates a list of all available devices. * @@ -232,8 +175,6 @@ AudioAlsa::DeviceInfoCollection AudioAlsa::getAvailableDevices() char *name = snd_device_name_get_hint(*n, "NAME"); char *description = snd_device_name_get_hint(*n, "DESC"); - // We could call hasCapabilities(name) here but this gives strange - // results if (name != 0 && description != 0) { deviceInfos.push_back(DeviceInfo(QString(name), QString(description))); diff --git a/src/core/audio/AudioPortAudio.cpp b/src/core/audio/AudioPortAudio.cpp index d23baf277..b2ddf1d97 100644 --- a/src/core/audio/AudioPortAudio.cpp +++ b/src/core/audio/AudioPortAudio.cpp @@ -389,7 +389,7 @@ void AudioPortAudioSetupUtil::updateChannels() AudioPortAudio::setupWidget::setupWidget( QWidget * _parent ) : - AudioDevice::setupWidget( AudioPortAudio::name(), _parent ) + AudioDeviceSetupWidget( AudioPortAudio::name(), _parent ) { m_backend = new ComboBox( this, "BACKEND" ); m_backend->setGeometry( 64, 15, 260, 20 ); diff --git a/src/gui/AudioAlsaSetupWidget.cpp b/src/gui/AudioAlsaSetupWidget.cpp index 0e83922e4..43fe828f3 100644 --- a/src/gui/AudioAlsaSetupWidget.cpp +++ b/src/gui/AudioAlsaSetupWidget.cpp @@ -29,8 +29,6 @@ #ifdef LMMS_HAVE_ALSA -#include "AudioAlsa.h" - #include "ConfigManager.h" #include "LcdSpinBox.h" #include "gui_templates.h" diff --git a/src/gui/AudioDeviceSetupWidget.cpp b/src/gui/AudioDeviceSetupWidget.cpp new file mode 100644 index 000000000..85515aab9 --- /dev/null +++ b/src/gui/AudioDeviceSetupWidget.cpp @@ -0,0 +1,41 @@ +/* + * AudioDeviceSetupWidget.cpp - Base class for audio device setup widgets + * + * Copyright (c) 2004-2015 Tobias Doerffel + * + * This file is part of LMMS - http://lmms.io + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program (see COPYING); if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ + +#include "AudioDeviceSetupWidget.h" + +AudioDeviceSetupWidget::AudioDeviceSetupWidget( const QString & _caption, QWidget * _parent ) : + TabWidget( TabWidget::tr( "Settings for %1" ).arg(TabWidget::tr( _caption.toLatin1() ) ).toUpper(), + _parent ) +{ +} + +AudioDeviceSetupWidget::~AudioDeviceSetupWidget() +{ +} + +void AudioDeviceSetupWidget::show() +{ + parentWidget()->show(); + QWidget::show(); +} diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index bfe43f15c..00f9f6296 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -3,6 +3,7 @@ SET(LMMS_SRCS gui/AboutDialog.cpp gui/ActionGroup.cpp gui/AudioAlsaSetupWidget.cpp + gui/AudioDeviceSetupWidget.cpp gui/AutomatableModelView.cpp gui/AutomationPatternView.cpp gui/ControllerConnectionDialog.cpp