Subversion Repositories eduke32

Rev

Rev 8567 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8567 Rev 8757
Line 1... Line 1...
1
/*
1
/*
2
 Copyright (C) 2009 Jonathon Fowler <jf@jonof.id.au>
2
 Copyright (C) 2009 Jonathon Fowler <jf@jonof.id.au>
-
 
3
 Copyright (C) EDuke32 developers and contributors
3

4

4
 This program is free software; you can redistribute it and/or
5
 This program is free software; you can redistribute it and/or
5
 modify it under the terms of the GNU General Public License
6
 modify it under the terms of the GNU General Public License
6
 as published by the Free Software Foundation; either version 2
7
 as published by the Free Software Foundation; either version 2
7
 of the License, or (at your option) any later version.
8
 of the License, or (at your option) any later version.
Line 35... Line 36...
35
#include "android.h"
36
#include "android.h"
36
#endif
37
#endif
37
38
38
enum
39
enum
39
{
40
{
40
    SDLErr_Warning = -2,
-
 
41
    SDLErr_Error   = -1,
41
    SDLErr_Error   = -1,
42
    SDLErr_Ok      = 0,
42
    SDLErr_Ok      = 0,
43
    SDLErr_Uninitialised,
43
    SDLErr_Uninitialised,
44
    SDLErr_InitSubSystem,
44
    SDLErr_InitSubSystem,
45
    SDLErr_OpenAudio
45
    SDLErr_OpenAudio
Line 103... Line 103...
103
103
104
int SDLDrv_GetError(void) { return ErrorCode; }
104
int SDLDrv_GetError(void) { return ErrorCode; }
105
105
106
const char *SDLDrv_ErrorString(int ErrorNumber)
106
const char *SDLDrv_ErrorString(int ErrorNumber)
107
{
107
{
108
    const char *ErrorString;
-
 
109
-
 
110
    switch (ErrorNumber)
108
    switch (ErrorNumber)
111
    {
109
    {
112
        case SDLErr_Warning:
-
 
113
        case SDLErr_Error:
-
 
114
            ErrorString = SDLDrv_ErrorString(ErrorCode);
110
        case SDLErr_Error:         return SDLDrv_ErrorString(ErrorCode);
115
            break;
-
 
116
-
 
117
        case SDLErr_Ok:
-
 
118
            ErrorString = "SDL Audio ok.";
111
        case SDLErr_Ok:            return "SDL Audio ok.";
119
            break;
-
 
120
-
 
121
        case SDLErr_Uninitialised:
-
 
122
            ErrorString = "SDL Audio uninitialised.";
112
        case SDLErr_Uninitialised: return "SDL Audio uninitialized.";
123
            break;
-
 
124
-
 
125
        case SDLErr_InitSubSystem:
-
 
126
            ErrorString = "SDL Audio: error in Init or InitSubSystem.";
113
        case SDLErr_InitSubSystem: return "SDL Audio: error in Init or InitSubSystem.";
127
            break;
-
 
128
-
 
129
        case SDLErr_OpenAudio:
-
 
130
            ErrorString = "SDL Audio: error in OpenAudio.";
114
        case SDLErr_OpenAudio:     return "SDL Audio: error in OpenAudio.";
131
            break;
-
 
132
-
 
133
        default:
-
 
134
            ErrorString = "Unknown SDL Audio error code.";
115
        default:                   return "Unknown SDL Audio error code.";
135
            break;
-
 
136
    }
116
    }
137
-
 
138
    return ErrorString;
-
 
139
}
117
}
140
118
141
#if SDL_MAJOR_VERSION >= 2
119
#if SDL_MAJOR_VERSION >= 2
142
void SDLDrv_PCM_PrintDrivers(void)
120
void SDLDrv_PCM_PrintDrivers(void)
143
{
121
{
Line 166... Line 144...
166
{
144
{
167
    UNREFERENCED_PARAMETER(initdata);
145
    UNREFERENCED_PARAMETER(initdata);
168
146
169
    Uint32 inited;
147
    Uint32 inited;
170
    int err = 0;
148
    int err = 0;
171
    SDL_AudioSpec spec, actual;
-
 
172
149
173
    if (Initialised)
150
    if (Initialised)
174
        SDLDrv_PCM_Shutdown();
151
        SDLDrv_PCM_Shutdown();
175
#if SDL_MAJOR_VERSION >= 2
152
#if SDL_MAJOR_VERSION >= 2
176
    else if (SDLAudioDriverNameEnv == nullptr)
153
    else if (SDLAudioDriverNameEnv == nullptr)
Line 208... Line 185...
208
    int chunksize = 512;
185
    int chunksize = 512;
209
#ifdef __ANDROID__
186
#ifdef __ANDROID__
210
    chunksize = droidinfo.audio_buffer_size;
187
    chunksize = droidinfo.audio_buffer_size;
211
#endif
188
#endif
212
189
-
 
190
    SDL_AudioSpec spec = {};
-
 
191
213
    spec.freq = *mixrate;
192
    spec.freq = *mixrate;
214
    spec.format = AUDIO_S16SYS;
193
    spec.format = AUDIO_S16SYS;
215
    spec.channels = *numchannels;
194
    spec.channels = *numchannels;
216
    spec.samples = chunksize;
195
    spec.samples = chunksize;
217
    spec.callback = fillData;
196
    spec.callback = fillData;
218
    spec.userdata = nullptr;
197
    spec.userdata = nullptr;
219
198
220
    Bmemset(&actual, 0, sizeof(actual));
199
    SDL_AudioSpec actual = {};
221
200
222
#if (SDL_MAJOR_VERSION == 1)
201
#if (SDL_MAJOR_VERSION == 1)
223
    err = !SDL_OpenAudio(&spec, &actual);
202
    err = !SDL_OpenAudio(&spec, &actual);
224
#else
203
#else
225
    audio_dev = err = SDL_OpenAudioDevice(nullptr, 0, &spec, &actual, SDL_AUDIO_ALLOW_FREQUENCY_CHANGE);
204
    audio_dev = err = SDL_OpenAudioDevice(nullptr, 0, &spec, &actual, SDL_AUDIO_ALLOW_FREQUENCY_CHANGE);