aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbenjamin gaignard <benjamin.gaignard@linaro.org>2012-01-26 14:40:57 +0100
committerbenjamin gaignard <benjamin.gaignard@linaro.org>2012-01-26 14:40:57 +0100
commit4070d3bf6430bb6523f4425f280524298c64768f (patch)
tree2244b76dff7a4d7d9c92496415077518c6f7b500
parentfc2ccb6cfc6e1cdecaaf0ffb6ca595a0154a2201 (diff)
parent42337bcf41a0afa63df80b7eb8961ed6f5b939bd (diff)
downloade2eaudiotest-4070d3bf6430bb6523f4425f280524298c64768f.tar.gz
Merge remote branch 'origin/master'
Conflicts: e2eaudiotest.sh
-rw-r--r--README19
-rwxr-xr-xe2eaudiotest.sh2
-rw-r--r--testfreq.c60
-rw-r--r--utils_alsa.c3
4 files changed, 25 insertions, 59 deletions
diff --git a/README b/README
index ba3b8ea..1f4c173 100644
--- a/README
+++ b/README
@@ -1,7 +1,16 @@
kurt-taylor@linaro.org
+What is it:
+===========
+This program is a simple test for testing the audio device on a linux host.
+The application, testfreq, will test the audio device by playing a sine wave
+at A440 and then sampling the input for that frequency - input is coupled to
+output with a cable.
+
+
To build:
+=========
first install libasound2-dev and libfftw3-dev
@@ -9,3 +18,13 @@ then run make
make clean will tidy up
+
+To run the test:
+================
+
+use a cable to connect the input jack to the output jack (line out to mic in)
+
+adjust mixer settings for your device
+
+run with: ./e2eaudiotest.sh
+
diff --git a/e2eaudiotest.sh b/e2eaudiotest.sh
index 4c7534d..677a0b0 100755
--- a/e2eaudiotest.sh
+++ b/e2eaudiotest.sh
@@ -4,6 +4,8 @@ amixer sset Headset 10
amixer sset 'Headset Left Playback' 'HS DAC'
amixer sset 'Headset Right Playback' 'HS DAC'
speaker-test -D hw:0,8 -c 2 -F S32_LE -r 96000 -t sine -f 440 -l 1 &
+STPID=$!
+trap "kill $STPID" TERM INT EXIT
# check the loopback frequency
if ./testfreq ; then
diff --git a/testfreq.c b/testfreq.c
index 39193b6..28649b3 100644
--- a/testfreq.c
+++ b/testfreq.c
@@ -12,7 +12,7 @@
#include <complex.h>
#include <fftw3.h>
-int get_sample(snd_pcm_t *handle, char *device_name, int num_samples, int sample_rate, unsigned short sine_input[]);
+int get_sample(char *device_name, int num_samples, int sample_rate, unsigned short sine_input[]);
int main (int argc, char *argv[])
{
@@ -22,8 +22,6 @@ int main (int argc, char *argv[])
char *device_name = "default"; /* pcm.default */
- snd_pcm_t *handle;
-
unsigned short sine_input[num_samples];
double f_input[num_samples];
double f_output[num_samples];
@@ -37,7 +35,7 @@ int main (int argc, char *argv[])
device_name = argv[1];
}
- if ((rc = get_sample (handle, device_name, num_samples, sample_rate, sine_input)) < 0) {
+ if ((rc = get_sample (device_name, num_samples, sample_rate, sine_input)) < 0) {
fprintf (stderr, "%s: cannot get sample\n", snd_strerror (rc));
exit (1);
}
@@ -73,57 +71,3 @@ int main (int argc, char *argv[])
exit (1);
}
-#ifdef NEVER
-int get_sample(snd_pcm_t *handle, char *device_name, int num_samples, int sample_rate, unsigned short sine_input[])
-{
- int rc;
- snd_pcm_hw_params_t *parms;
-
- /* Open the device */
- if ((rc = snd_pcm_open (&handle, device_name, SND_PCM_STREAM_CAPTURE, 0)) < 0) {
- fprintf (stderr, "%s: cannot open pcm device: %s \n", snd_strerror (rc), device_name);
- return (-1);
- }
- //fprintf (stdout, "Device Opened %s \n", device_name);
-
- /* Configure the device */
- if ((rc = snd_pcm_hw_params_malloc (&parms)) < 0) {
- fprintf (stderr, "%s: cannot malloc parms struct\n", snd_strerror (rc));
- return (-1);
- }
- if ((rc = snd_pcm_hw_params_any (handle, parms)) < 0) {
- fprintf (stderr, "%s: cannot set default parms\n", snd_strerror (rc));
- return (-1);
- }
- if ((rc = snd_pcm_hw_params_set_access (handle, parms, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) {
- fprintf (stderr, "%s: cannot set interleaved access\n", snd_strerror (rc));
- return (-1);
- }
- if ((rc = snd_pcm_hw_params_set_format (handle, parms, SND_PCM_FORMAT_U8)) < 0) {
- fprintf (stderr, "%s: cannot set format\n", snd_strerror (rc));
- return (-1);
- }
- if ((rc = snd_pcm_hw_params_set_channels (handle, parms, 2)) < 0) {
- fprintf (stderr, "%s: cannot set channels\n", snd_strerror (rc));
- return (-1);
- }
- if ((rc = snd_pcm_hw_params_set_rate_near (handle, parms, &sample_rate, 0)) < 0) {
- fprintf (stderr, "%s: cannot set rate\n", snd_strerror (rc));
- return (-1);
- }
- if ((rc = snd_pcm_hw_params (handle, parms)) < 0) {
- fprintf (stderr, "%s: cannot set parms\n", snd_strerror (rc));
- return (-1);
- }
- snd_pcm_hw_params_free (parms);
-
- /* Get samples of the sine wave */
- if ((rc = snd_pcm_readi (handle, sine_input, num_samples)) != num_samples) {
- fprintf (stderr, "%s: read failed\n", snd_strerror (rc));
- return (-1);
- }
- snd_pcm_close (handle);
-
- return 0;
-}
-#endif
diff --git a/utils_alsa.c b/utils_alsa.c
index e7b2c0c..cabc0a7 100644
--- a/utils_alsa.c
+++ b/utils_alsa.c
@@ -10,10 +10,11 @@
#include <alsa/asoundlib.h>
-int get_sample(snd_pcm_t *handle, char *device_name, int num_samples, int sample_rate, unsigned short sine_input[])
+int get_sample(char *device_name, int num_samples, int sample_rate, unsigned short sine_input[])
{
int rc;
snd_pcm_hw_params_t *parms;
+ snd_pcm_t *handle;
/* Open the device */
if ((rc = snd_pcm_open (&handle, device_name, SND_PCM_STREAM_CAPTURE, 0)) < 0) {