PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
audsrv.h File Reference
#include <types.h>
#include <irx.h>
+ Include dependency graph for audsrv.h:

Go to the source code of this file.

Macros

#define AUDSRV_INIT   0x0000
 
#define AUDSRV_QUIT   0x0001
 
#define AUDSRV_FORMAT_OK   0x0002
 
#define AUDSRV_SET_FORMAT   0x0003
 
#define AUDSRV_PLAY_AUDIO   0x0004
 
#define AUDSRV_WAIT_AUDIO   0x0005
 
#define AUDSRV_STOP_AUDIO   0x0006
 
#define AUDSRV_SET_VOLUME   0x0007
 
#define AUDSRV_SET_THRESHOLD   0x0008
 
#define AUDSRV_PLAY_CD   0x0009
 
#define AUDSRV_STOP_CD   0x000a
 
#define AUDSRV_GET_CDPOS   0x000b
 
#define AUDSRV_GET_TRACKPOS   0x000c
 
#define AUDSRV_GET_NUMTRACKS   0x000d
 
#define AUDSRV_GET_TRACKOFFSET   0x000e
 
#define AUDSRV_PAUSE_CD   0x0011
 
#define AUDSRV_RESUME_CD   0x0012
 
#define AUDSRV_PLAY_SECTORS   0x0013
 
#define AUDSRV_GET_CD_STATUS   0x0014
 
#define AUDSRV_GET_CD_TYPE   0x0015
 
#define AUDSRV_INIT_ADPCM   0x0016
 
#define AUDSRV_LOAD_ADPCM   0x0017
 
#define AUDSRV_PLAY_ADPCM   0x0018
 
#define AUDSRV_SET_ADPCM_VOL   0x0019
 
#define AUDSRV_FREE_ADPCM   0x001c
 
#define AUDSRV_IS_ADPCM_PLAYING   0x001d
 
#define AUDSRV_AVAILABLE   0x001a
 
#define AUDSRV_QUEUED   0x001b
 
#define AUDSRV_FILLBUF_CALLBACK   0x0001
 
#define AUDSRV_CDDA_CALLBACK   0x0002
 
#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_play_adpcm(id)   audsrv_ch_play_adpcm(-1, id)
 
#define audsrv_IMPORTS_start   DECLARE_IMPORT_TABLE(audsrv, 1, 4)
 
#define audsrv_IMPORTS_end   END_IMPORT_TABLE
 
#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_play_adpcm   I_audsrv_ch_play_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)
 

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)
 

Detailed Description

audsrv IOP server

Definition in file audsrv.h.

Macro Definition Documentation

◆ AUDSRV_INIT

#define AUDSRV_INIT   0x0000

intialization and destruction functions

Definition at line 22 of file audsrv.h.

◆ AUDSRV_QUIT

#define AUDSRV_QUIT   0x0001

Definition at line 23 of file audsrv.h.

◆ AUDSRV_FORMAT_OK

#define AUDSRV_FORMAT_OK   0x0002

audio control functions

Definition at line 26 of file audsrv.h.

◆ AUDSRV_SET_FORMAT

#define AUDSRV_SET_FORMAT   0x0003

Definition at line 27 of file audsrv.h.

◆ AUDSRV_PLAY_AUDIO

#define AUDSRV_PLAY_AUDIO   0x0004

Definition at line 28 of file audsrv.h.

◆ AUDSRV_WAIT_AUDIO

#define AUDSRV_WAIT_AUDIO   0x0005

Definition at line 29 of file audsrv.h.

◆ AUDSRV_STOP_AUDIO

#define AUDSRV_STOP_AUDIO   0x0006

Definition at line 30 of file audsrv.h.

◆ AUDSRV_SET_VOLUME

#define AUDSRV_SET_VOLUME   0x0007

Definition at line 31 of file audsrv.h.

◆ AUDSRV_SET_THRESHOLD

#define AUDSRV_SET_THRESHOLD   0x0008

Definition at line 32 of file audsrv.h.

◆ AUDSRV_PLAY_CD

#define AUDSRV_PLAY_CD   0x0009

cdrom functions

Definition at line 35 of file audsrv.h.

◆ AUDSRV_STOP_CD

#define AUDSRV_STOP_CD   0x000a

Definition at line 36 of file audsrv.h.

◆ AUDSRV_GET_CDPOS

#define AUDSRV_GET_CDPOS   0x000b

Definition at line 37 of file audsrv.h.

◆ AUDSRV_GET_TRACKPOS

