test/testver.c
author Sam Lantinga <slouken@libsdl.org>
Sun, 07 Jul 2019 09:10:56 -0700
changeset 12928 3c4a4b1077cd
parent 12503 806492103856
permissions -rw-r--r--
Fixed bug 4710 - audio/alsa: avoid configuring hardware parameters with only a single period

Anthony Pesch

The previous code first configured the period size using snd_pcm_hw_par-
ams_set_period_size_near. Then, it further narrowed the configuration
space by calling snd_pcm_hw_params_set_buffer_size_near using a buffer
size of 2 times the _requested_ period size in order to try and get a
configuration with only 2 periods. If the configured period size was
larger than the requested size, the second call could inadvertently
narrow the configuration space to contain only a single period.

Rather than fixing the call to snd_pcm_hw_params_set_buffer_size_near
to use a size of 2 times the configured period size, the code has been
changed to use snd_pcm_hw_params_set_periods_min in order to more
clearly explain the intent.
slouken@5535
     1
/*
slouken@12503
     2
  Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
slouken@5535
     3
slouken@5535
     4
  This software is provided 'as-is', without any express or implied
slouken@5535
     5
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     6
  arising from the use of this software.
slouken@5535
     7
slouken@5535
     8
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
     9
  including commercial applications, and to alter it and redistribute it
slouken@5535
    10
  freely.
slouken@5535
    11
*/
slouken@0
    12
slouken@0
    13
/* Test program to compare the compile-time version of SDL with the linked
slouken@0
    14
   version of SDL
slouken@0
    15
*/
slouken@0
    16
slouken@0
    17
#include <stdio.h>
icculus@1154
    18
#include <stdlib.h>
slouken@0
    19
slouken@0
    20
#include "SDL.h"
slouken@5310
    21
#include "SDL_revision.h"
slouken@0
    22
slouken@1895
    23
int
slouken@1895
    24
main(int argc, char *argv[])
slouken@0
    25
{
slouken@1895
    26
    SDL_version compiled;
slouken@2983
    27
    SDL_version linked;
slouken@0
    28
philipp@9922
    29
    /* Enable standard application logging */
aschiffler@7639
    30
    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
aschiffler@7639
    31
slouken@6251
    32
#if SDL_VERSION_ATLEAST(2, 0, 0)
aschiffler@7639
    33
    SDL_Log("Compiled with SDL 2.0 or newer\n");
slouken@0
    34
#else
aschiffler@7639
    35
    SDL_Log("Compiled with SDL older than 2.0\n");
slouken@0
    36
#endif
slouken@1895
    37
    SDL_VERSION(&compiled);
aschiffler@7639
    38
    SDL_Log("Compiled version: %d.%d.%d.%d (%s)\n",
slouken@5359
    39
           compiled.major, compiled.minor, compiled.patch,
slouken@5359
    40
           SDL_REVISION_NUMBER, SDL_REVISION);
slouken@2983
    41
    SDL_GetVersion(&linked);
aschiffler@7639
    42
    SDL_Log("Linked version: %d.%d.%d.%d (%s)\n",
slouken@5359
    43
           linked.major, linked.minor, linked.patch,
slouken@5359
    44
           SDL_GetRevisionNumber(), SDL_GetRevision());
slouken@1895
    45
    SDL_Quit();
slouken@1895
    46
    return (0);
slouken@0
    47
}