[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: |
Tomas Groth |
Subject: |
[Gnash-commit] gnash ChangeLog backend/sound_handler.h backend... |
Date: |
Fri, 27 Jul 2007 15:09:42 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Tomas Groth <tgc> 07/07/27 15:09:42
Modified files:
. : ChangeLog
backend : sound_handler.h sound_handler_gst.cpp
sound_handler_gst.h sound_handler_sdl.cpp
sound_handler_sdl.h
server/asobj : SoundFfmpeg.cpp SoundGst.cpp SoundGst.h
SoundMad.cpp SoundMad.h
server/swf : tag_loaders.cpp
Log message:
* backend/sound_handler.h, backend/sound_handler_gst.{cpp,h},
backend/sound_handler_sdl.{cpp,h},
server/asobj/SoundFfmpeg.{h,cpp},
server/asobj/SoundGst.{h,cpp}, server/asobj/SoundMad.{h,cpp}:
Implement duration and position properties when using Sound
objects
to control an eventsound, patch partly by Sergio Costas.
* server/swf/tag_loaders.cpp: Fix warnings.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3843&r2=1.3844
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/sound_handler.h?cvsroot=gnash&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/sound_handler_gst.cpp?cvsroot=gnash&r1=1.54&r2=1.55
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/sound_handler_gst.h?cvsroot=gnash&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/sound_handler_sdl.cpp?cvsroot=gnash&r1=1.75&r2=1.76
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/sound_handler_sdl.h?cvsroot=gnash&r1=1.30&r2=1.31
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/SoundFfmpeg.cpp?cvsroot=gnash&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/SoundGst.cpp?cvsroot=gnash&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/SoundGst.h?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/SoundMad.cpp?cvsroot=gnash&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/SoundMad.h?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/server/swf/tag_loaders.cpp?cvsroot=gnash&r1=1.116&r2=1.117
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.3843
retrieving revision 1.3844
diff -u -b -r1.3843 -r1.3844
--- ChangeLog 27 Jul 2007 14:13:00 -0000 1.3843
+++ ChangeLog 27 Jul 2007 15:09:40 -0000 1.3844
@@ -1,3 +1,12 @@
+2007-07-27 Tomas Groth Christensen <address@hidden>
+
+ * backend/sound_handler.h, backend/sound_handler_gst.{cpp,h},
+ backend/sound_handler_sdl.{cpp,h}, server/asobj/SoundFfmpeg.{h,cpp},
+ server/asobj/SoundGst.{h,cpp}, server/asobj/SoundMad.{h,cpp}:
+ Implement duration and position properties when using Sound objects
+ to control an eventsound, patch partly by Sergio Costas.
+ * server/swf/tag_loaders.cpp: Fix warnings.
+
2007-07-27 Sandro Santilli <address@hidden>
* gui/Makefile.am: distribute kde_glue_opengl.h.
Index: backend/sound_handler.h
===================================================================
RCS file: /sources/gnash/gnash/backend/sound_handler.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- backend/sound_handler.h 23 Jul 2007 22:07:58 -0000 1.19
+++ backend/sound_handler.h 27 Jul 2007 15:09:41 -0000 1.20
@@ -18,7 +18,7 @@
//
//
-/* $Id: sound_handler.h,v 1.19 2007/07/23 22:07:58 strk Exp $ */
+/* $Id: sound_handler.h,v 1.20 2007/07/27 15:09:41 tgc Exp $ */
/// \page sound_handler_intro Sound handler introduction
///
@@ -262,6 +262,24 @@
virtual ~sound_handler() {};
+ /// Gets the duration in milliseconds of an event sound connected
+ /// to an AS Sound obejct.
+ ///
+ /// @param sound_handle
+ /// The id of the event sound
+ ///
+ /// @return the duration of the sound in milliseconds
+ virtual unsigned int get_duration(int sound_handle) = 0;
+
+ /// Gets the playhead position in milliseconds of an event sound
connected
+ /// to an AS Sound obejct.
+ ///
+ /// @param sound_handle
+ /// The id of the event sound
+ ///
+ /// @return the duration of the sound in milliseconds
+ virtual unsigned int get_position(int sound_handle) = 0;
+
/// Special test-fuction. Reports how many times a sound has been
started
size_t numSoundsStarted() const { return _soundsStarted; }
Index: backend/sound_handler_gst.cpp
===================================================================
RCS file: /sources/gnash/gnash/backend/sound_handler_gst.cpp,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -b -r1.54 -r1.55
--- backend/sound_handler_gst.cpp 23 Jul 2007 22:23:33 -0000 1.54
+++ backend/sound_handler_gst.cpp 27 Jul 2007 15:09:41 -0000 1.55
@@ -20,7 +20,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_gst.cpp,v 1.54 2007/07/23 22:23:33 strk Exp $ */
+/* $Id: sound_handler_gst.cpp,v 1.55 2007/07/27 15:09:41 tgc Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -604,6 +604,63 @@
log_unimpl(__PRETTY_FUNCTION__);
}
+unsigned int GST_sound_handler::get_duration(int sound_handle)
+{
+ mutex::scoped_lock lock(_mutex);
+
+ // Check if the sound exists.
+ if (sound_handle < 0 || (unsigned int) sound_handle >=
m_sound_data.size())
+ {
+ // Invalid handle.
+ return 0;
+ }
+
+ sound_data* sounddata = m_sound_data[sound_handle];
+
+ // Return the sound duration in milliseconds
+ if (sounddata->sample_count > 0 && sounddata->sample_rate > 0) {
+ unsigned int ret = sounddata->sample_count /
sounddata->sample_rate * 100;
+ if (sounddata->stereo) ret = ret / 2;
+ return ret;
+ } else {
+ return 0;
+ }
+}
+
+unsigned int GST_sound_handler::get_position(int sound_handle)
+{
+ mutex::scoped_lock lock(_mutex);
+
+ // Check if the sound exists.
+ if (sound_handle < 0 || (unsigned int) sound_handle >=
m_sound_data.size())
+ {
+ // Invalid handle.
+ return 0;
+ }
+
+ sound_data* sounddata = m_sound_data[sound_handle];
+
+ // return the position of the last element added
+ GstElement *pipeline,*audiosink;
+ GstStateChangeReturn ret;
+ GstState current, pending;
+ int64_t pos;
+ GstFormat fmt = GST_FORMAT_TIME;
+
+
pipeline=sounddata->m_gst_elements[sounddata->m_gst_elements.size()-1]->pipeline;
+
+ ret = gst_element_get_state (GST_ELEMENT (pipeline), ¤t,
&pending, 0);
+
+ if (current != GST_STATE_NULL) {
+
audiosink=sounddata->m_gst_elements[sounddata->m_gst_elements.size()-1]->audiosink;
+ if (gst_element_query_position (pipeline, &fmt, &pos)) {
+ return static_cast<unsigned int>(pos / GST_MSECOND);
+ } else {
+ return 0;
+ }
+ }
+}
+
// Pointer handling and checking functions
uint8_t* gst_elements::get_data_ptr(unsigned long int pos) {
assert(data_size > pos);
Index: backend/sound_handler_gst.h
===================================================================
RCS file: /sources/gnash/gnash/backend/sound_handler_gst.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- backend/sound_handler_gst.h 23 Jul 2007 22:22:25 -0000 1.12
+++ backend/sound_handler_gst.h 27 Jul 2007 15:09:41 -0000 1.13
@@ -177,8 +177,15 @@
/// Gnash calls this to get the mute state.
virtual bool is_muted();
+ /// Gets the duration in milliseconds of an event sound connected to an
AS Sound obejct.
+ virtual unsigned int get_duration(int sound_handle);
+
+ /// Gets the playhead position in milliseconds of an event sound
connected to an AS Soound obejct.
+ virtual unsigned int get_position(int sound_handle);
+
virtual void attach_aux_streamer(aux_streamer_ptr ptr, void* owner);
//vv
virtual void detach_aux_streamer(void* owner); //vv
+
};
} // namespace gnash
Index: backend/sound_handler_sdl.cpp
===================================================================
RCS file: /sources/gnash/gnash/backend/sound_handler_sdl.cpp,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -b -r1.75 -r1.76
--- backend/sound_handler_sdl.cpp 23 Jul 2007 22:22:25 -0000 1.75
+++ backend/sound_handler_sdl.cpp 27 Jul 2007 15:09:41 -0000 1.76
@@ -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.75 2007/07/23 22:22:25 strk Exp $
+// $Id: sound_handler_sdl.cpp,v 1.76 2007/07/27 15:09:41 tgc Exp $
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -535,6 +535,53 @@
}
+unsigned int SDL_sound_handler::get_duration(int sound_handle)
+{
+ mutex::scoped_lock lock(_mutex);
+
+ // Check if the sound exists.
+ if (sound_handle < 0 || (unsigned int) sound_handle >=
m_sound_data.size())
+ {
+ // Invalid handle.
+ return 0;
+ }
+
+ sound_data* sounddata = m_sound_data[sound_handle];
+
+ // Return the sound duration in milliseconds
+ if (sounddata->sample_count > 0 && sounddata->sample_rate > 0) {
+ unsigned int ret = sounddata->sample_count /
sounddata->sample_rate * 100;
+ if (sounddata->stereo) ret = ret / 2;
+ return ret;
+ } else {
+ return 0;
+ }
+}
+
+unsigned int SDL_sound_handler::get_position(int sound_handle)
+{
+ mutex::scoped_lock lock(_mutex);
+
+ // Check if the sound exists.
+ if (sound_handle < 0 || (unsigned int) sound_handle >=
m_sound_data.size())
+ {
+ // Invalid handle.
+ return 0;
+ }
+
+ sound_data* sounddata = m_sound_data[sound_handle];
+
+ // If there is no active sounds, return 0
+ if (sounddata->m_active_sounds.size() == 0) return 0;
+
+ // We use the first active sound of this.
+ active_sound* asound = sounddata->m_active_sounds[0];
+
+ // Return the playhead position in milliseconds
+ unsigned int ret = asound->samples_played / sounddata->sample_rate *
100;
+ if (sounddata->stereo) ret = ret / 2;
+ return ret;
+}
sound_handler*
create_sound_handler_sdl()
@@ -714,10 +761,7 @@
delete [] buf;
}
-#ifdef WIN32 // hack
- return;
-#endif
-
+ // Run through all the sounds.
for(uint32_t i=0; i < handler->m_sound_data.size(); i++) {
sound_data* sounddata = handler->m_sound_data[i];
for(uint32_t j = 0; j < sounddata->m_active_sounds.size(); j++)
{
@@ -747,6 +791,7 @@
if (index < buffer_length) {
sound->loop_count--;
sound->raw_position = 0;
+ sound->samples_played = 0;
unsigned int mix_length =
((buffer_length - index) > sound->raw_data_size ? sound->raw_data_size :
(buffer_length - index));
do_mixing(stream+index, sound,
sound->get_raw_data_ptr(sound->raw_position),
mix_length,
sounddata->volume);
@@ -765,6 +810,7 @@
if (sound->data_size == sound->position
&& sound->loop_count != 0) {
sound->loop_count--;
sound->position = 0;
+ sound->samples_played = 0;
}
// Test if we will get problems...
Should not happen...
Index: backend/sound_handler_sdl.h
===================================================================
RCS file: /sources/gnash/gnash/backend/sound_handler_sdl.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- backend/sound_handler_sdl.h 23 Jul 2007 22:22:25 -0000 1.30
+++ backend/sound_handler_sdl.h 27 Jul 2007 15:09:41 -0000 1.31
@@ -14,7 +14,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-// $Id: sound_handler_sdl.h,v 1.30 2007/07/23 22:22:25 strk Exp $
+// $Id: sound_handler_sdl.h,v 1.31 2007/07/27 15:09:41 tgc Exp $
#ifndef SOUND_HANDLER_SDL_H
#define SOUND_HANDLER_SDL_H
@@ -226,6 +226,12 @@
/// Gnash calls this to get the mute state.
virtual bool is_muted();
+ /// Gets the duration in milliseconds of an event sound connected to an
AS Sound obejct.
+ virtual unsigned int get_duration(int sound_handle);
+
+ /// Gets the playhead position in milliseconds of an event sound
connected to an AS Soound obejct.
+ virtual unsigned int get_position(int sound_handle);
+
virtual void attach_aux_streamer(aux_streamer_ptr ptr, void* owner);
//vv
virtual void detach_aux_streamer(void* owner); //vv
Index: server/asobj/SoundFfmpeg.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/SoundFfmpeg.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- server/asobj/SoundFfmpeg.cpp 6 Jul 2007 18:51:41 -0000 1.13
+++ server/asobj/SoundFfmpeg.cpp 27 Jul 2007 15:09:41 -0000 1.14
@@ -165,10 +165,7 @@
}
break;
- case CODEC_TYPE_VIDEO:
- case CODEC_TYPE_DATA:
- case CODEC_TYPE_SUBTITLE:
- case CODEC_TYPE_UNKNOWN:
+ default:
log_error(_("Non-audio data (type %d) found in
file %s"),
enc->codec_type, so->externalURL.c_str());
@@ -430,7 +427,7 @@
sound_handler* s = get_sound_handler();
if (s != NULL)
{
- if (si > -1) {
+ if (si < 0) {
if (externalSound) {
s->detach_aux_streamer(this);
} else {
@@ -445,6 +442,17 @@
unsigned int
SoundFfmpeg::getDuration()
{
+
+ // If this is a event sound get the info from the soundhandler
+ if (!externalSound) {
+ sound_handler* s = get_sound_handler();
+ if (s) {
+ return (s->get_duration(soundId));
+ } else {
+ return 0; // just in case
+ }
+ }
+
// Return the duration of the file in milliseconds
if (formatCtx && audioIndex) {
return static_cast<unsigned int>(formatCtx->duration * 1000);
@@ -456,6 +464,16 @@
unsigned int
SoundFfmpeg::getPosition()
{
+ // If this is a event sound get the info from the soundhandler
+ if (!externalSound) {
+ sound_handler* s = get_sound_handler();
+ if (s) {
+ return s->get_position(soundId);
+ } else {
+ return 0; // just in case
+ }
+ }
+
// Return the position in the file in milliseconds
if (formatCtx && audioIndex) {
double time =
(double)formatCtx->streams[audioIndex]->time_base.num /
formatCtx->streams[audioIndex]->time_base.den *
(double)formatCtx->streams[audioIndex]->cur_dts;
Index: server/asobj/SoundGst.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/SoundGst.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- server/asobj/SoundGst.cpp 1 Jul 2007 10:54:31 -0000 1.9
+++ server/asobj/SoundGst.cpp 27 Jul 2007 15:09:41 -0000 1.10
@@ -284,7 +284,7 @@
sound_handler* s = get_sound_handler();
if (s != NULL)
{
- if (si > -1) {
+ if (si < 0) {
if (externalSound) {
gst_element_set_state (GST_ELEMENT (pipeline),
GST_STATE_NULL);
} else {
@@ -300,6 +300,17 @@
SoundGst::getDuration()
{
// Return the duration of the file in milliseconds
+
+ // If this is a event sound get the info from the soundhandler
+ if (!externalSound) {
+ sound_handler* s = get_sound_handler();
+ if (s) {
+ return (s->get_duration(soundId));
+ } else {
+ return 0; // just in case
+ }
+ }
+
GstFormat fmt = GST_FORMAT_TIME;
int64_t len;
@@ -314,6 +325,17 @@
SoundGst::getPosition()
{
// Return the position in the file in milliseconds
+
+ // If this is a event sound get the info from the soundhandler
+ if (!externalSound) {
+ sound_handler* s = get_sound_handler();
+ if (s) {
+ return s->get_position(soundId);
+ } else {
+ return 0; // just in case
+ }
+ }
+
if (!pipeline) return 0;
GstFormat fmt = GST_FORMAT_TIME;
Index: server/asobj/SoundGst.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/SoundGst.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- server/asobj/SoundGst.h 1 Jul 2007 10:54:31 -0000 1.4
+++ server/asobj/SoundGst.h 27 Jul 2007 15:09:41 -0000 1.5
@@ -40,7 +40,20 @@
class SoundGst : public Sound {
public:
-
+ SoundGst()
+ :
+ pipeline(NULL),
+ audiosink(NULL),
+ source(NULL),
+ decoder(NULL),
+ volume(NULL),
+ audioconv(NULL),
+ setupThread(NULL),
+ lock(NULL),
+ inputPos(0),
+ isAttached(false),
+ remainingLoops(0)
+ {}
~SoundGst();
void loadSound(std::string file, bool streaming);
Index: server/asobj/SoundMad.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/SoundMad.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- server/asobj/SoundMad.cpp 23 Jul 2007 22:07:59 -0000 1.11
+++ server/asobj/SoundMad.cpp 27 Jul 2007 15:09:41 -0000 1.12
@@ -327,11 +327,11 @@
SoundMad::~SoundMad() {
if (leftOverData && leftOverSize) delete[] leftOverData;
+ if (isAttached) {
mad_synth_finish(&synth);
mad_frame_finish(&frame);
mad_stream_finish(&stream);
- if (isAttached) {
sound_handler* s = get_sound_handler();
if (s) {
s->detach_aux_streamer(this);
@@ -400,7 +400,7 @@
sound_handler* s = get_sound_handler();
if (s != NULL)
{
- if (si > -1) {
+ if (si < 0) {
if (externalSound) {
s->detach_aux_streamer(this);
} else {
@@ -415,6 +415,16 @@
unsigned int
SoundMad::getDuration()
{
+ // If this is a event sound get the info from the soundhandler
+ if (!externalSound) {
+ sound_handler* s = get_sound_handler();
+ if (s) {
+ return (s->get_duration(soundId));
+ } else {
+ return 0; // just in case
+ }
+ }
+
// Return the duration of the file in milliseconds
/* if (formatCtx && audioIndex) {
return static_cast<unsigned int>(formatCtx->duration * 1000);
@@ -427,12 +437,19 @@
unsigned int
SoundMad::getPosition()
{
- // Return the position in the file in milliseconds
- if (1) {
- return inputPos/bitrate/8*1000;
+
+ // If this is a event sound get the info from the soundhandler
+ if (!externalSound) {
+ sound_handler* s = get_sound_handler();
+ if (s) {
+ return s->get_position(soundId);
} else {
- return 0;
+ return 0; // just in case
}
+ }
+
+ // Return the position in the file in milliseconds
+ return inputPos/bitrate/8*1000;
}
} // end of gnash namespace
Index: server/asobj/SoundMad.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/SoundMad.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- server/asobj/SoundMad.h 1 Jul 2007 10:54:31 -0000 1.4
+++ server/asobj/SoundMad.h 27 Jul 2007 15:09:41 -0000 1.5
@@ -40,7 +40,17 @@
class SoundMad : public Sound {
public:
-
+ SoundMad()
+ :
+ inputPos(0),
+ setupThread(NULL),
+ lock(NULL),
+ bitrate(0),
+ leftOverData(NULL),
+ leftOverSize(0),
+ isAttached(false),
+ remainingLoops(0)
+ {}
~SoundMad();
void loadSound(std::string file, bool streaming);
Index: server/swf/tag_loaders.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/swf/tag_loaders.cpp,v
retrieving revision 1.116
retrieving revision 1.117
diff -u -b -r1.116 -r1.117
--- server/swf/tag_loaders.cpp 1 Jul 2007 10:54:36 -0000 1.116
+++ server/swf/tag_loaders.cpp 27 Jul 2007 15:09:42 -0000 1.117
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: tag_loaders.cpp,v 1.116 2007/07/01 10:54:36 bjacques Exp $ */
+/* $Id: tag_loaders.cpp,v 1.117 2007/07/27 15:09:42 tgc Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -1233,6 +1233,7 @@
case sound_handler::FORMAT_MP3:
case sound_handler::FORMAT_NELLYMOSER:
case sound_handler::FORMAT_NATIVE16:
+ case sound_handler::FORMAT_NELLYMOSER_8HZ_MONO:
break;
}
@@ -1389,6 +1390,7 @@
in->read((char *)data, data_bytes);
break;
+ case sound_handler::FORMAT_NELLYMOSER_8HZ_MONO:
case sound_handler::FORMAT_NELLYMOSER:
// One day...
in->skip_bytes(data_bytes);
- [Gnash-commit] gnash ChangeLog backend/sound_handler.h backend...,
Tomas Groth <=