#define AUDSRV_GET_TRACKPOS   0x000c

Definition at line 38 of file audsrv.h.

◆ AUDSRV_GET_NUMTRACKS

#define AUDSRV_GET_NUMTRACKS   0x000d

Definition at line 39 of file audsrv.h.

◆ AUDSRV_GET_TRACKOFFSET

#define AUDSRV_GET_TRACKOFFSET   0x000e

Definition at line 40 of file audsrv.h.

◆ AUDSRV_PAUSE_CD

#define AUDSRV_PAUSE_CD   0x0011

Definition at line 41 of file audsrv.h.

◆ AUDSRV_RESUME_CD

#define AUDSRV_RESUME_CD   0x0012

Definition at line 42 of file audsrv.h.

◆ AUDSRV_PLAY_SECTORS

#define AUDSRV_PLAY_SECTORS   0x0013

Definition at line 43 of file audsrv.h.

◆ AUDSRV_GET_CD_STATUS

#define AUDSRV_GET_CD_STATUS   0x0014

Definition at line 44 of file audsrv.h.

◆ AUDSRV_GET_CD_TYPE

#define AUDSRV_GET_CD_TYPE   0x0015

Definition at line 45 of file audsrv.h.

◆ AUDSRV_INIT_ADPCM

#define AUDSRV_INIT_ADPCM   0x0016

Definition at line 47 of file audsrv.h.

◆ AUDSRV_LOAD_ADPCM

#define AUDSRV_LOAD_ADPCM   0x0017

Definition at line 48 of file audsrv.h.

◆ AUDSRV_PLAY_ADPCM

#define AUDSRV_PLAY_ADPCM   0x0018

Definition at line 49 of file audsrv.h.

◆ AUDSRV_SET_ADPCM_VOL

#define AUDSRV_SET_ADPCM_VOL   0x0019

Definition at line 50 of file audsrv.h.

◆ AUDSRV_FREE_ADPCM

#define AUDSRV_FREE_ADPCM   0x001c

Definition at line 51 of file audsrv.h.

◆ AUDSRV_IS_ADPCM_PLAYING

#define AUDSRV_IS_ADPCM_PLAYING   0x001d

Definition at line 52 of file audsrv.h.

◆ AUDSRV_AVAILABLE

#define AUDSRV_AVAILABLE   0x001a

Definition at line 54 of file audsrv.h.

◆ AUDSRV_QUEUED

#define AUDSRV_QUEUED   0x001b

Definition at line 55 of file audsrv.h.

◆ AUDSRV_FILLBUF_CALLBACK

#define AUDSRV_FILLBUF_CALLBACK   0x0001

Definition at line 57 of file audsrv.h.

◆ AUDSRV_CDDA_CALLBACK

#define AUDSRV_CDDA_CALLBACK   0x0002

Definition at line 58 of file audsrv.h.

◆ AUDSRV_ERR_NOERROR

#define AUDSRV_ERR_NOERROR   0x0000

Definition at line 61 of file audsrv.h.

◆ AUDSRV_ERR_NOT_INITIALIZED

#define AUDSRV_ERR_NOT_INITIALIZED   0x0001

Definition at line 62 of file audsrv.h.

◆ AUDSRV_ERR_RPC_FAILED

#define AUDSRV_ERR_RPC_FAILED   0x0002

Definition at line 63 of file audsrv.h.

◆ AUDSRV_ERR_FORMAT_NOT_SUPPORTED

#define AUDSRV_ERR_FORMAT_NOT_SUPPORTED   0x0003

Definition at line 64 of file audsrv.h.

◆ AUDSRV_ERR_OUT_OF_MEMORY

#define AUDSRV_ERR_OUT_OF_MEMORY   0x0004

Definition at line 65 of file audsrv.h.

◆ AUDSRV_ERR_ARGS

#define AUDSRV_ERR_ARGS   0x0005

Definition at line 66 of file audsrv.h.

◆ AUDSRV_ERR_NO_DISC

#define AUDSRV_ERR_NO_DISC   0x0006

Definition at line 67 of file audsrv.h.

◆ AUDSRV_ERR_NO_MORE_CHANNELS

#define AUDSRV_ERR_NO_MORE_CHANNELS   0x0007

Definition at line 68 of file audsrv.h.

◆ audsrv_play_adpcm

#define audsrv_play_adpcm (   id)    audsrv_ch_play_adpcm(-1, id)

Definition at line 101 of file audsrv.h.

◆ audsrv_IMPORTS_start

