* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
- * xine is distributed in the hope that it will be useful,
+ * speaker-test 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.
static char *device = "plughw:0,0"; /* playback device */
static snd_pcm_format_t format = SND_PCM_FORMAT_S16; /* sample format */
-static unsigned int rate = 44100; /* stream rate */
+static unsigned int rate = 48000; /* stream rate */
static unsigned int channels = 1; /* count of channels */
+static unsigned int speaker = 0; /* count of channels */
static unsigned int buffer_time = 500000; /* ring buffer length in us */
static unsigned int period_time = 100000; /* period time in us */
static double freq = 440; /* sinusoidal wave frequency in Hz */
}
static void help(void) {
- int k;
printf(
- "Usage: latency [OPTION]... [FILE]...\n"
+ "Usage: speaker-test [OPTION]... \n"
"-h,--help help\n"
"-D,--device playback device\n"
"-r,--rate stream rate in Hz\n"
"-f,--frequency sine wave frequency in Hz\n"
"-b,--buffer ring buffer size in us\n"
"-p,--period period size in us\n"
+ "-s,--speaker single speaker test. Values 1=Left or 2=right\n"
"\n");
-
+#if 0
printf("Recognized sample formats are:");
for (k = 0; k < SND_PCM_FORMAT_LAST; ++k) {
const char *s = snd_pcm_format_name(k);
}
printf("\n\n");
+#endif
+
}
int main(int argc, char *argv[]) {
{"frequency", 1, NULL, 'f'},
{"buffer", 1, NULL, 'b'},
{"period", 1, NULL, 'p'},
+ {"speaker", 1, NULL, 's'},
{NULL, 0, NULL, 0 },
};
while (1) {
int c;
- if ((c = getopt_long(argc, argv, "hD:r:c:f:b:p:m:", long_option, NULL)) < 0)
+ if ((c = getopt_long(argc, argv, "hD:r:c:f:b:p:s:", long_option, NULL)) < 0)
break;
switch (c) {
period_time = period_time < 1000 ? 1000 : period_time;
period_time = period_time > 1000000 ? 1000000 : period_time;
break;
+ case 's':
+ speaker = atoi(optarg);
+ speaker = speaker < 1 ? 0 : speaker;
+ speaker = speaker > channels ? 0 : speaker;
+ if (speaker==0) {
+ printf("Invalid parameter for -s option.\n");
+ exit(EXIT_FAILURE);
+ }
+ break;
default:
printf("Unknown option '%c'\n", c);
exit(EXIT_FAILURE);
printf("No enough memory\n");
exit(EXIT_FAILURE);
}
+ if (speaker==0) {
+ while (1) {
- while (1) {
-
- for(chn = 0; chn < channels; chn++) {
- printf(" - %s\n", channel_name[chn]);
+ for(chn = 0; chn < channels; chn++) {
+ printf(" - %s\n", channel_name[chn]);
- err = write_loop(handle, chn, ((rate*5)/period_size), samples);
+ err = write_loop(handle, chn, ((rate*5)/period_size), samples);
- if (err < 0) {
- printf("Transfer failed: %s\n", snd_strerror(err));
- exit(EXIT_FAILURE);
+ if (err < 0) {
+ printf("Transfer failed: %s\n", snd_strerror(err));
+ exit(EXIT_FAILURE);
+ }
}
}
+ } else {
+ printf(" - %s\n", channel_name[speaker-1]);
+ err = write_loop(handle, speaker-1, ((rate*5)/period_size), samples);
+
+ if (err < 0) {
+ printf("Transfer failed: %s\n", snd_strerror(err));
+ }
}
+
free(samples);
snd_pcm_close(handle);