PS2SDK
PS2 Homebrew Libraries
|
Go to the source code of this file.
Functions | |
int | audsrv_init () |
int | audsrv_quit () |
int | audsrv_format_ok (int freq, int bits, int channels) |
int | audsrv_set_format (int freq, int bits, int channels) |
int | audsrv_wait_audio (int buflen) |
int | audsrv_play_audio (const char *buf, int buflen) |
int | audsrv_stop_audio () |
int | audsrv_set_volume (int vol) |
int | audsrv_available () |
int | audsrv_queued () |
int | audsrv_play_cd (int track) |
int | audsrv_stop_cd () |
int | audsrv_set_threshold (int amount) |
int | audsrv_get_cdpos () |
int | audsrv_get_trackpos () |
int | audsrv_get_numtracks () |
int | audsrv_get_track_offset (int track) |
int | audsrv_cd_pause () |
int | audsrv_cd_resume () |
int | audsrv_cd_play_sectors (int start, int end) |
int | audsrv_get_cd_status () |
int | audsrv_get_cd_type () |
int | audsrv_adpcm_init () |
int | audsrv_adpcm_set_volume (int ch, int voll, int volr) |
void * | audsrv_load_adpcm (u32 *buffer, int size, int id) |
int | audsrv_ch_play_adpcm (int ch, u32 id) |
int | audsrv_is_adpcm_playing (int ch, u32 id) |
int | free_sample (u32 id) |
audsrv IOP server
Definition in file audsrv.h.
#define AUDSRV_INIT 0x0000 |
#define audsrv_play_adpcm | ( | id | ) | audsrv_ch_play_adpcm(-1, id) |
#define audsrv_IMPORTS_start DECLARE_IMPORT_TABLE(audsrv, 1, 4) |
#define I_audsrv_init DECLARE_IMPORT( 4, audsrv_init) |
#define I_audsrv_quit DECLARE_IMPORT( 5, audsrv_quit) |
#define I_audsrv_format_ok DECLARE_IMPORT( 6, audsrv_format_ok) |
#define I_audsrv_set_format DECLARE_IMPORT( 7, audsrv_set_format) |
#define I_audsrv_wait_audio DECLARE_IMPORT( 8, audsrv_wait_audio) |
#define I_audsrv_play_audio DECLARE_IMPORT( 9, audsrv_play_audio) |
#define I_audsrv_stop_audio DECLARE_IMPORT(10, audsrv_stop_audio) |
#define I_audsrv_set_volume DECLARE_IMPORT(11, audsrv_set_volume) |
#define I_audsrv_play_cd DECLARE_IMPORT(12, audsrv_play_cd) |
#define I_audsrv_stop_cd DECLARE_IMPORT(13, audsrv_stop_cd) |
#define I_audsrv_set_threshold DECLARE_IMPORT(14, audsrv_set_threshold) |
#define I_audsrv_get_cdpos DECLARE_IMPORT(15, audsrv_get_cdpos) |
#define I_audsrv_get_trackpos DECLARE_IMPORT(16, audsrv_get_trackpos) |
#define I_audsrv_get_numtracks DECLARE_IMPORT(17, audsrv_get_numtracks) |
#define I_audsrv_get_track_offset DECLARE_IMPORT(18, audsrv_get_track_offset) |
#define I_audsrv_cd_pause DECLARE_IMPORT(19, audsrv_cd_pause) |
#define I_audsrv_cd_resume DECLARE_IMPORT(20, audsrv_cd_resume) |
#define I_audsrv_cd_play_sectors DECLARE_IMPORT(21, audsrv_cd_play_sectors) |
#define I_audsrv_get_cd_status DECLARE_IMPORT(22, audsrv_get_cd_status) |
#define I_audsrv_get_cd_type DECLARE_IMPORT(23, audsrv_get_cd_type) |
#define I_audsrv_adpcm_init DECLARE_IMPORT(24, audsrv_adpcm_init) |
#define I_audsrv_load_adpcm DECLARE_IMPORT(25, audsrv_load_adpcm) |
#define I_audsrv_ch_play_adpcm DECLARE_IMPORT(26, audsrv_ch_play_adpcm) |
#define I_audsrv_adpcm_set_volume DECLARE_IMPORT(27, audsrv_adpcm_set_volume) |
#define I_audsrv_available DECLARE_IMPORT(28, audsrv_available) |
#define I_audsrv_queued DECLARE_IMPORT(29, audsrv_queued) |
int audsrv_init | ( | ) |
Initializes audsrv library
Initializes audsrv library
Definition at line 328 of file audsrv_rpc.c.
References AUDSRV_ERR_NOERROR, audsrv_set_format(), audsrv_stop_audio(), create_thread(), initialized, play_thread(), play_tid, queue_sema, readpos, transfer_complete(), transfer_sema, and writepos.
int audsrv_quit | ( | ) |
Shutdowns audsrv
Definition at line 143 of file audsrv_rpc.c.
References audsrv_adpcm_init(), audsrv_stop_audio(), audsrv_stop_cd(), play_tid, queue_sema, and transfer_sema.
int audsrv_format_ok | ( | int | freq, |
int | bits, | ||
int | channels | ||
) |
Checks if the format noted by frequency and depth is supported
freq | frequency in hz |
bits | bits per sample (8, 16) |
channels | channels |
Definition at line 156 of file audsrv.c.
References find_upsampler().
Referenced by audsrv_set_format(), and rpc_command().
int audsrv_set_format | ( | int | freq, |
int | bits, | ||
int | channels | ||
) |
Configures audio stream
freq | frequency in hz |
bits | bits per sample (8, 16) |
channels | number of channels |
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 178 of file audsrv.c.
References AUDSRV_ERR_NOERROR, audsrv_format_ok(), core1_bits, core1_channels, core1_freq, core1_sample_shift, format_changed, readpos, ringbuf_size, and writepos.
Referenced by audsrv_init().
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 audsrv_available(), AUDSRV_ERR_NOERROR, queue_sema, and ringbuf_size.
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_available(), initialized, playing, readpos, ringbuf, ringbuf_size, update_volume(), and writepos.
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 AUDSRV_ERR_NOERROR, fillbuf_threshold, playing, and update_volume().
Referenced by audsrv_init(), and audsrv_quit().
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 AUDSRV_ERR_NOERROR, core1_volume, MAX_VOLUME, and update_volume().
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 readpos, ringbuf_size, and writepos.
Referenced by audsrv_play_audio(), audsrv_wait_audio(), and play_thread().
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 readpos, ringbuf_size, and writepos.
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_cd_play_sectors(), audsrv_get_track_offset(), MAX_VOLUME, sceCdGetDiskType(), and toc.
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 audsrv_stop_cd_stream(), and cdda_play_tid.
Referenced by audsrv_cd_play_sectors(), and cdda_procedure().
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 cd_playing, and cdda_pos.
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 cd_playing, cdda_play_start, and cdda_pos.
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 toc.
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 sceCdlLOCCD::minute, sceCdlLOCCD::second, sceCdlLOCCD::sector, and toc.
Referenced by audsrv_play_cd().
int audsrv_cd_pause | ( | ) |
Pauses CD playing
Definition at line 298 of file cdrom.c.
References AUDSRV_ERR_NOERROR, and cd_paused.
Referenced by rpc_command().
int audsrv_cd_resume | ( | ) |
Resumes CD playing
Definition at line 307 of file cdrom.c.
References AUDSRV_ERR_NOERROR, and cd_paused.
Referenced by rpc_command().
int audsrv_cd_play_sectors | ( | int | start, |
int | end | ||
) |
Starts playing cdda sectors from disc
start | first sector to play |
end | stop playing at this sector |
Starts the cdda feeding thread at the given sector. Any previously set up playback is stopped. If a callback was set, it will NOT be called, as the thread is stopped abnormally.
Definition at line 472 of file cdrom.c.
References AUDSRV_ERR_NOERROR, audsrv_stop_cd(), cd_playing, cdda_play_end, cdda_play_start, cdda_play_tid, cdda_pos, cdda_procedure(), and create_thread().
Referenced by audsrv_play_cd(), and rpc_command().
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 sceCdStatus().
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 sceCdGetDiskType().
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_ERR_NOERROR, and free_all_samples().
int audsrv_adpcm_set_volume | ( | int | ch, |
int | voll, | ||
int | volr | ||
) |
Sets output volume for the specified voice channel.
ch | Voice channel ID |
voll | left volume in SPU2 units [0 .. 0x3fff] |
volr | right volume in SPU2 units [0 .. 0x3fff] |
Definition at line 347 of file adpcm.c.
References AUDSRV_ERR_NOERROR, and MAX_VOLUME.
void * audsrv_load_adpcm | ( | u32 * | buffer, |
int | size, | ||
int | id | ||
) |
Uploads a sample to SPU2 memory
buffer | pointer to adpcm sample header |
size | size of sample in bytes |
id | sample identifier (to be later used in play()) |
Definition at line 160 of file adpcm.c.
References adpcm_loaded(), alloc_new_sample(), and audsrv_read_adpcm_header().
int audsrv_ch_play_adpcm | ( | int | ch, |
u32 | id | ||
) |
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. If set to an invalid channel ID, an unoccupied channel will be selected. |
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 277 of file adpcm.c.
References adpcm_loaded().
int free_sample | ( | u32 | id | ) |
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 84 of file adpcm.c.
References AUDSRV_ERR_NOERROR, CpuResumeIntr(), and CpuSuspendIntr().
Referenced by rpc_command().