[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog backend/Makefile.am backend/sou...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog backend/Makefile.am backend/sou... |
Date: |
Mon, 31 Jul 2006 21:49:43 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 06/07/31 21:49:43
Modified files:
. : ChangeLog
backend : Makefile.am sound_handler_sdl.cpp
server : Makefile.am
Added files:
backend : sound_handler_mp3.cpp
Removed files:
server : sound_handler_mp3.cpp
Log message:
* backend/Makefile.am, backend/sound_handler_mp3.cpp,
backend/sound_handler_sdl.cpp, server/Makefile.am,
server/sound_handler_mp3.cpp:
Moved sound_handler_mp3 from server/ to backend/,
enabled build (needs --enable-sound=sdl --enable-mp3)
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.563&r2=1.564
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/Makefile.am?cvsroot=gnash&r1=1.29&r2=1.30
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/sound_handler_sdl.cpp?cvsroot=gnash&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/sound_handler_mp3.cpp?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/server/Makefile.am?cvsroot=gnash&r1=1.53&r2=1.54
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sound_handler_mp3.cpp?cvsroot=gnash&r1=1.12&r2=0
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.563
retrieving revision 1.564
diff -u -b -r1.563 -r1.564
--- ChangeLog 31 Jul 2006 20:35:03 -0000 1.563
+++ ChangeLog 31 Jul 2006 21:49:43 -0000 1.564
@@ -1,8 +1,16 @@
2006-07-31 Sandro Santilli <address@hidden>
+ * backend/Makefile.am, backend/sound_handler_mp3.cpp,
+ backend/sound_handler_sdl.cpp, server/Makefile.am,
+ server/sound_handler_mp3.cpp:
+ Moved sound_handler_mp3 from server/ to backend/,
+ enabled build (needs --enable-sound=sdl --enable-mp3)
* configure.ac: disable sound by default, set nogo=true
when sdl sound is requested but dependencies are not
met (bug#17225)
+
+2006-07-31 Sandro Santilli <address@hidden>
+
* gui/Makefile.am, gui/NullGui.cpp, gui/NullGui.h,
gui/gnash.cpp, gui/gui.h:
Moved NullGui class into its own files, implemented
Index: backend/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/backend/Makefile.am,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- backend/Makefile.am 29 Jul 2006 23:12:53 -0000 1.29
+++ backend/Makefile.am 31 Jul 2006 21:49:43 -0000 1.30
@@ -90,8 +90,12 @@
if USE_SOUND_GST
SOUND_SOURCES = sound_handler_gst.cpp
endif
+
if USE_SOUND_SDL
SOUND_SOURCES = sound_handler_sdl.cpp
+if MP3
+SOUND_SOURCES += sound_handler_mp3.cpp
+endif
endif
libgnashbackend_la_SOURCES = \
Index: backend/sound_handler_sdl.cpp
===================================================================
RCS file: /sources/gnash/gnash/backend/sound_handler_sdl.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- backend/sound_handler_sdl.cpp 26 Jul 2006 21:49:05 -0000 1.15
+++ backend/sound_handler_sdl.cpp 31 Jul 2006 21:49:43 -0000 1.16
@@ -148,13 +148,13 @@
convert_mp3_data(&adjusted_data,
&adjusted_size, data, sample_count, 0, sample_rate, stereo);
}
#else
- log_error("mp3 format sound requested; this demo does
not handle mp3\n");
+ log_error("SDL sound handler: mp3 sound requested, but
MAD support was not compiled in\n");
#endif
break;
default:
// Unhandled format.
- log_error("unknown format sound requested; this demo
does not handle it\n");
+ log_error("SDL sound handler: unknown format sound
requested\n");
break;
}
Index: server/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/server/Makefile.am,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -b -r1.53 -r1.54
--- server/Makefile.am 30 Jul 2006 15:54:00 -0000 1.53
+++ server/Makefile.am 31 Jul 2006 21:49:43 -0000 1.54
@@ -68,12 +68,6 @@
$(DMALLOC_CFLAGS) \
$(LIBXML_CFLAGS)
-if MP3
-MP3_CFLAGS = $(MAD_CFLAGS)
-MP3_LIBS = $(MAD_LIBS)
-MP3_HANDLER = sound_handler_mp3.cpp
-endif
-
libgnashserver_la_SOURCES = \
as_object.cpp \
as_value.cpp \
@@ -119,7 +113,7 @@
swf/ASHandlers.cpp \
swf/TagLoadersTable.cpp \
swf/tag_loaders.cpp \
- types.cpp $(MP3_HANDLER)
+ types.cpp
noinst_HEADERS = \
action.h \
@@ -190,8 +184,7 @@
libgnashserver_la_LIBADD = \
$(ZLIB_LIBS) \
- $(LIBXML_LIBS) \
- $(MP3_LIBS)
+ $(LIBXML_LIBS)
# $(OPENGL_LIBS)
#libserver_la_LDFLAGS = -module -avoid-version -no-undefined
Index: backend/sound_handler_mp3.cpp
===================================================================
RCS file: backend/sound_handler_mp3.cpp
diff -N backend/sound_handler_mp3.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ backend/sound_handler_mp3.cpp 31 Jul 2006 21:49:43 -0000 1.1
@@ -0,0 +1,231 @@
+/*
+ * sound_handler_mp3.cpp -- tbp, 2003
+ *
+ * This source code has been donated to the Public Domain.
+ * Do whatever you want with it.
+ *
+ * Some brain damaged helpers to decode mp3 streams for use in
+ * a gnash::sound_handler that uses SDL_mixer for output.
+ * (even comments are cut&paste compliant)
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifndef HAVE_MAD_H
+#error "You need to have the libmad development package installed\
+to compile this file. You can either reconfigure without --enable-mp3,\
+ or install libmad0-dev (using apt-get) or libmad (using yum)."
+#else
+
+#include "gnash.h"
+#include "container.h"
+#include "log.h"
+
+#include <SDL_mixer.h>
+
+#include <mad.h>
+#ifdef _MSC_VER
+ #pragma comment(lib, "libmad")
+ #define snprintf _snprintf
+#endif
+
+using gnash::log_error;
+using gnash::log_parse;
+
+namespace mad_helpers {
+ static const char *parse_layer(const mad_header& h)
+ {
+ switch(h.layer) {
+ case MAD_LAYER_I: return "I";
+ case MAD_LAYER_II: return "II";
+ case MAD_LAYER_III: return "III";
+ default: return "bogus";
+ }
+ }
+
+ static const char *parse_channel_mode(const mad_header& h)
+ {
+ switch (h.mode) {
+ case MAD_MODE_SINGLE_CHANNEL:
+ return "single channel";
+ case MAD_MODE_DUAL_CHANNEL:
+ return "dual channel";
+ case MAD_MODE_JOINT_STEREO:
+ return "joint (MS/intensity) stereo";
+ case MAD_MODE_STEREO:
+ return "normal LR stereo";
+ default:
+ return "bogus";
+ }
+ }
+
+ static const char *parse_emphasis(const mad_header& h)
+ {
+ switch (h.emphasis) {
+ case MAD_EMPHASIS_NONE:
+ return "none";
+ case MAD_EMPHASIS_50_15_US:
+ return "50/15 us";
+ case MAD_EMPHASIS_CCITT_J_17:
+ return "CCITT J.17";
+ default:
+ return "bogus";
+ }
+ }
+
+#if 1
+ static const char* parse_frame_info(const mad_header& h)
+ {
+ static char buf[1024];
+ size_t len = 1024;
+
+ snprintf(buf, len, "%lu kb/s audio mpeg layer %s "
+ "stream crc [%s] mode '%s' with '%s' "
+ "emphasis at %u Hz sample rate",
+ h.bitrate, parse_layer(h),
+ (h.flags&MAD_FLAG_PROTECTION) ? "X" : " ",
+ parse_channel_mode(h), parse_emphasis(h),
+ h.samplerate);
+ buf[len-1] = 0;
+ return buf;
+ }
+#endif
+
+ template <const unsigned int stride> static void
pcm_fixed_to_native(const mad_fixed_t *src, int16_t *dst, const unsigned int
count)
+ {
+ assert(count > 0);
+ unsigned int
+ dec = count,
+ idx = 0;
+ do {
+ dst[idx*stride] = src[idx] >> (MAD_F_FRACBITS-15); //
no fancy dithering...
+ ++idx;
+ } while (--dec);
+ }
+
+}
+
+// some intermediary buffer to hold a frame worth of samples
+// fugly.
+struct pcm_buff_t {
+ //enum { frame_payload = 1152 };
+ int16_t *samples;
+ unsigned int count;
+
+ ~pcm_buff_t() {
+ delete samples;
+ }
+
+ // from mad fixed point to native 16 bits in a temp. buffer
+ unsigned int transmogrify(const mad_synth &synth, const bool stereo) {
+ count = synth.pcm.length;
+ if (stereo) {
+ samples = new int16_t[count*2];
+
mad_helpers::pcm_fixed_to_native<2>(&synth.pcm.samples[0][0], &samples[0],
count);
+
mad_helpers::pcm_fixed_to_native<2>(&synth.pcm.samples[1][0], &samples[1],
count);
+ return count * 2;
+ }
+ else {
+ samples = new int16_t[count];
+
mad_helpers::pcm_fixed_to_native<1>(&synth.pcm.samples[0][0], samples, count);
+ return count;
+ }
+ }
+
+ void *collate(void *p, const bool stereo) const
+ {
+ const unsigned int bytes = count * (stereo ? 2 : 1) *
sizeof(int16_t);
+ memcpy(p, samples, bytes);
+ return (void *) (((char *)p) + bytes); // geez
+ }
+};
+
+// there's quite some (useless) copying around since there's no infrastructure
+// for streaming and we need to decode it all at once
+void convert_mp3_data(int16_t **adjusted_data, int *adjusted_size, void *data,
+ const int sample_count, const int /*sample_size*/,
+ const int sample_rate, const bool stereo)
+{
+
+ //log_msg("convert_mp3_data sample count %d rate %d stereo %s\n",
sample_count, sample_rate, stereo?"yes":"no");
+
+ mad_stream stream;
+ mad_frame frame;
+ mad_synth synth;
+ mad_timer_t timer;
+
+ mad_stream_init(&stream);
+ mad_frame_init(&frame);
+ mad_synth_init(&synth);
+ mad_timer_reset(&timer);
+
+ // decode stream
+ mad_stream_buffer(&stream, (const unsigned char *)data, sample_count);
+ stream.error = MAD_ERROR_NONE;
+
+ // decode frames
+ unsigned int fc = 0, total = 0;
+ std::vector<pcm_buff_t *> out; // holds decoded frames
+
+ while (true)
+ {
+ if (mad_frame_decode(&frame, &stream)) {
+ // there's always some garbage in front of the buffer
+ // so i guess, it's not so garbagish. anyway, skip.
+ if (fc == 0 && stream.error == MAD_ERROR_LOSTSYNC)
+ {
+ continue;
+ }
+ else
+ {
+ // kludge as we stop decoding on LOSTSYNC.
+ if (stream.error != MAD_ERROR_LOSTSYNC)
+ {
+ log_error("** MP3 frame error: %s\n",
mad_stream_errorstr(&stream));
+ }
+ break;
+ }
+ }
+
+ if (fc == 0)
+ {
+ log_parse("%s",
mad_helpers::parse_frame_info(frame.header));
+ }
+
+ ++fc;
+ mad_timer_add(&timer,frame.header.duration);
+
+ mad_synth_frame(&synth,&frame);
+ pcm_buff_t *pcm = new pcm_buff_t;
+ total += pcm->transmogrify(synth, stereo);
+ out.push_back(pcm);
+ }
+
+ if (total == 0) goto cleanup; // yay
+
+ log_parse("decoded frames %d bytes %d(diff %d) -- original rate
%d\n\n", fc, total, total - sample_count, sample_rate);
+
+ // assemble together all decoded frames. another round of memcpy.
+ {
+ void *p = new int16_t[total];
+ *adjusted_data = (int16_t*) p;
+ *adjusted_size = total * sizeof(int16_t);
+ // stuff all that crap together
+ {for (unsigned int i=0; i<out.size(); ++i)
+ p = out[i]->collate(p,stereo);
+ }
+ }
+
+cleanup:
+ {for (unsigned int i=0; i<out.size(); ++i) delete out[i]; }
+ mad_synth_finish(&synth);
+ mad_frame_finish(&frame);
+ mad_stream_finish(&stream);
+}
+
+// HAVE_MAD_H
+#endif
+
Index: server/sound_handler_mp3.cpp
===================================================================
RCS file: server/sound_handler_mp3.cpp
diff -N server/sound_handler_mp3.cpp
--- server/sound_handler_mp3.cpp 27 Jul 2006 21:00:55 -0000 1.12
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,231 +0,0 @@
-/*
- * sound_handler_mp3.cpp -- tbp, 2003
- *
- * This source code has been donated to the Public Domain.
- * Do whatever you want with it.
- *
- * Some brain damaged helpers to decode mp3 streams for use in
- * a gnash::sound_handler that uses SDL_mixer for output.
- * (even comments are cut&paste compliant)
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#ifndef HAVE_MAD_H
-#error "You need to have the libmad development package installed\
-to compile this file. You can either reconfigure without --enable-mp3,\
- or install libmad0-dev (using apt-get) or libmad (using yum)."
-#else
-
-#include "gnash.h"
-#include "container.h"
-#include "log.h"
-
-#include <SDL_mixer.h>
-
-#include <mad.h>
-#ifdef _MSC_VER
- #pragma comment(lib, "libmad")
- #define snprintf _snprintf
-#endif
-
-using gnash::log_error;
-using gnash::log_parse;
-
-namespace mad_helpers {
- static const char *parse_layer(const mad_header& h)
- {
- switch(h.layer) {
- case MAD_LAYER_I: return "I";
- case MAD_LAYER_II: return "II";
- case MAD_LAYER_III: return "III";
- default: return "bogus";
- }
- }
-
- static const char *parse_channel_mode(const mad_header& h)
- {
- switch (h.mode) {
- case MAD_MODE_SINGLE_CHANNEL:
- return "single channel";
- case MAD_MODE_DUAL_CHANNEL:
- return "dual channel";
- case MAD_MODE_JOINT_STEREO:
- return "joint (MS/intensity) stereo";
- case MAD_MODE_STEREO:
- return "normal LR stereo";
- default:
- return "bogus";
- }
- }
-
- static const char *parse_emphasis(const mad_header& h)
- {
- switch (h.emphasis) {
- case MAD_EMPHASIS_NONE:
- return "none";
- case MAD_EMPHASIS_50_15_US:
- return "50/15 us";
- case MAD_EMPHASIS_CCITT_J_17:
- return "CCITT J.17";
- default:
- return "bogus";
- }
- }
-
-#if 1
- static const char* parse_frame_info(const mad_header& h)
- {
- static char buf[1024];
- size_t len = 1024;
-
- snprintf(buf, len, "%lu kb/s audio mpeg layer %s "
- "stream crc [%s] mode '%s' with '%s' "
- "emphasis at %u Hz sample rate",
- h.bitrate, parse_layer(h),
- (h.flags&MAD_FLAG_PROTECTION) ? "X" : " ",
- parse_channel_mode(h), parse_emphasis(h),
- h.samplerate);
- buf[len-1] = 0;
- return buf;
- }
-#endif
-
- template <const unsigned int stride> static void
pcm_fixed_to_native(const mad_fixed_t *src, int16_t *dst, const unsigned int
count)
- {
- assert(count > 0);
- unsigned int
- dec = count,
- idx = 0;
- do {
- dst[idx*stride] = src[idx] >> (MAD_F_FRACBITS-15); //
no fancy dithering...
- ++idx;
- } while (--dec);
- }
-
-}
-
-// some intermediary buffer to hold a frame worth of samples
-// fugly.
-struct pcm_buff_t {
- //enum { frame_payload = 1152 };
- int16_t *samples;
- unsigned int count;
-
- ~pcm_buff_t() {
- delete samples;
- }
-
- // from mad fixed point to native 16 bits in a temp. buffer
- unsigned int transmogrify(const mad_synth &synth, const bool stereo) {
- count = synth.pcm.length;
- if (stereo) {
- samples = new int16_t[count*2];
-
mad_helpers::pcm_fixed_to_native<2>(&synth.pcm.samples[0][0], &samples[0],
count);
-
mad_helpers::pcm_fixed_to_native<2>(&synth.pcm.samples[1][0], &samples[1],
count);
- return count * 2;
- }
- else {
- samples = new int16_t[count];
-
mad_helpers::pcm_fixed_to_native<1>(&synth.pcm.samples[0][0], samples, count);
- return count;
- }
- }
-
- void *collate(void *p, const bool stereo) const
- {
- const unsigned int bytes = count * (stereo ? 2 : 1) *
sizeof(int16_t);
- memcpy(p, samples, bytes);
- return (void *) (((char *)p) + bytes); // geez
- }
-};
-
-// there's quite some (useless) copying around since there's no infrastructure
-// for streaming and we need to decode it all at once
-void convert_mp3_data(int16_t **adjusted_data, int *adjusted_size, void *data,
- const int sample_count, const int /*sample_size*/,
- const int sample_rate, const bool stereo)
-{
-
- //log_msg("convert_mp3_data sample count %d rate %d stereo %s\n",
sample_count, sample_rate, stereo?"yes":"no");
-
- mad_stream stream;
- mad_frame frame;
- mad_synth synth;
- mad_timer_t timer;
-
- mad_stream_init(&stream);
- mad_frame_init(&frame);
- mad_synth_init(&synth);
- mad_timer_reset(&timer);
-
- // decode stream
- mad_stream_buffer(&stream, (const unsigned char *)data, sample_count);
- stream.error = MAD_ERROR_NONE;
-
- // decode frames
- unsigned int fc = 0, total = 0;
- std::vector<pcm_buff_t *> out; // holds decoded frames
-
- while (true)
- {
- if (mad_frame_decode(&frame, &stream)) {
- // there's always some garbage in front of the buffer
- // so i guess, it's not so garbagish. anyway, skip.
- if (fc == 0 && stream.error == MAD_ERROR_LOSTSYNC)
- {
- continue;
- }
- else
- {
- // kludge as we stop decoding on LOSTSYNC.
- if (stream.error != MAD_ERROR_LOSTSYNC)
- {
- log_error("** MP3 frame error: %s\n",
mad_stream_errorstr(&stream));
- }
- break;
- }
- }
-
- if (fc == 0)
- {
- log_parse("%s",
mad_helpers::parse_frame_info(frame.header));
- }
-
- ++fc;
- mad_timer_add(&timer,frame.header.duration);
-
- mad_synth_frame(&synth,&frame);
- pcm_buff_t *pcm = new pcm_buff_t;
- total += pcm->transmogrify(synth, stereo);
- out.push_back(pcm);
- }
-
- if (total == 0) goto cleanup; // yay
-
- log_parse("decoded frames %d bytes %d(diff %d) -- original rate
%d\n\n", fc, total, total - sample_count, sample_rate);
-
- // assemble together all decoded frames. another round of memcpy.
- {
- void *p = new int16_t[total];
- *adjusted_data = (int16_t*) p;
- *adjusted_size = total * sizeof(int16_t);
- // stuff all that crap together
- {for (unsigned int i=0; i<out.size(); ++i)
- p = out[i]->collate(p,stereo);
- }
- }
-
-cleanup:
- {for (unsigned int i=0; i<out.size(); ++i) delete out[i]; }
- mad_synth_finish(&synth);
- mad_frame_finish(&frame);
- mad_stream_finish(&stream);
-}
-
-// HAVE_MAD_H
-#endif
-
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog backend/Makefile.am backend/sou...,
Sandro Santilli <=