test/testnative.h
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@3059
    12
slouken@3059
    13
/* Definitions for platform dependent windowing functions to test SDL
slouken@3059
    14
   integration with native windows
slouken@3059
    15
*/
slouken@3059
    16
slouken@3059
    17
#include "SDL.h"
slouken@3059
    18
slouken@3059
    19
/* This header includes all the necessary system headers for native windows */
slouken@3059
    20
#include "SDL_syswm.h"
slouken@3059
    21
slouken@3059
    22
typedef struct
slouken@3059
    23
{
slouken@3059
    24
    const char *tag;
slouken@3061
    25
    void *(*CreateNativeWindow) (int w, int h);
slouken@3061
    26
    void (*DestroyNativeWindow) (void *window);
slouken@3059
    27
} NativeWindowFactory;
slouken@3059
    28
slouken@5062
    29
#ifdef SDL_VIDEO_DRIVER_WINDOWS
slouken@5062
    30
#define TEST_NATIVE_WINDOWS
slouken@5062
    31
extern NativeWindowFactory WindowsWindowFactory;
slouken@3059
    32
#endif
slouken@3059
    33
slouken@3059
    34
#ifdef SDL_VIDEO_DRIVER_X11
slouken@3059
    35
#define TEST_NATIVE_X11
slouken@3059
    36
extern NativeWindowFactory X11WindowFactory;
slouken@3059
    37
#endif
slouken@3059
    38
slouken@3059
    39
#ifdef SDL_VIDEO_DRIVER_COCOA
slouken@3059
    40
/* Actually, we don't really do this, since it involves adding Objective C
slouken@3059
    41
   support to the build system, which is a little tricky.  You can uncomment
slouken@3059
    42
   it manually though and link testnativecocoa.m into the test application.
slouken@3059
    43
*/
slouken@3059
    44
#define TEST_NATIVE_COCOA
slouken@3059
    45
extern NativeWindowFactory CocoaWindowFactory;
slouken@3059
    46
#endif