#define audsrv_IMPORTS_start   DECLARE_IMPORT_TABLE(audsrv, 1, 4)

Definition at line 106 of file audsrv.h.

◆ audsrv_IMPORTS_end

#define audsrv_IMPORTS_end   END_IMPORT_TABLE

Definition at line 107 of file audsrv.h.

◆ I_audsrv_init

#define I_audsrv_init   DECLARE_IMPORT( 4, audsrv_init)

Definition at line 109 of file audsrv.h.

◆ I_audsrv_quit

#define I_audsrv_quit   DECLARE_IMPORT( 5, audsrv_quit)

Definition at line 110 of file audsrv.h.

◆ I_audsrv_format_ok

#define I_audsrv_format_ok   DECLARE_IMPORT( 6, audsrv_format_ok)

Definition at line 113 of file audsrv.h.

◆ I_audsrv_set_format

#define I_audsrv_set_format   DECLARE_IMPORT( 7, audsrv_set_format)

Definition at line 114 of file audsrv.h.

◆ I_audsrv_wait_audio

#define I_audsrv_wait_audio   DECLARE_IMPORT( 8, audsrv_wait_audio)

Definition at line 115 of file audsrv.h.

◆ I_audsrv_play_audio

#define I_audsrv_play_audio   DECLARE_IMPORT( 9, audsrv_play_audio)

Definition at line 116 of file audsrv.h.

◆ I_audsrv_stop_audio

#define I_audsrv_stop_audio   DECLARE_IMPORT(10, audsrv_stop_audio)

Definition at line 117 of file audsrv.h.

◆ I_audsrv_set_volume

#define I_audsrv_set_volume   DECLARE_IMPORT(11, audsrv_set_volume)

Definition at line 118 of file audsrv.h.

◆ I_audsrv_play_cd

#define I_audsrv_play_cd   DECLARE_IMPORT(12, audsrv_play_cd)

Definition at line 121 of file audsrv.h.

◆ I_audsrv_stop_cd

#define I_audsrv_stop_cd   DECLARE_IMPORT(13, audsrv_stop_cd)

Definition at line 122 of file audsrv.h.

◆ I_audsrv_set_threshold

#define I_audsrv_set_threshold   DECLARE_IMPORT(14, audsrv_set_threshold)

Definition at line 123 of file audsrv.h.

◆ I_audsrv_get_cdpos

#define I_audsrv_get_cdpos   DECLARE_IMPORT(15, audsrv_get_cdpos)

Definition at line 124 of file audsrv.h.

◆ I_audsrv_get_trackpos

#define I_audsrv_get_trackpos   DECLARE_IMPORT(16, audsrv_get_trackpos)

Definition at line 125 of file audsrv.h.

◆ I_audsrv_get_numtracks

#define I_audsrv_get_numtracks   DECLARE_IMPORT(17, audsrv_get_numtracks)

Definition at line 126 of file audsrv.h.

◆ I_audsrv_get_track_offset

#define I_audsrv_get_track_offset   DECLARE_IMPORT(18, audsrv_get_track_offset)

Definition at line 127 of file audsrv.h.

◆ I_audsrv_cd_pause

#define I_audsrv_cd_pause   DECLARE_IMPORT(19, audsrv_cd_pause)

Definition at line 128 of file audsrv.h.

◆ I_audsrv_cd_resume

#define I_audsrv_cd_resume   DECLARE_IMPORT(20, audsrv_cd_resume)

Definition at line 129 of file audsrv.h.

◆ I_audsrv_cd_play_sectors

#define I_audsrv_cd_play_sectors   DECLARE_IMPORT(21, audsrv_cd_play_sectors)

Definition at line 130 of file audsrv.h.

◆ I_audsrv_get_cd_status

#define I_audsrv_get_cd_status   DECLARE_IMPORT(22, audsrv_get_cd_status)

Definition at line 131 of file audsrv.h.

◆ I_audsrv_get_cd_type

#define I_audsrv_get_cd_type   DECLARE_IMPORT(23, audsrv_get_cd_type)

Definition at line 132 of file audsrv.h.

◆ I_audsrv_adpcm_init

#define I_audsrv_adpcm_init   DECLARE_IMPORT(24, audsrv_adpcm_init)

Definition at line 134 of file audsrv.h.

◆ I_audsrv_load_adpcm

#define I_audsrv_load_adpcm   DECLARE_IMPORT(25, audsrv_load_adpcm)

Definition at line 135 of file audsrv.h.

◆ I_audsrv_play_adpcm

