readanysf~0.43/0000775000175000017500000000000012017704610013137 5ustar augustaugustreadanysf~0.43/READMEmacpkg.txt0000664000175000017500000000050212017676342016027 0ustar augustaugust http://aug.ment.org/readanysf/ by August Black -- To install, drag the readanysf~ folder and anysndfiler.pd to /Library/Pd. Then you can create [readanysf~] anywhere you need it. If /Library/Pd does not exist, just create it. This build put together by Hans-Christoph Steiner, post to the pd-list with questions. readanysf~0.43/screengrab0.40.png0000664000175000017500000007505412017676342016307 0ustar augustaugustPNG  IHDR}b sRGB pHYst$qtIME!*tEXtCommentCreated with GIMPW IDATxweUy}M S@؀D4$ $b4bb]cH0QQ1XP@T3 S^r3sf.g>^}z5R\WzݹErDžt^n/]{;޹ yEowQj' k (rmrxߙY3=wmdgun Q,w&Ǯ[~YgGOPYu]@WO|W.LӞٰj1oVݷPLqs_- ~~|g.H*;7uwǪccnr^3oԀdh?f[?! c3?0iќݺᛟ? eS/`y{7#}*my[* NZuRRsԿ_&z;7,_ZZmj㯞|OYDk*5 Jz]Dd}l|r)GohOy׆w|;[^CK=m73wȃYQn1eyWΐ/bJE˘\}x*ʾ_?{>vk^K<'P­N.-åӏ^#"R5gt~UXT+iY6^򷵷hUD{jaݯ,̛\QTCSmiǚ]?|GJDDVw垮[iQov'фWl+ETJw4v 8.%-c}|YD#FQk ޵MϽ>~Vww 푓=SunY/>}sYK_=<2>GS*:R i;y/9c9IG7{JIs_9ww#j3#OovfWw@@:cRjjmWvNm]A=w9nojgXYDjC^/ky #gҡ^;&i^/k5x껧8,co14xֿ\CD#b7E{WoܩhA2̏r|?~~,]VٸO{Sk'J]#^ck{zM:.zmÏ_7qQu桷~cꠈH餯g"zڵ~(No^୿d[~c'+Cy~mW,;;lݖUa9%/h!fޣ_wŝo䡹JĖ iNzQsW-_K?߸q];='?|]F{yiH[nzI9uTCdxtsyܱ?،É2y|v~];6Qc+noJ]fc_kow{>tzpCu^ߔ߿wrozznsJ=u?2sv(M|K|`;`|?te«g'wu{6ois;Uj]yf,])M8m_\uo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n,ߟk羗Nyh1\$IOo(}`c+ HܶW4gb#r }y=]QiAuߣYyU4hϙ/ߴOmB8&`.37 no,Qj38t_.Zh-oIg:uφem"qMss m"褼M@=4玗fjlytNHںe˗7 @97{K6qJ'/. _ge˧YA>ӛ. @  ?wOmIFWJ6|>Bmy4~`uPhnUW>P42r1J yR#"6$])d6GiijqZ<lI v~A] GigА26e8@{).7]]I.[Z4g\$mtD3qvA̪.Ot/u6ͭ4?3> @K-?p'̅bg0#@pegY?]3~hFR} 48\<^X϶IgDJ?lc$fx;_#sapA.%֪!k})w:UQOI[ %/^oRxȞ˜Y'5K_ ,w6AȕY$'TWݵe_J'NX< `3ַ5H[4! 0uIc2.R 6Y37sd۽jEJ } _zͅ :uYن=벍qFξ|w>y@ɼ~?|oPm3._իlҧs;R6F] ,^KoWJM;R$s0Kyzzsap(`rDy1jFt HRAsT?w3 t]`IZBu/ +x|)/lXo(ge8P|fZh, wGSUi䕚k4{.,Rœ׿M鿞WLW̌IGy&j맃$kǯїZoE*ot~5A w'gt)4lHX| gd_̆ #X~%ydvomC*$MufWr6ˤlRkeWWBߖ.R]T.YrTцˆAaф yLu:ūo jVԞݔ%-ufVDj֋H @Ɓ3$;uD9)zacA 1ܯ#|n}aACAb "@b ϥ*N/AL \M|Dt+gW-r@i޻_7@K2@S^pp`@eſ]멋ܢ3J!ʬq?6Џ:C5~/V XIv1Y1P?{yC~EBb pH(~EB#b _ 6ꯞ䧷GWhAKy#saϯ| z>1!O( ~&@"!2 (iHT5D?bl$$y*?9Xo{G. Q[+ozw?}/?'|[]4 pm߽/zxxo~W?:%}/~?|/͛7|G~u??<||wp%⓮>;/|ͷ~﫟}||Ƿ)eIENDB`readanysf~0.43/jamesdunn_buzz_stresstest.pd0000664000175000017500000000247112017676342021043 0ustar augustaugust#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; readanysf~0.43/embed-MacOSX-dependencies.sh0000775000175000017500000000532512017676342020305 0ustar augustaugust#!/bin/sh # # This script finds all of the dependecies from Fink and included them into # current folder so that it becomes a libdir to be installed into /Library/Pd. # PD_APP_LIB=$1 echo " " for pd_darwin in `find . -name '*.pd_darwin'`; do LIBS=`otool -L $pd_darwin | sed -n 's|.*/sw/lib/\(.*\.dylib\).*|\1|p'` if [ "x$LIBS" != "x" ]; then echo "`echo $pd_darwin | sed 's|.*/\(.*\.pd_darwin$\)|\1|'` is using:" for lib in $LIBS; do echo " $lib" install -vp /sw/lib/$lib $PD_APP_LIB new_lib=`echo $lib | sed 's|.*/\(.*\.dylib\)|\1|'` install_name_tool -id @loader_path/$new_lib $PD_APP_LIB/$new_lib install_name_tool -change /sw/lib/$lib @loader_path/$new_lib $pd_darwin done echo " " fi done for dylib in $PD_APP_LIB/*.dylib; do LIBS=`otool -L $dylib | sed -n 's|.*/sw/lib/\(.*\.dylib\).*|\1|p'` if [ "x$LIBS" != "x" ]; then echo "`echo $dylib | sed 's|.*/\(.*\.dylib\)|\1|'` is using:" for lib in $LIBS; do echo " $lib" new_lib=`echo $lib | sed 's|.*/\(.*\.dylib\)|\1|'` if [ -e $PD_APP_LIB/$new_lib ]; then echo "$PD_APP_LIB/$new_lib already exists, skipping copy." else install -vp /sw/lib/$lib $PD_APP_LIB fi install_name_tool -id @loader_path/$new_lib $PD_APP_LIB/$new_lib install_name_tool -change /sw/lib/$lib @loader_path/$new_lib $dylib done echo " " fi done # run it one more time to catch dylibs that depend on dylibs for dylib in $PD_APP_LIB/*.dylib; do LIBS=`otool -L $dylib | sed -n 's|.*/sw/lib/\(.*\.dylib\).*|\1|p'` if [ "x$LIBS" != "x" ]; then echo "`echo $dylib | sed 's|.*/\(.*\.dylib\)|\1|'` is using:" for lib in $LIBS; do echo " $lib" new_lib=`echo $lib | sed 's|.*/\(.*\.dylib\)|\1|'` if [ -e $PD_APP_LIB/$new_lib ]; then echo "$PD_APP_LIB/$new_lib already exists, skipping copy." else install -vp /sw/lib/$lib $PD_APP_LIB fi install_name_tool -id @loader_path/$new_lib $PD_APP_LIB/$new_lib install_name_tool -change /sw/lib/$lib @loader_path/$new_lib $dylib done echo " " fi done # seems like we need it one last time! phew... for dylib in $PD_APP_LIB/*.dylib; do LIBS=`otool -L $dylib | sed -n 's|.*/sw/lib/\(.*\.dylib\).*|\1|p'` if [ "x$LIBS" != "x" ]; then echo "`echo $dylib | sed 's|.*/\(.*\.dylib\)|\1|'` is using:" for lib in $LIBS; do echo " $lib" new_lib=`echo $lib | sed 's|.*/\(.*\.dylib\)|\1|'` if [ -e $PD_APP_LIB/$new_lib ]; then echo "$PD_APP_LIB/$new_lib already exists, skipping copy." else install -vp /sw/lib/$lib $PD_APP_LIB fi install_name_tool -id @loader_path/$new_lib $PD_APP_LIB/$new_lib install_name_tool -change /sw/lib/$lib @loader_path/$new_lib $dylib done echo " " fi done readanysf~0.43/README0000664000175000017500000000277412017676342014043 0ustar augustaugustreadanysf~, a puredata external for reading multiple file formats. ----------------------------------------------------------------- © august black 2003 - 2010 licensed under the GNU GPL v2 see: http://aug.ment.org/readanysf/ you will need: o Gavl : by Burkhard Plaum Low level multimedia API. http://gmerlin.sf.net/ cvs -d:pserver:anonymous@gmerlin.cvs.sourceforge.net:/cvsroot/gmerlin login cvs -z3 -d:pserver:anonymous@gmerlin.cvs.sourceforge.net:/cvsroot/gmerlin co -P gavl cd gavl/ ./autogen.sh ./configure --without-doxygen make sudo make install o Gmerlin_avdecode : by Burkhard Plaum Gmerlin_avdecoder is a general purpose media decoding library. http://gmerlin.sourceforge.net cvs -d:pserver:anonymous@gmerlin.cvs.sourceforge.net:/cvsroot/gmerlin login cvs -z3 -d:pserver:anonymous@gmerlin.cvs.sourceforge.net:/cvsroot/gmerlin co -P gmerlin_avdecoder cd gmerlin_avdecoder ./autogen.sh ./configure --without-doxygen make sudo make install After installing gavl and gmerlin_avdecode, you should just be able to type make. ---------------------------------------------------------------------------------------- Mac users: you can install gavl/gmerlin-avdecoder either by source as above with linux or through fink. then, do "make" and let me know if it doesn't work readanysf~0.43/.svn/0000775000175000017500000000000012017703635014031 5ustar augustaugustreadanysf~0.43/.svn/props/0000775000175000017500000000000012017676335015202 5ustar augustaugustreadanysf~0.43/.svn/prop-base/0000775000175000017500000000000012017676342015725 5ustar augustaugustreadanysf~0.43/.svn/prop-base/embed-MacOSX-dependencies.sh.svn-base0000444000175000017500000000003612017676342024561 0ustar augustaugustK 14 svn:executable V 1 * END readanysf~0.43/.svn/prop-base/screengrab0.40.png.svn-base0000444000175000017500000000006512017676342022562 0ustar augustaugustK 13 svn:mime-type V 24 application/octet-stream END readanysf~0.43/.svn/entries0000444000175000017500000000354012017703635015423 0ustar augustaugust10 dir 16184 https://pure-data.svn.sourceforge.net/svnroot/pure-data/trunk/externals/august/readanysf~ https://pure-data.svn.sourceforge.net/svnroot/pure-data 2011-10-30T18:02:26.448014Z 15685 augmentus df7eb9d6-776f-4174-a42d-0ffd8d5d5b5d READMEmacpkg.txt file 2012-08-30T14:46:58.251399Z d2476addcfcb4021f09459959d39789c 2010-07-28T09:14:17.977129Z 13732 augmentus 322 anysndfiler.pd file 2012-08-30T14:46:58.247399Z 9d68d7c21f3089a3e42a058d54d6280f 2010-07-28T09:14:17.977129Z 13732 augmentus 3400 readanysf~-meta.pd file 2012-08-30T14:46:58.247399Z 9904b2b5b954437256a34940f980ece6 2010-10-05T22:52:49.783687Z 14200 augmentus 201 screengrab0.40.png file 2012-08-30T14:46:58.251399Z 711a0a0a4108145f68b80eb688b9898c 2010-07-28T09:14:17.977129Z 13732 augmentus has-props 31276 embed-MacOSX-dependencies.sh file 2012-08-30T14:46:58.251399Z 6ac408ad51fe9a295f3b05a0f3462284 2011-10-27T02:07:29.056739Z 15660 eighthave has-props 2773 readanysf~-help.pd file 2012-08-30T14:46:58.251399Z ab4db7375ba78eab3d0c330ed630e42f 2010-11-01T05:18:52.115446Z 14251 augmentus 3767 jamesdunn_buzz_stresstest.pd file 2012-08-30T14:46:58.251399Z f388c53d4e0dcaaf65e13e44c1779edf 2011-10-30T18:02:26.448014Z 15685 augmentus 1337 src dir Makefile.win file 2012-08-30T14:46:58.251399Z b8e6dc83535a5a1c2f7573b418e8a477 2011-10-30T18:02:26.448014Z 15685 augmentus 1765 Makefile file 16185 2012-08-30T15:17:17.292419Z 539195709e2efecd631b370dbd864d84 2012-08-30T15:32:17.066167Z 16185 augmentus 3568 README file 2012-08-30T14:46:58.251399Z bbc8d4fde6875910b53564799aa10772 2010-07-28T09:14:17.977129Z 13732 augmentus 1532 readanysf~0.43/.svn/text-base/0000775000175000017500000000000012017703635015725 5ustar augustaugustreadanysf~0.43/.svn/text-base/jamesdunn_buzz_stresstest.pd.svn-base0000444000175000017500000000247112017676342025334 0ustar augustaugust#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; readanysf~0.43/.svn/text-base/READMEmacpkg.txt.svn-base0000444000175000017500000000050212017676342022320 0ustar augustaugust http://aug.ment.org/readanysf/ by August Black -- To install, drag the readanysf~ folder and anysndfiler.pd to /Library/Pd. Then you can create [readanysf~] anywhere you need it. If /Library/Pd does not exist, just create it. This build put together by Hans-Christoph Steiner, post to the pd-list with questions. readanysf~0.43/.svn/text-base/readanysf~-help.pd.svn-base0000444000175000017500000000726712017676342023103 0ustar augustaugust#N canvas 13 56 842 642 10; #X obj 28 367 dac~; #X obj 28 332 *~ 0; #X obj 69 332 *~ 0; #X obj 651 106 vsl 15 50 0.01 1.3 1 0 empty empty empty 0 -8 0 8 -241291 -1 -1 4411 0; #X msg 112 140 play; #X msg 193 139 pause; #X msg 348 121 speed \$1; #X floatatom 348 98 5 0 0 0 - - -; #X obj 588 15 loadbang; #X msg 390 75 1; #X msg 601 51 \; pd dsp 1 \;; #X floatatom 662 160 5 0 0 0 - - -; #X msg 12 126 open \$1; #X obj 12 98 openpanel; #X obj 12 66 bng 25 250 50 0 empty empty empty 17 7 0 10 -4032 -1 -1 ; #X msg 152 139 stop; #X floatatom 345 173 16 0 0 0 - - -; #X msg 345 193 pcm_seek \$1; #X obj 348 150 hsl 128 15 0 7.368e+06 0 0 empty empty empty -2 -8 0 10 -260818 -1 -1 0 1; #X msg 348 74 0.21; #X msg 78 73 open http://www.fro.at:8008/fro-64.ogg.m3u; #X floatatom 262 552 5 0 0 0 - - -; #X floatatom 308 504 5 0 0 0 - - -; #X floatatom 217 582 5 0 0 0 - - -; #X msg 722 253 loop \$1; #X obj 722 233 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 1; #X floatatom 353 467 5 0 0 0 - - -; #X obj 444 404 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #X obj 217 378 route ready samplerate length cache float bang; #X floatatom 399 435 5 0 0 0 - - -; #X text 262 581 ready: status for when a file is loaded and ready; #X text 306 594 to play. If you load a file from disk or; #X text 306 608 from the net \, it may take a while to load; #X text 305 621 depending on disk activity and net bandwidth.; #X text 394 466 cache: percentage (0.0->1.0) of; #X text 435 479 cache being used.; #X text 469 405 bang: end of file.; #X msg 588 87 0.8; #X obj 29 269 readanysf~ 4 32 256; #X obj 651 179 s v; #X obj 38 294 r v; #X obj 108 332 *~ 0; #X obj 149 332 *~ 0; #X text 671 130 Volume; #X text 217 300 <- readanysf~ has 3 possible creation args 1) number of channels (all channels will be up or down mixed accordingly) default is 2 channels. 2) number of "frames" in the internal buffer. Default=24 3) number of samples per frame in internal buffer. Default is your blocksize.; #X msg 98 96 open http://wnycam.streamguys.com; #X floatatom 494 176 16 0 0 0 - - -; #X obj 497 153 hsl 128 15 0 500 0 0 empty empty empty -2 -8 0 10 -260818 -1 -1 0 1; #X msg 494 196 time_seek \$1; #X msg 329 242 tick 100; #X text 404 231 send cache \, length output every X ticks; #X text 402 244 "tick 1" sends out every single dsp cycle; #X text 720 214 loop on/off; #X text 441 434 float: position of file in seconds; #X text 482 447 relative to the file's samplerate; #X text 347 503 length: total duration of file in seconds; #X text 394 529 (will be empty for network streams); #X text 396 516 relative to file's internal samplerate; #X text 320 553 The samplerate of the file being played.; #X text 168 5 readanysf~ by August Black; #X text 170 40 august@alien.mur.at; #X text 172 26 please send comments \, suggest \, bugs \, donations ->; #X connect 1 0 0 0; #X connect 2 0 0 1; #X connect 3 0 11 0; #X connect 3 0 39 0; #X connect 4 0 38 0; #X connect 5 0 38 0; #X connect 6 0 38 0; #X connect 7 0 6 0; #X connect 8 0 37 0; #X connect 8 0 10 0; #X connect 9 0 7 0; #X connect 12 0 38 0; #X connect 13 0 12 0; #X connect 14 0 13 0; #X connect 15 0 38 0; #X connect 16 0 17 0; #X connect 17 0 38 0; #X connect 18 0 16 0; #X connect 19 0 7 0; #X connect 20 0 38 0; #X connect 24 0 38 0; #X connect 25 0 24 0; #X connect 28 0 23 0; #X connect 28 1 21 0; #X connect 28 2 22 0; #X connect 28 3 26 0; #X connect 28 4 29 0; #X connect 28 5 27 0; #X connect 37 0 3 0; #X connect 38 0 1 0; #X connect 38 1 2 0; #X connect 38 2 41 0; #X connect 38 3 42 0; #X connect 38 4 28 0; #X connect 40 0 1 1; #X connect 40 0 2 1; #X connect 40 0 41 1; #X connect 40 0 42 1; #X connect 45 0 38 0; #X connect 46 0 48 0; #X connect 47 0 46 0; #X connect 48 0 38 0; #X connect 49 0 38 0; readanysf~0.43/.svn/text-base/Makefile.svn-base0000444000175000017500000000676012017703577021114 0ustar augustaugust# Edit these two variables to suit your system. # You need both gavl and gmerlin_avdec libs to compile GAVLPREFIX=/usr/local #GAVLPREFIX=/opt/gmerlin PD_INCLUDES=/usr/include # SHOULDN'T REALLY NEED TO EDIT BELOW HERE VERSION=0.43 UNAME := $(shell uname) ifneq ($(UNAME), Darwin) # simplistic approach to handle Debians non-linux architectures (kFreeBSD, # kHurd) the same as linux UNAME=Linux endif ifeq ($(UNAME), Linux) TARGET=pd_linux STRIP=strip --strip-unneeded PD_LDFLAGS = -L$(GAVLPREFIX)/lib -lgavl -lgmerlin_avdec -lpthread GAVLPATH=$(GAVLPREFIX)/include CXXFLAGS=-Wall PD_CXXFLAGS = -I./ -I$(GAVLPATH) -I$(GAVLPATH)/gavl -I$(GAVLPATH)/gmerlin -I$(PD_INCLUDES) else # assume darwin here GAVLPATH=/sw/include PD_INCLUDES=/Applications/Pd-extended.app/Contents/Resources/include/ TARGET=pd_darwin STRIP=strip -x PD_CXXFLAGS = -I./ -I$(GAVLPATH) -I$(GAVLPATH)/gavl -I$(GAVLPATH)/gmerlin -I$(PD_INCLUDES) PD_CXXFLAGS += -I/sw/include -fast PD_LDFLAGS = -bundle -undefined dynamic_lookup -L/sw/lib -lgavl -lgmerlin_avdec #PD_LDFLAGS += -bundle -bundle_loader $(pd_src)/bin/pd -undefined dynamic_lookup \ # -L/sw/lib -weak_framework Carbon -lc -L/sw/lib -lgavl -lgmerlin_avdec # os 10.4 #PD_CXXFLAGS += -mmacosx-version-min=10.4 -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk #PD_LDFLAGS = -L/sw/lib -lgavl -lgmerlin_avdec \ # -dynamiclib -undefined dynamic_lookup -lsupc++ -mmacosx-version-min=10.4 \ # -lSystem.B -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk endif ############################################## PD_CXXFLAGS += -fPIC PD_CXXFLAGS += $(CXXFLAGS) PD_LDFLAGS += $(LDFLAGS) all: $(TARGET) pd_linux: src/readanysf~.cpp objs/FifoVideoFrames.o objs/FifoAudioFrames.o objs/ReadMedia.o $(CXX) -shared -o readanysf~.pd_linux $(PD_CXXFLAGS) \ src/readanysf~.cpp \ objs/FifoAudioFrames.o \ objs/FifoVideoFrames.o \ objs/ReadMedia.o \ $(PD_LDFLAGS) $(STRIP) readanysf~.pd_linux pd_darwin: src/readanysf~.cpp objs/FifoVideoFrames.o objs/FifoAudioFrames.o objs/ReadMedia.o $(CXX) -o readanysf~.pd_darwin $(PD_CXXFLAGS) \ src/readanysf~.cpp \ objs/FifoAudioFrames.o \ objs/FifoVideoFrames.o \ objs/ReadMedia.o \ $(PD_LDFLAGS) $(STRIP) readanysf~.pd_darwin mkdir -p readanysf~$(VERSION)_MacOSX-Intel mkdir -p readanysf~$(VERSION)_MacOSX-Intel/readanysf~ cp readanysf~.pd_darwin readanysf~-help.pd readanysf~$(VERSION)_MacOSX-Intel/readanysf~ cp READMEmacpkg.txt anysndfiler.pd readanysf~$(VERSION)_MacOSX-Intel/ mv readanysf~$(VERSION)_MacOSX-Intel/READMEmacpkg.txt readanysf~$(VERSION)_MacOSX-Intel/README.txt ./embed-MacOSX-dependencies.sh readanysf~$(VERSION)_MacOSX-Intel/readanysf~ tar -cvf readanysf~$(VERSION)_MacOSX-Intel.tar readanysf~$(VERSION)_MacOSX-Intel/ gzip readanysf~$(VERSION)_MacOSX-Intel.tar objs/ReadMedia.o: src/ReadMedia.cpp src/ReadMedia.h objs/FifoAudioFrames.o objs/FifoVideoFrames.o objs/ $(CXX) -c -o objs/ReadMedia.o src/ReadMedia.cpp $(PD_CXXFLAGS) objs/FifoAudioFrames.o: src/FifoAudioFrames.cpp src/FifoAudioFrames.h objs/ $(CXX) -c -o objs/FifoAudioFrames.o src/FifoAudioFrames.cpp $(PD_CXXFLAGS) objs/FifoVideoFrames.o: src/FifoVideoFrames.cpp src/FifoVideoFrames.h objs/ $(CXX) -c -o objs/FifoVideoFrames.o src/FifoVideoFrames.cpp $(PD_CXXFLAGS) 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 -f objs/*.o readanysf~.pd_* rm -rf objs objs/: mkdir $@ readanysf~0.43/.svn/text-base/embed-MacOSX-dependencies.sh.svn-base0000444000175000017500000000532512017676342024573 0ustar augustaugust#!/bin/sh # # This script finds all of the dependecies from Fink and included them into # current folder so that it becomes a libdir to be installed into /Library/Pd. # PD_APP_LIB=$1 echo " " for pd_darwin in `find . -name '*.pd_darwin'`; do LIBS=`otool -L $pd_darwin | sed -n 's|.*/sw/lib/\(.*\.dylib\).*|\1|p'` if [ "x$LIBS" != "x" ]; then echo "`echo $pd_darwin | sed 's|.*/\(.*\.pd_darwin$\)|\1|'` is using:" for lib in $LIBS; do echo " $lib" install -vp /sw/lib/$lib $PD_APP_LIB new_lib=`echo $lib | sed 's|.*/\(.*\.dylib\)|\1|'` install_name_tool -id @loader_path/$new_lib $PD_APP_LIB/$new_lib install_name_tool -change /sw/lib/$lib @loader_path/$new_lib $pd_darwin done echo " " fi done for dylib in $PD_APP_LIB/*.dylib; do LIBS=`otool -L $dylib | sed -n 's|.*/sw/lib/\(.*\.dylib\).*|\1|p'` if [ "x$LIBS" != "x" ]; then echo "`echo $dylib | sed 's|.*/\(.*\.dylib\)|\1|'` is using:" for lib in $LIBS; do echo " $lib" new_lib=`echo $lib | sed 's|.*/\(.*\.dylib\)|\1|'` if [ -e $PD_APP_LIB/$new_lib ]; then echo "$PD_APP_LIB/$new_lib already exists, skipping copy." else install -vp /sw/lib/$lib $PD_APP_LIB fi install_name_tool -id @loader_path/$new_lib $PD_APP_LIB/$new_lib install_name_tool -change /sw/lib/$lib @loader_path/$new_lib $dylib done echo " " fi done # run it one more time to catch dylibs that depend on dylibs for dylib in $PD_APP_LIB/*.dylib; do LIBS=`otool -L $dylib | sed -n 's|.*/sw/lib/\(.*\.dylib\).*|\1|p'` if [ "x$LIBS" != "x" ]; then echo "`echo $dylib | sed 's|.*/\(.*\.dylib\)|\1|'` is using:" for lib in $LIBS; do echo " $lib" new_lib=`echo $lib | sed 's|.*/\(.*\.dylib\)|\1|'` if [ -e $PD_APP_LIB/$new_lib ]; then echo "$PD_APP_LIB/$new_lib already exists, skipping copy." else install -vp /sw/lib/$lib $PD_APP_LIB fi install_name_tool -id @loader_path/$new_lib $PD_APP_LIB/$new_lib install_name_tool -change /sw/lib/$lib @loader_path/$new_lib $dylib done echo " " fi done # seems like we need it one last time! phew... for dylib in $PD_APP_LIB/*.dylib; do LIBS=`otool -L $dylib | sed -n 's|.*/sw/lib/\(.*\.dylib\).*|\1|p'` if [ "x$LIBS" != "x" ]; then echo "`echo $dylib | sed 's|.*/\(.*\.dylib\)|\1|'` is using:" for lib in $LIBS; do echo " $lib" new_lib=`echo $lib | sed 's|.*/\(.*\.dylib\)|\1|'` if [ -e $PD_APP_LIB/$new_lib ]; then echo "$PD_APP_LIB/$new_lib already exists, skipping copy." else install -vp /sw/lib/$lib $PD_APP_LIB fi install_name_tool -id @loader_path/$new_lib $PD_APP_LIB/$new_lib install_name_tool -change /sw/lib/$lib @loader_path/$new_lib $dylib done echo " " fi done readanysf~0.43/.svn/text-base/readanysf~-meta.pd.svn-base0000444000175000017500000000031112017676341023057 0ustar augustaugust#N canvas 15 49 200 200 10; #N canvas 15 49 420 300 META 0; #X text 10 10 VERSION 0.4; #X text 10 24 AUTHOR August Black ; #X text 11 39 NAME readanysf~; #X restore 10 10 pd META; readanysf~0.43/.svn/text-base/anysndfiler.pd.svn-base0000444000175000017500000000651012017676341022306 0ustar augustaugust#N canvas 403 78 800 378 10; #N canvas 314 180 836 579 loadfast 0; #X obj 398 364 switch~; #X obj 68 55 inlet; #X obj 304 95 loadbang; #X text 63 34 filename; #X obj 396 179 inlet; #X text 421 132 <--- upsampled by factor of 128 \, then switched off ; #X obj 50 401 tabwrite~ \$0-samp-1; #X obj 209 399 tabwrite~ \$0-samp-2; #X msg 396 202 set 64 1 \$1 \, 0; #X msg 304 129 set 64 1 128 \, 0; #X msg 68 110 open \$1; #X msg 511 346 0; #X msg 309 332 1; #X obj 414 403 print starting; #X obj 549 360 print stoping; #X obj 277 281 select 1; #X obj 534 320 t b b; #X floatatom 480 294 5 0 0 0 - - -; #X obj 562 293 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #X msg 111 183 play; #X obj 480 264 route ready bang samplerate length; #X floatatom 597 299 5 0 0 0 - - -; #X floatatom 656 300 5 0 0 0 - - -; #X msg 701 416 resize \$1; #X obj 701 467 s \$0-samp-2; #X obj 701 443 s \$0-samp-1; #X obj 68 247 readanysf~ 2 12 1024; #X obj 699 181 inlet; #X obj 698 337 f; #X obj 671 369 *; #X floatatom 671 392 14 0 0 0 - - -; #X obj 602 427 print size; #X floatatom 716 371 5 0 0 0 - - -; #X obj 277 303 t b b b b; #X obj 655 334 f; #X obj 602 325 t b b; #X obj 580 514 outlet; #X connect 1 0 10 0; #X connect 2 0 9 0; #X connect 4 0 8 0; #X connect 8 0 0 0; #X connect 10 0 26 0; #X connect 11 0 0 0; #X connect 11 0 36 0; #X connect 12 0 0 0; #X connect 12 0 13 0; #X connect 15 0 33 0; #X connect 16 0 11 0; #X connect 16 1 14 0; #X connect 19 0 26 0; #X connect 20 0 15 0; #X connect 20 0 17 0; #X connect 20 1 16 0; #X connect 20 1 18 0; #X connect 20 2 21 0; #X connect 20 3 22 0; #X connect 22 0 34 1; #X connect 23 0 24 0; #X connect 23 0 25 0; #X connect 26 0 6 0; #X connect 26 1 7 0; #X connect 26 2 20 0; #X connect 27 0 28 1; #X connect 28 0 29 1; #X connect 28 0 32 0; #X connect 29 0 30 0; #X connect 30 0 31 0; #X connect 30 0 23 0; #X connect 33 0 6 0; #X connect 33 0 7 0; #X connect 33 1 19 0; #X connect 33 2 12 0; #X connect 33 3 35 0; #X connect 34 0 29 0; #X connect 35 0 34 0; #X connect 35 1 28 0; #X restore 118 186 pd loadfast; #X obj 151 221 bng 15 250 50 0 empty empty done 17 7 1 10 -262144 -1 -1; #X obj 79 71 openpanel; #X msg 79 49 bang; #X obj 413 206 * 44100; #X floatatom 413 145 5 0 0 1 buffer_length_in_seconds - -; #X msg 413 235 resize \$1; #X msg 459 183 22050; #X msg 508 183 44100; #X text 569 185 choose file samplerate; #X obj 79 244 timer; #X obj 79 129 t b a; #X floatatom 79 275 10 0 0 0 - - -; #X obj 413 60 loadbang; #X msg 449 93 \; pd dsp 1; #X msg 413 124 8; #X obj 79 107 symbol; #X msg 152 71 bang; #X floatatom 185 138 5 0 0 0 - - -; #X msg 152 93 64; #X msg 185 94 128; #X msg 218 93 512; #X msg 253 93 1024; #X msg 339 222 const 0; #X obj 507 261 table \$0-samp-1; #X obj 507 287 table \$0-samp-2; #X obj 413 286 s \$0-samp-2; #X obj 413 262 s \$0-samp-1; #X obj 262 140 samplerate~; #X connect 0 0 1 0; #X connect 2 0 16 0; #X connect 3 0 2 0; #X connect 4 0 6 0; #X connect 5 0 4 0; #X connect 6 0 26 0; #X connect 6 0 27 0; #X connect 7 0 4 1; #X connect 8 0 4 1; #X connect 10 0 12 0; #X connect 11 0 10 0; #X connect 11 1 0 0; #X connect 13 0 15 0; #X connect 13 0 14 0; #X connect 13 0 28 0; #X connect 15 0 5 0; #X connect 16 0 11 0; #X connect 17 0 16 0; #X connect 18 0 0 1; #X connect 19 0 18 0; #X connect 20 0 18 0; #X connect 21 0 18 0; #X connect 22 0 18 0; #X connect 23 0 26 0; #X connect 23 0 27 0; #X connect 28 0 0 2; readanysf~0.43/.svn/text-base/screengrab0.40.png.svn-base0000444000175000017500000007505412017676342022600 0ustar augustaugustPNG  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~hFR} 48\<^X϶IgDJ?lc$fx;_#sapA.%֪!k})w:UQOI[ %/^oRxȞ˜Y'5K_ ,w6AȕY$'TWݵe_J'NX< `3ַ5H[4! 0uIc2.R 6Y37sd۽jEJ } _zͅ :uYن=벍qFξ|w>y@ɼ~?|oPm3._իlҧs;R6F] ,^KoWJM;R$s0Kyzzsap(`rDy1jFt HRAsT?w3 t]`IZBu/ +x|)/lXo(ge8P|fZh, wGSUi䕚k4{.,Rœ׿M鿞WLW̌IGy&j맃$kǯїZoE*ot~5A w'gt)4lHX| gd_̆ #X~%ydvomC*$MufWr6ˤlRkeWWBߖ.R]T.YrTцˆAaф yLu:ūo jVԞݔ%-ufVDj֋H @Ɓ3$;uD9)zacA 1ܯ#|n}aACAb "@b ϥ*N/AL \M|Dt+gW-r@i޻_7@K2@S^pp`@eſ]멋ܢ3J!ʬq?6Џ:C5~/V XIv1Y1P?{yC~EBb pH(~EB#b _ 6ꯞ䧷GWhAKy#saϯ| z>1!O( ~&@"!2 (iHT5D?bl$$y*?9Xo{G. Q[+ozw?}/?'|[]4 pm߽/zxxo~W?:%}/~?|/͛7|G~u??<||wp%⓮>;/|ͷ~﫟}||Ƿ)eIENDB`readanysf~0.43/.svn/text-base/README.svn-base0000444000175000017500000000277412017676342020334 0ustar augustaugustreadanysf~, a puredata external for reading multiple file formats. ----------------------------------------------------------------- © august black 2003 - 2010 licensed under the GNU GPL v2 see: http://aug.ment.org/readanysf/ you will need: o Gavl : by Burkhard Plaum Low level multimedia API. http://gmerlin.sf.net/ cvs -d:pserver:anonymous@gmerlin.cvs.sourceforge.net:/cvsroot/gmerlin login cvs -z3 -d:pserver:anonymous@gmerlin.cvs.sourceforge.net:/cvsroot/gmerlin co -P gavl cd gavl/ ./autogen.sh ./configure --without-doxygen make sudo make install o Gmerlin_avdecode : by Burkhard Plaum Gmerlin_avdecoder is a general purpose media decoding library. http://gmerlin.sourceforge.net cvs -d:pserver:anonymous@gmerlin.cvs.sourceforge.net:/cvsroot/gmerlin login cvs -z3 -d:pserver:anonymous@gmerlin.cvs.sourceforge.net:/cvsroot/gmerlin co -P gmerlin_avdecoder cd gmerlin_avdecoder ./autogen.sh ./configure --without-doxygen make sudo make install After installing gavl and gmerlin_avdecode, you should just be able to type make. ---------------------------------------------------------------------------------------- Mac users: you can install gavl/gmerlin-avdecoder either by source as above with linux or through fink. then, do "make" and let me know if it doesn't work readanysf~0.43/.svn/text-base/Makefile.win.svn-base0000444000175000017500000000334512017676342021703 0ustar augustaugustGAVLPREFIX=/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 readanysf~0.43/.svn/all-wcprops0000444000175000017500000000300412017703635016210 0ustar augustaugustK 25 svn:wc:ra_dav:version-url V 67 /svnroot/pure-data/!svn/ver/15685/trunk/externals/august/readanysf~ END anysndfiler.pd K 25 svn:wc:ra_dav:version-url V 82 /svnroot/pure-data/!svn/ver/13732/trunk/externals/august/readanysf~/anysndfiler.pd END readanysf~-meta.pd K 25 svn:wc:ra_dav:version-url V 86 /svnroot/pure-data/!svn/ver/14200/trunk/externals/august/readanysf~/readanysf~-meta.pd END screengrab0.40.png K 25 svn:wc:ra_dav:version-url V 86 /svnroot/pure-data/!svn/ver/13732/trunk/externals/august/readanysf~/screengrab0.40.png END embed-MacOSX-dependencies.sh K 25 svn:wc:ra_dav:version-url V 96 /svnroot/pure-data/!svn/ver/15660/trunk/externals/august/readanysf~/embed-MacOSX-dependencies.sh END readanysf~-help.pd K 25 svn:wc:ra_dav:version-url V 86 /svnroot/pure-data/!svn/ver/14251/trunk/externals/august/readanysf~/readanysf~-help.pd END jamesdunn_buzz_stresstest.pd K 25 svn:wc:ra_dav:version-url V 96 /svnroot/pure-data/!svn/ver/15685/trunk/externals/august/readanysf~/jamesdunn_buzz_stresstest.pd END Makefile.win K 25 svn:wc:ra_dav:version-url V 80 /svnroot/pure-data/!svn/ver/15685/trunk/externals/august/readanysf~/Makefile.win END Makefile K 25 svn:wc:ra_dav:version-url V 76 /svnroot/pure-data/!svn/ver/16185/trunk/externals/august/readanysf~/Makefile END README K 25 svn:wc:ra_dav:version-url V 74 /svnroot/pure-data/!svn/ver/13732/trunk/externals/august/readanysf~/README END READMEmacpkg.txt K 25 svn:wc:ra_dav:version-url V 84 /svnroot/pure-data/!svn/ver/13732/trunk/externals/august/readanysf~/READMEmacpkg.txt END readanysf~0.43/.svn/tmp/0000775000175000017500000000000012017703635014631 5ustar augustaugustreadanysf~0.43/.svn/tmp/props/0000775000175000017500000000000012017676335016002 5ustar augustaugustreadanysf~0.43/.svn/tmp/prop-base/0000775000175000017500000000000012017676335016527 5ustar augustaugustreadanysf~0.43/.svn/tmp/text-base/0000775000175000017500000000000012017703635016525 5ustar augustaugustreadanysf~0.43/Makefile.win0000664000175000017500000000334512017676342015412 0ustar augustaugustGAVLPREFIX=/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 readanysf~0.43/src/0000775000175000017500000000000012017676342013740 5ustar augustaugustreadanysf~0.43/src/ReadMedia.h0000664000175000017500000001270112017676342015725 0ustar augustaugust/* * Copyright (C) 2003-2010 August Black * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ifndef _READMEDIA_H_ #define _READMEDIA_H_ #include #include #include #include "FifoAudioFrames.h" #include "FifoVideoFrames.h" #ifndef _AVDEC_H_ #define _AVDEC_H_ extern "C" { #include } #endif #define STATE_EMPTY 0 #define STATE_OPENING 1 #define STATE_READY 2 #define SRC_MAX 256.0 #define SRC_MIN 1/256.0 #define CMD_START 3 #define CMD_NULL 0 #define CMD_OPEN 1 #define CMD_QUIT 2 #define SEEK_NOTHING -1 #define SEEK_REWIND -2 class ReadMedia { public: ReadMedia(); ~ReadMedia(); void openFile( char * filename, int vfifosize, int afifosize, int samples_per_frame); int decodeAudio( gavl_audio_frame_t *af); int decodeVideo( gavl_video_frame_t *vf); bool isReady(); // see if file is loaded or not bool getEOF(); bool rewind(); bool rewindNoFlush(); bool frameSeek(int64_t frames); bool pcmSeek(int64_t samples); bool timeSeek(double seconds); int getAudioSamplerate(); int getAudioChannelCount(); int getVideoTimescale(); double getLengthInSeconds(); gavl_time_t getLengthInGavlTime(); int64_t getLengthInAudioSamples(); int64_t getLengthInVideoFrames(); int getAudioStreamCount(); int getVideoStreamCount(); // this is used to sync AV frames void pealOffVideoFrames(int howmany); void dump() { lockState(); if (m_file != NULL) bgav_dump(m_file); unlockState(); }; double getATimeInSeconds(); double getVTimeInSeconds(); //float getTimeInSeconds(); float getAudioFifoSizePercentage(); void copyAudioFormat(gavl_audio_format_t * dst ); void copyVideoFormat(gavl_video_format_t * dst ); void setLoop( bool b); bool getLoop(); //||||||||||||||||||||||||||||||||||||||||||||||||||||||||| // NON-PUBLIC public functions //||||||||||||||||||||||||||||||||||||||||||||||||||||||||| int64_t pcmSeek(); int64_t frameSeek(); //bool seek(gavl_time_t gt); void killAVThreads(); bool startAVThreads(); void setAudioStreamCount(int s); void setVideoStreamCount(int s); FifoAudioFrames * getAudioFifo(); FifoVideoFrames * getVideoFifo(); bgav_t * getFile(); char * getFilename(); gavl_audio_frame_t * getAudioFrame(); gavl_video_frame_t * getVideoFrame(); void closeFile(); void clearFile(); void setState(int b); int getState(); gavl_audio_format_t * getAudioFormat() { return &m_audio_format;}; gavl_video_format_t * getVideoFormat() { return &m_video_format;}; void setCommand( int c); int getCommand(); void setAEOF(bool b); void setVEOF(bool b); bool getAEOF(); bool getVEOF(); int getSamplesPerFrame(); int lockAV(); int unlockAV(); //int lockAV(const char *s); //int unlockAV(const char *s); int lockState(); int unlockState(); //int lockState(const char *s); //int unlockState(const char *s); void waitA(); void waitV(); void signalAV(); void signalA(); void signalV(); void waitDispatch(); void signalDispatcher(); bool initFormat(); void setOpenCallback(void (*oc)(void *), void *v ); void callOpenCallback(); void setBufferCallback( bgav_buffer_callback bc, void *v ); bool quitAVThreads(); private: bool quit_av_threads; // callbacks for open, input buffer etc. void * m_open_callback_data; void (* m_open_callback)(void * v); bgav_buffer_callback m_buffer_callback; void * m_buffer_callback_data; // end of file for audio and video bool m_aeof; bool m_veof; // seek vars int64_t m_pcm_seek; int64_t m_frame_seek; double m_length_in_seconds; gavl_time_t m_length_in_gavltime; int64_t m_num_samples; int64_t m_num_frames; // command for dispatcher thread int m_cmd; // internal state of media reader and // current filename int m_state; char m_filename[1024]; bool m_loop; // current time of audio in seconds //double m_atime; //double m_vtime; int m_afifosize; int m_vfifosize; int m_audio_stream_count; int m_video_stream_count; bgav_t * m_file; bgav_options_t * m_opt; // audio stuff gavl_audio_frame_t * m_audio_frame; gavl_audio_format_t m_audio_format; //video stuff gavl_video_frame_t * m_video_frame; gavl_video_format_t m_video_format; FifoAudioFrames *m_fifoaudio; FifoVideoFrames *m_fifovideo; int m_audio_thread_ret; int m_video_thread_ret; int m_dispatcher_thread_ret; pthread_t m_thread_fillaudiofifo; pthread_t m_thread_fillvideofifo; pthread_t m_thread_dispatch; pthread_mutex_t m_condmut_a; pthread_mutex_t m_condmut_v; pthread_mutex_t m_condmut_dispatch; pthread_mutex_t m_state_mut; pthread_mutex_t m_av_mut; pthread_cond_t m_cond_a; pthread_cond_t m_cond_v; pthread_cond_t m_cond_dispatch; }; #endif readanysf~0.43/src/FifoVideoFrames.cpp0000664000175000017500000001043112017676342017453 0ustar augustaugust/* * Copyright (C) 2003-2010 August Black * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include "FifoVideoFrames.h" FifoVideoFrames::FifoVideoFrames(int s, gavl_video_format_t * f) { size = s ; start = 0 ; end = 0 ; count = 0; format = new gavl_video_format_t; gavl_video_format_copy(format, f); fifoPtr = new gavl_video_frame_t * [size] ; for(int i=0; i < size; i++) { fifoPtr[i] = gavl_video_frame_create( format ); } pthread_mutex_init (&mut, 0); } FifoVideoFrames::~FifoVideoFrames() { //printf("deleting fifo \n"); for(int i=0; i < size; i++) { gavl_video_frame_destroy( fifoPtr[i] ); } delete format; delete[] fifoPtr; pthread_mutex_destroy (&mut); //printf("deleted fifo \n"); } // empty the fifo of any content void FifoVideoFrames::Flush() { pthread_mutex_lock (&mut); start = 0 ; end = 0 ; count = 0; //printf("FifoVideoFrames::flushed size=%d\n", count); pthread_mutex_unlock (&mut); } // push an element onto the FifoVideoFrames bool FifoVideoFrames::Append( gavl_video_frame_t * source) { bool ret = false; //Dump("Appending a frame "); pthread_mutex_lock (&mut); if ( count < size ) { // if there is room for one more gavl_video_frame_copy(format, fifoPtr[end], source) ; fifoPtr[end]->timestamp = source->timestamp; fifoPtr[end]->duration = source->duration; if (++end >= size) end = 0; count++; ret = true; } // no room in fifo, return false pthread_mutex_unlock (&mut); //Dump("Appended a frame "); return ret; } // remove an element off the front FifoVideoFrames bool FifoVideoFrames::Get( ) { bool ret = false; pthread_mutex_lock (&mut); if ( count > 0 ) { // if there any items in the fifo if ( ++start >= size ) start = 0; count--; ret = true; } pthread_mutex_unlock (&mut); //Dump("Got a frame "); return ret; } // get an element off the FifoVideoFrames bool FifoVideoFrames::Get( gavl_video_frame_t * dest) { bool ret = false; //Dump("Getting a frame "); pthread_mutex_lock (&mut); if ( count > 0 ) { // if there any items in the fifo gavl_video_frame_copy(format, dest, fifoPtr[start]) ; dest->timestamp = fifoPtr[start]->timestamp; dest->duration = fifoPtr[start]->duration; if ( ++start >= size ) start = 0; count--; ret = true; } pthread_mutex_unlock (&mut); //Dump("Got a frame "); return ret; } /* void FifoVideoFrames::Dump( char * c) { int i,j = 0; pthread_mutex_lock (&mut); printf("%s -----------------------\n", c); for( i=0;i= size) // j = j -size; j=i; if ( j == start) textcolor(BRIGHT, GREEN, BLACK); if (j == end) textcolor(BRIGHT, RED, BLACK); if (j == end && j == start) textcolor(BRIGHT, YELLOW, BLACK); printf("[%d]=%ld ", j, fifoPtr[j]->timestamp); textcolor(RESET, BLACK, WHITE); } printf("\n"); printf("start=%02d, end=%02d, count=%02d\n", start,end,count); printf("-----------------------\n"); pthread_mutex_unlock (&mut); } */ bool FifoVideoFrames::FreeSpace() { bool ret; pthread_mutex_lock(&mut); ret = (count < size);pthread_mutex_unlock (&mut); return ret;} bool FifoVideoFrames::isEmpty() { bool c; pthread_mutex_lock(&mut); c = (count == 0) ; pthread_mutex_unlock (&mut); return c; } bool FifoVideoFrames::isFull() { bool c; pthread_mutex_lock(&mut); c = (count == size ); pthread_mutex_unlock (&mut); return c; } gavl_video_format_t * FifoVideoFrames::getFormat() { return format; }; float FifoVideoFrames::getSizePercentage() { float ret; pthread_mutex_lock(&mut);ret = count / (float) size; pthread_mutex_unlock (&mut); return ret;}; int FifoVideoFrames::getSize() { int ret; pthread_mutex_lock(&mut);ret = count; pthread_mutex_unlock (&mut); return ret;}; readanysf~0.43/src/FifoAudioFrames.cpp0000664000175000017500000001103712017676342017451 0ustar augustaugust/* * Copyright (C) 2003-2010 August Black * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include "FifoAudioFrames.h" /* #define RESET 0 #define BRIGHT 1 #define DIM 2 #define UNDERLINE 3 #define BLINK 4 #define REVERSE 7 #define HIDDEN 8 #define BLACK 0 #define RED 1 #define GREEN 2 #define YELLOW 3 #define BLUE 4 #define MAGENTA 5 #define CYAN 6 #define WHITE 7 void textcolor(int attr, int fg, int bg) { char command[13]; // Command is the control command to the terminal sprintf(command, "%c[%d;%d;%dm", 0x1B, attr, fg + 30, bg + 40); printf("%s", command); } */ FifoAudioFrames::FifoAudioFrames(int s, gavl_audio_format_t * f) { size = s ; start = 0 ; end = 0 ; count = 0; format = new gavl_audio_format_t; gavl_audio_format_copy(format, f); fifoPtr = new gavl_audio_frame_t * [size] ; for(int i=0; i < size; i++) { fifoPtr[i] = gavl_audio_frame_create( format ); } pthread_mutex_init (&mut, 0); //printf("FifoAudioFrames::size=%d\n", size); } FifoAudioFrames::~FifoAudioFrames() { //printf("deleting fifo \n"); for(int i=0; i < size; i++) { gavl_audio_frame_destroy( fifoPtr[i] ); } delete format; delete[] fifoPtr; pthread_mutex_destroy (&mut); //printf("deleted fifo \n"); } // empty the fifo of any content void FifoAudioFrames::Flush() { pthread_mutex_lock (&mut); start = 0 ; end = 0 ; count = 0; //printf("FifoAudioFrames::flushed size=%d\n", count); pthread_mutex_unlock (&mut); } // push an element onto the FifoAudioFrames bool FifoAudioFrames::Append( gavl_audio_frame_t * source) { bool ret = false; //Dump("Appending a frame "); pthread_mutex_lock (&mut); if ( count < size ) { // if there is room for one more int vs = gavl_audio_frame_copy(format, fifoPtr[end], source, 0,0, format->samples_per_frame, format->samples_per_frame) ; fifoPtr[end]->timestamp = source->timestamp; fifoPtr[end]->valid_samples =vs; if (++end >= size) end = 0; count++; ret = true; } // no room in fifo, return false pthread_mutex_unlock (&mut); //Dump("Appended a frame "); return ret; } // get an element off the FifoAudioFrames bool FifoAudioFrames::Get( gavl_audio_frame_t * dest) { bool ret = false; //Dump("Getting a frame "); pthread_mutex_lock (&mut); if ( count > 0 ) { // if there any items in the fifo int vs = gavl_audio_frame_copy(format, dest, fifoPtr[start], 0, 0, format->samples_per_frame, format->samples_per_frame) ; dest->timestamp = fifoPtr[start]->timestamp; dest->valid_samples = vs; if ( ++start >= size ) start = 0; count--; ret = true; } pthread_mutex_unlock (&mut); //Dump("Got a frame "); return ret; } /* void FifoAudioFrames::Dump( char * c) { int i,j = 0; pthread_mutex_lock (&mut); printf("%s -----------------------\n", c); for( i=0;i= size) // j = j -size; j=i; if ( j == start) textcolor(BRIGHT, GREEN, BLACK); if (j == end) textcolor(BRIGHT, RED, BLACK); if (j == end && j == start) textcolor(BRIGHT, YELLOW, BLACK); printf("[%d]=%ld ", j, fifoPtr[j]->timestamp); textcolor(RESET, BLACK, WHITE); } printf("\n"); printf("start=%02d, end=%02d, count=%02d\n", start,end,count); printf("-----------------------\n"); pthread_mutex_unlock (&mut); } */ bool FifoAudioFrames::FreeSpace() { bool ret = false; //printf("asking for free space on audio fifo\n"); pthread_mutex_lock(&mut); ret = (count < size); pthread_mutex_unlock (&mut); return ret; } bool FifoAudioFrames::isEmpty() { bool c; pthread_mutex_lock(&mut); c = (count == 0) ; pthread_mutex_unlock (&mut); return c; } bool FifoAudioFrames::isFull() { bool c; pthread_mutex_lock(&mut); c = (count == size ); pthread_mutex_unlock (&mut); return c; } gavl_audio_format_t * FifoAudioFrames::getFormat() { return format; }; float FifoAudioFrames::getSizePercentage() { float ret; pthread_mutex_lock(&mut);ret = count / (float) size; pthread_mutex_unlock (&mut); return ret;}; readanysf~0.43/src/readanysf~.cpp0000664000175000017500000004261612017676342016627 0ustar augustaugust/* * Readanysf PD object for reading and playing multiple soundfile types * from disk and from the web using gmerlin_avdecode * * Copyright (C) 2003-2010 August Black * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * readanysf.cpp */ #include #include #include #include #include //IMPORTANT bool #include // for malloc #include //sprintf #include //strcmp #include // ceil #include "m_pd.h" #include "ReadMedia.h" #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; typedef struct readanysf { t_object x_obj; t_sample *(x_outvec[MAXSFCHANS]); t_outlet *outinfo; int blocksize; // size of the pd block for this object int num_channels; int num_frames_in_fifo; int num_samples_per_frame; 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; bool do_t2o_audio_convert; bool do_i2t_audio_convert; int samplesleft; // how many audio samples left in our curren read buf ReadMedia *rm; gavl_audio_frame_t * out_audio_frame; gavl_audio_frame_t * tmp_audio_frame; gavl_audio_frame_t * in_audio_frame; gavl_audio_format_t out_audio_format; gavl_audio_format_t tmp_audio_format; gavl_audio_format_t in_audio_format; gavl_audio_converter_t * i2t_audio_converter; gavl_audio_converter_t * t2o_audio_converter; pthread_mutex_t mut; } t_readanysf; void m_play(t_readanysf *x) { pthread_mutex_lock(&x->mut); if (x->rm->isReady() && !x->is_opening ) { // is_opening protects the play variable, which in turn protects // the memory accessed in m_decode_block inside of the perform function // as long as play is false, no memory is accessed // as long as is_opening is true, play is false and no memory is accessed // to be safe, we will protect the is_opening var so that when the open callback // is called, and the memory is de-allocated and re-allocated, that memory is not // access by the perform function x->play = true; // this is the only place where play is true } else { if (x->is_opening ) { post("readanysf~: Current file is still starting."); post("This probably means that it is a stream and it needs to buffer in from the network."); } else { post("readanysf~: Current file is either invalid or an unsupported codec."); } } pthread_mutex_unlock(&x->mut); } void readanysf_bang(t_readanysf *x) { m_play(x); } void m_pause(t_readanysf *x) { x->play = false; } void m_pcm_seek(t_readanysf *x, float f) { if (! x->rm->pcmSeek( (long)f) ) post("can't seek on this file."); } void m_time_seek(t_readanysf *x, float f) { if (! x->rm->timeSeek( (double)f) ) post("can't seek on this file."); } void m_tick(t_readanysf *x, float f) { if (f >= 0.0) { x->tick = (unsigned int) f ; } } void m_stop(t_readanysf *x) { x->play = false; x->samplesleft=0; x->count=0; /* if( x->out_audio_frame != NULL) gavl_audio_frame_mute_samples(x->out_audio_frame, &x->out_audio_format, x->out_audio_format.samples_per_frame); if( x->in_audio_frame != NULL) gavl_audio_frame_mute_samples(x->in_audio_frame, &x->in_audio_format, x->in_audio_format.samples_per_frame); if( x->tmp_audio_frame != NULL) gavl_audio_frame_mute_samples(x->tmp_audio_frame, &x->tmp_audio_format, x->tmp_audio_format.samples_per_frame); */ x->rm->rewind(); } void m_init_audio( t_readanysf *x) { // Now,. do Audio stuff x->rm->copyAudioFormat( &x->in_audio_format); x->in_audio_format.samples_per_frame = x->num_samples_per_frame; x->tmp_audio_format.samplerate = x->in_audio_format.samplerate; x->tmp_audio_format.samples_per_frame = x->in_audio_format.samples_per_frame; x->tmp_audio_format.num_channels = x->out_audio_format.num_channels; x->tmp_audio_format.channel_locations[0] = GAVL_CHID_NONE; // Reset gavl_set_channel_setup (&x->tmp_audio_format); // Set channel locations if (x->in_audio_frame != NULL) gavl_audio_frame_destroy(x->in_audio_frame); x->in_audio_frame = gavl_audio_frame_create(&x->in_audio_format); if (x->tmp_audio_frame != NULL) gavl_audio_frame_destroy(x->tmp_audio_frame); x->tmp_audio_frame = gavl_audio_frame_create(&x->tmp_audio_format); if (x->i2t_audio_converter == NULL) x->i2t_audio_converter = gavl_audio_converter_create( ); x->do_i2t_audio_convert = gavl_audio_converter_init( x->i2t_audio_converter, &x->in_audio_format, &x->tmp_audio_format); if (x->t2o_audio_converter == NULL) x->t2o_audio_converter = gavl_audio_converter_create( ); x->do_t2o_audio_convert = gavl_audio_converter_init_resample( x->t2o_audio_converter, &x->out_audio_format); // this should be protected x->src_factor = x->out_audio_format.samplerate / (float) x->in_audio_format.samplerate; /* printf("in audio format: \n"); gavl_audio_format_dump( &x->in_audio_format); printf("tmp audio format, converting from input=%d \n", x->do_i2t_audio_convert); gavl_audio_format_dump( &x->tmp_audio_format); printf("output audio format, converting from tmp=%d \n", x->do_t2o_audio_convert); gavl_audio_format_dump( &x->out_audio_format); */ }; void m_open_callback( void * data) { t_readanysf * x = (t_readanysf *)data; pthread_mutex_lock(&x->mut); x->is_opening = true; // set it here again just to be safe pthread_mutex_unlock(&x->mut); if (x->rm->isReady() && x->rm->getAudioStreamCount() ) { 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); // 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); } } void m_open(t_readanysf *x, t_symbol *s) { t_atom lst; SETFLOAT(&lst, 0.0 ); outlet_anything(x->outinfo, gensym("ready"), 1, &lst); SETFLOAT(&lst, 0.0 ); outlet_anything(x->outinfo, gensym("length"), 1, &lst); outlet_float(x->outinfo, 0.0); x->play = false; pthread_mutex_lock(&x->mut); x->is_opening = true; pthread_mutex_unlock(&x->mut); x->rm->openFile( s->s_name, 0, x->num_frames_in_fifo, x->num_samples_per_frame ); } void m_speed(t_readanysf *x, float f) { // x->rm->setSpeed( f ); if (f > SRC_MAX) return; if (f < SRC_MIN) return; // lock on src_factor because it is set called during open callback // we can be sure then it won't conflict pthread_mutex_lock(&x->mut); x->src_factor = 1.0/f; pthread_mutex_unlock(&x->mut); } void m_loop(t_readanysf *x, float f) { if ( f == 0) x->rm->setLoop( false ); else x->rm->setLoop( true ); post("readanysf~: looping = %d", x->rm->getLoop()); } static void *readanysf_new(t_float f, t_float f2, t_float f3 ) { int nchannels = (int)f; int nframes = (int)f2; int nsamples = (int)f3; int i; t_atom lst; // if the external is created without any options if (nchannels <=0) nchannels = 2; if (nframes <=0) nframes = 24; if (nsamples <=0) nsamples = sys_getblksize(); t_readanysf *x = (t_readanysf *)pd_new(readanysf_class); x->blocksize=0; x->num_channels = nchannels; x->num_frames_in_fifo = nframes; x->num_samples_per_frame = nsamples; 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; x->do_i2t_audio_convert = false; x->samplesleft = 0; x->rm = NULL; x->out_audio_frame=NULL; x->tmp_audio_frame=NULL; x->in_audio_frame=NULL; // set up the audio formats. Need to also set them in dsp call x->tmp_audio_format.samplerate = sys_getsr(); x->tmp_audio_format.sample_format = GAVL_SAMPLE_FLOAT ; x->tmp_audio_format.interleave_mode = GAVL_INTERLEAVE_NONE; x->tmp_audio_format.num_channels = x->num_channels; x->tmp_audio_format.channel_locations[0] = GAVL_CHID_NONE; // Reset x->tmp_audio_format.samples_per_frame = x->num_samples_per_frame; x->out_audio_format.samplerate = sys_getsr(); x->out_audio_format.sample_format = GAVL_SAMPLE_FLOAT ; x->out_audio_format.interleave_mode = GAVL_INTERLEAVE_NONE; x->out_audio_format.num_channels = x->num_channels; x->out_audio_format.channel_locations[0] = GAVL_CHID_NONE; // Reset x->i2t_audio_converter=NULL; x->t2o_audio_converter=NULL; pthread_mutex_init(&x->mut, 0); for (i=0; i < nchannels; i++) { outlet_new(&x->x_obj, gensym("signal")); } x->outinfo = outlet_new(&x->x_obj, &s_anything); SETFLOAT(&lst, 0.0 ); outlet_anything(x->outinfo, gensym("ready"), 1, &lst); // set time to 0.0 outlet_float(x->outinfo, 0.0); if (x->rm == NULL) { x->rm = new ReadMedia ( ); // (int)sys_getsr(), x->num_channels, x->num_frames_in_fifo, x->num_samples_per_frame); post("Created new readanysf~ with %d channels and internal buffer of %d blocks of %d samples = %d", x->num_channels, x->num_frames_in_fifo, x->num_samples_per_frame, x->num_frames_in_fifo * x->num_samples_per_frame); } x->rm->setOpenCallback( m_open_callback, (void *)x); return (void *)x; } int m_get_frame( t_readanysf *x ) { int ret =0; ret = x->rm->decodeAudio(x->in_audio_frame); if (ret != 1) // EOF=0 or error=-1 return ret; if (x->do_i2t_audio_convert) { gavl_audio_convert( x->i2t_audio_converter, x->in_audio_frame, x->tmp_audio_frame) ; x->tmp_audio_frame->valid_samples = x->in_audio_frame->valid_samples; } else { gavl_audio_frame_copy(&x->in_audio_format, x->tmp_audio_frame, x->in_audio_frame, 0,0, x->in_audio_frame->valid_samples, x->in_audio_frame->valid_samples) ; x->tmp_audio_frame->valid_samples = x->in_audio_frame->valid_samples; } if ( x->do_t2o_audio_convert ) { // should be true all of the time // protect src_factor here? gavl_audio_converter_resample( x->t2o_audio_converter, x->tmp_audio_frame, x->out_audio_frame, x->src_factor ); // Don't know why, but on the first conversion, I get one extra sample // THIS SHOULD NOT HAPPEN...this is a fix for now..check it out later. //if (x->src_factor == 1.0 && x->out_audio_frame->valid_samples > x->num_samples_per_frame) { // printf("Got wierd return value for audio frames, taf->vs %d, oaf->vs %d, src_factor=%f\n", // x->tmp_audio_frame->valid_samples, x->out_audio_frame->valid_samples, x->src_factor); //x->samplesleft = x->out_audio_frame->valid_samples = x->num_samples_per_frame; //} else { x->samplesleft = x->out_audio_frame->valid_samples; //} } else { // copy the samples to the output gavl_audio_frame_copy(&x->tmp_audio_format, x->out_audio_frame, x->tmp_audio_frame, 0,0, x->tmp_audio_frame->valid_samples, x->tmp_audio_frame->valid_samples) ; //printf("copying taf to oaf, taf->vs %d, oaf->vs %d\n", taf->valid_samples, oaf->valid_samples); x->samplesleft = x->out_audio_frame->valid_samples = x->tmp_audio_frame->valid_samples; } return ret; } int m_decode_block( t_readanysf * x ) { int i=0,j=0, samps_done=0; int samps_to_do = x->blocksize; while( samps_to_do > 0) { if ( samps_to_do <= x->samplesleft) { // copy our samples out to the pd audio buffer for (i = 0; i < x->num_channels; i++) { for (j = 0; j < samps_to_do ; j++) { x->x_outvec[i][samps_done + j] = x->out_audio_frame->channels.f[i][ x->out_audio_frame->valid_samples - x->samplesleft +j ]; } } x->samplesleft -= samps_to_do; samps_done += samps_to_do; samps_to_do = 0; break; } else if ( x->samplesleft > 0 ) { for (i = 0; i < x->num_channels; i++) { for (j = 0; j < x->samplesleft; j++) { x->x_outvec[i][samps_done + j] = x->out_audio_frame->channels.f[i][ x->out_audio_frame->valid_samples - x->samplesleft +j ]; } } samps_to_do = samps_to_do - x->samplesleft; samps_done += x->samplesleft; x->samplesleft = 0; } else { // samplesleft is zero int ret = m_get_frame(x); if (ret == 0) { // EOF return samps_done; } else if (ret == -1) { // error, file proly not ready printf("error getting frame...must be seeking\n"); return ret; } } } return samps_done; } static t_int *readanysf_perform(t_int *w) { t_readanysf *x = (t_readanysf *) (w[1]); int i=0,j=0; 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 m_stop(x); outlet_bang(x->outinfo); } else if (samples_returned == -1) { // error in getting audio, normally from seeking samples_returned=0; } } for (i = 0; i < x->num_channels; i++) { for (j = samples_returned; j < x->blocksize; j++) { x->x_outvec[i][j] = 0.0; } } 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 ) { SETFLOAT (&lst, x->rm->getAudioFifoSizePercentage() ); outlet_anything(x->outinfo, gensym("cache"), 1, &lst); if (x->play) { outlet_float( x->outinfo, gavl_time_to_seconds(gavl_time_unscale(x->in_audio_format.samplerate, x->in_audio_frame->timestamp)) ); } x->count = 0; } return (w+2); } void readanysf_dsp(t_readanysf *x, t_signal **sp) { int i=0; if (x->blocksize != sp[0]->s_n) { x->blocksize = sp[0]->s_n; x->tmp_audio_format.samplerate = sys_getsr(); x->tmp_audio_format.sample_format = GAVL_SAMPLE_FLOAT ; x->tmp_audio_format.interleave_mode = GAVL_INTERLEAVE_NONE; x->tmp_audio_format.num_channels = x->num_channels; x->tmp_audio_format.channel_locations[0] = GAVL_CHID_NONE; // Reset x->tmp_audio_format.samples_per_frame = x->num_samples_per_frame; x->out_audio_format.samplerate = sys_getsr(); x->out_audio_format.sample_format = GAVL_SAMPLE_FLOAT ; x->out_audio_format.interleave_mode = GAVL_INTERLEAVE_NONE; x->out_audio_format.num_channels = x->num_channels; x->out_audio_format.channel_locations[0] = GAVL_CHID_NONE; // Reset // leave enough room in our out format and frame for resampling x->out_audio_format.samples_per_frame = ( x->num_samples_per_frame * SRC_MAX ) +10; gavl_set_channel_setup (&x->out_audio_format); // Set channel locations if(x->out_audio_frame != NULL) gavl_audio_frame_destroy( x->out_audio_frame); x->out_audio_frame = gavl_audio_frame_create(&x->out_audio_format); //post("readanysf~: pd blocksize=%d, spf=%d", x->blocksize, x->num_samples_per_frame); } for (i = 0; i < x->num_channels; i++) x->x_outvec[i] = sp[i]->s_vec; dsp_add(readanysf_perform, 1, x); } static void readanysf_free(t_readanysf *x) { // delete the readany objs if (x->in_audio_frame != NULL) gavl_audio_frame_destroy(x->in_audio_frame); if (x->tmp_audio_frame != NULL) gavl_audio_frame_destroy(x->tmp_audio_frame); if (x->out_audio_frame != NULL) gavl_audio_frame_destroy(x->out_audio_frame); if (x->i2t_audio_converter != NULL) gavl_audio_converter_destroy(x->i2t_audio_converter); if (x->t2o_audio_converter != NULL) gavl_audio_converter_destroy(x->t2o_audio_converter); pthread_mutex_destroy(&x->mut); delete x->rm; x->rm = NULL; } extern "C" void readanysf_tilde_setup(void) { readanysf_class = class_new(gensym("readanysf~"), (t_newmethod)readanysf_new, (t_method)readanysf_free, sizeof(t_readanysf), 0, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_NULL); class_addmethod(readanysf_class, (t_method)readanysf_dsp, gensym("dsp"), A_NULL); class_addmethod(readanysf_class, (t_method)m_open, gensym("open"), A_SYMBOL, A_NULL); class_addmethod(readanysf_class, (t_method)m_play, gensym("play"), A_NULL); class_addmethod(readanysf_class, (t_method)m_pause, gensym("pause"), A_NULL); class_addmethod(readanysf_class, (t_method)m_stop, gensym("stop"), A_NULL); class_addmethod(readanysf_class, (t_method)m_tick, gensym("tick"), A_FLOAT, A_NULL); class_addmethod(readanysf_class, (t_method)m_speed, gensym("speed"), A_FLOAT, A_NULL); class_addmethod(readanysf_class, (t_method)m_loop, gensym("loop"), A_FLOAT, A_NULL); class_addmethod(readanysf_class, (t_method)m_pcm_seek, gensym("pcm_seek"), A_FLOAT, A_NULL); class_addmethod(readanysf_class, (t_method)m_time_seek, gensym("time_seek"), A_FLOAT, A_NULL); class_addbang(readanysf_class, readanysf_bang); } readanysf~0.43/src/.svn/0000775000175000017500000000000012017703635014620 5ustar augustaugustreadanysf~0.43/src/.svn/props/0000775000175000017500000000000012017676342015767 5ustar augustaugustreadanysf~0.43/src/.svn/prop-base/0000775000175000017500000000000012017676342016514 5ustar augustaugustreadanysf~0.43/src/.svn/entries0000444000175000017500000000254112017676342016216 0ustar augustaugust10 dir 16184 https://pure-data.svn.sourceforge.net/svnroot/pure-data/trunk/externals/august/readanysf~/src https://pure-data.svn.sourceforge.net/svnroot/pure-data 2011-10-30T18:02:26.448014Z 15685 augmentus df7eb9d6-776f-4174-a42d-0ffd8d5d5b5d FifoVideoFrames.h file 2012-08-30T14:46:58.247399Z 783ced77021730d99c32afd3510499ad 2010-10-05T22:52:49.783687Z 14200 augmentus 1699 ReadMedia.h file 2012-08-30T14:46:58.243399Z 0edd71c9b3302df0aa1d0bcf17cff326 2010-10-05T22:52:49.783687Z 14200 augmentus 5569 FifoAudioFrames.cpp file 2012-08-30T14:46:58.243399Z 1e2b8ba1a1721a89a6762b9c02bd1c39 2010-10-05T22:52:49.783687Z 14200 augmentus 4639 FifoAudioFrames.h file 2012-08-30T14:46:58.243399Z 26f947dfd1691fdba9303f1159344d2d 2010-10-05T22:52:49.783687Z 14200 augmentus 1630 FifoVideoFrames.cpp file 2012-08-30T14:46:58.243399Z c874c63b61e8a034c7023e3c0ea1c64c 2010-10-05T22:52:49.783687Z 14200 augmentus 4377 readanysf~.cpp file 2012-08-30T14:46:58.243399Z a9ba8e0d7f80999e201f57ccc2ae70c6 2011-10-30T18:02:26.448014Z 15685 augmentus 17806 ReadMedia.cpp file 2012-08-30T14:46:58.247399Z c58f78dda8d506518d2eb5fb19a25168 2010-12-08T22:26:44.463684Z 14578 augmentus 32630 readanysf~0.43/src/.svn/text-base/0000775000175000017500000000000012017676342016520 5ustar augustaugustreadanysf~0.43/src/.svn/text-base/ReadMedia.cpp.svn-base0000444000175000017500000007756612017676342022575 0ustar augustaugust/* * Copyright (C) 2003-2010 August Black * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include "ReadMedia.h" #include #include //usleep static void *the_thread_dispatcher(void * xp); static void *the_thread_opener(void * xp); static void *the_audiofifo_filler(void * xp); static void *the_videofifo_filler(void * xp); ReadMedia::ReadMedia( ) { m_state = STATE_EMPTY; m_audio_frame = NULL; m_video_frame = NULL; m_aeof = true; m_veof = true; //m_atime = 0.0; //m_vtime = 0.0; m_video_stream_count =0; m_audio_stream_count =0; m_pcm_seek = SEEK_NOTHING; m_frame_seek = SEEK_NOTHING; m_length_in_seconds=0.0; m_length_in_gavltime = 0; m_num_frames=0; m_num_samples=0; m_video_format.frame_width=0; m_video_format.frame_height=0; m_video_format.image_width=0; m_video_format.image_height=0; m_video_format.pixel_width=0; m_video_format.pixel_height=0; m_video_format.pixelformat = GAVL_PIXELFORMAT_NONE ; m_video_format.frame_duration=0; m_video_format.timescale=0; m_video_format.framerate_mode=GAVL_FRAMERATE_CONSTANT; m_video_format.chroma_placement=GAVL_CHROMA_PLACEMENT_DEFAULT; m_video_format.interlace_mode=GAVL_INTERLACE_NONE; m_video_format.timecode_format.int_framerate =0; m_video_format.timecode_format.flags =0; m_audio_format.samples_per_frame = 0; m_audio_format.samplerate = 0; m_audio_format.num_channels = 0; m_audio_format.sample_format = GAVL_SAMPLE_NONE ; m_audio_format.interleave_mode = GAVL_INTERLEAVE_NONE; m_audio_format.center_level = 1.0; m_audio_format.rear_level = 1.0; m_audio_format.channel_locations[0] = GAVL_CHID_NONE; // Reset m_fifoaudio= NULL; // new FifoAudioFrames( frames_in_fifo , &tmp_audio_lormat); m_fifovideo= NULL; // new FifoVideoFrames( 12 , &output_video_format); m_audio_thread_ret = -1; m_video_thread_ret = -1; m_open_callback = NULL; m_open_callback_data = NULL; m_buffer_callback = NULL; m_buffer_callback_data = NULL; quit_av_threads = false; m_loop = false; sprintf(m_filename, "seinettbitte!"); //bgav stuff m_file = NULL; m_opt = bgav_options_create(); bgav_options_set_connect_timeout(m_opt, 5000); bgav_options_set_read_timeout(m_opt, 5000); bgav_options_set_network_bandwidth(m_opt, 524300); bgav_options_set_network_buffer_size(m_opt, 1024*12); bgav_options_set_http_shoutcast_metadata (m_opt, 1); // set up the reading so that we can seek sample accurately bgav_options_set_sample_accurate (m_opt, 1 ); pthread_cond_init(&m_cond_dispatch, 0); pthread_mutex_init(&m_condmut_dispatch, 0); pthread_cond_init(&m_cond_a, 0); pthread_cond_init(&m_cond_v, 0); pthread_mutex_init(&m_condmut_a, 0); pthread_mutex_init(&m_condmut_v, 0); pthread_mutex_init(&m_av_mut, 0); pthread_mutex_init(&m_state_mut, 0); // start the dispatcher thread m_cmd = CMD_START; m_dispatcher_thread_ret = pthread_create(&m_thread_dispatch, NULL, the_thread_dispatcher, (void *)this) ; if (m_dispatcher_thread_ret != 0 ) printf("error starting the readmedia dispatcher thread.\n"); while( getCommand() != CMD_NULL) signalDispatcher(); //printf("dispatcher ready ...\n"); } ReadMedia::~ReadMedia() { printf("killing the media..\n"); setCommand( CMD_QUIT ); signalDispatcher(); // signal dispatcher joins the opener and AV threads pthread_join( m_thread_dispatch, NULL); //printf("joined dispatcher\n"); if (m_audio_frame != NULL) { gavl_audio_frame_destroy(m_audio_frame); } if (m_video_frame != NULL) { gavl_video_frame_destroy(m_video_frame); } if (m_file != NULL) { bgav_close(m_file); } //printf("now, on to deleting fifo...\n"); if( m_fifoaudio != NULL) delete m_fifoaudio; if( m_fifovideo != NULL) delete m_fifovideo; // these are created only once bgav_options_destroy(m_opt); pthread_cond_destroy(&m_cond_dispatch); pthread_mutex_destroy(&m_condmut_dispatch); pthread_cond_destroy(&m_cond_a); pthread_cond_destroy(&m_cond_v); pthread_mutex_destroy(&m_condmut_a); pthread_mutex_destroy(&m_condmut_v); pthread_mutex_destroy(&m_av_mut); pthread_mutex_destroy(&m_state_mut); printf("killed the media..\n"); } int ReadMedia::decodeVideo( gavl_video_frame_t * vf ) { // check state first, if state is ready, we can check the other vars without locking lockState(); if (m_state != STATE_READY || m_video_stream_count < 1 || m_fifovideo == NULL ) { unlockState(); return -1; } if (!m_fifovideo->Get( vf ) ) { if ( m_veof ) { m_frame_seek = SEEK_NOTHING; unlockState(); signalV(); return 0; } else { //printf("Couldn't get a video frame, videofifo is %f full\n", m_fifovideo->getSizePercentage()); // this can only happen if the fifo is empty unlockState(); signalV(); return -1; // return with error } } //m_vtime = vf->timestamp / (double)m_video_format.timescale; unlockState(); signalV(); return 1 ; } int ReadMedia::decodeAudio( gavl_audio_frame_t * af ) { lockState(); if (m_state != STATE_READY || m_audio_stream_count < 1 || m_fifoaudio == NULL ) { unlockState(); return -1; } if ( !m_fifoaudio->Get( af ) ) { if ( m_aeof ) { m_pcm_seek = SEEK_NOTHING; unlockState(); signalA(); return 0; } else { printf("Couldn't get an audio frame, audiofifo is %f full.\n", m_fifoaudio->getSizePercentage()); // this can only happen if the fifo is empty unlockState(); signalA(); return -1; } } //m_atime = af->timestamp / (double)m_audio_format.samplerate; unlockState(); signalA(); return 1 ; } bool ReadMedia::rewind() { // NOTE!! Always check for stream count before setting aeof or veof lockState(); if ( m_state == STATE_READY && m_file != NULL) { //printf("ReadMedia::rewind(), valid_samples=%d\n", m_audio_frame->valid_samples); m_pcm_seek = SEEK_REWIND; if(m_audio_stream_count) m_aeof = false; //m_atime = 0; m_frame_seek=SEEK_REWIND; if (m_video_stream_count) m_veof = false; //m_vtime=0; unlockState(); if (m_audio_stream_count) { signalA(); // only signal one or the other here //printf("ReadMedia::rewind(), signaled audio\n"); // we are gong to flush here even though it is flushed // during the audio or video thread. This will ensure our fifo // is clean and empty. Otherwise, the audio thread may be waiting // at the bottom of its loop and not make it to the flush part even // though we signalled it. if (m_fifoaudio) m_fifoaudio->Flush(); } else if (m_video_stream_count) { signalV(); if (m_fifovideo) m_fifovideo->Flush(); } return true; } unlockState(); return false; } gavl_time_t ReadMedia::getLengthInGavlTime() { gavl_time_t time = 0; lockState(); time = m_length_in_gavltime; unlockState(); return time; } double ReadMedia::getLengthInSeconds() { double secs = 0.0; lockState(); secs = m_length_in_seconds; unlockState(); return secs; } int64_t ReadMedia::getLengthInAudioSamples() { int64_t samples = 0; lockState(); samples = m_num_samples; unlockState(); return samples; } int64_t ReadMedia::getLengthInVideoFrames() { int64_t frames = 0; lockState(); frames = m_num_frames; unlockState(); return frames; } bool ReadMedia::frameSeek( int64_t frames ) { lockState(); if (m_state == STATE_READY && m_file && bgav_can_seek( m_file ) && frames >= 0 && frames < m_num_frames ) { m_frame_seek = frames; unlockState(); signalAV(); return true; } else { m_frame_seek = SEEK_NOTHING; unlockState(); return false; } } // NOT PUBLIC int64_t ReadMedia::frameSeek() { int64_t tmp=SEEK_NOTHING; lockState(); tmp = m_frame_seek; m_frame_seek = SEEK_NOTHING; unlockState(); return tmp; } bool ReadMedia::pcmSeek( int64_t samples ) { lockState(); if (m_state == STATE_READY && m_file && bgav_can_seek( m_file) && samples >= 0 && samples < m_num_samples ) { m_pcm_seek = samples; unlockState(); signalAV(); return true; } else { m_pcm_seek = SEEK_NOTHING; unlockState(); return false; } } // NOT PUBLIC int64_t ReadMedia::pcmSeek() { int64_t tmp=SEEK_NOTHING; lockState(); tmp = m_pcm_seek; m_pcm_seek = SEEK_NOTHING; unlockState(); return tmp; } bool ReadMedia::timeSeek(double seconds) { gavl_time_t gt = gavl_seconds_to_time( seconds ) ; lockState(); if (m_state == STATE_READY && m_file && bgav_can_seek( m_file) && seconds >= 0.0 && seconds < m_length_in_seconds ) { if (m_audio_stream_count) { m_pcm_seek = gavl_time_to_samples(m_audio_format.samplerate, gt ); if (m_pcm_seek >= m_num_samples || m_pcm_seek < 0) m_pcm_seek = SEEK_NOTHING; unlockState(); signalAV(); return true; } else if ( m_video_stream_count && m_video_format.framerate_mode == GAVL_FRAMERATE_CONSTANT ) { m_frame_seek = gavl_time_to_frames( m_video_format.timescale, m_video_format.frame_duration, gt ); if (m_frame_seek >= m_num_frames || m_frame_seek < 0 ) m_frame_seek = SEEK_NOTHING; unlockState(); signalAV(); return true; } } unlockState(); return false; } bool ReadMedia::quitAVThreads() { bool b =false; lockState(); b = quit_av_threads; unlockState(); return b; } void ReadMedia::openFile( char * fn, int vsize, int asize, int spf) { lockState(); /* if ( strcmp(m_filename, fn) == 0 && m_state == STATE_READY) { printf("%s is already open for action. \n", m_filename); unlockState(); callOpenCallback(); return; } */ // signal the dispatcher that we want an new file m_audio_format.samples_per_frame = spf ; m_afifosize = asize; m_vfifosize = vsize; sprintf(m_filename, "%s", fn); m_cmd = CMD_OPEN ; unlockState(); signalDispatcher(); } void ReadMedia::copyAudioFormat(gavl_audio_format_t * dst ){ lockState(); //if (m_state == STATE_READY) gavl_audio_format_copy(dst, &m_audio_format); unlockState(); } void ReadMedia::copyVideoFormat(gavl_video_format_t * dst ){ lockState(); //if (m_state == STATE_READY) gavl_video_format_copy( dst, &m_video_format); unlockState(); } int ReadMedia::getAudioSamplerate() { int sr=0; lockState(); //if (m_state == STATE_READY ) sr = m_audio_format.samplerate; unlockState(); return sr; } int ReadMedia::getAudioChannelCount() { int ch=0; lockState(); //if (m_state == STATE_READY ) ch = m_audio_format.num_channels; unlockState(); return ch; } int ReadMedia::getVideoTimescale() { int t=0; lockState(); t = m_video_format.timescale; unlockState(); return t; } char * ReadMedia::getFilename() { return m_filename; } bgav_t * ReadMedia::getFile() {return m_file;} FifoAudioFrames * ReadMedia::getAudioFifo() { return m_fifoaudio; } FifoVideoFrames * ReadMedia::getVideoFifo() { return m_fifovideo; } gavl_audio_frame_t * ReadMedia::getAudioFrame() { return m_audio_frame;} gavl_video_frame_t * ReadMedia::getVideoFrame() { return m_video_frame;} void ReadMedia::setState(int b) { lockState(); m_state = b; unlockState(); } int ReadMedia::getState() { int s=STATE_EMPTY; lockState(); s = m_state; unlockState(); return s; } bool ReadMedia::isReady() { if ( getState() == STATE_READY) return true; else return false;} // no need to lock on these //double ReadMedia::getATimeInSeconds() { return m_atime;}; //double ReadMedia::getVTimeInSeconds() { return m_vtime;}; /* float ReadMedia::getTimeInSeconds() { lockState(); if (m_audio_stream_count > 0 ) { unlockState(); return m_atime; } else { // FIXME : see if the following is really true unlockState(); return m_vtime; } }; */ float ReadMedia::getAudioFifoSizePercentage() { float f=0.0; lockState(); if (m_fifoaudio) f = m_fifoaudio->getSizePercentage(); unlockState(); return f; } void ReadMedia::pealOffVideoFrames( int howmany) { lockAV(); if (m_fifovideo == NULL) { unlockAV(); return; } int max = howmany > m_fifovideo->getSize() ? m_fifovideo->getSize() : howmany; for (int i=0;i< max; i++) { m_fifovideo->Get(); //printf("pealing of a video frame size = %d\n", m_fifovideo->getSize()); } unlockAV(); } void ReadMedia::setAEOF(bool b) { lockState(); m_aeof = b; m_pcm_seek = SEEK_NOTHING; unlockState(); } void ReadMedia::setVEOF(bool b) { lockState(); m_veof = b; m_frame_seek = SEEK_NOTHING; unlockState(); } bool ReadMedia::getEOF() { bool tmp = true; lockState(); if (m_state == STATE_READY) tmp = (m_aeof && m_veof); unlockState(); //printf("ReadMedia:getEOF=%d, aeof=%d, veof=%d\n", tmp, m_aeof, m_veof); return tmp; } void ReadMedia::setLoop( bool b) { lockState(); m_loop = b; unlockState(); } bool ReadMedia::getLoop() { bool tmp = true; lockState(); if (m_file && bgav_can_seek( m_file) ) { tmp = m_loop; } else { tmp = false; // we can't loop on file, return false // but leave the loop var untouched } unlockState(); return tmp; } // NOT PUBILC // only used in fifo filler bool ReadMedia::getAEOF() { bool tmp = false; lockState(); tmp = m_aeof; unlockState(); return tmp; } // NOT PUBLIC bool ReadMedia::getVEOF() { bool tmp = false; lockState(); tmp = m_veof; unlockState(); return tmp; } int ReadMedia::getSamplesPerFrame() { int spf=0; lockState(); spf = m_audio_format.samples_per_frame; unlockState(); return spf; } int ReadMedia::lockAV() { //printf("locking AV\n"); return pthread_mutex_lock(&m_av_mut); } int ReadMedia::unlockAV() { //printf("unlocking AV\n"); return pthread_mutex_unlock(&m_av_mut); } int ReadMedia::lockState() { // printf("locking state.\n"); return pthread_mutex_lock(&m_state_mut); } int ReadMedia::unlockState() { //printf("unlocking state.\n"); return pthread_mutex_unlock(&m_state_mut); } void ReadMedia::waitA() { pthread_cond_wait( &m_cond_a, &m_condmut_a); } void ReadMedia::waitV() { pthread_cond_wait( &m_cond_v, &m_condmut_v); } void ReadMedia::signalAV() { signalA(); signalV(); } void ReadMedia::signalA() { pthread_cond_signal( &m_cond_a); } void ReadMedia::signalV() { pthread_cond_signal( &m_cond_v); } void ReadMedia::signalDispatcher() { pthread_cond_signal( &m_cond_dispatch); } void ReadMedia::waitDispatch() { pthread_cond_wait( &m_cond_dispatch, &m_condmut_dispatch); } void ReadMedia::setOpenCallback(void (*oc)(void *), void *v ) { lockState();// do we need this? m_open_callback = oc; m_open_callback_data = v; unlockState(); } void ReadMedia::callOpenCallback() { // do NOT lock on the callback, user must do call public functions // that also lock if(m_open_callback != NULL) m_open_callback( m_open_callback_data); }; void ReadMedia::setBufferCallback(bgav_buffer_callback bc, void *v ) { lockState(); m_buffer_callback = bc; m_buffer_callback_data = v; // set up callbacks. if (m_buffer_callback) { bgav_options_set_buffer_callback( m_opt, m_buffer_callback, m_buffer_callback_data); } unlockState(); }; int ReadMedia::getAudioStreamCount() { int asc=0; lockState(); asc = m_audio_stream_count; unlockState(); return asc; } int ReadMedia::getVideoStreamCount() { int vsc=0; lockState(); vsc = m_video_stream_count; unlockState(); return vsc; } // NOT PUBLIC void ReadMedia::setAudioStreamCount(int s){ lockState(); m_audio_stream_count=s; if (s == 0) // no audio streams, we are already at audio eof m_aeof = true; else m_aeof = false; unlockState(); } // NOT PUBLIC void ReadMedia::setVideoStreamCount(int s){ lockState(); m_video_stream_count=s; if (s==0) // if there are no video streams, video is at eof m_veof = true; else m_veof =false; unlockState(); } // NOT PUBLIC void ReadMedia::setCommand(int s){ lockState(); m_cmd = s; unlockState(); } // NOT PUBLIC int ReadMedia::getCommand() { int cmd= CMD_NULL; lockState(); cmd = m_cmd; unlockState(); return cmd; } // NOT PUBLIC // Clears the bgav_t struct, destroying and then creating it // NO NEED TO DO AV LOCK, only called in the opener thread void ReadMedia::clearFile() { if (m_file != NULL) bgav_close( m_file ); m_file = bgav_create(); bgav_options_copy( bgav_get_options( m_file ) , m_opt); m_aeof = true; m_veof = true; m_pcm_seek = SEEK_NOTHING; m_frame_seek = SEEK_NOTHING; } // NOT PUBLIC // Closes the bgav_t struct, destroying it and setting to NULL // NO NEED TO DO AV LOCK, only called in the opener thread void ReadMedia::closeFile() { if (m_file != NULL) bgav_close( m_file ); m_file = NULL; m_aeof = true; m_veof = true; m_pcm_seek = SEEK_NOTHING; m_frame_seek = SEEK_NOTHING; sprintf(m_filename, "seinettbitte!"); } // NOT PUBLIC // killAVThreads is only called from the opener thread // and from the destructor // THIS IS NOT REALLY A PUBLIC function void ReadMedia::killAVThreads() { lockState(); m_state = STATE_EMPTY; quit_av_threads = true; unlockState(); signalAV(); signalAV(); // FIRST need to join the threads that exist and are running if (m_audio_thread_ret == 0) { pthread_join( m_thread_fillaudiofifo, NULL); //pthread_detach( m_thread_fillaudiofifo); } if (m_video_thread_ret == 0){ pthread_join( m_thread_fillvideofifo, NULL); //pthread_detach( m_thread_fillvideofifo); } m_audio_thread_ret = -1; m_video_thread_ret = -1; // no need to lock here quit_av_threads = false; } // NOT PUBLIC // Only called from the opener thread bool ReadMedia::startAVThreads() { if (m_audio_thread_ret == 0 || m_video_thread_ret == 0 ) { // ouch!, we have running AV threads, this is not good return false; } if (m_audio_stream_count > 0) { m_audio_thread_ret = pthread_create(&m_thread_fillaudiofifo, NULL, the_audiofifo_filler, (void *)this); if (m_audio_thread_ret != 0 ) { printf("ReadMedia:: problem starting the audio thread\n"); return false; } } if (m_video_stream_count > 0) { m_video_thread_ret = pthread_create(&m_thread_fillvideofifo, NULL, the_videofifo_filler, (void *)this); if (m_video_thread_ret != 0 ) { printf("ReadMedia:: problem starting the video thread\n"); return false; } } return true; } bool ReadMedia::initFormat() { const gavl_audio_format_t * open_audio_format; const gavl_video_format_t * open_video_format; // we use the m_vfifosize to see if the user app wants video or not // then, we set m_video_stream_count to 0 if he doesn't want video if (m_video_stream_count > 0 && m_vfifosize > 0) { open_video_format = bgav_get_video_format(m_file, 0); if (open_video_format->pixelformat == GAVL_PIXELFORMAT_NONE) { printf("!!!sorry, pixelformat is not recognized.\n"); return false; } // let's check to see if the formats are the same, if they are the same // there is no reason to recreate the fifo or frames if ( gavl_video_formats_equal( &m_video_format, open_video_format) == 0 ) { // the formats are different gavl_video_format_copy (&m_video_format, open_video_format); if (m_video_frame != NULL) gavl_video_frame_destroy(m_video_frame); m_video_frame = gavl_video_frame_create(&m_video_format); gavl_video_frame_clear( m_video_frame, &m_video_format); if (m_fifovideo != NULL) delete m_fifovideo; m_fifovideo= new FifoVideoFrames( m_vfifosize , &m_video_format); } } else { m_video_stream_count = 0; m_veof = true; } // we use the m_afifosize to see if the user app wants audio or not // then, we set m_audio_stream_count to 0 if he doesn't want audio if (m_audio_stream_count > 0 && m_afifosize > 0) { open_audio_format = bgav_get_audio_format(m_file, 0); // we can get audio formats that are unkown if ( open_audio_format->sample_format == GAVL_SAMPLE_NONE) { printf("sorry, this file has unsupported audio.\n"); return false; } if ( gavl_audio_formats_equal(&m_audio_format, open_audio_format) == 0 ) { // audio formats are different // save the old spf int spf = m_audio_format.samples_per_frame; gavl_audio_format_copy(&m_audio_format, open_audio_format); if (m_audio_frame != NULL) { gavl_audio_frame_destroy(m_audio_frame); } // set it back to original m_audio_format.samples_per_frame = spf ; m_audio_frame = gavl_audio_frame_create(&m_audio_format); gavl_audio_frame_mute( m_audio_frame, &m_audio_format); if( m_fifoaudio != NULL ) delete m_fifoaudio; m_fifoaudio = new FifoAudioFrames( m_afifosize , &m_audio_format); } } else { // user doesn't want audio m_audio_stream_count = 0; m_aeof=true; } m_length_in_gavltime = bgav_get_duration ( m_file, 0);; m_length_in_seconds = gavl_time_to_seconds( m_length_in_gavltime ); m_num_samples = 0; m_num_frames = 0; if (m_audio_stream_count) { if ( bgav_can_seek_sample(m_file) == 1 ) { m_num_samples= bgav_audio_duration ( m_file, 0) ; } else { m_num_samples= gavl_time_to_samples( m_audio_format.samplerate , bgav_get_duration ( m_file, 0) ); } } // set frames WE NEED TO take care here for non-constant frame-rates if(m_video_stream_count) { if ( bgav_can_seek_sample(m_file) == 1 && m_video_format.framerate_mode == GAVL_FRAMERATE_CONSTANT) { m_num_frames = bgav_video_duration ( m_file, 0)/ m_video_format.frame_duration; } else if ( bgav_can_seek_sample(m_file) == 1 && m_video_format.framerate_mode == GAVL_FRAMERATE_VARIABLE ) { // FIXME what to do with non constant frame rates? m_num_frames=0; } else { m_num_frames = gavl_time_to_frames( m_video_format.timescale, m_video_format.frame_duration , bgav_get_duration ( m_file, 0) ); } } // printf("m_num_frames =%lld, duration = %lld , vid_duration=%lld\n", // m_num_frames, bgav_get_duration ( m_file, 0), bgav_video_duration ( m_file, 0) ); // set seconds if ( bgav_can_seek_sample(m_file) == 1) { gavl_time_t atime=0,vtime=0; if ( m_audio_stream_count ) atime = gavl_samples_to_time( m_audio_format.samplerate, m_num_samples ); if (m_video_stream_count && m_video_format.frame_duration > 0) { vtime = gavl_frames_to_time( m_video_format.timescale, m_video_format.frame_duration, m_num_frames ); } else if ( m_video_stream_count ) { // non constant framerate vtime = bgav_video_duration( m_file, 0); } // else rely on audio time m_length_in_gavltime = atime > vtime ? atime :vtime; m_length_in_seconds = gavl_time_to_seconds( m_length_in_gavltime ); //printf("atime=%ld, vtime=%ld, l_in_sec=%f\n", atime, vtime, m_length_in_seconds); } m_pcm_seek = SEEK_NOTHING; m_frame_seek = SEEK_NOTHING; return true; } void *the_thread_dispatcher(void *xp) { ReadMedia *rm = (ReadMedia *)xp; int cmd = CMD_NULL; pthread_t thread_open; int start_thread_ret = -1; cmd = rm->getCommand(); while ( cmd != CMD_QUIT ) { if (cmd == CMD_OPEN) { // We already check in the openFile function if the user is trying to open // a file that is already open. // join the opener thread, this will protect again any other calls to open if (start_thread_ret == 0 ) pthread_join( thread_open, NULL ); // we join the AV threads // the opener thread will start the AV threads anew upon success rm->killAVThreads(); start_thread_ret = pthread_create(&thread_open, NULL, the_thread_opener, (void *)rm) ; if (start_thread_ret != 0 ) printf( "Failed to create m_thread_open thread.\n"); } if (rm->getCommand() == CMD_QUIT) break; rm->setCommand( CMD_NULL); rm->waitDispatch(); cmd = rm->getCommand(); } //printf("dispatcher: joining thread open\n"); if( start_thread_ret == 0 ) pthread_join( thread_open , NULL); //printf("dispatcher: joined thread open, joining AV's\n"); rm->killAVThreads(); //printf("dispatcher: joined AV's\n"); pthread_exit(NULL); }; void *the_thread_opener(void *xp) { ReadMedia *rm = NULL; int num_urls=0, num_tracks=0, audio_stream_count=0, video_stream_count =0; rm = (ReadMedia *)xp; rm->setState(STATE_OPENING); // AFTER WE KILL THE THREADS, THERE IS NO NEED TO LOCK AV mutex // ALL functions that want to get info on the file, seek, // or decode a frame, MUST first check the state. If the // state is STATE_READY, then it can perform it's function, // locking on the necessary variables that might conflict with // the AV. // clearFile deletes old file and creates new File rm->clearFile(); if(!bgav_open(rm->getFile(), rm->getFilename())) { printf( "Could not open file %s\n", rm->getFilename()); rm->setState( STATE_EMPTY ); rm->closeFile(); rm->callOpenCallback(); pthread_exit(NULL); //return NULL; } else { printf("opened %s\n", rm->getFilename()); } // check to see if it is a redirector if(bgav_is_redirector( rm->getFile() )) { num_urls = bgav_redirector_get_num_urls( rm->getFile() ); printf( "Found redirector with %d urls inside, we will try to use the first one.\n", num_urls); printf( "Name %d: %s\n", 1, bgav_redirector_get_name(rm->getFile() , 0)); printf("URL %d: %s\n", 1, bgav_redirector_get_url(rm->getFile(), 0)); sprintf(rm->getFilename(), "%s", bgav_redirector_get_url(rm->getFile(), 0) ); rm->clearFile(); if (!bgav_open( rm->getFile(), rm->getFilename() )) { printf("Could not open redirector\n"); rm->setState( STATE_EMPTY ); rm->closeFile(); rm->callOpenCallback(); pthread_exit(NULL); //return NULL; } else { printf("opened redirector %s\n", rm->getFilename()); } } num_tracks = bgav_num_tracks(rm->getFile()); if ( num_tracks ) { bgav_select_track(rm->getFile(), 0); } else { printf("No tracks associated with file:%s\n", rm->getFilename() ); rm->setState( STATE_EMPTY ); rm->closeFile(); rm->callOpenCallback(); pthread_exit(NULL); } audio_stream_count = bgav_num_audio_streams(rm->getFile(), 0); if( audio_stream_count ) bgav_set_audio_stream(rm->getFile(), 0, BGAV_STREAM_DECODE); video_stream_count = bgav_num_video_streams(rm->getFile(), 0); if( video_stream_count ) bgav_set_video_stream(rm->getFile(), 0, BGAV_STREAM_DECODE); rm->setVideoStreamCount(video_stream_count); rm->setAudioStreamCount(audio_stream_count); //printf("astream_count = %d, vstream_count=%d\n", audio_stream_count, video_stream_count); if(!bgav_start(rm->getFile())) { printf( "failed to start file\n"); rm->setState( STATE_EMPTY ); rm->closeFile(); rm->callOpenCallback(); pthread_exit(NULL) ; //return NULL; } if( !rm->initFormat() ){ rm->setState( STATE_EMPTY ); rm->closeFile(); rm->callOpenCallback(); pthread_exit(NULL) ; } if( !rm->startAVThreads() ){ rm->setState( STATE_EMPTY ); rm->closeFile(); rm->callOpenCallback(); pthread_exit(NULL) ; } // AV threads are now running, blocking will be necessary // STATE_READY and callOpenCallback is set/called in the // fifo fill callbacks rm->signalAV(); rm->signalAV(); //extra signal for second thread pthread_exit(NULL); //return NULL; } void *the_audiofifo_filler( void * xp) { int samples_returned=0; ReadMedia *rm = (ReadMedia *)xp; int first = true; int dovideo = rm->getVideoStreamCount(); int spf = rm->getSamplesPerFrame(); int samplerate = rm->getAudioSamplerate(); int64_t seekto = SEEK_NOTHING; int can_seek = bgav_can_seek ( rm->getFile() ); int can_seek_sample = bgav_can_seek_sample ( rm->getFile() ); while ( !rm->quitAVThreads() ) { //while ( rm->getAudioFifo() != NULL && rm->getAudioFifo()->FreeSpace() && !rm->getAEOF() ) { while ( rm->getAudioFifo()->FreeSpace() && !rm->getAEOF() ) { if (rm->quitAVThreads() ) pthread_exit(NULL) ; //return NULL; rm->lockAV(); // check to see if we need to seek // if this is set, we already know we can seek on this file // and don't need to check with bgav_can_seek if ( can_seek ) { seekto = rm->pcmSeek(); if ( seekto != SEEK_NOTHING ) { if ( seekto == SEEK_REWIND) { // bgav_seek_audio ONLY seeks on the audio stream seekto = 0; // bgav_seek_scaled(rm->getFile(), &seekto, samplerate); } //else { bgav_seek_scaled(rm->getFile(), &seekto, samplerate); //} rm->getAudioFifo()->Flush(); if (dovideo && rm->getVideoFifo() ) { rm->getVideoFifo()->Flush(); rm->signalV(); } } } samples_returned = bgav_read_audio(rm->getFile(), rm->getAudioFrame(), 0, spf ); //rm->unlockAV(); if (samples_returned == 0 ) { if( rm->getLoop() ) { if ( can_seek ) { // Now, rewind the file, don't flush the fifo's if (can_seek_sample) { // only seek on audio stream bgav_seek_audio(rm->getFile(), 0, 0); } else { seekto =0; bgav_seek_scaled(rm->getFile(), &seekto, samplerate); if (dovideo && rm->getVideoFifo() ) { rm->setVEOF(false); rm->signalV(); } } // SAVE THIS FOR ANOTHER TIME, OVERLAPPED SMOOTH LOOPING //if ( rm->getLoop() > 1 && bgav_read_audio(rm->getFile(), rm->getAudioFrame(), 0, spf ) ) { // add to the fifo, overlapping // rm->getAudioFifo()->AppendOverlap( rm->getAudioFrame(), 5 ); // } } else { // this file is not seekable, what do we do? printf("cannot seek on file, but we want to loop. setting end of file.\n"); rm->setAEOF(true); } } else { rm->setAEOF(true); } rm->unlockAV(); break; } rm->unlockAV(); if( !rm->getAudioFifo()->Append( rm->getAudioFrame() )) printf("problem with appending Audio Frame\n"); } if (first && !dovideo) { rm->setState( STATE_READY ); rm->callOpenCallback(); first = false; } if (rm->quitAVThreads() ) pthread_exit(NULL); //return NULL; rm->waitA(); } pthread_exit(NULL);//return NULL; } void *the_videofifo_filler( void * xp) { ReadMedia *rm = (ReadMedia *)xp; int ret = 0; int first = true; int doaudio = rm->getAudioStreamCount(); int64_t seekto =SEEK_NOTHING; int can_seek = bgav_can_seek ( rm->getFile() ); int can_seek_sample = bgav_can_seek_sample ( rm->getFile() ); int timescale = rm->getVideoTimescale(); while (!rm->quitAVThreads() ) { while ( rm->getVideoFifo() !=NULL && rm->getVideoFifo()->FreeSpace() && !rm->getVEOF() ) { if (rm->quitAVThreads() ) pthread_exit(NULL);//return NULL; rm->lockAV(); // check to see if we need to seek // if this is set, we already know we can seek on this file // and don't need to check with bgav_can_seek if (can_seek) { seekto = rm->frameSeek(); if ( seekto >= 0 ) { if (doaudio && rm->getAudioFifo() ) rm->getAudioFifo()->Flush(); rm->getVideoFifo()->Flush(); bgav_seek_scaled(rm->getFile(), &seekto, timescale); } else if (seekto == SEEK_REWIND && !doaudio) { // rewind is a special case for Video. rm->getVideoFifo()->Flush(); seekto =0; bgav_seek_scaled(rm->getFile(), &seekto, timescale); } } ret = bgav_read_video(rm->getFile(), rm->getVideoFrame(), 0 ); if ( !ret ) { // only loop from video if there is no audio // audio controls loop timing if ( rm->getLoop() ){ if ( can_seek ) { if (doaudio && can_seek_sample) { // seek on video stream only if we have audio // audio and video seeking are separate in sample accurate // seeking. If no sample accurate seeking, then let audio // handle seeking bgav_seek_video(rm->getFile(), 0,0); } else if (!doaudio) { // if we don't have audio...just seek to 0 seekto=0; bgav_seek_scaled(rm->getFile(), &seekto, timescale); } } else { // if (can_seek) printf ("We want to loop video, but we cannot seek on this video stream,setting VEOF\n"); rm->setVEOF(true); } } else { rm->setVEOF(true); } rm->unlockAV(); break; } rm->unlockAV(); if( !rm->getVideoFifo()->Append( rm->getVideoFrame() )) printf("problem with appending VideoFrame\n"); } // on the first time 'round we will call the open callback // if there is no video in the file, the audio will handle it. if (first) { rm->setState( STATE_READY ); rm->callOpenCallback(); first = false; } if (rm->quitAVThreads() ) pthread_exit(NULL); //return NULL; rm->waitV(); } pthread_exit(NULL); //return NULL; } readanysf~0.43/src/.svn/text-base/FifoAudioFrames.h.svn-base0000444000175000017500000000313612017676342023410 0ustar augustaugust/* * Copyright (C) 2003-2010 August Black * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ifndef _FIFOAUDIOFRAMES_H_ #define _FIFOAUDIOFRAMES_H_ #include // memcpy #include #include #ifndef _AVDEC_H_ #define _AVDEC_H_ extern "C" { #include } #endif class FifoAudioFrames { public: FifoAudioFrames(int s, gavl_audio_format_t * format) ; ~FifoAudioFrames();// { delete [] fifoPtr; } bool Append( gavl_audio_frame_t * af); bool Get( gavl_audio_frame_t * af) ; // pop an element off the fifo void Flush(); //void Dump(char *c); bool FreeSpace(); bool isEmpty(); bool isFull(); void setDebug( bool b); gavl_audio_format_t * getFormat(); float getSizePercentage(); private: int size ; // Number of elements on FifoAudioFrames int start ; int end ; int count; gavl_audio_frame_t ** fifoPtr ; gavl_audio_format_t * format; pthread_mutex_t mut; } ; #endif readanysf~0.43/src/.svn/text-base/FifoVideoFrames.h.svn-base0000444000175000017500000000324312017676342023414 0ustar augustaugust/* * Copyright (C) 2003-2010 August Black * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ifndef _FIFOVIDEOFRAMES_H_ #define _FIFOVIDEOFRAMES_H_ #include // memcpy #include #include #ifndef _AVDEC_H_ #define _AVDEC_H_ extern "C" { #include } #endif class FifoVideoFrames { public: FifoVideoFrames(int s, gavl_video_format_t * format) ; ~FifoVideoFrames();// { delete [] fifoPtr; } bool Append( gavl_video_frame_t * af); bool Get( gavl_video_frame_t * af) ; // pop an element off the fifo bool Get( ) ; // discard an element off the fifo void Flush(); //void Dump(char *c); bool FreeSpace(); bool isEmpty(); bool isFull(); void setDebug( bool b); gavl_video_format_t * getFormat(); int getSize(); float getSizePercentage(); private: int size ; // Number of elements on FifoVideoFrames int start ; int end ; int count; gavl_video_frame_t ** fifoPtr ; gavl_video_format_t * format; pthread_mutex_t mut; } ; #endif readanysf~0.43/src/.svn/text-base/FifoVideoFrames.cpp.svn-base0000444000175000017500000001043112017676342023744 0ustar augustaugust/* * Copyright (C) 2003-2010 August Black * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include "FifoVideoFrames.h" FifoVideoFrames::FifoVideoFrames(int s, gavl_video_format_t * f) { size = s ; start = 0 ; end = 0 ; count = 0; format = new gavl_video_format_t; gavl_video_format_copy(format, f); fifoPtr = new gavl_video_frame_t * [size] ; for(int i=0; i < size; i++) { fifoPtr[i] = gavl_video_frame_create( format ); } pthread_mutex_init (&mut, 0); } FifoVideoFrames::~FifoVideoFrames() { //printf("deleting fifo \n"); for(int i=0; i < size; i++) { gavl_video_frame_destroy( fifoPtr[i] ); } delete format; delete[] fifoPtr; pthread_mutex_destroy (&mut); //printf("deleted fifo \n"); } // empty the fifo of any content void FifoVideoFrames::Flush() { pthread_mutex_lock (&mut); start = 0 ; end = 0 ; count = 0; //printf("FifoVideoFrames::flushed size=%d\n", count); pthread_mutex_unlock (&mut); } // push an element onto the FifoVideoFrames bool FifoVideoFrames::Append( gavl_video_frame_t * source) { bool ret = false; //Dump("Appending a frame "); pthread_mutex_lock (&mut); if ( count < size ) { // if there is room for one more gavl_video_frame_copy(format, fifoPtr[end], source) ; fifoPtr[end]->timestamp = source->timestamp; fifoPtr[end]->duration = source->duration; if (++end >= size) end = 0; count++; ret = true; } // no room in fifo, return false pthread_mutex_unlock (&mut); //Dump("Appended a frame "); return ret; } // remove an element off the front FifoVideoFrames bool FifoVideoFrames::Get( ) { bool ret = false; pthread_mutex_lock (&mut); if ( count > 0 ) { // if there any items in the fifo if ( ++start >= size ) start = 0; count--; ret = true; } pthread_mutex_unlock (&mut); //Dump("Got a frame "); return ret; } // get an element off the FifoVideoFrames bool FifoVideoFrames::Get( gavl_video_frame_t * dest) { bool ret = false; //Dump("Getting a frame "); pthread_mutex_lock (&mut); if ( count > 0 ) { // if there any items in the fifo gavl_video_frame_copy(format, dest, fifoPtr[start]) ; dest->timestamp = fifoPtr[start]->timestamp; dest->duration = fifoPtr[start]->duration; if ( ++start >= size ) start = 0; count--; ret = true; } pthread_mutex_unlock (&mut); //Dump("Got a frame "); return ret; } /* void FifoVideoFrames::Dump( char * c) { int i,j = 0; pthread_mutex_lock (&mut); printf("%s -----------------------\n", c); for( i=0;i= size) // j = j -size; j=i; if ( j == start) textcolor(BRIGHT, GREEN, BLACK); if (j == end) textcolor(BRIGHT, RED, BLACK); if (j == end && j == start) textcolor(BRIGHT, YELLOW, BLACK); printf("[%d]=%ld ", j, fifoPtr[j]->timestamp); textcolor(RESET, BLACK, WHITE); } printf("\n"); printf("start=%02d, end=%02d, count=%02d\n", start,end,count); printf("-----------------------\n"); pthread_mutex_unlock (&mut); } */ bool FifoVideoFrames::FreeSpace() { bool ret; pthread_mutex_lock(&mut); ret = (count < size);pthread_mutex_unlock (&mut); return ret;} bool FifoVideoFrames::isEmpty() { bool c; pthread_mutex_lock(&mut); c = (count == 0) ; pthread_mutex_unlock (&mut); return c; } bool FifoVideoFrames::isFull() { bool c; pthread_mutex_lock(&mut); c = (count == size ); pthread_mutex_unlock (&mut); return c; } gavl_video_format_t * FifoVideoFrames::getFormat() { return format; }; float FifoVideoFrames::getSizePercentage() { float ret; pthread_mutex_lock(&mut);ret = count / (float) size; pthread_mutex_unlock (&mut); return ret;}; int FifoVideoFrames::getSize() { int ret; pthread_mutex_lock(&mut);ret = count; pthread_mutex_unlock (&mut); return ret;}; readanysf~0.43/src/.svn/text-base/readanysf~.cpp.svn-base0000444000175000017500000004261612017676342023120 0ustar augustaugust/* * Readanysf PD object for reading and playing multiple soundfile types * from disk and from the web using gmerlin_avdecode * * Copyright (C) 2003-2010 August Black * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * readanysf.cpp */ #include #include #include #include #include //IMPORTANT bool #include // for malloc #include //sprintf #include //strcmp #include // ceil #include "m_pd.h" #include "ReadMedia.h" #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; typedef struct readanysf { t_object x_obj; t_sample *(x_outvec[MAXSFCHANS]); t_outlet *outinfo; int blocksize; // size of the pd block for this object int num_channels; int num_frames_in_fifo; int num_samples_per_frame; 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; bool do_t2o_audio_convert; bool do_i2t_audio_convert; int samplesleft; // how many audio samples left in our curren read buf ReadMedia *rm; gavl_audio_frame_t * out_audio_frame; gavl_audio_frame_t * tmp_audio_frame; gavl_audio_frame_t * in_audio_frame; gavl_audio_format_t out_audio_format; gavl_audio_format_t tmp_audio_format; gavl_audio_format_t in_audio_format; gavl_audio_converter_t * i2t_audio_converter; gavl_audio_converter_t * t2o_audio_converter; pthread_mutex_t mut; } t_readanysf; void m_play(t_readanysf *x) { pthread_mutex_lock(&x->mut); if (x->rm->isReady() && !x->is_opening ) { // is_opening protects the play variable, which in turn protects // the memory accessed in m_decode_block inside of the perform function // as long as play is false, no memory is accessed // as long as is_opening is true, play is false and no memory is accessed // to be safe, we will protect the is_opening var so that when the open callback // is called, and the memory is de-allocated and re-allocated, that memory is not // access by the perform function x->play = true; // this is the only place where play is true } else { if (x->is_opening ) { post("readanysf~: Current file is still starting."); post("This probably means that it is a stream and it needs to buffer in from the network."); } else { post("readanysf~: Current file is either invalid or an unsupported codec."); } } pthread_mutex_unlock(&x->mut); } void readanysf_bang(t_readanysf *x) { m_play(x); } void m_pause(t_readanysf *x) { x->play = false; } void m_pcm_seek(t_readanysf *x, float f) { if (! x->rm->pcmSeek( (long)f) ) post("can't seek on this file."); } void m_time_seek(t_readanysf *x, float f) { if (! x->rm->timeSeek( (double)f) ) post("can't seek on this file."); } void m_tick(t_readanysf *x, float f) { if (f >= 0.0) { x->tick = (unsigned int) f ; } } void m_stop(t_readanysf *x) { x->play = false; x->samplesleft=0; x->count=0; /* if( x->out_audio_frame != NULL) gavl_audio_frame_mute_samples(x->out_audio_frame, &x->out_audio_format, x->out_audio_format.samples_per_frame); if( x->in_audio_frame != NULL) gavl_audio_frame_mute_samples(x->in_audio_frame, &x->in_audio_format, x->in_audio_format.samples_per_frame); if( x->tmp_audio_frame != NULL) gavl_audio_frame_mute_samples(x->tmp_audio_frame, &x->tmp_audio_format, x->tmp_audio_format.samples_per_frame); */ x->rm->rewind(); } void m_init_audio( t_readanysf *x) { // Now,. do Audio stuff x->rm->copyAudioFormat( &x->in_audio_format); x->in_audio_format.samples_per_frame = x->num_samples_per_frame; x->tmp_audio_format.samplerate = x->in_audio_format.samplerate; x->tmp_audio_format.samples_per_frame = x->in_audio_format.samples_per_frame; x->tmp_audio_format.num_channels = x->out_audio_format.num_channels; x->tmp_audio_format.channel_locations[0] = GAVL_CHID_NONE; // Reset gavl_set_channel_setup (&x->tmp_audio_format); // Set channel locations if (x->in_audio_frame != NULL) gavl_audio_frame_destroy(x->in_audio_frame); x->in_audio_frame = gavl_audio_frame_create(&x->in_audio_format); if (x->tmp_audio_frame != NULL) gavl_audio_frame_destroy(x->tmp_audio_frame); x->tmp_audio_frame = gavl_audio_frame_create(&x->tmp_audio_format); if (x->i2t_audio_converter == NULL) x->i2t_audio_converter = gavl_audio_converter_create( ); x->do_i2t_audio_convert = gavl_audio_converter_init( x->i2t_audio_converter, &x->in_audio_format, &x->tmp_audio_format); if (x->t2o_audio_converter == NULL) x->t2o_audio_converter = gavl_audio_converter_create( ); x->do_t2o_audio_convert = gavl_audio_converter_init_resample( x->t2o_audio_converter, &x->out_audio_format); // this should be protected x->src_factor = x->out_audio_format.samplerate / (float) x->in_audio_format.samplerate; /* printf("in audio format: \n"); gavl_audio_format_dump( &x->in_audio_format); printf("tmp audio format, converting from input=%d \n", x->do_i2t_audio_convert); gavl_audio_format_dump( &x->tmp_audio_format); printf("output audio format, converting from tmp=%d \n", x->do_t2o_audio_convert); gavl_audio_format_dump( &x->out_audio_format); */ }; void m_open_callback( void * data) { t_readanysf * x = (t_readanysf *)data; pthread_mutex_lock(&x->mut); x->is_opening = true; // set it here again just to be safe pthread_mutex_unlock(&x->mut); if (x->rm->isReady() && x->rm->getAudioStreamCount() ) { 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); // 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); } } void m_open(t_readanysf *x, t_symbol *s) { t_atom lst; SETFLOAT(&lst, 0.0 ); outlet_anything(x->outinfo, gensym("ready"), 1, &lst); SETFLOAT(&lst, 0.0 ); outlet_anything(x->outinfo, gensym("length"), 1, &lst); outlet_float(x->outinfo, 0.0); x->play = false; pthread_mutex_lock(&x->mut); x->is_opening = true; pthread_mutex_unlock(&x->mut); x->rm->openFile( s->s_name, 0, x->num_frames_in_fifo, x->num_samples_per_frame ); } void m_speed(t_readanysf *x, float f) { // x->rm->setSpeed( f ); if (f > SRC_MAX) return; if (f < SRC_MIN) return; // lock on src_factor because it is set called during open callback // we can be sure then it won't conflict pthread_mutex_lock(&x->mut); x->src_factor = 1.0/f; pthread_mutex_unlock(&x->mut); } void m_loop(t_readanysf *x, float f) { if ( f == 0) x->rm->setLoop( false ); else x->rm->setLoop( true ); post("readanysf~: looping = %d", x->rm->getLoop()); } static void *readanysf_new(t_float f, t_float f2, t_float f3 ) { int nchannels = (int)f; int nframes = (int)f2; int nsamples = (int)f3; int i; t_atom lst; // if the external is created without any options if (nchannels <=0) nchannels = 2; if (nframes <=0) nframes = 24; if (nsamples <=0) nsamples = sys_getblksize(); t_readanysf *x = (t_readanysf *)pd_new(readanysf_class); x->blocksize=0; x->num_channels = nchannels; x->num_frames_in_fifo = nframes; x->num_samples_per_frame = nsamples; 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; x->do_i2t_audio_convert = false; x->samplesleft = 0; x->rm = NULL; x->out_audio_frame=NULL; x->tmp_audio_frame=NULL; x->in_audio_frame=NULL; // set up the audio formats. Need to also set them in dsp call x->tmp_audio_format.samplerate = sys_getsr(); x->tmp_audio_format.sample_format = GAVL_SAMPLE_FLOAT ; x->tmp_audio_format.interleave_mode = GAVL_INTERLEAVE_NONE; x->tmp_audio_format.num_channels = x->num_channels; x->tmp_audio_format.channel_locations[0] = GAVL_CHID_NONE; // Reset x->tmp_audio_format.samples_per_frame = x->num_samples_per_frame; x->out_audio_format.samplerate = sys_getsr(); x->out_audio_format.sample_format = GAVL_SAMPLE_FLOAT ; x->out_audio_format.interleave_mode = GAVL_INTERLEAVE_NONE; x->out_audio_format.num_channels = x->num_channels; x->out_audio_format.channel_locations[0] = GAVL_CHID_NONE; // Reset x->i2t_audio_converter=NULL; x->t2o_audio_converter=NULL; pthread_mutex_init(&x->mut, 0); for (i=0; i < nchannels; i++) { outlet_new(&x->x_obj, gensym("signal")); } x->outinfo = outlet_new(&x->x_obj, &s_anything); SETFLOAT(&lst, 0.0 ); outlet_anything(x->outinfo, gensym("ready"), 1, &lst); // set time to 0.0 outlet_float(x->outinfo, 0.0); if (x->rm == NULL) { x->rm = new ReadMedia ( ); // (int)sys_getsr(), x->num_channels, x->num_frames_in_fifo, x->num_samples_per_frame); post("Created new readanysf~ with %d channels and internal buffer of %d blocks of %d samples = %d", x->num_channels, x->num_frames_in_fifo, x->num_samples_per_frame, x->num_frames_in_fifo * x->num_samples_per_frame); } x->rm->setOpenCallback( m_open_callback, (void *)x); return (void *)x; } int m_get_frame( t_readanysf *x ) { int ret =0; ret = x->rm->decodeAudio(x->in_audio_frame); if (ret != 1) // EOF=0 or error=-1 return ret; if (x->do_i2t_audio_convert) { gavl_audio_convert( x->i2t_audio_converter, x->in_audio_frame, x->tmp_audio_frame) ; x->tmp_audio_frame->valid_samples = x->in_audio_frame->valid_samples; } else { gavl_audio_frame_copy(&x->in_audio_format, x->tmp_audio_frame, x->in_audio_frame, 0,0, x->in_audio_frame->valid_samples, x->in_audio_frame->valid_samples) ; x->tmp_audio_frame->valid_samples = x->in_audio_frame->valid_samples; } if ( x->do_t2o_audio_convert ) { // should be true all of the time // protect src_factor here? gavl_audio_converter_resample( x->t2o_audio_converter, x->tmp_audio_frame, x->out_audio_frame, x->src_factor ); // Don't know why, but on the first conversion, I get one extra sample // THIS SHOULD NOT HAPPEN...this is a fix for now..check it out later. //if (x->src_factor == 1.0 && x->out_audio_frame->valid_samples > x->num_samples_per_frame) { // printf("Got wierd return value for audio frames, taf->vs %d, oaf->vs %d, src_factor=%f\n", // x->tmp_audio_frame->valid_samples, x->out_audio_frame->valid_samples, x->src_factor); //x->samplesleft = x->out_audio_frame->valid_samples = x->num_samples_per_frame; //} else { x->samplesleft = x->out_audio_frame->valid_samples; //} } else { // copy the samples to the output gavl_audio_frame_copy(&x->tmp_audio_format, x->out_audio_frame, x->tmp_audio_frame, 0,0, x->tmp_audio_frame->valid_samples, x->tmp_audio_frame->valid_samples) ; //printf("copying taf to oaf, taf->vs %d, oaf->vs %d\n", taf->valid_samples, oaf->valid_samples); x->samplesleft = x->out_audio_frame->valid_samples = x->tmp_audio_frame->valid_samples; } return ret; } int m_decode_block( t_readanysf * x ) { int i=0,j=0, samps_done=0; int samps_to_do = x->blocksize; while( samps_to_do > 0) { if ( samps_to_do <= x->samplesleft) { // copy our samples out to the pd audio buffer for (i = 0; i < x->num_channels; i++) { for (j = 0; j < samps_to_do ; j++) { x->x_outvec[i][samps_done + j] = x->out_audio_frame->channels.f[i][ x->out_audio_frame->valid_samples - x->samplesleft +j ]; } } x->samplesleft -= samps_to_do; samps_done += samps_to_do; samps_to_do = 0; break; } else if ( x->samplesleft > 0 ) { for (i = 0; i < x->num_channels; i++) { for (j = 0; j < x->samplesleft; j++) { x->x_outvec[i][samps_done + j] = x->out_audio_frame->channels.f[i][ x->out_audio_frame->valid_samples - x->samplesleft +j ]; } } samps_to_do = samps_to_do - x->samplesleft; samps_done += x->samplesleft; x->samplesleft = 0; } else { // samplesleft is zero int ret = m_get_frame(x); if (ret == 0) { // EOF return samps_done; } else if (ret == -1) { // error, file proly not ready printf("error getting frame...must be seeking\n"); return ret; } } } return samps_done; } static t_int *readanysf_perform(t_int *w) { t_readanysf *x = (t_readanysf *) (w[1]); int i=0,j=0; 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 m_stop(x); outlet_bang(x->outinfo); } else if (samples_returned == -1) { // error in getting audio, normally from seeking samples_returned=0; } } for (i = 0; i < x->num_channels; i++) { for (j = samples_returned; j < x->blocksize; j++) { x->x_outvec[i][j] = 0.0; } } 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 ) { SETFLOAT (&lst, x->rm->getAudioFifoSizePercentage() ); outlet_anything(x->outinfo, gensym("cache"), 1, &lst); if (x->play) { outlet_float( x->outinfo, gavl_time_to_seconds(gavl_time_unscale(x->in_audio_format.samplerate, x->in_audio_frame->timestamp)) ); } x->count = 0; } return (w+2); } void readanysf_dsp(t_readanysf *x, t_signal **sp) { int i=0; if (x->blocksize != sp[0]->s_n) { x->blocksize = sp[0]->s_n; x->tmp_audio_format.samplerate = sys_getsr(); x->tmp_audio_format.sample_format = GAVL_SAMPLE_FLOAT ; x->tmp_audio_format.interleave_mode = GAVL_INTERLEAVE_NONE; x->tmp_audio_format.num_channels = x->num_channels; x->tmp_audio_format.channel_locations[0] = GAVL_CHID_NONE; // Reset x->tmp_audio_format.samples_per_frame = x->num_samples_per_frame; x->out_audio_format.samplerate = sys_getsr(); x->out_audio_format.sample_format = GAVL_SAMPLE_FLOAT ; x->out_audio_format.interleave_mode = GAVL_INTERLEAVE_NONE; x->out_audio_format.num_channels = x->num_channels; x->out_audio_format.channel_locations[0] = GAVL_CHID_NONE; // Reset // leave enough room in our out format and frame for resampling x->out_audio_format.samples_per_frame = ( x->num_samples_per_frame * SRC_MAX ) +10; gavl_set_channel_setup (&x->out_audio_format); // Set channel locations if(x->out_audio_frame != NULL) gavl_audio_frame_destroy( x->out_audio_frame); x->out_audio_frame = gavl_audio_frame_create(&x->out_audio_format); //post("readanysf~: pd blocksize=%d, spf=%d", x->blocksize, x->num_samples_per_frame); } for (i = 0; i < x->num_channels; i++) x->x_outvec[i] = sp[i]->s_vec; dsp_add(readanysf_perform, 1, x); } static void readanysf_free(t_readanysf *x) { // delete the readany objs if (x->in_audio_frame != NULL) gavl_audio_frame_destroy(x->in_audio_frame); if (x->tmp_audio_frame != NULL) gavl_audio_frame_destroy(x->tmp_audio_frame); if (x->out_audio_frame != NULL) gavl_audio_frame_destroy(x->out_audio_frame); if (x->i2t_audio_converter != NULL) gavl_audio_converter_destroy(x->i2t_audio_converter); if (x->t2o_audio_converter != NULL) gavl_audio_converter_destroy(x->t2o_audio_converter); pthread_mutex_destroy(&x->mut); delete x->rm; x->rm = NULL; } extern "C" void readanysf_tilde_setup(void) { readanysf_class = class_new(gensym("readanysf~"), (t_newmethod)readanysf_new, (t_method)readanysf_free, sizeof(t_readanysf), 0, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_NULL); class_addmethod(readanysf_class, (t_method)readanysf_dsp, gensym("dsp"), A_NULL); class_addmethod(readanysf_class, (t_method)m_open, gensym("open"), A_SYMBOL, A_NULL); class_addmethod(readanysf_class, (t_method)m_play, gensym("play"), A_NULL); class_addmethod(readanysf_class, (t_method)m_pause, gensym("pause"), A_NULL); class_addmethod(readanysf_class, (t_method)m_stop, gensym("stop"), A_NULL); class_addmethod(readanysf_class, (t_method)m_tick, gensym("tick"), A_FLOAT, A_NULL); class_addmethod(readanysf_class, (t_method)m_speed, gensym("speed"), A_FLOAT, A_NULL); class_addmethod(readanysf_class, (t_method)m_loop, gensym("loop"), A_FLOAT, A_NULL); class_addmethod(readanysf_class, (t_method)m_pcm_seek, gensym("pcm_seek"), A_FLOAT, A_NULL); class_addmethod(readanysf_class, (t_method)m_time_seek, gensym("time_seek"), A_FLOAT, A_NULL); class_addbang(readanysf_class, readanysf_bang); } readanysf~0.43/src/.svn/text-base/FifoAudioFrames.cpp.svn-base0000444000175000017500000001103712017676342023742 0ustar augustaugust/* * Copyright (C) 2003-2010 August Black * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include "FifoAudioFrames.h" /* #define RESET 0 #define BRIGHT 1 #define DIM 2 #define UNDERLINE 3 #define BLINK 4 #define REVERSE 7 #define HIDDEN 8 #define BLACK 0 #define RED 1 #define GREEN 2 #define YELLOW 3 #define BLUE 4 #define MAGENTA 5 #define CYAN 6 #define WHITE 7 void textcolor(int attr, int fg, int bg) { char command[13]; // Command is the control command to the terminal sprintf(command, "%c[%d;%d;%dm", 0x1B, attr, fg + 30, bg + 40); printf("%s", command); } */ FifoAudioFrames::FifoAudioFrames(int s, gavl_audio_format_t * f) { size = s ; start = 0 ; end = 0 ; count = 0; format = new gavl_audio_format_t; gavl_audio_format_copy(format, f); fifoPtr = new gavl_audio_frame_t * [size] ; for(int i=0; i < size; i++) { fifoPtr[i] = gavl_audio_frame_create( format ); } pthread_mutex_init (&mut, 0); //printf("FifoAudioFrames::size=%d\n", size); } FifoAudioFrames::~FifoAudioFrames() { //printf("deleting fifo \n"); for(int i=0; i < size; i++) { gavl_audio_frame_destroy( fifoPtr[i] ); } delete format; delete[] fifoPtr; pthread_mutex_destroy (&mut); //printf("deleted fifo \n"); } // empty the fifo of any content void FifoAudioFrames::Flush() { pthread_mutex_lock (&mut); start = 0 ; end = 0 ; count = 0; //printf("FifoAudioFrames::flushed size=%d\n", count); pthread_mutex_unlock (&mut); } // push an element onto the FifoAudioFrames bool FifoAudioFrames::Append( gavl_audio_frame_t * source) { bool ret = false; //Dump("Appending a frame "); pthread_mutex_lock (&mut); if ( count < size ) { // if there is room for one more int vs = gavl_audio_frame_copy(format, fifoPtr[end], source, 0,0, format->samples_per_frame, format->samples_per_frame) ; fifoPtr[end]->timestamp = source->timestamp; fifoPtr[end]->valid_samples =vs; if (++end >= size) end = 0; count++; ret = true; } // no room in fifo, return false pthread_mutex_unlock (&mut); //Dump("Appended a frame "); return ret; } // get an element off the FifoAudioFrames bool FifoAudioFrames::Get( gavl_audio_frame_t * dest) { bool ret = false; //Dump("Getting a frame "); pthread_mutex_lock (&mut); if ( count > 0 ) { // if there any items in the fifo int vs = gavl_audio_frame_copy(format, dest, fifoPtr[start], 0, 0, format->samples_per_frame, format->samples_per_frame) ; dest->timestamp = fifoPtr[start]->timestamp; dest->valid_samples = vs; if ( ++start >= size ) start = 0; count--; ret = true; } pthread_mutex_unlock (&mut); //Dump("Got a frame "); return ret; } /* void FifoAudioFrames::Dump( char * c) { int i,j = 0; pthread_mutex_lock (&mut); printf("%s -----------------------\n", c); for( i=0;i= size) // j = j -size; j=i; if ( j == start) textcolor(BRIGHT, GREEN, BLACK); if (j == end) textcolor(BRIGHT, RED, BLACK); if (j == end && j == start) textcolor(BRIGHT, YELLOW, BLACK); printf("[%d]=%ld ", j, fifoPtr[j]->timestamp); textcolor(RESET, BLACK, WHITE); } printf("\n"); printf("start=%02d, end=%02d, count=%02d\n", start,end,count); printf("-----------------------\n"); pthread_mutex_unlock (&mut); } */ bool FifoAudioFrames::FreeSpace() { bool ret = false; //printf("asking for free space on audio fifo\n"); pthread_mutex_lock(&mut); ret = (count < size); pthread_mutex_unlock (&mut); return ret; } bool FifoAudioFrames::isEmpty() { bool c; pthread_mutex_lock(&mut); c = (count == 0) ; pthread_mutex_unlock (&mut); return c; } bool FifoAudioFrames::isFull() { bool c; pthread_mutex_lock(&mut); c = (count == size ); pthread_mutex_unlock (&mut); return c; } gavl_audio_format_t * FifoAudioFrames::getFormat() { return format; }; float FifoAudioFrames::getSizePercentage() { float ret; pthread_mutex_lock(&mut);ret = count / (float) size; pthread_mutex_unlock (&mut); return ret;}; readanysf~0.43/src/.svn/text-base/ReadMedia.h.svn-base0000444000175000017500000001270112017676342022216 0ustar augustaugust/* * Copyright (C) 2003-2010 August Black * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ifndef _READMEDIA_H_ #define _READMEDIA_H_ #include #include #include #include "FifoAudioFrames.h" #include "FifoVideoFrames.h" #ifndef _AVDEC_H_ #define _AVDEC_H_ extern "C" { #include } #endif #define STATE_EMPTY 0 #define STATE_OPENING 1 #define STATE_READY 2 #define SRC_MAX 256.0 #define SRC_MIN 1/256.0 #define CMD_START 3 #define CMD_NULL 0 #define CMD_OPEN 1 #define CMD_QUIT 2 #define SEEK_NOTHING -1 #define SEEK_REWIND -2 class ReadMedia { public: ReadMedia(); ~ReadMedia(); void openFile( char * filename, int vfifosize, int afifosize, int samples_per_frame); int decodeAudio( gavl_audio_frame_t *af); int decodeVideo( gavl_video_frame_t *vf); bool isReady(); // see if file is loaded or not bool getEOF(); bool rewind(); bool rewindNoFlush(); bool frameSeek(int64_t frames); bool pcmSeek(int64_t samples); bool timeSeek(double seconds); int getAudioSamplerate(); int getAudioChannelCount(); int getVideoTimescale(); double getLengthInSeconds(); gavl_time_t getLengthInGavlTime(); int64_t getLengthInAudioSamples(); int64_t getLengthInVideoFrames(); int getAudioStreamCount(); int getVideoStreamCount(); // this is used to sync AV frames void pealOffVideoFrames(int howmany); void dump() { lockState(); if (m_file != NULL) bgav_dump(m_file); unlockState(); }; double getATimeInSeconds(); double getVTimeInSeconds(); //float getTimeInSeconds(); float getAudioFifoSizePercentage(); void copyAudioFormat(gavl_audio_format_t * dst ); void copyVideoFormat(gavl_video_format_t * dst ); void setLoop( bool b); bool getLoop(); //||||||||||||||||||||||||||||||||||||||||||||||||||||||||| // NON-PUBLIC public functions //||||||||||||||||||||||||||||||||||||||||||||||||||||||||| int64_t pcmSeek(); int64_t frameSeek(); //bool seek(gavl_time_t gt); void killAVThreads(); bool startAVThreads(); void setAudioStreamCount(int s); void setVideoStreamCount(int s); FifoAudioFrames * getAudioFifo(); FifoVideoFrames * getVideoFifo(); bgav_t * getFile(); char * getFilename(); gavl_audio_frame_t * getAudioFrame(); gavl_video_frame_t * getVideoFrame(); void closeFile(); void clearFile(); void setState(int b); int getState(); gavl_audio_format_t * getAudioFormat() { return &m_audio_format;}; gavl_video_format_t * getVideoFormat() { return &m_video_format;}; void setCommand( int c); int getCommand(); void setAEOF(bool b); void setVEOF(bool b); bool getAEOF(); bool getVEOF(); int getSamplesPerFrame(); int lockAV(); int unlockAV(); //int lockAV(const char *s); //int unlockAV(const char *s); int lockState(); int unlockState(); //int lockState(const char *s); //int unlockState(const char *s); void waitA(); void waitV(); void signalAV(); void signalA(); void signalV(); void waitDispatch(); void signalDispatcher(); bool initFormat(); void setOpenCallback(void (*oc)(void *), void *v ); void callOpenCallback(); void setBufferCallback( bgav_buffer_callback bc, void *v ); bool quitAVThreads(); private: bool quit_av_threads; // callbacks for open, input buffer etc. void * m_open_callback_data; void (* m_open_callback)(void * v); bgav_buffer_callback m_buffer_callback; void * m_buffer_callback_data; // end of file for audio and video bool m_aeof; bool m_veof; // seek vars int64_t m_pcm_seek; int64_t m_frame_seek; double m_length_in_seconds; gavl_time_t m_length_in_gavltime; int64_t m_num_samples; int64_t m_num_frames; // command for dispatcher thread int m_cmd; // internal state of media reader and // current filename int m_state; char m_filename[1024]; bool m_loop; // current time of audio in seconds //double m_atime; //double m_vtime; int m_afifosize; int m_vfifosize; int m_audio_stream_count; int m_video_stream_count; bgav_t * m_file; bgav_options_t * m_opt; // audio stuff gavl_audio_frame_t * m_audio_frame; gavl_audio_format_t m_audio_format; //video stuff gavl_video_frame_t * m_video_frame; gavl_video_format_t m_video_format; FifoAudioFrames *m_fifoaudio; FifoVideoFrames *m_fifovideo; int m_audio_thread_ret; int m_video_thread_ret; int m_dispatcher_thread_ret; pthread_t m_thread_fillaudiofifo; pthread_t m_thread_fillvideofifo; pthread_t m_thread_dispatch; pthread_mutex_t m_condmut_a; pthread_mutex_t m_condmut_v; pthread_mutex_t m_condmut_dispatch; pthread_mutex_t m_state_mut; pthread_mutex_t m_av_mut; pthread_cond_t m_cond_a; pthread_cond_t m_cond_v; pthread_cond_t m_cond_dispatch; }; #endif readanysf~0.43/src/.svn/all-wcprops0000444000175000017500000000215212017676342017006 0ustar augustaugustK 25 svn:wc:ra_dav:version-url V 71 /svnroot/pure-data/!svn/ver/15685/trunk/externals/august/readanysf~/src END FifoVideoFrames.h K 25 svn:wc:ra_dav:version-url V 89 /svnroot/pure-data/!svn/ver/14200/trunk/externals/august/readanysf~/src/FifoVideoFrames.h END ReadMedia.h K 25 svn:wc:ra_dav:version-url V 83 /svnroot/pure-data/!svn/ver/14200/trunk/externals/august/readanysf~/src/ReadMedia.h END FifoAudioFrames.cpp K 25 svn:wc:ra_dav:version-url V 91 /svnroot/pure-data/!svn/ver/14200/trunk/externals/august/readanysf~/src/FifoAudioFrames.cpp END FifoAudioFrames.h K 25 svn:wc:ra_dav:version-url V 89 /svnroot/pure-data/!svn/ver/14200/trunk/externals/august/readanysf~/src/FifoAudioFrames.h END FifoVideoFrames.cpp K 25 svn:wc:ra_dav:version-url V 91 /svnroot/pure-data/!svn/ver/14200/trunk/externals/august/readanysf~/src/FifoVideoFrames.cpp END readanysf~.cpp K 25 svn:wc:ra_dav:version-url V 86 /svnroot/pure-data/!svn/ver/15685/trunk/externals/august/readanysf~/src/readanysf~.cpp END ReadMedia.cpp K 25 svn:wc:ra_dav:version-url V 85 /svnroot/pure-data/!svn/ver/14578/trunk/externals/august/readanysf~/src/ReadMedia.cpp END readanysf~0.43/src/.svn/tmp/0000775000175000017500000000000012017676342015424 5ustar augustaugustreadanysf~0.43/src/.svn/tmp/props/0000775000175000017500000000000012017676342016567 5ustar augustaugustreadanysf~0.43/src/.svn/tmp/prop-base/0000775000175000017500000000000012017676342017314 5ustar augustaugustreadanysf~0.43/src/.svn/tmp/text-base/0000775000175000017500000000000012017676342017320 5ustar augustaugustreadanysf~0.43/src/ReadMedia.cpp0000664000175000017500000007756612017676342016304 0ustar augustaugust/* * Copyright (C) 2003-2010 August Black * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include "ReadMedia.h" #include #include //usleep static void *the_thread_dispatcher(void * xp); static void *the_thread_opener(void * xp); static void *the_audiofifo_filler(void * xp); static void *the_videofifo_filler(void * xp); ReadMedia::ReadMedia( ) { m_state = STATE_EMPTY; m_audio_frame = NULL; m_video_frame = NULL; m_aeof = true; m_veof = true; //m_atime = 0.0; //m_vtime = 0.0; m_video_stream_count =0; m_audio_stream_count =0; m_pcm_seek = SEEK_NOTHING; m_frame_seek = SEEK_NOTHING; m_length_in_seconds=0.0; m_length_in_gavltime = 0; m_num_frames=0; m_num_samples=0; m_video_format.frame_width=0; m_video_format.frame_height=0; m_video_format.image_width=0; m_video_format.image_height=0; m_video_format.pixel_width=0; m_video_format.pixel_height=0; m_video_format.pixelformat = GAVL_PIXELFORMAT_NONE ; m_video_format.frame_duration=0; m_video_format.timescale=0; m_video_format.framerate_mode=GAVL_FRAMERATE_CONSTANT; m_video_format.chroma_placement=GAVL_CHROMA_PLACEMENT_DEFAULT; m_video_format.interlace_mode=GAVL_INTERLACE_NONE; m_video_format.timecode_format.int_framerate =0; m_video_format.timecode_format.flags =0; m_audio_format.samples_per_frame = 0; m_audio_format.samplerate = 0; m_audio_format.num_channels = 0; m_audio_format.sample_format = GAVL_SAMPLE_NONE ; m_audio_format.interleave_mode = GAVL_INTERLEAVE_NONE; m_audio_format.center_level = 1.0; m_audio_format.rear_level = 1.0; m_audio_format.channel_locations[0] = GAVL_CHID_NONE; // Reset m_fifoaudio= NULL; // new FifoAudioFrames( frames_in_fifo , &tmp_audio_lormat); m_fifovideo= NULL; // new FifoVideoFrames( 12 , &output_video_format); m_audio_thread_ret = -1; m_video_thread_ret = -1; m_open_callback = NULL; m_open_callback_data = NULL; m_buffer_callback = NULL; m_buffer_callback_data = NULL; quit_av_threads = false; m_loop = false; sprintf(m_filename, "seinettbitte!"); //bgav stuff m_file = NULL; m_opt = bgav_options_create(); bgav_options_set_connect_timeout(m_opt, 5000); bgav_options_set_read_timeout(m_opt, 5000); bgav_options_set_network_bandwidth(m_opt, 524300); bgav_options_set_network_buffer_size(m_opt, 1024*12); bgav_options_set_http_shoutcast_metadata (m_opt, 1); // set up the reading so that we can seek sample accurately bgav_options_set_sample_accurate (m_opt, 1 ); pthread_cond_init(&m_cond_dispatch, 0); pthread_mutex_init(&m_condmut_dispatch, 0); pthread_cond_init(&m_cond_a, 0); pthread_cond_init(&m_cond_v, 0); pthread_mutex_init(&m_condmut_a, 0); pthread_mutex_init(&m_condmut_v, 0); pthread_mutex_init(&m_av_mut, 0); pthread_mutex_init(&m_state_mut, 0); // start the dispatcher thread m_cmd = CMD_START; m_dispatcher_thread_ret = pthread_create(&m_thread_dispatch, NULL, the_thread_dispatcher, (void *)this) ; if (m_dispatcher_thread_ret != 0 ) printf("error starting the readmedia dispatcher thread.\n"); while( getCommand() != CMD_NULL) signalDispatcher(); //printf("dispatcher ready ...\n"); } ReadMedia::~ReadMedia() { printf("killing the media..\n"); setCommand( CMD_QUIT ); signalDispatcher(); // signal dispatcher joins the opener and AV threads pthread_join( m_thread_dispatch, NULL); //printf("joined dispatcher\n"); if (m_audio_frame != NULL) { gavl_audio_frame_destroy(m_audio_frame); } if (m_video_frame != NULL) { gavl_video_frame_destroy(m_video_frame); } if (m_file != NULL) { bgav_close(m_file); } //printf("now, on to deleting fifo...\n"); if( m_fifoaudio != NULL) delete m_fifoaudio; if( m_fifovideo != NULL) delete m_fifovideo; // these are created only once bgav_options_destroy(m_opt); pthread_cond_destroy(&m_cond_dispatch); pthread_mutex_destroy(&m_condmut_dispatch); pthread_cond_destroy(&m_cond_a); pthread_cond_destroy(&m_cond_v); pthread_mutex_destroy(&m_condmut_a); pthread_mutex_destroy(&m_condmut_v); pthread_mutex_destroy(&m_av_mut); pthread_mutex_destroy(&m_state_mut); printf("killed the media..\n"); } int ReadMedia::decodeVideo( gavl_video_frame_t * vf ) { // check state first, if state is ready, we can check the other vars without locking lockState(); if (m_state != STATE_READY || m_video_stream_count < 1 || m_fifovideo == NULL ) { unlockState(); return -1; } if (!m_fifovideo->Get( vf ) ) { if ( m_veof ) { m_frame_seek = SEEK_NOTHING; unlockState(); signalV(); return 0; } else { //printf("Couldn't get a video frame, videofifo is %f full\n", m_fifovideo->getSizePercentage()); // this can only happen if the fifo is empty unlockState(); signalV(); return -1; // return with error } } //m_vtime = vf->timestamp / (double)m_video_format.timescale; unlockState(); signalV(); return 1 ; } int ReadMedia::decodeAudio( gavl_audio_frame_t * af ) { lockState(); if (m_state != STATE_READY || m_audio_stream_count < 1 || m_fifoaudio == NULL ) { unlockState(); return -1; } if ( !m_fifoaudio->Get( af ) ) { if ( m_aeof ) { m_pcm_seek = SEEK_NOTHING; unlockState(); signalA(); return 0; } else { printf("Couldn't get an audio frame, audiofifo is %f full.\n", m_fifoaudio->getSizePercentage()); // this can only happen if the fifo is empty unlockState(); signalA(); return -1; } } //m_atime = af->timestamp / (double)m_audio_format.samplerate; unlockState(); signalA(); return 1 ; } bool ReadMedia::rewind() { // NOTE!! Always check for stream count before setting aeof or veof lockState(); if ( m_state == STATE_READY && m_file != NULL) { //printf("ReadMedia::rewind(), valid_samples=%d\n", m_audio_frame->valid_samples); m_pcm_seek = SEEK_REWIND; if(m_audio_stream_count) m_aeof = false; //m_atime = 0; m_frame_seek=SEEK_REWIND; if (m_video_stream_count) m_veof = false; //m_vtime=0; unlockState(); if (m_audio_stream_count) { signalA(); // only signal one or the other here //printf("ReadMedia::rewind(), signaled audio\n"); // we are gong to flush here even though it is flushed // during the audio or video thread. This will ensure our fifo // is clean and empty. Otherwise, the audio thread may be waiting // at the bottom of its loop and not make it to the flush part even // though we signalled it. if (m_fifoaudio) m_fifoaudio->Flush(); } else if (m_video_stream_count) { signalV(); if (m_fifovideo) m_fifovideo->Flush(); } return true; } unlockState(); return false; } gavl_time_t ReadMedia::getLengthInGavlTime() { gavl_time_t time = 0; lockState(); time = m_length_in_gavltime; unlockState(); return time; } double ReadMedia::getLengthInSeconds() { double secs = 0.0; lockState(); secs = m_length_in_seconds; unlockState(); return secs; } int64_t ReadMedia::getLengthInAudioSamples() { int64_t samples = 0; lockState(); samples = m_num_samples; unlockState(); return samples; } int64_t ReadMedia::getLengthInVideoFrames() { int64_t frames = 0; lockState(); frames = m_num_frames; unlockState(); return frames; } bool ReadMedia::frameSeek( int64_t frames ) { lockState(); if (m_state == STATE_READY && m_file && bgav_can_seek( m_file ) && frames >= 0 && frames < m_num_frames ) { m_frame_seek = frames; unlockState(); signalAV(); return true; } else { m_frame_seek = SEEK_NOTHING; unlockState(); return false; } } // NOT PUBLIC int64_t ReadMedia::frameSeek() { int64_t tmp=SEEK_NOTHING; lockState(); tmp = m_frame_seek; m_frame_seek = SEEK_NOTHING; unlockState(); return tmp; } bool ReadMedia::pcmSeek( int64_t samples ) { lockState(); if (m_state == STATE_READY && m_file && bgav_can_seek( m_file) && samples >= 0 && samples < m_num_samples ) { m_pcm_seek = samples; unlockState(); signalAV(); return true; } else { m_pcm_seek = SEEK_NOTHING; unlockState(); return false; } } // NOT PUBLIC int64_t ReadMedia::pcmSeek() { int64_t tmp=SEEK_NOTHING; lockState(); tmp = m_pcm_seek; m_pcm_seek = SEEK_NOTHING; unlockState(); return tmp; } bool ReadMedia::timeSeek(double seconds) { gavl_time_t gt = gavl_seconds_to_time( seconds ) ; lockState(); if (m_state == STATE_READY && m_file && bgav_can_seek( m_file) && seconds >= 0.0 && seconds < m_length_in_seconds ) { if (m_audio_stream_count) { m_pcm_seek = gavl_time_to_samples(m_audio_format.samplerate, gt ); if (m_pcm_seek >= m_num_samples || m_pcm_seek < 0) m_pcm_seek = SEEK_NOTHING; unlockState(); signalAV(); return true; } else if ( m_video_stream_count && m_video_format.framerate_mode == GAVL_FRAMERATE_CONSTANT ) { m_frame_seek = gavl_time_to_frames( m_video_format.timescale, m_video_format.frame_duration, gt ); if (m_frame_seek >= m_num_frames || m_frame_seek < 0 ) m_frame_seek = SEEK_NOTHING; unlockState(); signalAV(); return true; } } unlockState(); return false; } bool ReadMedia::quitAVThreads() { bool b =false; lockState(); b = quit_av_threads; unlockState(); return b; } void ReadMedia::openFile( char * fn, int vsize, int asize, int spf) { lockState(); /* if ( strcmp(m_filename, fn) == 0 && m_state == STATE_READY) { printf("%s is already open for action. \n", m_filename); unlockState(); callOpenCallback(); return; } */ // signal the dispatcher that we want an new file m_audio_format.samples_per_frame = spf ; m_afifosize = asize; m_vfifosize = vsize; sprintf(m_filename, "%s", fn); m_cmd = CMD_OPEN ; unlockState(); signalDispatcher(); } void ReadMedia::copyAudioFormat(gavl_audio_format_t * dst ){ lockState(); //if (m_state == STATE_READY) gavl_audio_format_copy(dst, &m_audio_format); unlockState(); } void ReadMedia::copyVideoFormat(gavl_video_format_t * dst ){ lockState(); //if (m_state == STATE_READY) gavl_video_format_copy( dst, &m_video_format); unlockState(); } int ReadMedia::getAudioSamplerate() { int sr=0; lockState(); //if (m_state == STATE_READY ) sr = m_audio_format.samplerate; unlockState(); return sr; } int ReadMedia::getAudioChannelCount() { int ch=0; lockState(); //if (m_state == STATE_READY ) ch = m_audio_format.num_channels; unlockState(); return ch; } int ReadMedia::getVideoTimescale() { int t=0; lockState(); t = m_video_format.timescale; unlockState(); return t; } char * ReadMedia::getFilename() { return m_filename; } bgav_t * ReadMedia::getFile() {return m_file;} FifoAudioFrames * ReadMedia::getAudioFifo() { return m_fifoaudio; } FifoVideoFrames * ReadMedia::getVideoFifo() { return m_fifovideo; } gavl_audio_frame_t * ReadMedia::getAudioFrame() { return m_audio_frame;} gavl_video_frame_t * ReadMedia::getVideoFrame() { return m_video_frame;} void ReadMedia::setState(int b) { lockState(); m_state = b; unlockState(); } int ReadMedia::getState() { int s=STATE_EMPTY; lockState(); s = m_state; unlockState(); return s; } bool ReadMedia::isReady() { if ( getState() == STATE_READY) return true; else return false;} // no need to lock on these //double ReadMedia::getATimeInSeconds() { return m_atime;}; //double ReadMedia::getVTimeInSeconds() { return m_vtime;}; /* float ReadMedia::getTimeInSeconds() { lockState(); if (m_audio_stream_count > 0 ) { unlockState(); return m_atime; } else { // FIXME : see if the following is really true unlockState(); return m_vtime; } }; */ float ReadMedia::getAudioFifoSizePercentage() { float f=0.0; lockState(); if (m_fifoaudio) f = m_fifoaudio->getSizePercentage(); unlockState(); return f; } void ReadMedia::pealOffVideoFrames( int howmany) { lockAV(); if (m_fifovideo == NULL) { unlockAV(); return; } int max = howmany > m_fifovideo->getSize() ? m_fifovideo->getSize() : howmany; for (int i=0;i< max; i++) { m_fifovideo->Get(); //printf("pealing of a video frame size = %d\n", m_fifovideo->getSize()); } unlockAV(); } void ReadMedia::setAEOF(bool b) { lockState(); m_aeof = b; m_pcm_seek = SEEK_NOTHING; unlockState(); } void ReadMedia::setVEOF(bool b) { lockState(); m_veof = b; m_frame_seek = SEEK_NOTHING; unlockState(); } bool ReadMedia::getEOF() { bool tmp = true; lockState(); if (m_state == STATE_READY) tmp = (m_aeof && m_veof); unlockState(); //printf("ReadMedia:getEOF=%d, aeof=%d, veof=%d\n", tmp, m_aeof, m_veof); return tmp; } void ReadMedia::setLoop( bool b) { lockState(); m_loop = b; unlockState(); } bool ReadMedia::getLoop() { bool tmp = true; lockState(); if (m_file && bgav_can_seek( m_file) ) { tmp = m_loop; } else { tmp = false; // we can't loop on file, return false // but leave the loop var untouched } unlockState(); return tmp; } // NOT PUBILC // only used in fifo filler bool ReadMedia::getAEOF() { bool tmp = false; lockState(); tmp = m_aeof; unlockState(); return tmp; } // NOT PUBLIC bool ReadMedia::getVEOF() { bool tmp = false; lockState(); tmp = m_veof; unlockState(); return tmp; } int ReadMedia::getSamplesPerFrame() { int spf=0; lockState(); spf = m_audio_format.samples_per_frame; unlockState(); return spf; } int ReadMedia::lockAV() { //printf("locking AV\n"); return pthread_mutex_lock(&m_av_mut); } int ReadMedia::unlockAV() { //printf("unlocking AV\n"); return pthread_mutex_unlock(&m_av_mut); } int ReadMedia::lockState() { // printf("locking state.\n"); return pthread_mutex_lock(&m_state_mut); } int ReadMedia::unlockState() { //printf("unlocking state.\n"); return pthread_mutex_unlock(&m_state_mut); } void ReadMedia::waitA() { pthread_cond_wait( &m_cond_a, &m_condmut_a); } void ReadMedia::waitV() { pthread_cond_wait( &m_cond_v, &m_condmut_v); } void ReadMedia::signalAV() { signalA(); signalV(); } void ReadMedia::signalA() { pthread_cond_signal( &m_cond_a); } void ReadMedia::signalV() { pthread_cond_signal( &m_cond_v); } void ReadMedia::signalDispatcher() { pthread_cond_signal( &m_cond_dispatch); } void ReadMedia::waitDispatch() { pthread_cond_wait( &m_cond_dispatch, &m_condmut_dispatch); } void ReadMedia::setOpenCallback(void (*oc)(void *), void *v ) { lockState();// do we need this? m_open_callback = oc; m_open_callback_data = v; unlockState(); } void ReadMedia::callOpenCallback() { // do NOT lock on the callback, user must do call public functions // that also lock if(m_open_callback != NULL) m_open_callback( m_open_callback_data); }; void ReadMedia::setBufferCallback(bgav_buffer_callback bc, void *v ) { lockState(); m_buffer_callback = bc; m_buffer_callback_data = v; // set up callbacks. if (m_buffer_callback) { bgav_options_set_buffer_callback( m_opt, m_buffer_callback, m_buffer_callback_data); } unlockState(); }; int ReadMedia::getAudioStreamCount() { int asc=0; lockState(); asc = m_audio_stream_count; unlockState(); return asc; } int ReadMedia::getVideoStreamCount() { int vsc=0; lockState(); vsc = m_video_stream_count; unlockState(); return vsc; } // NOT PUBLIC void ReadMedia::setAudioStreamCount(int s){ lockState(); m_audio_stream_count=s; if (s == 0) // no audio streams, we are already at audio eof m_aeof = true; else m_aeof = false; unlockState(); } // NOT PUBLIC void ReadMedia::setVideoStreamCount(int s){ lockState(); m_video_stream_count=s; if (s==0) // if there are no video streams, video is at eof m_veof = true; else m_veof =false; unlockState(); } // NOT PUBLIC void ReadMedia::setCommand(int s){ lockState(); m_cmd = s; unlockState(); } // NOT PUBLIC int ReadMedia::getCommand() { int cmd= CMD_NULL; lockState(); cmd = m_cmd; unlockState(); return cmd; } // NOT PUBLIC // Clears the bgav_t struct, destroying and then creating it // NO NEED TO DO AV LOCK, only called in the opener thread void ReadMedia::clearFile() { if (m_file != NULL) bgav_close( m_file ); m_file = bgav_create(); bgav_options_copy( bgav_get_options( m_file ) , m_opt); m_aeof = true; m_veof = true; m_pcm_seek = SEEK_NOTHING; m_frame_seek = SEEK_NOTHING; } // NOT PUBLIC // Closes the bgav_t struct, destroying it and setting to NULL // NO NEED TO DO AV LOCK, only called in the opener thread void ReadMedia::closeFile() { if (m_file != NULL) bgav_close( m_file ); m_file = NULL; m_aeof = true; m_veof = true; m_pcm_seek = SEEK_NOTHING; m_frame_seek = SEEK_NOTHING; sprintf(m_filename, "seinettbitte!"); } // NOT PUBLIC // killAVThreads is only called from the opener thread // and from the destructor // THIS IS NOT REALLY A PUBLIC function void ReadMedia::killAVThreads() { lockState(); m_state = STATE_EMPTY; quit_av_threads = true; unlockState(); signalAV(); signalAV(); // FIRST need to join the threads that exist and are running if (m_audio_thread_ret == 0) { pthread_join( m_thread_fillaudiofifo, NULL); //pthread_detach( m_thread_fillaudiofifo); } if (m_video_thread_ret == 0){ pthread_join( m_thread_fillvideofifo, NULL); //pthread_detach( m_thread_fillvideofifo); } m_audio_thread_ret = -1; m_video_thread_ret = -1; // no need to lock here quit_av_threads = false; } // NOT PUBLIC // Only called from the opener thread bool ReadMedia::startAVThreads() { if (m_audio_thread_ret == 0 || m_video_thread_ret == 0 ) { // ouch!, we have running AV threads, this is not good return false; } if (m_audio_stream_count > 0) { m_audio_thread_ret = pthread_create(&m_thread_fillaudiofifo, NULL, the_audiofifo_filler, (void *)this); if (m_audio_thread_ret != 0 ) { printf("ReadMedia:: problem starting the audio thread\n"); return false; } } if (m_video_stream_count > 0) { m_video_thread_ret = pthread_create(&m_thread_fillvideofifo, NULL, the_videofifo_filler, (void *)this); if (m_video_thread_ret != 0 ) { printf("ReadMedia:: problem starting the video thread\n"); return false; } } return true; } bool ReadMedia::initFormat() { const gavl_audio_format_t * open_audio_format; const gavl_video_format_t * open_video_format; // we use the m_vfifosize to see if the user app wants video or not // then, we set m_video_stream_count to 0 if he doesn't want video if (m_video_stream_count > 0 && m_vfifosize > 0) { open_video_format = bgav_get_video_format(m_file, 0); if (open_video_format->pixelformat == GAVL_PIXELFORMAT_NONE) { printf("!!!sorry, pixelformat is not recognized.\n"); return false; } // let's check to see if the formats are the same, if they are the same // there is no reason to recreate the fifo or frames if ( gavl_video_formats_equal( &m_video_format, open_video_format) == 0 ) { // the formats are different gavl_video_format_copy (&m_video_format, open_video_format); if (m_video_frame != NULL) gavl_video_frame_destroy(m_video_frame); m_video_frame = gavl_video_frame_create(&m_video_format); gavl_video_frame_clear( m_video_frame, &m_video_format); if (m_fifovideo != NULL) delete m_fifovideo; m_fifovideo= new FifoVideoFrames( m_vfifosize , &m_video_format); } } else { m_video_stream_count = 0; m_veof = true; } // we use the m_afifosize to see if the user app wants audio or not // then, we set m_audio_stream_count to 0 if he doesn't want audio if (m_audio_stream_count > 0 && m_afifosize > 0) { open_audio_format = bgav_get_audio_format(m_file, 0); // we can get audio formats that are unkown if ( open_audio_format->sample_format == GAVL_SAMPLE_NONE) { printf("sorry, this file has unsupported audio.\n"); return false; } if ( gavl_audio_formats_equal(&m_audio_format, open_audio_format) == 0 ) { // audio formats are different // save the old spf int spf = m_audio_format.samples_per_frame; gavl_audio_format_copy(&m_audio_format, open_audio_format); if (m_audio_frame != NULL) { gavl_audio_frame_destroy(m_audio_frame); } // set it back to original m_audio_format.samples_per_frame = spf ; m_audio_frame = gavl_audio_frame_create(&m_audio_format); gavl_audio_frame_mute( m_audio_frame, &m_audio_format); if( m_fifoaudio != NULL ) delete m_fifoaudio; m_fifoaudio = new FifoAudioFrames( m_afifosize , &m_audio_format); } } else { // user doesn't want audio m_audio_stream_count = 0; m_aeof=true; } m_length_in_gavltime = bgav_get_duration ( m_file, 0);; m_length_in_seconds = gavl_time_to_seconds( m_length_in_gavltime ); m_num_samples = 0; m_num_frames = 0; if (m_audio_stream_count) { if ( bgav_can_seek_sample(m_file) == 1 ) { m_num_samples= bgav_audio_duration ( m_file, 0) ; } else { m_num_samples= gavl_time_to_samples( m_audio_format.samplerate , bgav_get_duration ( m_file, 0) ); } } // set frames WE NEED TO take care here for non-constant frame-rates if(m_video_stream_count) { if ( bgav_can_seek_sample(m_file) == 1 && m_video_format.framerate_mode == GAVL_FRAMERATE_CONSTANT) { m_num_frames = bgav_video_duration ( m_file, 0)/ m_video_format.frame_duration; } else if ( bgav_can_seek_sample(m_file) == 1 && m_video_format.framerate_mode == GAVL_FRAMERATE_VARIABLE ) { // FIXME what to do with non constant frame rates? m_num_frames=0; } else { m_num_frames = gavl_time_to_frames( m_video_format.timescale, m_video_format.frame_duration , bgav_get_duration ( m_file, 0) ); } } // printf("m_num_frames =%lld, duration = %lld , vid_duration=%lld\n", // m_num_frames, bgav_get_duration ( m_file, 0), bgav_video_duration ( m_file, 0) ); // set seconds if ( bgav_can_seek_sample(m_file) == 1) { gavl_time_t atime=0,vtime=0; if ( m_audio_stream_count ) atime = gavl_samples_to_time( m_audio_format.samplerate, m_num_samples ); if (m_video_stream_count && m_video_format.frame_duration > 0) { vtime = gavl_frames_to_time( m_video_format.timescale, m_video_format.frame_duration, m_num_frames ); } else if ( m_video_stream_count ) { // non constant framerate vtime = bgav_video_duration( m_file, 0); } // else rely on audio time m_length_in_gavltime = atime > vtime ? atime :vtime; m_length_in_seconds = gavl_time_to_seconds( m_length_in_gavltime ); //printf("atime=%ld, vtime=%ld, l_in_sec=%f\n", atime, vtime, m_length_in_seconds); } m_pcm_seek = SEEK_NOTHING; m_frame_seek = SEEK_NOTHING; return true; } void *the_thread_dispatcher(void *xp) { ReadMedia *rm = (ReadMedia *)xp; int cmd = CMD_NULL; pthread_t thread_open; int start_thread_ret = -1; cmd = rm->getCommand(); while ( cmd != CMD_QUIT ) { if (cmd == CMD_OPEN) { // We already check in the openFile function if the user is trying to open // a file that is already open. // join the opener thread, this will protect again any other calls to open if (start_thread_ret == 0 ) pthread_join( thread_open, NULL ); // we join the AV threads // the opener thread will start the AV threads anew upon success rm->killAVThreads(); start_thread_ret = pthread_create(&thread_open, NULL, the_thread_opener, (void *)rm) ; if (start_thread_ret != 0 ) printf( "Failed to create m_thread_open thread.\n"); } if (rm->getCommand() == CMD_QUIT) break; rm->setCommand( CMD_NULL); rm->waitDispatch(); cmd = rm->getCommand(); } //printf("dispatcher: joining thread open\n"); if( start_thread_ret == 0 ) pthread_join( thread_open , NULL); //printf("dispatcher: joined thread open, joining AV's\n"); rm->killAVThreads(); //printf("dispatcher: joined AV's\n"); pthread_exit(NULL); }; void *the_thread_opener(void *xp) { ReadMedia *rm = NULL; int num_urls=0, num_tracks=0, audio_stream_count=0, video_stream_count =0; rm = (ReadMedia *)xp; rm->setState(STATE_OPENING); // AFTER WE KILL THE THREADS, THERE IS NO NEED TO LOCK AV mutex // ALL functions that want to get info on the file, seek, // or decode a frame, MUST first check the state. If the // state is STATE_READY, then it can perform it's function, // locking on the necessary variables that might conflict with // the AV. // clearFile deletes old file and creates new File rm->clearFile(); if(!bgav_open(rm->getFile(), rm->getFilename())) { printf( "Could not open file %s\n", rm->getFilename()); rm->setState( STATE_EMPTY ); rm->closeFile(); rm->callOpenCallback(); pthread_exit(NULL); //return NULL; } else { printf("opened %s\n", rm->getFilename()); } // check to see if it is a redirector if(bgav_is_redirector( rm->getFile() )) { num_urls = bgav_redirector_get_num_urls( rm->getFile() ); printf( "Found redirector with %d urls inside, we will try to use the first one.\n", num_urls); printf( "Name %d: %s\n", 1, bgav_redirector_get_name(rm->getFile() , 0)); printf("URL %d: %s\n", 1, bgav_redirector_get_url(rm->getFile(), 0)); sprintf(rm->getFilename(), "%s", bgav_redirector_get_url(rm->getFile(), 0) ); rm->clearFile(); if (!bgav_open( rm->getFile(), rm->getFilename() )) { printf("Could not open redirector\n"); rm->setState( STATE_EMPTY ); rm->closeFile(); rm->callOpenCallback(); pthread_exit(NULL); //return NULL; } else { printf("opened redirector %s\n", rm->getFilename()); } } num_tracks = bgav_num_tracks(rm->getFile()); if ( num_tracks ) { bgav_select_track(rm->getFile(), 0); } else { printf("No tracks associated with file:%s\n", rm->getFilename() ); rm->setState( STATE_EMPTY ); rm->closeFile(); rm->callOpenCallback(); pthread_exit(NULL); } audio_stream_count = bgav_num_audio_streams(rm->getFile(), 0); if( audio_stream_count ) bgav_set_audio_stream(rm->getFile(), 0, BGAV_STREAM_DECODE); video_stream_count = bgav_num_video_streams(rm->getFile(), 0); if( video_stream_count ) bgav_set_video_stream(rm->getFile(), 0, BGAV_STREAM_DECODE); rm->setVideoStreamCount(video_stream_count); rm->setAudioStreamCount(audio_stream_count); //printf("astream_count = %d, vstream_count=%d\n", audio_stream_count, video_stream_count); if(!bgav_start(rm->getFile())) { printf( "failed to start file\n"); rm->setState( STATE_EMPTY ); rm->closeFile(); rm->callOpenCallback(); pthread_exit(NULL) ; //return NULL; } if( !rm->initFormat() ){ rm->setState( STATE_EMPTY ); rm->closeFile(); rm->callOpenCallback(); pthread_exit(NULL) ; } if( !rm->startAVThreads() ){ rm->setState( STATE_EMPTY ); rm->closeFile(); rm->callOpenCallback(); pthread_exit(NULL) ; } // AV threads are now running, blocking will be necessary // STATE_READY and callOpenCallback is set/called in the // fifo fill callbacks rm->signalAV(); rm->signalAV(); //extra signal for second thread pthread_exit(NULL); //return NULL; } void *the_audiofifo_filler( void * xp) { int samples_returned=0; ReadMedia *rm = (ReadMedia *)xp; int first = true; int dovideo = rm->getVideoStreamCount(); int spf = rm->getSamplesPerFrame(); int samplerate = rm->getAudioSamplerate(); int64_t seekto = SEEK_NOTHING; int can_seek = bgav_can_seek ( rm->getFile() ); int can_seek_sample = bgav_can_seek_sample ( rm->getFile() ); while ( !rm->quitAVThreads() ) { //while ( rm->getAudioFifo() != NULL && rm->getAudioFifo()->FreeSpace() && !rm->getAEOF() ) { while ( rm->getAudioFifo()->FreeSpace() && !rm->getAEOF() ) { if (rm->quitAVThreads() ) pthread_exit(NULL) ; //return NULL; rm->lockAV(); // check to see if we need to seek // if this is set, we already know we can seek on this file // and don't need to check with bgav_can_seek if ( can_seek ) { seekto = rm->pcmSeek(); if ( seekto != SEEK_NOTHING ) { if ( seekto == SEEK_REWIND) { // bgav_seek_audio ONLY seeks on the audio stream seekto = 0; // bgav_seek_scaled(rm->getFile(), &seekto, samplerate); } //else { bgav_seek_scaled(rm->getFile(), &seekto, samplerate); //} rm->getAudioFifo()->Flush(); if (dovideo && rm->getVideoFifo() ) { rm->getVideoFifo()->Flush(); rm->signalV(); } } } samples_returned = bgav_read_audio(rm->getFile(), rm->getAudioFrame(), 0, spf ); //rm->unlockAV(); if (samples_returned == 0 ) { if( rm->getLoop() ) { if ( can_seek ) { // Now, rewind the file, don't flush the fifo's if (can_seek_sample) { // only seek on audio stream bgav_seek_audio(rm->getFile(), 0, 0); } else { seekto =0; bgav_seek_scaled(rm->getFile(), &seekto, samplerate); if (dovideo && rm->getVideoFifo() ) { rm->setVEOF(false); rm->signalV(); } } // SAVE THIS FOR ANOTHER TIME, OVERLAPPED SMOOTH LOOPING //if ( rm->getLoop() > 1 && bgav_read_audio(rm->getFile(), rm->getAudioFrame(), 0, spf ) ) { // add to the fifo, overlapping // rm->getAudioFifo()->AppendOverlap( rm->getAudioFrame(), 5 ); // } } else { // this file is not seekable, what do we do? printf("cannot seek on file, but we want to loop. setting end of file.\n"); rm->setAEOF(true); } } else { rm->setAEOF(true); } rm->unlockAV(); break; } rm->unlockAV(); if( !rm->getAudioFifo()->Append( rm->getAudioFrame() )) printf("problem with appending Audio Frame\n"); } if (first && !dovideo) { rm->setState( STATE_READY ); rm->callOpenCallback(); first = false; } if (rm->quitAVThreads() ) pthread_exit(NULL); //return NULL; rm->waitA(); } pthread_exit(NULL);//return NULL; } void *the_videofifo_filler( void * xp) { ReadMedia *rm = (ReadMedia *)xp; int ret = 0; int first = true; int doaudio = rm->getAudioStreamCount(); int64_t seekto =SEEK_NOTHING; int can_seek = bgav_can_seek ( rm->getFile() ); int can_seek_sample = bgav_can_seek_sample ( rm->getFile() ); int timescale = rm->getVideoTimescale(); while (!rm->quitAVThreads() ) { while ( rm->getVideoFifo() !=NULL && rm->getVideoFifo()->FreeSpace() && !rm->getVEOF() ) { if (rm->quitAVThreads() ) pthread_exit(NULL);//return NULL; rm->lockAV(); // check to see if we need to seek // if this is set, we already know we can seek on this file // and don't need to check with bgav_can_seek if (can_seek) { seekto = rm->frameSeek(); if ( seekto >= 0 ) { if (doaudio && rm->getAudioFifo() ) rm->getAudioFifo()->Flush(); rm->getVideoFifo()->Flush(); bgav_seek_scaled(rm->getFile(), &seekto, timescale); } else if (seekto == SEEK_REWIND && !doaudio) { // rewind is a special case for Video. rm->getVideoFifo()->Flush(); seekto =0; bgav_seek_scaled(rm->getFile(), &seekto, timescale); } } ret = bgav_read_video(rm->getFile(), rm->getVideoFrame(), 0 ); if ( !ret ) { // only loop from video if there is no audio // audio controls loop timing if ( rm->getLoop() ){ if ( can_seek ) { if (doaudio && can_seek_sample) { // seek on video stream only if we have audio // audio and video seeking are separate in sample accurate // seeking. If no sample accurate seeking, then let audio // handle seeking bgav_seek_video(rm->getFile(), 0,0); } else if (!doaudio) { // if we don't have audio...just seek to 0 seekto=0; bgav_seek_scaled(rm->getFile(), &seekto, timescale); } } else { // if (can_seek) printf ("We want to loop video, but we cannot seek on this video stream,setting VEOF\n"); rm->setVEOF(true); } } else { rm->setVEOF(true); } rm->unlockAV(); break; } rm->unlockAV(); if( !rm->getVideoFifo()->Append( rm->getVideoFrame() )) printf("problem with appending VideoFrame\n"); } // on the first time 'round we will call the open callback // if there is no video in the file, the audio will handle it. if (first) { rm->setState( STATE_READY ); rm->callOpenCallback(); first = false; } if (rm->quitAVThreads() ) pthread_exit(NULL); //return NULL; rm->waitV(); } pthread_exit(NULL); //return NULL; } readanysf~0.43/src/FifoVideoFrames.h0000664000175000017500000000324312017676342017123 0ustar augustaugust/* * Copyright (C) 2003-2010 August Black * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ifndef _FIFOVIDEOFRAMES_H_ #define _FIFOVIDEOFRAMES_H_ #include // memcpy #include #include #ifndef _AVDEC_H_ #define _AVDEC_H_ extern "C" { #include } #endif class FifoVideoFrames { public: FifoVideoFrames(int s, gavl_video_format_t * format) ; ~FifoVideoFrames();// { delete [] fifoPtr; } bool Append( gavl_video_frame_t * af); bool Get( gavl_video_frame_t * af) ; // pop an element off the fifo bool Get( ) ; // discard an element off the fifo void Flush(); //void Dump(char *c); bool FreeSpace(); bool isEmpty(); bool isFull(); void setDebug( bool b); gavl_video_format_t * getFormat(); int getSize(); float getSizePercentage(); private: int size ; // Number of elements on FifoVideoFrames int start ; int end ; int count; gavl_video_frame_t ** fifoPtr ; gavl_video_format_t * format; pthread_mutex_t mut; } ; #endif readanysf~0.43/src/FifoAudioFrames.h0000664000175000017500000000313612017676342017117 0ustar augustaugust/* * Copyright (C) 2003-2010 August Black * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ifndef _FIFOAUDIOFRAMES_H_ #define _FIFOAUDIOFRAMES_H_ #include // memcpy #include #include #ifndef _AVDEC_H_ #define _AVDEC_H_ extern "C" { #include } #endif class FifoAudioFrames { public: FifoAudioFrames(int s, gavl_audio_format_t * format) ; ~FifoAudioFrames();// { delete [] fifoPtr; } bool Append( gavl_audio_frame_t * af); bool Get( gavl_audio_frame_t * af) ; // pop an element off the fifo void Flush(); //void Dump(char *c); bool FreeSpace(); bool isEmpty(); bool isFull(); void setDebug( bool b); gavl_audio_format_t * getFormat(); float getSizePercentage(); private: int size ; // Number of elements on FifoAudioFrames int start ; int end ; int count; gavl_audio_frame_t ** fifoPtr ; gavl_audio_format_t * format; pthread_mutex_t mut; } ; #endif readanysf~0.43/readanysf~-help.pd0000664000175000017500000000726712017676342016612 0ustar augustaugust#N canvas 13 56 842 642 10; #X obj 28 367 dac~; #X obj 28 332 *~ 0; #X obj 69 332 *~ 0; #X obj 651 106 vsl 15 50 0.01 1.3 1 0 empty empty empty 0 -8 0 8 -241291 -1 -1 4411 0; #X msg 112 140 play; #X msg 193 139 pause; #X msg 348 121 speed \$1; #X floatatom 348 98 5 0 0 0 - - -; #X obj 588 15 loadbang; #X msg 390 75 1; #X msg 601 51 \; pd dsp 1 \;; #X floatatom 662 160 5 0 0 0 - - -; #X msg 12 126 open \$1; #X obj 12 98 openpanel; #X obj 12 66 bng 25 250 50 0 empty empty empty 17 7 0 10 -4032 -1 -1 ; #X msg 152 139 stop; #X floatatom 345 173 16 0 0 0 - - -; #X msg 345 193 pcm_seek \$1; #X obj 348 150 hsl 128 15 0 7.368e+06 0 0 empty empty empty -2 -8 0 10 -260818 -1 -1 0 1; #X msg 348 74 0.21; #X msg 78 73 open http://www.fro.at:8008/fro-64.ogg.m3u; #X floatatom 262 552 5 0 0 0 - - -; #X floatatom 308 504 5 0 0 0 - - -; #X floatatom 217 582 5 0 0 0 - - -; #X msg 722 253 loop \$1; #X obj 722 233 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 1; #X floatatom 353 467 5 0 0 0 - - -; #X obj 444 404 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #X obj 217 378 route ready samplerate length cache float bang; #X floatatom 399 435 5 0 0 0 - - -; #X text 262 581 ready: status for when a file is loaded and ready; #X text 306 594 to play. If you load a file from disk or; #X text 306 608 from the net \, it may take a while to load; #X text 305 621 depending on disk activity and net bandwidth.; #X text 394 466 cache: percentage (0.0->1.0) of; #X text 435 479 cache being used.; #X text 469 405 bang: end of file.; #X msg 588 87 0.8; #X obj 29 269 readanysf~ 4 32 256; #X obj 651 179 s v; #X obj 38 294 r v; #X obj 108 332 *~ 0; #X obj 149 332 *~ 0; #X text 671 130 Volume; #X text 217 300 <- readanysf~ has 3 possible creation args 1) number of channels (all channels will be up or down mixed accordingly) default is 2 channels. 2) number of "frames" in the internal buffer. Default=24 3) number of samples per frame in internal buffer. Default is your blocksize.; #X msg 98 96 open http://wnycam.streamguys.com; #X floatatom 494 176 16 0 0 0 - - -; #X obj 497 153 hsl 128 15 0 500 0 0 empty empty empty -2 -8 0 10 -260818 -1 -1 0 1; #X msg 494 196 time_seek \$1; #X msg 329 242 tick 100; #X text 404 231 send cache \, length output every X ticks; #X text 402 244 "tick 1" sends out every single dsp cycle; #X text 720 214 loop on/off; #X text 441 434 float: position of file in seconds; #X text 482 447 relative to the file's samplerate; #X text 347 503 length: total duration of file in seconds; #X text 394 529 (will be empty for network streams); #X text 396 516 relative to file's internal samplerate; #X text 320 553 The samplerate of the file being played.; #X text 168 5 readanysf~ by August Black; #X text 170 40 august@alien.mur.at; #X text 172 26 please send comments \, suggest \, bugs \, donations ->; #X connect 1 0 0 0; #X connect 2 0 0 1; #X connect 3 0 11 0; #X connect 3 0 39 0; #X connect 4 0 38 0; #X connect 5 0 38 0; #X connect 6 0 38 0; #X connect 7 0 6 0; #X connect 8 0 37 0; #X connect 8 0 10 0; #X connect 9 0 7 0; #X connect 12 0 38 0; #X connect 13 0 12 0; #X connect 14 0 13 0; #X connect 15 0 38 0; #X connect 16 0 17 0; #X connect 17 0 38 0; #X connect 18 0 16 0; #X connect 19 0 7 0; #X connect 20 0 38 0; #X connect 24 0 38 0; #X connect 25 0 24 0; #X connect 28 0 23 0; #X connect 28 1 21 0; #X connect 28 2 22 0; #X connect 28 3 26 0; #X connect 28 4 29 0; #X connect 28 5 27 0; #X connect 37 0 3 0; #X connect 38 0 1 0; #X connect 38 1 2 0; #X connect 38 2 41 0; #X connect 38 3 42 0; #X connect 38 4 28 0; #X connect 40 0 1 1; #X connect 40 0 2 1; #X connect 40 0 41 1; #X connect 40 0 42 1; #X connect 45 0 38 0; #X connect 46 0 48 0; #X connect 47 0 46 0; #X connect 48 0 38 0; #X connect 49 0 38 0; readanysf~0.43/readanysf~-meta.pd0000664000175000017500000000031112017676342016567 0ustar augustaugust#N canvas 15 49 200 200 10; #N canvas 15 49 420 300 META 0; #X text 10 10 VERSION 0.4; #X text 10 24 AUTHOR August Black ; #X text 11 39 NAME readanysf~; #X restore 10 10 pd META; readanysf~0.43/anysndfiler.pd0000664000175000017500000000651012017676342016016 0ustar augustaugust#N canvas 403 78 800 378 10; #N canvas 314 180 836 579 loadfast 0; #X obj 398 364 switch~; #X obj 68 55 inlet; #X obj 304 95 loadbang; #X text 63 34 filename; #X obj 396 179 inlet; #X text 421 132 <--- upsampled by factor of 128 \, then switched off ; #X obj 50 401 tabwrite~ \$0-samp-1; #X obj 209 399 tabwrite~ \$0-samp-2; #X msg 396 202 set 64 1 \$1 \, 0; #X msg 304 129 set 64 1 128 \, 0; #X msg 68 110 open \$1; #X msg 511 346 0; #X msg 309 332 1; #X obj 414 403 print starting; #X obj 549 360 print stoping; #X obj 277 281 select 1; #X obj 534 320 t b b; #X floatatom 480 294 5 0 0 0 - - -; #X obj 562 293 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #X msg 111 183 play; #X obj 480 264 route ready bang samplerate length; #X floatatom 597 299 5 0 0 0 - - -; #X floatatom 656 300 5 0 0 0 - - -; #X msg 701 416 resize \$1; #X obj 701 467 s \$0-samp-2; #X obj 701 443 s \$0-samp-1; #X obj 68 247 readanysf~ 2 12 1024; #X obj 699 181 inlet; #X obj 698 337 f; #X obj 671 369 *; #X floatatom 671 392 14 0 0 0 - - -; #X obj 602 427 print size; #X floatatom 716 371 5 0 0 0 - - -; #X obj 277 303 t b b b b; #X obj 655 334 f; #X obj 602 325 t b b; #X obj 580 514 outlet; #X connect 1 0 10 0; #X connect 2 0 9 0; #X connect 4 0 8 0; #X connect 8 0 0 0; #X connect 10 0 26 0; #X connect 11 0 0 0; #X connect 11 0 36 0; #X connect 12 0 0 0; #X connect 12 0 13 0; #X connect 15 0 33 0; #X connect 16 0 11 0; #X connect 16 1 14 0; #X connect 19 0 26 0; #X connect 20 0 15 0; #X connect 20 0 17 0; #X connect 20 1 16 0; #X connect 20 1 18 0; #X connect 20 2 21 0; #X connect 20 3 22 0; #X connect 22 0 34 1; #X connect 23 0 24 0; #X connect 23 0 25 0; #X connect 26 0 6 0; #X connect 26 1 7 0; #X connect 26 2 20 0; #X connect 27 0 28 1; #X connect 28 0 29 1; #X connect 28 0 32 0; #X connect 29 0 30 0; #X connect 30 0 31 0; #X connect 30 0 23 0; #X connect 33 0 6 0; #X connect 33 0 7 0; #X connect 33 1 19 0; #X connect 33 2 12 0; #X connect 33 3 35 0; #X connect 34 0 29 0; #X connect 35 0 34 0; #X connect 35 1 28 0; #X restore 118 186 pd loadfast; #X obj 151 221 bng 15 250 50 0 empty empty done 17 7 1 10 -262144 -1 -1; #X obj 79 71 openpanel; #X msg 79 49 bang; #X obj 413 206 * 44100; #X floatatom 413 145 5 0 0 1 buffer_length_in_seconds - -; #X msg 413 235 resize \$1; #X msg 459 183 22050; #X msg 508 183 44100; #X text 569 185 choose file samplerate; #X obj 79 244 timer; #X obj 79 129 t b a; #X floatatom 79 275 10 0 0 0 - - -; #X obj 413 60 loadbang; #X msg 449 93 \; pd dsp 1; #X msg 413 124 8; #X obj 79 107 symbol; #X msg 152 71 bang; #X floatatom 185 138 5 0 0 0 - - -; #X msg 152 93 64; #X msg 185 94 128; #X msg 218 93 512; #X msg 253 93 1024; #X msg 339 222 const 0; #X obj 507 261 table \$0-samp-1; #X obj 507 287 table \$0-samp-2; #X obj 413 286 s \$0-samp-2; #X obj 413 262 s \$0-samp-1; #X obj 262 140 samplerate~; #X connect 0 0 1 0; #X connect 2 0 16 0; #X connect 3 0 2 0; #X connect 4 0 6 0; #X connect 5 0 4 0; #X connect 6 0 26 0; #X connect 6 0 27 0; #X connect 7 0 4 1; #X connect 8 0 4 1; #X connect 10 0 12 0; #X connect 11 0 10 0; #X connect 11 1 0 0; #X connect 13 0 15 0; #X connect 13 0 14 0; #X connect 13 0 28 0; #X connect 15 0 5 0; #X connect 16 0 11 0; #X connect 17 0 16 0; #X connect 18 0 0 1; #X connect 19 0 18 0; #X connect 20 0 18 0; #X connect 21 0 18 0; #X connect 22 0 18 0; #X connect 23 0 26 0; #X connect 23 0 27 0; #X connect 28 0 0 2; readanysf~0.43/Makefile0000664000175000017500000000676012017701775014621 0ustar augustaugust# Edit these two variables to suit your system. # You need both gavl and gmerlin_avdec libs to compile GAVLPREFIX=/usr/local #GAVLPREFIX=/opt/gmerlin PD_INCLUDES=/usr/include # SHOULDN'T REALLY NEED TO EDIT BELOW HERE VERSION=0.43 UNAME := $(shell uname) ifneq ($(UNAME), Darwin) # simplistic approach to handle Debians non-linux architectures (kFreeBSD, # kHurd) the same as linux UNAME=Linux endif ifeq ($(UNAME), Linux) TARGET=pd_linux STRIP=strip --strip-unneeded PD_LDFLAGS = -L$(GAVLPREFIX)/lib -lgavl -lgmerlin_avdec -lpthread GAVLPATH=$(GAVLPREFIX)/include CXXFLAGS=-Wall PD_CXXFLAGS = -I./ -I$(GAVLPATH) -I$(GAVLPATH)/gavl -I$(GAVLPATH)/gmerlin -I$(PD_INCLUDES) else # assume darwin here GAVLPATH=/sw/include PD_INCLUDES=/Applications/Pd-extended.app/Contents/Resources/include/ TARGET=pd_darwin STRIP=strip -x PD_CXXFLAGS = -I./ -I$(GAVLPATH) -I$(GAVLPATH)/gavl -I$(GAVLPATH)/gmerlin -I$(PD_INCLUDES) PD_CXXFLAGS += -I/sw/include -fast PD_LDFLAGS = -bundle -undefined dynamic_lookup -L/sw/lib -lgavl -lgmerlin_avdec #PD_LDFLAGS += -bundle -bundle_loader $(pd_src)/bin/pd -undefined dynamic_lookup \ # -L/sw/lib -weak_framework Carbon -lc -L/sw/lib -lgavl -lgmerlin_avdec # os 10.4 #PD_CXXFLAGS += -mmacosx-version-min=10.4 -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk #PD_LDFLAGS = -L/sw/lib -lgavl -lgmerlin_avdec \ # -dynamiclib -undefined dynamic_lookup -lsupc++ -mmacosx-version-min=10.4 \ # -lSystem.B -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk endif ############################################## PD_CXXFLAGS += -fPIC PD_CXXFLAGS += $(CXXFLAGS) PD_LDFLAGS += $(LDFLAGS) all: $(TARGET) pd_linux: src/readanysf~.cpp objs/FifoVideoFrames.o objs/FifoAudioFrames.o objs/ReadMedia.o $(CXX) -shared -o readanysf~.pd_linux $(PD_CXXFLAGS) \ src/readanysf~.cpp \ objs/FifoAudioFrames.o \ objs/FifoVideoFrames.o \ objs/ReadMedia.o \ $(PD_LDFLAGS) $(STRIP) readanysf~.pd_linux pd_darwin: src/readanysf~.cpp objs/FifoVideoFrames.o objs/FifoAudioFrames.o objs/ReadMedia.o $(CXX) -o readanysf~.pd_darwin $(PD_CXXFLAGS) \ src/readanysf~.cpp \ objs/FifoAudioFrames.o \ objs/FifoVideoFrames.o \ objs/ReadMedia.o \ $(PD_LDFLAGS) $(STRIP) readanysf~.pd_darwin mkdir -p readanysf~$(VERSION)_MacOSX-Intel mkdir -p readanysf~$(VERSION)_MacOSX-Intel/readanysf~ cp readanysf~.pd_darwin readanysf~-help.pd readanysf~$(VERSION)_MacOSX-Intel/readanysf~ cp READMEmacpkg.txt anysndfiler.pd readanysf~$(VERSION)_MacOSX-Intel/ mv readanysf~$(VERSION)_MacOSX-Intel/READMEmacpkg.txt readanysf~$(VERSION)_MacOSX-Intel/README.txt ./embed-MacOSX-dependencies.sh readanysf~$(VERSION)_MacOSX-Intel/readanysf~ tar -cvf readanysf~$(VERSION)_MacOSX-Intel.tar readanysf~$(VERSION)_MacOSX-Intel/ gzip readanysf~$(VERSION)_MacOSX-Intel.tar objs/ReadMedia.o: src/ReadMedia.cpp src/ReadMedia.h objs/FifoAudioFrames.o objs/FifoVideoFrames.o objs/ $(CXX) -c -o objs/ReadMedia.o src/ReadMedia.cpp $(PD_CXXFLAGS) objs/FifoAudioFrames.o: src/FifoAudioFrames.cpp src/FifoAudioFrames.h objs/ $(CXX) -c -o objs/FifoAudioFrames.o src/FifoAudioFrames.cpp $(PD_CXXFLAGS) objs/FifoVideoFrames.o: src/FifoVideoFrames.cpp src/FifoVideoFrames.h objs/ $(CXX) -c -o objs/FifoVideoFrames.o src/FifoVideoFrames.cpp $(PD_CXXFLAGS) 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 -f objs/*.o readanysf~.pd_* rm -rf objs objs/: mkdir $@