PS2SDK
PS2 Homebrew Libraries
|
Go to the source code of this file.
Data Structures | |
struct | audsrv_fmt_t |
struct | audsrv_adpcm_t |
Macros | |
#define | AUDSRV_IRX 0x870884e |
#define | MIN_VOLUME 0 |
#define | MAX_VOLUME 100 |
#define | AUDSRV_ERR_NOERROR 0x0000 |
#define | AUDSRV_ERR_NOT_INITIALIZED 0x0001 |
#define | AUDSRV_ERR_RPC_FAILED 0x0002 |
#define | AUDSRV_ERR_FORMAT_NOT_SUPPORTED 0x0003 |
#define | AUDSRV_ERR_OUT_OF_MEMORY 0x0004 |
#define | AUDSRV_ERR_ARGS 0x0005 |
#define | AUDSRV_ERR_NO_DISC 0x0006 |
#define | AUDSRV_ERR_NO_MORE_CHANNELS 0x0007 |
#define | AUDSRV_ERR_FAILED_TO_LOAD_ADPCM 0x0010 |
#define | AUDSRV_ERR_FAILED_TO_CREATE_SEMA 0x0011 |
#define | audsrv_adpcm_set_volume(ch, vol) audsrv_adpcm_set_volume_and_pan(ch, vol, 0) |
#define | audsrv_play_adpcm(adpcm) audsrv_ch_play_adpcm(-1, adpcm) |
Typedefs | |
typedef struct audsrv_fmt_t | audsrv_fmt_t |
typedef struct audsrv_adpcm_t | audsrv_adpcm_t |
typedef int(* | audsrv_callback_t) (void *arg) |
audsrv EE-side RPC code
Definition in file audsrv.h.
struct audsrv_fmt_t |
struct audsrv_adpcm_t |
#define audsrv_adpcm_set_volume | ( | ch, | |
vol | |||
) | audsrv_adpcm_set_volume_and_pan(ch, vol, 0) |
#define audsrv_play_adpcm | ( | adpcm | ) | audsrv_ch_play_adpcm(-1, adpcm) |
typedef struct audsrv_fmt_t audsrv_fmt_t |
structure used to set new format
typedef struct audsrv_adpcm_t audsrv_adpcm_t |
adpcm sample definition
int audsrv_init | ( | ) |
Initializes audsrv library
Initializes audsrv library
Definition at line 328 of file audsrv_rpc.c.
References AUDSRV_ERR_NOERROR, AUDSRV_INIT, and set_error().
Referenced by rpc_command().
int audsrv_quit | ( | ) |
Shutdowns audsrv
Definition at line 143 of file audsrv_rpc.c.
References AUDSRV_ERR_NOERROR, and set_error().
Referenced by rpc_command().
int audsrv_set_format | ( | struct audsrv_fmt_t * | fmt | ) |
Configures audio stream
fmt | output specification structure |
This sets up audsrv to accept stream in this format and convert it to SPU2's native format if required. Note: it is possible to change the format at any point. You might want to stop audio prior to that, to prevent mismatched audio output.
Definition at line 159 of file audsrv_rpc.c.
References audsrv_fmt_t::bits, audsrv_fmt_t::channels, audsrv_fmt_t::freq, and set_error().
Referenced by rpc_command().
int audsrv_wait_audio | ( | int | buflen | ) |
Blocks until there is enough space to enqueue chunk
bytes | size of chunk requested to be enqueued (in bytes) |
Blocks until there are enough space to store the upcoming chunk in audsrv's internal ring buffer.
Blocks until there is enough space to enqueue chunk
buflen | size of chunk requested to be enqueued (in bytes) |
Blocks until there are enough space to store the upcoming chunk in audsrv's internal ring buffer.
Definition at line 178 of file audsrv_rpc.c.
References call_rpc_1().
Referenced by rpc_command().
int audsrv_set_volume | ( | int | vol | ) |
Sets output volume
vol | volume in percentage |
Sets output volume
vol | volume in SPU2 units [0 .. 0x3fff] |
Definition at line 183 of file audsrv_rpc.c.
References call_rpc_1(), MAX_VOLUME, and MIN_VOLUME.
Referenced by rpc_command().
int audsrv_play_audio | ( | const char * | buf, |
int | buflen | ||
) |
Uploads audio buffer to SPU
chunk | audio buffer |
bytes | size of chunk in bytes |
Plays an audio buffer; It will not interrupt a playing buffer, rather queue it up and play it as soon as possible without interfering with fluent streaming. The buffer and buflen are given in host format (i.e, 11025hz 8bit stereo.)
Uploads audio buffer to SPU
buf | audio chunk |
buflen | size of chunk in bytes |
Plays an audio buffer; It will not interrupt a playing buffer, rather queue it up and play it as soon as possible without interfering with fluent streaming. The buffer and buflen are given in host format (i.e, 11025hz 8bit stereo.)
Definition at line 254 of file audsrv_rpc.c.
References AUDSRV_ERR_NOERROR, and set_error().
Referenced by rpc_command().
int audsrv_stop_audio | ( | ) |
Stops audio from playing.
Stops all audio playing
Mutes output and stops accepting audio blocks; also, clears callbacks.
Definition at line 292 of file audsrv_rpc.c.
References call_rpc_1().
Referenced by rpc_command().
int audsrv_get_error | ( | ) |
Returns the last error audsrv raised
Definition at line 66 of file audsrv_rpc.c.
Referenced by audsrv_get_error_string().
const char * audsrv_get_error_string | ( | ) |
Translates audsrv_get_error() response to readable string
Definition at line 498 of file audsrv_rpc.c.
References AUDSRV_ERR_NOERROR, and audsrv_get_error().
int audsrv_play_cd | ( | int | track | ) |
Starts playing the request track
track | segment to play |
Plays CD audio track
track | segment to play [1 .. 99] |
Definition at line 197 of file audsrv_rpc.c.
References AUDSRV_PLAY_CD, and call_rpc_1().
Referenced by rpc_command().
int audsrv_stop_cd | ( | ) |
Stops CD from playing.
Stops CD play
Stops CD from being played; this has no effect on other music audsrv is currently playing
Definition at line 207 of file audsrv_rpc.c.
References call_rpc_1().
Referenced by audsrv_quit(), and rpc_command().
int audsrv_get_cdpos | ( | ) |
Returns the current playing sector
CDDA type discs have sector size of 2352 bytes. There are 75 such sectors per second.
Returns the current sector being played
Definition at line 214 of file audsrv_rpc.c.
References call_rpc_1().
Referenced by rpc_command().
int audsrv_get_trackpos | ( | ) |
Returns the current playing sector, relative to track
There are 75 sectors a second. To translate this position to mm:ss:ff use the following: mm = sector / (75*60) ss = (sector / 75) % 60 ff = sector % 75
where ff is the frame number, 1/75th of a second.
Returns the current sector being played, relative to first sector in track
Definition at line 219 of file audsrv_rpc.c.
References call_rpc_1().
Referenced by rpc_command().
int audsrv_get_numtracks | ( | ) |
Returns the number of tracks available on the CD in tray
Definition at line 224 of file audsrv_rpc.c.
References call_rpc_1().
Referenced by rpc_command().
int audsrv_get_track_offset | ( | int | track | ) |
Returns the first sector for the given track
track | track index, must be between 1 and the trackcount |
Definition at line 229 of file audsrv_rpc.c.
References call_rpc_1().
Referenced by rpc_command().
int audsrv_pause_cd | ( | ) |
Pauses CDDA playing
If CDDA is paused, no operation is taken
Definition at line 234 of file audsrv_rpc.c.
References call_rpc_1().
int audsrv_resume_cd | ( | ) |
Resumes CDDA playing
If CDDA was not paused, no operation is taken
Definition at line 239 of file audsrv_rpc.c.
References call_rpc_1().
int audsrv_play_sectors | ( | int | start, |
int | end | ||
) |
Starts playing at a specific sector
start | first sector to play |
end | last sector to play |
Definition at line 202 of file audsrv_rpc.c.
References call_rpc_2().
int audsrv_get_cd_status | ( | ) |
Returns the status of the CD tray (open, closed, seeking etc.)
Returns CD drive status
Definition at line 249 of file audsrv_rpc.c.
References call_rpc_1().
Referenced by rpc_command().
int audsrv_get_cd_type | ( | ) |
Returns the type of disc currently in tray
Returns the type of disc in drive
Definition at line 244 of file audsrv_rpc.c.
References call_rpc_1().
Referenced by rpc_command().
int audsrv_on_fillbuf | ( | int | amount, |
audsrv_callback_t | cb, | ||
void * | arg | ||
) |
Installs a callback function to be called when ringbuffer has enough space to transmit the request number of bytes.
bytes | request a callback when this amount of bytes is available |
cb | your callback |
arg | extra parameter to pass to callback function later |
Definition at line 531 of file audsrv_rpc.c.
References AUDSRV_ERR_NOERROR, and call_rpc_1().
int audsrv_adpcm_init | ( | ) |
Initializes adpcm unit of audsrv
Frees up all memory taken by samples, and stops all voices from being played. This can be called multiple times
Initializes adpcm unit of audsrv
Definition at line 394 of file audsrv_rpc.c.
References AUDSRV_INIT_ADPCM, and call_rpc_1().
Referenced by _start(), audsrv_quit(), and rpc_command().
int audsrv_adpcm_set_volume_and_pan | ( | int | ch, |
int | vol, | ||
int | pan | ||
) |
Sets output volume for the specified voice channel.
ch | Voice channel ID |
vol | volume in percentage (0-100) |
pan | left/right offset [-100 .. 0 .. 100] |
Definition at line 399 of file audsrv_rpc.c.
References call_rpc_3(), MAX_VOLUME, and MIN_VOLUME.
int audsrv_load_adpcm | ( | audsrv_adpcm_t * | adpcm, |
void * | buffer, | ||
int | size | ||
) |
Uploads a sample to SPU2 memory
adpcm | adpcm descriptor structure |
buffer | pointer to adpcm sample |
size | size of sample (including the header) |
Definition at line 430 of file audsrv_rpc.c.
References AUDSRV_ERR_NOERROR.
Referenced by rpc_command().
int audsrv_ch_play_adpcm | ( | int | ch, |
audsrv_adpcm_t * | adpcm | ||
) |
Plays an adpcm sample already uploaded with audsrv_load_adpcm()
ch | channel identifier. Specifies one of the 24 voice channel to play the ADPCM channel on. |
id | sample identifier, as specified in load() |
When ch is set to an invalid channel ID, the sample will be played in an unoccupied channel. If all 24 channels are used, then -AUDSRV_ERR_NO_MORE_CHANNELS is returned. When ch is set to a valid channel ID, -AUDSRV_ERR_NO_MORE_CHANNELS is returned if the channel is currently in use. Trying to play a sample which is unavailable will result in -AUDSRV_ERR_ARGS
Definition at line 481 of file audsrv_rpc.c.
References call_rpc_2().
Referenced by rpc_command().
int audsrv_is_adpcm_playing | ( | int | ch, |
audsrv_adpcm_t * | adpcm | ||
) |
Check if a sample is currently playing on the given channel
Definition at line 487 of file audsrv_rpc.c.
References call_rpc_2().
Referenced by rpc_command().
int audsrv_free_adpcm | ( | audsrv_adpcm_t * | adpcm | ) |
Remove an adpcm sample uploaded with audsrv_load_adpcm() from the list of loaded sounds
id | sample identifier, as specified in load() |
SPU memory is freed only when there are no sounds in the list that where loaded after the ones that have been freed
Definition at line 492 of file audsrv_rpc.c.
References call_rpc_1().
int audsrv_on_cdda_stop | ( | audsrv_callback_t | cb, |
void * | arg | ||
) |
Installs a callback function upon completion of a cdda track
cb | your callback |
arg | extra parameter to pass to callback function later |
Definition at line 524 of file audsrv_rpc.c.
References AUDSRV_ERR_NOERROR.
int audsrv_available | ( | ) |
Returns the number of bytes that can be queued
Returns the number of bytes that are available in the ring buffer. This is the total bytes that can be queued, without collision of the reading head with the writing head.
Returns the number of bytes that can be queued
Returns the number of bytes that are available in the ring buffer. This is the total bytes that can be queued, without collision of the reading head with the writing head.
Definition at line 549 of file audsrv_rpc.c.
References call_rpc_1().
Referenced by rpc_command().
int audsrv_queued | ( | ) |
Returns the number of bytes already in queue
Returns the number of bytes that are already in the ring buffer.
Definition at line 554 of file audsrv_rpc.c.
References call_rpc_1().
Referenced by rpc_command().