#define I_audsrv_play_adpcm   I_audsrv_ch_play_adpcm

Definition at line 136 of file audsrv.h.

◆ I_audsrv_ch_play_adpcm

#define I_audsrv_ch_play_adpcm   DECLARE_IMPORT(26, audsrv_ch_play_adpcm)

Definition at line 137 of file audsrv.h.

◆ I_audsrv_adpcm_set_volume

#define I_audsrv_adpcm_set_volume   DECLARE_IMPORT(27, audsrv_adpcm_set_volume)

Definition at line 138 of file audsrv.h.

◆ I_audsrv_available

#define I_audsrv_available   DECLARE_IMPORT(28, audsrv_available)

Definition at line 139 of file audsrv.h.

◆ I_audsrv_queued

#define I_audsrv_queued   DECLARE_IMPORT(29, audsrv_queued)

Definition at line 140 of file audsrv.h.

Function Documentation

◆ audsrv_init()

int audsrv_init ( )

Initializes audsrv library

Returns
error code

Initializes audsrv library

Returns
0 on success

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.

◆ audsrv_quit()

int audsrv_quit ( )

Shutdowns audsrv

Returns
AUDSRV_ERR_NOERROR

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.

◆ audsrv_format_ok()

int audsrv_format_ok ( int  freq,
int  bits,
int  channels 
)

Checks if the format noted by frequency and depth is supported

Parameters
freqfrequency in hz
bitsbits per sample (8, 16)
channelschannels
Returns
positive on success, zero value on failure

Definition at line 156 of file audsrv.c.

References find_upsampler().

Referenced by audsrv_set_format(), and rpc_command().

◆ audsrv_set_format()

int audsrv_set_format ( int  freq,
int  bits,
int  channels 
)

Configures audio stream

Parameters
freqfrequency in hz
bitsbits per sample (8, 16)
channelsnumber of channels
Returns
0 on success, negative if configuration is not supported

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().

◆ audsrv_wait_audio()

int audsrv_wait_audio ( int  buflen)

Blocks until there is enough space to enqueue chunk

Parameters
bytessize of chunk requested to be enqueued (in bytes)
Returns
error code

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

Parameters
buflensize of chunk requested to be enqueued (in bytes)
Returns
error status code

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.

◆ audsrv_play_audio()

int audsrv_play_audio ( const char *  buf,
int  buflen 
)

Uploads audio buffer to SPU

Parameters
chunkaudio buffer
bytessize of chunk in bytes
Returns
positive number of bytes sent to processor or negative error status

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

Parameters
bufaudio chunk
buflensize of chunk in bytes
Returns
positive number of bytes sent to processor or negative error status

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.

◆ audsrv_stop_audio()

int audsrv_stop_audio ( )

Stops audio from playing.

Returns
status code

Stops all audio playing

Returns
0, always

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().

◆ audsrv_set_volume()

int audsrv_set_volume ( int  vol)

Sets output volume

Parameters
volvolume in percentage
Returns
error code

Sets output volume

Parameters
volvolume in SPU2 units [0 .. 0x3fff]
Returns
0 on success, negative otherwise

Definition at line 183 of file audsrv_rpc.c.

References AUDSRV_ERR_NOERROR, core1_volume, MAX_VOLUME, and update_volume().

◆ audsrv_available()

int audsrv_available ( )

Returns the number of bytes that can be queued

Returns
number of bytes left in the ring buffer

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
byte count

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().

◆ audsrv_queued()

int audsrv_queued ( )

Returns the number of bytes already in queue

Returns
byte count

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.

◆ audsrv_play_cd()

int audsrv_play_cd ( int  track)

Starts playing the request track

Parameters
tracksegment to play
Returns
status code

Plays CD audio track

Parameters
tracksegment to play [1 .. 99]
Returns
error status

Definition at line 197 of file audsrv_rpc.c.

References audsrv_cd_play_sectors(), audsrv_get_track_offset(), MAX_VOLUME, sceCdGetDiskType(), and toc.

◆ audsrv_stop_cd()

int audsrv_stop_cd ( )

Stops CD from playing.

Returns
status code

Stops CD play

Returns
0, always

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().

◆ audsrv_set_threshold()

int audsrv_set_threshold ( int  amount)

Definition at line 406 of file audsrv.c.

◆ audsrv_get_cdpos()

int audsrv_get_cdpos ( )

Returns the current playing sector

Returns
sector number

CDDA type discs have sector size of 2352 bytes. There are 75 such sectors per second.

Returns the current sector being played

Returns
sector number, or negative value on error

