src/audio/arts/SDL_artsaudio.c
author Ryan C. Gordon <icculus@icculus.org>
Wed, 18 Mar 2015 02:01:17 -0400
changeset 9394 bb28e5281770
parent 9393 ed79a66e57e5
child 9619 b94b6d0bff0f
permissions -rw-r--r--
Bunch of reworking to how we manage audio devices. Device enumeration now happens at startup and then is managed exclusively through hotplugging instead of full redetection. The device name list now has a unique "handle" associated with each item and SDL will pass this to the backend so they don't have to figure out how a human readable name maps to real hardware for a second time. Other cleanups, fixes, improvements, plus all the audio backends updated to the new interface...largely untested at this point, though.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
     1
/*
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
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>
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
     4
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
     5
  This software is provided 'as-is', without any express or implied
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
     7
  arising from the use of this software.
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
     8
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    11
  freely, subject to the following restrictions:
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    12
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    14
     claim that you wrote the original software. If you use this software
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    16
     appreciated but is not required.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    18
     misrepresented as being the original software.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
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: 7857
diff changeset
    21
#include "../../SDL_internal.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    22
6044
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 5594
diff changeset
    23
#if SDL_AUDIO_DRIVER_ARTS
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 5594
diff changeset
    24
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    25
/* Allow access to a raw mixing buffer */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    26
2155
31269eb74914 Merged r3165:3166 from branches/SDL-1.2: gcc -Wall fix in arts audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 2141
diff changeset
    27
#ifdef HAVE_SIGNAL_H
31269eb74914 Merged r3165:3166 from branches/SDL-1.2: gcc -Wall fix in arts audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 2141
diff changeset
    28
#include <signal.h>
31269eb74914 Merged r3165:3166 from branches/SDL-1.2: gcc -Wall fix in arts audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 2141
diff changeset
    29
#endif
31269eb74914 Merged r3165:3166 from branches/SDL-1.2: gcc -Wall fix in arts audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 2141
diff changeset
    30
#include <unistd.h>
3068
b21348d47cab Fixed bug #633
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
    31
#include <errno.h>
2155
31269eb74914 Merged r3165:3166 from branches/SDL-1.2: gcc -Wall fix in arts audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 2141
diff changeset
    32
1358
c71e05b4dc2e More header massaging... works great on Windows. ;-)
Sam Lantinga <slouken@libsdl.org>
parents: 1338
diff changeset
    33
#include "SDL_timer.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    34
#include "SDL_audio.h"
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
    35
#include "../SDL_audiomem.h"
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
    36
#include "../SDL_audio_c.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    37
#include "SDL_artsaudio.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
    38
6046
3b33b82cdbac Fixed some preprocessor mistakes introduced in iOS project cleanup.
Ryan C. Gordon <icculus@icculus.org>
parents: 6044
diff changeset
    39
#ifdef SDL_AUDIO_DRIVER_ARTS_DYNAMIC
294
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
    40
#include "SDL_name.h"
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
    41
#include "SDL_loadso.h"
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
    42
#else
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
    43
#define SDL_NAME(X)	X
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
    44
#endif
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
    45
6046
3b33b82cdbac Fixed some preprocessor mistakes introduced in iOS project cleanup.
Ryan C. Gordon <icculus@icculus.org>
parents: 6044
diff changeset
    46
#ifdef SDL_AUDIO_DRIVER_ARTS_DYNAMIC
294
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
    47
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
    48
static const char *arts_library = SDL_AUDIO_DRIVER_ARTS_DYNAMIC;
294
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
    49
static void *arts_handle = NULL;
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
    50
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
    51
/* !!! FIXME: I hate this SDL_NAME clutter...it makes everything so messy! */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    52
static int (*SDL_NAME(arts_init)) (void);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    53
static void (*SDL_NAME(arts_free)) (void);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    54
static arts_stream_t(*SDL_NAME(arts_play_stream)) (int rate, int bits,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    55
                                                   int channels,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    56
                                                   const char *name);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    57
