From: Lawrence S. <ljs...@us...> - 2020-10-07 23:45:50
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via fae2358ca346842f3f4d36237be3994fe6135139 (commit) from 380b73bb62327dfca14f2c139886bddeb819d3ba (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit fae2358ca346842f3f4d36237be3994fe6135139 Author: Lawrence Sebald <ljs...@us...> Date: Wed Oct 7 19:45:19 2020 -0400 Add user data to the sound stream structure and an accessor/mutator for it. ----------------------------------------------------------------------- Summary of changes: doc/CHANGELOG | 1 + kernel/arch/dreamcast/include/dc/sound/stream.h | 27 ++++++++++++++++++++++++- kernel/arch/dreamcast/sound/snd_stream.c | 16 +++++++++++++-- 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/doc/CHANGELOG b/doc/CHANGELOG index 1d5905d..87282da 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -134,6 +134,7 @@ KallistiOS version 2.1.0 ----------------------------------------------- - NAO Added naominetboot - a tool to upload NAOMI formatted binaries to a NetDIMM board for executing on the NAOMI [LS] - DC Prevent double-initialization of Maple devices from breaking things [LS] +- DC Add a user data pointer to snd_stream [LS] KallistiOS version 2.0.0 ----------------------------------------------- - DC Broadband Adapter driver fixes [Dan Potter == DP] diff --git a/kernel/arch/dreamcast/include/dc/sound/stream.h b/kernel/arch/dreamcast/include/dc/sound/stream.h index 70556c1..2df47c1 100644 --- a/kernel/arch/dreamcast/include/dc/sound/stream.h +++ b/kernel/arch/dreamcast/include/dc/sound/stream.h @@ -2,6 +2,7 @@ dc/sound/stream.h Copyright (C) 2002, 2004 Dan Potter + Copyright (C) 2020 Lawrence Sebald */ @@ -14,6 +15,8 @@ to worry about that yourself (or use something in kos-ports). \author Dan Potter + \author Florian Schulze + \author Lawrence Sebald */ #ifndef __DC_SOUND_STREAM_H @@ -68,6 +71,29 @@ typedef void *(*snd_stream_callback_t)(snd_stream_hnd_t hnd, int smp_req, */ void snd_stream_set_callback(snd_stream_hnd_t hnd, snd_stream_callback_t cb); +/** \brief Set the user data for a given stream. + + This function sets the user data pointer for the given stream, overwriting + any existing one that may have been in place. This is designed to allow the + user the ability to associate a piece of data with the stream for instance + to assist in identifying what sound is playing on a stream. The driver does + not attempt to use this data in any way. + + \param hnd The stream handle to look up. + \param cb A pointer to the user data. +*/ +void snd_stream_set_userdata(snd_stream_hnd_t hnd, void *d); + +/** \brief Get the user data for a given stream. + + This function retrieves the set user data pointer for a given stream. + + \param handle The stream handle to look up. + \return The user data pointer set for this stream or NULL + if no data pointer has been set. +*/ +void *snd_stream_get_userdata(snd_stream_hnd_t hnd); + /* Add an effect filter to the sound stream chain. When the stream buffer filler needs more data, it starts out by calling the initial callback (set above). It then calls each function in the effect @@ -255,4 +281,3 @@ void snd_stream_volume(snd_stream_hnd_t hnd, int vol); __END_DECLS #endif /* __DC_SOUND_STREAM_H */ - diff --git a/kernel/arch/dreamcast/sound/snd_stream.c b/kernel/arch/dreamcast/sound/snd_stream.c index 314460e..c2ae83b 100644 --- a/kernel/arch/dreamcast/sound/snd_stream.c +++ b/kernel/arch/dreamcast/sound/snd_stream.c @@ -3,6 +3,7 @@ snd_stream.c Copyright (C) 2000, 2001, 2002, 2003, 2004 Dan Potter Copyright (C) 2002 Florian Schulze + Copyright (C) 2020 Lawrence Sebald SH-4 support routines for SPU streaming sound driver */ @@ -77,6 +78,9 @@ typedef struct strchan { /* Have we been initialized yet? (and reserved a buffer, etc) */ volatile int initted; + + /* User data. */ + void *user_data; } strchan_t; // Our stream structs @@ -100,6 +104,16 @@ void snd_stream_set_callback(snd_stream_hnd_t hnd, snd_stream_callback_t cb) { streams[hnd].get_data = cb; } +void snd_stream_set_userdata(snd_stream_hnd_t hnd, void *d) { + CHECK_HND(hnd); + streams[hnd].user_data = d; +} + +void *snd_stream_get_userdata(snd_stream_hnd_t hnd) { + CHECK_HND(hnd); + return streams[hnd].user_data; +} + void snd_stream_filter_add(snd_stream_hnd_t hnd, snd_stream_filter_t filtfunc, void * obj) { filter_t * f; @@ -549,5 +563,3 @@ void snd_stream_volume(snd_stream_hnd_t hnd, int vol) { cmd->cmd_id = streams[hnd].ch[1]; snd_sh4_to_aica(tmp, cmd->size); } - - hooks/post-receive -- A pseudo Operating System for the Dreamcast. |