test/testaudioinfo.c
author Sam Lantinga
Sun, 04 Oct 2009 09:55:20 +0000
changeset 3338 9de326b3099c
parent 2060 866052b01ee5
child 3635 5ea5e4e6103f
permissions -rw-r--r--
Fixed bug #817

Daniele Forghieri 2009-09-30 15:48:24 PDT

Some tests doesn't use the correct include statement (and there are some
missing declaration) and some test use C++ variable after statement, preventing
compile wicth Open Watcom

The patch attached fixes this
     1 #include <stdio.h>
     2 #include "SDL.h"
     3 
     4 static void
     5 print_devices(int iscapture)
     6 {
     7     const char *typestr = ((iscapture) ? "capture" : "output");
     8     int n = SDL_GetNumAudioDevices(iscapture);
     9 
    10     printf("%s devices:\n", typestr);
    11 
    12     if (n == -1)
    13         printf("  Driver can't detect specific devices.\n\n", typestr);
    14     else if (n == 0)
    15         printf("  No %s devices found.\n\n", typestr);
    16     else {
    17         int i;
    18         for (i = 0; i < n; i++) {
    19             printf("  %s\n", SDL_GetAudioDeviceName(i, iscapture));
    20         }
    21         printf("\n");
    22     }
    23 }
    24 
    25 int
    26 main(int argc, char **argv)
    27 {
    28     /* Print available audio drivers */
    29     int n = SDL_GetNumAudioDrivers();
    30     if (n == 0) {
    31         printf("No built-in audio drivers\n\n");
    32     } else {
    33         int i;
    34         printf("Built-in audio drivers:\n");
    35         for (i = 0; i < n; ++i) {
    36             printf("  %s\n", SDL_GetAudioDriver(i));
    37         }
    38         printf("\n");
    39     }
    40 
    41     /* Load the SDL library */
    42     if (SDL_Init(SDL_INIT_AUDIO) < 0) {
    43         fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
    44         return (1);
    45     }
    46 
    47     printf("Using audio driver: %s\n\n", SDL_GetCurrentAudioDriver());
    48 
    49     print_devices(0);
    50     print_devices(1);
    51 
    52     SDL_Quit();
    53     return 0;
    54 }