static int (*SDL_NAME(arts_stream_set)) (arts_stream_t s,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    58
                                         arts_parameter_t param, int value);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    59
static int (*SDL_NAME(arts_stream_get)) (arts_stream_t s,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    60
                                         arts_parameter_t param);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    61
static int (*SDL_NAME(arts_write)) (arts_stream_t s, const void *buffer,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    62
                                    int count);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    63
static void (*SDL_NAME(arts_close_stream)) (arts_stream_t s);
6152
ff0bc7241515 Use arts_suspend() in a loop to wait for arts to become ready.
Ryan C. Gordon <icculus@icculus.org>
parents: 6138
diff changeset
    64
static int (*SDL_NAME(arts_suspend))(void);
2141
e1a70460c354 stupid indent
Sam Lantinga <slouken@libsdl.org>
parents: 2121
diff changeset
    65
static int (*SDL_NAME(arts_suspended)) (void);
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
    66
static const char *(*SDL_NAME(arts_error_text)) (int errorcode);
301
fb4c4c6a2773 Fixed dynamic arts support.
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
    67
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
    68
#define SDL_ARTS_SYM(x) { #x, (void **) (char *) &SDL_NAME(x) }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    69
static struct
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    70
{
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    71
    const char *name;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    72
    void **func;
294
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
    73
} arts_functions[] = {
2141
e1a70460c354 stupid indent
Sam Lantinga <slouken@libsdl.org>
parents: 2121
diff changeset
    74
/* *INDENT-OFF* */
e1a70460c354 stupid indent
Sam Lantinga <slouken@libsdl.org>
parents: 2121
diff changeset
    75
    SDL_ARTS_SYM(arts_init),
e1a70460c354 stupid indent
Sam Lantinga <slouken@libsdl.org>
parents: 2121
diff changeset
    76
    SDL_ARTS_SYM(arts_free),
e1a70460c354 stupid indent
Sam Lantinga <slouken@libsdl.org>
parents: 2121
diff changeset
    77
    SDL_ARTS_SYM(arts_play_stream),
e1a70460c354 stupid indent
Sam Lantinga <slouken@libsdl.org>
parents: 2121
diff changeset
    78
    SDL_ARTS_SYM(arts_stream_set),
e1a70460c354 stupid indent
Sam Lantinga <slouken@libsdl.org>
parents: 2121
diff changeset
    79
    SDL_ARTS_SYM(arts_stream_get),
e1a70460c354 stupid indent
Sam Lantinga <slouken@libsdl.org>
parents: 2121
diff changeset
    80
    SDL_ARTS_SYM(arts_write),
e1a70460c354 stupid indent
Sam Lantinga <slouken@libsdl.org>
parents: 2121
diff changeset
    81
    SDL_ARTS_SYM(arts_close_stream),
6152
ff0bc7241515 Use arts_suspend() in a loop to wait for arts to become ready.
Ryan C. Gordon <icculus@icculus.org>
parents: 6138
diff changeset
    82
    SDL_ARTS_SYM(arts_suspend),
2141
e1a70460c354 stupid indent
Sam Lantinga <slouken@libsdl.org>
parents: 2121
diff changeset
    83
    SDL_ARTS_SYM(arts_suspended),
e1a70460c354 stupid indent
Sam Lantinga <slouken@libsdl.org>
parents: 2121
diff changeset
    84
    SDL_ARTS_SYM(arts_error_text),
e1a70460c354 stupid indent
Sam Lantinga <slouken@libsdl.org>
parents: 2121
diff changeset
    85
/* *INDENT-ON* */
2121
85ed90a755fa Reworked r3067:3068 from branches/SDL-1.2: arts unavailable hardware bug fix.
Ryan C. Gordon <icculus@icculus.org>
parents: 2060
diff changeset
    86
};
2141
e1a70460c354 stupid indent
Sam Lantinga <slouken@libsdl.org>
parents: 2121
diff changeset
    87
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
    88
