From 870168f3d54355c7bbb2fc7e4c4b97e73e4b61e6 Mon Sep 17 00:00:00 2001 From: Jeremy Simon Date: Fri, 1 Mar 2002 17:25:42 +0000 Subject: adding TIMESTAMP to buffer ( work with goom now ;) adding AUTHORS code cleanup Original commit message from CVS: adding TIMESTAMP to buffer ( work with goom now ;) adding AUTHORS code cleanup --- gst/modplug/gstmodplug.cc | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/gst/modplug/gstmodplug.cc b/gst/modplug/gstmodplug.cc index 180b9c5b6..5b251c7f2 100644 --- a/gst/modplug/gstmodplug.cc +++ b/gst/modplug/gstmodplug.cc @@ -16,6 +16,14 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ + +/* + Code based on modplugxmms + XMMS plugin: + Kenton Varda + Sound Engine: + Olivier Lapicque +*/ #include "libmodplug/stdafx.h" #include "libmodplug/sndfile.h" @@ -28,9 +36,11 @@ GstElementDetails modplug_details = { "ModPlug", "Audio/Module", - "Module decoder based on modplug engine from (Olivier ..)", + "Module decoder based on modplug engine", VERSION, - "Jeremy SIMON ", + "Jeremy SIMON " + "Kenton Varda " + "Olivier Lapicque ", "(C) 2001" }; @@ -260,7 +270,7 @@ gst_modplug_setup (GstModPlug *modplug) modplug->mSoundFile->SetWaveConfig ( modplug->frequency, 8, modplug->channel ); modplug->mSoundFile->SetWaveConfigEx ( modplug->surround, !modplug->oversamp, modplug->reverb, true, modplug->megabass, modplug->noise_reduction, false ); - modplug->mSoundFile->SetResamplingMode ( SRCMODE_SPLINE ); + modplug->mSoundFile->SetResamplingMode ( SRCMODE_POLYPHASE ); if ( modplug->surround ) modplug->mSoundFile->SetSurroundParameters( modplug->surround_depth, modplug->surround_delay ); @@ -281,6 +291,7 @@ gst_modplug_loop (GstElement *element) GstModPlug *modplug; GstBuffer *buffer_in, *buffer_out; gint mode16bits; + guint64 total_samples, sync_point; g_return_if_fail (element != NULL); g_return_if_fail (GST_IS_MODPLUG (element)); @@ -334,14 +345,14 @@ gst_modplug_loop (GstElement *element) "rate", GST_PROPS_INT (modplug->frequency), "channels", GST_PROPS_INT (modplug->channel))); - modplug->length = 512000 / modplug->frequency + 1; - modplug->length *= modplug->frequency; - modplug->length /= 1000; - modplug->length *= modplug->channel; + modplug->length = 1152 * modplug->channel; + if ( modplug->_16bit ) modplug->length *= 2; modplug->audiobuffer = (guchar *) g_malloc( modplug->length ); + total_samples = 0; + sync_point = 0; do { if( modplug->mSoundFile->Read ( modplug->audiobuffer, modplug->length ) != 0 ) @@ -349,14 +360,18 @@ gst_modplug_loop (GstElement *element) buffer_out = gst_buffer_new(); GST_BUFFER_DATA( buffer_out ) = (guchar *) g_memdup( modplug->audiobuffer, modplug->length ); GST_BUFFER_SIZE( buffer_out ) = modplug->length; - - gst_pad_push( srcpad, buffer_out ); + + total_samples+=1152; + GST_BUFFER_TIMESTAMP( buffer_out ) = total_samples * 1000000LL / modplug->frequency; + + gst_pad_push( srcpad, buffer_out ); gst_element_yield (element); } else { + free( modplug->audiobuffer ); gst_element_set_eos (GST_ELEMENT (modplug)); - gst_pad_push (modplug->srcpad, GST_BUFFER (gst_event_new (GST_EVENT_EOS))); + gst_pad_push (modplug->srcpad, GST_BUFFER (gst_event_new (GST_EVENT_EOS))); } } while ( 1 ); -- cgit v1.2.1