[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kmix/kmix-improvements] src/daemon2: Start working on ALSA backend
From:       Trever Fischer <tdfischer () fedoraproject ! org>
Date:       2012-09-26 1:35:51
Message-ID: 20120926013551.72C8FA63AA () git ! kde ! org
[Download RAW message or body]

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 which 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 <QtCore/QDebug>
 
 #include "backends/PulseAudio.h"
+#include "backends/ALSA.h"
 
 BackendManager *BackendManager::s_instance = 0;
 
@@ -34,7 +35,7 @@ BackendManager::BackendManager()
     m_groups[Control::InputStream] = new ControlGroup("Recording");
     m_groups[Control::HardwareInput] = new ControlGroup("Hardware Input");
     m_groups[Control::HardwareOutput] = new ControlGroup("Hardware Output");
-    Backend *pulse = new Backends::PulseAudio(this);
+    Backend *pulse = new Backends::ALSA(this);
     connect(pulse, SIGNAL(controlAdded(Control *)), this, \
                SLOT(handleControlAdded(Control *)));
     connect(pulse, SIGNAL(controlRemoved(Control *)), this, \
SLOT(handleControlRemoved(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 <alsa/asoundlib.h>
+#include <QtCore/QDebug>
+
+namespace Backends {
+
+ALSA::ALSA(QObject *parent)
+    : Backend(parent)
+{
+}
+
+ALSA::~ALSA()
+{
+}
+
+bool ALSA::open()
+{
+    int card = -1;
+    while (snd_card_next(&card) == 0 && card > -1) {
+        int err;
+        QString devName;
+        devName = QString("hw:%1").arg(card);
+
+        qDebug() << "Card" << devName;
+        snd_mixer_t *mixer;
+        if ((err = snd_mixer_open(&mixer, 0)) == 0) {
+            if ((err = snd_mixer_attach(mixer, devName.toAscii().constData())) == 0) \
{ +                if ((err = snd_mixer_selem_register(mixer, NULL, NULL)) != 0) {
+                    qDebug() << "Couldn't register simple controls" << \
snd_strerror(err); +                    continue;
+                }
+                if ((err = snd_mixer_load(mixer)) != 0) {
+                    qDebug() << "Couldn't load mixer" << snd_strerror(err);
+                    continue;
+                }
+                snd_mixer_elem_t *elem;
+                elem = snd_mixer_first_elem(mixer);
+                while (elem) {
+                    elem = 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 = 0);
+    ~ALSA();
+    bool open();
+};
+
+}
+
+#endif // ALSABACKEND_H


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic