src/audio/winmm/SDL_winmm.c
author Sam Lantinga <slouken@libsdl.org>
Sun, 09 Mar 2014 12:27:31 -0700
changeset 8585 2d08b56cbfa9
parent 8149 681eb46b8ac4
child 9394 bb28e5281770
permissions -rw-r--r--
Fixed 64-bit warnings
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5588
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     1
/*
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     2
  Simple DirectMedia Layer
8149
681eb46b8ac4 Fixed bug 2374 - Update copyright for 2014...
Sam Lantinga <slouken@libsdl.org>
parents: 8093
diff changeset
     3
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
5588
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     4
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     5
  This software is provided 'as-is', without any express or implied
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     7
  arising from the use of this software.
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     8
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    11
  freely, subject to the following restrictions:
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    12
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    14
     claim that you wrote the original software. If you use this software
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    16
     appreciated but is not required.
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    18
     misrepresented as being the original software.
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    20
*/
8093
b43765095a6f Make internal SDL sources include SDL_internal.h instead of SDL_config.h
Ryan C. Gordon <icculus@icculus.org>
parents: 7719
diff changeset
    21
#include "../../SDL_internal.h"
5588
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    22
6044
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 5593
diff changeset
    23
#if SDL_AUDIO_DRIVER_WINMM
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 5593
diff changeset
    24
5588
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    25
/* Allow access to a raw mixing buffer */
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    26
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    27
#include "../../core/windows/SDL_windows.h"
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    28
#include <mmsystem.h>
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    29
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    30
#include "SDL_timer.h"
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    31
#include "SDL_audio.h"
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    32
#include "../SDL_audio_c.h"
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    33
#include "SDL_winmm.h"
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    34
7449
5148cfb37948 Implement float32 support for winmm and directsound targets (Thanks, John!).
Ryan C. Gordon <icculus@icculus.org>
parents: 7332
diff changeset
    35
#ifndef WAVE_FORMAT_IEEE_FLOAT
5148cfb37948 Implement float32 support for winmm and directsound targets (Thanks, John!).
Ryan C. Gordon <icculus@icculus.org>
parents: 7332
diff changeset
    36
#define WAVE_FORMAT_IEEE_FLOAT 0x0003
5148cfb37948 Implement float32 support for winmm and directsound targets (Thanks, John!).
Ryan C. Gordon <icculus@icculus.org>
parents: 7332
diff changeset
    37
#endif
5148cfb37948 Implement float32 support for winmm and directsound targets (Thanks, John!).
Ryan C. Gordon <icculus@icculus.org>
parents: 7332
diff changeset
    38
5593
ab22ca13c47f Cleaned up audio device detection. Cleared out a lot of cut-and-paste.
Ryan C. Gordon <icculus@icculus.org>
parents: 5588
diff changeset
    39
#define DETECT_DEV_IMPL(typ, capstyp) \
ab22ca13c47f Cleaned up audio device detection. Cleared out a lot of cut-and-paste.
Ryan C. Gordon <icculus@icculus.org>
parents: 5588
diff changeset
    40
static void DetectWave##typ##Devs(SDL_AddAudioDevice addfn) { \
ab22ca13c47f Cleaned up audio device detection. Cleared out a lot of cut-and-paste.
Ryan C. Gordon <icculus@icculus.org>
parents: 5588
diff changeset
    41
    const UINT devcount = wave##typ##GetNumDevs(); \
ab22ca13c47f Cleaned up audio device detection. Cleared out a lot of cut-and-paste.
Ryan C. Gordon <icculus@icculus.org>
parents: 5588
diff changeset
    42
    capstyp caps; \
ab22ca13c47f Cleaned up audio device detection. Cleared out a lot of cut-and-paste.
Ryan C. Gordon <icculus@icculus.org>
parents: 5588
diff changeset
    43
    UINT i; \
ab22ca13c47f Cleaned up audio device detection. Cleared out a lot of cut-and-paste.
Ryan C. Gordon <icculus@icculus.org>
parents: 5588
diff changeset
    44
    for (i = 0; i < devcount; i++) { \
ab22ca13c47f Cleaned up audio device detection. Cleared out a lot of cut-and-paste.
Ryan C. Gordon <icculus@icculus.org>
parents: 5588
diff changeset
    45
        if (wave##typ##GetDevCaps(i,&caps,sizeof(caps))==MMSYSERR_NOERROR) { \
ab22ca13c47f Cleaned up audio device detection. Cleared out a lot of cut-and-paste.
Ryan C. Gordon <icculus@icculus.org>
parents: 5588
diff changeset
    46
            char *name = WIN_StringToUTF8(caps.szPname); \
ab22ca13c47f Cleaned up audio device detection. Cleared out a lot of cut-and-paste.
Ryan C. Gordon <icculus@icculus.org>
parents: 5588
diff changeset
    47
            if (name != NULL) { \
ab22ca13c47f Cleaned up audio device detection. Cleared out a lot of cut-and-paste.
Ryan C. Gordon <icculus@icculus.org>
parents: 5588
diff changeset
    48
                addfn(name); \
ab22ca13c47f Cleaned up audio device detection. Cleared out a lot of cut-and-paste.
Ryan C. Gordon <icculus@icculus.org>
parents: 5588
diff changeset
    49
                SDL_free(name); \
ab22ca13c47f Cleaned up audio device detection. Cleared out a lot of cut-and-paste.
Ryan C. Gordon <icculus@icculus.org>
parents: 5588
diff changeset
    50
            } \
ab22ca13c47f Cleaned up audio device detection. Cleared out a lot of cut-and-paste.
Ryan C. Gordon <icculus@icculus.org>
parents: 5588
diff changeset
    51
        } \
ab22ca13c47f Cleaned up audio device detection. Cleared out a lot of cut-and-paste.
Ryan C. Gordon <icculus@icculus.org>
parents: 5588
diff changeset
    52
    } \
5588
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    53
}
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    54
5593
ab22ca13c47f Cleaned up audio device detection. Cleared out a lot of cut-and-paste.
Ryan C. Gordon <icculus@icculus.org>
parents: 5588
diff changeset
    55
DETECT_DEV_IMPL(Out, WAVEOUTCAPS)
ab22ca13c47f Cleaned up audio device detection. Cleared out a lot of cut-and-paste.
Ryan C. Gordon <icculus@icculus.org>
parents: 5588
diff changeset
    56
DETECT_DEV_IMPL(In, WAVEINCAPS)
5588
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    57
5593
ab22ca13c47f Cleaned up audio device detection. Cleared out a lot of cut-and-paste.
Ryan C. Gordon <icculus@icculus.org>
parents: 5588
diff changeset
    58
static void
ab22ca13c47f Cleaned up audio device detection. Cleared out a lot of cut-and-paste.
Ryan C. Gordon <icculus@icculus.org>
parents: 5588
diff changeset
    59
WINMM_DetectDevices(int iscapture, SDL_AddAudioDevice addfn)
5588
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    60
{
5593
ab22ca13c47f Cleaned up audio device detection. Cleared out a lot of cut-and-paste.
Ryan C. Gordon <icculus@icculus.org>
parents: 5588
diff changeset
    61
    if (iscapture) {
ab22ca13c47f Cleaned up audio device detection. Cleared out a lot of cut-and-paste.
Ryan C. Gordon <icculus@icculus.org>
parents: 5588
diff changeset
    62
        DetectWaveInDevs(addfn);
ab22ca13c47f Cleaned up audio device detection. Cleared out a lot of cut-and-paste.
Ryan C. Gordon <icculus@icculus.org>
parents: 5588
diff changeset
    63
    } else {
ab22ca13c47f Cleaned up audio device detection. Cleared out a lot of cut-and-paste.
Ryan C. Gordon <icculus@icculus.org>
parents: 5588
diff changeset
    64
        DetectWaveOutDevs(addfn);
5588
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    65
    }
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    66
}
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    67
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    68
static void CALLBACK
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    69
CaptureSound(HWAVEIN hwi, UINT uMsg, DWORD_PTR dwInstance,
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    70
          DWORD_PTR dwParam1, DWORD_PTR dwParam2)
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    71
{
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    72
    SDL_AudioDevice *this = (SDL_AudioDevice *) dwInstance;
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    73
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    74
    /* Only service "buffer is filled" messages */
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    75
    if (uMsg != WIM_DATA)
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    76
        return;
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    77
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    78
    /* Signal that we have a new buffer of data */
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    79
    ReleaseSemaphore(this->hidden->audio_sem, 1, NULL);
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    80
}
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    81
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    82
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    83
/* The Win32 callback for filling the WAVE device */
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    84
static void CALLBACK
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    85
FillSound(HWAVEOUT hwo, UINT uMsg, DWORD_PTR dwInstance,
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    86
          DWORD_PTR dwParam1, DWORD_PTR dwParam2)
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    87
{
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    88
    SDL_AudioDevice *this = (SDL_AudioDevice *) dwInstance;
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    89
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    90
    /* Only service "buffer done playing" messages */
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    91
    if (uMsg != WOM_DONE)
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    92
        return;
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    93
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    94
    /* Signal that we are done playing a buffer */
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    95
    ReleaseSemaphore(this->hidden->audio_sem, 1, NULL);
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    96
}
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    97
7038
7f22b9ba218f Changed audio subsystem's OpenDevice interface to return -1 on error.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
    98
static int
5588
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    99
SetMMerror(char *function, MMRESULT code)
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   100
{
8585
2d08b56cbfa9 Fixed 64-bit warnings
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   101
    int len;
5588
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   102
    char errbuf[MAXERRORLENGTH];
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   103
    wchar_t werrbuf[MAXERRORLENGTH];
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   104
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   105
    SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: ", function);
8585
2d08b56cbfa9 Fixed 64-bit warnings
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   106
    len = SDL_static_cast(int, SDL_strlen(errbuf));
5588
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   107
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   108
    waveOutGetErrorText(code, werrbuf, MAXERRORLENGTH - len);
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   109
    WideCharToMultiByte(CP_ACP, 0, werrbuf, -1, errbuf + len,
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   110
                        MAXERRORLENGTH - len, NULL, NULL);
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   111
7038
7f22b9ba218f Changed audio subsystem's OpenDevice interface to return -1 on error.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   112
    return SDL_SetError("%s", errbuf);
5588
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   113
}
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   114
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   115
static void
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   116
WINMM_WaitDevice(_THIS)
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   117
{
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   118
    /* Wait for an audio chunk to finish */
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   119
    WaitForSingleObject(this->hidden->audio_sem, INFINITE);
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   120
}
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   121
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   122
static Uint8 *
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   123
WINMM_GetDeviceBuf(_THIS)
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   124
{
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   125
    return (Uint8 *) (this->hidden->
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   126
                      wavebuf[this->hidden->next_buffer].lpData);
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   127
}
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   128
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   129
static void
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   130
WINMM_PlayDevice(_THIS)
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   131
{
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   132
    /* Queue it up */
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   133
    waveOutWrite(this->hidden->hout,
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   134
                 &this->hidden->wavebuf[this->hidden->next_buffer],
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   135
                 sizeof(this->hidden->wavebuf[0]));
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   136
    this->hidden->next_buffer = (this->hidden->next_buffer + 1) % NUM_BUFFERS;
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   137
}
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   138
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   139
static void
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   140
WINMM_WaitDone(_THIS)
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   141
{
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   142
    int i, left;
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   143
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   144
    do {
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   145
        left = NUM_BUFFERS;
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   146
        for (i = 0; i < NUM_BUFFERS; ++i) {
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   147
            if (this->hidden->wavebuf[i].dwFlags & WHDR_DONE) {
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   148
                --left;
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   149
            }
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   150
        }
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   151
        if (left > 0) {
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   152
            SDL_Delay(100);
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   153
        }
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   154
    } while (left > 0);
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   155
}
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   156
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   157
static void
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   158
WINMM_CloseDevice(_THIS)
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   159
{
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   160
    /* Close up audio */
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   161
    if (this->hidden != NULL) {
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   162
        int i;
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   163
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   164
        if (this->hidden->audio_sem) {
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   165
            CloseHandle(this->hidden->audio_sem);
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   166
            this->hidden->audio_sem = 0;
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   167
        }
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   168
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   169
        /* Clean up mixing buffers */
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   170
        for (i = 0; i < NUM_BUFFERS; ++i) {
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   171
            if (this->hidden->wavebuf[i].dwUser != 0xFFFF) {
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   172
                waveOutUnprepareHeader(this->hidden->hout,
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   173
                                       &this->hidden->wavebuf[i],
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   174
                                       sizeof(this->hidden->wavebuf[i]));
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   175
                this->hidden->wavebuf[i].dwUser = 0xFFFF;
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   176
            }
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   177
        }
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   178
7719
31b5f9ff36ca Christoph Mallon: Remove pointless if (x) before SDL_free(x)
Sam Lantinga <slouken@libsdl.org>
parents: 7461
diff changeset
   179
        /* Free raw mixing buffer */
31b5f9ff36ca Christoph Mallon: Remove pointless if (x) before SDL_free(x)
Sam Lantinga <slouken@libsdl.org>
parents: 7461
diff changeset
   180
        SDL_free(this->hidden->mixbuf);
31b5f9ff36ca Christoph Mallon: Remove pointless if (x) before SDL_free(x)
Sam Lantinga <slouken@libsdl.org>
parents: 7461
diff changeset
   181
        this->hidden->mixbuf = NULL;
5588
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   182
7332
b53acf6ab70b Fixed some Visual Studio analyze warnings
Sam Lantinga <slouken@libsdl.org>
parents: 7038
diff changeset
   183
        if (this->hidden->hin) {
b53acf6ab70b Fixed some Visual Studio analyze warnings
Sam Lantinga <slouken@libsdl.org>
parents: 7038
diff changeset
   184
            waveInClose(this->hidden->hin);
b53acf6ab70b Fixed some Visual Studio analyze warnings
Sam Lantinga <slouken@libsdl.org>
parents: 7038
diff changeset
   185
            this->hidden->hin = 0;
b53acf6ab70b Fixed some Visual Studio analyze warnings
Sam Lantinga <slouken@libsdl.org>
parents: 7038
diff changeset
   186
        }
b53acf6ab70b Fixed some Visual Studio analyze warnings
Sam Lantinga <slouken@libsdl.org>
parents: 7038
diff changeset
   187
b53acf6ab70b Fixed some Visual Studio analyze warnings
Sam Lantinga <slouken@libsdl.org>
parents: 7038
diff changeset
   188
        if (this->hidden->hout) {
b53acf6ab70b Fixed some Visual Studio analyze warnings
Sam Lantinga <slouken@libsdl.org>
parents: 7038
diff changeset
   189
            waveOutClose(this->hidden->hout);
b53acf6ab70b Fixed some Visual Studio analyze warnings
Sam Lantinga <slouken@libsdl.org>
parents: 7038
diff changeset
   190
            this->hidden->hout = 0;
b53acf6ab70b Fixed some Visual Studio analyze warnings
Sam Lantinga <slouken@libsdl.org>
parents: 7038
diff changeset
   191
        }
b53acf6ab70b Fixed some Visual Studio analyze warnings
Sam Lantinga <slouken@libsdl.org>
parents: 7038
diff changeset
   192
5588
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   193
        SDL_free(this->hidden);
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   194
        this->hidden = NULL;
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   195
    }
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   196
}
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   197
7461
489d2bbcf4aa Make winmm and directsound audio targets robust against unsupported formats.
Ryan C. Gordon <icculus@icculus.org>
parents: 7449
diff changeset
   198
static SDL_bool
8585
2d08b56cbfa9 Fixed 64-bit warnings
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   199
PrepWaveFormat(_THIS, UINT devId, WAVEFORMATEX *pfmt, const int iscapture)
7461
489d2bbcf4aa Make winmm and directsound audio targets robust against unsupported formats.
Ryan C. Gordon <icculus@icculus.org>
parents: 7449
diff changeset
   200
{
489d2bbcf4aa Make winmm and directsound audio targets robust against unsupported formats.
Ryan C. Gordon <icculus@icculus.org>
parents: 7449
diff changeset
   201
    SDL_zerop(pfmt);
489d2bbcf4aa Make winmm and directsound audio targets robust against unsupported formats.
Ryan C. Gordon <icculus@icculus.org>
parents: 7449
diff changeset
   202
489d2bbcf4aa Make winmm and directsound audio targets robust against unsupported formats.
Ryan C. Gordon <icculus@icculus.org>
parents: 7449
diff changeset
   203
    if (SDL_AUDIO_ISFLOAT(this->spec.format)) {
489d2bbcf4aa Make winmm and directsound audio targets robust against unsupported formats.
Ryan C. Gordon <icculus@icculus.org>
parents: 7449
diff changeset
   204
        pfmt->wFormatTag = WAVE_FORMAT_IEEE_FLOAT;
489d2bbcf4aa Make winmm and directsound audio targets robust against unsupported formats.
Ryan C. Gordon <icculus@icculus.org>
parents: 7449
diff changeset
   205
    } else {
489d2bbcf4aa Make winmm and directsound audio targets robust against unsupported formats.
Ryan C. Gordon <icculus@icculus.org>
parents: 7449
diff changeset
   206
        pfmt->wFormatTag = WAVE_FORMAT_PCM;
489d2bbcf4aa Make winmm and directsound audio targets robust against unsupported formats.
Ryan C. Gordon <icculus@icculus.org>
parents: 7449
diff changeset
   207
    }
489d2bbcf4aa Make winmm and directsound audio targets robust against unsupported formats.
Ryan C. Gordon <icculus@icculus.org>
parents: 7449
diff changeset
   208
    pfmt->wBitsPerSample = SDL_AUDIO_BITSIZE(this->spec.format);
489d2bbcf4aa Make winmm and directsound audio targets robust against unsupported formats.
Ryan C. Gordon <icculus@icculus.org>
parents: 7449
diff changeset
   209
489d2bbcf4aa Make winmm and directsound audio targets robust against unsupported formats.
Ryan C. Gordon <icculus@icculus.org>
parents: 7449
diff changeset
   210
    pfmt->nChannels = this->spec.channels;
489d2bbcf4aa Make winmm and directsound audio targets robust against unsupported formats.
Ryan C. Gordon <icculus@icculus.org>
parents: 7449
diff changeset
   211
    pfmt->nSamplesPerSec = this->spec.freq;
489d2bbcf4aa Make winmm and directsound audio targets robust against unsupported formats.
Ryan C. Gordon <icculus@icculus.org>
parents: 7449
diff changeset
   212
    pfmt->nBlockAlign = pfmt->nChannels * (pfmt->wBitsPerSample / 8);
489d2bbcf4aa Make winmm and directsound audio targets robust against unsupported formats.
Ryan C. Gordon <icculus@icculus.org>
parents: 7449
diff changeset
   213
    pfmt->nAvgBytesPerSec = pfmt->nSamplesPerSec * pfmt->nBlockAlign;
489d2bbcf4aa Make winmm and directsound audio targets robust against unsupported formats.
Ryan C. Gordon <icculus@icculus.org>
parents: 7449
diff changeset
   214
489d2bbcf4aa Make winmm and directsound audio targets robust against unsupported formats.
Ryan C. Gordon <icculus@icculus.org>
parents: 7449
diff changeset
   215
    if (iscapture) {
489d2bbcf4aa Make winmm and directsound audio targets robust against unsupported formats.
Ryan C. Gordon <icculus@icculus.org>
parents: 7449
diff changeset
   216
        return (waveInOpen(0, devId, pfmt, 0, 0, WAVE_FORMAT_QUERY) == 0);
489d2bbcf4aa Make winmm and directsound audio targets robust against unsupported formats.
Ryan C. Gordon <icculus@icculus.org>
parents: 7449
diff changeset
   217
    } else {
489d2bbcf4aa Make winmm and directsound audio targets robust against unsupported formats.
Ryan C. Gordon <icculus@icculus.org>
parents: 7449
diff changeset
   218
        return (waveOutOpen(0, devId, pfmt, 0, 0, WAVE_FORMAT_QUERY) == 0);
489d2bbcf4aa Make winmm and directsound audio targets robust against unsupported formats.
Ryan C. Gordon <icculus@icculus.org>
parents: 7449
diff changeset
   219
    }
489d2bbcf4aa Make winmm and directsound audio targets robust against unsupported formats.
Ryan C. Gordon <icculus@icculus.org>
parents: 7449
diff changeset
   220
}
489d2bbcf4aa Make winmm and directsound audio targets robust against unsupported formats.
Ryan C. Gordon <icculus@icculus.org>
parents: 7449
diff changeset
   221
5588
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   222
static int
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   223
WINMM_OpenDevice(_THIS, const char *devname, int iscapture)
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   224
{
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   225
    SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format);
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   226
    int valid_datatype = 0;
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   227
    MMRESULT result;
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   228
    WAVEFORMATEX waveformat;
8585
2d08b56cbfa9 Fixed 64-bit warnings
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   229
    UINT devId = WAVE_MAPPER;  /* WAVE_MAPPER == choose system's default */
5588
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   230
    char *utf8 = NULL;
8585
2d08b56cbfa9 Fixed 64-bit warnings
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   231
    UINT i;
5588
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   232
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   233
    if (devname != NULL) {  /* specific device requested? */
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   234
        if (iscapture) {
8585
2d08b56cbfa9 Fixed 64-bit warnings
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   235
            const UINT devcount = waveInGetNumDevs();
5588
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   236
            WAVEINCAPS caps;
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   237
            for (i = 0; (i < devcount) && (devId == WAVE_MAPPER); i++) {
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   238
                result = waveInGetDevCaps(i, &caps, sizeof (caps));
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   239
                if (result != MMSYSERR_NOERROR)
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   240
                    continue;
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   241
                else if ((utf8 = WIN_StringToUTF8(caps.szPname)) == NULL)
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   242
                    continue;
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   243
                else if (SDL_strcmp(devname, utf8) == 0)
8585
2d08b56cbfa9 Fixed 64-bit warnings
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   244
                    devId = i;
5588
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   245
                SDL_free(utf8);
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   246
            }
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   247
        } else {
8585
2d08b56cbfa9 Fixed 64-bit warnings
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   248
            const UINT devcount = waveOutGetNumDevs();
5588
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   249
            WAVEOUTCAPS caps;
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   250
            for (i = 0; (i < devcount) && (devId == WAVE_MAPPER); i++) {
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   251
                result = waveOutGetDevCaps(i, &caps, sizeof (caps));
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   252
                if (result != MMSYSERR_NOERROR)
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   253
                    continue;
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   254
                else if ((utf8 = WIN_StringToUTF8(caps.szPname)) == NULL)
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   255
                    continue;
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   256
                else if (SDL_strcmp(devname, utf8) == 0)
8585
2d08b56cbfa9 Fixed 64-bit warnings
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   257
                    devId = i;
5588
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   258
                SDL_free(utf8);
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   259
            }
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   260
        }
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   261
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   262
        if (devId == WAVE_MAPPER) {
7038
7f22b9ba218f Changed audio subsystem's OpenDevice interface to return -1 on error.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   263
            return SDL_SetError("Requested device not found");
5588
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   264
        }
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   265
    }
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   266
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   267
    /* Initialize all variables that we clean on shutdown */
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   268
    this->hidden = (struct SDL_PrivateAudioData *)
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   269
        SDL_malloc((sizeof *this->hidden));
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   270
    if (this->hidden == NULL) {
7038
7f22b9ba218f Changed audio subsystem's OpenDevice interface to return -1 on error.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   271
        return SDL_OutOfMemory();
5588
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   272
    }
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   273
    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   274
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   275
    /* Initialize the wavebuf structures for closing */
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   276
    for (i = 0; i < NUM_BUFFERS; ++i)
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   277
        this->hidden->wavebuf[i].dwUser = 0xFFFF;
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   278
7461
489d2bbcf4aa Make winmm and directsound audio targets robust against unsupported formats.
Ryan C. Gordon <icculus@icculus.org>
parents: 7449
diff changeset
   279
    if (this->spec.channels > 2)
489d2bbcf4aa Make winmm and directsound audio targets robust against unsupported formats.
Ryan C. Gordon <icculus@icculus.org>
parents: 7449
diff changeset
   280
        this->spec.channels = 2;        /* !!! FIXME: is this right? */
489d2bbcf4aa Make winmm and directsound audio targets robust against unsupported formats.
Ryan C. Gordon <icculus@icculus.org>
parents: 7449
diff changeset
   281
489d2bbcf4aa Make winmm and directsound audio targets robust against unsupported formats.
Ryan C. Gordon <icculus@icculus.org>
parents: 7449
diff changeset
   282
    /* Check the buffer size -- minimum of 1/4 second (word aligned) */
489d2bbcf4aa Make winmm and directsound audio targets robust against unsupported formats.
Ryan C. Gordon <icculus@icculus.org>
parents: 7449
diff changeset
   283
    if (this->spec.samples < (this->spec.freq / 4))
489d2bbcf4aa Make winmm and directsound audio targets robust against unsupported formats.
Ryan C. Gordon <icculus@icculus.org>
parents: 7449
diff changeset
   284
        this->spec.samples = ((this->spec.freq / 4) + 3) & ~3;
489d2bbcf4aa Make winmm and directsound audio targets robust against unsupported formats.
Ryan C. Gordon <icculus@icculus.org>
parents: 7449
diff changeset
   285
5588
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   286
    while ((!valid_datatype) && (test_format)) {
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   287
        switch (test_format) {
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   288
        case AUDIO_U8:
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   289
        case AUDIO_S16:
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   290
        case AUDIO_S32:
7449
5148cfb37948 Implement float32 support for winmm and directsound targets (Thanks, John!).
Ryan C. Gordon <icculus@icculus.org>
parents: 7332
diff changeset
   291
        case AUDIO_F32:
7461
489d2bbcf4aa Make winmm and directsound audio targets robust against unsupported formats.
Ryan C. Gordon <icculus@icculus.org>
parents: 7449
diff changeset
   292
            this->spec.format = test_format;
489d2bbcf4aa Make winmm and directsound audio targets robust against unsupported formats.
Ryan C. Gordon <icculus@icculus.org>
parents: 7449
diff changeset
   293
            if (PrepWaveFormat(this, devId, &waveformat, iscapture)) {
489d2bbcf4aa Make winmm and directsound audio targets robust against unsupported formats.
Ryan C. Gordon <icculus@icculus.org>
parents: 7449
diff changeset
   294
                valid_datatype = 1;
489d2bbcf4aa Make winmm and directsound audio targets robust against unsupported formats.
Ryan C. Gordon <icculus@icculus.org>
parents: 7449
diff changeset
   295
            } else {
489d2bbcf4aa Make winmm and directsound audio targets robust against unsupported formats.
Ryan C. Gordon <icculus@icculus.org>
parents: 7449
diff changeset
   296
                test_format = SDL_NextAudioFormat();
489d2bbcf4aa Make winmm and directsound audio targets robust against unsupported formats.
Ryan C. Gordon <icculus@icculus.org>
parents: 7449
diff changeset
   297
            }
489d2bbcf4aa Make winmm and directsound audio targets robust against unsupported formats.
Ryan C. Gordon <icculus@icculus.org>
parents: 7449
diff changeset
   298
            break;
5588
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   299
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   300
        default:
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   301
            test_format = SDL_NextAudioFormat();
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   302
            break;
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   303
        }
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   304
    }
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   305
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   306
    if (!valid_datatype) {
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   307
        WINMM_CloseDevice(this);
7038
7f22b9ba218f Changed audio subsystem's OpenDevice interface to return -1 on error.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   308
        return SDL_SetError("Unsupported audio format");
5588
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   309
    }
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   310
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   311
    /* Update the fragment size as size in bytes */
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   312
    SDL_CalculateAudioSpec(&this->spec);
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   313
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   314
    /* Open the audio device */
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   315
    if (iscapture) {
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   316
        result = waveInOpen(&this->hidden->hin, devId, &waveformat,
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   317
                             (DWORD_PTR) CaptureSound, (DWORD_PTR) this,
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   318
                             CALLBACK_FUNCTION);
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   319
    } else {
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   320
        result = waveOutOpen(&this->hidden->hout, devId, &waveformat,
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   321
                             (DWORD_PTR) FillSound, (DWORD_PTR) this,
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   322
                             CALLBACK_FUNCTION);
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   323
    }
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   324
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   325
    if (result != MMSYSERR_NOERROR) {
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   326
        WINMM_CloseDevice(this);
7038
7f22b9ba218f Changed audio subsystem's OpenDevice interface to return -1 on error.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   327
        return SetMMerror("waveOutOpen()", result);
5588
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   328
    }
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   329
#ifdef SOUND_DEBUG
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   330
    /* Check the sound device we retrieved */
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   331
    {
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   332
        WAVEOUTCAPS caps;
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   333
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   334
        result = waveOutGetDevCaps((UINT) this->hidden->hout,
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   335
                                   &caps, sizeof(caps));
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   336
        if (result != MMSYSERR_NOERROR) {
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   337
            WINMM_CloseDevice(this);
7038
7f22b9ba218f Changed audio subsystem's OpenDevice interface to return -1 on error.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   338
            return SetMMerror("waveOutGetDevCaps()", result);
5588
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   339
        }
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   340
        printf("Audio device: %s\n", caps.szPname);
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   341
    }
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   342
#endif
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   343
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   344
    /* Create the audio buffer semaphore */
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   345
    this->hidden->audio_sem =
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   346
        CreateSemaphore(NULL, NUM_BUFFERS - 1, NUM_BUFFERS, NULL);
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   347
    if (this->hidden->audio_sem == NULL) {
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   348
        WINMM_CloseDevice(this);
7038
7f22b9ba218f Changed audio subsystem's OpenDevice interface to return -1 on error.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   349
        return SDL_SetError("Couldn't create semaphore");
5588
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   350
    }
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   351
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   352
    /* Create the sound buffers */
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   353
    this->hidden->mixbuf =
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   354
        (Uint8 *) SDL_malloc(NUM_BUFFERS * this->spec.size);
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   355
    if (this->hidden->mixbuf == NULL) {
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   356
        WINMM_CloseDevice(this);
7038
7f22b9ba218f Changed audio subsystem's OpenDevice interface to return -1 on error.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   357
        return SDL_OutOfMemory();
5588
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   358
    }
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   359
    for (i = 0; i < NUM_BUFFERS; ++i) {
6352
a9bcd26e7105 Removed unneeded audio buffer memset() for consistent behavior on all platforms.
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   360
        SDL_memset(&this->hidden->wavebuf[i], 0,
5588
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   361
                   sizeof(this->hidden->wavebuf[i]));
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   362
        this->hidden->wavebuf[i].dwBufferLength = this->spec.size;
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   363
        this->hidden->wavebuf[i].dwFlags = WHDR_DONE;
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   364
        this->hidden->wavebuf[i].lpData =
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   365
            (LPSTR) & this->hidden->mixbuf[i * this->spec.size];
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   366
        result = waveOutPrepareHeader(this->hidden->hout,
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   367
                                      &this->hidden->wavebuf[i],
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   368
                                      sizeof(this->hidden->wavebuf[i]));
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   369
        if (result != MMSYSERR_NOERROR) {
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   370
            WINMM_CloseDevice(this);
7038
7f22b9ba218f Changed audio subsystem's OpenDevice interface to return -1 on error.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   371
            return SetMMerror("waveOutPrepareHeader()", result);
5588
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   372
        }
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   373
    }
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   374
7038
7f22b9ba218f Changed audio subsystem's OpenDevice interface to return -1 on error.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   375
    return 0;                   /* Ready to go! */
5588
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   376
}
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   377
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   378
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   379
static int
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   380
WINMM_Init(SDL_AudioDriverImpl * impl)
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   381
{
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   382
    /* Set the function pointers */
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   383
    impl->DetectDevices = WINMM_DetectDevices;
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   384
    impl->OpenDevice = WINMM_OpenDevice;
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   385
    impl->PlayDevice = WINMM_PlayDevice;
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   386
    impl->WaitDevice = WINMM_WaitDevice;
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   387
    impl->WaitDone = WINMM_WaitDone;
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   388
    impl->GetDeviceBuf = WINMM_GetDeviceBuf;
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   389
    impl->CloseDevice = WINMM_CloseDevice;
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   390
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   391
    return 1;   /* this audio target is available. */
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   392
}
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   393
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   394
AudioBootStrap WINMM_bootstrap = {
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   395
    "winmm", "Windows Waveform Audio", WINMM_Init, 0
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   396
};
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   397
6044
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 5593
diff changeset
   398
#endif /* SDL_AUDIO_DRIVER_WINMM */
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 5593
diff changeset
   399
5588
57bfc2a2a452 Reworked Windows waveOut code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   400
/* vi: set ts=4 sw=4 expandtab: */