#undef SDL_ARTS_SYM
294
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
    89
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    90
static void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    91
UnloadARTSLibrary()
294
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
    92
{
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
    93
    if (arts_handle != NULL) {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    94
        SDL_UnloadObject(arts_handle);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    95
        arts_handle = NULL;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    96
    }
294
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
    97
}
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
    98
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
    99
static int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   100
LoadARTSLibrary(void)
294
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
   101
{
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   102
    int i, retval = -1;
294
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
   103
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   104
    if (arts_handle == NULL) {
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   105
        arts_handle = SDL_LoadObject(arts_library);
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   106
        if (arts_handle != NULL) {
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   107
            retval = 0;
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   108
            for (i = 0; i < SDL_arraysize(arts_functions); ++i) {
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   109
                *arts_functions[i].func =
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   110
                    SDL_LoadFunction(arts_handle, arts_functions[i].name);
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   111
                if (!*arts_functions[i].func) {
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   112
                    retval = -1;
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   113
                    UnloadARTSLibrary();
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   114
                    break;
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   115
                }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   116
            }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   117
        }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   118
    }
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   119
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   120
    return retval;
294
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
   121
}
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
   122
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
   123
#else
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
   124
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   125
static void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   126
UnloadARTSLibrary()
294
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
   127
{
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   128
    return;
294
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
   129
}
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
   130
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   131
static int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   132
LoadARTSLibrary(void)
294
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
   133
{
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   134
    return 0;
294
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
   135
}
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
   136
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
   137
#endif /* SDL_AUDIO_DRIVER_ARTS_DYNAMIC */
294
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
   138
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   139
/* This function waits until it is possible to write a full sound buffer */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   140
static void
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   141
ARTS_WaitDevice(_THIS)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   142
{
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   143
    Sint32 ticks;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   144
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   145
    /* Check to see if the thread-parent process is still alive */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   146
    {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   147
        static int cnt = 0;
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   148
        /* Note that this only works with thread implementations
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   149
           that use a different process id for each thread.
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   150
         */
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   151
        /* Check every 10 loops */
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   152
        if (this->hidden->parent && (((++cnt) % 10) == 0)) {
3068
b21348d47cab Fixed bug #633
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
   153
            if (kill(this->hidden->parent, 0) < 0 && errno == ESRCH) {
9394
bb28e5281770 Bunch of reworking to how we manage audio devices.
Ryan C. Gordon <icculus@icculus.org>
parents: 9393
diff changeset
   154
                SDL_OpenedAudioDeviceDisconnected(this);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   155
            }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   156
        }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   157
    }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   158
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   159
    /* Use timer for general audio synchronization */
2060
866052b01ee5 indent is evil
Sam Lantinga <slouken@libsdl.org>
parents: 2049
diff changeset
   160
    ticks =
866052b01ee5 indent is evil
Sam Lantinga <slouken@libsdl.org>
parents: 2049
diff changeset
   161
        ((Sint32) (this->hidden->next_frame - SDL_GetTicks())) - FUDGE_TICKS;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   162
    if (ticks > 0) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   163
        SDL_Delay(ticks);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   164
    }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   165
}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   166
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   167
static void
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   168
ARTS_PlayDevice(_THIS)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   169
{
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   170
    /* Write the audio data */
2060
866052b01ee5 indent is evil
Sam Lantinga <slouken@libsdl.org>
parents: 2049
diff changeset
   171
    int written = SDL_NAME(arts_write) (this->hidden->stream,
866052b01ee5 indent is evil
Sam Lantinga <slouken@libsdl.org>
parents: 2049
diff changeset
   172
                                        this->hidden->mixbuf,
866052b01ee5 indent is evil
Sam Lantinga <slouken@libsdl.org>
parents: 2049
diff changeset
   173
                                        this->hidden->mixlen);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   174
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   175
    /* If timer synchronization is enabled, set the next write frame */
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   176
    if (this->hidden->frame_ticks) {
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   177
        this->hidden->next_frame += this->hidden->frame_ticks;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   178
    }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   179
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   180
    /* If we couldn't write, assume fatal error for now */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   181
    if (written < 0) {
9394
bb28e5281770 Bunch of reworking to how we manage audio devices.
Ryan C. Gordon <icculus@icculus.org>
parents: 9393
diff changeset
   182
        SDL_OpenedAudioDeviceDisconnected(this);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   183
    }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   184
#ifdef DEBUG_AUDIO
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   185
    fprintf(stderr, "Wrote %d bytes of audio data\n", written);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   186
#endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   187
}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   188
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   189
static void
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   190
ARTS_WaitDone(_THIS)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   191
{
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   192
    /* !!! FIXME: camp here until buffer drains... SDL_Delay(???); */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   193
}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   194
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   195
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   196
static Uint8 *
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   197
ARTS_GetDeviceBuf(_THIS)
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   198
{
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   199
    return (this->hidden->mixbuf);
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   200
}
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   201
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   202
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   203
static void
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   204
ARTS_CloseDevice(_THIS)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   205
{
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   206
    if (this->hidden != NULL) {
7719
31b5f9ff36ca Christoph Mallon: Remove pointless if (x) before SDL_free(x)
Sam Lantinga <slouken@libsdl.org>
parents: 7038
diff changeset
   207
        SDL_FreeAudioMem(this->hidden->mixbuf);
31b5f9ff36ca Christoph Mallon: Remove pointless if (x) before SDL_free(x)
Sam Lantinga <slouken@libsdl.org>
parents: 7038
diff changeset
   208
        this->hidden->mixbuf = NULL;
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   209
        if (this->hidden->stream) {
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   210
            SDL_NAME(arts_close_stream) (this->hidden->stream);
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   211
            this->hidden->stream = 0;
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   212
        }
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   213
        SDL_NAME(arts_free) ();
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   214
        SDL_free(this->hidden);
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   215
        this->hidden = NULL;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   216
    }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   217
}
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   218
6152
ff0bc7241515 Use arts_suspend() in a loop to wait for arts to become ready.
Ryan C. Gordon <icculus@icculus.org>
parents: 6138
diff changeset
   219
