seal 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +1 -0
- data/LICENSE +13 -0
- data/README.md +265 -0
- data/ext/seal/extconf.rb +45 -0
- data/include/al/al.h +724 -0
- data/include/al/alc.h +277 -0
- data/include/al/efx-presets.h +402 -0
- data/include/al/efx.h +758 -0
- data/include/mpg123/mpg123.h +1034 -0
- data/include/ogg/config_types.h +25 -0
- data/include/ogg/ogg.h +210 -0
- data/include/ogg/os_types.h +147 -0
- data/include/seal.h +23 -0
- data/include/seal/buf.h +143 -0
- data/include/seal/core.h +95 -0
- data/include/seal/efs.h +112 -0
- data/include/seal/err.h +93 -0
- data/include/seal/fmt.h +58 -0
- data/include/seal/listener.h +103 -0
- data/include/seal/raw.h +86 -0
- data/include/seal/rvb.h +520 -0
- data/include/seal/src.h +413 -0
- data/include/seal/stream.h +81 -0
- data/include/vorbis/codec.h +243 -0
- data/include/vorbis/vorbisfile.h +206 -0
- data/mpg123/AUTHORS +150 -0
- data/mpg123/COPYING +773 -0
- data/mpg123/ChangeLog +3 -0
- data/mpg123/INSTALL +111 -0
- data/mpg123/Makefile.am +99 -0
- data/mpg123/Makefile.in +1043 -0
- data/mpg123/NEWS +1200 -0
- data/mpg123/NEWS.libmpg123 +133 -0
- data/mpg123/README +203 -0
- data/mpg123/TODO +38 -0
- data/mpg123/aclocal.m4 +1168 -0
- data/mpg123/build/config.guess +1530 -0
- data/mpg123/build/config.sub +1782 -0
- data/mpg123/build/depcomp +707 -0
- data/mpg123/build/install-sh +527 -0
- data/mpg123/build/ltmain.sh +9655 -0
- data/mpg123/build/missing +330 -0
- data/mpg123/configure +20267 -0
- data/mpg123/configure.ac +2178 -0
- data/mpg123/doc/ACCURACY +2 -0
- data/mpg123/doc/BENCHMARKING +110 -0
- data/mpg123/doc/BUGS +3 -0
- data/mpg123/doc/CONTACT +17 -0
- data/mpg123/doc/LICENSE +22 -0
- data/mpg123/doc/Makefile.am +32 -0
- data/mpg123/doc/Makefile.in +490 -0
- data/mpg123/doc/PATENTS +39 -0
- data/mpg123/doc/README.3DNOW +56 -0
- data/mpg123/doc/README.gain +171 -0
- data/mpg123/doc/README.remote +218 -0
- data/mpg123/doc/ROAD_TO_LGPL +270 -0
- data/mpg123/doc/THANKS +13 -0
- data/mpg123/doc/TODO +63 -0
- data/mpg123/doc/doxy_examples.c +21 -0
- data/mpg123/doc/doxygen.conf +41 -0
- data/mpg123/doc/doxyhead.xhtml +12 -0
- data/mpg123/doc/examples/dump_seekindex.c +41 -0
- data/mpg123/doc/examples/extract_frames.c +92 -0
- data/mpg123/doc/examples/feedseek.c +238 -0
- data/mpg123/doc/examples/id3dump.c +178 -0
- data/mpg123/doc/examples/mpg123_to_wav.c +118 -0
- data/mpg123/doc/examples/mpglib.c +92 -0
- data/mpg123/doc/examples/scan.c +47 -0
- data/mpg123/doc/libmpg123_speed.txt +84 -0
- data/mpg123/equalize.dat +37 -0
- data/mpg123/libmpg123.pc.in +11 -0
- data/mpg123/m4/addrconfig.m4 +34 -0
- data/mpg123/m4/libtool.m4 +7982 -0
- data/mpg123/m4/ltoptions.m4 +384 -0
- data/mpg123/m4/ltsugar.m4 +123 -0
- data/mpg123/m4/ltversion.m4 +23 -0
- data/mpg123/m4/lt~obsolete.m4 +98 -0
- data/mpg123/makedll.sh +19 -0
- data/mpg123/man1/mpg123.1 +512 -0
- data/mpg123/mpg123.spec +68 -0
- data/mpg123/mpg123.spec.in +68 -0
- data/mpg123/ports/MSVC++/2005/libmpg123/libmpg123.vcproj +741 -0
- data/mpg123/ports/MSVC++/2008/dump_seekindex/dump_seekindex.vcproj +194 -0
- data/mpg123/ports/MSVC++/2008/feedseek/feedseek.vcproj +195 -0
- data/mpg123/ports/MSVC++/2008/libmpg123/libmpg123.vcproj +1357 -0
- data/mpg123/ports/MSVC++/2008/mpg123.sln +44 -0
- data/mpg123/ports/MSVC++/2008/mpglib/mpglib.vcproj +191 -0
- data/mpg123/ports/MSVC++/2008/scan/scan.vcproj +195 -0
- data/mpg123/ports/MSVC++/2008clr/2008clr.sln +81 -0
- data/mpg123/ports/MSVC++/2008clr/examples/ReplaceReaderclr/Program.cs +435 -0
- data/mpg123/ports/MSVC++/2008clr/examples/ReplaceReaderclr/Properties/AssemblyInfo.cs +36 -0
- data/mpg123/ports/MSVC++/2008clr/examples/ReplaceReaderclr/ReplaceReaderclr.csproj +72 -0
- data/mpg123/ports/MSVC++/2008clr/examples/feedseekclr/Program.cs +331 -0
- data/mpg123/ports/MSVC++/2008clr/examples/feedseekclr/Properties/AssemblyInfo.cs +36 -0
- data/mpg123/ports/MSVC++/2008clr/examples/feedseekclr/feedseekclr.csproj +71 -0
- data/mpg123/ports/MSVC++/2008clr/examples/scanclr/Program.cs +79 -0
- data/mpg123/ports/MSVC++/2008clr/examples/scanclr/Properties/AssemblyInfo.cs +36 -0
- data/mpg123/ports/MSVC++/2008clr/examples/scanclr/scanclr.csproj +70 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/AssemblyInfo.cpp +76 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/ReadMe.txt +165 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/advanced.cpp +91 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/advanced.h +130 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/dllmain.cpp +19 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/enum.h +218 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/error.cpp +48 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/error.h +134 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/id3v1.cpp +92 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/id3v1.h +132 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/id3v2.cpp +138 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/id3v2.h +152 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/mpg123clr.cpp +896 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/mpg123clr.h +953 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/mpg123clr.rc +102 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/mpg123clr.vcproj +328 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/resource.h +14 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/stdafx.cpp +8 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/stdafx.h +38 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/string.cpp +166 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/string.h +265 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/targetver.h +24 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/text.cpp +67 -0
- data/mpg123/ports/MSVC++/2008clr/mpg123clr/text.h +111 -0
- data/mpg123/ports/MSVC++/2010/dump_seekindex/dump_seekindex.vcxproj +90 -0
- data/mpg123/ports/MSVC++/2010/dump_seekindex/dump_seekindex.vcxproj.filters +6 -0
- data/mpg123/ports/MSVC++/2010/feedseek/feedseek.vcxproj +95 -0
- data/mpg123/ports/MSVC++/2010/feedseek/feedseek.vcxproj.filters +6 -0
- data/mpg123/ports/MSVC++/2010/libmpg123/libmpg123.vcxproj +960 -0
- data/mpg123/ports/MSVC++/2010/libmpg123/libmpg123.vcxproj.user +3 -0
- data/mpg123/ports/MSVC++/2010/libmpg123/yasm.exe +0 -0
- data/mpg123/ports/MSVC++/2010/mpg123.sln +38 -0
- data/mpg123/ports/MSVC++/2010/scan/scan.vcxproj +93 -0
- data/mpg123/ports/MSVC++/2010/scan/scan.vcxproj.filters +6 -0
- data/mpg123/ports/MSVC++/CMP3Stream/INCLUDE/CORE/CORE_FileIn.H +15 -0
- data/mpg123/ports/MSVC++/CMP3Stream/INCLUDE/CORE/SourceFilter_MP3.H +139 -0
- data/mpg123/ports/MSVC++/CMP3Stream/INCLUDE/IIEP_Def.H +206 -0
- data/mpg123/ports/MSVC++/CMP3Stream/INCLUDE/IIEP_FileIn.H +167 -0
- data/mpg123/ports/MSVC++/CMP3Stream/README +4 -0
- data/mpg123/ports/MSVC++/CMP3Stream/SOURCE/CORE_FileIn.CPP +462 -0
- data/mpg123/ports/MSVC++/CMP3Stream/SOURCE/CORE_Log.CPP +122 -0
- data/mpg123/ports/MSVC++/CMP3Stream/SOURCE/CORE_Mutex.CPP +35 -0
- data/mpg123/ports/MSVC++/CMP3Stream/SOURCE/SourceFilter_MP3Stream.CPP +586 -0
- data/mpg123/ports/MSVC++/CMP3Stream/libMPG123/PLACE_LIBMPG123_SOURCES_HERE +0 -0
- data/mpg123/ports/MSVC++/CMP3Stream/libMPG123/libMPG123.vcproj +245 -0
- data/mpg123/ports/MSVC++/config.h +35 -0
- data/mpg123/ports/MSVC++/examples/feedseek.c +240 -0
- data/mpg123/ports/MSVC++/examples/scan.c +47 -0
- data/mpg123/ports/MSVC++/mpg123.h +46 -0
- data/mpg123/ports/MSVC++/msvc.c +59 -0
- data/mpg123/ports/README +26 -0
- data/mpg123/ports/Sony_PSP/Makefile.psp +38 -0
- data/mpg123/ports/Sony_PSP/README +11 -0
- data/mpg123/ports/Sony_PSP/config.h +368 -0
- data/mpg123/ports/Sony_PSP/readers.c.patch +2 -0
- data/mpg123/ports/Xcode/config.h +197 -0
- data/mpg123/ports/Xcode/mpg123.h +17 -0
- data/mpg123/ports/Xcode/mpg123.xcodeproj/project.pbxproj +670 -0
- data/mpg123/ports/mpg123_.pas +478 -0
- data/mpg123/scripts/benchmark-cpu.pl +56 -0
- data/mpg123/scripts/tag_lyrics.py +76 -0
- data/mpg123/src/Makefile.am +186 -0
- data/mpg123/src/Makefile.in +1097 -0
- data/mpg123/src/audio.c +725 -0
- data/mpg123/src/audio.h +106 -0
- data/mpg123/src/buffer.c +312 -0
- data/mpg123/src/buffer.h +45 -0
- data/mpg123/src/common.c +240 -0
- data/mpg123/src/common.h +29 -0
- data/mpg123/src/config.h.in +436 -0
- data/mpg123/src/control_generic.c +809 -0
- data/mpg123/src/equalizer.c +48 -0
- data/mpg123/src/genre.c +271 -0
- data/mpg123/src/genre.h +15 -0
- data/mpg123/src/getlopt.c +148 -0
- data/mpg123/src/getlopt.h +77 -0
- data/mpg123/src/httpget.c +700 -0
- data/mpg123/src/httpget.h +66 -0
- data/mpg123/src/legacy_module.c +74 -0
- data/mpg123/src/libmpg123/Makefile.am +141 -0
- data/mpg123/src/libmpg123/Makefile.in +919 -0
- data/mpg123/src/libmpg123/compat.c +138 -0
- data/mpg123/src/libmpg123/compat.h +178 -0
- data/mpg123/src/libmpg123/dct36_3dnow.S +505 -0
- data/mpg123/src/libmpg123/dct36_3dnowext.S +512 -0
- data/mpg123/src/libmpg123/dct64.c +174 -0
- data/mpg123/src/libmpg123/dct64_3dnow.S +712 -0
- data/mpg123/src/libmpg123/dct64_3dnowext.S +714 -0
- data/mpg123/src/libmpg123/dct64_altivec.c +315 -0
- data/mpg123/src/libmpg123/dct64_i386.c +336 -0
- data/mpg123/src/libmpg123/dct64_i486.c +342 -0
- data/mpg123/src/libmpg123/dct64_mmx.S +811 -0
- data/mpg123/src/libmpg123/dct64_neon.S +297 -0
- data/mpg123/src/libmpg123/dct64_neon_float.S +270 -0
- data/mpg123/src/libmpg123/dct64_sse.S +454 -0
- data/mpg123/src/libmpg123/dct64_sse_float.S +401 -0
- data/mpg123/src/libmpg123/dct64_x86_64.S +464 -0
- data/mpg123/src/libmpg123/dct64_x86_64_float.S +426 -0
- data/mpg123/src/libmpg123/debug.h +171 -0
- data/mpg123/src/libmpg123/decode.h +268 -0
- data/mpg123/src/libmpg123/dither.c +119 -0
- data/mpg123/src/libmpg123/dither.h +23 -0
- data/mpg123/src/libmpg123/equalizer.c +17 -0
- data/mpg123/src/libmpg123/equalizer_3dnow.S +70 -0
- data/mpg123/src/libmpg123/feature.c +106 -0
- data/mpg123/src/libmpg123/format.c +521 -0
- data/mpg123/src/libmpg123/frame.c +1046 -0
- data/mpg123/src/libmpg123/frame.h +410 -0
- data/mpg123/src/libmpg123/gapless.h +119 -0
- data/mpg123/src/libmpg123/getbits.h +100 -0
- data/mpg123/src/libmpg123/getcpuflags.S +91 -0
- data/mpg123/src/libmpg123/getcpuflags.h +47 -0
- data/mpg123/src/libmpg123/huffman.h +340 -0
- data/mpg123/src/libmpg123/icy.c +32 -0
- data/mpg123/src/libmpg123/icy.h +38 -0
- data/mpg123/src/libmpg123/icy2utf8.c +438 -0
- data/mpg123/src/libmpg123/icy2utf8.h +10 -0
- data/mpg123/src/libmpg123/id3.c +999 -0
- data/mpg123/src/libmpg123/id3.h +43 -0
- data/mpg123/src/libmpg123/index.c +134 -0
- data/mpg123/src/libmpg123/index.h +59 -0
- data/mpg123/src/libmpg123/intsym.h +256 -0
- data/mpg123/src/libmpg123/l12_integer_tables.h +278 -0
- data/mpg123/src/libmpg123/l2tables.h +164 -0
- data/mpg123/src/libmpg123/l3_integer_tables.h +1002 -0
- data/mpg123/src/libmpg123/layer1.c +155 -0
- data/mpg123/src/libmpg123/layer2.c +371 -0
- data/mpg123/src/libmpg123/layer3.c +2053 -0
- data/mpg123/src/libmpg123/lfs_alias.c +252 -0
- data/mpg123/src/libmpg123/lfs_wrap.c +751 -0
- data/mpg123/src/libmpg123/libmpg123.c +1607 -0
- data/mpg123/src/libmpg123/mangle.h +74 -0
- data/mpg123/src/libmpg123/mpeghead.h +87 -0
- data/mpg123/src/libmpg123/mpg123.h.in +1075 -0
- data/mpg123/src/libmpg123/mpg123lib_intern.h +338 -0
- data/mpg123/src/libmpg123/ntom.c +148 -0
- data/mpg123/src/libmpg123/optimize.c +964 -0
- data/mpg123/src/libmpg123/optimize.h +219 -0
- data/mpg123/src/libmpg123/parse.c +1179 -0
- data/mpg123/src/libmpg123/parse.h +25 -0
- data/mpg123/src/libmpg123/reader.h +137 -0
- data/mpg123/src/libmpg123/readers.c +1235 -0
- data/mpg123/src/libmpg123/sample.h +152 -0
- data/mpg123/src/libmpg123/stringbuf.c +163 -0
- data/mpg123/src/libmpg123/synth.c +816 -0
- data/mpg123/src/libmpg123/synth.h +196 -0
- data/mpg123/src/libmpg123/synth_3dnow.S +318 -0
- data/mpg123/src/libmpg123/synth_3dnowext.S +6 -0
- data/mpg123/src/libmpg123/synth_8bit.c +142 -0
- data/mpg123/src/libmpg123/synth_8bit.h +86 -0
- data/mpg123/src/libmpg123/synth_altivec.c +1057 -0
- data/mpg123/src/libmpg123/synth_arm.S +271 -0
- data/mpg123/src/libmpg123/synth_arm_accurate.S +287 -0
- data/mpg123/src/libmpg123/synth_i486.c +252 -0
- data/mpg123/src/libmpg123/synth_i586.S +336 -0
- data/mpg123/src/libmpg123/synth_i586_dither.S +375 -0
- data/mpg123/src/libmpg123/synth_mmx.S +125 -0
- data/mpg123/src/libmpg123/synth_mono.h +64 -0
- data/mpg123/src/libmpg123/synth_neon.S +123 -0
- data/mpg123/src/libmpg123/synth_neon_accurate.S +173 -0
- data/mpg123/src/libmpg123/synth_neon_float.S +149 -0
- data/mpg123/src/libmpg123/synth_neon_s32.S +168 -0
- data/mpg123/src/libmpg123/synth_ntom.h +213 -0
- data/mpg123/src/libmpg123/synth_real.c +404 -0
- data/mpg123/src/libmpg123/synth_s32.c +411 -0
- data/mpg123/src/libmpg123/synth_sse.S +6 -0
- data/mpg123/src/libmpg123/synth_sse3d.h +246 -0
- data/mpg123/src/libmpg123/synth_sse_accurate.S +294 -0
- data/mpg123/src/libmpg123/synth_sse_float.S +241 -0
- data/mpg123/src/libmpg123/synth_sse_s32.S +306 -0
- data/mpg123/src/libmpg123/synth_stereo_neon.S +175 -0
- data/mpg123/src/libmpg123/synth_stereo_neon_accurate.S +262 -0
- data/mpg123/src/libmpg123/synth_stereo_neon_float.S +220 -0
- data/mpg123/src/libmpg123/synth_stereo_neon_s32.S +247 -0
- data/mpg123/src/libmpg123/synth_stereo_sse_accurate.S +508 -0
- data/mpg123/src/libmpg123/synth_stereo_sse_float.S +416 -0
- data/mpg123/src/libmpg123/synth_stereo_sse_s32.S +540 -0
- data/mpg123/src/libmpg123/synth_stereo_x86_64.S +335 -0
- data/mpg123/src/libmpg123/synth_stereo_x86_64_accurate.S +454 -0
- data/mpg123/src/libmpg123/synth_stereo_x86_64_float.S +396 -0
- data/mpg123/src/libmpg123/synth_stereo_x86_64_s32.S +473 -0
- data/mpg123/src/libmpg123/synth_x86_64.S +244 -0
- data/mpg123/src/libmpg123/synth_x86_64_accurate.S +301 -0
- data/mpg123/src/libmpg123/synth_x86_64_float.S +259 -0
- data/mpg123/src/libmpg123/synth_x86_64_s32.S +312 -0
- data/mpg123/src/libmpg123/synths.h +52 -0
- data/mpg123/src/libmpg123/tabinit.c +294 -0
- data/mpg123/src/libmpg123/tabinit_mmx.S +210 -0
- data/mpg123/src/libmpg123/testcpu.c +35 -0
- data/mpg123/src/libmpg123/true.h +14 -0
- data/mpg123/src/local.c +63 -0
- data/mpg123/src/local.h +21 -0
- data/mpg123/src/metaprint.c +373 -0
- data/mpg123/src/metaprint.h +17 -0
- data/mpg123/src/module.c +306 -0
- data/mpg123/src/module.h +48 -0
- data/mpg123/src/mpg123.c +1405 -0
- data/mpg123/src/mpg123app.h +171 -0
- data/mpg123/src/output/Makefile.am +213 -0
- data/mpg123/src/output/Makefile.in +1238 -0
- data/mpg123/src/output/aix.c +300 -0
- data/mpg123/src/output/alib.c +209 -0
- data/mpg123/src/output/alsa.c +297 -0
- data/mpg123/src/output/arts.c +117 -0
- data/mpg123/src/output/coreaudio.c +370 -0
- data/mpg123/src/output/dummy.c +78 -0
- data/mpg123/src/output/esd.c +167 -0
- data/mpg123/src/output/hp.c +184 -0
- data/mpg123/src/output/jack.c +450 -0
- data/mpg123/src/output/mint.c +197 -0
- data/mpg123/src/output/nas.c +335 -0
- data/mpg123/src/output/openal.c +197 -0
- data/mpg123/src/output/os2.c +665 -0
- data/mpg123/src/output/oss.c +319 -0
- data/mpg123/src/output/portaudio.c +255 -0
- data/mpg123/src/output/pulse.c +164 -0
- data/mpg123/src/output/sdl.c +206 -0
- data/mpg123/src/output/sgi.c +213 -0
- data/mpg123/src/output/sndio.c +161 -0
- data/mpg123/src/output/sun.c +281 -0
- data/mpg123/src/output/win32.c +229 -0
- data/mpg123/src/playlist.c +596 -0
- data/mpg123/src/playlist.h +52 -0
- data/mpg123/src/resolver.c +319 -0
- data/mpg123/src/resolver.h +25 -0
- data/mpg123/src/sfifo.c +146 -0
- data/mpg123/src/sfifo.h +95 -0
- data/mpg123/src/streamdump.c +74 -0
- data/mpg123/src/streamdump.h +20 -0
- data/mpg123/src/term.c +479 -0
- data/mpg123/src/term.h +81 -0
- data/mpg123/src/tests/noise.c +52 -0
- data/mpg123/src/tests/plain_id3.c +109 -0
- data/mpg123/src/tests/seek_accuracy.c +261 -0
- data/mpg123/src/tests/seek_whence.c +56 -0
- data/mpg123/src/tests/testtext.h +34 -0
- data/mpg123/src/tests/text.c +80 -0
- data/mpg123/src/wav.c +464 -0
- data/mpg123/src/wavhead.h +68 -0
- data/mpg123/src/win32_net.c +599 -0
- data/mpg123/src/win32_support.c +191 -0
- data/mpg123/src/win32_support.h +152 -0
- data/mpg123/src/xfermem.c +321 -0
- data/mpg123/src/xfermem.h +74 -0
- data/mpg123/windows-builds.sh +137 -0
- data/msvc/lib/OpenAL32.lib +0 -0
- data/spec/fixtures/heal.ogg +0 -0
- data/spec/fixtures/tone_up.wav +0 -0
- data/spec/seal/buffer_spec.rb +37 -0
- data/spec/seal/core_spec.rb +29 -0
- data/spec/seal/effect_slot_spec.rb +38 -0
- data/spec/seal/listener_spec.rb +33 -0
- data/spec/seal/reverb_spec.rb +51 -0
- data/spec/seal/source_spec.rb +370 -0
- data/spec/seal/stream_spec.rb +38 -0
- data/spec/spec_helper.rb +45 -0
- data/spec/support/attribute_examples.rb +75 -0
- data/spec/support/audio_object_with_format.rb +27 -0
- data/spec/support/movable_object.rb +22 -0
- data/src/libogg/bitwise.c +857 -0
- data/src/libogg/framing.c +2093 -0
- data/src/libvorbis/backends.h +144 -0
- data/src/libvorbis/bitrate.c +253 -0
- data/src/libvorbis/bitrate.h +59 -0
- data/src/libvorbis/block.c +1046 -0
- data/src/libvorbis/codebook.c +484 -0
- data/src/libvorbis/codebook.h +119 -0
- data/src/libvorbis/codec_internal.h +167 -0
- data/src/libvorbis/envelope.c +375 -0
- data/src/libvorbis/envelope.h +80 -0
- data/src/libvorbis/floor0.c +221 -0
- data/src/libvorbis/floor1.c +1100 -0
- data/src/libvorbis/highlevel.h +58 -0
- data/src/libvorbis/info.c +668 -0
- data/src/libvorbis/lookup.c +94 -0
- data/src/libvorbis/lookup.h +32 -0
- data/src/libvorbis/lookup_data.h +192 -0
- data/src/libvorbis/lpc.c +160 -0
- data/src/libvorbis/lpc.h +29 -0
- data/src/libvorbis/lsp.c +456 -0
- data/src/libvorbis/lsp.h +28 -0
- data/src/libvorbis/mapping0.c +816 -0
- data/src/libvorbis/masking.h +785 -0
- data/src/libvorbis/mdct.c +563 -0
- data/src/libvorbis/mdct.h +71 -0
- data/src/libvorbis/misc.h +57 -0
- data/src/libvorbis/os.h +186 -0
- data/src/libvorbis/psy.c +1206 -0
- data/src/libvorbis/psy.h +154 -0
- data/src/libvorbis/registry.c +45 -0
- data/src/libvorbis/registry.h +32 -0
- data/src/libvorbis/res0.c +889 -0
- data/src/libvorbis/scales.h +90 -0
- data/src/libvorbis/sharedbook.c +579 -0
- data/src/libvorbis/smallft.c +1255 -0
- data/src/libvorbis/smallft.h +34 -0
- data/src/libvorbis/synthesis.c +184 -0
- data/src/libvorbis/vorbisfile.c +2337 -0
- data/src/libvorbis/window.c +2135 -0
- data/src/libvorbis/window.h +26 -0
- data/src/rubyext.c +2329 -0
- data/src/seal/buf.c +124 -0
- data/src/seal/core.c +283 -0
- data/src/seal/efs.c +74 -0
- data/src/seal/err.c +118 -0
- data/src/seal/fmt.c +86 -0
- data/src/seal/listener.c +111 -0
- data/src/seal/mpg.c +174 -0
- data/src/seal/mpg.h +24 -0
- data/src/seal/ov.c +180 -0
- data/src/seal/ov.h +22 -0
- data/src/seal/raw.c +59 -0
- data/src/seal/reader.c +102 -0
- data/src/seal/reader.h +59 -0
- data/src/seal/rvb.c +368 -0
- data/src/seal/src.c +654 -0
- data/src/seal/stream.c +109 -0
- data/src/seal/threading.c +66 -0
- data/src/seal/threading.h +20 -0
- data/src/seal/wav.c +297 -0
- data/src/seal/wav.h +23 -0
- data/src/win32api.rb +29 -0
- metadata +563 -0
@@ -0,0 +1,596 @@
|
|
1
|
+
/*
|
2
|
+
playlist: playlist logic
|
3
|
+
|
4
|
+
copyright 1995-2008 by the mpg123 project - free software under the terms of the LGPL 2.1
|
5
|
+
see COPYING and AUTHORS files in distribution or http://mpg123.org
|
6
|
+
initially written by Michael Hipp, outsourced/reorganized by Thomas Orgis
|
7
|
+
|
8
|
+
If we officially support Windows again, we should have this reworked to really cope with Windows paths, too.
|
9
|
+
*/
|
10
|
+
|
11
|
+
#include "mpg123app.h"
|
12
|
+
#include "getlopt.h" /* for loptind */
|
13
|
+
#include "term.h" /* for term_restore */
|
14
|
+
#include "playlist.h"
|
15
|
+
#include "httpget.h"
|
16
|
+
#include <time.h> /* For srand(). */
|
17
|
+
#include "debug.h"
|
18
|
+
|
19
|
+
#ifdef HAVE_RANDOM
|
20
|
+
#define RAND random
|
21
|
+
#define SRAND srandom
|
22
|
+
#else
|
23
|
+
#define RAND rand
|
24
|
+
#define SRAND srand
|
25
|
+
#endif
|
26
|
+
|
27
|
+
/* increase linebuf in blocks of ... bytes */
|
28
|
+
#define LINEBUF_STEP 100
|
29
|
+
|
30
|
+
/* one global instance... add a pointer to this to every function definition and you have OO-style... */
|
31
|
+
playlist_struct pl;
|
32
|
+
|
33
|
+
/*
|
34
|
+
functions to be called from outside and thus declared in the header:
|
35
|
+
|
36
|
+
void prepare_playlist(int argc, char** argv);
|
37
|
+
char *get_next_file(int argc, char **argv);
|
38
|
+
void free_playlist();
|
39
|
+
*/
|
40
|
+
|
41
|
+
/* local functions */
|
42
|
+
|
43
|
+
int add_next_file (int argc, char *argv[]);
|
44
|
+
void shuffle_playlist();
|
45
|
+
void init_playlist();
|
46
|
+
int add_copy_to_playlist(char* new_entry);
|
47
|
+
int add_to_playlist(char* new_entry, char freeit);
|
48
|
+
|
49
|
+
/* used to be init_input */
|
50
|
+
void prepare_playlist(int argc, char** argv)
|
51
|
+
{
|
52
|
+
/*
|
53
|
+
fetch all playlist entries ... I don't consider playlists to be an endless stream.
|
54
|
+
If you want to intentionally hang mpg123 on some other prog that may take infinite time to produce the full list (perhaps load tracks on demand), then just use the remote control and let that program print "load filename" instead of "filename".
|
55
|
+
We may even provide a simple wrapper script that emulates the old playlist reading behaviour (for files and stdin, http playlists are actually a strong point on reading the list in _before_ starting playback since http connections don't last forever).
|
56
|
+
*/
|
57
|
+
init_playlist();
|
58
|
+
while (add_next_file(argc, argv)) {}
|
59
|
+
if(param.verbose > 1)
|
60
|
+
{
|
61
|
+
fprintf(stderr, "\nplaylist in normal order:\n");
|
62
|
+
print_playlist(stderr, 0);
|
63
|
+
fprintf(stderr, "\n");
|
64
|
+
}
|
65
|
+
if(param.shuffle == 1) shuffle_playlist();
|
66
|
+
/* Don't need these anymore, we have copies! */
|
67
|
+
mpg123_free_string(&pl.linebuf);
|
68
|
+
mpg123_free_string(&pl.dir);
|
69
|
+
}
|
70
|
+
|
71
|
+
/* Return a random number >= 0 and < n */
|
72
|
+
static size_t rando(size_t n)
|
73
|
+
{
|
74
|
+
long ran;
|
75
|
+
long limit = RAND_MAX - (RAND_MAX % (long)n);
|
76
|
+
if(n<2) return 0; /* Better settle that here than in an endless loop... */
|
77
|
+
do{ ran = RAND(); }while( ran >= limit );
|
78
|
+
return (size_t)(ran%n);
|
79
|
+
}
|
80
|
+
|
81
|
+
char *get_next_file()
|
82
|
+
{
|
83
|
+
struct listitem *newitem = NULL;
|
84
|
+
|
85
|
+
if(pl.fill == 0) return NULL;
|
86
|
+
|
87
|
+
++pl.playcount;
|
88
|
+
|
89
|
+
/* normal order, just pick next thing */
|
90
|
+
if(param.shuffle < 2)
|
91
|
+
{
|
92
|
+
do
|
93
|
+
{
|
94
|
+
if(pl.pos < pl.fill) newitem = &pl.list[pl.pos];
|
95
|
+
else newitem = NULL;
|
96
|
+
/* if we have rounds left, decrease loop, else reinit loop because it's a new track */
|
97
|
+
if(pl.loop > 0) --pl.loop; /* loop for current track... */
|
98
|
+
if(pl.loop == 0)
|
99
|
+
{
|
100
|
+
pl.loop = param.loop;
|
101
|
+
++pl.pos;
|
102
|
+
}
|
103
|
+
} while(pl.loop == 0 && newitem != NULL);
|
104
|
+
}
|
105
|
+
else
|
106
|
+
{ /* Randomly select files, with repeating... but keep track of current track for playlist printing. */
|
107
|
+
do /* limiting randomness: don't repeat too early */
|
108
|
+
{
|
109
|
+
pl.pos = rando(pl.fill);
|
110
|
+
} while( pl.list[pl.pos].playcount && (pl.playcount - pl.list[pl.pos].playcount) <= pl.fill/2 );
|
111
|
+
|
112
|
+
newitem = &pl.list[pl.pos];
|
113
|
+
}
|
114
|
+
|
115
|
+
/* "-" is STDOUT, "" is dumb, NULL is nothing */
|
116
|
+
if(newitem != NULL)
|
117
|
+
{
|
118
|
+
/* Remember the playback position of the track. */
|
119
|
+
newitem->playcount = pl.playcount;
|
120
|
+
return newitem->url;
|
121
|
+
}
|
122
|
+
else return NULL;
|
123
|
+
}
|
124
|
+
|
125
|
+
/* It doesn't really matter on program exit, but anyway...
|
126
|
+
Make sure you don't free() an item of argv! */
|
127
|
+
void free_playlist()
|
128
|
+
{
|
129
|
+
if(pl.list != NULL)
|
130
|
+
{
|
131
|
+
debug("going to free() the playlist");
|
132
|
+
while(pl.fill)
|
133
|
+
{
|
134
|
+
--pl.fill;
|
135
|
+
debug1("free()ing entry %lu", (unsigned long)pl.fill);
|
136
|
+
if(pl.list[pl.fill].freeit) free(pl.list[pl.fill].url);
|
137
|
+
}
|
138
|
+
free(pl.list);
|
139
|
+
pl.list = NULL;
|
140
|
+
pl.size = 0;
|
141
|
+
debug("free()d the playlist");
|
142
|
+
}
|
143
|
+
mpg123_free_string(&pl.linebuf);
|
144
|
+
mpg123_free_string(&pl.dir);
|
145
|
+
}
|
146
|
+
|
147
|
+
/* the constructor... */
|
148
|
+
void init_playlist()
|
149
|
+
{
|
150
|
+
SRAND(time(NULL));
|
151
|
+
pl.file = NULL;
|
152
|
+
pl.entry = 0;
|
153
|
+
pl.playcount = 0;
|
154
|
+
pl.size = 0;
|
155
|
+
pl.fill = 0;
|
156
|
+
pl.pos = 0;
|
157
|
+
pl.list = NULL;
|
158
|
+
pl.alloc_step = 10;
|
159
|
+
mpg123_init_string(&pl.dir);
|
160
|
+
mpg123_init_string(&pl.linebuf);
|
161
|
+
pl.type = UNKNOWN;
|
162
|
+
pl.loop = param.loop;
|
163
|
+
#ifdef WANT_WIN32_SOCKETS
|
164
|
+
pl.sockd = -1;
|
165
|
+
#endif
|
166
|
+
}
|
167
|
+
|
168
|
+
/*
|
169
|
+
slightly modified find_next_file from mpg123.c
|
170
|
+
now doesn't return the next entry but adds it to playlist struct
|
171
|
+
returns 1 if it found something, 0 on end
|
172
|
+
*/
|
173
|
+
int add_next_file (int argc, char *argv[])
|
174
|
+
{
|
175
|
+
int firstline = 0;
|
176
|
+
|
177
|
+
/* hack for url that has been detected as track, not playlist */
|
178
|
+
if(pl.type == NO_LIST) return 0;
|
179
|
+
|
180
|
+
/* Get playlist dirname to append it to the files in playlist */
|
181
|
+
if (param.listname)
|
182
|
+
{
|
183
|
+
char* slashpos;
|
184
|
+
/* Oh, right... that doesn't look good for Windows... */
|
185
|
+
if ((slashpos=strrchr(param.listname, '/')))
|
186
|
+
{
|
187
|
+
/* up to and including /, with space for \0 */
|
188
|
+
if(mpg123_resize_string(&pl.dir, 2 + slashpos - param.listname))
|
189
|
+
{
|
190
|
+
memcpy(pl.dir.p, param.listname, pl.dir.size-1);
|
191
|
+
pl.dir.p[pl.dir.size-1] = 0;
|
192
|
+
}
|
193
|
+
else
|
194
|
+
{
|
195
|
+
error("cannot allocate memory for list directory!");
|
196
|
+
pl.dir.size = 0;
|
197
|
+
}
|
198
|
+
}
|
199
|
+
}
|
200
|
+
|
201
|
+
if (param.listname || pl.file)
|
202
|
+
{
|
203
|
+
size_t line_offset = 0;
|
204
|
+
#ifndef WANT_WIN32_SOCKETS
|
205
|
+
if (!pl.file)
|
206
|
+
#else
|
207
|
+
if (!pl.file && pl.sockd == -1)
|
208
|
+
#endif
|
209
|
+
{
|
210
|
+
/* empty or "-" */
|
211
|
+
if (!*param.listname || !strcmp(param.listname, "-"))
|
212
|
+
{
|
213
|
+
pl.file = stdin;
|
214
|
+
param.listname = NULL;
|
215
|
+
pl.entry = 0;
|
216
|
+
}
|
217
|
+
else if (!strncmp(param.listname, "http://", 7))
|
218
|
+
{
|
219
|
+
int fd;
|
220
|
+
struct httpdata htd;
|
221
|
+
httpdata_init(&htd);
|
222
|
+
#ifndef WANT_WIN32_SOCKETS
|
223
|
+
fd = http_open(param.listname, &htd);
|
224
|
+
#else
|
225
|
+
fd = win32_net_http_open(param.listname, &htd);
|
226
|
+
#endif
|
227
|
+
debug1("htd.content_type.p: %p", (void*) htd.content_type.p);
|
228
|
+
if(!APPFLAG(MPG123APP_IGNORE_MIME) && htd.content_type.p != NULL)
|
229
|
+
{
|
230
|
+
int mimi;
|
231
|
+
debug1("htd.content_type.p value: %s", htd.content_type.p);
|
232
|
+
mimi = debunk_mime(htd.content_type.p);
|
233
|
+
|
234
|
+
if(mimi & IS_M3U) pl.type = M3U;
|
235
|
+
else if(mimi & IS_PLS) pl.type = PLS;
|
236
|
+
else
|
237
|
+
{
|
238
|
+
#ifndef WANT_WIN32_SOCKETS
|
239
|
+
if(fd >= 0) close(fd);
|
240
|
+
#else
|
241
|
+
if(fd != SOCKET_ERROR) win32_net_close(fd);
|
242
|
+
#endif
|
243
|
+
fd = -1;
|
244
|
+
|
245
|
+
if(mimi & IS_FILE)
|
246
|
+
{
|
247
|
+
pl.type = NO_LIST;
|
248
|
+
if(param.listentry < 0)
|
249
|
+
{
|
250
|
+
printf("#note you gave me a file url, no playlist, so...\n#entry 1\n%s\n", param.listname);
|
251
|
+
return 0;
|
252
|
+
}
|
253
|
+
else
|
254
|
+
{
|
255
|
+
fprintf(stderr, "Note: MIME type indicates that this is no playlist but an mpeg audio file... reopening as such.\n");
|
256
|
+
add_to_playlist(param.listname, 0);
|
257
|
+
return 1;
|
258
|
+
}
|
259
|
+
}
|
260
|
+
error1("Unknown playlist MIME type %s; maybe "PACKAGE_NAME" can support it in future if you report this to the maintainer.", htd.content_type.p);
|
261
|
+
}
|
262
|
+
httpdata_free(&htd);
|
263
|
+
}
|
264
|
+
if(fd < 0)
|
265
|
+
{
|
266
|
+
param.listname = NULL;
|
267
|
+
pl.file = NULL;
|
268
|
+
#ifdef WANT_WIN32_SOCKETS
|
269
|
+
pl.sockd = -1;
|
270
|
+
#endif
|
271
|
+
error("Invalid playlist from http_open()!\n");
|
272
|
+
}
|
273
|
+
else
|
274
|
+
{
|
275
|
+
pl.entry = 0;
|
276
|
+
#ifndef WANT_WIN32_SOCKETS
|
277
|
+
pl.file = fdopen(fd,"r");
|
278
|
+
#else
|
279
|
+
pl.sockd = fd;
|
280
|
+
#endif
|
281
|
+
}
|
282
|
+
}
|
283
|
+
else if (!(pl.file = fopen(param.listname, "rb")))
|
284
|
+
{
|
285
|
+
perror (param.listname);
|
286
|
+
return 0;
|
287
|
+
}
|
288
|
+
else
|
289
|
+
{
|
290
|
+
debug("opened ordinary list file");
|
291
|
+
pl.entry = 0;
|
292
|
+
}
|
293
|
+
if (param.verbose && pl.file) fprintf (stderr, "Using playlist from %s ...\n", param.listname ? param.listname : "standard input");
|
294
|
+
firstline = 1; /* just opened */
|
295
|
+
}
|
296
|
+
/* reading the file line by line */
|
297
|
+
#ifndef WANT_WIN32_SOCKETS
|
298
|
+
while (pl.file)
|
299
|
+
#else
|
300
|
+
while (pl.file || (pl.sockd) != -1)
|
301
|
+
#endif
|
302
|
+
{
|
303
|
+
/*
|
304
|
+
now read a string of arbitrary size...
|
305
|
+
read a chunk, see if lineend, realloc, read another chunk
|
306
|
+
|
307
|
+
fgets reads at most size-1 bytes and always appends the \0
|
308
|
+
*/
|
309
|
+
size_t have = 0;
|
310
|
+
do
|
311
|
+
{
|
312
|
+
/* have is the length of the string read, without the closing \0 */
|
313
|
+
if(pl.linebuf.size <= have+1)
|
314
|
+
{
|
315
|
+
if(!mpg123_resize_string(&pl.linebuf, pl.linebuf.size+LINEBUF_STEP))
|
316
|
+
{
|
317
|
+
error("cannot increase line buffer");
|
318
|
+
break;
|
319
|
+
}
|
320
|
+
}
|
321
|
+
/* I rely on fgets writing the \0 at the end! */
|
322
|
+
#ifndef WANT_WIN32_SOCKETS
|
323
|
+
if(fgets(pl.linebuf.p+have, pl.linebuf.size-have, pl.file))
|
324
|
+
#else
|
325
|
+
if( (pl.file ? (fgets(pl.linebuf.p+have, pl.linebuf.size-have, pl.file)) : (win32_net_fgets(pl.linebuf.p+have, pl.linebuf.size-have, pl.sockd))))
|
326
|
+
#endif
|
327
|
+
{
|
328
|
+
have += strlen(pl.linebuf.p+have);
|
329
|
+
debug2("have read %lu characters into linebuf: [%s]", (unsigned long)have, pl.linebuf.p);
|
330
|
+
}
|
331
|
+
else
|
332
|
+
{
|
333
|
+
debug("fgets failed to deliver something... file ended?");
|
334
|
+
break;
|
335
|
+
}
|
336
|
+
} while(have && pl.linebuf.p[have-1] != '\r' && pl.linebuf.p[have-1] != '\n');
|
337
|
+
if(have)
|
338
|
+
{
|
339
|
+
pl.linebuf.p[strcspn(pl.linebuf.p, "\t\n\r")] = '\0';
|
340
|
+
/* a bit of fuzzyness */
|
341
|
+
if(firstline)
|
342
|
+
{
|
343
|
+
if(pl.type == UNKNOWN)
|
344
|
+
{
|
345
|
+
if(!strcmp("[playlist]", pl.linebuf.p))
|
346
|
+
{
|
347
|
+
fprintf(stderr, "Note: detected Shoutcast/Winamp PLS playlist\n");
|
348
|
+
pl.type = PLS;
|
349
|
+
continue;
|
350
|
+
}
|
351
|
+
else if
|
352
|
+
(
|
353
|
+
(!strncasecmp("#M3U", pl.linebuf.p ,4))
|
354
|
+
||
|
355
|
+
(!strncasecmp("#EXTM3U", pl.linebuf.p ,7))
|
356
|
+
||
|
357
|
+
(param.listname != NULL && (strrchr(param.listname, '.')) != NULL && !strcasecmp(".m3u", strrchr(param.listname, '.')))
|
358
|
+
)
|
359
|
+
{
|
360
|
+
if(param.verbose) fprintf(stderr, "Note: detected M3U playlist type\n");
|
361
|
+
pl.type = M3U;
|
362
|
+
}
|
363
|
+
else
|
364
|
+
{
|
365
|
+
if(param.verbose) fprintf(stderr, "Note: guessed M3U playlist type\n");
|
366
|
+
pl.type = M3U;
|
367
|
+
}
|
368
|
+
}
|
369
|
+
else
|
370
|
+
{
|
371
|
+
if(param.verbose)
|
372
|
+
{
|
373
|
+
fprintf(stderr, "Note: Interpreting as ");
|
374
|
+
switch(pl.type)
|
375
|
+
{
|
376
|
+
case M3U: fprintf(stderr, "M3U"); break;
|
377
|
+
case PLS: fprintf(stderr, "PLS (Winamp/Shoutcast)"); break;
|
378
|
+
default: fprintf(stderr, "???");
|
379
|
+
}
|
380
|
+
fprintf(stderr, " playlist\n");
|
381
|
+
}
|
382
|
+
}
|
383
|
+
firstline = 0;
|
384
|
+
}
|
385
|
+
#if !defined(WIN32)
|
386
|
+
{
|
387
|
+
size_t i;
|
388
|
+
/* convert \ to / (from MS-like directory format) */
|
389
|
+
for (i=0;pl.linebuf.p[i]!='\0';i++)
|
390
|
+
{
|
391
|
+
if (pl.linebuf.p[i] == '\\') pl.linebuf.p[i] = '/';
|
392
|
+
}
|
393
|
+
}
|
394
|
+
#endif
|
395
|
+
if (pl.linebuf.p[0]=='\0') continue; /* skip empty lines... */
|
396
|
+
if (((pl.type == M3U) && (pl.linebuf.p[0]=='#')))
|
397
|
+
{
|
398
|
+
/* a comment line in m3u file */
|
399
|
+
if(param.listentry < 0) printf("%s\n", pl.linebuf.p);
|
400
|
+
continue;
|
401
|
+
}
|
402
|
+
|
403
|
+
/* real filename may start at an offset */
|
404
|
+
line_offset = 0;
|
405
|
+
/* extract path out of PLS */
|
406
|
+
if(pl.type == PLS)
|
407
|
+
{
|
408
|
+
if(!strncasecmp("File", pl.linebuf.p, 4))
|
409
|
+
{
|
410
|
+
/* too lazy to really check for file number... would have to change logic to support unordered file entries anyway */
|
411
|
+
char* in_line;
|
412
|
+
if((in_line = strchr(pl.linebuf.p+4, '=')) != NULL)
|
413
|
+
{
|
414
|
+
/* FileN=? */
|
415
|
+
if(in_line[1] != 0)
|
416
|
+
{
|
417
|
+
++in_line;
|
418
|
+
line_offset = (size_t) (in_line-pl.linebuf.p);
|
419
|
+
}
|
420
|
+
else
|
421
|
+
{
|
422
|
+
fprintf(stderr, "Warning: Invalid PLS line (empty filename) - corrupt playlist file?\n");
|
423
|
+
continue;
|
424
|
+
}
|
425
|
+
}
|
426
|
+
else
|
427
|
+
{
|
428
|
+
fprintf(stderr, "Warning: Invalid PLS line (no '=' after 'File') - corrupt playlist file?\n");
|
429
|
+
continue;
|
430
|
+
}
|
431
|
+
}
|
432
|
+
else
|
433
|
+
{
|
434
|
+
if(param.listentry < 0) printf("#metainfo %s\n", pl.linebuf.p);
|
435
|
+
continue;
|
436
|
+
}
|
437
|
+
}
|
438
|
+
|
439
|
+
/* make paths absolute */
|
440
|
+
/* Windows knows absolute paths with c: in front... should handle this if really supporting win32 again */
|
441
|
+
if
|
442
|
+
(
|
443
|
+
(pl.dir.p != NULL)
|
444
|
+
&& (pl.linebuf.p[line_offset]!='/')
|
445
|
+
&& (pl.linebuf.p[line_offset]!='\\')
|
446
|
+
&& strncmp(pl.linebuf.p+line_offset, "http://", 7)
|
447
|
+
)
|
448
|
+
{
|
449
|
+
size_t need;
|
450
|
+
need = pl.dir.size + strlen(pl.linebuf.p+line_offset);
|
451
|
+
if(pl.linebuf.size < need)
|
452
|
+
{
|
453
|
+
if(!mpg123_resize_string(&pl.linebuf, need))
|
454
|
+
{
|
455
|
+
error("unable to enlarge linebuf for appending path! skipping");
|
456
|
+
continue;
|
457
|
+
}
|
458
|
+
}
|
459
|
+
/* move to have the space at beginning */
|
460
|
+
memmove(pl.linebuf.p+pl.dir.size-1, pl.linebuf.p+line_offset, strlen(pl.linebuf.p+line_offset)+1);
|
461
|
+
/* prepend path */
|
462
|
+
memcpy(pl.linebuf.p, pl.dir.p, pl.dir.size-1);
|
463
|
+
line_offset = 0;
|
464
|
+
}
|
465
|
+
++pl.entry;
|
466
|
+
if(param.listentry < 0) printf("#entry %lu\n%s\n", (unsigned long)pl.entry,pl.linebuf.p+line_offset);
|
467
|
+
else if((param.listentry == 0) || (param.listentry == pl.entry))
|
468
|
+
{
|
469
|
+
add_copy_to_playlist(pl.linebuf.p+line_offset);
|
470
|
+
return 1;
|
471
|
+
}
|
472
|
+
}
|
473
|
+
else
|
474
|
+
{
|
475
|
+
if (param.listname)
|
476
|
+
if(pl.file) fclose (pl.file);
|
477
|
+
param.listname = NULL;
|
478
|
+
pl.file = NULL;
|
479
|
+
#ifdef WANT_WIN32_SOCKETS
|
480
|
+
if( pl.sockd != -1)
|
481
|
+
{
|
482
|
+
win32_net_close(pl.sockd);
|
483
|
+
pl.sockd = -1;
|
484
|
+
}
|
485
|
+
#endif
|
486
|
+
}
|
487
|
+
}
|
488
|
+
}
|
489
|
+
if(loptind < argc)
|
490
|
+
{
|
491
|
+
add_to_playlist(argv[loptind++], 0);
|
492
|
+
return 1;
|
493
|
+
}
|
494
|
+
return 0;
|
495
|
+
}
|
496
|
+
|
497
|
+
void shuffle_playlist()
|
498
|
+
{
|
499
|
+
size_t loop;
|
500
|
+
size_t rannum;
|
501
|
+
if(pl.fill >= 2)
|
502
|
+
{
|
503
|
+
/* Refer to bug 1777621 for discussion on that.
|
504
|
+
It's Durstenfeld... */
|
505
|
+
for (loop = 0; loop < pl.fill; loop++)
|
506
|
+
{
|
507
|
+
struct listitem tmp;
|
508
|
+
rannum = loop + rando(pl.fill-loop);
|
509
|
+
/*
|
510
|
+
Small test on your binary operation skills (^ is XOR):
|
511
|
+
a = b^(a^b)
|
512
|
+
b = (a^b)^(b^(a^b))
|
513
|
+
And, understood? ;-)
|
514
|
+
|
515
|
+
pl.list[loop] ^= pl.list[rannum];
|
516
|
+
pl.list[rannum] ^= pl.list[loop];
|
517
|
+
pl.list[loop] ^= pl.list[rannum];
|
518
|
+
|
519
|
+
But since this is not allowed with pointers and any speed gain questionable (well, saving _some_ memory...), doing it the lame way:
|
520
|
+
*/
|
521
|
+
tmp = pl.list[rannum];
|
522
|
+
pl.list[rannum] = pl.list[loop];
|
523
|
+
pl.list[loop] = tmp;
|
524
|
+
}
|
525
|
+
}
|
526
|
+
|
527
|
+
if(param.verbose > 1)
|
528
|
+
{
|
529
|
+
/* print them */
|
530
|
+
fprintf(stderr, "\nshuffled playlist:\n");
|
531
|
+
print_playlist(stderr, 0);
|
532
|
+
fprintf(stderr, "\n");
|
533
|
+
}
|
534
|
+
}
|
535
|
+
|
536
|
+
void print_playlist(FILE* out, int showpos)
|
537
|
+
{
|
538
|
+
size_t loop;
|
539
|
+
for (loop = 0; loop < pl.fill; loop++)
|
540
|
+
{
|
541
|
+
char *pre = "";
|
542
|
+
if(showpos)
|
543
|
+
pre = (pl.pos>0 && loop==pl.pos-1) ? "> " : " ";
|
544
|
+
|
545
|
+
fprintf(out, "%s%s\n", pre, pl.list[loop].url);
|
546
|
+
}
|
547
|
+
}
|
548
|
+
|
549
|
+
|
550
|
+
int add_copy_to_playlist(char* new_entry)
|
551
|
+
{
|
552
|
+
char* cop;
|
553
|
+
if((cop = (char*) malloc(strlen(new_entry)+1)) != NULL)
|
554
|
+
{
|
555
|
+
strcpy(cop, new_entry);
|
556
|
+
return add_to_playlist(cop, 1);
|
557
|
+
}
|
558
|
+
else return 0;
|
559
|
+
}
|
560
|
+
|
561
|
+
/* add new entry to playlist - no string copy, just the pointer! */
|
562
|
+
int add_to_playlist(char* new_entry, char freeit)
|
563
|
+
{
|
564
|
+
if(pl.fill == pl.size)
|
565
|
+
{
|
566
|
+
struct listitem* tmp = NULL;
|
567
|
+
/* enlarge the list */
|
568
|
+
tmp = (struct listitem*) safe_realloc(pl.list, (pl.size + pl.alloc_step) * sizeof(struct listitem));
|
569
|
+
if(!tmp)
|
570
|
+
{
|
571
|
+
error("unable to allocate more memory for playlist");
|
572
|
+
perror("");
|
573
|
+
return 0;
|
574
|
+
}
|
575
|
+
else
|
576
|
+
{
|
577
|
+
pl.list = tmp;
|
578
|
+
pl.size += pl.alloc_step;
|
579
|
+
}
|
580
|
+
}
|
581
|
+
/* paranoid */
|
582
|
+
if(pl.fill < pl.size)
|
583
|
+
{
|
584
|
+
pl.list[pl.fill].freeit = freeit;
|
585
|
+
pl.list[pl.fill].url = new_entry;
|
586
|
+
pl.list[pl.fill].playcount = 0;
|
587
|
+
++pl.fill;
|
588
|
+
}
|
589
|
+
else
|
590
|
+
{
|
591
|
+
error("playlist memory still too small?!");
|
592
|
+
return 0;
|
593
|
+
}
|
594
|
+
return 1;
|
595
|
+
}
|
596
|
+
|