Fixes most of stuff found in Wallacoloo's code review for #1600
Removal of a superfluous include in AudioAlsaSetupWidget.cpp Removal of the function "bool hasCapabilities(char *device_name)" which was not used anyway. It implemented a test for ALSA device capabilities needed by LMMS (SND_PCM_ACCESS_RW_INTERLEAVED, SND_PCM_FORMAT_S16_LE, etc.). Corrected header name in AudioAlsaSetupWidget.h. Created an implementation file for AudioDeviceSetupWidget to make more clear that it's part of the GUI. Fix build for builds that use Port Audio. The setup widget of AudioPortAudio.h still inherited from AudioDevice::setupWidget instead of the new AudioDeviceSetupWidget.
This commit is contained in:
@@ -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 <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
@@ -57,7 +57,7 @@ private:
|
||||
|
||||
int m_selectedDevice;
|
||||
AudioAlsa::DeviceInfoCollection m_deviceInfos;
|
||||
} ;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -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();
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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 <tt>true</tt> 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)));
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -29,8 +29,6 @@
|
||||
|
||||
#ifdef LMMS_HAVE_ALSA
|
||||
|
||||
#include "AudioAlsa.h"
|
||||
|
||||
#include "ConfigManager.h"
|
||||
#include "LcdSpinBox.h"
|
||||
#include "gui_templates.h"
|
||||
|
||||
41
src/gui/AudioDeviceSetupWidget.cpp
Normal file
41
src/gui/AudioDeviceSetupWidget.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* AudioDeviceSetupWidget.cpp - Base class for audio device setup widgets
|
||||
*
|
||||
* Copyright (c) 2004-2015 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* 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();
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user