🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
2.1 KiB

  1. /*
  2. Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
  3. This software is provided 'as-is', without any express or implied
  4. warranty. In no event will the authors be held liable for any damages
  5. arising from the use of this software.
  6. Permission is granted to anyone to use this software for any purpose,
  7. including commercial applications, and to alter it and redistribute it
  8. freely.
  9. */
  10. #include <stdio.h>
  11. #include "SDL.h"
  12. static void
  13. print_devices(int iscapture)
  14. {
  15. const char *typestr = ((iscapture) ? "capture" : "output");
  16. int n = SDL_GetNumAudioDevices(iscapture);
  17. SDL_Log("Found %d %s device%s:\n", n, typestr, n != 1 ? "s" : "");
  18. if (n == -1)
  19. SDL_Log(" Driver can't detect specific %s devices.\n\n", typestr);
  20. else if (n == 0)
  21. SDL_Log(" No %s devices found.\n\n", typestr);
  22. else {
  23. int i;
  24. for (i = 0; i < n; i++) {
  25. const char *name = SDL_GetAudioDeviceName(i, iscapture);
  26. if (name != NULL)
  27. SDL_Log(" %d: %s\n", i, name);
  28. else
  29. SDL_Log(" %d Error: %s\n", i, SDL_GetError());
  30. }
  31. SDL_Log("\n");
  32. }
  33. }
  34. int
  35. main(int argc, char **argv)
  36. {
  37. int n;
  38. /* Enable standard application logging */
  39. SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
  40. /* Load the SDL library */
  41. if (SDL_Init(SDL_INIT_AUDIO) < 0) {
  42. SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
  43. return (1);
  44. }
  45. /* Print available audio drivers */
  46. n = SDL_GetNumAudioDrivers();
  47. if (n == 0) {
  48. SDL_Log("No built-in audio drivers\n\n");
  49. } else {
  50. int i;
  51. SDL_Log("Built-in audio drivers:\n");
  52. for (i = 0; i < n; ++i) {
  53. SDL_Log(" %d: %s\n", i, SDL_GetAudioDriver(i));
  54. }
  55. SDL_Log("Select a driver with the SDL_AUDIODRIVER environment variable.\n");
  56. }
  57. SDL_Log("Using audio driver: %s\n\n", SDL_GetCurrentAudioDriver());
  58. print_devices(0);
  59. print_devices(1);
  60. SDL_Quit();
  61. return 0;
  62. }