|
PS2SDK
PS2 Homebrew Libraries
|
#include <stdio.h>#include <thbase.h>#include <thsemap.h>#include <loadcore.h>#include <sysmem.h>#include <intrman.h>#include <sifcmd.h>#include <libsd.h>#include <sysclib.h>#include <audsrv.h>#include "audsrv_internal.h"#include "common.h"#include "rpc_server.h"#include "rpc_client.h"#include "upsamplers.h"#include "hw.h"#include "spu.h"#include "debug_printf.h"
Include dependency graph for audsrv.c:Go to the source code of this file.
Macros | |
| #define | MODNAME "audsrv" |
| #define | VERSION "0.93" |
Functions | |
| IRX_ID (MODNAME, 1, 4) | |
| static u8 core1_buf[0x1000] | __attribute__ ((aligned(16))) |
| static void | play_thread (void *arg) |
| static int | transfer_complete (void *arg) |
| static void | update_volume () |
| int | audsrv_stop_audio () |
| int | audsrv_format_ok (int freq, int bits, int channels) |
| int | audsrv_set_format (int freq, int bits, int channels) |
| int | audsrv_init () |
| int | audsrv_available () |
| int | audsrv_queued () |
| int | audsrv_wait_audio (int buflen) |
| int | audsrv_play_audio (const char *buf, int buflen) |
| int | audsrv_set_volume (int vol) |
| int | audsrv_set_threshold (int amount) |
| int | audsrv_quit () |
| int | _start (int argc, char *argv[]) |
Variables | |
| static int | core1_volume = MAX_VOLUME |
| static int | core1_freq = 0 |
| static int | core1_bits = 0 |
| static int | core1_channels = 0 |
| static int | core1_sample_shift = 0 |
| static int | initialized = 0 |
| static int | playing = 0 |
| static char | ringbuf [20480] |
| static int | ringbuf_size = sizeof(ringbuf) |
| static int | readpos |
| static int | writepos |
| static int | play_tid = 0 |
| static int | queue_sema = 0 |
| static int | transfer_sema = 0 |
| static int | fillbuf_threshold = 0 |
| static int | format_changed = 0 |
| static short | rendered_left [512] |
| static short | rendered_right [512] |
| struct irx_export_table | _exp_audsrv |
audsrv IOP server
Definition in file audsrv.c.
|
static |
double buffer for streaming
SOURCE CHAIN TAG for DMA CHAIN MODE
Definition at line 19 of file netcnfif.c.
|
static |
Main playing thread
| arg | not used |
This is the main playing thread. It feeds the SPU with upsampled, demux'd audio data, from what has been queued beforehand. The stream is constructed as a ring buffer. This thread only ends with TerminateThread, and is usually asleep, waiting for SPU to complete playing the current wave. SPU plays 2048 bytes blocks, which yields that this thread wakes and sleeps 93.75 times a second
|
static |
|
static |
Apply volume changes, or keep mute if not playing
Definition at line 108 of file audsrv.c.
Referenced by audsrv_stop_audio().
| int audsrv_stop_audio | ( | ) |
Stops all audio playing
Mutes output and stops accepting audio blocks; also, clears callbacks.
Definition at line 139 of file audsrv.c.
References AUDSRV_ERR_NOERROR, call_rpc_1(), fillbuf_threshold, playing, and update_volume().
Referenced by audsrv_quit().
| 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().
| 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_format_ok().
| int audsrv_init | ( | ) |
Initializes audsrv library
Definition at line 219 of file audsrv.c.
References initialized.
| 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.
Definition at line 278 of file audsrv.c.
References call_rpc_1(), readpos, ringbuf_size, and writepos.
| 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 295 of file audsrv.c.
References call_rpc_1(), readpos, ringbuf_size, and writepos.
| int audsrv_wait_audio | ( | int | buflen | ) |
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 314 of file audsrv.c.
References call_rpc_1(), and ringbuf_size.
| int audsrv_play_audio | ( | const char * | buf, |
| int | buflen | ||
| ) |
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 344 of file audsrv.c.
References AUDSRV_ERR_NOERROR, and set_error().
| int audsrv_set_volume | ( | int | vol | ) |
Sets output volume
| vol | volume in SPU2 units [0 .. 0x3fff] |
Definition at line 393 of file audsrv.c.
References call_rpc_1(), MAX_VOLUME, and MIN_VOLUME.
| int audsrv_quit | ( | ) |
Shutdowns audsrv
Definition at line 512 of file audsrv.c.
References audsrv_adpcm_init(), audsrv_stop_audio(), and audsrv_stop_cd().
| int _start | ( | int | argc, |
| char * | argv[] | ||
| ) |
|
static |
|
static |
|
static |
|
static |
playing (not mute) status
Definition at line 55 of file audsrv.c.
Referenced by audsrv_stop_audio().
|
static |
size of ring buffer in bytes
Definition at line 62 of file audsrv.c.
Referenced by audsrv_available(), audsrv_queued(), and audsrv_wait_audio().
|
static |
reading head pointer
Definition at line 64 of file audsrv.c.
Referenced by audsrv_available(), and audsrv_queued().
|
static |
writing head pointer
Definition at line 66 of file audsrv.c.
Referenced by audsrv_available(), and audsrv_queued().
|
static |
|
static |
threshold to initiate a callback
Definition at line 75 of file audsrv.c.
Referenced by audsrv_stop_audio().
|
static |
| struct irx_export_table _exp_audsrv |
exports table