KallistiOS  ##version##
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Functions
sound.h File Reference

Low-level sound support and memory management. More...

#include <sys/cdefs.h>
#include <arch/types.h>

Go to the source code of this file.

Functions

uint32 snd_mem_malloc (size_t size)
 Allocate memory in the SPU RAM pool. More...
 
void snd_mem_free (uint32 addr)
 Free a block of allocated memory in the SPU RAM pool. More...
 
uint32 snd_mem_available ()
 Get the size of the largest allocateable block in the SPU RAM pool. More...
 
int snd_mem_init (uint32 reserve)
 Reinitialize the SPU RAM pool. More...
 
void snd_mem_shutdown ()
 Shutdown the SPU RAM allocator. More...
 
int snd_init ()
 Initialize the sound system. More...
 
void snd_shutdown ()
 Shut down the sound system. More...
 
int snd_sh4_to_aica (void *packet, uint32 size)
 Copy a request packet to the AICA queue. More...
 
void snd_sh4_to_aica_start ()
 Begin processing AICA queue requests. More...
 
void snd_sh4_to_aica_stop ()
 Stop processing AICA queue requests. More...
 
int snd_aica_to_sh4 (void *packetout)
 Transfer a packet of data from the AICA's SH4 queue. More...
 
void snd_poll_resp ()
 Poll for a response from the AICA. More...
 

Detailed Description

Low-level sound support and memory management.

This file contains declarations for low-level sound operations and for SPU RAM pool memory management. Most of the time you'll be better off using the higher-level functionality in the sound effect support or streaming support, but this stuff can be very useful for some things.

Author
Dan Potter

Function Documentation

int snd_aica_to_sh4 ( void *  packetout)

Transfer a packet of data from the AICA's SH4 queue.

This function is used to retrieve a packet of data from the AICA back to the SH4. The buffer passed in should at least contain 1024 bytes of space to make sure any packet can fit.

Parameters
packetoutThe buffer to store the retrieved packet in.
Return values
-1On failure. Failure probably indicates the queue has been corrupted, and thus should be reinitialized.
0If no packets are available.
1On successful copy of one packet.
int snd_init ( )

Initialize the sound system.

This function reinitializes the whole sound system. It will not do anything unless the sound system has been shut down previously or has not been initialized yet. This will implicitly replace the program running on the AICA's ARM processor when it actually initializes anything. The default snd_stream_drv will be loaded if a new program is uploaded to the SPU.

uint32 snd_mem_available ( )

Get the size of the largest allocateable block in the SPU RAM pool.

This function returns the largest size that can be currently passed to snd_mem_malloc() and expected to not return failure. There may be more memory available in the pool, especially if multiple blocks have been allocated and freed, but calls to snd_mem_malloc() for larger blocks will return failure, since the memory is not available contiguously.

Returns
The size of the largest available block of memory in the SPU RAM pool.
void snd_mem_free ( uint32  addr)

Free a block of allocated memory in the SPU RAM pool.

This function frees memory previously allocated with snd_mem_malloc().

Parameters
addrThe location of the start of the block to free.
int snd_mem_init ( uint32  reserve)

Reinitialize the SPU RAM pool.

This function reinitializes the SPU RAM pool with the given base offset within the memory space. There is generally not a good reason to do this in your own code, but the functionality is there if needed.

Parameters
reserveThe amount of memory to reserve as a base.
Return values
0On success (no failure conditions defined).
uint32 snd_mem_malloc ( size_t  size)

Allocate memory in the SPU RAM pool.

This function acts as the memory allocator for the SPU RAM pool. It acts much like one would expect a malloc() function to act, although it does not return a pointer directly, but rather an offset in SPU RAM.

Parameters
sizeThe amount of memory to allocate, in bytes.
Returns
The location of the start of the block on success, or 0 on failure.
void snd_mem_shutdown ( )

Shutdown the SPU RAM allocator.

There is generally no reason to be calling this function in your own code, as doing so will cause problems if you try to allocate SPU memory without calling snd_mem_init() afterwards.

void snd_poll_resp ( )

Poll for a response from the AICA.

This function waits for the AICA to respond to a previously sent request. This function is not safe to call in an IRQ, as it does implicitly wait.

int snd_sh4_to_aica ( void *  packet,
uint32  size 
)

Copy a request packet to the AICA queue.

This function is to put in a low-level request using the built-in streaming sound driver.

Parameters
packetThe packet of data to copy.
sizeThe size of the packet, in 32-bit increments.
Return values
0On success (no error conditions defined).
void snd_sh4_to_aica_start ( )

Begin processing AICA queue requests.

This function begins processing of any queued requests in the AICA queue.

void snd_sh4_to_aica_stop ( )

Stop processing AICA queue requests.

This function stops the processing of any queued requests in the AICA queue.

void snd_shutdown ( )

Shut down the sound system.

This function shuts down the whole sound system, freeing memory and disabling the SPU in the process. There's not generally many good reasons for doing this in your own code.