Merge pull request #2135 from michaelgregorius/alsa-combobox

Partial fix for #1600: ALSA device can be selected using a combo box
This commit is contained in:
Colin Wallace
2015-08-26 03:21:48 +00:00
21 changed files with 378 additions and 107 deletions

View File

@@ -37,12 +37,33 @@
#include "AudioDevice.h"
class LcdSpinBox;
class QLineEdit;
class AudioAlsa : public AudioDevice, public QThread
{
// Public classes and enums
public:
/**
* @brief Contains the relevant information about available ALSA devices
*/
class DeviceInfo
{
public:
DeviceInfo(QString const & deviceName, QString const & deviceDescription) :
m_deviceName(deviceName),
m_deviceDescription(deviceDescription)
{}
~DeviceInfo() {}
QString const & getDeviceName() const { return m_deviceName; }
QString const & getDeviceDescription() const { return m_deviceDescription; }
private:
QString m_deviceName;
QString m_deviceDescription;
};
typedef std::vector<DeviceInfo> DeviceInfoCollection;
public:
AudioAlsa( bool & _success_ful, Mixer* mixer );
virtual ~AudioAlsa();
@@ -55,21 +76,7 @@ public:
static QString probeDevice();
class setupWidget : public AudioDevice::setupWidget
{
public:
setupWidget( QWidget * _parent );
virtual ~setupWidget();
virtual void saveSettings();
private:
QLineEdit * m_device;
LcdSpinBox * m_channels;
} ;
static DeviceInfoCollection getAvailableDevices();
private:
virtual void startProcessing();

View File

@@ -0,0 +1,64 @@
/*
* AudioAlsaSetupWidget.h - Implements a setup widget for ALSA-PCM-output
*
* 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.
*
*/
#ifndef AUDIO_ALSA_SETUP_WIDGET_H
#define AUDIO_ALSA_SETUP_WIDGET_H
#include "lmmsconfig.h"
#ifdef LMMS_HAVE_ALSA
#include "AudioDeviceSetupWidget.h"
#include "AudioAlsa.h"
class QComboBox;
class LcdSpinBox;
class AudioAlsaSetupWidget : public AudioDeviceSetupWidget
{
Q_OBJECT
public:
AudioAlsaSetupWidget( QWidget * _parent );
virtual ~AudioAlsaSetupWidget();
virtual void saveSettings();
public slots:
void onCurrentIndexChanged(int index);
private:
QComboBox * m_deviceComboBox;
LcdSpinBox * m_channels;
int m_selectedDevice;
AudioAlsa::DeviceInfoCollection m_deviceInfos;
};
#endif
#endif

View File

@@ -90,32 +90,6 @@ public:
class setupWidget : public TabWidget
{
public:
setupWidget( const QString & _caption, QWidget * _parent ) :
TabWidget( TabWidget::tr( "Settings for %1" ).arg(
TabWidget::tr( _caption.toLatin1() ) ).
toUpper(), _parent )
{
}
virtual ~setupWidget()
{
}
virtual void saveSettings() = 0;
virtual void show()
{
parentWidget()->show();
QWidget::show();
}
} ;
protected:
// subclasses can re-implement this for being used in conjunction with
// processNextBuffer()

View File

@@ -0,0 +1,44 @@
/*
* AudioDeviceSetupWidget.h - 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.
*
*/
#ifndef AUDIO_DEVICE_SETUP_WIDGET_H
#define AUDIO_DEVICE_SETUP_WIDGET_H
#include "TabWidget.h"
class AudioDeviceSetupWidget : public TabWidget
{
public:
AudioDeviceSetupWidget( const QString & _caption, QWidget * _parent );
virtual ~AudioDeviceSetupWidget();
virtual void saveSettings() = 0;
virtual void show();
};
#endif

View File

@@ -26,6 +26,7 @@
#define AUDIO_DUMMY_H
#include "AudioDevice.h"
#include "AudioDeviceSetupWidget.h"
#include "MicroTimer.h"
@@ -49,11 +50,11 @@ public:
}
class setupWidget : public AudioDevice::setupWidget
class setupWidget : public AudioDeviceSetupWidget
{
public:
setupWidget( QWidget * _parent ) :
AudioDevice::setupWidget( AudioDummy::name(), _parent )
AudioDeviceSetupWidget( AudioDummy::name(), _parent )
{
}

View File

@@ -35,6 +35,7 @@
#include <QtCore/QMap>
#include "AudioDevice.h"
#include "AudioDeviceSetupWidget.h"
class QLineEdit;
@@ -55,7 +56,7 @@ public:
}
class setupWidget : public AudioDevice::setupWidget
class setupWidget : public AudioDeviceSetupWidget
{
public:
setupWidget( QWidget * _parent );

View File

@@ -30,6 +30,7 @@
#ifdef LMMS_HAVE_OSS
#include "AudioDevice.h"
#include "AudioDeviceSetupWidget.h"
class LcdSpinBox;
@@ -50,7 +51,7 @@ public:
static QString probeDevice();
class setupWidget : public AudioDevice::setupWidget
class setupWidget : public AudioDeviceSetupWidget
{
public:
setupWidget( QWidget * _parent );

View File

@@ -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 );

View File

@@ -32,6 +32,7 @@
#include <pulse/pulseaudio.h>
#include "AudioDevice.h"
#include "AudioDeviceSetupWidget.h"
class LcdSpinBox;
@@ -52,7 +53,7 @@ public:
static QString probeDevice();
class setupWidget : public AudioDevice::setupWidget
class setupWidget : public AudioDeviceSetupWidget
{
public:
setupWidget( QWidget * _parent );

View File

@@ -33,6 +33,7 @@
#include <SDL/SDL_audio.h>
#include "AudioDevice.h"
#include "AudioDeviceSetupWidget.h"
class QLineEdit;
@@ -50,7 +51,7 @@ public:
}
class setupWidget : public AudioDevice::setupWidget
class setupWidget : public AudioDeviceSetupWidget
{
public:
setupWidget( QWidget * _parent );

View File

@@ -33,6 +33,8 @@
#include "AudioDevice.h"
#include "MidiClient.h"
#include "AudioDeviceSetupWidget.h"
class QComboBox;
class QLabel;
@@ -178,7 +180,7 @@ private:
bool m_displayWaveform;
bool m_disableAutoQuit;
typedef QMap<QString, AudioDevice::setupWidget *> AswMap;
typedef QMap<QString, AudioDeviceSetupWidget *> AswMap;
typedef QMap<QString, MidiClient::setupWidget *> MswMap;
typedef QMap<QString, QString> trMap;