static int
ff0bc7241515 Use arts_suspend() in a loop to wait for arts to become ready.
Ryan C. Gordon <icculus@icculus.org>
parents: 6138
diff changeset
   220
ARTS_Suspend(void)
ff0bc7241515 Use arts_suspend() in a loop to wait for arts to become ready.
Ryan C. Gordon <icculus@icculus.org>
parents: 6138
diff changeset
   221
{
ff0bc7241515 Use arts_suspend() in a loop to wait for arts to become ready.
Ryan C. Gordon <icculus@icculus.org>
parents: 6138
diff changeset
   222
    const Uint32 abortms = SDL_GetTicks() + 3000; /* give up after 3 secs */
7857
6388f5229bb7 Added a macro SDL_TICKS_PASSED() to correctly compare two 32-bit tick values.
Sam Lantinga <slouken@libsdl.org>
parents: 7719
diff changeset
   223
    while ( (!SDL_NAME(arts_suspended)()) && !SDL_TICKS_PASSED(SDL_GetTicks(), abortms) ) {
6152
ff0bc7241515 Use arts_suspend() in a loop to wait for arts to become ready.
Ryan C. Gordon <icculus@icculus.org>
parents: 6138
diff changeset
   224
        if ( SDL_NAME(arts_suspend)() ) {
ff0bc7241515 Use arts_suspend() in a loop to wait for arts to become ready.
Ryan C. Gordon <icculus@icculus.org>
parents: 6138
diff changeset
   225
            break;
ff0bc7241515 Use arts_suspend() in a loop to wait for arts to become ready.
Ryan C. Gordon <icculus@icculus.org>
parents: 6138
diff changeset
   226
        }
ff0bc7241515 Use arts_suspend() in a loop to wait for arts to become ready.
Ryan C. Gordon <icculus@icculus.org>
parents: 6138
diff changeset
   227
    }
ff0bc7241515 Use arts_suspend() in a loop to wait for arts to become ready.
Ryan C. Gordon <icculus@icculus.org>
parents: 6138
diff changeset
   228
    return SDL_NAME(arts_suspended)();
ff0bc7241515 Use arts_suspend() in a loop to wait for arts to become ready.
Ryan C. Gordon <icculus@icculus.org>
parents: 6138
diff changeset
   229
}
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   230
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   231
static int
9394
bb28e5281770 Bunch of reworking to how we manage audio devices.
Ryan C. Gordon <icculus@icculus.org>
parents: 9393
diff changeset
   232
