|
sdk-world v2026.11.05
PS2 SDK - world tier (copyleft-allowed, non-essential packages)
|
PCM playback for music and video audio. More...
Functions | |
| int | audio_stream_start (const audio_stream_format_t *format) |
| int | audio_stream_end (void) |
| int | audio_stream_queue_pcm (const void *pcm, int32_t byte_count) |
| int | audio_stream_wait_until_writable (int32_t byte_count, int32_t timeout_ms) |
| int | audio_stream_get_queued_bytes (void) |
| int | audio_stream_get_free_bytes (void) |
| int | audio_stream_stop_and_clear (void) |
| int | audio_stream_pause (void) |
| int | audio_stream_resume (void) |
| int | audio_stream_set_volume (int volume_percent) |
| int | audio_stream_set_low_data_callback (int32_t threshold_bytes, audio_low_data_fn callback, void *user) |
PCM playback for music and video audio.
One stream per context. Data is queued in the format given to audio_stream_start() and the library converts it to the 48 kHz stereo 16-bit layout the SPU2 plays. All byte counts are in the source format. A stream that runs out of data plays silence and continues when more arrives; that is not an error.
| int audio_stream_end | ( | void | ) |
Ends the stream and discards queued data. Threads waiting for space return -AUDIO_ERR_INTERRUPTED.
| int audio_stream_get_free_bytes | ( | void | ) |
Bytes audio_stream_queue_pcm() accepts right now, rounded down.
| int audio_stream_get_queued_bytes | ( | void | ) |
Bytes queued and not yet played, rounded up.
| int audio_stream_pause | ( | void | ) |
Silences the output and keeps the queued data. Queuing continues until the stream is full.
| int audio_stream_queue_pcm | ( | const void * | pcm, |
| int32_t | byte_count ) |
Adds PCM data to the stream. Copies the data before returning and never waits for space.
| pcm | Data in the stream format. No alignment needed. |
| byte_count | Bytes to queue. A trailing partial frame is not accepted. |
| int audio_stream_resume | ( | void | ) |
Continues from where audio_stream_pause() stopped.
| int audio_stream_set_low_data_callback | ( | int32_t | threshold_bytes, |
| audio_low_data_fn | callback, | ||
| void * | user ) |
Registers a function called when the queued data falls to a threshold.
The callback runs on a thread owned by the library, once each time the queue drains to the threshold. It runs again only after the level has risen above the threshold. Registering does not call it for a level that is already low. The callback may queue data; it must not end or restart the stream. The threshold is kept when the stream is restarted.
| threshold_bytes | 0 up to the capacity of the stream, in source bytes; 0 calls back only when empty. |
| callback | The function, or NULL to unregister. |
| user | Passed to the callback unchanged. |
| int audio_stream_set_volume | ( | int | volume_percent | ) |
Volume of the stream alone. It persists across restarts and works before the stream is started.
| volume_percent | 0 to 100. |
| int audio_stream_start | ( | const audio_stream_format_t * | format | ) |
Starts a stream, or restarts it with a new format and discards queued data.
| format | Sample rate 8000-48000 Hz, 8 or 16 bits, 1 or 2 channels. |
| int audio_stream_stop_and_clear | ( | void | ) |
Stops playback and discards queued data. The stream stays started with its format, in the playing state.
| int audio_stream_wait_until_writable | ( | int32_t | byte_count, |
| int32_t | timeout_ms ) |
Blocks until at least byte_count bytes can be queued.
| byte_count | 1 up to the capacity of the stream in source bytes. |
| timeout_ms | Milliseconds to wait: 0 polls once, -1 waits forever. |