/usr/share/doc/libclalsadrv-dev/examples/apps/loopback.cc is in libclalsadrv-dev 2.0.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | /*
Copyright (C) 2003-2010 Fons Adriaensen <fons@kokkinizita.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <clthreads.h>
#include <clalsadrv.h>
// --------------------------------------------------------------------------------
char playdev [256];
char captdev [256];
unsigned long fsamp;
unsigned long frsize;
unsigned long nfrags;
class Audiothr : public P_thread
{
public:
virtual void thr_main (void);
private:
float *buf0;
float *buf1;
};
void Audiothr::thr_main (void)
{
Alsa_driver *D;
unsigned long k;
buf0 = new float [frsize];
buf1 = new float [frsize];
D = new Alsa_driver (playdev, captdev, 0, fsamp, frsize, nfrags);
if (D->stat ())
{
fprintf (stderr, "Can't open ALSA device\n");
delete D;
return;
}
D->printinfo ();
D->pcm_start ();
while (1)
{
k = D->pcm_wait ();
while (k >= frsize)
{
D->capt_init (frsize);
D->capt_chan (0, buf0, frsize);
D->capt_chan (1, buf1, frsize);
D->capt_done (frsize);
D->play_init (frsize);
D->play_chan (0, buf0, frsize);
D->play_chan (1, buf1, frsize);
D->play_done (frsize);
k -= frsize;
}
}
D->pcm_stop ();
delete D;
}
// --------------------------------------------------------------------------------
int main (int ac, char *av [])
{
Audiothr A;
if (ac < 6)
{
fprintf (stderr, "alsa-loopback <playdev><captdev><fsamp><frsize><nfrags>\n");
return 1;
}
strcpy (playdev, av [1]);
strcpy (captdev, av [2]);
fsamp = atoi (av [3]);
frsize = atoi (av [4]);
nfrags = atoi (av [5]);
if (A.thr_start (SCHED_FIFO, -50, 0x20000))
{
fprintf (stderr, "Can't run in RT mode, trying normal scheduling.\n");
if (A.thr_start (SCHED_OTHER, 0, 0x20000))
{
fprintf (stderr, "Can't start audio thread.\n");
return 1;
}
}
sleep (1000000);
return 0;
}
// --------------------------------------------------------------------------------
|