comparison SDL_sound.h @ 186:70561bf8d5fd

Updated and clarified some documentation.
author Ryan C. Gordon <icculus@icculus.org>
date Thu, 27 Dec 2001 23:05:32 +0000
parents 47cc2de2ae36
children e2cb8bfe8051
comparison
equal deleted inserted replaced
185:6bb68b3bdcf1 186:70561bf8d5fd
221 * SDL_Init() before calling this. Sound_Init() will attempt to call 221 * SDL_Init() before calling this. Sound_Init() will attempt to call
222 * SDL_Init(SDL_INIT_AUDIO), just in case. This is a safe behaviour, but it 222 * SDL_Init(SDL_INIT_AUDIO), just in case. This is a safe behaviour, but it
223 * may not configure SDL to your liking by itself. 223 * may not configure SDL to your liking by itself.
224 * 224 *
225 * @returns nonzero on success, zero on error. Specifics of the 225 * @returns nonzero on success, zero on error. Specifics of the
226 * error can be gleaned from Sound_GetLastError(). 226 * error can be gleaned from Sound_GetError().
227 */ 227 */
228 extern DECLSPEC int Sound_Init(void); 228 extern DECLSPEC int Sound_Init(void);
229 229
230 230
231 /** 231 /**
240 * 240 *
241 * You should call this BEFORE SDL_Quit(). This will NOT call SDL_Quit() 241 * You should call this BEFORE SDL_Quit(). This will NOT call SDL_Quit()
242 * for you! 242 * for you!
243 * 243 *
244 * @returns nonzero on success, zero on error. Specifics of the error 244 * @returns nonzero on success, zero on error. Specifics of the error
245 * can be gleaned from Sound_GetLastError(). If failure, state of 245 * can be gleaned from Sound_GetError(). If failure, state of
246 * SDL_sound is undefined, and probably badly screwed up. 246 * SDL_sound is undefined, and probably badly screwed up.
247 */ 247 */
248 extern DECLSPEC int Sound_Quit(void); 248 extern DECLSPEC int Sound_Quit(void);
249 249
250 250
308 * to claim the data for decoding. If none of the extensions match (or the 308 * to claim the data for decoding. If none of the extensions match (or the
309 * extension is NULL), then every decoder examines the data to determine if 309 * extension is NULL), then every decoder examines the data to determine if
310 * it can handle it, until one accepts it. In such a case your SDL_RWops will 310 * it can handle it, until one accepts it. In such a case your SDL_RWops will
311 * need to be capable of rewinding to the start of the stream. 311 * need to be capable of rewinding to the start of the stream.
312 * If no decoders can handle the data, a NULL value is returned, and a human 312 * If no decoders can handle the data, a NULL value is returned, and a human
313 * readable error message can be fetched from Sound_GetLastError(). 313 * readable error message can be fetched from Sound_GetError().
314 * Optionally, a desired audio format can be specified. If the incoming data 314 * Optionally, a desired audio format can be specified. If the incoming data
315 * is in a different format, SDL_sound will convert it to the desired format 315 * is in a different format, SDL_sound will convert it to the desired format
316 * on the fly. Note that this can be an expensive operation, so it may be 316 * on the fly. Note that this can be an expensive operation, so it may be
317 * wise to convert data before you need to play it back, if possible, or 317 * wise to convert data before you need to play it back, if possible, or
318 * make sure your data is initially in the format that you need it in. 318 * make sure your data is initially in the format that you need it in.
328 * can safely allocate, the more decoding can be done in one block, but the 328 * can safely allocate, the more decoding can be done in one block, but the
329 * more resources you have to use up, and the longer each decoding call will 329 * more resources you have to use up, and the longer each decoding call will
330 * take. Note that different data formats require more or less space to 330 * take. Note that different data formats require more or less space to
331 * store. This buffer can be resized via Sound_SetBufferSize() ... 331 * store. This buffer can be resized via Sound_SetBufferSize() ...
332 * The buffer size specified must be a multiple of the size of a single 332 * The buffer size specified must be a multiple of the size of a single
333 * sample (not to be confused with a single Sound_Sample). So, if you want 333 * sample point. So, if you want 16-bit, stereo samples, then your sample
334 * 16-bit, stereo samples, then your sample size is (2 channels * 16 bits), 334 * point size is (2 channels * 16 bits), or 32 bits per sample, which is four
335 * or 32 bits per sample, which is four bytes. In such a case, you could 335 * bytes. In such a case, you could specify 128 or 132 bytes for a buffer,
336 * specify 128 or 132 bytes for a buffer, but not 129, 130, or 131, although 336 * but not 129, 130, or 131 (although in reality, you'll want to specify a
337 * in reality, you'll want to specify a MUCH larger buffer. 337 * MUCH larger buffer).
338 * When you are done with this Sound_Sample pointer, you can dispose of it 338 * When you are done with this Sound_Sample pointer, you can dispose of it
339 * via Sound_FreeSample(). 339 * via Sound_FreeSample().
340 * You do not have to keep a reference to (rw) around. If this function 340 * You do not have to keep a reference to (rw) around. If this function
341 * suceeds, it stores (rw) internally (and disposes of it during the call 341 * suceeds, it stores (rw) internally (and disposes of it during the call
342 * to Sound_FreeSample()). If this function fails, it will dispose of the 342 * to Sound_FreeSample()). If this function fails, it will dispose of the
347 * Can usually be NULL. 347 * Can usually be NULL.
348 * @param desired Format to convert sound data into. Can usually be NULL, 348 * @param desired Format to convert sound data into. Can usually be NULL,
349 * if you don't need conversion. 349 * if you don't need conversion.
350 * @returns Sound_Sample pointer, which is used as a handle to several other 350 * @returns Sound_Sample pointer, which is used as a handle to several other
351 * SDL_sound APIs. NULL on error. If error, use 351 * SDL_sound APIs. NULL on error. If error, use
352 * Sound_GetLastError() to see what went wrong. 352 * Sound_GetError() to see what went wrong.
353 */ 353 */
354 extern DECLSPEC Sound_Sample *Sound_NewSample(SDL_RWops *rw, const char *ext, 354 extern DECLSPEC Sound_Sample *Sound_NewSample(SDL_RWops *rw, const char *ext,
355 Sound_AudioInfo *desired, 355 Sound_AudioInfo *desired,
356 Uint32 bufferSize); 356 Uint32 bufferSize);
357 357
367 * @param desired Format to convert sound data into. Can usually be NULL, 367 * @param desired Format to convert sound data into. Can usually be NULL,
368 * if you don't need conversion. 368 * if you don't need conversion.
369 * @param bufferSize size, in bytes, of initial read buffer. 369 * @param bufferSize size, in bytes, of initial read buffer.
370 * @returns Sound_Sample pointer, which is used as a handle to several other 370 * @returns Sound_Sample pointer, which is used as a handle to several other
371 * SDL_sound APIs. NULL on error. If error, use 371 * SDL_sound APIs. NULL on error. If error, use
372 * Sound_GetLastError() to see what went wrong. 372 * Sound_GetError() to see what went wrong.
373 */ 373 */
374 extern DECLSPEC Sound_Sample *Sound_NewSampleFromFile(const char *filename, 374 extern DECLSPEC Sound_Sample *Sound_NewSampleFromFile(const char *filename,
375 Sound_AudioInfo *desired, 375 Sound_AudioInfo *desired,
376 Uint32 bufferSize); 376 Uint32 bufferSize);
377 377
395 * buffer is truncated. If the buffer is growing, the contents of the new 395 * buffer is truncated. If the buffer is growing, the contents of the new
396 * space at the end is undefined until you decode more into it or initialize 396 * space at the end is undefined until you decode more into it or initialize
397 * it yourself. 397 * it yourself.
398 * 398 *
399 * The buffer size specified must be a multiple of the size of a single 399 * The buffer size specified must be a multiple of the size of a single
400 * sample (not to be confused with a single Sound_Sample). So, if you want 400 * sample point. So, if you want 16-bit, stereo samples, then your sample
401 * 16-bit, stereo samples, then your sample size is (2 channels * 16 bits), 401 * point size is (2 channels * 16 bits), or 32 bits per sample, which is four
402 * or 32 bits per sample, which is four bytes. In such a case, you could 402 * bytes. In such a case, you could specify 128 or 132 bytes for a buffer,
403 * specify 128 or 132 bytes for a buffer, but not 129, 130, or 131, although 403 * but not 129, 130, or 131 (although in reality, you'll want to specify a
404 * in reality, you'll want to specify a MUCH larger buffer. 404 * MUCH larger buffer).
405 * 405 *
406 * @param sample The Sound_Sample whose buffer to modify. 406 * @param sample The Sound_Sample whose buffer to modify.
407 * @param new_size The desired size, in bytes, of the new buffer. 407 * @param new_size The desired size, in bytes, of the new buffer.
408 * @returns non-zero if buffer size changed, zero on failure. 408 * @returns non-zero if buffer size changed, zero on failure.
409 */ 409 */
416 * return the number of decoded bytes. 416 * return the number of decoded bytes.
417 * If sample->buffer_size bytes could not be decoded, then please refer to 417 * If sample->buffer_size bytes could not be decoded, then please refer to
418 * sample->flags to determine if this was an End-of-stream or error condition. 418 * sample->flags to determine if this was an End-of-stream or error condition.
419 * 419 *
420 * @param sample Do more decoding to this Sound_Sample. 420 * @param sample Do more decoding to this Sound_Sample.
421 * @returns number of bytes decoded into sample->buffer. If it is less than 421 * @returns number of bytes decoded into sample->buffer. If it is less than
422 * sample->buffer_size, then you should check sample->flags to see 422 * sample->buffer_size, then you should check sample->flags to see
423 * what the current state of the sample is (EOF, error, read again). 423 * what the current state of the sample is (EOF, error, read again).
424 */ 424 */
425 extern DECLSPEC Uint32 Sound_Decode(Sound_Sample *sample); 425 extern DECLSPEC Uint32 Sound_Decode(Sound_Sample *sample);
426 426