Add COPYING licence file (GPLv3)
[magread] / audioinput.h
1 /*
2     This file is part of MagRead.
3
4     MagRead is free software: you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation, either version 3 of the License, or
7     (at your option) any later version.
8
9     MagRead is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with MagRead.  If not, see <http://www.gnu.org/licenses/>.
16     
17     Written by Jeffrey Malone <ieatlint@tehinterweb.com>
18     http://blog.tehinterweb.com
19 */
20 #ifndef AUDIOINPUT_H
21 #define AUDIOINPUT_H
22
23 #include <QThread>
24 #include <QVarLengthArray>
25 #include <QDateTime>
26 #include <pulse/pulseaudio.h>
27 #include <pulse/simple.h>
28
29 #include "mslib.h"
30 #include "magcard.h"
31
32 class AudioInput : public QThread {
33         Q_OBJECT
34         public:
35                 explicit AudioInput( QObject *parent = 0 );
36                 ~AudioInput();
37
38                 void run();
39                 void stop();
40                 void processSwipe();
41
42         signals:
43                 void cardRead( const MagCard& );
44                 void error( const QString& );
45
46         private:
47                 pa_simple *paServer;
48                 pa_sample_spec paSpec;
49                 int paError;
50
51                 bool captureAudio;
52                 int silenceThresh;
53                 QVarLengthArray<qint16, 20000> pcmData;
54
55                 MagCard card;
56
57                 msData *ms;
58 };
59
60 #endif // AUDIOINPUT_H