OSDN Git Service

Removed obsolete test programs.
authorJaroslav Kysela <perex@perex.cz>
Fri, 7 Sep 2001 09:33:20 +0000 (09:33 +0000)
committerJaroslav Kysela <perex@perex.cz>
Fri, 7 Sep 2001 09:33:20 +0000 (09:33 +0000)
test/Makefile.am
test/cardid.c [deleted file]
test/loopback.c [deleted file]
test/pause.c [deleted file]
test/switches.c [deleted file]

index cff0eb9..94d3b0e 100644 (file)
@@ -1,19 +1,14 @@
-check_PROGRAMS=control mixer switches pause pcm latency seq \
-              playmidi1 timer loopback rawmidi midiloop cardid
+check_PROGRAMS=control pcm latency seq \
+              playmidi1 timer rawmidi midiloop
 
 control_LDADD=../src/libasound.la
-mixer_LDADD=../src/libasound.la
-switches_LDADD=../src/libasound.la
-pause_LDADD=../src/libasound.la
 pcm_LDADD=../src/libasound.la
 latency_LDADD=../src/libasound.la
 seq_LDADD=../src/libasound.la
 playmidi1_LDADD=../src/libasound.la
 timer_LDADD=../src/libasound.la
-loopback_LDADD=../src/libasound.la
 rawmidi_LDADD=../src/libasound.la
 midiloop_LDADD=../src/libasound.la
-cardid_LDADD=../src/libasound.la
 
 INCLUDES=-I$(top_srcdir)/include
 # CFLAGS=-static -Wall -pipe -g
