[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog backend/sound_handler_gst.cpp b...
From: |
Tomas Groth |
Subject: |
[Gnash-commit] gnash ChangeLog backend/sound_handler_gst.cpp b... |
Date: |
Mon, 24 Jul 2006 18:59:40 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Tomas Groth <tgc> 06/07/24 18:59:40
Modified files:
. : ChangeLog
backend : sound_handler_gst.cpp sound_handler_sdl.cpp
server : button.cpp gnash.h movie_def_impl.h
movie_definition.h sound.cpp
sprite_definition.h
server/asobj : ASSound.cpp
Log message:
Restructured the way sound streams are treated. Not much different in
playing yet, but it will help later.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.505&r2=1.506
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/sound_handler_gst.cpp?cvsroot=gnash&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/sound_handler_sdl.cpp?cvsroot=gnash&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/gnash/server/button.cpp?cvsroot=gnash&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/gnash/server/gnash.h?cvsroot=gnash&r1=1.33&r2=1.34
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_def_impl.h?cvsroot=gnash&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_definition.h?cvsroot=gnash&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sound.cpp?cvsroot=gnash&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_definition.h?cvsroot=gnash&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/ASSound.cpp?cvsroot=gnash&r1=1.1&r2=1.2
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.505
retrieving revision 1.506
diff -u -b -r1.505 -r1.506
--- ChangeLog 24 Jul 2006 14:57:16 -0000 1.505
+++ ChangeLog 24 Jul 2006 18:59:40 -0000 1.506
@@ -1,3 +1,12 @@
+2006-07-24 Tomas Groth Christensen <address@hidden>
+
+ * backend/sound_handler_gst.cpp, backend/sound_handler_sdl.cpp,
+ server/button.cpp, server/gnash.h, server/movie_def_impl.h,
+ server/movie_definition.h, server/sound.cpp,
+ server/sprite_definition.h, server/asobj/ASSound.cpp:
+ Restructured the way sound streams are treated. Not much different
+ in playing yet, but it will help later.
+
2006-07-24 Vitaly Alexeev <address@hidden>
* gnash.vcproj: added /server/asobj files
* server/swf/ASHandlers.h: small optimization is done
Index: backend/sound_handler_gst.cpp
===================================================================
RCS file: /sources/gnash/gnash/backend/sound_handler_gst.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- backend/sound_handler_gst.cpp 24 Jul 2006 15:53:35 -0000 1.2
+++ backend/sound_handler_gst.cpp 24 Jul 2006 18:59:40 -0000 1.3
@@ -119,9 +119,6 @@
// Is the loop running?
bool looping;
- // latest sound stream we've created - we expect some data to arrive
- int currentStream;
-
GST_sound_handler()
: soundsPlaying(0),
looping(false)
@@ -174,16 +171,10 @@
int sample_count,
format_type format,
int sample_rate,
- bool stereo,
- bool stream)
+ bool stereo)
// Called to create a sample. We'll return a sample ID that
// can be use for playing it.
{
- // Add something similar... check gst elements?
- /*if (m_opened == false)
- {
- return 0;
- }*/
int16_t* adjusted_data = 0;
int adjusted_size = 0;
@@ -256,23 +247,22 @@
m_sound_data.push_back(sounddata);
-
- if (stream) currentStream = m_sound_data.size()-1;
-
return m_sound_data.size()-1;
}
// this gets called when a stream gets more data
- virtual void fill_stream_data(void* data, int data_bytes)
+ virtual long fill_stream_data(void* data, int data_bytes, int
handle_id)
{
- if (currentStream >= 0 && currentStream < m_sound_data.size())
+ if (handle_id >= 0 && handle_id < m_sound_data.size())
{
- m_sound_data[currentStream]->data =
static_cast<guint8*>(realloc(m_sound_data[currentStream]->data, data_bytes +
m_sound_data[currentStream]->data_size));
- memcpy(m_sound_data[currentStream]->data +
m_sound_data[currentStream]->data_size, data, data_bytes);
- m_sound_data[currentStream]->data_size += data_bytes;
+ m_sound_data[handle_id]->data =
static_cast<guint8*>(realloc(m_sound_data[handle_id]->data, data_bytes +
m_sound_data[handle_id]->data_size));
+ memcpy(m_sound_data[handle_id]->data +
m_sound_data[handle_id]->data_size, data, data_bytes);
+ m_sound_data[handle_id]->data_size += data_bytes;
+ return m_sound_data[handle_id]->data_size - data_bytes;
}
+ return 0;
// FIXME: if the playback of the stream has already started
we'll need to update the struct
@@ -350,7 +340,7 @@
}*/
- virtual void play_sound(int sound_handle, int loop_count, int offset)
+ virtual void play_sound(int sound_handle, int loop_count, int
offset, long start_position)
// Play the index'd sample.
{
@@ -361,6 +351,12 @@
return;
}
+ // If this is called from a streamsoundblocktag, we only start
if this
+ // sound isn't already playing. If a gst_element-struct is
existing we
+ // assume it is also playing.
+ if (start_position > 0 &&
m_sound_data[sound_handle]->m_gst_elements.size() > 0) {
+ return;
+ }
// Make a "gst_elements" for this sound which is latter placed
on the vector of instances of this sound being played
gst_elements* gst_element = new gst_elements;
@@ -371,7 +367,7 @@
// Copy data-info to the "gst_elements"
gst_element->data_size = m_sound_data[sound_handle]->data_size;
gst_element->data = m_sound_data[sound_handle]->data;
- gst_element->position = 0;
+ gst_element->position = start_position;
// Set number of loop we should do. -1 is infinte loop, 0 plays
it once, 1 twice etc.
gst_element->loop_count = loop_count;
Index: backend/sound_handler_sdl.cpp
===================================================================
RCS file: /sources/gnash/gnash/backend/sound_handler_sdl.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- backend/sound_handler_sdl.cpp 24 Jul 2006 13:30:50 -0000 1.12
+++ backend/sound_handler_sdl.cpp 24 Jul 2006 18:59:40 -0000 1.13
@@ -106,8 +106,7 @@
int sample_count,
format_type format,
int sample_rate,
- bool stereo,
- bool stream)
+ bool stereo)
// Called to create a sample. We'll return a sample ID that
// can use for playing it.
{
@@ -168,7 +167,7 @@
return m_samples.size() - 1;
}
- virtual void play_sound(int sound_handle, int loop_count, int
secondOffset)
+ virtual void play_sound(int sound_handle, int loop_count, int
secondOffset, long start_position)
// Play the index'd sample.
{
if (m_opened && sound_handle >= 0 && sound_handle < (int)
m_samples.size())
Index: server/button.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/button.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- server/button.cpp 10 Jul 2006 13:47:12 -0000 1.20
+++ server/button.cpp 24 Jul 2006 18:59:40 -0000 1.21
@@ -605,7 +605,7 @@
}
else
{
-
s->play_sound(bs.m_sam->m_sound_handler_id, bs.m_sound_style.m_loop_count, 0);
+
s->play_sound(bs.m_sam->m_sound_handler_id, bs.m_sound_style.m_loop_count, 0,
0);
}
}
}
Index: server/gnash.h
===================================================================
RCS file: /sources/gnash/gnash/server/gnash.h,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -b -r1.33 -r1.34
--- server/gnash.h 24 Jul 2006 13:30:51 -0000 1.33
+++ server/gnash.h 24 Jul 2006 18:59:40 -0000 1.34
@@ -405,17 +405,16 @@
int sample_count,
format_type format,
int sample_rate, /* one of 5512, 11025, 22050,
44100 */
- bool stereo,
- bool stream
+ bool stereo
) = 0;
#ifdef HAVE_GST_GST_H
// gnash calls this to fill up soundstreams data
- virtual void fill_stream_data(void* data, int data_bytes) = 0;
+ virtual long fill_stream_data(void* data, int data_bytes, int
handle_id) = 0;
#endif
// gnash calls this when it wants you to play the defined sound.
//
// loop_count == 0 means play the sound once (1 means play it twice,
etc)
- virtual void play_sound(int sound_handle, int loop_count, int
secondOffset) = 0;
+ virtual void play_sound(int sound_handle, int loop_count, int
secondOffset, long start) = 0;
// stops all sounds currently playing in a SWF file without
stopping the playhead.
// Sounds set to stream will resume playing as the playhead moves
over the frames they are in.
Index: server/movie_def_impl.h
===================================================================
RCS file: /sources/gnash/gnash/server/movie_def_impl.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- server/movie_def_impl.h 24 Jun 2006 17:56:36 -0000 1.10
+++ server/movie_def_impl.h 24 Jul 2006 18:59:40 -0000 1.11
@@ -159,6 +159,7 @@
hash<int, smart_ptr<font> > m_fonts;
hash<int, smart_ptr<bitmap_character_def> > m_bitmap_characters;
hash<int, smart_ptr<sound_sample> > m_sound_samples;
+ hash<int, smart_ptr<sound_sample> > m_sound_streams;
/// A list of movie control events for each frame.
std::vector<std::vector<execute_tag*> > m_playlist;
@@ -190,6 +191,7 @@
int m_frame_count;
int m_version;
int m_loading_frame;
+ int m_loading_sound_stream;
uint32 m_file_length;
jpeg::input* m_jpeg_in;
@@ -337,6 +339,8 @@
void add_bitmap_character(int character_id, bitmap_character_def*
ch);
sound_sample* get_sound_sample(int character_id);
virtual void add_sound_sample(int character_id, sound_sample* sam);
+ virtual void set_loading_sound_stream_id(int id) {
m_loading_sound_stream = id; }
+ int get_loading_sound_stream_id() { return
m_loading_sound_stream; }
/// Add an execute_tag to this movie_definition's playlist
void add_execute_tag(execute_tag* e)
@@ -431,6 +435,8 @@
movie_interface* create_instance();
virtual const std::string& get_url() const { return _url; }
+
+
};
} // namespace gnash
Index: server/movie_definition.h
===================================================================
RCS file: /sources/gnash/gnash/server/movie_definition.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- server/movie_definition.h 24 Jun 2006 17:56:36 -0000 1.5
+++ server/movie_definition.h 24 Jul 2006 18:59:40 -0000 1.6
@@ -222,6 +222,11 @@
virtual void add_sound_sample(int character_id, sound_sample* sam) = 0;
+ virtual void set_loading_sound_stream_id(int id) = 0;
+
+ virtual int get_loading_sound_stream_id() = 0;
+
+
virtual void export_resource(const tu_string& symbol,
resource* res) = 0;
Index: server/sound.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/sound.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- server/sound.cpp 24 Jul 2006 15:53:35 -0000 1.11
+++ server/sound.cpp 24 Jul 2006 18:59:40 -0000 1.12
@@ -106,36 +106,35 @@
}
else
{
-
s_sound_handler->play_sound(m_handler_id, m_loop_count, 0);
+
s_sound_handler->play_sound(m_handler_id, m_loop_count, 0,0);
}
}
}
};
#ifdef HAVE_GST_GST_H
- // Used to simulate a start_sound_tag when we have a stream
+ /// SWF Tag SoundStreamBlock (19)
struct start_stream_sound_tag : public execute_tag
{
uint16_t m_handler_id;
- int m_loop_count;
- bool m_stop_playback;
+ long m_start;
+ int latency;
start_stream_sound_tag()
:
m_handler_id(0),
- m_loop_count(0),
- m_stop_playback(false)
+ m_start(0),
+ latency(0)
{
}
- void read(movie_definition* m, const sound_sample_impl* sam)
+ void read(movie_definition* m, int handler_id, long start)
// Initialize this StartSound tag from the stream & given
sample.
// Insert ourself into the movie.
{
- assert(sam);
-
- m_handler_id = sam->m_sound_handler_id;
+ m_handler_id = handler_id;
+ m_start = start;
m->add_execute_tag(this);
}
@@ -144,14 +143,7 @@
{
if (s_sound_handler)
{
- if (m_stop_playback)
- {
-
s_sound_handler->stop_sound(m_handler_id);
- }
- else
- {
-
s_sound_handler->play_sound(m_handler_id, m_loop_count, 0);
- }
+ s_sound_handler->play_sound(m_handler_id, 0, 0,
m_start);
}
}
};
@@ -444,8 +436,7 @@
sample_count,
format,
s_sample_rate_table[sample_rate],
- stereo,
- false);
+ stereo);
sound_sample* sam = new sound_sample_impl(handler_id);
m->add_sound_sample(character_id, sam);
@@ -495,7 +486,6 @@
// This only works if there is only one stream in the movie...
// The right way to do it is to make seperate structures for streams
// in movie_def_impl.
- uint16_t character_id = 10000;
// extract garbage data
int garbage = in->read_uint(8);
@@ -513,8 +503,8 @@
static int s_sample_rate_table[] = { 5512, 11025, 22050, 44100 };
- log_parse("sound stream head: ch=%d, format=%d, rate=%d, 16=%d,
stereo=%d, ct=%d\n",
- character_id, int(format), sample_rate, int(sample_16bit),
int(stereo), sample_count);
+ log_parse("sound stream head: format=%d, rate=%d, 16=%d, stereo=%d,
ct=%d\n",
+ int(format), sample_rate, int(sample_16bit), int(stereo),
sample_count);
// If we have a sound_handler, ask it to init this sound.
if (s_sound_handler)
@@ -527,14 +517,8 @@
sample_count,
format,
s_sample_rate_table[sample_rate],
- stereo,
- true);
- sound_sample* sam = new sound_sample_impl(handler_id);
- m->add_sound_sample(character_id, sam);
-
- sound_sample_impl* sam_impl = (sound_sample_impl*)
m->get_sound_sample(10000);
- start_stream_sound_tag* ssst = new start_stream_sound_tag();
- ssst->read(m, sam_impl);
+ stereo);
+ m->set_loading_sound_stream_id(handler_id);
}
#endif
@@ -548,12 +532,14 @@
#ifdef HAVE_GST_GST_H
assert(tag == 19);
+
// extract garbage data
int garbage = in->read_uint(32);
+
// If we have a sound_handler, store the data with the appropiate sound.
- if (s_sound_handler)
- {
+ if (!s_sound_handler) return;
+
int data_bytes = 0;
unsigned char* data = NULL;
@@ -568,12 +554,18 @@
data[i] = in->read_u8();
}
- // Swap bytes on behalf of the host, to make it easier for the
handler.
- // @@ I'm assuming this is a good idea? Most sound handlers
will prefer native endianness?
- s_sound_handler->fill_stream_data(data, data_bytes);
+ int handle_id = m->get_loading_sound_stream_id();
+
+ // Fill the data on the apropiate sound, and receives the starting point
+ // for later "start playing from this frame" events.
+ long start = s_sound_handler->fill_stream_data(data, data_bytes,
handle_id);
delete [] data;
- }
+
+ start_stream_sound_tag* ssst = new start_stream_sound_tag();
+ ssst->read(m, handle_id, start);
+
+
#endif
}
Index: server/sprite_definition.h
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_definition.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- server/sprite_definition.h 1 Jul 2006 20:44:10 -0000 1.10
+++ server/sprite_definition.h 24 Jul 2006 18:59:40 -0000 1.11
@@ -144,6 +144,15 @@
" Malformed SWF?");
}
+ virtual void set_loading_sound_stream_id(int id) {
+ return m_movie_def->set_loading_sound_stream_id(id);
+ }
+
+ virtual int get_loading_sound_stream_id() {
+ return m_movie_def->get_loading_sound_stream_id();
+ }
+
+
// @@ would be nicer to not inherit these...
virtual create_bitmaps_flag get_create_bitmaps() const
{ assert(0); return DO_LOAD_BITMAPS; }
Index: server/asobj/ASSound.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/ASSound.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- server/asobj/ASSound.cpp 22 Jul 2006 23:47:56 -0000 1.1
+++ server/asobj/ASSound.cpp 24 Jul 2006 18:59:40 -0000 1.2
@@ -156,7 +156,7 @@
sound_as_object* so = (sound_as_object*)
(as_object*) fn.this_ptr;
assert(so);
- s->play_sound(so->sound_id, loop, secondOffset);
+ s->play_sound(so->sound_id, loop, secondOffset, 0);
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog backend/sound_handler_gst.cpp b...,
Tomas Groth <=