test/testaudioinfo.c
changeset 10413 636499ff46f8
parent 9998 f67cf37e9cd4
child 10737 3406a0f8b041
equal deleted inserted replaced
10412:a644712b2fb2 10413:636499ff46f8
    16 print_devices(int iscapture)
    16 print_devices(int iscapture)
    17 {
    17 {
    18     const char *typestr = ((iscapture) ? "capture" : "output");
    18     const char *typestr = ((iscapture) ? "capture" : "output");
    19     int n = SDL_GetNumAudioDevices(iscapture);
    19     int n = SDL_GetNumAudioDevices(iscapture);
    20 
    20 
    21     SDL_Log("%s devices:\n", typestr);
    21     SDL_Log("Found %d %s device%s:\n", n, typestr, n != 1 ? "s" : "");
    22 
    22 
    23     if (n == -1)
    23     if (n == -1)
    24         SDL_Log("  Driver can't detect specific %s devices.\n\n", typestr);
    24         SDL_Log("  Driver can't detect specific %s devices.\n\n", typestr);
    25     else if (n == 0)
    25     else if (n == 0)
    26         SDL_Log("  No %s devices found.\n\n", typestr);
    26         SDL_Log("  No %s devices found.\n\n", typestr);
    27     else {
    27     else {
    28         int i;
    28         int i;
    29         for (i = 0; i < n; i++) {
    29         for (i = 0; i < n; i++) {
    30             SDL_Log("  %s\n", SDL_GetAudioDeviceName(i, iscapture));
    30             const char *name = SDL_GetAudioDeviceName(i, iscapture);
       
    31             if (name != NULL)
       
    32                 SDL_Log("  %d: %s\n", i, name);
       
    33             else
       
    34                 SDL_Log("  %d Error: %s\n", i, SDL_GetError());
    31         }
    35         }
    32         SDL_Log("\n");
    36         SDL_Log("\n");
    33     }
    37     }
    34 }
    38 }
    35 
    39 
    53         SDL_Log("No built-in audio drivers\n\n");
    57         SDL_Log("No built-in audio drivers\n\n");
    54     } else {
    58     } else {
    55         int i;
    59         int i;
    56         SDL_Log("Built-in audio drivers:\n");
    60         SDL_Log("Built-in audio drivers:\n");
    57         for (i = 0; i < n; ++i) {
    61         for (i = 0; i < n; ++i) {
    58             SDL_Log("  %s\n", SDL_GetAudioDriver(i));
    62             SDL_Log("  %d: %s\n", i, SDL_GetAudioDriver(i));
    59         }
    63         }
    60         SDL_Log("\n");
    64         SDL_Log("Select a driver with the SDL_AUDIODRIVER environment variable.\n");
    61     }
    65     }
    62 
    66 
    63     SDL_Log("Using audio driver: %s\n\n", SDL_GetCurrentAudioDriver());
    67     SDL_Log("Using audio driver: %s\n\n", SDL_GetCurrentAudioDriver());
    64 
    68 
    65     print_devices(0);
    69     print_devices(0);