ARTS_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   233
{
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   234
    int rc = 0;
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   235
    int bits = 0, frag_spec = 0;
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   236
    SDL_AudioFormat test_format = 0, format = 0;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   237
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   238
    /* Initialize all variables that we clean on shutdown */
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   239
    this->hidden = (struct SDL_PrivateAudioData *)
2060
866052b01ee5 indent is evil
Sam Lantinga <slouken@libsdl.org>
parents: 2049
diff changeset
   240
        SDL_malloc((sizeof *this->hidden));
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   241
    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
   242
        return SDL_OutOfMemory();
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   243
    }
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   244
    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   245
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   246
    /* Try for a closest match on audio format */
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   247
    for (test_format = SDL_FirstAudioFormat(this->spec.format);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   248
         !format && test_format;) {
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   249
#ifdef DEBUG_AUDIO
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   250
        fprintf(stderr, "Trying format 0x%4.4x\n", test_format);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   251
#endif
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   252
        switch (test_format) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   253
        case AUDIO_U8:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   254
            bits = 8;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   255
            format = 1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   256
            break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   257
        case AUDIO_S16LSB:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   258
            bits = 16;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   259
            format = 1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   260
            break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   261
        default:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   262
            format = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   263
            break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   264
        }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   265
        if (!format) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   266
            test_format = SDL_NextAudioFormat();
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   267
        }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   268
    }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   269
    if (format == 0) {
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   270
        ARTS_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
   271
        return SDL_SetError("Couldn't find any hardware audio formats");
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   272
    }
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   273
    this->spec.format = test_format;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   274
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   275
    if ((rc = SDL_NAME(arts_init) ()) != 0) {
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   276
        ARTS_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
   277
        return SDL_SetError("Unable to initialize ARTS: %s",
7f22b9ba218f Changed audio subsystem's OpenDevice interface to return -1 on error.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   278
                            SDL_NAME(arts_error_text) (rc));
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   279
    }
2121
85ed90a755fa Reworked r3067:3068 from branches/SDL-1.2: arts unavailable hardware bug fix.
Ryan C. Gordon <icculus@icculus.org>
parents: 2060
diff changeset
   280
6152
ff0bc7241515 Use arts_suspend() in a loop to wait for arts to become ready.
Ryan C. Gordon <icculus@icculus.org>
parents: 6138
diff changeset
   281
    if (!ARTS_Suspend()) {
2121
85ed90a755fa Reworked r3067:3068 from branches/SDL-1.2: arts unavailable hardware bug fix.
Ryan C. Gordon <icculus@icculus.org>
parents: 2060
diff changeset
   282
        ARTS_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
   283
        return SDL_SetError("ARTS can not open audio device");
2121
85ed90a755fa Reworked r3067:3068 from branches/SDL-1.2: arts unavailable hardware bug fix.
Ryan C. Gordon <icculus@icculus.org>
parents: 2060
diff changeset
   284
    }
85ed90a755fa Reworked r3067:3068 from branches/SDL-1.2: arts unavailable hardware bug fix.
Ryan C. Gordon <icculus@icculus.org>
parents: 2060
diff changeset
   285
