Mercurial > sdl-ios-xcode
annotate src/audio/baudio/SDL_beaudio.cc @ 3837:7c9663fb0860 SDL-ryan-multiple-audio-device
BeOS audio now works in 1.3 branch.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Sun, 08 Oct 2006 01:39:01 +0000 |
parents | 29e83f221c62 |
children | 66fb40445587 |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
0 | 7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
0 | 9 |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
13 Lesser General Public License for more details. |
0 | 14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 18 |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
114
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
1403
376665398b25
Catch the C++ and Objective C sources too...
Sam Lantinga <slouken@libsdl.org>
parents:
1367
diff
changeset
|
22 #include "SDL_config.h" |
0 | 23 |
24 /* Allow access to the audio stream on BeOS */ | |
25 | |
26 #include <SoundPlayer.h> | |
27 | |
1367
e440d5c488c1
Fixes for BeOS and Solaris builds
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
28 #include "../../main/beos/SDL_BeApp.h" |
0 | 29 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1403
diff
changeset
|
30 extern "C" |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1403
diff
changeset
|
31 { |
0 | 32 |
33 #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
|
34 #include "../SDL_audio_c.h" |
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_sysaudio.h" |
1367
e440d5c488c1
Fixes for BeOS and Solaris builds
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
36 #include "../../thread/beos/SDL_systhread_c.h" |
0 | 37 #include "SDL_beaudio.h" |
38 | |
3819
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
39 } |
0 | 40 |
41 | |
3837
7c9663fb0860
BeOS audio now works in 1.3 branch.
Ryan C. Gordon <icculus@icculus.org>
parents:
3830
diff
changeset
|
42 static int BEOSAUDIO_Available(void) |
3819
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
43 { |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
44 return 1; /* Always available on BeOS. */ |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
45 } |
0 | 46 |
47 | |
3819
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
48 /* !!! FIXME: have the callback call the higher level to avoid code dupe. */ |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
49 /* The BeOS callback for handling the audio buffer */ |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
50 static void |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
51 FillSound(void *device, void *stream, size_t len, |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
52 const media_raw_audio_format & format) |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
53 { |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
54 SDL_AudioDevice *audio = (SDL_AudioDevice *) device; |
0 | 55 |
3819
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
56 /* Silence the buffer, since it's ours */ |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
57 SDL_memset(stream, audio->spec.silence, len); |
0 | 58 |
3819
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
59 /* Only do soemthing if audio is enabled */ |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
60 if (!audio->enabled) |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
61 return; |
0 | 62 |
3819
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
63 if (!audio->paused) { |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
64 if (audio->convert.needed) { |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
65 SDL_mutexP(audio->mixer_lock); |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
66 (*audio->spec.callback) (audio->spec.userdata, |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1403
diff
changeset
|
67 (Uint8 *) audio->convert.buf, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1403
diff
changeset
|
68 audio->convert.len); |
3819
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
69 SDL_mutexV(audio->mixer_lock); |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
70 SDL_ConvertAudio(&audio->convert); |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
71 SDL_memcpy(stream, audio->convert.buf, audio->convert.len_cvt); |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
72 } else { |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
73 SDL_mutexP(audio->mixer_lock); |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
74 (*audio->spec.callback) (audio->spec.userdata, |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
75 (Uint8 *) stream, len); |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
76 SDL_mutexV(audio->mixer_lock); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1403
diff
changeset
|
77 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1403
diff
changeset
|
78 } |
3819
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
79 } |
0 | 80 |
3819
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
81 static void |
3837
7c9663fb0860
BeOS audio now works in 1.3 branch.
Ryan C. Gordon <icculus@icculus.org>
parents:
3830
diff
changeset
|
82 BEOSAUDIO_CloseDevice(_THIS) |
3819
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
83 { |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
84 if (_this->hidden != NULL) { |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
85 if (_this->hidden->audio_obj) { |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
86 _this->hidden->audio_obj->Stop(); |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
87 delete _this->hidden->audio_obj; |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
88 _this->hidden->audio_obj = NULL; |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
89 } |
0 | 90 |
3819
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
91 delete _this->hidden; |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
92 _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:
1403
diff
changeset
|
93 } |
3819
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
94 } |
0 | 95 |
3819
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
96 static int |
3837
7c9663fb0860
BeOS audio now works in 1.3 branch.
Ryan C. Gordon <icculus@icculus.org>
parents:
3830
diff
changeset
|
97 BEOSAUDIO_OpenDevice(_THIS, const char *devname, int iscapture) |
3819
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
98 { |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
99 int valid_datatype = 0; |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
100 media_raw_audio_format format; |
3837
7c9663fb0860
BeOS audio now works in 1.3 branch.
Ryan C. Gordon <icculus@icculus.org>
parents:
3830
diff
changeset
|
101 SDL_AudioFormat test_format = SDL_FirstAudioFormat(_this->spec.format); |
1997
46319c67b3d7
Added int32 and float32 support (and some others!) to BeOS audio backend.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
102 |
3819
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
103 /* Initialize all variables that we clean on shutdown */ |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
104 _this->hidden = new SDL_PrivateAudioData; |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
105 if (_this->hidden == NULL) { |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
106 SDL_OutOfMemory(); |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
107 return 0; |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
108 } |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
109 SDL_memset(_this->hidden, 0, (sizeof *_this->hidden)); |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
110 |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
111 /* Parse the audio format and fill the Be raw audio format */ |
3830
29e83f221c62
Fixed some things to use SDL C runtime functions.
Ryan C. Gordon <icculus@icculus.org>
parents:
3819
diff
changeset
|
112 SDL_memset(&format, '\0', sizeof(media_raw_audio_format)); |
3819
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
113 format.byte_order = B_MEDIA_LITTLE_ENDIAN; |
3837
7c9663fb0860
BeOS audio now works in 1.3 branch.
Ryan C. Gordon <icculus@icculus.org>
parents:
3830
diff
changeset
|
114 format.frame_rate = (float) _this->spec.freq; |
7c9663fb0860
BeOS audio now works in 1.3 branch.
Ryan C. Gordon <icculus@icculus.org>
parents:
3830
diff
changeset
|
115 format.channel_count = _this->spec.channels; /* !!! FIXME: support > 2? */ |
3819
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
116 while ((!valid_datatype) && (test_format)) { |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
117 valid_datatype = 1; |
3837
7c9663fb0860
BeOS audio now works in 1.3 branch.
Ryan C. Gordon <icculus@icculus.org>
parents:
3830
diff
changeset
|
118 _this->spec.format = test_format; |
3819
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
119 switch (test_format) { |
2043 | 120 case AUDIO_S8: |
121 format.format = media_raw_audio_format::B_AUDIO_CHAR; | |
122 break; | |
1997
46319c67b3d7
Added int32 and float32 support (and some others!) to BeOS audio backend.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
123 |
2043 | 124 case AUDIO_U8: |
125 format.format = media_raw_audio_format::B_AUDIO_UCHAR; | |
126 break; | |
1997
46319c67b3d7
Added int32 and float32 support (and some others!) to BeOS audio backend.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
127 |
2043 | 128 case AUDIO_S16LSB: |
129 format.format = media_raw_audio_format::B_AUDIO_SHORT; | |
130 break; | |
1997
46319c67b3d7
Added int32 and float32 support (and some others!) to BeOS audio backend.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
131 |
2043 | 132 case AUDIO_S16MSB: |
133 format.format = media_raw_audio_format::B_AUDIO_SHORT; | |
134 format.byte_order = B_MEDIA_BIG_ENDIAN; | |
135 break; | |
1997
46319c67b3d7
Added int32 and float32 support (and some others!) to BeOS audio backend.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
136 |
2043 | 137 case AUDIO_S32LSB: |
138 format.format = media_raw_audio_format::B_AUDIO_INT; | |
139 break; | |
1997
46319c67b3d7
Added int32 and float32 support (and some others!) to BeOS audio backend.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
140 |
2043 | 141 case AUDIO_S32MSB: |
142 format.format = media_raw_audio_format::B_AUDIO_INT; | |
143 format.byte_order = B_MEDIA_BIG_ENDIAN; | |
144 break; | |
1997
46319c67b3d7
Added int32 and float32 support (and some others!) to BeOS audio backend.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
145 |
2043 | 146 case AUDIO_F32LSB: |
147 format.format = media_raw_audio_format::B_AUDIO_FLOAT; | |
148 break; | |
1997
46319c67b3d7
Added int32 and float32 support (and some others!) to BeOS audio backend.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
149 |
2043 | 150 case AUDIO_F32MSB: |
151 format.format = media_raw_audio_format::B_AUDIO_FLOAT; | |
152 format.byte_order = B_MEDIA_BIG_ENDIAN; | |
153 break; | |
1997
46319c67b3d7
Added int32 and float32 support (and some others!) to BeOS audio backend.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
154 |
2043 | 155 default: |
156 valid_datatype = 0; | |
157 test_format = SDL_NextAudioFormat(); | |
158 break; | |
1997
46319c67b3d7
Added int32 and float32 support (and some others!) to BeOS audio backend.
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
159 } |
3819
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
160 } |
0 | 161 |
3837
7c9663fb0860
BeOS audio now works in 1.3 branch.
Ryan C. Gordon <icculus@icculus.org>
parents:
3830
diff
changeset
|
162 format.buffer_size = _this->spec.samples; |
0 | 163 |
3819
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
164 if (!valid_datatype) { /* shouldn't happen, but just in case... */ |
3837
7c9663fb0860
BeOS audio now works in 1.3 branch.
Ryan C. Gordon <icculus@icculus.org>
parents:
3830
diff
changeset
|
165 BEOSAUDIO_CloseDevice(_this); |
3819
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
166 SDL_SetError("Unsupported audio format"); |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
167 return 0; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1403
diff
changeset
|
168 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1403
diff
changeset
|
169 |
3819
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
170 /* Calculate the final parameters for this audio specification */ |
3837
7c9663fb0860
BeOS audio now works in 1.3 branch.
Ryan C. Gordon <icculus@icculus.org>
parents:
3830
diff
changeset
|
171 SDL_CalculateAudioSpec(&_this->spec); |
3819
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
172 |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
173 /* Subscribe to the audio stream (creates a new thread) */ |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
174 sigset_t omask; |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
175 SDL_MaskSignals(&omask); |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
176 _this->hidden->audio_obj = new BSoundPlayer(&format, "SDL Audio", |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
177 FillSound, NULL, _this); |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
178 SDL_UnmaskSignals(&omask); |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
179 |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
180 if (_this->hidden->audio_obj->Start() == B_NO_ERROR) { |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
181 _this->hidden->audio_obj->SetHasData(true); |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
182 } else { |
3837
7c9663fb0860
BeOS audio now works in 1.3 branch.
Ryan C. Gordon <icculus@icculus.org>
parents:
3830
diff
changeset
|
183 BEOSAUDIO_CloseDevice(_this); |
3819
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
184 SDL_SetError("Unable to start Be audio"); |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
185 return 0; |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
186 } |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
187 |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
188 /* We're running! */ |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
189 return 1; |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
190 } |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
191 |
3837
7c9663fb0860
BeOS audio now works in 1.3 branch.
Ryan C. Gordon <icculus@icculus.org>
parents:
3830
diff
changeset
|
192 static void |
7c9663fb0860
BeOS audio now works in 1.3 branch.
Ryan C. Gordon <icculus@icculus.org>
parents:
3830
diff
changeset
|
193 BEOSAUDIO_Deinitialize(void) |
7c9663fb0860
BeOS audio now works in 1.3 branch.
Ryan C. Gordon <icculus@icculus.org>
parents:
3830
diff
changeset
|
194 { |
7c9663fb0860
BeOS audio now works in 1.3 branch.
Ryan C. Gordon <icculus@icculus.org>
parents:
3830
diff
changeset
|
195 SDL_QuitBeApp(); |
7c9663fb0860
BeOS audio now works in 1.3 branch.
Ryan C. Gordon <icculus@icculus.org>
parents:
3830
diff
changeset
|
196 } |
7c9663fb0860
BeOS audio now works in 1.3 branch.
Ryan C. Gordon <icculus@icculus.org>
parents:
3830
diff
changeset
|
197 |
3819
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
198 static int |
3837
7c9663fb0860
BeOS audio now works in 1.3 branch.
Ryan C. Gordon <icculus@icculus.org>
parents:
3830
diff
changeset
|
199 BEOSAUDIO_Init(SDL_AudioDriverImpl *impl) |
3819
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
200 { |
3837
7c9663fb0860
BeOS audio now works in 1.3 branch.
Ryan C. Gordon <icculus@icculus.org>
parents:
3830
diff
changeset
|
201 /* Initialize the Be Application, if it's not already started */ |
7c9663fb0860
BeOS audio now works in 1.3 branch.
Ryan C. Gordon <icculus@icculus.org>
parents:
3830
diff
changeset
|
202 if (SDL_InitBeApp() < 0) { |
7c9663fb0860
BeOS audio now works in 1.3 branch.
Ryan C. Gordon <icculus@icculus.org>
parents:
3830
diff
changeset
|
203 return 0; |
7c9663fb0860
BeOS audio now works in 1.3 branch.
Ryan C. Gordon <icculus@icculus.org>
parents:
3830
diff
changeset
|
204 } |
7c9663fb0860
BeOS audio now works in 1.3 branch.
Ryan C. Gordon <icculus@icculus.org>
parents:
3830
diff
changeset
|
205 |
3819
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
206 /* Set the function pointers */ |
3837
7c9663fb0860
BeOS audio now works in 1.3 branch.
Ryan C. Gordon <icculus@icculus.org>
parents:
3830
diff
changeset
|
207 impl->OpenDevice = BEOSAUDIO_OpenDevice; |
7c9663fb0860
BeOS audio now works in 1.3 branch.
Ryan C. Gordon <icculus@icculus.org>
parents:
3830
diff
changeset
|
208 impl->CloseDevice = BEOSAUDIO_CloseDevice; |
7c9663fb0860
BeOS audio now works in 1.3 branch.
Ryan C. Gordon <icculus@icculus.org>
parents:
3830
diff
changeset
|
209 impl->Deinitialize = BEOSAUDIO_Deinitialize; |
3819
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
210 impl->ProvidesOwnCallbackThread = 1; |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
211 impl->OnlyHasDefaultOutputDevice = 1; |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
212 |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
213 return 1; |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
214 } |
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
215 |
3837
7c9663fb0860
BeOS audio now works in 1.3 branch.
Ryan C. Gordon <icculus@icculus.org>
parents:
3830
diff
changeset
|
216 extern "C" { extern AudioBootStrap BEOSAUDIO_bootstrap; } |
7c9663fb0860
BeOS audio now works in 1.3 branch.
Ryan C. Gordon <icculus@icculus.org>
parents:
3830
diff
changeset
|
217 AudioBootStrap BEOSAUDIO_bootstrap = { |
3819
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
218 "baudio", "BeOS BSoundPlayer", |
3837
7c9663fb0860
BeOS audio now works in 1.3 branch.
Ryan C. Gordon <icculus@icculus.org>
parents:
3830
diff
changeset
|
219 BEOSAUDIO_Available, BEOSAUDIO_Init, 0 |
3819
b225d9820ee3
Updated a bunch of audio backends to 1.3 API (Dreamcast, OS/2, ALSA, and
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
220 }; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1403
diff
changeset
|
221 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1403
diff
changeset
|
222 /* vi: set ts=4 sw=4 expandtab: */ |
3837
7c9663fb0860
BeOS audio now works in 1.3 branch.
Ryan C. Gordon <icculus@icculus.org>
parents:
3830
diff
changeset
|
223 |