diff --git a/test/cardid.c b/test/cardid.c
deleted file mode 100644 (file)
index 94dadb9..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <errno.h>
-#include "../include/asoundlib.h"
-
-int main(int argc, char *argv[])
-{
-       char *str;
-       snd_card_type_t type;
-       int idx, err;
-       
-       for (idx = 1; idx < argc; idx++) {
-               if (isdigit(argv[idx][0])) {
-                       type = (snd_card_type_t)atoi(argv[idx]);
-                       err = snd_card_type_enum_to_string(type, &str);
-                       printf("enum_to_string: input %i -> '%s', error %i\n", (int)type, str, err);
-               } else {
-                       str = argv[idx];
-                       err = snd_card_type_string_to_enum(str, &type);
-                       printf("string_to_enum: input '%s' -> %i, error %i\n", str, (int)type, err);
-               }
-       }
-       return EXIT_SUCCESS;
-}
diff --git a/test/loopback.c b/test/loopback.c
deleted file mode 100644 (file)
index 8326595..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "../include/asoundlib.h"
-
-#define CARD   0
-#define DEVICE 0
-#define SUBDEV 0
-#define MODE   SND_PCM_LB_STREAM_MODE_PACKET
-
-static void show_format1(const char *prefix, snd_pcm_format_t *format)
-{
-       printf("%sinterleave = %i, rate = %i, voices = %i, format = %i\n",
-                       prefix,
-                       format->interleave ? 1 : 0,
-                       format->rate,
-                       format->voices,
-                       format->sfmt);
-}
-
-static void show_format(snd_pcm_loopback_t *handle)
-{
-       snd_pcm_format_t format;
-       int err;
-
-       err = snd_pcm_loopback_format(handle, &format);
-       if (err < 0) {
-               fprintf(stderr, "format failed: %s\n", snd_strerror(err));
-               exit(0);
-       }
-       show_format1("Format: ", &format);
-}
-
-static void data(void *private_data, char *buf, size_t count)
-{
-       printf("DATA> count = %li\n", (long)count);
-}
-
-static void format_change(void *private_data, snd_pcm_format_t *format)
-{
-       show_format1("Format change> ", format);
-}
-
-static void position_change(void *private_data, unsigned int pos)
-{
-       printf("Position change> %u\n", pos);
-}
-
-int main(int argc, char *argv[])
-{
-       int err;
-       ssize_t res;
-       snd_pcm_loopback_t *handle;
-       snd_pcm_loopback_callbacks_t callbacks;
-
-       err = snd_pcm_loopback_open(&handle, CARD, DEVICE, SUBDEV, SND_PCM_LB_OPEN_PLAYBACK);
-       if (err < 0) {
-               fprintf(stderr, "open error: %s\n", snd_strerror(err));
-               exit(0);
-       }
-       err = snd_pcm_loopback_stream_mode(handle, MODE);
-       if (err < 0) {
-               fprintf(stderr, "stream mode setup failed: %s\n", snd_strerror(err));
-               exit(0);
-       }
-       show_format(handle);
-       memset(&callbacks, 0, sizeof(callbacks));
-       callbacks.data = data;
-       callbacks.format_change = format_change;        
-       callbacks.position_change = position_change;
-       while ((res = snd_pcm_loopback_read(handle, &callbacks)) >= 0) {
-               if (res > 0)
-                       printf("Read ok.. - %i\n", res);
-       }
-       snd_pcm_loopback_close(handle);
-       return 0;
-}
diff --git a/test/pause.c b/test/pause.c
deleted file mode 100644 (file)
index 4d7e26d..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-#include <stdio.h>
-#include <malloc.h>
-#include "../include/asoundlib.h"
-
-#define AU_FILE "/home/ftp/pub/audio/AlwaysOnTheRun.au"
-
-static void show_playback_status(void *handle)
-{
-       snd_pcm_playback_status_t pstatus;
-
-       if (snd_pcm_playback_status(handle, &pstatus) < 0) {
-               perror("playback status");
-               return;
-       }
-       printf("PCM playback status:\n");
-       printf("  rate = %i\n", pstatus.rate);
-       printf("  fragments = %i\n", pstatus.fragments);
-       printf("  fragment_size = %i\n", pstatus.fragment_size);
-       printf("  count = %i\n", pstatus.count);
-       printf("  queue = %i\n", pstatus.queue);
-       printf("  underrun = %i\n", pstatus.underrun);
-       printf("  time = %i.%i\n", (int) pstatus.time.tv_sec, (int) pstatus.time.tv_usec);
-       printf("  stime = %i.%i\n", (int) pstatus.stime.tv_sec, (int) pstatus.stime.tv_usec);
-       printf("  scount = %i\n", pstatus.scount);
-}
-
-int main(void)
-{
-       int card = 0, device = 0, err, fd, count, count1, size, idx;
-       snd_pcm_t *handle;
-       snd_pcm_format_t format;
-       snd_pcm_playback_status_t status;
-       char *buffer, *buffer1;
-
-       buffer = (char *) malloc(512 * 1024);
-       if (!buffer)
-               return 0;
-       if ((err = snd_pcm_open(&handle, card, device, SND_PCM_OPEN_PLAYBACK)) < 0) {
-               fprintf(stderr, "open failed: %s\n", snd_strerror(err));
-               return 0;
-       }
-       format.sfmt = SND_PCM_FORMAT_MU_LAW;
-       format.rate = 8000;
-       format.channels = 1;
-       if ((err = snd_pcm_playback_format(handle, &format)) < 0) {
-               fprintf(stderr, "format setup failed: %s\n", snd_strerror(err));
-               snd_pcm_close(handle);
-               return 0;
-       }
-       if ((err = snd_pcm_playback_status(handle, &status)) < 0) {
-               fprintf(stderr, "status failed: %s\n", snd_strerror(err));
-               snd_pcm_close(handle);
-               return 0;
-       }
-       fd = open(AU_FILE, O_RDONLY);
-       if (fd < 0) {
-               perror("open file");
-               snd_pcm_close(handle);
-               return 0;
-       }
-       idx = 0;
-       count = read(fd, buffer, 512 * 1024);
-       if (count <= 0) {
-               perror("read from file");
-               snd_pcm_close(handle);
-               return 0;
-       }
-       close(fd);
-       if (!memcmp(buffer, ".snd", 4)) {
-               idx = (buffer[4] << 24) | (buffer[5] << 16) | (buffer[6] << 8) | (buffer[7]);
-               if (idx > 128)
-                       idx = 128;
-               if (idx > count)
-                       idx = count;
-       }
-       buffer1 = buffer + idx;
-       count -= idx;
-       if (count < 256 * 1024) {
-               perror("small count < 256k");
-               snd_pcm_close(handle);
-               return 0;
-       }
-       count1 = status.fragment_size * 12;
-       show_playback_status(handle);
-       size = snd_pcm_writei(handle, buffer1, count1);
-       sleep(2);
-       show_playback_status(handle);
-       printf("Pause.. Bytes written %i from %i...\n", size, count1);
-       count -= count1;
-       buffer1 += count1;
-       snd_pcm_playback_pause(handle, 1);
-       show_playback_status(handle);
-       sleep(5);
-       printf("Pause end..\n");
-       snd_pcm_playback_pause(handle, 0);
-       show_playback_status(handle);
-       size = snd_pcm_writei(handle, buffer1, count);
-       printf("Pause end.. Bytes written %i from %i...\n", size, count);
-       snd_pcm_close(handle);
-       free(buffer);
-       return 0;
-}
diff --git a/test/switches.c b/test/switches.c
deleted file mode 100644 (file)
index 8b7b0b9..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include <malloc.h>
-#include <errno.h>
-#include "../include/asoundlib.h"
-
-const char *get_type(unsigned int type)
-{
-       switch (type) {
-       case SND_SW_TYPE_BOOLEAN:
-               return "Boolean";
-       case SND_SW_TYPE_BYTE:
-               return "Byte";
-       case SND_SW_TYPE_WORD:
-               return "Word";
-       case SND_SW_TYPE_DWORD:
-               return "Double Word";
-       case SND_SW_TYPE_LIST:
-               return "List";
-       case SND_SW_TYPE_LIST_ITEM:
-               return "List Item";
-       case SND_SW_TYPE_USER:
-               return "User";
-       default:
-               return "Unknown";
-       }
-}
-
-const char *get_interface(int iface)
-{
-       switch (iface) {
-       case SND_CTL_IFACE_CONTROL:
-               return "control";
-       case SND_CTL_IFACE_MIXER:
-               return "mixer";
-       case SND_CTL_IFACE_PCM:
-               return "pcm";
-       case SND_CTL_IFACE_RAWMIDI:
-               return "rawmidi";
-       default:
-               return "unknown";
-       }
-}
-
-void print_switch(snd_ctl_t *ctl_handle, char *space, char *prefix, snd_switch_t *sw)
-{
-       snd_switch_t sw1;
-       int low, err;
-
-       printf("%s%s : '%s' [%s]\n", space, prefix, sw->name, get_type(sw->type));
-       if (sw->type == SND_SW_TYPE_LIST) {
-               for (low = sw->low; low <= sw->high; low++) {
-                       memcpy(&sw1, sw,  sizeof(sw1));
-                       sw1.type = SND_SW_TYPE_LIST_ITEM;
-                       sw1.low = sw1.high = low;
-                       if ((err = snd_ctl_switch_read(ctl_handle, &sw1)) < 0) {
-                               printf("Switch list item read failed for %s interface and device %i stream %i: %s\n", get_interface(sw->iface), sw->device, sw->stream, snd_strerror(err));
-                               continue;
-                       }
-                       printf("  %s%s : '%s' [%s] {%s}\n", space, prefix, sw1.name, get_type(sw1.type), sw1.value.item);
-               }
-       }
-}
-
-void process(snd_ctl_t *ctl_handle, char *space, char *prefix, int iface, int device, int stream)
-{
-       snd_switch_list_t list;
-       snd_switch_t sw;
-       int err, idx;
-
-       bzero(&list, sizeof(list));
-       list.iface = iface;
-       list.device = device;
-       list.stream = stream;
-       if ((err = snd_ctl_switch_list(ctl_handle, &list)) < 0) {
-               printf("Switch listing failed for the %s interface and the device %i: %s\n", get_interface(iface), device, snd_strerror(err));
-               return;
-       }
-       if (list.switches_over <= 0)
-               return;
-       list.switches_size = list.switches_over + 16;
-       list.switches = list.switches_over = 0;
-       list.pswitches = malloc(sizeof(snd_switch_list_item_t) * list.switches_size);
-       if (!list.pswitches) {
-               printf("No enough memory... (%i switches)\n", list.switches_size);
-               return;
-       }
-       if ((err = snd_ctl_switch_list(ctl_handle, &list)) < 0) {
-               printf("Second switch listing failed for the %s interface and the device %i: %s\n", get_interface(iface), device, snd_strerror(err));
-               return;
-       }
-       for (idx = 0; idx < list.switches; idx++) {
-               bzero(&sw, sizeof(sw));
-               sw.iface = iface;
-               sw.device = device;
-               sw.stream = stream;
-               strncpy(sw.name, list.pswitches[idx].name, sizeof(sw.name));
-               if ((err = snd_ctl_switch_read(ctl_handle, &sw)) < 0) {
-                       printf("Switch read failed for the %s interface and the device %i stream %i: %s\n", get_interface(iface), device, stream, snd_strerror(err));
-                       continue;
-               }
-               print_switch(ctl_handle, space, prefix, &sw);
-       }
-       free(list.pswitches);
-}
-
-int main(void)
-{
-       snd_ctl_t *ctl_handle;
-       int cards, card, err, idx;
-       snd_ctl_card_info_t info;
-
-       cards = snd_cards();
-       printf("Detected %i soundcard%s...\n", cards, cards > 1 ? "s" : "");
-       if (cards <= 0) {
-               printf("Giving up...\n");
-               return 0;
-       }
-       /* control interface */
-       for (card = 0; card < cards; card++) {
-               if ((err = snd_ctl_open(&ctl_handle, card)) < 0) {
-                       printf("CTL open error: %s\n", snd_strerror(err));
-                       continue;
-               }
-               if ((err = snd_ctl_card_info(ctl_handle, &info)) < 0) {
-                       printf("HWINFO error: %s\n", snd_strerror(err));
-                       continue;
-               }
-               printf("CARD %i:\n", card);
-               process(ctl_handle, "  ", "Control", SND_CTL_IFACE_CONTROL, 0, 0);
-               for (idx = 0; idx < info.mixerdevs; idx++)
-                       process(ctl_handle, "  ", "Mixer", SND_CTL_IFACE_MIXER, idx, 0);
-               for (idx = 0; idx < info.pcmdevs; idx++) {
-                       process(ctl_handle, "  ", "PCM playback", SND_CTL_IFACE_PCM, idx, SND_PCM_STREAM_PLAYBACK);
-                       process(ctl_handle, "  ", "PCM capture", SND_CTL_IFACE_PCM, idx, SND_PCM_STREAM_CAPTURE);
-               }
-               snd_ctl_close(ctl_handle);
-       }
-       return 0;
-}