2060
866052b01ee5 indent is evil
Sam Lantinga <slouken@libsdl.org>
parents: 2049
diff changeset
   286
    this->hidden->stream = SDL_NAME(arts_play_stream) (this->spec.freq,
866052b01ee5 indent is evil
Sam Lantinga <slouken@libsdl.org>
parents: 2049
diff changeset
   287
                                                       bits,
866052b01ee5 indent is evil
Sam Lantinga <slouken@libsdl.org>
parents: 2049
diff changeset
   288
                                                       this->spec.channels,
866052b01ee5 indent is evil
Sam Lantinga <slouken@libsdl.org>
parents: 2049
diff changeset
   289
                                                       "SDL");
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   290
2121
85ed90a755fa Reworked r3067:3068 from branches/SDL-1.2: arts unavailable hardware bug fix.
Ryan C. Gordon <icculus@icculus.org>
parents: 2060
diff changeset
   291
    /* Play nothing so we have at least one write (server bug workaround). */
85ed90a755fa Reworked r3067:3068 from branches/SDL-1.2: arts unavailable hardware bug fix.
Ryan C. Gordon <icculus@icculus.org>
parents: 2060
diff changeset
   292
    SDL_NAME(arts_write) (this->hidden->stream, "", 0);
85ed90a755fa Reworked r3067:3068 from branches/SDL-1.2: arts unavailable hardware bug fix.
Ryan C. Gordon <icculus@icculus.org>
parents: 2060
diff changeset
   293
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   294
    /* Calculate the final parameters for this audio specification */
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   295
    SDL_CalculateAudioSpec(&this->spec);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   296
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   297
    /* Determine the power of two of the fragment size */
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   298
    for (frag_spec = 0; (0x01 << frag_spec) < this->spec.size; ++frag_spec);
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   299
    if ((0x01 << frag_spec) != this->spec.size) {
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   300
        ARTS_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
   301
        return SDL_SetError("Fragment size must be a power of two");
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   302
    }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   303
    frag_spec |= 0x00020000;    /* two fragments, for low latency */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   304
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   305
#ifdef ARTS_P_PACKET_SETTINGS
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   306
    SDL_NAME(arts_stream_set) (this->hidden->stream,
2060
866052b01ee5 indent is evil
Sam Lantinga <slouken@libsdl.org>
parents: 2049
diff changeset
   307
                               ARTS_P_PACKET_SETTINGS, frag_spec);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   308
#else
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   309
    SDL_NAME(arts_stream_set) (this->hidden->stream, ARTS_P_PACKET_SIZE,
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   310
                               frag_spec & 0xffff);
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   311
    SDL_NAME(arts_stream_set) (this->hidden->stream, ARTS_P_PACKET_COUNT,
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   312
                               frag_spec >> 16);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   313
#endif
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   314
    this->spec.size = SDL_NAME(arts_stream_get) (this->hidden->stream,
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   315
                                                 ARTS_P_PACKET_SIZE);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   316
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   317
    /* Allocate mixing buffer */
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   318
    this->hidden->mixlen = this->spec.size;
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   319
    this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen);
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   320
    if (this->hidden->mixbuf == NULL) {
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   321
        ARTS_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
   322
        return SDL_OutOfMemory();
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   323
    }
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   324
    SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   325
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   326
    /* Get the parent process id (we're the parent of the audio thread) */
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   327
    this->hidden->parent = getpid();
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   328
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   329
    /* We're ready to rock and roll. :-) */
7038
7f22b9ba218f Changed audio subsystem's OpenDevice interface to return -1 on error.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   330
    return 0;
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   331
}
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   332
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   333
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   334
static void
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   335
ARTS_Deinitialize(void)
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   336
{
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   337
    UnloadARTSLibrary();
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
   338
}
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   339
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   340
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   341
static int
2060
866052b01ee5 indent is evil
Sam Lantinga <slouken@libsdl.org>
parents: 2049
diff changeset
   342
