| 1 | package SDL2::audio { | ||
| 2 | use strictures 2; | ||
| 3 | use experimental 'signatures'; | ||
| 4 | use SDL2::Utils; | ||
| 5 | # | ||
| 6 | use SDL2::stdinc; | ||
| 7 | use SDL2::error; | ||
| 8 | use SDL2::endian; | ||
| 9 | use SDL2::mutex; | ||
| 10 | use SDL2::thread; | ||
| 11 | use SDL2::rwops; | ||
| 12 | # | ||
| 13 | ffi->type( 'uint16' => 'SDL_AudioFormat' ); | ||
| 14 | define audio => [ | ||
| 15 | [ SDL_AUDIO_MASK_BITSIZE => 0xFF ], [ SDL_AUDIO_MASK_DATATYPE => ( 1 << 8 ) ], | ||
| 16 | [ SDL_AUDIO_MASK_ENDIAN => ( 1 << 12 ) ], [ SDL_AUDIO_MASK_SIGNED => ( 1 << 15 ) ], | ||
| 17 | [ SDL_AUDIO_BITSIZE => sub ($x) { $x & SDL2::FFI::SDL_AUDIO_MASK_BITSIZE() } ], | ||
| 18 | [ SDL_AUDIO_ISFLOAT => sub ($x) { $x & SDL2::FFI::SDL_AUDIO_MASK_DATATYPE() } ], | ||
| 19 | [ SDL_AUDIO_ISBIGENDIAN => sub ($x) { $x & SDL2::FFI::SDL_AUDIO_MASK_ENDIAN() } ], | ||
| 20 | [ SDL_AUDIO_ISSIGNED => sub ($x) { $x & SDL2::FFI::SDL_AUDIO_MASK_SIGNED() } ], | ||
| 21 | [ SDL_AUDIO_ISINT => sub ($x) { !SDL2::FFI::DL_AUDIO_ISFLOAT($x) } ], | ||
| 22 | [ SDL_AUDIO_ISLITTLEENDIAN => sub ($x) { !SDL2::FFI::SDL_AUDIO_ISBIGENDIAN($x) } ], | ||
| 23 | [ SDL_AUDIO_ISUNSIGNED => sub ($x) { !SDL2::FFI::SDL_AUDIO_ISSIGNED($x) } ], | ||
| 24 | |||
| 25 | # audio format flags | ||
| 26 | [ AUDIO_U8 => 0x0008 ], [ AUDIO_S8 => 0x8008 ], [ AUDIO_U16LSB => 0x0010 ], | ||
| 27 | [ AUDIO_S16LSB => 0x8010 ], [ AUDIO_U16MSB => 0x1010 ], [ AUDIO_S16MSB => 0x9010 ], | ||
| 28 | [ AUDIO_U16 => sub () { SDL2::FFI::AUDIO_U16LSB() } ], | ||
| 29 | [ AUDIO_S16 => sub () { SDL2::FFI::AUDIO_S16LSB() } ], | ||
| 30 | |||
| 31 | # int32 support | ||
| 32 | [ AUDIO_S32LSB => 0x8020 ], [ AUDIO_S32MSB => 0x9020 ], | ||
| 33 | [ AUDIO_S32 => sub () { SDL2::FFI::AUDIO_S32LSB() } ], | ||
| 34 | |||
| 35 | # float32 support | ||
| 36 | [ AUDIO_F32LSB => 0x8120 ], [ AUDIO_F32MSB => 0x9120 ], | ||
| 37 | [ AUDIO_F32 => sub () { SDL2::FFI::AUDIO_F32LSB() } ], | ||
| 38 | |||
| 39 | # Native audio byte ordering | ||
| 40 | ( | ||
| 41 | SDL2::FFI::SDL_BYTEORDER() == SDL2::FFI::SDL_BIG_ENDIAN() ? ( | ||
| 42 | [ AUDIO_U16SYS => sub () { SDL2::FFI::AUDIO_U16MSB() } ], | ||
| 43 | [ AUDIO_S16SYS => sub () { SDL2::FFI::AUDIO_S16MSB() } ], | ||
| 44 | [ AUDIO_S32SYS => sub () { SDL2::FFI::AUDIO_S32MSB() } ], | ||
| 45 | [ AUDIO_F32SYS => sub () { SDL2::FFI::AUDIO_F32MSB() } ] | ||
| 46 | ) : ( | ||
| 47 | [ AUDIO_U16SYS => sub () { SDL2::FFI::AUDIO_U16LSB() } ], | ||
| 48 | [ AUDIO_S16SYS => sub () { SDL2::FFI::AUDIO_S16LSB() } ], | ||
| 49 | [ AUDIO_S32SYS => sub () { SDL2::FFI::AUDIO_S32LSB() } ], | ||
| 50 | [ AUDIO_F32SYS => sub () { SDL2::FFI::AUDIO_F32LSB() } ], | ||
| 51 | ) | ||
| 52 | ), | ||
| 53 | |||
| 54 | # Allow change flags | ||
| 55 | [ SDL_AUDIO_ALLOW_FREQUENCY_CHANGE => sub () {0x00000001} ], | ||
| 56 | [ SDL_AUDIO_ALLOW_FORMAT_CHANGE => sub () {0x00000002} ], | ||
| 57 | [ SDL_AUDIO_ALLOW_CHANNELS_CHANGE => sub () {0x00000004} ], | ||
| 58 | [ SDL_AUDIO_ALLOW_SAMPLES_CHANGE => sub () {0x00000008} ], | ||
| 59 | [ SDL_AUDIO_ALLOW_ANY_CHANGE => sub () { | ||
| 60 | ( SDL2::FFI::SDL_AUDIO_ALLOW_FREQUENCY_CHANGE() | ||
| 61 | | SDL2::FFI::SDL_AUDIO_ALLOW_FORMAT_CHANGE() | ||
| 62 | | SDL2::FFI::SDL_AUDIO_ALLOW_CHANNELS_CHANGE() | ||
| 63 | | SDL2::FFI::SDL_AUDIO_ALLOW_SAMPLES_CHANGE() ) | ||
| 64 | } | ||
| 65 | ] | ||
| 66 | ]; | ||
| 67 | |||
| 68 | # TODO: This is not how you accept a list of ints | ||
| 69 | ffi->type( '(opaque,opaque,int)->void' => 'SDL_AudioCallback' ); # void*, uint8*, int -> void | ||
| 70 | |||
| 71 | package SDL2::AudioSpec { | ||
| 72 | use strictures 2; | ||
| 73 | use experimental 'signatures'; | ||
| 74 | use SDL2::Utils; | ||
| 75 | has | ||
| 76 | freq => 'int', | ||
| 77 | format => 'SDL_AudioFormat', | ||
| 78 | channels => 'uint8', | ||
| 79 | silence => 'uint8', | ||
| 80 | samples => 'uint16', | ||
| 81 | padding => 'uint16', | ||
| 82 | size => 'uint32', | ||
| 83 | _callback => 'opaque', # 'SDL_AudioCallback', | ||
| 84 | userdata => 'opaque'; # void * | ||
| 85 | |||
| 86 | sub callback ( $s, $cb = () ) { | ||
| 87 | if ( defined $cb ) { | ||
| 88 | my $closure = ffi->closure($cb); | ||
| 89 | ffi->cast( 'opaque', 'SDL_AudioCallback', $s->_callback )->unsticky | ||
| 90 | if defined $s->_callback; | ||
| 91 | $closure->sticky; | ||
| 92 | return $s->_callback($closure); | ||
| 93 | } | ||
| 94 | ffi->cast( 'opaque', 'SDL_AudioCallback', $_[0]->_callback ); | ||
| 95 | } | ||
| 96 | }; | ||
| 97 | # | ||
| 98 | define audio => [ [ SDL_AUDIOCVT_MAX_FILTERS => 9 ] ]; | ||
| 99 | ffi->type( '(opaque,SDL_AudioFormat)->void' => 'SDL_AudioFilter' ) | ||
| 100 | ; # struct SDL_AudioCVT * cvt, SDL_AudioFormat format | ||
| 101 | |||
| 102 | package SDL2::AudioCVT { | ||
| 103 | use SDL2::Utils; | ||
| 104 | has | ||
| 105 | needed => 'int', | ||
| 106 | src_format => 'SDL_AudioFormat', # SDL_AudioFormat | ||
| 107 | dst_format => 'SDL_AudioFormat', # SDL_AudioFormat | ||
| 108 | rate_incr => 'double', | ||
| 109 | buf => 'opaque', # uint8 * | ||
| 110 | len => 'int', | ||
| 111 | len_cvt => 'int', | ||
| 112 | len_mult => 'int', | ||
| 113 | len_ratio => 'double', | ||
| 114 | filters => 'opaque', #SDL_AudioFilter[SDL_AUDIOCVT_MAX_FILTERS + 1]; | ||
| 115 | filter_index => 'int'; | ||
| 116 | |||
| 117 | # TODO: unwrap these opaque values with casts | ||
| 118 | }; | ||
| 119 | attach audio => { | ||
| 120 | SDL_GetNumAudioDrivers => [ [], 'int' ], | ||
| 121 | SDL_GetAudioDriver => [ ['int'], 'string' ], | ||
| 122 | SDL_AudioInit => [ ['string'], 'int' ], | ||
| 123 | SDL_AudioQuit => [ [] ], | ||
| 124 | SDL_GetCurrentAudioDriver => [ [], 'string' ], | ||
| 125 | SDL_OpenAudio => [ | ||
| 126 | [ 'SDL_AudioSpec', 'SDL_AudioSpec' ], | ||
| 127 | 'int' => sub ( $inner, $desired, $obtained = () ) { | ||
| 128 | deprecate <<'END'; | ||
| 129 | SDL_OpenAudio( ... ) remains for compatibility with SDL 1.2. The new, more | ||
| 130 | powerful, and preferred way to do this is SDL_OpenAudioDevice( ... ); | ||
| 131 | END | ||
| 132 | $inner->( $desired, $obtained ); | ||
| 133 | } | ||
| 134 | ] | ||
| 135 | }; | ||
| 136 | ffi->type( 'uint32' => 'SDL_AudioDeviceID' ); | ||
| 137 | attach audio => { | ||
| 138 | SDL_GetNumAudioDevices => [ ['int'], 'int' ], | ||
| 139 | SDL_GetAudioDeviceName => [ [ 'int', 'int' ], 'string' ], | ||
| 140 | SDL_GetAudioDeviceSpec => [ [ 'int', 'int', 'SDL_AudioSpec' ], 'int' ], | ||
| 141 | SDL_OpenAudioDevice => | ||
| 142 | [ [ 'string', 'int', 'SDL_AudioSpec', 'SDL_AudioSpec', 'int' ], 'SDL_AudioDeviceID' ] | ||
| 143 | }; | ||
| 144 | # | ||
| 145 | enum SDL_AudioStatus => [ [ SDL_AUDIO_STOPPED => 0 ], qw[SDL_AUDIO_PLAYING SDL_AUDIO_PAUSED] ]; | ||
| 146 | attach audio => { | ||
| 147 | SDL_GetAudioStatus => [ [], 'SDL_AudioStatus' ], | ||
| 148 | SDL_GetAudioDeviceStatus => [ ['SDL_AudioDeviceID'], 'SDL_AudioStatus' ], | ||
| 149 | SDL_PauseAudio => [ ['int'] ], | ||
| 150 | SDL_PauseAudioDevice => [ [ 'SDL_AudioDeviceID', 'int' ] ], | ||
| 151 | SDL_LoadWAV_RW => | ||
| 152 | [ [ 'SDL_RWops', 'int', 'SDL_AudioSpec', 'opaque*', 'uint32*' ], 'SDL_AudioSpec' ] | ||
| 153 | }; | ||
| 154 | define audio => [ | ||
| 155 | [ SDL_LoadWAV => sub ( $file, $spec, $audio_buf, $audio_len ) { | ||
| 156 | SDL2::FFI::SDL_LoadWAV_RW( SDL2::FFI::SDL_RWFromFile( $file, 'rb' ), | ||
| 157 | 1, $spec, $audio_buf, $audio_len ); | ||
| 158 | } | ||
| 159 | ] | ||
| 160 | ]; | ||
| 161 | attach audio => { | ||
| 162 | SDL_FreeWAV => [ ['uint8*'] ], | ||
| 163 | SDL_BuildAudioCVT => [ | ||
| 164 | [ 'SDL_AudioCVT', 'SDL_AudioFormat', 'uint8', 'int', | ||
| 165 | 'SDL_AudioFormat', 'uint8', 'int', | ||
| 166 | ], | ||
| 167 | 'int' | ||
| 168 | ], | ||
| 169 | SDL_ConvertAudio => [ ['SDL_AudioCVT'], 'int' ] | ||
| 170 | }; | ||
| 171 | |||
| 172 | package SDL2::AudioStream { | ||
| 173 | use SDL2::Utils; | ||
| 174 | our $TYPE = has(); | ||
| 175 | }; | ||
| 176 | attach audio => { | ||
| 177 | SDL_NewAudioStream => [ | ||
| 178 | [ 'SDL_AudioFormat', 'uint8', 'int', 'SDL_AudioFormat', 'uint8', 'int' ], | ||
| 179 | 'SDL_AudioStream', | ||
| 180 | ], | ||
| 181 | SDL_AudioStreamPut => [ [ 'SDL_AudioStream', 'opaque', 'int' ], 'int' ], | ||
| 182 | SDL_AudioStreamGet => [ [ 'SDL_AudioStream', 'opaque', 'int' ], 'int' ], | ||
| 183 | SDL_AudioStreamAvailable => [ ['SDL_AudioStream'], 'int' ], | ||
| 184 | SDL_AudioStreamFlush => [ ['SDL_AudioStream'], 'int' ], | ||
| 185 | SDL_AudioStreamClear => [ ['SDL_AudioStream'] ], | ||
| 186 | SDL_FreeAudioStream => [ ['SDL_AudioStream'] ] | ||
| 187 | }; | ||
| 188 | define audio => [ [ SDL_MIX_MAXVOLUME => 128 ] ]; | ||
| 189 | attach audio => { | ||
| 190 | SDL_MixAudio => [ [ 'uint8*', 'uint8*', 'uint32', 'int' ] ], | ||
| 191 | SDL_MixAudioFormat => [ [ 'uint8*', 'uint8*', 'SDL_AudioFormat', 'uint32', 'int' ] ], | ||
| 192 | SDL_QueueAudio => [ [ 'SDL_AudioDeviceID', 'opaque', 'uint32' ], 'int' ], | ||
| 193 | SDL_DequeueAudio => [ [ 'SDL_AudioDeviceID', 'opaque', 'uint32' ], 'uint32' ], | ||
| 194 | SDL_GetQueuedAudioSize => [ ['SDL_AudioDeviceID'], 'uint32' ], | ||
| 195 | SDL_ClearQueuedAudio => [ ['SDL_AudioDeviceID'] ], | ||
| 196 | SDL_LockAudio => [ [] ], | ||
| 197 | SDL_LockAudioDevice => [ ['SDL_AudioDeviceID'] ], | ||
| 198 | SDL_UnlockAudio => [ [] ], | ||
| 199 | SDL_UnlockAudioDevice => [ ['SDL_AudioDeviceID'] ], | ||
| 200 | SDL_CloseAudio => [ [] ], | ||
| 201 | SDL_CloseAudioDevice => [ ['SDL_AudioDeviceID'] ] | ||
| 202 | }; | ||
| 203 | |||
| 204 | =encoding utf-8 | ||
| 205 | |||
| 206 | =head1 NAME | ||
| 207 | |||
| 208 | SDL2::audio - SDL Audio Functions | ||
| 209 | |||
| 210 | =head1 SYNOPSIS | ||
| 211 | |||
| 212 | use SDL2::FFI qw[:atomic]; | ||
| 213 | SDL_assert( 1 == 1 ); | ||
| 214 | my $test = 'nope'; | ||
| 215 | SDL_assert( | ||
| 216 | sub { | ||
| 217 | warn 'testing'; | ||
| 218 | my $retval = $test eq "blah"; | ||
| 219 | $test = "blah"; | ||
| 220 | $retval; | ||
| 221 | } | ||
| 222 | ); | ||
| 223 | |||
| 224 | =head1 DESCRIPTION | ||
| 225 | |||
| 226 | Audio functions and data types. | ||
| 227 | |||
| 228 | =head1 Functions | ||
| 229 | |||
| 230 | These functions may be imported by name or with the C<:audio> tag. | ||
| 231 | |||
| 232 | =head2 <SDL_GetNumAudioDrivers( )> | ||
| 233 | |||
| 234 | Returns the number of built-in audio drivers. | ||
| 235 | |||
| 236 | =head2 C<SDL_GetAudioDriver( ... )> | ||
| 237 | |||
| 238 | Returns the audio driver at the given index. They are listed in the order they | ||
| 239 | are normally initialized by default. | ||
| 240 | |||
| 241 | for my $index (0 .. SDL_GetNumAudioDrivers() - 1) { | ||
| 242 | printf "[%d] %s\n", $index, SDL_GetAudioDriver($index); | ||
| 243 | } | ||
| 244 | |||
| 245 | Expected parameters include: | ||
| 246 | |||
| 247 | =over | ||
| 248 | |||
| 249 | =item C<index> - zero based index | ||
| 250 | |||
| 251 | =back | ||
| 252 | |||
| 253 | Returns the name as a string. | ||
| 254 | |||
| 255 | =head2 C<SDL_AudioInit( ... )> | ||
| 256 | |||
| 257 | Initialize a particular audio driver. | ||
| 258 | |||
| 259 | my $ok = SDL_AudioInit( 'disk' ); | ||
| 260 | |||
| 261 | This function is used internally, and should not be used unless you have a | ||
| 262 | specific need to specify the audio driver you want to use. You should normally | ||
| 263 | use C<SDL_Init( ... )> or C<SDL_InitSubSystem( ... )>. | ||
| 264 | |||
| 265 | Expected parameters include: | ||
| 266 | |||
| 267 | =over | ||
| 268 | |||
| 269 | =item C<name> - name of the particular audio driver | ||
| 270 | |||
| 271 | =back | ||
| 272 | |||
| 273 | Returns C<0> on success. Check C<SDL_GetError( )> for more information. | ||
| 274 | |||
| 275 | =head2 C<SDL_AudioQuit( )> | ||
| 276 | |||
| 277 | Closes the current audio driver. | ||
| 278 | |||
| 279 | SDL_AudioQuit( ); | ||
| 280 | |||
| 281 | This function is used internally, and should not be used unless you have a | ||
| 282 | specific need to specify the audio driver you want to use. You should normally | ||
| 283 | use C<SDL_Init( ... )> or C<SDL_InitSubSystem( ... )>. | ||
| 284 | |||
| 285 | =head2 C<SDL_GetCurrentAudioDriver( )> | ||
| 286 | |||
| 287 | Get the name of the current audio driver. | ||
| 288 | |||
| 289 | my $driver = SDL_GetCurrentAudioDriver( ); | ||
| 290 | |||
| 291 | The returned string points to internal static memory and thus never becomes | ||
| 292 | invalid, even if you quit the audio subsystem and initialize a new driver | ||
| 293 | (although such a case would return a different static string from another call | ||
| 294 | to this function, of course). As such, you should not modify or free the | ||
| 295 | returned string. | ||
| 296 | |||
| 297 | Returns the name of the current audio driver or NULL if no driver has been | ||
| 298 | initialized. | ||
| 299 | |||
| 300 | =head2 C<SDL_OpenAudio( ... )> | ||
| 301 | |||
| 302 | This function is a legacy means of opening the audio device. | ||
| 303 | |||
| 304 | This function remains for compatibility with SDL 1.2, but also because it's | ||
| 305 | slightly easier to use than the new functions in SDL 2.0. The new, more | ||
| 306 | powerful, and preferred way to do this is SDL_OpenAudioDevice(). | ||
| 307 | |||
| 308 | This function is roughly equivalent to: | ||
| 309 | |||
| 310 | SDL_OpenAudioDevice(undef, 0, $desired, $obtained, SDL_AUDIO_ALLOW_ANY_CHANGE); | ||
| 311 | |||
| 312 | With two notable exceptions: | ||
| 313 | |||
| 314 | =over | ||
| 315 | |||
| 316 | =item If C<obtained> is NULL, we use C<desired> (and allow no changes), which means desired will be modified to have the correct values for silence, etc, and SDL will convert any differences between your app's specific request and the hardware behind the scenes. | ||
| 317 | |||
| 318 | =item The return value is always success or failure, and not a device ID, which means you can only have one device open at a time with this function. | ||
| 319 | |||
| 320 | =back | ||
| 321 | |||
| 322 | Expected parameters include: | ||
| 323 | |||
| 324 | =over | ||
| 325 | |||
| 326 | =item C<desired> - an L<SDL2::AudioSpec> structure representing the desired output format. Please refer to the C<SDL_OpenAudioDevice( ... )> documentation for details on how to prepare this structure. | ||
| 327 | |||
| 328 | =item C<obtained> - an L<SDL2::AudioSpec> structure filled in with the actual parameters, or NULL. | ||
| 329 | |||
| 330 | =back | ||
| 331 | |||
| 332 | This function opens the audio device with the desired parameters, and returns | ||
| 333 | C<0> if successful, placing the actual hardware parameters in the structure | ||
| 334 | pointed to by C<obtained>. | ||
| 335 | |||
| 336 | If C<obtained> is NULL, the audio data passed to the callback function will be | ||
| 337 | guaranteed to be in the requested format, and will be automatically converted | ||
| 338 | to the actual hardware audio format if necessary. If C<obtained> is NULL, | ||
| 339 | C<desired> will have fields modified. | ||
| 340 | |||
| 341 | This function returns a negative error code on failure to open the audio device | ||
| 342 | or failure to set up the audio thread; call C<SDL_GetError( )> for more | ||
| 343 | information. | ||
| 344 | |||
| 345 | =head2 C<SDL_GetNumAudioDevices( ... )> | ||
| 346 | |||
| 347 | Get the number of built-in audio devices. | ||
| 348 | |||
| 349 | my $num = SDL_GetNumberAudioDevices( ); | ||
| 350 | |||
| 351 | This function is only valid after successfully initializing the audio | ||
| 352 | subsystem. | ||
| 353 | |||
| 354 | Note that audio capture support is not implemented as of SDL 2.0.4, so the | ||
| 355 | C<iscapture> parameter is for future expansion and should always be zero for | ||
| 356 | now. | ||
| 357 | |||
| 358 | This function will return C<-1> if an explicit list of devices can't be | ||
| 359 | determined. Returning C<-1> is not an error. For example, if SDL is set up to | ||
| 360 | talk to a remote audio server, it can't list every one available on the | ||
| 361 | Internet, but it will still allow a specific host to be specified in | ||
| 362 | C<SDL_OpenAudioDevice( ... )>. | ||
| 363 | |||
| 364 | In many common cases, when this function returns a value <= 0, it can still | ||
| 365 | successfully open the default device (NULL for first argument of | ||
| 366 | C<SDL_OpenAudioDevice( ... )>). | ||
| 367 | |||
| 368 | This function may trigger a complete redetect of available hardware. It should | ||
| 369 | not be called for each iteration of a loop, but rather once at the start of a | ||
| 370 | loop: | ||
| 371 | |||
| 372 | # Don't do this: | ||
| 373 | for (my $i = 0; $i < SDL_GetNumAudioDevices(0); $i++) { ... } | ||
| 374 | |||
| 375 | # do this instead: | ||
| 376 | my $count = SDL_GetNumAudioDevices(0); | ||
| 377 | for (my $i = 0; $i < $count; ++$i) { do_something_here(); } | ||
| 378 | |||
| 379 | Expected parameters include: | ||
| 380 | |||
| 381 | =over | ||
| 382 | |||
| 383 | =item C<iscapture> - zero to request playback devices, non-zero to request recording devices | ||
| 384 | |||
| 385 | =back | ||
| 386 | |||
| 387 | Returns the number of available devices exposed by the current driver or C<-1> | ||
| 388 | if an explicit list of devices can't be determined. A return value of C<-1> | ||
| 389 | does not necessarily mean an error condition. | ||
| 390 | |||
| 391 | =head2 C<SDL_GetAudioDeviceName( ... )> | ||
| 392 | |||
| 393 | Get the human-readable name of a specific audio device. | ||
| 394 | |||
| 395 | This function is only valid after successfully initializing the audio | ||
| 396 | subsystem. The values returned by this function reflect the latest call to | ||
| 397 | C<SDL_GetNumAudioDevices( ... )>; re-call that function to redetect available | ||
| 398 | hardware. | ||
| 399 | |||
| 400 | The string returned by this function is UTF-8 encoded, read-only, and managed | ||
| 401 | internally. You are not to free it. If you need to keep the string for any | ||
| 402 | length of time, you should make your own copy of it, as it will be invalid next | ||
| 403 | time any of several other SDL functions are called. | ||
| 404 | |||
| 405 | Expected parameters include: | ||
| 406 | |||
| 407 | =over | ||
| 408 | |||
| 409 | =item C<index> - the index of the audio device; valid values range from C<0> to C<SDL_GetNumAudioDevices( ) - 1> | ||
| 410 | |||
| 411 | =item C<iscapture> - non-zero to query the list of recording devices, zero to query the list of output devices. | ||
| 412 | |||
| 413 | =back | ||
| 414 | |||
| 415 | Returns the name of the audio device at the requested index, or NULL on error. | ||
| 416 | |||
| 417 | =head2 C<SDL_GetAudioDeviceSpec( ... )> | ||
| 418 | |||
| 419 | Get the preferred audio format of a specific audio device. | ||
| 420 | |||
| 421 | This function is only valid after a successfully initializing the audio | ||
| 422 | subsystem. The values returned by this function reflect the latest call to | ||
| 423 | C<SDL_GetNumAudioDevices( )>; re-call that function to redetect available | ||
| 424 | hardware. | ||
| 425 | |||
| 426 | C<spec> will be filled with the sample rate, sample format, and channel count. | ||
| 427 | All other values in the structure are filled with 0. When the supported struct | ||
| 428 | members are 0, SDL was unable to get the property from the backend. | ||
| 429 | |||
| 430 | Expected parameters include: | ||
| 431 | |||
| 432 | =over | ||
| 433 | |||
| 434 | =item C<index> - the index of the audio device; valid values range from C<0> to C<SDL_GetNumAudioDevices( ) - 1> | ||
| 435 | |||
| 436 | =item C<iscapture> - non-zero to query the list of recording devices, zero to query the list of output devices. | ||
| 437 | |||
| 438 | =item C<spec> - The L<SDL2::AudioSpec> to be initialized by this function. | ||
| 439 | |||
| 440 | =back | ||
| 441 | |||
| 442 | Returns C<0> on success, nonzero on error. | ||
| 443 | |||
| 444 | =head2 C<SDL_OpenAudioDevice( ... )> | ||
| 445 | |||
| 446 | Open a specific audio device. | ||
| 447 | |||
| 448 | C<SDL_OpenAudio( )>, unlike this function, always acts on device ID 1. As such, | ||
| 449 | this function will never return a 1 so as not to conflict with the legacy | ||
| 450 | function. | ||
| 451 | |||
| 452 | Please note that SDL 2.0 before 2.0.5 did not support recording; as such, this | ||
| 453 | function would fail if `iscapture` was not zero. Starting with SDL 2.0.5, | ||
| 454 | recording is implemented and this value can be non-zero. | ||
| 455 | |||
| 456 | Passing in a C<device> name of NULL requests the most reasonable default (and | ||
| 457 | is equivalent to what C<SDL_OpenAudio( )> does to choose a device). The | ||
| 458 | C<device> name is a UTF-8 string reported by C<SDL_GetAudioDeviceName( )>, but | ||
| 459 | some drivers allow arbitrary and driver-specific strings, such as a hostname/IP | ||
| 460 | address for a remote audio server, or a filename in the diskaudio driver. | ||
| 461 | |||
| 462 | When filling in the desired audio spec structure: | ||
| 463 | |||
| 464 | =over | ||
| 465 | |||
| 466 | =item - C<desired-E<gt>freq> should be the frequency in sample-frames-per-second (Hz). | ||
| 467 | |||
| 468 | =item - C<desired-E<gt>format> should be the audio format (`AUDIO_S16SYS`, etc). | ||
| 469 | |||
| 470 | =item - C<desired-E<gt>samples> is the desired size of the audio buffer, in | ||
| 471 | B<sample frames> (with stereo output, two samples--left and right--would | ||
| 472 | make a single sample frame). This number should be a power of two, and | ||
| 473 | may be adjusted by the audio driver to a value more suitable for the | ||
| 474 | hardware. Good values seem to range between 512 and 8096 inclusive, | ||
| 475 | depending on the application and CPU speed. Smaller values reduce | ||
| 476 | latency, but can lead to underflow if the application is doing heavy | ||
| 477 | processing and cannot fill the audio buffer in time. Note that the | ||
| 478 | number of sample frames is directly related to time by the following | ||
| 479 | formula: C<ms = (sampleframes*1000)/freq> | ||
| 480 | |||
| 481 | =item - C<desired-E<gt>size> is the size in B<bytes> of the audio buffer, and is calculated by C<SDL_OpenAudioDevice( )>. You don't initialize this. | ||
| 482 | |||
| 483 | =item - C<desired-E<gt>silence> is the value used to set the buffer to silence, and is calculated by C<SDL_OpenAudioDevice( )>. You don't initialize this. | ||
| 484 | |||
| 485 | =item - C<desired-E<gt>callback> should be set to a function that will be called when the audio device is ready for more data. It is passed a pointer to the audio buffer, and the length in bytes of the audio buffer. This function usually runs in a separate thread, and so you should protect data structures that it accesses by calling C<SDL_LockAudioDevice( )> and C<SDL_UnlockAudioDevice( )> in your code. Alternately, you may pass a NULL pointer here, and call C<SDL_QueueAudio( )> with some frequency, to queue more audio samples to be played (or for capture devices, call C<SDL_DequeueAudio( )> with some frequency, to obtain audio samples). | ||
| 486 | |||
| 487 | =item - C<desired-E<gt>userdata> is passed as the first parameter to your callback function. If you passed a NULL callback, this value is ignored. | ||
| 488 | |||
| 489 | =back | ||
| 490 | |||
| 491 | C<allowed_changes> can have the following flags OR'd together: | ||
| 492 | |||
| 493 | =over | ||
| 494 | |||
| 495 | =item - C<SDL_AUDIO_ALLOW_FREQUENCY_CHANGE> | ||
| 496 | |||
| 497 | =item - C<SDL_AUDIO_ALLOW_FORMAT_CHANGE> | ||
| 498 | |||
| 499 | =item - C<SDL_AUDIO_ALLOW_CHANNELS_CHANGE> | ||
| 500 | |||
| 501 | =item - C<SDL_AUDIO_ALLOW_ANY_CHANGE> | ||
| 502 | |||
| 503 | =back | ||
| 504 | |||
| 505 | These flags specify how SDL should behave when a device cannot offer a specific | ||
| 506 | feature. If the application requests a feature that the hardware doesn't offer, | ||
| 507 | SDL will always try to get the closest equivalent. | ||
| 508 | |||
| 509 | For example, if you ask for float32 audio format, but the sound card only | ||
| 510 | supports int16, SDL will set the hardware to int16. If you had set | ||
| 511 | C<SDL_AUDIO_ALLOW_FORMAT_CHANGE>, SDL will change the format in the C<obtained> | ||
| 512 | structure. If that flag was B<not> set, SDL will prepare to convert your | ||
| 513 | callback's float32 audio to int16 before feeding it to the hardware and will | ||
| 514 | keep the originally requested format in the C<obtained> structure. | ||
| 515 | |||
| 516 | If your application can only handle one specific data format, pass a zero for | ||
| 517 | C<allowed_changes> and let SDL transparently handle any differences. | ||
| 518 | |||
| 519 | An opened audio device starts out paused, and should be enabled for playing by | ||
| 520 | calling C<SDL_PauseAudioDevice($devid, 0)> when you are ready for your audio | ||
| 521 | callback function to be called. Since the audio driver may modify the requested | ||
| 522 | size of the audio buffer, you should allocate any local mixing buffers after | ||
| 523 | you open the audio device. | ||
| 524 | |||
| 525 | The audio callback runs in a separate thread in most cases; you can prevent | ||
| 526 | race conditions between your callback and other threads without fully pausing | ||
| 527 | playback with C<SDL_LockAudioDevice( )>. For more information about the | ||
| 528 | callback, see SDL_AudioSpec. | ||
| 529 | |||
| 530 | Expected parameters include: | ||
| 531 | |||
| 532 | =over | ||
| 533 | |||
| 534 | =item C<device> - a UTF-8 string reported by C<SDL_GetAudioDeviceName( ... )> or a driver-specific name as appropriate. NULL requests the most reasonable default device. | ||
| 535 | |||
| 536 | =item C<iscapture> - non-zero to specify a device should be opened for recording, not playback | ||
| 537 | |||
| 538 | =item C<desired> - an L<SDL2::AudioSpec> structure representing the desired output format; see C<SDL_OpenAudio( )> for more information | ||
| 539 | |||
| 540 | =item C<obtained> - an L<SDL2::AudioSpec> structure filled in with the actual output format; see C<SDL_OpenAudio( )> for more information | ||
| 541 | |||
| 542 | =item C<allowed_changes> - C<0>, or one or more flags OR'd together | ||
| 543 | |||
| 544 | =back | ||
| 545 | |||
| 546 | Returns a valid device ID that is > 0 on success or 0 on failure; call | ||
| 547 | C<SDL_GetError( )> for more information. | ||
| 548 | |||
| 549 | =head2 C<SDL_GetAudioStatus( )> | ||
| 550 | |||
| 551 | Get the current audio status. | ||
| 552 | |||
| 553 | Returns an L<< C<SDL_AudioStatus>|/C<SDL_AudioStatus> >>. | ||
| 554 | |||
| 555 | =head2 C<SDL_GetAudioDeviceStatus( ... )> | ||
| 556 | |||
| 557 | Get the current audio status of a particular audio device. | ||
| 558 | |||
| 559 | Expected parameters include: | ||
| 560 | |||
| 561 | =over | ||
| 562 | |||
| 563 | =item C<dev> - C<SDL_AudioDeviceID> of the device to be queried. | ||
| 564 | |||
| 565 | =back | ||
| 566 | |||
| 567 | Returns an L<< C<SDL_AudioStatus>|/C<SDL_AudioStatus> >>. | ||
| 568 | |||
| 569 | =head2 C<SDL_PauseAudio( ... )> | ||
| 570 | |||
| 571 | Pause and unpause audio callback processing. | ||
| 572 | |||
| 573 | This function should be called with a parameter of C<0> after opening the audio | ||
| 574 | device to start playing sound. This is so you can safely initialize data for | ||
| 575 | your callback function after opening the audio device. Silence will be written | ||
| 576 | to the audio device during the pause. | ||
| 577 | |||
| 578 | Expected parameters include: | ||
| 579 | |||
| 580 | =over | ||
| 581 | |||
| 582 | =item C<pause_on> - true to pause processing | ||
| 583 | |||
| 584 | =back | ||
| 585 | |||
| 586 | =head2 C<SDL_PauseAudioDevice( ... )> | ||
| 587 | |||
| 588 | Pause the audio callback processing of a particular device. | ||
| 589 | |||
| 590 | Expected parameters include: | ||
| 591 | |||
| 592 | =over | ||
| 593 | |||
| 594 | =item C<dev> - C<SDL_AudioDeviceID> of the device to be pause or unpaused. | ||
| 595 | |||
| 596 | =item C<pause_on> - true to pause processing | ||
| 597 | |||
| 598 | =back | ||
| 599 | |||
| 600 | =head2 C<SDL_LoadWAV_RW( ... )> | ||
| 601 | |||
| 602 | Load the audio data of a WAVE file into memory. | ||
| 603 | |||
| 604 | Loading a WAVE file requires C<src>, C<spec>, C<audio_buf> and C<audio_len> to | ||
| 605 | be valid pointers. The entire data portion of the file is then loaded into | ||
| 606 | memory and decoded if necessary. | ||
| 607 | |||
| 608 | If C<freesrc> is non-zero, the data source gets automatically closed and freed | ||
| 609 | before the function returns. | ||
| 610 | |||
| 611 | Supported formats are RIFF WAVE files with the formats PCM (8, 16, 24, and 32 | ||
| 612 | bits), IEEE Float (32 bits), Microsoft ADPCM and IMA ADPCM (4 bits), and A-law | ||
| 613 | and mu-law (8 bits). Other formats are currently unsupported and cause an | ||
| 614 | error. | ||
| 615 | |||
| 616 | If this function succeeds, the pointer returned by it is equal to C<spec> and | ||
| 617 | the pointer to the audio data allocated by the function is written to | ||
| 618 | C<audio_buf> and its length in bytes to C<audio_len>. The L<SDL2::AudioSpec> | ||
| 619 | members C<freq>, C<channels>, and C<format> are set to the values of the audio | ||
| 620 | data in the buffer. The C<samples> member is set to a sane default and all | ||
| 621 | others are set to zero. | ||
| 622 | |||
| 623 | It's necessary to use C<SDL_FreeWAV( )> to free the audio data returned in | ||
| 624 | C<audio_buf> when it is no longer used. | ||
| 625 | |||
| 626 | Because of the underspecification of the .WAV format, there are many | ||
| 627 | problematic files in the wild that cause issues with strict decoders. To | ||
| 628 | provide compatibility with these files, this decoder is lenient in regards to | ||
| 629 | the truncation of the file, the fact chunk, and the size of the RIFF chunk. The | ||
| 630 | hints C<SDL_HINT_WAVE_RIFF_CHUNK_SIZE>, C<SDL_HINT_WAVE_TRUNCATION>, and | ||
| 631 | C<SDL_HINT_WAVE_FACT_CHUNK> can be used to tune the behavior of the loading | ||
| 632 | process. | ||
| 633 | |||
| 634 | Any file that is invalid (due to truncation, corruption, or wrong values in the | ||
| 635 | headers), too big, or unsupported causes an error. Additionally, any critical | ||
| 636 | I/O error from the data source will terminate the loading process with an | ||
| 637 | error. The function returns NULL on error and in all cases (with the exception | ||
| 638 | of C<src> being NULL), an appropriate error message will be set. | ||
| 639 | |||
| 640 | It is required that the data source supports seeking. | ||
| 641 | |||
| 642 | Example: | ||
| 643 | |||
| 644 | SDL_LoadWAV_RW( SDL_RWFromFile('sample.wav', 'rb'), 1, $spec, $buf, $len ); | ||
| 645 | |||
| 646 | Note that C<SDL_LoadWAV( ... )> does this same thing for you, but in a less | ||
| 647 | messy way: | ||
| 648 | |||
| 649 | SDL_LoadWAV("sample.wav", $spec, $buf, $len); | ||
| 650 | |||
| 651 | Expected parameters include: | ||
| 652 | |||
| 653 | =over | ||
| 654 | |||
| 655 | =item C<src> - The data source for the WAVE data | ||
| 656 | |||
| 657 | =item C<freesrc> - If non-zero, SDL will _always_ free the data source | ||
| 658 | |||
| 659 | =item C<spec> - An SDL_AudioSpec that will be filled in with the wave file's format details | ||
| 660 | |||
| 661 | =item C<audio_buf> - A pointer filled with the audio data, allocated by the function. | ||
| 662 | |||
| 663 | =item C<audio_len> - A pointer filled with the length of the audio data buffer in bytes | ||
| 664 | |||
| 665 | =back | ||
| 666 | |||
| 667 | This function, if successfully called, returns C<spec>, which will be filled | ||
| 668 | with the audio data format of the wave source data. C<audio_buf> will be filled | ||
| 669 | with a pointer to an allocated buffer containing the audio data, and | ||
| 670 | C<audio_len> is filled with the length of that audio buffer in bytes. | ||
| 671 | |||
| 672 | This function returns NULL if the .WAV file cannot be opened, uses an unknown | ||
| 673 | data format, or is corrupt; call C<SDL_GetError( )> for more information. | ||
| 674 | |||
| 675 | When the application is done with the data returned in C<audio_buf>, it should | ||
| 676 | call C<SDL_FreeWAV( )> to dispose of it. | ||
| 677 | |||
| 678 | =head2 C<SDL_LoadWAV( ... )> | ||
| 679 | |||
| 680 | Loads a .WAV from a file. | ||
| 681 | |||
| 682 | SDL_LoadWAV("sample.wav", $spec, $buf, $len); | ||
| 683 | |||
| 684 | Expected parameters include: | ||
| 685 | |||
| 686 | =over | ||
| 687 | |||
| 688 | =item C<file> - A filename | ||
| 689 | |||
| 690 | =item C<spec> - An SDL_AudioSpec that will be filled in with the wave file's format details | ||
| 691 | |||
| 692 | =item C<audio_buf> - A pointer filled with the audio data, allocated by the function. | ||
| 693 | |||
| 694 | =item C<audio_len> - A pointer filled with the length of the audio data buffer in bytes | ||
| 695 | |||
| 696 | =back | ||
| 697 | |||
| 698 | This function is a compatibility convenience function that wraps L<< | ||
| 699 | C<SDL_LoadWAV_RW( ... )>|/C<SDL_LoadWAV_RW( ... )> >>. See that function for | ||
| 700 | return value information. | ||
| 701 | |||
| 702 | =head2 C<SDL_FreeWAV( ... )> | ||
| 703 | |||
| 704 | Free data previously allocated with C<SDL_LoadWAV( ... )> or C<SDL_LoadWAV_RW( | ||
| 705 | ... )>. | ||
| 706 | |||
| 707 | After a WAVE file has been opened with C<SDL_LoadWAV( ... )> or | ||
| 708 | C<SDL_LoadWAV_RW( ... )> its data can eventually be freed with C<SDL_FreeWAV( | ||
| 709 | ... )>. It is safe to call this function with a NULL pointer. | ||
| 710 | |||
| 711 | Expected parameters include: | ||
| 712 | |||
| 713 | =over | ||
| 714 | |||
| 715 | =item C<audio_buf> - a pointer to the buffer created by C<SDL_LoadWAV( ... )> or C<SDL_LoadWAV_RW( ... )> | ||
| 716 | |||
| 717 | =back | ||
| 718 | |||
| 719 | =head2 C<SDL_BuildAudioCVT( ... )> | ||
| 720 | |||
| 721 | Initialize an SDL_AudioCVT structure for conversion. | ||
| 722 | |||
| 723 | Before an SDL_AudioCVT structure can be used to convert audio data it must be | ||
| 724 | initialized with source and destination information. | ||
| 725 | |||
| 726 | This function will zero out every field of the SDL_AudioCVT, so it must be | ||
| 727 | called before the application fills in the final buffer information. | ||
| 728 | |||
| 729 | Once this function has returned successfully, and reported that a conversion is | ||
| 730 | necessary, the application fills in the rest of the fields in SDL_AudioCVT, now | ||
| 731 | that it knows how large a buffer it needs to allocate, and then can call | ||
| 732 | SDL_ConvertAudio() to complete the conversion. | ||
| 733 | |||
| 734 | Expected parameters include: | ||
| 735 | |||
| 736 | =over | ||
| 737 | |||
| 738 | =item C<cvt> - an SDL_AudioCVT structure filled in with audio conversion information | ||
| 739 | |||
| 740 | =item C<src_format> - the source format of the audio data; for more info see SDL_AudioFormat | ||
| 741 | |||
| 742 | =item C<src_channels> - the number of channels in the source | ||
| 743 | |||
| 744 | =item C<src_rate> - the frequency (sample-frames-per-second) of the source | ||
| 745 | |||
| 746 | =item C<dst_format> - the destination format of the audio data; for more info see SDL_AudioFormat | ||
| 747 | |||
| 748 | =item C<dst_channels> - the number of channels in the destination | ||
| 749 | |||
| 750 | =item C<dst_rate> - the frequency (sample-frames-per-second) of the destination | ||
| 751 | |||
| 752 | =back | ||
| 753 | |||
| 754 | Returns C<1> if the audio filter is prepared, C<0> if no conversion is needed, | ||
| 755 | or a negative error code on failure; call C<SDL_GetError( )> for more | ||
| 756 | information. | ||
| 757 | |||
| 758 | =head2 C<SDL_ConvertAudio( ... )> | ||
| 759 | |||
| 760 | Convert audio data to a desired audio format. | ||
| 761 | |||
| 762 | This function does the actual audio data conversion, after the application has | ||
| 763 | called C<SDL_BuildAudioCVT( ... )> to prepare the conversion information and | ||
| 764 | then filled in the buffer details. | ||
| 765 | |||
| 766 | Once the application has initialized the C<cvt> structure using | ||
| 767 | C<SDL_BuildAudioCVT( ... )>, allocated an audio buffer and filled it with audio | ||
| 768 | data in the source format, this function will convert the buffer, in-place, to | ||
| 769 | the desired format. | ||
| 770 | |||
| 771 | The data conversion may go through several passes; any given pass may possibly | ||
| 772 | temporarily increase the size of the data. For example, SDL might expand 16-bit | ||
| 773 | data to 32 bits before resampling to a lower frequency, shrinking the data size | ||
| 774 | after having grown it briefly. Since the supplied buffer will be both the | ||
| 775 | source and destination, converting as necessary in-place, the application must | ||
| 776 | allocate a buffer that will fully contain the data during its largest | ||
| 777 | conversion pass. After C<SDL_BuildAudioCVT( ... )> returns, the application | ||
| 778 | should set the C<$cvt-E<gt>len> field to the size, in bytes, of the source | ||
| 779 | data, and allocate a buffer that is C<cvt-E<gt>len * cvt-E<gt>len_mult> bytes | ||
| 780 | long for the C<buf> field. | ||
| 781 | |||
| 782 | The source data should be copied into this buffer before the call to | ||
| 783 | C<SDL_ConvertAudio( ... )>. Upon successful return, this buffer will contain | ||
| 784 | the converted audio, and C<cvt-E<gt>len_cvt> will be the size of the converted | ||
| 785 | data, in bytes. Any bytes in the buffer past C<cvt-E<gt>len_cvt> are undefined | ||
| 786 | once this function returns. | ||
| 787 | |||
| 788 | Expected parameters include: | ||
| 789 | |||
| 790 | =over | ||
| 791 | |||
| 792 | =item C<cvt> an L<SDL2::AudioCVT> structure that was previously set up by C<SDL_BuildAudioCVT( ... )>. | ||
| 793 | |||
| 794 | =back | ||
| 795 | |||
| 796 | Returns C<0> if the conversion was completed successfully or a negative error | ||
| 797 | code on failure; call C<SDL_GetError( )> for more information. | ||
| 798 | |||
| 799 | =head2 C<SDL_NewAudioStream( ... )> | ||
| 800 | |||
| 801 | Create a new audio stream. | ||
| 802 | |||
| 803 | Expected parameters include: | ||
| 804 | |||
| 805 | =over | ||
| 806 | |||
| 807 | =item C<src_format> - The format of the source audio | ||
| 808 | |||
| 809 | =item C<src_channels> - The number of channels of the source audio | ||
| 810 | |||
| 811 | =item C<src_rate> - The sampling rate of the source audio | ||
| 812 | |||
| 813 | =item C<dst_format> - The format of the desired audio output | ||
| 814 | |||
| 815 | =item C<dst_channels> - The number of channels of the desired audio output | ||
| 816 | |||
| 817 | =item C<dst_rate> - The sampling rate of the desired audio output | ||
| 818 | |||
| 819 | =back | ||
| 820 | |||
| 821 | Returns a L<SDL2::AudioStream> on success. | ||
| 822 | |||
| 823 | =head2 C<SDL_AudioStreamPut( ... )> | ||
| 824 | |||
| 825 | Add data to be converted/resampled to the stream. | ||
| 826 | |||
| 827 | Expected parameters include: | ||
| 828 | |||
| 829 | =over | ||
| 830 | |||
| 831 | =item C<stream> - The stream the audio data is being added to | ||
| 832 | |||
| 833 | =item C<buf> - A pointer to the audio data to add | ||
| 834 | |||
| 835 | =item C<len> - The number of bytes to write to the stream | ||
| 836 | |||
| 837 | =back | ||
| 838 | |||
| 839 | Returns C<0> on success, or C<-1> on error. | ||
| 840 | |||
| 841 | =head2 C<SDL_AudioStreamGet( ... )> | ||
| 842 | |||
| 843 | Get converted/resampled data from the stream | ||
| 844 | |||
| 845 | Expected parameters include: | ||
| 846 | |||
| 847 | =over | ||
| 848 | |||
| 849 | =item C<stream> - The stream the audio is being requested from | ||
| 850 | |||
| 851 | =item C<buf> - A buffer to fill with audio data | ||
| 852 | |||
| 853 | =item C<len> - The maximum number of bytes to fill | ||
| 854 | |||
| 855 | =back | ||
| 856 | |||
| 857 | Returns the number of bytes read from the stream, or C<-1> on error. | ||
| 858 | |||
| 859 | =head2 C<SDL_AudioStreamAvailable( ... )> | ||
| 860 | |||
| 861 | Get the number of converted/resampled bytes available. The stream may be | ||
| 862 | buffering data behind the scenes until it has enough to resample correctly, so | ||
| 863 | this number might be lower than what you expect, or even be zero. Add more data | ||
| 864 | or flush the stream if you need the data now. | ||
| 865 | |||
| 866 | Expected parameters include: | ||
| 867 | |||
| 868 | =over | ||
| 869 | |||
| 870 | =item C<stream> - The stream the audio is being requested from | ||
| 871 | |||
| 872 | =back | ||
| 873 | |||
| 874 | =head2 C<SDL_AudioStreamFlush( ... )> | ||
| 875 | |||
| 876 | Tell the stream that you're done sending data, and anything being buffered | ||
| 877 | should be converted/resampled and made available immediately. | ||
| 878 | |||
| 879 | It is legal to add more data to a stream after flushing, but there will be | ||
| 880 | audio gaps in the output. Generally this is intended to signal the end of | ||
| 881 | input, so the complete output becomes available. | ||
| 882 | |||
| 883 | Expected parameters include: | ||
| 884 | |||
| 885 | =over | ||
| 886 | |||
| 887 | =item C<stream> - The stream the audio is being flushed | ||
| 888 | |||
| 889 | =back | ||
| 890 | |||
| 891 | =head2 C<SDL_AudioStreamClear( ... )> | ||
| 892 | |||
| 893 | Clear any pending data in the stream without converting it. | ||
| 894 | |||
| 895 | Expected parameters include: | ||
| 896 | |||
| 897 | =over | ||
| 898 | |||
| 899 | =item C<stream> - The stream the audio is being cleared | ||
| 900 | |||
| 901 | =back | ||
| 902 | |||
| 903 | =head2 C<SDL_FreeAudioStream( ... )> | ||
| 904 | |||
| 905 | Free an audio stream. | ||
| 906 | |||
| 907 | Expected parameters include: | ||
| 908 | |||
| 909 | =over | ||
| 910 | |||
| 911 | =item C<stream> - The stream the audio is being freed | ||
| 912 | |||
| 913 | =back | ||
| 914 | |||
| 915 | =head2 C<SDL_MixAudio( ... )> | ||
| 916 | |||
| 917 | This function is a legacy means of mixing audio. | ||
| 918 | |||
| 919 | This function is equivalent to calling | ||
| 920 | |||
| 921 | SDL_MixAudioFormat( $dst, $src, $format, $len, $volume ); | ||
| 922 | |||
| 923 | where C<$format> is the obtained format of the audio device from the legacy | ||
| 924 | C<SDL_OpenAudio( ... )> function. | ||
| 925 | |||
| 926 | Expected parameters include: | ||
| 927 | |||
| 928 | =over | ||
| 929 | |||
| 930 | =item C<dst> - the destination for the mixed audio | ||
| 931 | |||
| 932 | =item C<src> - the source audio buffer to be mixed | ||
| 933 | |||
| 934 | =item C<len> - the length of the audio buffer in bytes | ||
| 935 | |||
| 936 | =item C<volume> - ranges from C<0> - C<128>, and should be set to C<SDL_MIX_MAXVOLUME> for full audio volume | ||
| 937 | |||
| 938 | =back | ||
| 939 | |||
| 940 | =head2 C<SDL_MixAudioFormat( ... )> | ||
| 941 | |||
| 942 | Mix audio data in a specified format. | ||
| 943 | |||
| 944 | This takes an audio buffer C<src> of C<len> bytes of C<format> data and mixes | ||
| 945 | it into C<dst>, performing addition, volume adjustment, and overflow clipping. | ||
| 946 | The buffer pointed to by C<dst> must also be C<len> bytes of C<format> data. | ||
| 947 | |||
| 948 | This is provided for convenience -- you can mix your own audio data. | ||
| 949 | |||
| 950 | Do not use this function for mixing together more than two streams of sample | ||
| 951 | data. The output from repeated application of this function may be distorted by | ||
| 952 | clipping, because there is no accumulator with greater range than the input | ||
| 953 | (not to mention this being an inefficient way of doing it). | ||
| 954 | |||
| 955 | It is a common misconception that this function is required to write audio data | ||
| 956 | to an output stream in an audio callback. While you can do that, | ||
| 957 | C<SDL_MixAudioFormat( ... )> is really only needed when you're mixing a single | ||
| 958 | audio stream with a volume adjustment. | ||
| 959 | |||
| 960 | Expected parameters include: | ||
| 961 | |||
| 962 | =over | ||
| 963 | |||
| 964 | =item C<dst> - the destination for the mixed audio | ||
| 965 | |||
| 966 | =item C<src> - the source audio buffer to be mixed | ||
| 967 | |||
| 968 | =item C<format> - the C<SDL_AudioFormat> structure representing the desired audio format | ||
| 969 | |||
| 970 | =item C<len> the length of the audio buffer in bytes | ||
| 971 | |||
| 972 | =item C<volume> ranges from C<0> - C<128>, and should be set to C<SDL_MIX_MAXVOLUME> for full audio volume | ||
| 973 | |||
| 974 | =back | ||
| 975 | |||
| 976 | =head2 C<SDL_QueueAudio( ... )> | ||
| 977 | |||
| 978 | Queue more audio on non-callback devices. | ||
| 979 | |||
| 980 | If you are looking to retrieve queued audio from a non-callback capture device, | ||
| 981 | you want C<SDL_DequeueAudio( ... )> instead. C<SDL_QueueAudio( ... )> will | ||
| 982 | return C<-1> to signify an error if you use it with capture devices. | ||
| 983 | |||
| 984 | SDL offers two ways to feed audio to the device: you can either supply a | ||
| 985 | callback that SDL triggers with some frequency to obtain more audio (pull | ||
| 986 | method), or you can supply no callback, and then SDL will expect you to supply | ||
| 987 | data at regular intervals (push method) with this function. | ||
| 988 | |||
| 989 | There are no limits on the amount of data you can queue, short of exhaustion of | ||
| 990 | address space. Queued data will drain to the device as necessary without | ||
| 991 | further intervention from you. If the device needs audio but there is not | ||
| 992 | enough queued, it will play silence to make up the difference. This means you | ||
| 993 | will have skips in your audio playback if you aren't routinely queueing | ||
| 994 | sufficient data. | ||
| 995 | |||
| 996 | This function copies the supplied data, so you are safe to free it when the | ||
| 997 | function returns. This function is thread-safe, but queueing to the same device | ||
| 998 | from two threads at once does not promise which buffer will be queued first. | ||
| 999 | |||
| 1000 | You may not queue audio on a device that is using an application-supplied | ||
| 1001 | callback; doing so returns an error. You have to use the audio callback or | ||
| 1002 | queue audio with this function, but not both. | ||
| 1003 | |||
| 1004 | You should not call C<SDL_LockAudio( ... )> on the device before queueing; SDL | ||
| 1005 | handles locking internally for this function. | ||
| 1006 | |||
| 1007 | Expected parameters include: | ||
| 1008 | |||
| 1009 | =over | ||
| 1010 | |||
| 1011 | =item C<dev> - the device ID to which we will queue audio | ||
| 1012 | |||
| 1013 | =item C<data> - the data to queue to the device for later playback | ||
| 1014 | |||
| 1015 | =item C<len> - the number of bytes (not samples!) to which C<data> points | ||
| 1016 | |||
| 1017 | =back | ||
| 1018 | |||
| 1019 | Returns C<0> on success or a negative error code on failure; call | ||
| 1020 | C<SDL_GetError( )> for more information. | ||
| 1021 | |||
| 1022 | =head2 C<SDL_DequeueAudio( ... )> | ||
| 1023 | |||
| 1024 | Dequeue more audio on non-callback devices. | ||
| 1025 | |||
| 1026 | If you are looking to queue audio for output on a non-callback playback device, | ||
| 1027 | you want C<SDL_QueueAudio( ... )> instead. C<SDL_DequeueAudio( ... )> will | ||
| 1028 | always return C<0> if you use it with playback devices. | ||
| 1029 | |||
| 1030 | SDL offers two ways to retrieve audio from a capture device: you can either | ||
| 1031 | supply a callback that SDL triggers with some frequency as the device records | ||
| 1032 | more audio data, (push method), or you can supply no callback, and then SDL | ||
| 1033 | will expect you to retrieve data at regular intervals (pull method) with this | ||
| 1034 | function. | ||
| 1035 | |||
| 1036 | There are no limits on the amount of data you can queue, short of exhaustion of | ||
| 1037 | address space. Data from the device will keep queuing as necessary without | ||
| 1038 | further intervention from you. This means you will eventually run out of memory | ||
| 1039 | if you aren't routinely dequeueing data. | ||
| 1040 | |||
| 1041 | Capture devices will not queue data when paused; if you are expecting to not | ||
| 1042 | need captured audio for some length of time, use SDL_PauseAudioDevice() to stop | ||
| 1043 | the capture device from queueing more data. This can be useful during, say, | ||
| 1044 | level loading times. When unpaused, capture devices will start queueing data | ||
| 1045 | from that point, having flushed any capturable data available while paused. | ||
| 1046 | |||
| 1047 | This function is thread-safe, but dequeueing from the same device from two | ||
| 1048 | threads at once does not promise which thread will dequeue data first. | ||
| 1049 | |||
| 1050 | You may not dequeue audio from a device that is using an application-supplied | ||
| 1051 | callback; doing so returns an error. You have to use the audio callback, or | ||
| 1052 | dequeue audio with this function, but not both. | ||
| 1053 | |||
| 1054 | You should not call C<SDL_LockAudio( ... )> on the device before dequeueing; | ||
| 1055 | SDL handles locking internally for this function. | ||
| 1056 | |||
| 1057 | Expected parameters include: | ||
| 1058 | |||
| 1059 | =over | ||
| 1060 | |||
| 1061 | =item C<dev> - the device ID from which we will dequeue audio | ||
| 1062 | |||
| 1063 | =item C<data> - a pointer into where audio data should be copied | ||
| 1064 | |||
| 1065 | =item C<len> - the number of bytes (not samples!) to which (data) points | ||
| 1066 | |||
| 1067 | =back | ||
| 1068 | |||
| 1069 | Returns the number of bytes dequeued, which could be less than requested; call | ||
| 1070 | C<SDL_GetError( )> for more information. | ||
| 1071 | |||
| 1072 | =head2 C<SDL_GetQueuedAudioSize( ... )> | ||
| 1073 | |||
| 1074 | Get the number of bytes of still-queued audio. | ||
| 1075 | |||
| 1076 | For playback devices: this is the number of bytes that have been queued for | ||
| 1077 | playback with C<SDL_QueueAudio( ... )>, but have not yet been sent to the | ||
| 1078 | hardware. | ||
| 1079 | |||
| 1080 | Once we've sent it to the hardware, this function can not decide the exact byte | ||
| 1081 | boundary of what has been played. It's possible that we just gave the hardware | ||
| 1082 | several kilobytes right before you called this function, but it hasn't played | ||
| 1083 | any of it yet, or maybe half of it, etc. | ||
| 1084 | |||
| 1085 | For capture devices, this is the number of bytes that have been captured by the | ||
| 1086 | device and are waiting for you to dequeue. This number may grow at any time, so | ||
| 1087 | this only informs of the lower-bound of available data. | ||
| 1088 | |||
| 1089 | You may not queue or dequeue audio on a device that is using an | ||
| 1090 | application-supplied callback; calling this function on such a device always | ||
| 1091 | returns 0. You have to use the audio callback or queue audio, but not both. | ||
| 1092 | |||
| 1093 | You should not call C<SDL_LockAudio( ... )> on the device before querying; SDL | ||
| 1094 | handles locking internally for this function. | ||
| 1095 | |||
| 1096 | Expected parameters include: | ||
| 1097 | |||
| 1098 | =over | ||
| 1099 | |||
| 1100 | =item C<dev> - the device ID of which we will query queued audio size | ||
| 1101 | |||
| 1102 | =back | ||
| 1103 | |||
| 1104 | Returns the number of bytes (not samples!) of queued audio. | ||
| 1105 | |||
| 1106 | =head2 C<SDL_ClearQueuedAudio( ... )> | ||
| 1107 | |||
| 1108 | Drop any queued audio data waiting to be sent to the hardware. | ||
| 1109 | |||
| 1110 | Immediately after this call, C<SDL_GetQueuedAudioSize( ... )> will return C<0>. | ||
| 1111 | For output devices, the hardware will start playing silence if more audio isn't | ||
| 1112 | queued. For capture devices, the hardware will start filling the empty queue | ||
| 1113 | with new data if the capture device isn't paused. | ||
| 1114 | |||
| 1115 | This will not prevent playback of queued audio that's already been sent to the | ||
| 1116 | hardware, as we can not undo that, so expect there to be some fraction of a | ||
| 1117 | second of audio that might still be heard. This can be useful if you want to, | ||
| 1118 | say, drop any pending music or any unprocessed microphone input during a level | ||
| 1119 | change in your game. | ||
| 1120 | |||
| 1121 | You may not queue or dequeue audio on a device that is using an | ||
| 1122 | application-supplied callback; calling this function on such a device always | ||
| 1123 | returns C<0>. You have to use the audio callback or queue audio, but not both. | ||
| 1124 | |||
| 1125 | You should not call C<SDL_LockAudio( ... )> on the device before clearing the | ||
| 1126 | queue; SDL handles locking internally for this function. | ||
| 1127 | |||
| 1128 | Expected parameters include: | ||
| 1129 | |||
| 1130 | =over | ||
| 1131 | |||
| 1132 | =item C<dev> - the device ID of which to clear the audio queue | ||
| 1133 | |||
| 1134 | =back | ||
| 1135 | |||
| 1136 | This function always succeeds and thus returns void. | ||
| 1137 | |||
| 1138 | =head2 C<SDL_LockAudio( )> | ||
| 1139 | |||
| 1140 | Protects the callback function. | ||
| 1141 | |||
| 1142 | During a C<SDL_LockAudio( )>/C<SDL_UnlockAudio( )> pair, you can be guaranteed | ||
| 1143 | that the callback function is not running. Do not call these from the callback | ||
| 1144 | function or you will cause deadlock. | ||
| 1145 | |||
| 1146 | =head2 C<SDL_LockAudioDevice( ... )> | ||
| 1147 | |||
| 1148 | Protects the callback function for a particular audio device. | ||
| 1149 | |||
| 1150 | During a C<SDL_LockAudioDevice( ... )>/C<SDL_UnlockAudioDevice( ... )> pair, | ||
| 1151 | you can be guaranteed that the callback function is not running. Do not call | ||
| 1152 | these from the callback function or you will cause deadlock. | ||
| 1153 | |||
| 1154 | Expected parameters include: | ||
| 1155 | |||
| 1156 | =over | ||
| 1157 | |||
| 1158 | =item C<dev> - the <SDL_AudioDeviceID> | ||
| 1159 | |||
| 1160 | =back | ||
| 1161 | |||
| 1162 | =head2 C<SDL_UnlockAudio( )> | ||
| 1163 | |||
| 1164 | Protects the callback function. | ||
| 1165 | |||
| 1166 | During a C<SDL_LockAudio( )>/C<SDL_UnlockAudio( )> pair, you can be guaranteed | ||
| 1167 | that the callback function is not running. Do not call these from the callback | ||
| 1168 | function or you will cause deadlock. | ||
| 1169 | |||
| 1170 | =head2 C<SDL_UnlockAudioDevice( ... )> | ||
| 1171 | |||
| 1172 | Protects the callback function for a particular audio device. | ||
| 1173 | |||
| 1174 | During a C<SDL_LockAudioDevice( ... )>/C<SDL_UnlockAudioDevice( ... )> pair, | ||
| 1175 | you can be guaranteed that the callback function is not running. Do not call | ||
| 1176 | these from the callback function or you will cause deadlock. | ||
| 1177 | |||
| 1178 | Expected parameters include: | ||
| 1179 | |||
| 1180 | =over | ||
| 1181 | |||
| 1182 | =item C<dev> - the <SDL_AudioDeviceID> | ||
| 1183 | |||
| 1184 | =back | ||
| 1185 | |||
| 1186 | =head2 C<SDL_CloseAudio( )> | ||
| 1187 | |||
| 1188 | This function is a legacy means of closing the audio device. | ||
| 1189 | |||
| 1190 | This function is equivalent to calling | ||
| 1191 | |||
| 1192 | SDL_CloseAudioDevice( 1 ); | ||
| 1193 | |||
| 1194 | and is only useful if you used the legacy C<SDL_OpenAudio( ... )> function. | ||
| 1195 | |||
| 1196 | =head2 C<SDL_CloseAudioDevice( ... )> | ||
| 1197 | |||
| 1198 | This function is a legacy means of closing a particular audio device and is | ||
| 1199 | only useful if you used the legacy C<SDL_OpenAudio( ... )> function. | ||
| 1200 | |||
| 1201 | Expected parameters include: | ||
| 1202 | |||
| 1203 | =over | ||
| 1204 | |||
| 1205 | =item C<dev> - the <SDL_AudioDeviceID> | ||
| 1206 | |||
| 1207 | =back | ||
| 1208 | |||
| 1209 | =head1 Defined Values and Enumumerations | ||
| 1210 | |||
| 1211 | Defines and enumerations listed here may be imported by name or with their | ||
| 1212 | given tags. | ||
| 1213 | |||
| 1214 | =head2 C<SDL_AudioFormat> | ||
| 1215 | |||
| 1216 | These are what the 16 bits in SDL_AudioFormat currently mean... (Unspecified | ||
| 1217 | bits are always zero). | ||
| 1218 | |||
| 1219 | ++-----------------------sample is signed if set | ||
| 1220 | || | ||
| 1221 | || ++-----------sample is bigendian if set | ||
| 1222 | || || | ||
| 1223 | || || ++---sample is float if set | ||
| 1224 | || || || | ||
| 1225 | || || || +---sample bit size---+ | ||
| 1226 | || || || | | | ||
| 1227 | 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 | ||
| 1228 | |||
| 1229 | =head2 Audio flags | ||
| 1230 | |||
| 1231 | These may be imported by name or with the C<:audio> tag. | ||
| 1232 | |||
| 1233 | =over | ||
| 1234 | |||
| 1235 | =item C<SDL_AUDIO_MASK_BITSIZE> | ||
| 1236 | |||
| 1237 | =item C<SDL_AUDIO_MASK_DATATYPE> | ||
| 1238 | |||
| 1239 | =item C<SDL_AUDIO_MASK_ENDIAN> | ||
| 1240 | |||
| 1241 | =item C<SDL_AUDIO_MASK_SIGNED> | ||
| 1242 | |||
| 1243 | =item C<SDL_AUDIO_BITSIZE( ... )> | ||
| 1244 | |||
| 1245 | =item C<SDL_AUDIO_ISFLOAT( ... )> | ||
| 1246 | |||
| 1247 | =item C<SDL_AUDIO_ISBIGENDIAN( ... )> | ||
| 1248 | |||
| 1249 | =item C<SDL_AUDIO_ISSIGNED( ... )> | ||
| 1250 | |||
| 1251 | =item C<SDL_AUDIO_ISINT( ... )> | ||
| 1252 | |||
| 1253 | =item C<SDL_AUDIO_ISLITTLEENDIAN( ... )> | ||
| 1254 | |||
| 1255 | =item C<SDL_AUDIO_ISUNSIGNED( ... )> | ||
| 1256 | |||
| 1257 | =back | ||
| 1258 | |||
| 1259 | =head2 Audio format flags | ||
| 1260 | |||
| 1261 | Defaults to LSB byte order. These may be imported with the C<:audio> tag. | ||
| 1262 | |||
| 1263 | =over | ||
| 1264 | |||
| 1265 | =item C<AUDIO_U8> - Unsigned 8-bit samples | ||
| 1266 | |||
| 1267 | =item C<AUDIO_S8> - Signed 8-bit samples | ||
| 1268 | |||
| 1269 | =item C<AUDIO_U16LSB> - Unsigned 16-bit samples | ||
| 1270 | |||
| 1271 | =item C<AUDIO_S16LSB> - Signed 16-bit samples | ||
| 1272 | |||
| 1273 | =item C<AUDIO_U16MSB> - As above, but big-endian byte order | ||
| 1274 | |||
| 1275 | =item C<AUDIO_S16MSB> - As above, but big-endian byte order | ||
| 1276 | |||
| 1277 | =item C<AUDIO_U16> - C<AUDIO_U16LSB> | ||
| 1278 | |||
| 1279 | =item C<AUDIO_S16> - C<AUDIO_S16LSB> | ||
| 1280 | |||
| 1281 | =back | ||
| 1282 | |||
| 1283 | =head2 C<int32> support | ||
| 1284 | |||
| 1285 | These may be imported with the C<:audio> tag. | ||
| 1286 | |||
| 1287 | =over | ||
| 1288 | |||
| 1289 | =item C<AUDIO_S32LSB> - 32-bit integer samples | ||
| 1290 | |||
| 1291 | =item C<AUDIO_S32MSB> - As above, but big-endian byte order | ||
| 1292 | |||
| 1293 | =item C<AUDIO_S32> - C<AUDIO_S32LSB> | ||
| 1294 | |||
| 1295 | =back | ||
| 1296 | |||
| 1297 | =head2 C<float32> support | ||
| 1298 | |||
| 1299 | These may be imported with the C<:audio> tag. | ||
| 1300 | |||
| 1301 | =over | ||
| 1302 | |||
| 1303 | =item C<AUDIO_F32LSB> - 32-bit floating point samples | ||
| 1304 | |||
| 1305 | =item C<AUDIO_F32MSB> - As above, but big-endian byte order | ||
| 1306 | |||
| 1307 | =item C<AUDIO_F32> - C<AUDIO_F32LSB> | ||
| 1308 | |||
| 1309 | =back | ||
| 1310 | |||
| 1311 | =head2 Native audio byte ordering | ||
| 1312 | |||
| 1313 | Values are based on endianness of system. These may be imported with the | ||
| 1314 | C<:audio> tag. | ||
| 1315 | |||
| 1316 | =over | ||
| 1317 | |||
| 1318 | =item C<AUDIO_U16SYS> | ||
| 1319 | |||
| 1320 | =item C<AUDIO_S16SYS> | ||
| 1321 | |||
| 1322 | =item C<AUDIO_S32SYS> | ||
| 1323 | |||
| 1324 | =item C<AUDIO_F32SYS> | ||
| 1325 | |||
| 1326 | =back | ||
| 1327 | |||
| 1328 | =head2 Allow change flags | ||
| 1329 | |||
| 1330 | Which audio format changes are allowed when opening a device. These may be | ||
| 1331 | imported with the C<:audio> tag. | ||
| 1332 | |||
| 1333 | =over | ||
| 1334 | |||
| 1335 | =item C<SDL_AUDIO_ALLOW_FREQUENCY_CHANGE> | ||
| 1336 | |||
| 1337 | =item C<SDL_AUDIO_ALLOW_FORMAT_CHANGE> | ||
| 1338 | |||
| 1339 | =item C<SDL_AUDIO_ALLOW_CHANNELS_CHANGE> | ||
| 1340 | |||
| 1341 | =item C<SDL_AUDIO_ALLOW_SAMPLES_CHANGE> | ||
| 1342 | |||
| 1343 | =item C<SDL_AUDIO_ALLOW_ANY_CHANGE> | ||
| 1344 | |||
| 1345 | =back | ||
| 1346 | |||
| 1347 | =head2 C<SDL_AudioCallback> | ||
| 1348 | |||
| 1349 | Callback called when the audio device needs more data. | ||
| 1350 | |||
| 1351 | Parameters you should expect: | ||
| 1352 | |||
| 1353 | =over | ||
| 1354 | |||
| 1355 | =item C<userdata> - an application-specific parameter saved in the L<SDL2::AudioSpec> structure | ||
| 1356 | |||
| 1357 | =item C<stream> - a pointer to the audio data buffer. | ||
| 1358 | |||
| 1359 | =item C<len> - the length of that buffer in bytes. | ||
| 1360 | |||
| 1361 | =back | ||
| 1362 | |||
| 1363 | Once the callback returns, the buffer will no longer be valid. Stereo samples | ||
| 1364 | are stored in a LRLRLR ordering. | ||
| 1365 | |||
| 1366 | You can choose to avoid callbacks and use C<SDL_QueueAudio( )> instead, if you | ||
| 1367 | like. Just open your audio device with a NULL callback. | ||
| 1368 | |||
| 1369 | =head2 C<SDL_AudioFilter> | ||
| 1370 | |||
| 1371 | Callback that feeds the audio device. | ||
| 1372 | |||
| 1373 | Parameters you should expect: | ||
| 1374 | |||
| 1375 | =over | ||
| 1376 | |||
| 1377 | =item C<cvt> - L<SDL2::AudioCVT> structure | ||
| 1378 | |||
| 1379 | =item C<format> - L<SDL_AudioFormat> value | ||
| 1380 | |||
| 1381 | =back | ||
| 1382 | |||
| 1383 | =head2 C<SDL_AUDIOCVT_MAX_FILTERS> | ||
| 1384 | |||
| 1385 | The maximum number of C<SDL_AudioFilter> functions in L<SDL2::AudioCVT> is | ||
| 1386 | currently limited to 9. The L<SDL2::AudioCVT>->filters array has 10 pointers, | ||
| 1387 | one of which is the terminating NULL pointer. | ||
| 1388 | |||
| 1389 | =head2 C<SDL_AudioDeviceID> | ||
| 1390 | |||
| 1391 | SDL Audio Device IDs. | ||
| 1392 | |||
| 1393 | A successful call to C<SDL_OpenAudio( ... )> is always device id 1, and legacy | ||
| 1394 | SDL audio APIs assume you want this device ID. C<SDL_OpenAudioDevice( ... )> | ||
| 1395 | calls always returns devices >= 2 on success. The legacy calls are good both | ||
| 1396 | for backwards compatibility and when you don't care about multiple, specific, | ||
| 1397 | or capture devices. | ||
| 1398 | |||
| 1399 | =head2 C<SDL_AudioStatus> | ||
| 1400 | |||
| 1401 | Get the current audio state. This enumeration may be imported with the | ||
| 1402 | C<:audioStatus> tag. | ||
| 1403 | |||
| 1404 | =over | ||
| 1405 | |||
| 1406 | =item C<SDL_AUDIO_STOPPED> | ||
| 1407 | |||
| 1408 | =item C<SDL_AUDIO_PLAYING> | ||
| 1409 | |||
| 1410 | =item C<SDL_AUDIO_PAUSED> | ||
| 1411 | |||
| 1412 | =back | ||
| 1413 | |||
| 1414 | =head2 C<SDL_MIX_MAXVOLUME> | ||
| 1415 | |||
| 1416 | Max audio volume. | ||
| 1417 | |||
| 1418 | =head1 LICENSE | ||
| 1419 | |||
| 1420 | Copyright (C) Sanko Robinson. | ||
| 1421 | |||
| 1422 | This library is free software; you can redistribute it and/or modify it under | ||
| 1423 | the terms found in the Artistic License 2. Other copyrights, terms, and | ||
| 1424 | conditions may apply to data transmitted through this module. | ||
| 1425 | |||
| 1426 | =head1 AUTHOR | ||
| 1427 | |||
| 1428 | Sanko Robinson E<lt>sanko@cpan.orgE<gt> | ||
| 1429 | |||
| 1430 | =begin stopwords | ||
| 1431 | |||
| 1432 | redetect iscapture diskaudio unpause unpaused underflow dequeueing capturable | ||
| 1433 | dequeue dequeueing underspecification dequeued | ||
| 1434 | |||
| 1435 | =end stopwords | ||
| 1436 | |||
| 1437 | =cut | ||
| 1438 | |||
| 1439 | }; | ||
| 1440 | 1; |