seal 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,52 @@
|
|
|
1
|
+
/*
|
|
2
|
+
playlist: playlist logic
|
|
3
|
+
|
|
4
|
+
copyright 1995-2007 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
|
+
#ifndef MPG123_PLAYLIST_H
|
|
9
|
+
#define MPG123_PLAYLIST_H
|
|
10
|
+
|
|
11
|
+
#include "mpg123app.h"
|
|
12
|
+
|
|
13
|
+
enum playlist_type { UNKNOWN = 0, M3U, PLS, NO_LIST };
|
|
14
|
+
|
|
15
|
+
typedef struct listitem
|
|
16
|
+
{
|
|
17
|
+
char* url; /* the filename */
|
|
18
|
+
char freeit; /* if it was allocated and should be free()d here */
|
|
19
|
+
size_t playcount; /* has been played as ...th track in overall counting */
|
|
20
|
+
} listitem;
|
|
21
|
+
|
|
22
|
+
typedef struct playlist_struct
|
|
23
|
+
{
|
|
24
|
+
FILE* file; /* the current playlist stream */
|
|
25
|
+
size_t entry; /* entry in the playlist file */
|
|
26
|
+
size_t playcount; /* overall track counter for playback */
|
|
27
|
+
long loop; /* repeat a track n times */
|
|
28
|
+
size_t size;
|
|
29
|
+
size_t fill;
|
|
30
|
+
size_t pos;
|
|
31
|
+
size_t alloc_step;
|
|
32
|
+
struct listitem* list;
|
|
33
|
+
mpg123_string linebuf;
|
|
34
|
+
mpg123_string dir;
|
|
35
|
+
enum playlist_type type;
|
|
36
|
+
#if defined (WANT_WIN32_SOCKETS)
|
|
37
|
+
int sockd; /* Is Win32 socket descriptor working? */
|
|
38
|
+
#endif
|
|
39
|
+
} playlist_struct;
|
|
40
|
+
|
|
41
|
+
extern struct playlist_struct pl;
|
|
42
|
+
|
|
43
|
+
/* create playlist form argv including reading of playlist file */
|
|
44
|
+
void prepare_playlist(int argc, char** argv);
|
|
45
|
+
/* returns the next url to play or NULL when there is none left */
|
|
46
|
+
char *get_next_file();
|
|
47
|
+
/* frees memory that got allocated in prepare_playlist */
|
|
48
|
+
void free_playlist();
|
|
49
|
+
/* Print out the playlist, with optional position indicator. */
|
|
50
|
+
void print_playlist(FILE* out, int showpos);
|
|
51
|
+
|
|
52
|
+
#endif
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
/*
|
|
2
|
+
resolver.c: TCP network stuff, for IPv4 and IPv6
|
|
3
|
+
Oh, and also some URL parsing... extracting host name and such.
|
|
4
|
+
|
|
5
|
+
copyright 2008-2010 by the mpg123 project - free software under the terms of the LGPL 2.1
|
|
6
|
+
see COPYING and AUTHORS files in distribution or http://mpg123.org
|
|
7
|
+
initially written Thomas Orgis (based on httpget.c)
|
|
8
|
+
|
|
9
|
+
The idea is to have everything involving the game between URLs and IPs/connections separated here.
|
|
10
|
+
I begin with the outsourcing of IPv4 stuff, then make the stuff generic.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
#include "mpg123app.h"
|
|
14
|
+
|
|
15
|
+
#ifdef NETWORK
|
|
16
|
+
#include "true.h"
|
|
17
|
+
#include "resolver.h"
|
|
18
|
+
#if !defined (WANT_WIN32_SOCKETS)
|
|
19
|
+
#include <netdb.h>
|
|
20
|
+
#include <sys/param.h>
|
|
21
|
+
#include <sys/socket.h>
|
|
22
|
+
#include <netinet/in.h>
|
|
23
|
+
#include <arpa/inet.h>
|
|
24
|
+
#include <errno.h>
|
|
25
|
+
#include <fcntl.h>
|
|
26
|
+
#endif
|
|
27
|
+
#ifdef HAVE_SYS_SELECT_H
|
|
28
|
+
#include <sys/select.h>
|
|
29
|
+
#endif
|
|
30
|
+
#ifdef HAVE_SYS_TIME_H
|
|
31
|
+
#include <sys/time.h>
|
|
32
|
+
#endif
|
|
33
|
+
#ifdef HAVE_SYS_TYPES_H
|
|
34
|
+
#include <sys/types.h>
|
|
35
|
+
#endif
|
|
36
|
+
#include <unistd.h>
|
|
37
|
+
#include "debug.h"
|
|
38
|
+
|
|
39
|
+
int split_url(mpg123_string *url, mpg123_string *auth, mpg123_string *host, mpg123_string *port, mpg123_string *path)
|
|
40
|
+
{
|
|
41
|
+
size_t pos = 0; /* current position in input URL */
|
|
42
|
+
size_t pos2 = 0; /* another position in input URL */
|
|
43
|
+
char *part = NULL; /* a part of url we work on */
|
|
44
|
+
int ret = TRUE; /* return code */
|
|
45
|
+
/* Zeroing the output strings; not freeing to avoid unnecessary mallocs. */
|
|
46
|
+
if(auth) auth->fill = 0;
|
|
47
|
+
if(host) host->fill = 0;
|
|
48
|
+
if(port) port->fill = 0;
|
|
49
|
+
if(path) path->fill = 0;
|
|
50
|
+
|
|
51
|
+
if(!url || !url->fill || url->p[url->fill-1] != 0)
|
|
52
|
+
{
|
|
53
|
+
error("URL string is not good! (Programmer's fault!?)");
|
|
54
|
+
return FALSE;
|
|
55
|
+
}
|
|
56
|
+
if (!(strncmp(url->p+pos, "http://", 7)))
|
|
57
|
+
pos += 7; /* Drop protocol. */
|
|
58
|
+
|
|
59
|
+
/* Extract user[:passwd]@... */
|
|
60
|
+
if( (part = strchr(url->p+pos,'@')) )
|
|
61
|
+
{
|
|
62
|
+
size_t i;
|
|
63
|
+
size_t partlen = part - url->p - pos;
|
|
64
|
+
int have_auth = TRUE;
|
|
65
|
+
/* User names or passwords don't have "/" in them (?), the "@" wasn't for real if we find such. */
|
|
66
|
+
for(i=0;i<partlen;i++)
|
|
67
|
+
{
|
|
68
|
+
if(url->p[pos+i] == '/' )
|
|
69
|
+
{
|
|
70
|
+
have_auth = FALSE;
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if(have_auth)
|
|
75
|
+
{
|
|
76
|
+
if(auth != NULL && !mpg123_set_substring(auth, url->p, pos, partlen))
|
|
77
|
+
{
|
|
78
|
+
error("Cannot set auth string (out of mem?).");
|
|
79
|
+
return FALSE;
|
|
80
|
+
}
|
|
81
|
+
pos += partlen+1; /* Continuing after the "@". */
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* Extract host name or IP. */
|
|
86
|
+
#ifdef IPV6
|
|
87
|
+
if(url->p[pos] == '[')
|
|
88
|
+
{ /* It's possibly an IPv6 url in [ ] */
|
|
89
|
+
++pos;
|
|
90
|
+
if( (part = strchr(url->p+pos,']')) != NULL)
|
|
91
|
+
{
|
|
92
|
+
pos2 = part-url->p;
|
|
93
|
+
}
|
|
94
|
+
else { error("Malformed IPv6 URL!"); return FALSE; }
|
|
95
|
+
}
|
|
96
|
+
else
|
|
97
|
+
#endif
|
|
98
|
+
for(pos2=pos; pos2 < url->fill-1; ++pos2)
|
|
99
|
+
{
|
|
100
|
+
char a = url->p[pos2];
|
|
101
|
+
if( a == ':' || a == '/') break;
|
|
102
|
+
}
|
|
103
|
+
/* At pos2 there is now either a delimiter or the end. */
|
|
104
|
+
debug4("hostname between %lu and %lu, %lu chars of %s", (unsigned long)pos, (unsigned long)pos2, (unsigned long)(pos2-pos), url->p + pos);
|
|
105
|
+
if(host != NULL && !mpg123_set_substring(host, url->p, pos, pos2-pos))
|
|
106
|
+
{
|
|
107
|
+
error("Cannot set host string (out of mem?).");
|
|
108
|
+
return FALSE;
|
|
109
|
+
}
|
|
110
|
+
pos = pos2;
|
|
111
|
+
|
|
112
|
+
/* Now for the port... */
|
|
113
|
+
if(url->p[pos] == ':')
|
|
114
|
+
{
|
|
115
|
+
pos += 1; /* We begin _after_ the ":". */
|
|
116
|
+
for(pos2=pos; pos2 < url->fill-1; ++pos2)
|
|
117
|
+
if( url->p[pos2] == '/' ) break;
|
|
118
|
+
|
|
119
|
+
/* Check for port being numbers? Not sure if that's needed. */
|
|
120
|
+
if(port) ret = mpg123_set_substring(port, url->p, pos, pos2-pos);
|
|
121
|
+
pos = pos2;
|
|
122
|
+
}
|
|
123
|
+
else if(port) ret = mpg123_set_string(port, "80");
|
|
124
|
+
|
|
125
|
+
if(!ret)
|
|
126
|
+
{
|
|
127
|
+
error("Cannot set port string (out of mem?).");
|
|
128
|
+
return FALSE;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/* Now only the path is left. */
|
|
132
|
+
if(path) ret = mpg123_set_substring(path, url->p, pos, url->fill-1-pos);
|
|
133
|
+
|
|
134
|
+
if(!ret) error("Cannot set path string (out of mem?)");
|
|
135
|
+
|
|
136
|
+
return ret;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/* Switch between blocking and non-blocking mode. */
|
|
140
|
+
#if !defined (WANT_WIN32_SOCKETS)
|
|
141
|
+
static void nonblock(int sock)
|
|
142
|
+
{
|
|
143
|
+
int flags = fcntl(sock, F_GETFL);
|
|
144
|
+
flags |= O_NONBLOCK;
|
|
145
|
+
fcntl(sock, F_SETFL, flags);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
static void block(int sock)
|
|
149
|
+
{
|
|
150
|
+
int flags = fcntl(sock, F_GETFL);
|
|
151
|
+
flags &= ~O_NONBLOCK;
|
|
152
|
+
fcntl(sock, F_SETFL, flags);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/* If we want a timeout, connect non-blocking and wait for that long... */
|
|
156
|
+
static int timeout_connect(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen)
|
|
157
|
+
{
|
|
158
|
+
if(param.timeout > 0)
|
|
159
|
+
{
|
|
160
|
+
int err;
|
|
161
|
+
nonblock(sockfd);
|
|
162
|
+
err = connect(sockfd, serv_addr, addrlen);
|
|
163
|
+
if(err == 0)
|
|
164
|
+
{
|
|
165
|
+
debug("immediately successful");
|
|
166
|
+
block(sockfd);
|
|
167
|
+
return 0;
|
|
168
|
+
}
|
|
169
|
+
else if(errno == EINPROGRESS)
|
|
170
|
+
{
|
|
171
|
+
struct timeval tv;
|
|
172
|
+
fd_set fds;
|
|
173
|
+
tv.tv_sec = param.timeout;
|
|
174
|
+
tv.tv_usec = 0;
|
|
175
|
+
|
|
176
|
+
debug("in progress, waiting...");
|
|
177
|
+
|
|
178
|
+
FD_ZERO(&fds);
|
|
179
|
+
FD_SET(sockfd, &fds);
|
|
180
|
+
err = select(sockfd+1, NULL, &fds, NULL, &tv);
|
|
181
|
+
if(err > 0)
|
|
182
|
+
{
|
|
183
|
+
socklen_t len = sizeof(err);
|
|
184
|
+
if( (getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &err, &len) == 0)
|
|
185
|
+
&& (err == 0) )
|
|
186
|
+
{
|
|
187
|
+
debug("non-blocking connect has been successful");
|
|
188
|
+
block(sockfd);
|
|
189
|
+
return 0;
|
|
190
|
+
}
|
|
191
|
+
else
|
|
192
|
+
{
|
|
193
|
+
error1("connection error: %s", strerror(err));
|
|
194
|
+
return -1;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
else if(err == 0)
|
|
198
|
+
{
|
|
199
|
+
error("connection timed out");
|
|
200
|
+
return -1;
|
|
201
|
+
}
|
|
202
|
+
else
|
|
203
|
+
{
|
|
204
|
+
error1("error from select(): %s", strerror(errno));
|
|
205
|
+
return -1;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
else
|
|
209
|
+
{
|
|
210
|
+
error1("connection failed: %s", strerror(errno));
|
|
211
|
+
return err;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
else
|
|
215
|
+
{
|
|
216
|
+
if(connect(sockfd, serv_addr, addrlen))
|
|
217
|
+
{
|
|
218
|
+
error1("connecton failed: %s", strerror(errno));
|
|
219
|
+
return -1;
|
|
220
|
+
}
|
|
221
|
+
else return 0; /* _good_ */
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
/* So, this then is the only routine that should know about IPv4 or v6 in future. */
|
|
227
|
+
int open_connection(mpg123_string *host, mpg123_string *port)
|
|
228
|
+
{
|
|
229
|
+
#ifndef IPV6 /* The legacy code for IPv4. No real change to keep all compatibility. */
|
|
230
|
+
#ifndef INADDR_NONE
|
|
231
|
+
#define INADDR_NONE 0xffffffff
|
|
232
|
+
#endif
|
|
233
|
+
struct sockaddr_in server;
|
|
234
|
+
struct hostent *myhostent;
|
|
235
|
+
struct in_addr myaddr;
|
|
236
|
+
int isip = 1;
|
|
237
|
+
char *cptr = host->p;
|
|
238
|
+
int sock = -1;
|
|
239
|
+
if(param.verbose>1) fprintf(stderr, "Note: Attempting old-style connection to %s\n", host->p);
|
|
240
|
+
/* Resolve to IP; parse port number. */
|
|
241
|
+
while(*cptr) /* Iterate over characters of hostname, check if it's an IP or name. */
|
|
242
|
+
{
|
|
243
|
+
if ((*cptr < '0' || *cptr > '9') && *cptr != '.')
|
|
244
|
+
{
|
|
245
|
+
isip = 0;
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
248
|
+
cptr++;
|
|
249
|
+
}
|
|
250
|
+
if(!isip)
|
|
251
|
+
{ /* Name lookup. */
|
|
252
|
+
if (!(myhostent = gethostbyname(host->p))) return -1;
|
|
253
|
+
|
|
254
|
+
memcpy (&myaddr, myhostent->h_addr, sizeof(myaddr));
|
|
255
|
+
server.sin_addr.s_addr = myaddr.s_addr;
|
|
256
|
+
}
|
|
257
|
+
else /* Just use the IP. */
|
|
258
|
+
if((server.sin_addr.s_addr = inet_addr(host->p)) == INADDR_NONE)
|
|
259
|
+
return -1;
|
|
260
|
+
|
|
261
|
+
server.sin_port = htons(atoi(port->p));
|
|
262
|
+
server.sin_family = AF_INET;
|
|
263
|
+
|
|
264
|
+
if((sock = socket(PF_INET, SOCK_STREAM, 6)) < 0)
|
|
265
|
+
{
|
|
266
|
+
error1("Cannot create socket: %s", strerror(errno));
|
|
267
|
+
return -1;
|
|
268
|
+
}
|
|
269
|
+
if(timeout_connect(sock, (struct sockaddr *)&server, sizeof(server)))
|
|
270
|
+
return -1;
|
|
271
|
+
#else /* Host lookup and connection in a protocol independent manner. */
|
|
272
|
+
struct addrinfo hints;
|
|
273
|
+
struct addrinfo *addr, *addrlist;
|
|
274
|
+
int ret, sock = -1;
|
|
275
|
+
|
|
276
|
+
if(param.verbose>1) fprintf(stderr, "Note: Attempting new-style connection to %s\n", host->p);
|
|
277
|
+
memset(&hints, 0, sizeof(struct addrinfo));
|
|
278
|
+
hints.ai_family = AF_UNSPEC; /* We accept both IPv4 and IPv6 ... and perhaps IPv8;-) */
|
|
279
|
+
hints.ai_socktype = SOCK_STREAM;
|
|
280
|
+
hints.ai_flags = 0;
|
|
281
|
+
#ifdef HAVE_GAI_ADDRCONFIG
|
|
282
|
+
hints.ai_flags |= AI_ADDRCONFIG; /* Only ask for addresses that we have configured interfaces for. */
|
|
283
|
+
#endif
|
|
284
|
+
ret = getaddrinfo(host->p, port->p, &hints, &addrlist);
|
|
285
|
+
if(ret != 0)
|
|
286
|
+
{
|
|
287
|
+
error3("Resolving %s:%s: %s", host->p, port->p, gai_strerror(ret));
|
|
288
|
+
return -1;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
addr = addrlist;
|
|
292
|
+
while(addr != NULL)
|
|
293
|
+
{
|
|
294
|
+
sock = socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol);
|
|
295
|
+
if(sock >= 0)
|
|
296
|
+
{
|
|
297
|
+
if(timeout_connect(sock, addr->ai_addr, addr->ai_addrlen) == 0)
|
|
298
|
+
break;
|
|
299
|
+
|
|
300
|
+
close(sock);
|
|
301
|
+
sock=-1;
|
|
302
|
+
}
|
|
303
|
+
addr=addr->ai_next;
|
|
304
|
+
}
|
|
305
|
+
if(sock < 0) error2("Cannot resolve/connect to %s:%s!", host->p, port->p);
|
|
306
|
+
|
|
307
|
+
freeaddrinfo(addrlist);
|
|
308
|
+
#endif
|
|
309
|
+
return sock; /* Hopefully, that's an open socket to talk with. */
|
|
310
|
+
}
|
|
311
|
+
#endif /* !defined (WANT_WIN32_SOCKETS) */
|
|
312
|
+
#else /* NETWORK */
|
|
313
|
+
|
|
314
|
+
void resolver_dummy_without_sense()
|
|
315
|
+
{
|
|
316
|
+
/* Some compilers don't like empty source files. */
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
#endif
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
resolver.c: TCP network stuff, for IPv4 and IPv6
|
|
3
|
+
|
|
4
|
+
copyright 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 Thomas Orgis (based on httpget.c)
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
#ifndef MPG123_RESOLVER_H
|
|
10
|
+
#define MPG123_RESOLVER_H
|
|
11
|
+
|
|
12
|
+
#include "mpg123app.h"
|
|
13
|
+
/*
|
|
14
|
+
Split an URL into parts of user:password, hostname, port, path on host.
|
|
15
|
+
There is no name resolution going on here, also no numeric conversion.
|
|
16
|
+
Return code 1 (TRUE) is fine, 0 (FALSE) is bad.
|
|
17
|
+
*/
|
|
18
|
+
int split_url(mpg123_string *url, mpg123_string *auth, mpg123_string *host, mpg123_string *port, mpg123_string *path);
|
|
19
|
+
/*
|
|
20
|
+
Open a connection to specified server and port.
|
|
21
|
+
The arguments are plain strings (hostname or IP, port number as string); any network specific data types are hidden.
|
|
22
|
+
*/
|
|
23
|
+
int open_connection(mpg123_string *host, mpg123_string *port);
|
|
24
|
+
|
|
25
|
+
#endif
|
data/mpg123/src/sfifo.c
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/*
|
|
2
|
+
SFIFO 1.3 Simple portable lock-free FIFO
|
|
3
|
+
|
|
4
|
+
(c) 2000-2002, David Olofson - free software under the terms of the LGPL 2.1
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
-----------------------------------------------------------
|
|
10
|
+
TODO:
|
|
11
|
+
* Is there a way to avoid losing one byte of buffer
|
|
12
|
+
space to avoid extra variables or locking?
|
|
13
|
+
|
|
14
|
+
* Test more compilers and environments.
|
|
15
|
+
-----------------------------------------------------------
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
#include <string.h>
|
|
19
|
+
#include <stdlib.h>
|
|
20
|
+
|
|
21
|
+
#include "sfifo.h"
|
|
22
|
+
#include "debug.h"
|
|
23
|
+
|
|
24
|
+
/*
|
|
25
|
+
* Alloc buffer, init FIFO etc...
|
|
26
|
+
*/
|
|
27
|
+
SFIFO_SCOPE int sfifo_init(sfifo_t *f, int size)
|
|
28
|
+
{
|
|
29
|
+
memset(f, 0, sizeof(sfifo_t));
|
|
30
|
+
|
|
31
|
+
if(size > SFIFO_MAX_BUFFER_SIZE)
|
|
32
|
+
return -EINVAL;
|
|
33
|
+
|
|
34
|
+
/*
|
|
35
|
+
* Set sufficient power-of-2 size.
|
|
36
|
+
*
|
|
37
|
+
* No, there's no bug. If you need
|
|
38
|
+
* room for N bytes, the buffer must
|
|
39
|
+
* be at least N+1 bytes. (The fifo
|
|
40
|
+
* can't tell 'empty' from 'full'
|
|
41
|
+
* without unsafe index manipulations
|
|
42
|
+
* otherwise.)
|
|
43
|
+
*/
|
|
44
|
+
f->size = 1;
|
|
45
|
+
for(; f->size <= size; f->size <<= 1)
|
|
46
|
+
;
|
|
47
|
+
|
|
48
|
+
/* Get buffer */
|
|
49
|
+
if( 0 == (f->buffer = (void *)malloc(f->size)) )
|
|
50
|
+
return -ENOMEM;
|
|
51
|
+
|
|
52
|
+
return 0;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/*
|
|
56
|
+
* Dealloc buffer etc...
|
|
57
|
+
*/
|
|
58
|
+
SFIFO_SCOPE void sfifo_close(sfifo_t *f)
|
|
59
|
+
{
|
|
60
|
+
if(f->buffer) {
|
|
61
|
+
free(f->buffer);
|
|
62
|
+
f->buffer = NULL; /* Prevent double free */
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/*
|
|
67
|
+
* Empty FIFO buffer
|
|
68
|
+
*/
|
|
69
|
+
SFIFO_SCOPE void sfifo_flush(sfifo_t *f)
|
|
70
|
+
{
|
|
71
|
+
/* Reset positions */
|
|
72
|
+
f->readpos = 0;
|
|
73
|
+
f->writepos = 0;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/*
|
|
77
|
+
* Write bytes to a FIFO
|
|
78
|
+
* Return number of bytes written, or an error code
|
|
79
|
+
*/
|
|
80
|
+
SFIFO_SCOPE int sfifo_write(sfifo_t *f, const void *_buf, int len)
|
|
81
|
+
{
|
|
82
|
+
int total;
|
|
83
|
+
int i;
|
|
84
|
+
const char *buf = (const char *)_buf;
|
|
85
|
+
|
|
86
|
+
if(!f->buffer)
|
|
87
|
+
return -ENODEV; /* No buffer! */
|
|
88
|
+
|
|
89
|
+
/* total = len = min(space, len) */
|
|
90
|
+
total = sfifo_space(f);
|
|
91
|
+
debug1("sfifo_space() = %d",total);
|
|
92
|
+
if(len > total)
|
|
93
|
+
len = total;
|
|
94
|
+
else
|
|
95
|
+
total = len;
|
|
96
|
+
|
|
97
|
+
i = f->writepos;
|
|
98
|
+
if(i + len > f->size)
|
|
99
|
+
{
|
|
100
|
+
memcpy(f->buffer + i, buf, f->size - i);
|
|
101
|
+
buf += f->size - i;
|
|
102
|
+
len -= f->size - i;
|
|
103
|
+
i = 0;
|
|
104
|
+
}
|
|
105
|
+
memcpy(f->buffer + i, buf, len);
|
|
106
|
+
f->writepos = i + len;
|
|
107
|
+
|
|
108
|
+
return total;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
/*
|
|
113
|
+
* Read bytes from a FIFO
|
|
114
|
+
* Return number of bytes read, or an error code
|
|
115
|
+
*/
|
|
116
|
+
SFIFO_SCOPE int sfifo_read(sfifo_t *f, void *_buf, int len)
|
|
117
|
+
{
|
|
118
|
+
int total;
|
|
119
|
+
int i;
|
|
120
|
+
char *buf = (char *)_buf;
|
|
121
|
+
|
|
122
|
+
if(!f->buffer)
|
|
123
|
+
return -ENODEV; /* No buffer! */
|
|
124
|
+
|
|
125
|
+
/* total = len = min(used, len) */
|
|
126
|
+
total = sfifo_used(f);
|
|
127
|
+
debug1("sfifo_used() = %d",total);
|
|
128
|
+
if(len > total)
|
|
129
|
+
len = total;
|
|
130
|
+
else
|
|
131
|
+
total = len;
|
|
132
|
+
|
|
133
|
+
i = f->readpos;
|
|
134
|
+
if(i + len > f->size)
|
|
135
|
+
{
|
|
136
|
+
memcpy(buf, f->buffer + i, f->size - i);
|
|
137
|
+
buf += f->size - i;
|
|
138
|
+
len -= f->size - i;
|
|
139
|
+
i = 0;
|
|
140
|
+
}
|
|
141
|
+
memcpy(buf, f->buffer + i, len);
|
|
142
|
+
f->readpos = i + len;
|
|
143
|
+
|
|
144
|
+
return total;
|
|
145
|
+
}
|
|
146
|
+
|