ARTS_Init(SDL_AudioDriverImpl * impl)
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   343
{
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   344
    if (LoadARTSLibrary() < 0) {
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   345
        return 0;
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   346
    } else {
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   347
        if (SDL_NAME(arts_init) () != 0) {
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   348
            UnloadARTSLibrary();
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   349
            SDL_SetError("ARTS: arts_init failed (no audio server?)");
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   350
            return 0;
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   351
        }
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   352
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   353
        /* Play a stream so aRts doesn't crash */
6152
ff0bc7241515 Use arts_suspend() in a loop to wait for arts to become ready.
Ryan C. Gordon <icculus@icculus.org>
parents: 6138
diff changeset
   354
        if (ARTS_Suspend()) {
2121
85ed90a755fa Reworked r3067:3068 from branches/SDL-1.2: arts unavailable hardware bug fix.
Ryan C. Gordon <icculus@icculus.org>
parents: 2060
diff changeset
   355
            arts_stream_t stream;
85ed90a755fa Reworked r3067:3068 from branches/SDL-1.2: arts unavailable hardware bug fix.
Ryan C. Gordon <icculus@icculus.org>
parents: 2060
diff changeset
   356
            stream = SDL_NAME(arts_play_stream) (44100, 16, 2, "SDL");
85ed90a755fa Reworked r3067:3068 from branches/SDL-1.2: arts unavailable hardware bug fix.
Ryan C. Gordon <icculus@icculus.org>
parents: 2060
diff changeset
   357
            SDL_NAME(arts_write) (stream, "", 0);
85ed90a755fa Reworked r3067:3068 from branches/SDL-1.2: arts unavailable hardware bug fix.
Ryan C. Gordon <icculus@icculus.org>
parents: 2060
diff changeset
   358
            SDL_NAME(arts_close_stream) (stream);
85ed90a755fa Reworked r3067:3068 from branches/SDL-1.2: arts unavailable hardware bug fix.
Ryan C. Gordon <icculus@icculus.org>
parents: 2060
diff changeset
   359
        }
85ed90a755fa Reworked r3067:3068 from branches/SDL-1.2: arts unavailable hardware bug fix.
Ryan C. Gordon <icculus@icculus.org>
parents: 2060
diff changeset
   360
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   361
        SDL_NAME(arts_free) ();
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   362
    }
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   363
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   364
    /* Set the function pointers */
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   365
    impl->OpenDevice = ARTS_OpenDevice;
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   366
    impl->PlayDevice = ARTS_PlayDevice;
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   367
    impl->WaitDevice = ARTS_WaitDevice;
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   368
    impl->GetDeviceBuf = ARTS_GetDeviceBuf;
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   369
    impl->CloseDevice = ARTS_CloseDevice;
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   370
    impl->WaitDone = ARTS_WaitDone;
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   371
    impl->Deinitialize = ARTS_Deinitialize;
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   372
    impl->OnlyHasDefaultOutputDevice = 1;
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   373
3699
4160ba33b597 Removed test for "driver is valid, but doesn't see any audio devices."
Ryan C. Gordon <icculus@icculus.org>
parents: 3697
diff changeset
   374
    return 1;   /* this audio target is available. */
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   375
}
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   376
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   377
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   378
AudioBootStrap ARTS_bootstrap = {
5594
e741303e08a8 Removed needless macros in various audio targets.
Ryan C. Gordon <icculus@icculus.org>
parents: 5535
diff changeset
   379
    "arts", "Analog RealTime Synthesizer", ARTS_Init, 0
2049
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   380
};
5f6550e5184f Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents: 1982
diff changeset
   381
6044
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 5594
diff changeset
   382
#endif /* SDL_AUDIO_DRIVER_ARTS */
35448a5ea044 Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents: 5594
diff changeset
   383
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
   384
/* vi: set ts=4 sw=4 expandtab: */