[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog backend/sound_handler.h backend...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog backend/sound_handler.h backend... |
Date: |
Thu, 31 May 2007 16:42:06 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/05/31 16:42:06
Modified files:
. : ChangeLog
backend : sound_handler.h sound_handler_sdl.cpp
Log message:
* backend/sound_handler.h: document attach_aux_streamer and
detach_aux_streamer; add TODO items.
* backend/sound_handler_sdl.cpp (sdl_audio_callback):
documentation,
TODO items, early return if buffer len passed by SDL == 0.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3426&r2=1.3427
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/sound_handler.h?cvsroot=gnash&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/sound_handler_sdl.cpp?cvsroot=gnash&r1=1.67&r2=1.68
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.3426
retrieving revision 1.3427
diff -u -b -r1.3426 -r1.3427
--- ChangeLog 31 May 2007 15:52:28 -0000 1.3426
+++ ChangeLog 31 May 2007 16:42:05 -0000 1.3427
@@ -1,3 +1,10 @@
+2007-05-31 Sandro Santilli <address@hidden>
+
+ * backend/sound_handler.h: document attach_aux_streamer and
+ detach_aux_streamer; add TODO items.
+ * backend/sound_handler_sdl.cpp (sdl_audio_callback): documentation,
+ TODO items, early return if buffer len passed by SDL == 0.
+
2007-05-31 Tomas Groth Christensen <address@hidden>
* server/asobj/NetStream*.{h,cpp}: Always use milliseconds internally.
Index: backend/sound_handler.h
===================================================================
RCS file: /sources/gnash/gnash/backend/sound_handler.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- backend/sound_handler.h 29 May 2007 17:15:13 -0000 1.15
+++ backend/sound_handler.h 31 May 2007 16:42:06 -0000 1.16
@@ -18,7 +18,7 @@
//
//
-/* $Id: sound_handler.h,v 1.15 2007/05/29 17:15:13 strk Exp $ */
+/* $Id: sound_handler.h,v 1.16 2007/05/31 16:42:06 strk Exp $ */
/// \page sound_handler_intro Sound handler introduction
///
@@ -56,6 +56,8 @@
{
public:
+ // See attach_aux_streamer
+ // TODO: change third parameter type to unsigned
typedef bool (*aux_streamer_ptr)(void *udata, uint8_t *stream, int len);
/// Used to control volume for event sounds. It basically tells that
from
@@ -220,12 +222,23 @@
/// This is called by AS classes NetStream or Sound to attach callback,
so
/// that audio from the classes will be played through the soundhandler.
//
+ /// This is actually only used by the SDL sound_handler. It uses these
"auxiliary"
+ /// streamers to fetch decoded audio data to mix and send to the output
channel.
+ ///
+ /// The "aux streamer" will be called with the 'udata' pointer as first
argument,
+ /// then will be passed a buffer pointer as second argument and it's
length
+ /// as third. The callbacks should fill the given buffer if possible.
+ /// The callback should return true if wants to remain attached, false
if wants
+ /// to be detached.
+ ///
/// @param ptr
/// The pointer to the callback function
///
- /// @param owner
- /// The pointer to the owner AS class, used to identify which sound
callback
- /// is owned by whom.
+ /// @param udata
+ /// User data pointer, passed as first argument to the registered
callback.
+ /// WARNING: this is currently also used to *identify* the callback
for later
+ /// removal, see detach_aux_streamer. TODO: stop using the data
pointer for
+ /// identification purposes and use the callback pointer directly
instead.
///
virtual void attach_aux_streamer(aux_streamer_ptr ptr, void* owner)
= 0;
@@ -233,11 +246,12 @@
/// that audio from the classes no longer will be played through the
/// soundhandler.
//
- /// @param owner
- /// The pointer to the owner AS class, used to identify which sound
callback
- /// is owned by whom.
+ /// @param udata
+ /// The key identifying the auxiliary streamer.
+ /// WARNING: this need currently be the 'udata' pointer passed to
attach_aux_streamer.
+ /// TODO: get the aux_streamer_ptr as key !!
///
- virtual void detach_aux_streamer(void* owner) = 0;
+ virtual void detach_aux_streamer(void* udata) = 0;
/// VERY crude sample-rate and steroe conversion. Converts input data
to
/// output format.
Index: backend/sound_handler_sdl.cpp
===================================================================
RCS file: /sources/gnash/gnash/backend/sound_handler_sdl.cpp,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -b -r1.67 -r1.68
--- backend/sound_handler_sdl.cpp 29 May 2007 17:15:14 -0000 1.67
+++ backend/sound_handler_sdl.cpp 31 May 2007 16:42:06 -0000 1.68
@@ -18,7 +18,7 @@
// Based on sound_handler_sdl.cpp by Thatcher Ulrich http://tulrich.com 2003
// which has been donated to the Public Domain.
-// $Id: sound_handler_sdl.cpp,v 1.67 2007/05/29 17:15:14 strk Exp $
+// $Id: sound_handler_sdl.cpp,v 1.68 2007/05/31 16:42:06 strk Exp $
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -650,14 +650,34 @@
}
-// The callback function which refills the buffer with data
-// We run through all of the sounds, and mix all of the active sounds
-// into the stream given by the callback.
-// If sound is compresssed (mp3) a mp3-frame is decoded into a buffer,
-// and resampled if needed. When the buffer has been sampled, another
-// frame is decoded until all frames has been decoded.
-// If a sound is looping it will be decoded from the beginning again.
-
+/// Callback invoked by the SDL audio thread.
+//
+/// Refills the output stream/buffer with data.
+///
+/// We run trough all the attached auxiliary streamers fetching decoded
+/// audio blocks and mixing them into the given output stream.
+///
+/// <UnverifiedComment>
+/// If sound is compresssed (mp3) a mp3-frame is decoded into a buffer,
+/// and resampled if needed. When the buffer has been sampled, another
+/// frame is decoded until all frames has been decoded.
+/// If a sound is looping it will be decoded from the beginning again.
+/// </UnverifiedComment>
+///
+/// TODO: make a static method of the SDL_sound_handler class
+///
+/// @param udata
+/// User data pointer (SDL_sound_handler instance in our case).
+/// We'll lock the SDL_sound_handler::_mutex during operations.
+///
+/// @param stream
+/// The output stream/buffer to fill
+///
+/// @param buffer_length_in
+/// Length of the buffer.
+/// If zero or negative we log an error and return
+/// (negative is probably an SDL bug, zero dunno yet).
+///
static void
sdl_audio_callback (void *udata, Uint8 *stream, int buffer_length_in)
{
@@ -667,6 +687,12 @@
return;
}
+ if ( buffer_length_in == 0 )
+ {
+ gnash::log_error(_("Zero buffer length in sdl_audio_callback"));
+ return;
+ }
+
unsigned int buffer_length = static_cast<unsigned
int>(buffer_length_in);
// Get the soundhandler