gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash/backend sound_handler_sdl.cpp sound_handl...


From: Vitaly Alexeev
Subject: [Gnash-commit] gnash/backend sound_handler_sdl.cpp sound_handl...
Date: Sun, 29 Oct 2006 17:14:59 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Vitaly Alexeev <alexeev>        06/10/29 17:14:59

Modified files:
        backend        : sound_handler_sdl.cpp sound_handler_sdl.h 

Log message:
        added audio streamer for video

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/sound_handler_sdl.cpp?cvsroot=gnash&r1=1.29&r2=1.30
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/sound_handler_sdl.h?cvsroot=gnash&r1=1.9&r2=1.10

Patches:
Index: sound_handler_sdl.cpp
===================================================================
RCS file: /sources/gnash/gnash/backend/sound_handler_sdl.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- sound_handler_sdl.cpp       21 Oct 2006 09:54:44 -0000      1.29
+++ sound_handler_sdl.cpp       29 Oct 2006 17:14:59 -0000      1.30
@@ -51,7 +51,7 @@
        audioSpec.channels = 2;
        audioSpec.callback = sdl_audio_callback;
        audioSpec.userdata = this;
-       audioSpec.samples = 512;
+       audioSpec.samples = 2048;               //512 - not enough for  
videostream     //vv
 }
 
 SDL_sound_handler::~SDL_sound_handler()
@@ -475,6 +475,24 @@
        return muted;
 }
 
+void   SDL_sound_handler::attach_aux_streamer(aux_streamer_ptr ptr, void* 
owner)       //vv
+{
+       assert(owner);
+       assert(ptr);
+
+       aux_streamer_ptr p;
+       if (m_aux_streamer.get(owner, &p))
+       {
+               // Already in the hash.
+               return;
+       }
+       m_aux_streamer[owner] = ptr;
+}
+
+void   SDL_sound_handler::detach_aux_streamer(void* owner)     //vv
+{
+       m_aux_streamer.erase(owner);
+}
 
 void SDL_sound_handler::convert_raw_data(
        int16_t** adjusted_data,
@@ -643,7 +661,7 @@
 
        // If nothing to play there is no reason to play
        // Is this a potential deadlock problem?
-       if (handler->soundsPlaying == 0) {
+       if (handler->soundsPlaying == 0 && handler->m_aux_streamer.size() == 0) 
{       //vv
                SDL_PauseAudio(1);
                return;
        }
@@ -654,6 +672,28 @@
        Uint8* buffer = stream;  //new Uint8[len];
        memset(buffer, 0, buffer_length);
 
+
+       // call NetStream audio callbacks       //vv
+       if (handler->m_aux_streamer.size() > 0)
+       {
+               Uint8* buf = new Uint8[buffer_length];
+
+               for (gnash::hash< void*, gnash::sound_handler::aux_streamer_ptr 
>::iterator it =
+                       handler->m_aux_streamer.begin();
+                       it != handler->m_aux_streamer.end(); ++it)
+               {
+                       memset(buf, 0, buffer_length);
+
+                       SDL_sound_handler::aux_streamer_ptr aux_streamer = 
it->second; //handler->m_aux_streamer[i]->ptr;
+                       void* owner = it->first;
+                       (aux_streamer)(owner, buf, buffer_length);
+
+                       SDL_MixAudio(stream, buf, buffer_length, 
SDL_MIX_MAXVOLUME);
+
+               }
+               delete buf;
+       }
+
        for(uint32_t i=0; i < handler->m_sound_data.size(); i++) {
                for(uint32_t j = 0; j < 
handler->m_sound_data[i]->m_active_sounds.size(); j++) {
 

Index: sound_handler_sdl.h
===================================================================
RCS file: /sources/gnash/gnash/backend/sound_handler_sdl.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- sound_handler_sdl.h 27 Oct 2006 15:04:33 -0000      1.9
+++ sound_handler_sdl.h 29 Oct 2006 17:14:59 -0000      1.10
@@ -115,6 +115,9 @@
 // Use SDL and ffmpeg/mad/nothing to handle sounds.
 struct SDL_sound_handler : public gnash::sound_handler
 {
+       // NetStream audio callbacks
+       gnash::hash< void* /* owner */, aux_streamer_ptr /* callback */> 
m_aux_streamer;        //vv
+
        // Sound data.
        std::vector<sound_data*>        m_sound_data;
 
@@ -172,10 +175,13 @@
 
        virtual bool    is_muted();
 
+       virtual void    attach_aux_streamer(aux_streamer_ptr ptr, void* owner); 
//vv
+       virtual void    detach_aux_streamer(void* owner);       //vv
+
        // Converts input data to the SDL output format.
        virtual void    convert_raw_data(int16_t** adjusted_data,
                          int* adjusted_size, void* data, int sample_count,
-                         int sample_size, int sample_rate, bool stereo);
+                         int sample_size, int sample_rate, bool stereo);       
//vv
 
 };
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]