Definition at line 214 of file audsrv_rpc.c.

References cd_playing, and cdda_pos.

◆ audsrv_get_trackpos()

int audsrv_get_trackpos ( )

Returns the current playing sector, relative to track

Returns
sector number

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

Returns
sector number, or negative value on error

Definition at line 219 of file audsrv_rpc.c.

References cd_playing, cdda_play_start, and cdda_pos.

◆ audsrv_get_numtracks()

int audsrv_get_numtracks ( )

Returns the number of tracks available on the CD in tray

Returns
positive track count, or negative error status code

Definition at line 224 of file audsrv_rpc.c.

References toc.

◆ audsrv_get_track_offset()

int audsrv_get_track_offset ( int  track)

Returns the first sector for the given track

Parameters
tracktrack index, must be between 1 and the trackcount
Returns
sector number, or negative status code

Definition at line 229 of file audsrv_rpc.c.

References sceCdlLOCCD::minute, sceCdlLOCCD::second, sceCdlLOCCD::sector, and toc.

Referenced by audsrv_play_cd().

◆ audsrv_cd_pause()

int audsrv_cd_pause ( )

Pauses CD playing

Returns
status code

Definition at line 298 of file cdrom.c.

References AUDSRV_ERR_NOERROR, and cd_paused.

Referenced by rpc_command().

◆ audsrv_cd_resume()

int audsrv_cd_resume ( )

Resumes CD playing

Returns
status code

Definition at line 307 of file cdrom.c.

References AUDSRV_ERR_NOERROR, and cd_paused.

Referenced by rpc_command().

◆ audsrv_cd_play_sectors()

int audsrv_cd_play_sectors ( int  start,
int  end 
)

Starts playing cdda sectors from disc

Parameters
startfirst sector to play
endstop playing at this sector
Returns
status code

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().

◆ audsrv_get_cd_status()

int audsrv_get_cd_status ( )

Returns the status of the CD tray (open, closed, seeking etc.)

Returns
value as defined in libcdvd, negative on error

Returns CD drive status

Returns
status according to PS2 native values

Definition at line 249 of file audsrv_rpc.c.

References sceCdStatus().

◆ audsrv_get_cd_type()

int audsrv_get_cd_type ( )

Returns the type of disc currently in tray

Returns
value as defined in libcdvd, negative on error

Returns the type of disc in drive

Returns
disc type (according to native PS2 values) or -AUDSRV_ERR_NO_DISC

Definition at line 244 of file audsrv_rpc.c.

References sceCdGetDiskType().

◆ audsrv_adpcm_init()

int audsrv_adpcm_init ( )

Initializes adpcm unit of audsrv

Returns
zero on success, negative value on error

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

Returns
zero on success, negative value on error

Definition at line 394 of file audsrv_rpc.c.

References AUDSRV_ERR_NOERROR, and free_all_samples().

◆ audsrv_adpcm_set_volume()

int audsrv_adpcm_set_volume ( int  ch,
int  voll,
int  volr 
)

Sets output volume for the specified voice channel.

Parameters
chVoice channel ID
vollleft volume in SPU2 units [0 .. 0x3fff]
volrright volume in SPU2 units [0 .. 0x3fff]
Returns
0 on success, negative otherwise

Definition at line 347 of file adpcm.c.

References AUDSRV_ERR_NOERROR, and MAX_VOLUME.

◆ audsrv_load_adpcm()

void * audsrv_load_adpcm ( u32 *  buffer,
int  size,
int  id 
)

Uploads a sample to SPU2 memory

Parameters
bufferpointer to adpcm sample header
sizesize of sample in bytes
idsample identifier (to be later used in play())
Returns
pointer to local adpcm buffer

Definition at line 160 of file adpcm.c.

References adpcm_loaded(), alloc_new_sample(), and audsrv_read_adpcm_header().

◆ audsrv_ch_play_adpcm()

int audsrv_ch_play_adpcm ( int  ch,
u32  id 
)

Plays an adpcm sample already uploaded with audsrv_load_adpcm()

Parameters
chchannel 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.
idsample identifier, as specified in load()
Returns
channel identifier on success, negative value on error

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().

◆ audsrv_is_adpcm_playing()

int audsrv_is_adpcm_playing ( int  ch,
u32  id 
)

Definition at line 211 of file adpcm.c.

◆ free_sample()

int free_sample ( u32  id)

Remove an adpcm sample uploaded with audsrv_load_adpcm() from the list of loaded sounds

Parameters
idsample 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().