From a81af1142aba2c30b3be3a08ae5f0eb6f5d155f7 Mon Sep 17 00:00:00 2001 From: august black Date: Sun, 30 Oct 2011 18:02:26 +0000 Subject: minor changes, add stress tester for obscure buzzing bug svn path=/trunk/externals/august/readanysf~/; revision=15685 --- Makefile.win | 47 +++++++++++++++++++++++++++++++++++ jamesdunn_buzz_stresstest.pd | 53 ++++++++++++++++++++++++++++++++++++++++ src/readanysf~.cpp | 58 ++++++++++++++++++++++++-------------------- 3 files changed, 132 insertions(+), 26 deletions(-) create mode 100644 Makefile.win create mode 100644 jamesdunn_buzz_stresstest.pd diff --git a/Makefile.win b/Makefile.win new file mode 100644 index 0000000..b9c2ad9 --- /dev/null +++ b/Makefile.win @@ -0,0 +1,47 @@ +GAVLPREFIX=/usr/local +PD_INCLUDES=/usr/local/include +GMERLIN_LIBS= -lgmerlin_avdec -lgavl.dll -lpng -lz -lintl -liconv -lws2_32 -lflac -lwsock32 -lregex -ldl \ + -logg -lvorbis -lvorbisenc -la52 -ldca -lspeex -ltiff -ltheora -lfaad + + +# SHOULDN'T REALLY NEED TO EDIT BELOW HERE + +VERSION=0.43 + +PD_PATH = $(shell cd "$(PROGRAMFILES)"/pd && pwd) +GAVLPATH=$(GAVLPREFIX)/include + +STRIP=strip --strip-unneeded -R .note -R .comment + +LDFLAGS = -s -shared -Wl,--enable-auto-import +LDFLAGS += -L$(GAVLPREFIX)/lib -L"$(PD_PATH)/src" -L"$(PD_PATH)/bin" -L"$(PD_PATH)/obj" +LDFLAGS += -lpd -lwsock32 -lkernel32 -luser32 -lgdi32 -lpthreadGC2 $(GMERLIN_LIBS) + + +CFLAGS = -I./ -I$(GAVLPATH) -I$(GAVLPATH)/gavl -I$(GAVLPATH)/gmerlin -I$(PD_INCLUDES) \ + -Wall -Wno-unused -Wunused-variable -Wno-trigraphs -g -I. -mms-bitfields -DNT -DPD -fPIC + + +all: pd_win + +pd_win: src/readanysf~.cpp objs/FifoVideoFrames.o objs/FifoAudioFrames.o objs/ReadMedia.o + g++ -o readanysf~.dll \ + src/readanysf~.cpp \ + objs/FifoAudioFrames.o \ + objs/FifoVideoFrames.o \ + objs/ReadMedia.o $(CFLAGS) $(LDFLAGS) + $(STRIP) readanysf~.dll + +objs/ReadMedia.o: src/ReadMedia.cpp src/ReadMedia.h objs/FifoAudioFrames.o objs/FifoVideoFrames.o + g++ -c -o objs/ReadMedia.o src/ReadMedia.cpp $(CFLAGS) + +objs/FifoAudioFrames.o: src/FifoAudioFrames.cpp src/FifoAudioFrames.h + g++ -c -o objs/FifoAudioFrames.o src/FifoAudioFrames.cpp $(CFLAGS) + +objs/FifoVideoFrames.o: src/FifoVideoFrames.cpp src/FifoVideoFrames.h + g++ -c -o objs/FifoVideoFrames.o src/FifoVideoFrames.cpp $(CFLAGS) + +clean: + if [ -d readanysf~$(VERSION)_MacOSX-Intel ]; then rm -rf readanysf~$(VERSION)_MacOSX-Intel; fi; + if [ -f readanysf~$(VERSION)_MacOSX-Intel.tar.gz ]; then rm -rf readanysf~$(VERSION)_MacOSX-Intel.tar.gz; fi; + rm diff --git a/jamesdunn_buzz_stresstest.pd b/jamesdunn_buzz_stresstest.pd new file mode 100644 index 0000000..77d0ca1 --- /dev/null +++ b/jamesdunn_buzz_stresstest.pd @@ -0,0 +1,53 @@ +#N canvas 560 185 516 458 10; +#X obj 100 192 readanysf~ 2; +#X msg 40 106 open Gunfire.wav; +#X obj 100 411 dac~; +#X obj 101 373 *~; +#X obj 134 374 *~; +#X msg 104 162 play; +#X msg 145 162 stop; +#X obj 199 281 vsl 15 50 0 1 0 0 empty empty empty 0 -9 0 10 -257985 +-1 -1 1470 1; +#X msg 199 339 \$1 50; +#X obj 198 358 line~; +#X obj 396 247 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 +-1 -1; +#X obj 169 216 route ready samplerate length cache float bang; +#X obj 40 23 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1 1 +; +#X obj 178 245 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 +-1 -1; +#X obj 40 60 metro 300; +#X obj 386 42 loadbang; +#X msg 349 98 \; pd dsp 1; +#X msg 421 102 0.3; +#X msg 259 42 1; +#X floatatom 318 301 0 0 0 0 - - -; +#X obj 318 276 + 1; +#X obj 261 277 float; +#X connect 0 0 3 0; +#X connect 0 1 4 0; +#X connect 0 2 11 0; +#X connect 1 0 0 0; +#X connect 3 0 2 0; +#X connect 4 0 2 1; +#X connect 5 0 0 0; +#X connect 6 0 0 0; +#X connect 7 0 8 0; +#X connect 8 0 9 0; +#X connect 9 0 4 1; +#X connect 9 0 3 1; +#X connect 11 0 13 0; +#X connect 11 5 10 0; +#X connect 12 0 14 0; +#X connect 13 0 5 0; +#X connect 13 0 21 0; +#X connect 14 0 1 0; +#X connect 15 0 16 0; +#X connect 15 0 17 0; +#X connect 15 0 18 0; +#X connect 17 0 7 0; +#X connect 18 0 12 0; +#X connect 20 0 19 0; +#X connect 20 0 21 1; +#X connect 21 0 20 0; diff --git a/src/readanysf~.cpp b/src/readanysf~.cpp index 6358dfe..f6482bc 100644 --- a/src/readanysf~.cpp +++ b/src/readanysf~.cpp @@ -36,6 +36,9 @@ #define MAXSFCHANS 64 // got this from d_soundfile.c in pd/src +#define OPENCB_READY 1 +#define OPENCB_BADFILE 2 + static t_class *readanysf_class; @@ -51,6 +54,7 @@ typedef struct readanysf { unsigned int tick; // how often to send outlet info bool play; bool is_opening; + unsigned int spit_out_info; unsigned int count; float src_factor; @@ -182,7 +186,6 @@ void m_init_audio( t_readanysf *x) { void m_open_callback( void * data) { - t_atom lst; t_readanysf * x = (t_readanysf *)data; pthread_mutex_lock(&x->mut); @@ -194,34 +197,15 @@ void m_open_callback( void * data) { pthread_mutex_lock(&x->mut); m_init_audio(x); x->is_opening=false; + x->spit_out_info = OPENCB_READY; // set variable so that dsp cycle can send out the right info pthread_mutex_unlock(&x->mut); - // FIXME: is it safe to call these here? - SETFLOAT(&lst, (float)x->rm->getAudioSamplerate() ); - outlet_anything(x->outinfo, gensym("samplerate"), 1, &lst); - - SETFLOAT(&lst, x->rm->getLengthInSeconds() ); - outlet_anything(x->outinfo, gensym("length"), 1, &lst); - - outlet_float(x->outinfo, 0.0); - - // ready should be last - SETFLOAT(&lst, 1.0 ); - outlet_anything(x->outinfo, gensym("ready"), 1, &lst); - // set time to 0 again here just to be sure + // set time to 0 again here just to be sure } else { pthread_mutex_lock(&x->mut); x->is_opening=false; + x->spit_out_info = OPENCB_BADFILE; pthread_mutex_unlock(&x->mut); - - SETFLOAT(&lst, 0.0 ); - outlet_anything(x->outinfo, gensym("samplerate"), 1, &lst); - SETFLOAT(&lst, 0.0 ); - outlet_anything(x->outinfo, gensym("length"), 1, &lst); - SETFLOAT(&lst, 0.0 ); - outlet_anything(x->outinfo, gensym("ready"), 1, &lst); - outlet_float(x->outinfo, 0.0); - post("readanysf~: Invalid file or unsupported codec."); } } @@ -291,6 +275,7 @@ static void *readanysf_new(t_float f, t_float f2, t_float f3 ) { x->tick = 1000; x->play =false; x->is_opening=false; + x->spit_out_info =0; x->count = 0; x->src_factor = 1.0; x->do_t2o_audio_convert = false; @@ -423,7 +408,6 @@ static t_int *readanysf_perform(t_int *w) { int samples_returned = 0; t_atom lst; - if (x->play ) { // play protects the memory accessed in m_decode_block samples_returned = m_decode_block( x ); if (samples_returned == 0 ) { // EOF @@ -431,9 +415,8 @@ static t_int *readanysf_perform(t_int *w) { outlet_bang(x->outinfo); } else if (samples_returned == -1) { // error in getting audio, normally from seeking - post("readanysf~: error on m_decode_block inside perform()"); samples_returned=0; - } + } } for (i = 0; i < x->num_channels; i++) { @@ -442,6 +425,29 @@ static t_int *readanysf_perform(t_int *w) { } } + if (x->spit_out_info == OPENCB_READY) { + SETFLOAT(&lst, (float)x->rm->getAudioSamplerate() ); + outlet_anything(x->outinfo, gensym("samplerate"), 1, &lst); + SETFLOAT(&lst, x->rm->getLengthInSeconds() ); + outlet_anything(x->outinfo, gensym("length"), 1, &lst); + outlet_float(x->outinfo, 0.0); + // ready should be last + SETFLOAT(&lst, 1.0 ); + outlet_anything(x->outinfo, gensym("ready"), 1, &lst); + x->spit_out_info = 0; + } + + if (x->spit_out_info == OPENCB_BADFILE) { + SETFLOAT(&lst, 0.0 ); + outlet_anything(x->outinfo, gensym("samplerate"), 1, &lst); + SETFLOAT(&lst, 0.0 ); + outlet_anything(x->outinfo, gensym("length"), 1, &lst); + SETFLOAT(&lst, 0.0 ); + outlet_anything(x->outinfo, gensym("ready"), 1, &lst); + outlet_float(x->outinfo, 0.0); + post("readanysf~: Invalid file or unsupported codec."); + x->spit_out_info = 0; + } // just set some variables if ( ++x->count > x->tick ) { -- cgit v1.2.1