2
Copyright (C) 2003-2010 Fons Adriaensen <fons@kokkinizita.net>
4
This program 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 2 of the License, or
7
(at your option) any later version.
9
This program 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.
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23
#include <clthreads.h>
24
#include <clalsadrv.h>
27
// --------------------------------------------------------------------------------
37
class Audiothr : public P_thread
41
virtual void thr_main (void);
51
void Audiothr::thr_main (void)
56
buf0 = new float [frsize];
57
buf1 = new float [frsize];
59
D = new Alsa_driver (playdev, captdev, 0, fsamp, frsize, nfrags);
62
fprintf (stderr, "Can't open ALSA device\n");
74
D->capt_init (frsize);
75
D->capt_chan (0, buf0, frsize);
76
D->capt_chan (1, buf1, frsize);
77
D->capt_done (frsize);
79
D->play_init (frsize);
80
D->play_chan (0, buf0, frsize);
81
D->play_chan (1, buf1, frsize);
82
D->play_done (frsize);
93
// --------------------------------------------------------------------------------
96
int main (int ac, char *av [])
102
fprintf (stderr, "alsa-loopback <playdev><captdev><fsamp><frsize><nfrags>\n");
106
strcpy (playdev, av [1]);
107
strcpy (captdev, av [2]);
108
fsamp = atoi (av [3]);
109
frsize = atoi (av [4]);
110
nfrags = atoi (av [5]);
112
if (A.thr_start (SCHED_FIFO, -50, 0x20000))
114
fprintf (stderr, "Can't run in RT mode, trying normal scheduling.\n");
115
if (A.thr_start (SCHED_OTHER, 0, 0x20000))
117
fprintf (stderr, "Can't start audio thread.\n");
128
// --------------------------------------------------------------------------------