test/automated/audio/audio.c
author David Ludwig <dludwig@pobox.com>
Tue, 12 Feb 2013 12:57:06 -0500
changeset 8424 3cf9501008f1
parent 3481 c32c53fca10d
permissions -rw-r--r--
WinRT: fixed bug: SDL_CreateWindow wouldn't work after an initial window was created + destroyed
slouken@3259
     1
/**
slouken@3259
     2
 * Automated SDL_RWops test.
slouken@3259
     3
 *
slouken@3259
     4
 * Written by Edgar Simo "bobbens"
slouken@3259
     5
 *
slouken@3259
     6
 * Released under Public Domain.
slouken@3259
     7
 */
slouken@3259
     8
slouken@3259
     9
slouken@3259
    10
#include "SDL.h"
slouken@3481
    11
#include "../SDL_at.h"
slouken@3259
    12
slouken@3259
    13
slouken@3259
    14
/**
slouken@3259
    15
 * @brief Prints available devices.
slouken@3259
    16
 */
slouken@3259
    17
static int audio_printDevices( int iscapture )
slouken@3259
    18
{
slouken@3259
    19
   int i, n;
slouken@3259
    20
slouken@3259
    21
   /* Get number of devices. */
slouken@3259
    22
   n = SDL_GetNumAudioDevices(iscapture);
slouken@3259
    23
   SDL_ATprintVerbose( 1, "%d %s Audio Devices\n",
slouken@3259
    24
         n, iscapture ? "Capture" : "Output" );
slouken@3259
    25
slouken@3259
    26
   /* List devices. */
slouken@3259
    27
   for (i=0; i<n; i++) {
slouken@3259
    28
      SDL_ATprintVerbose( 1, "   %d) %s\n", i+1, SDL_GetAudioDeviceName( i, iscapture ) );
slouken@3259
    29
   }
slouken@3259
    30
slouken@3259
    31
   return 0;
slouken@3259
    32
}
slouken@3259
    33
slouken@3259
    34
slouken@3259
    35
/**
slouken@3259
    36
 * @brief Makes sure parameters work properly.
slouken@3259
    37
 */
slouken@3259
    38
static void audio_testOpen (void)
slouken@3259
    39
{
slouken@3259
    40
   int i, n;
slouken@3259
    41
   int ret;
slouken@3259
    42
slouken@3259
    43
   /* Begin testcase. */
slouken@3259
    44
   SDL_ATbegin( "Audio Open" );
slouken@3259
    45
slouken@3259
    46
   /* List drivers. */
slouken@3259
    47
   n = SDL_GetNumAudioDrivers();
slouken@3259
    48
   SDL_ATprintVerbose( 1, "%d Audio Drivers\n", n );
slouken@3259
    49
   for (i=0; i<n; i++) {
slouken@3259
    50
      SDL_ATprintVerbose( 1, "   %s\n", SDL_GetAudioDriver(i) );
slouken@3259
    51
   }
slouken@3259
    52
slouken@3259
    53
   /* Start SDL. */
slouken@3259
    54
   ret = SDL_Init( SDL_INIT_AUDIO );
slouken@3259
    55
   if (SDL_ATvassert( ret==0, "SDL_Init( SDL_INIT_AUDIO ): %s", SDL_GetError()))
slouken@3259
    56
      return;
slouken@3259
    57
slouken@3259
    58
   /* Print devices. */
slouken@3259
    59
   SDL_ATprintVerbose( 1, "Using Audio Driver '%s'\n", SDL_GetCurrentAudioDriver() );
slouken@3259
    60
   audio_printDevices(0);
slouken@3259
    61
   audio_printDevices(1);
slouken@3259
    62
slouken@3259
    63
   /* Quit SDL. */
slouken@3259
    64
   SDL_Quit();
slouken@3259
    65
slouken@3259
    66
   /* End testcase. */
slouken@3259
    67
   SDL_ATend();
slouken@3259
    68
}
slouken@3259
    69
slouken@3259
    70
slouken@3259
    71
/**
slouken@3259
    72
 * @brief Entry point.
slouken@3259
    73
 */
slouken@3259
    74
#ifdef TEST_STANDALONE
slouken@3259
    75
int main( int argc, const char *argv[] )
slouken@3259
    76
{
slouken@3259
    77
   (void) argc;
slouken@3259
    78
   (void) argv;
slouken@3259
    79
#else /* TEST_STANDALONE */
slouken@3259
    80
int test_audio (void)
slouken@3259
    81
{
slouken@3259
    82
#endif /* TEST_STANDALONE */
slouken@3259
    83
slouken@3259
    84
   SDL_ATinit( "SDL_Audio" );
slouken@3259
    85
slouken@3259
    86
   audio_testOpen();
slouken@3259
    87
slouken@3259
    88
   return SDL_ATfinish();
slouken@3259
    89
}