diff options
| author | spicyjpeg <thatspicyjpeg@gmail.com> | 2023-06-20 13:27:34 +0200 |
|---|---|---|
| committer | spicyjpeg <thatspicyjpeg@gmail.com> | 2023-06-20 13:27:34 +0200 |
| commit | 79a966486615e60be3a37d278945dc3dd0fd933b (patch) | |
| tree | 4a4cd8412c10b9646ff1966af964a314c0567005 /examples/sound/cdstream | |
| parent | ced21c69f7b399dce169069334c1424e5254d582 (diff) | |
| download | psn00bsdk-79a966486615e60be3a37d278945dc3dd0fd933b.tar.gz | |
More SPU streaming example tweaks
Diffstat (limited to 'examples/sound/cdstream')
| -rw-r--r-- | examples/sound/cdstream/main.c | 6 | ||||
| -rw-r--r-- | examples/sound/cdstream/stream.c | 4 | ||||
| -rw-r--r-- | examples/sound/cdstream/stream.h | 12 |
3 files changed, 13 insertions, 9 deletions
diff --git a/examples/sound/cdstream/main.c b/examples/sound/cdstream/main.c index c6d578c..fbca65e 100644 --- a/examples/sound/cdstream/main.c +++ b/examples/sound/cdstream/main.c @@ -312,7 +312,7 @@ int main(int argc, const char* argv[]) { SHOW_STATUS("BUFFERING STREAM\n"); setup_stream(&file.pos); - Stream_Start(&stream_ctx); + Stream_Start(&stream_ctx, false); int sectors_per_chunk = (stream_ctx.chunk_size + 2047) / 2048; int vag_sample_rate = getSPUSampleRate(stream_ctx.config.sample_rate); @@ -326,7 +326,7 @@ int main(int argc, const char* argv[]) { bool buffering = feed_stream(); FntPrint(-1, "PLAYING SPU STREAM\n\n"); - FntPrint(-1, "BUFFER: %d\n", stream_ctx.db_active); + FntPrint(-1, "BUFFER: %d (%d)\n", stream_ctx.db_active, stream_ctx.chunk_counter); FntPrint(-1, "STATUS: %s\n\n", buffering ? "READING" : "IDLE"); FntPrint(-1, "BUFFERED: %d/%d\n", stream_ctx.buffer.length, stream_ctx.config.buffer_size); @@ -359,7 +359,7 @@ int main(int argc, const char* argv[]) { if (paused) Stream_Stop(); else - Stream_Start(&stream_ctx); + Stream_Start(&stream_ctx, true); } // Note that seeking will only work correctly with .VAG files whose diff --git a/examples/sound/cdstream/stream.c b/examples/sound/cdstream/stream.c index bf73b2f..aaf5703 100644 --- a/examples/sound/cdstream/stream.c +++ b/examples/sound/cdstream/stream.c @@ -145,14 +145,14 @@ void Stream_Destroy(Stream_Context *ctx) { ExitCriticalSection(); } -bool Stream_Start(Stream_Context *ctx) { +bool Stream_Start(Stream_Context *ctx, bool resume) { if (_active_ctx) return false; _active_ctx = ctx; // Wait for the first chunk to be buffered and ready to play. - if (!ctx->chunk_counter) { + if (!resume) { _spu_irq_handler(); SpuIsTransferCompleted(SPU_TRANSFER_WAIT); } diff --git a/examples/sound/cdstream/stream.h b/examples/sound/cdstream/stream.h index 15e3ec3..aa384ed 100644 --- a/examples/sound/cdstream/stream.h +++ b/examples/sound/cdstream/stream.h @@ -121,16 +121,20 @@ void Stream_Destroy(Stream_Context *ctx); /** * @brief Starts playback of a stream. * - * @details Activates the given stream context and starts playing audio from its - * FIFO. This function must be called while no other stream is active and after - * the stream's FIFO has been filled up. + * @details Activates the given stream context and starts or resumes playing + * audio from its FIFO. This function must be called while no other stream is + * active and after the stream's FIFO has been filled up. In order to prevent + * skipping, the resume argument shall be set to true if the stream was + * previously stopped and its buffer in SPU RAM was not overwritten by another + * stream or sample data. * * @param ctx + * @param resume Should be true if resuming a previously stopped stream * @return True if the stream was started, false if another stream is active * * @see Stream_Stop() */ -bool Stream_Start(Stream_Context *ctx); +bool Stream_Start(Stream_Context *ctx, bool resume); /** * @brief Stops playback of any currently active stream. |
