Final version that lets the user select the ALSA device with a combo box

This version lets the user select the ALSA device to use with a combo
box. It does not check whether the device works for the parameters that
LMMS uses (SND_PCM_ACCESS_RW_INTERLEAVED, SND_PCM_FORMAT_S16_LE, etc.).
Doing these checks while compiling the list of available devices led to
strange effects which are likely caused by the fact that the PCM device
has to be opened to query its capabilities. This in turn led to error
messages a la "Resource or device busy" when testing the new
functionality repeatedly.

However, having a combo box to select devices from should be a good step
forward compared to a simple line edit. :)
This commit is contained in:
Michael Gregorius
2015-06-27 20:07:26 +02:00
parent 27653b713b
commit 37c4da81b5
5 changed files with 113 additions and 169 deletions

View File

@@ -47,34 +47,19 @@ public:
class DeviceInfo
{
public:
DeviceInfo(int cardNumber, int deviceNumber,
QString const & cardName, QString const & pcmName,
QString const & cardId, QString const & pcmId) :
m_cardNumber(cardNumber),
m_deviceNumber(deviceNumber),
m_cardName(cardName),
m_pcmName(pcmName),
m_cardId(cardId),
m_pcmId(pcmId)
DeviceInfo(QString const & deviceName, QString const & deviceDescription) :
m_deviceName(deviceName),
m_deviceDescription(deviceDescription)
{}
~DeviceInfo() {}
int getCardNumber() const { return m_cardNumber; }
int getDeviceNumber() const { return m_deviceNumber; }
QString const & getCardName() const { return m_cardName; }
QString const & getPcmName() const { return m_pcmName; }
QString const & getCardId() const { return m_cardId; }
QString const & getPcmId() const { return m_pcmId; }
QString getHWString() const { return QString("hw:%1,%2").arg(m_cardNumber).arg(m_deviceNumber); }
QString const & getDeviceName() const { return m_deviceName; }
QString const & getDeviceDescription() const { return m_deviceDescription; }
private:
int m_cardNumber;
int m_deviceNumber;
QString m_cardName;
QString m_pcmName;
QString m_cardId;
QString m_pcmId;
QString m_deviceName;
QString m_deviceDescription;
};
typedef std::vector<DeviceInfo> DeviceInfoCollection;

View File

@@ -1,7 +1,7 @@
/*
* AudioAlsa.h - device-class that implements ALSA-PCM-output
* AudioDeviceSetupWidget.h - Implements a setup widget for ALSA-PCM-output
*
* Copyright (c) 2004-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2015 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of LMMS - http://lmms.io
*
@@ -33,12 +33,9 @@
#include "AudioAlsa.h"
#include <vector>
class QComboBox;
class LcdSpinBox;
class QLineEdit;
class AudioAlsaSetupWidget : public AudioDeviceSetupWidget
@@ -56,7 +53,6 @@ public slots:
private:
QComboBox * m_deviceComboBox;
QLineEdit * m_device;
LcdSpinBox * m_channels;
int m_selectedDevice;

View File

@@ -1,7 +1,7 @@
/*
* AudioDevice.h - base-class for audio-devices, used by LMMS-mixer
* AudioDeviceSetupWidget.h - Base class for audio device setup widgets
*
* Copyright (c) 2004-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2015 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of LMMS - http://lmms.io
*