Git commit fd74e8fd8e46140ddf6a3c520682ec67fbcb967b by Trever Fischer. Committed on 26/09/2012 at 03:33. Pushed by tdfischer into branch 'kmix-improvements'. Start working on ALSA backend M +2 -1 src/daemon2/BackendManager.cpp M +2 -0 src/daemon2/CMakeLists.txt A +53 -0 src/daemon2/backends/ALSA.cpp [License: UNKNOWN] * A +17 -0 src/daemon2/backends/ALSA.h [License: UNKNOWN] * The files marked with a * at the end have a non valid license. Please read:= http://techbase.kde.org/Policies/Licensing_Policy and use the headers whic= h are listed at that page. http://commits.kde.org/kmix/fd74e8fd8e46140ddf6a3c520682ec67fbcb967b diff --git a/src/daemon2/BackendManager.cpp b/src/daemon2/BackendManager.cpp index d9be01a..51ba049 100644 --- a/src/daemon2/BackendManager.cpp +++ b/src/daemon2/BackendManager.cpp @@ -25,6 +25,7 @@ #include = #include "backends/PulseAudio.h" +#include "backends/ALSA.h" = BackendManager *BackendManager::s_instance =3D 0; = @@ -34,7 +35,7 @@ BackendManager::BackendManager() m_groups[Control::InputStream] =3D new ControlGroup("Recording"); m_groups[Control::HardwareInput] =3D new ControlGroup("Hardware Input"= ); m_groups[Control::HardwareOutput] =3D new ControlGroup("Hardware Outpu= t"); - Backend *pulse =3D new Backends::PulseAudio(this); + Backend *pulse =3D new Backends::ALSA(this); connect(pulse, SIGNAL(controlAdded(Control *)), this, SLOT(handleContr= olAdded(Control *))); connect(pulse, SIGNAL(controlRemoved(Control *)), this, SLOT(handleCon= trolRemoved(Control *))); m_backends << pulse; diff --git a/src/daemon2/CMakeLists.txt b/src/daemon2/CMakeLists.txt index 995c7b0..7513156 100644 --- a/src/daemon2/CMakeLists.txt +++ b/src/daemon2/CMakeLists.txt @@ -22,6 +22,8 @@ set(kmixd_SRCS ControlGroup.cpp Control.cpp = + backends/ALSA.cpp + backends/PulseAudio.cpp backends/PulseControl.cpp backends/PulseSourceOutputControl.cpp diff --git a/src/daemon2/backends/ALSA.cpp b/src/daemon2/backends/ALSA.cpp new file mode 100644 index 0000000..0a177b4 --- /dev/null +++ b/src/daemon2/backends/ALSA.cpp @@ -0,0 +1,53 @@ +#include "ALSA.h" +#include +#include + +namespace Backends { + +ALSA::ALSA(QObject *parent) + : Backend(parent) +{ +} + +ALSA::~ALSA() +{ +} + +bool ALSA::open() +{ + int card =3D -1; + while (snd_card_next(&card) =3D=3D 0 && card > -1) { + int err; + QString devName; + devName =3D QString("hw:%1").arg(card); + + qDebug() << "Card" << devName; + snd_mixer_t *mixer; + if ((err =3D snd_mixer_open(&mixer, 0)) =3D=3D 0) { + if ((err =3D snd_mixer_attach(mixer, devName.toAscii().constDa= ta())) =3D=3D 0) { + if ((err =3D snd_mixer_selem_register(mixer, NULL, NULL)) = !=3D 0) { + qDebug() << "Couldn't register simple controls" << snd= _strerror(err); + continue; + } + if ((err =3D snd_mixer_load(mixer)) !=3D 0) { + qDebug() << "Couldn't load mixer" << snd_strerror(err); + continue; + } + snd_mixer_elem_t *elem; + elem =3D snd_mixer_first_elem(mixer); + while (elem) { + elem =3D snd_mixer_elem_next(elem); + } + snd_mixer_detach(mixer, devName.toAscii().constData()); + } else { + qDebug() << "Could not attach mixer to" << devName; + } + snd_mixer_close(mixer); + } else { + qDebug() << "Could not open mixer"; + } + } + return true; +} + +} diff --git a/src/daemon2/backends/ALSA.h b/src/daemon2/backends/ALSA.h new file mode 100644 index 0000000..2247b06 --- /dev/null +++ b/src/daemon2/backends/ALSA.h @@ -0,0 +1,17 @@ +#ifndef ALSABACKEND_H +#define ALSABACKEND_H +#include "Backend.h" + +namespace Backends { + +class ALSA : public Backend { + Q_OBJECT +public: + ALSA(QObject *parent =3D 0); + ~ALSA(); + bool open(); +}; + +} + +#endif // ALSABACKEND_H