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,252 @@
|
|
|
1
|
+
/*
|
|
2
|
+
lfs_alias: Aliases to the small/native API functions with the size of long int as suffix.
|
|
3
|
+
|
|
4
|
+
copyright 2010 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 Thomas Orgis
|
|
7
|
+
|
|
8
|
+
Use case: Client code on Linux/x86-64 that defines _FILE_OFFSET_BITS to 64, which is the only choice on that platform anyway. It should be no-op, but prompts the platform-agnostic header of mpg123 to define API calls with the corresponding suffix.
|
|
9
|
+
This file provides the names for this case. It's cruft, but glibc does it, too -- so people rely on it.
|
|
10
|
+
Oh, and it also caters for the lunatics that define _FILE_OFFSET_BITS=32 on 32 bit platforms.
|
|
11
|
+
|
|
12
|
+
There is also the strange case that the mpg123 build itself is configured for unnecessary _FILE_OFFSET_BITS == LFS_ALIAS_BITS =^ sizeof(long). In that case, the "native" function will have the suffix and the alias shall be provided without the suffix.
|
|
13
|
+
|
|
14
|
+
So, two basic cases:
|
|
15
|
+
1. mpg123_bla_32 alias for mpg123_bla
|
|
16
|
+
2. mpg123_bla alias for mpg123_bla_32
|
|
17
|
+
Confusing, I know. It sucks.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
#include "config.h"
|
|
21
|
+
|
|
22
|
+
/* Hack for Solaris: Some system headers included from compat.h might force _FILE_OFFSET_BITS. Need to follow that here. */
|
|
23
|
+
#include "compat.h"
|
|
24
|
+
|
|
25
|
+
#ifndef LFS_ALIAS_BITS
|
|
26
|
+
#error "I need the count of alias bits here."
|
|
27
|
+
#endif
|
|
28
|
+
|
|
29
|
+
#define MACROCAT_REALLY(a, b) a ## b
|
|
30
|
+
#define MACROCAT(a, b) MACROCAT_REALLY(a, b)
|
|
31
|
+
|
|
32
|
+
/* This is wicked switchery: Decide which way the aliases are facing. */
|
|
33
|
+
|
|
34
|
+
#if _FILE_OFFSET_BITS+0 == LFS_ALIAS_BITS
|
|
35
|
+
|
|
36
|
+
/* The native functions are actually _with_ suffix, so let the mpg123 header use large file hackery to define the correct interfaces. */
|
|
37
|
+
#include "mpg123.h"
|
|
38
|
+
/* Don't forget to undef the function symbols before usage... */
|
|
39
|
+
|
|
40
|
+
/* The native functions have suffix, the aliases not. */
|
|
41
|
+
#define NATIVE_SUFFIX MACROCAT(_, _FILE_OFFSET_BITS)
|
|
42
|
+
#define NATIVE_NAME(func) MACROCAT(func, NATIVE_SUFFIX)
|
|
43
|
+
#define ALIAS_NAME(func) func
|
|
44
|
+
|
|
45
|
+
#else
|
|
46
|
+
|
|
47
|
+
/* Native functions are without suffix... */
|
|
48
|
+
#define MPG123_NO_LARGENAME
|
|
49
|
+
#include "mpg123.h"
|
|
50
|
+
|
|
51
|
+
/* The alias functions have suffix, the native ones not. */
|
|
52
|
+
#define ALIAS_SUFFIX MACROCAT(_, LFS_ALIAS_BITS)
|
|
53
|
+
#define ALIAS_NAME(func) MACROCAT(func, ALIAS_SUFFIX)
|
|
54
|
+
#define NATIVE_NAME(func) func
|
|
55
|
+
|
|
56
|
+
#endif
|
|
57
|
+
|
|
58
|
+
/* Now get the rest of the infrastructure on speed, namely attribute_align_arg, to stay safe. */
|
|
59
|
+
#include "mpg123lib_intern.h"
|
|
60
|
+
|
|
61
|
+
/*
|
|
62
|
+
Extract the list of functions we need wrappers for, pregenerating the wrappers for simple cases (inline script for nedit):
|
|
63
|
+
perl -ne '
|
|
64
|
+
if(/^\s*EXPORT\s+(\S+)\s+(mpg123_\S+)\((.*)\);\s*$/)
|
|
65
|
+
{
|
|
66
|
+
my $type = $1;
|
|
67
|
+
my $name = $2;
|
|
68
|
+
my $args = $3;
|
|
69
|
+
next unless ($type =~ /off_t/ or $args =~ /off_t/ or ($name =~ /open/ and $name ne mpg123_open_feed));
|
|
70
|
+
$type =~ s/off_t/long/g;
|
|
71
|
+
my @nargs = ();
|
|
72
|
+
$args =~ s/off_t/long/g;
|
|
73
|
+
foreach my $a (split(/,/, $args))
|
|
74
|
+
{
|
|
75
|
+
$a =~ s/^.*\s\**([a-z_]+)$/$1/;
|
|
76
|
+
push(@nargs, $a);
|
|
77
|
+
}
|
|
78
|
+
my $nargs = join(", ", @nargs);
|
|
79
|
+
$nargs = "Human: figure me out." if($nargs =~ /\(/);
|
|
80
|
+
print <<EOT
|
|
81
|
+
|
|
82
|
+
##ifdef $name
|
|
83
|
+
##undef $name
|
|
84
|
+
##endif
|
|
85
|
+
$type attribute_align_arg ALIAS_NAME($name)($args)
|
|
86
|
+
{
|
|
87
|
+
return NATIVE_NAME($name)($nargs);
|
|
88
|
+
}
|
|
89
|
+
EOT
|
|
90
|
+
|
|
91
|
+
}' < mpg123.h.in
|
|
92
|
+
*/
|
|
93
|
+
|
|
94
|
+
#ifdef mpg123_open
|
|
95
|
+
#undef mpg123_open
|
|
96
|
+
#endif
|
|
97
|
+
int attribute_align_arg ALIAS_NAME(mpg123_open)(mpg123_handle *mh, const char *path)
|
|
98
|
+
{
|
|
99
|
+
return NATIVE_NAME(mpg123_open)(mh, path);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
#ifdef mpg123_open_fd
|
|
103
|
+
#undef mpg123_open_fd
|
|
104
|
+
#endif
|
|
105
|
+
int attribute_align_arg ALIAS_NAME(mpg123_open_fd)(mpg123_handle *mh, int fd)
|
|
106
|
+
{
|
|
107
|
+
return NATIVE_NAME(mpg123_open_fd)(mh, fd);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
#ifdef mpg123_open_handle
|
|
111
|
+
#undef mpg123_open_handle
|
|
112
|
+
#endif
|
|
113
|
+
int attribute_align_arg ALIAS_NAME(mpg123_open_handle)(mpg123_handle *mh, void *iohandle)
|
|
114
|
+
{
|
|
115
|
+
return NATIVE_NAME(mpg123_open_handle)(mh, iohandle);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
#ifdef mpg123_decode_frame
|
|
119
|
+
#undef mpg123_decode_frame
|
|
120
|
+
#endif
|
|
121
|
+
int attribute_align_arg ALIAS_NAME(mpg123_decode_frame)(mpg123_handle *mh, long *num, unsigned char **audio, size_t *bytes)
|
|
122
|
+
{
|
|
123
|
+
return NATIVE_NAME(mpg123_decode_frame)(mh, num, audio, bytes);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
#ifdef mpg123_framebyframe_decode
|
|
127
|
+
#undef mpg123_framebyframe_decode
|
|
128
|
+
#endif
|
|
129
|
+
int attribute_align_arg ALIAS_NAME(mpg123_framebyframe_decode)(mpg123_handle *mh, long *num, unsigned char **audio, size_t *bytes)
|
|
130
|
+
{
|
|
131
|
+
return NATIVE_NAME(mpg123_framebyframe_decode)(mh, num, audio, bytes);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
#ifdef mpg123_framepos
|
|
135
|
+
#undef mpg123_framepos
|
|
136
|
+
#endif
|
|
137
|
+
long attribute_align_arg ALIAS_NAME(mpg123_framepos)(mpg123_handle *mh)
|
|
138
|
+
{
|
|
139
|
+
return NATIVE_NAME(mpg123_framepos)(mh);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
#ifdef mpg123_tell
|
|
143
|
+
#undef mpg123_tell
|
|
144
|
+
#endif
|
|
145
|
+
long attribute_align_arg ALIAS_NAME(mpg123_tell)(mpg123_handle *mh)
|
|
146
|
+
{
|
|
147
|
+
return NATIVE_NAME(mpg123_tell)(mh);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
#ifdef mpg123_tellframe
|
|
151
|
+
#undef mpg123_tellframe
|
|
152
|
+
#endif
|
|
153
|
+
long attribute_align_arg ALIAS_NAME(mpg123_tellframe)(mpg123_handle *mh)
|
|
154
|
+
{
|
|
155
|
+
return NATIVE_NAME(mpg123_tellframe)(mh);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
#ifdef mpg123_tell_stream
|
|
159
|
+
#undef mpg123_tell_stream
|
|
160
|
+
#endif
|
|
161
|
+
long attribute_align_arg ALIAS_NAME(mpg123_tell_stream)(mpg123_handle *mh)
|
|
162
|
+
{
|
|
163
|
+
return NATIVE_NAME(mpg123_tell_stream)(mh);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
#ifdef mpg123_seek
|
|
167
|
+
#undef mpg123_seek
|
|
168
|
+
#endif
|
|
169
|
+
long attribute_align_arg ALIAS_NAME(mpg123_seek)(mpg123_handle *mh, long sampleoff, int whence)
|
|
170
|
+
{
|
|
171
|
+
return NATIVE_NAME(mpg123_seek)(mh, sampleoff, whence);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
#ifdef mpg123_feedseek
|
|
175
|
+
#undef mpg123_feedseek
|
|
176
|
+
#endif
|
|
177
|
+
long attribute_align_arg ALIAS_NAME(mpg123_feedseek)(mpg123_handle *mh, long sampleoff, int whence, long *input_offset)
|
|
178
|
+
{
|
|
179
|
+
return NATIVE_NAME(mpg123_feedseek)(mh, sampleoff, whence, input_offset);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
#ifdef mpg123_seek_frame
|
|
183
|
+
#undef mpg123_seek_frame
|
|
184
|
+
#endif
|
|
185
|
+
long attribute_align_arg ALIAS_NAME(mpg123_seek_frame)(mpg123_handle *mh, long frameoff, int whence)
|
|
186
|
+
{
|
|
187
|
+
return NATIVE_NAME(mpg123_seek_frame)(mh, frameoff, whence);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
#ifdef mpg123_timeframe
|
|
191
|
+
#undef mpg123_timeframe
|
|
192
|
+
#endif
|
|
193
|
+
long attribute_align_arg ALIAS_NAME(mpg123_timeframe)(mpg123_handle *mh, double sec)
|
|
194
|
+
{
|
|
195
|
+
return NATIVE_NAME(mpg123_timeframe)(mh, sec);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
#ifdef mpg123_index
|
|
199
|
+
#undef mpg123_index
|
|
200
|
+
#endif
|
|
201
|
+
int attribute_align_arg ALIAS_NAME(mpg123_index)(mpg123_handle *mh, long **offsets, long *step, size_t *fill)
|
|
202
|
+
{
|
|
203
|
+
return NATIVE_NAME(mpg123_index)(mh, offsets, step, fill);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
#ifdef mpg123_set_index
|
|
207
|
+
#undef mpg123_set_index
|
|
208
|
+
#endif
|
|
209
|
+
int attribute_align_arg ALIAS_NAME(mpg123_set_index)(mpg123_handle *mh, long *offsets, long step, size_t fill)
|
|
210
|
+
{
|
|
211
|
+
return NATIVE_NAME(mpg123_set_index)(mh, offsets, step, fill);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
#ifdef mpg123_position
|
|
215
|
+
#undef mpg123_position
|
|
216
|
+
#endif
|
|
217
|
+
int attribute_align_arg ALIAS_NAME(mpg123_position)( mpg123_handle *mh, long frame_offset, long buffered_bytes, long *current_frame, long *frames_left, double *current_seconds, double *seconds_left)
|
|
218
|
+
{
|
|
219
|
+
return NATIVE_NAME(mpg123_position)(mh, frame_offset, buffered_bytes, current_frame, frames_left, current_seconds, seconds_left);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
#ifdef mpg123_length
|
|
223
|
+
#undef mpg123_length
|
|
224
|
+
#endif
|
|
225
|
+
long attribute_align_arg ALIAS_NAME(mpg123_length)(mpg123_handle *mh)
|
|
226
|
+
{
|
|
227
|
+
return NATIVE_NAME(mpg123_length)(mh);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
#ifdef mpg123_set_filesize
|
|
231
|
+
#undef mpg123_set_filesize
|
|
232
|
+
#endif
|
|
233
|
+
int attribute_align_arg ALIAS_NAME(mpg123_set_filesize)(mpg123_handle *mh, long size)
|
|
234
|
+
{
|
|
235
|
+
return NATIVE_NAME(mpg123_set_filesize)(mh, size);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
#ifdef mpg123_replace_reader
|
|
239
|
+
#undef mpg123_replace_reader
|
|
240
|
+
#endif
|
|
241
|
+
int attribute_align_arg ALIAS_NAME(mpg123_replace_reader)(mpg123_handle *mh, ssize_t (*r_read) (int, void *, size_t), long (*r_lseek)(int, long, int))
|
|
242
|
+
{
|
|
243
|
+
return NATIVE_NAME(mpg123_replace_reader)(mh, r_read, r_lseek);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
#ifdef mpg123_replace_reader_handle
|
|
247
|
+
#undef mpg123_replace_reader_handle
|
|
248
|
+
#endif
|
|
249
|
+
int attribute_align_arg ALIAS_NAME(mpg123_replace_reader_handle)(mpg123_handle *mh, ssize_t (*r_read) (void *, void *, size_t), long (*r_lseek)(void *, long, int), void (*cleanup)(void*))
|
|
250
|
+
{
|
|
251
|
+
return NATIVE_NAME(mpg123_replace_reader_handle)(mh, r_read, r_lseek, cleanup);
|
|
252
|
+
}
|
|
@@ -0,0 +1,751 @@
|
|
|
1
|
+
/*
|
|
2
|
+
lfs_wrap: Crappy wrapper code for supporting crappy ambiguous large file support.
|
|
3
|
+
|
|
4
|
+
copyright 2010 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
|
+
|
|
7
|
+
initially written by Thomas Orgis, thanks to Guido Draheim for consulting
|
|
8
|
+
|
|
9
|
+
This file contains wrappers for the case that _FILE_OFFSET_BITS (or equivalent, theoretically, depends on mpg123.h) is defined and thus certain mpg123 API calls get renamed with a suffix (p.ex. _64).
|
|
10
|
+
The renamed calls expect large off_t arguments, and possibly return large off_t values... these wrappers here provide the same functionality with long integer arguments/values.
|
|
11
|
+
|
|
12
|
+
Prototypical idea: There is
|
|
13
|
+
off_t mpg123_seek_64(mpg123_handle*, off_t, int)
|
|
14
|
+
This code provides
|
|
15
|
+
long mpg123_seek(mpg123_handle*, long, int)
|
|
16
|
+
|
|
17
|
+
This is rather simple business... wouldn't mpg123 offer replacing the I/O core with callbacks. Translating the callbacks between long and off_t world is the main reason why this file contains non-trivial code.
|
|
18
|
+
|
|
19
|
+
Note about file descriptors: We just assume that they are generally interchangeable between large and small file code... and that a large file descriptor will trigger errors when accessed with small file code where it may cause trouble (a really large file).
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/* It mainly needs the official API ... */
|
|
23
|
+
/* ... but also some inside access (frame struct, readers). */
|
|
24
|
+
#include "mpg123lib_intern.h"
|
|
25
|
+
/* Include the system headers _after_ the implied config.h!
|
|
26
|
+
Otherwise _FILE_OFFSET_BITS is not in effect! */
|
|
27
|
+
#include <errno.h>
|
|
28
|
+
#include <sys/stat.h>
|
|
29
|
+
#include <fcntl.h>
|
|
30
|
+
#include "compat.h"
|
|
31
|
+
#include "debug.h"
|
|
32
|
+
|
|
33
|
+
/*
|
|
34
|
+
Now, start off easy... translate simple API calls.
|
|
35
|
+
I need to deal with these here:
|
|
36
|
+
perl -ne '
|
|
37
|
+
if(/^\s*EXPORT\s+(\S+)\s+(mpg123_\S+)\((.*)\);\s*$/)
|
|
38
|
+
{
|
|
39
|
+
$type = $1;
|
|
40
|
+
$name = $2;
|
|
41
|
+
$args = $3;
|
|
42
|
+
next unless ($type =~ /off_t/ or $args =~ /off_t/);
|
|
43
|
+
print "$name\n" unless grep {$_ eq $name}
|
|
44
|
+
("mpg123_open", "mpg123_open_fd", "mpg123_open_handle", "mpg123_replace_reader", "mpg123_replace_reader_handle");
|
|
45
|
+
}' < mpg123.h.in
|
|
46
|
+
|
|
47
|
+
mpg123_decode_frame
|
|
48
|
+
mpg123_framebyframe_decode
|
|
49
|
+
mpg123_framepos
|
|
50
|
+
mpg123_tell
|
|
51
|
+
mpg123_tellframe
|
|
52
|
+
mpg123_tell_stream
|
|
53
|
+
mpg123_seek
|
|
54
|
+
mpg123_feedseek
|
|
55
|
+
mpg123_seek_frame
|
|
56
|
+
mpg123_timeframe
|
|
57
|
+
mpg123_index
|
|
58
|
+
mpg123_set_index
|
|
59
|
+
mpg123_position
|
|
60
|
+
mpg123_length
|
|
61
|
+
mpg123_set_filesize
|
|
62
|
+
mpg123_decode_raw ... that's experimental.
|
|
63
|
+
|
|
64
|
+
Let's work on them in that order.
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
/* I see that I will need custom data storage. Main use is for the replaced I/O later, but the seek table for small file offsets needs extra storage, too. */
|
|
68
|
+
|
|
69
|
+
/* The wrapper handle for descriptor and handle I/O. */
|
|
70
|
+
|
|
71
|
+
/* The handle is used for nothing (0), or one of these two modes of operation: */
|
|
72
|
+
#define IO_FD 1 /* Wrapping over callbacks operation on integer file descriptor. */
|
|
73
|
+
#define IO_HANDLE 2 /* Wrapping over custom handle callbacks. */
|
|
74
|
+
|
|
75
|
+
struct wrap_data
|
|
76
|
+
{
|
|
77
|
+
/* Storage for small offset index table. */
|
|
78
|
+
long *indextable;
|
|
79
|
+
/* I/O handle stuff */
|
|
80
|
+
int iotype; /* IO_FD or IO_HANDLE */
|
|
81
|
+
/* Data for IO_FD. */
|
|
82
|
+
int fd;
|
|
83
|
+
int my_fd; /* A descriptor that the wrapper code opened itself. */
|
|
84
|
+
/* The actual callbacks from the outside. */
|
|
85
|
+
ssize_t (*r_read) (int, void *, size_t);
|
|
86
|
+
long (*r_lseek)(int, long, int);
|
|
87
|
+
/* Data for IO_HANDLE. */
|
|
88
|
+
void* handle;
|
|
89
|
+
ssize_t (*r_h_read)(void *, void *, size_t);
|
|
90
|
+
long (*r_h_lseek)(void*, long, int);
|
|
91
|
+
void (*h_cleanup)(void*);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
/* Cleanup I/O part of the handle handle... but not deleting the wrapper handle itself.
|
|
96
|
+
That is stored in the frame and only deleted on mpg123_delete(). */
|
|
97
|
+
static void wrap_io_cleanup(void *handle)
|
|
98
|
+
{
|
|
99
|
+
struct wrap_data *ioh = handle;
|
|
100
|
+
if(ioh->iotype == IO_HANDLE)
|
|
101
|
+
{
|
|
102
|
+
if(ioh->h_cleanup != NULL && ioh->handle != NULL)
|
|
103
|
+
ioh->h_cleanup(ioh->handle);
|
|
104
|
+
|
|
105
|
+
ioh->handle = NULL;
|
|
106
|
+
}
|
|
107
|
+
if(ioh->my_fd >= 0)
|
|
108
|
+
{
|
|
109
|
+
close(ioh->my_fd);
|
|
110
|
+
ioh->my_fd = -1;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/* Really finish off the handle... freeing all memory. */
|
|
115
|
+
static void wrap_destroy(void *handle)
|
|
116
|
+
{
|
|
117
|
+
struct wrap_data *wh = handle;
|
|
118
|
+
wrap_io_cleanup(handle);
|
|
119
|
+
if(wh->indextable != NULL)
|
|
120
|
+
free(wh->indextable);
|
|
121
|
+
|
|
122
|
+
free(wh);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/* More helper code... extract the special wrapper handle, possible allocate and initialize it. */
|
|
126
|
+
static struct wrap_data* wrap_get(mpg123_handle *mh)
|
|
127
|
+
{
|
|
128
|
+
struct wrap_data* whd;
|
|
129
|
+
if(mh == NULL) return NULL;
|
|
130
|
+
|
|
131
|
+
/* Access the private storage inside the mpg123 handle.
|
|
132
|
+
The real callback functions and handles are stored there. */
|
|
133
|
+
if(mh->wrapperdata == NULL)
|
|
134
|
+
{
|
|
135
|
+
/* Create a new one. */
|
|
136
|
+
mh->wrapperdata = malloc(sizeof(struct wrap_data));
|
|
137
|
+
if(mh->wrapperdata == NULL)
|
|
138
|
+
{
|
|
139
|
+
mh->err = MPG123_OUT_OF_MEM;
|
|
140
|
+
return NULL;
|
|
141
|
+
}
|
|
142
|
+
/* When we have wrapper data present, the callback for its proper cleanup is needed. */
|
|
143
|
+
mh->wrapperclean = wrap_destroy;
|
|
144
|
+
|
|
145
|
+
whd = mh->wrapperdata;
|
|
146
|
+
whd->indextable = NULL;
|
|
147
|
+
whd->iotype = 0;
|
|
148
|
+
whd->fd = -1;
|
|
149
|
+
whd->my_fd = -1;
|
|
150
|
+
whd->r_read = NULL;
|
|
151
|
+
whd->r_lseek = NULL;
|
|
152
|
+
whd->handle = NULL;
|
|
153
|
+
whd->r_h_read = NULL;
|
|
154
|
+
whd->r_h_lseek = NULL;
|
|
155
|
+
whd->h_cleanup = NULL;
|
|
156
|
+
}
|
|
157
|
+
else whd = mh->wrapperdata;
|
|
158
|
+
|
|
159
|
+
return whd;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/* After settling the data... start with some simple wrappers. */
|
|
163
|
+
|
|
164
|
+
#undef mpg123_decode_frame
|
|
165
|
+
/* int mpg123_decode_frame(mpg123_handle *mh, off_t *num, unsigned char **audio, size_t *bytes) */
|
|
166
|
+
int attribute_align_arg mpg123_decode_frame(mpg123_handle *mh, long *num, unsigned char **audio, size_t *bytes)
|
|
167
|
+
{
|
|
168
|
+
off_t largenum;
|
|
169
|
+
int err;
|
|
170
|
+
|
|
171
|
+
err = MPG123_LARGENAME(mpg123_decode_frame)(mh, &largenum, audio, bytes);
|
|
172
|
+
if(err == MPG123_OK && num != NULL)
|
|
173
|
+
{
|
|
174
|
+
*num = largenum;
|
|
175
|
+
if(*num != largenum)
|
|
176
|
+
{
|
|
177
|
+
mh->err = MPG123_LFS_OVERFLOW;
|
|
178
|
+
err = MPG123_ERR;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return err;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
#undef mpg123_framebyframe_decode
|
|
185
|
+
/* int mpg123_framebyframe_decode(mpg123_handle *mh, off_t *num, unsigned char **audio, size_t *bytes); */
|
|
186
|
+
int attribute_align_arg mpg123_framebyframe_decode(mpg123_handle *mh, long *num, unsigned char **audio, size_t *bytes)
|
|
187
|
+
{
|
|
188
|
+
off_t largenum;
|
|
189
|
+
int err;
|
|
190
|
+
|
|
191
|
+
err = MPG123_LARGENAME(mpg123_framebyframe_decode)(mh, &largenum, audio, bytes);
|
|
192
|
+
if(err == MPG123_OK && num != NULL)
|
|
193
|
+
{
|
|
194
|
+
*num = largenum;
|
|
195
|
+
if(*num != largenum)
|
|
196
|
+
{
|
|
197
|
+
mh->err = MPG123_LFS_OVERFLOW;
|
|
198
|
+
err = MPG123_ERR;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return err;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
#undef mpg123_framepos
|
|
205
|
+
/* off_t mpg123_framepos(mpg123_handle *mh); */
|
|
206
|
+
long attribute_align_arg mpg123_framepos(mpg123_handle *mh)
|
|
207
|
+
{
|
|
208
|
+
long val;
|
|
209
|
+
off_t largeval;
|
|
210
|
+
|
|
211
|
+
largeval = MPG123_LARGENAME(mpg123_framepos)(mh);
|
|
212
|
+
val = largeval;
|
|
213
|
+
if(val != largeval)
|
|
214
|
+
{
|
|
215
|
+
mh->err = MPG123_LFS_OVERFLOW;
|
|
216
|
+
return MPG123_ERR;
|
|
217
|
+
}
|
|
218
|
+
return val;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
#undef mpg123_tell
|
|
222
|
+
/* off_t mpg123_tell(mpg123_handle *mh); */
|
|
223
|
+
long attribute_align_arg mpg123_tell(mpg123_handle *mh)
|
|
224
|
+
{
|
|
225
|
+
long val;
|
|
226
|
+
off_t largeval;
|
|
227
|
+
|
|
228
|
+
largeval = MPG123_LARGENAME(mpg123_tell)(mh);
|
|
229
|
+
val = largeval;
|
|
230
|
+
if(val != largeval)
|
|
231
|
+
{
|
|
232
|
+
mh->err = MPG123_LFS_OVERFLOW;
|
|
233
|
+
return MPG123_ERR;
|
|
234
|
+
}
|
|
235
|
+
return val;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
#undef mpg123_tellframe
|
|
239
|
+
/* off_t mpg123_tellframe(mpg123_handle *mh); */
|
|
240
|
+
long attribute_align_arg mpg123_tellframe(mpg123_handle *mh)
|
|
241
|
+
{
|
|
242
|
+
long val;
|
|
243
|
+
off_t largeval;
|
|
244
|
+
|
|
245
|
+
largeval = MPG123_LARGENAME(mpg123_tellframe)(mh);
|
|
246
|
+
val = largeval;
|
|
247
|
+
if(val != largeval)
|
|
248
|
+
{
|
|
249
|
+
mh->err = MPG123_LFS_OVERFLOW;
|
|
250
|
+
return MPG123_ERR;
|
|
251
|
+
}
|
|
252
|
+
return val;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
#undef mpg123_tell_stream
|
|
256
|
+
/* off_t mpg123_tell_stream(mpg123_handle *mh); */
|
|
257
|
+
long attribute_align_arg mpg123_tell_stream(mpg123_handle *mh)
|
|
258
|
+
{
|
|
259
|
+
long val;
|
|
260
|
+
off_t largeval;
|
|
261
|
+
|
|
262
|
+
largeval = MPG123_LARGENAME(mpg123_tell_stream)(mh);
|
|
263
|
+
val = largeval;
|
|
264
|
+
if(val != largeval)
|
|
265
|
+
{
|
|
266
|
+
mh->err = MPG123_LFS_OVERFLOW;
|
|
267
|
+
return MPG123_ERR;
|
|
268
|
+
}
|
|
269
|
+
return val;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
#undef mpg123_seek
|
|
273
|
+
/* off_t mpg123_seek(mpg123_handle *mh, off_t sampleoff, int whence); */
|
|
274
|
+
long attribute_align_arg mpg123_seek(mpg123_handle *mh, long sampleoff, int whence)
|
|
275
|
+
{
|
|
276
|
+
long val;
|
|
277
|
+
off_t largeval;
|
|
278
|
+
|
|
279
|
+
largeval = MPG123_LARGENAME(mpg123_seek)(mh, sampleoff, whence);
|
|
280
|
+
val = largeval;
|
|
281
|
+
if(val != largeval)
|
|
282
|
+
{
|
|
283
|
+
mh->err = MPG123_LFS_OVERFLOW;
|
|
284
|
+
return MPG123_ERR;
|
|
285
|
+
}
|
|
286
|
+
return val;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
#undef mpg123_feedseek
|
|
290
|
+
/* off_t mpg123_feedseek(mpg123_handle *mh, off_t sampleoff, int whence, off_t *input_offset); */
|
|
291
|
+
long attribute_align_arg mpg123_feedseek(mpg123_handle *mh, long sampleoff, int whence, long *input_offset)
|
|
292
|
+
{
|
|
293
|
+
long val;
|
|
294
|
+
off_t largeioff;
|
|
295
|
+
off_t largeval;
|
|
296
|
+
|
|
297
|
+
largeval = MPG123_LARGENAME(mpg123_feedseek)(mh, sampleoff, whence, &largeioff);
|
|
298
|
+
/* Error/message codes are small... */
|
|
299
|
+
if(largeval < 0) return (long)largeval;
|
|
300
|
+
|
|
301
|
+
val = largeval;
|
|
302
|
+
*input_offset = largeioff;
|
|
303
|
+
if(val != largeval || *input_offset != largeioff)
|
|
304
|
+
{
|
|
305
|
+
mh->err = MPG123_LFS_OVERFLOW;
|
|
306
|
+
return MPG123_ERR;
|
|
307
|
+
}
|
|
308
|
+
return val;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
#undef mpg123_seek_frame
|
|
312
|
+
/* off_t mpg123_seek_frame(mpg123_handle *mh, off_t frameoff, int whence); */
|
|
313
|
+
long attribute_align_arg mpg123_seek_frame(mpg123_handle *mh, long frameoff, int whence)
|
|
314
|
+
{
|
|
315
|
+
long val;
|
|
316
|
+
off_t largeval;
|
|
317
|
+
|
|
318
|
+
largeval = MPG123_LARGENAME(mpg123_seek_frame)(mh, frameoff, whence);
|
|
319
|
+
val = largeval;
|
|
320
|
+
if(val != largeval)
|
|
321
|
+
{
|
|
322
|
+
mh->err = MPG123_LFS_OVERFLOW;
|
|
323
|
+
return MPG123_ERR;
|
|
324
|
+
}
|
|
325
|
+
return val;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
#undef mpg123_timeframe
|
|
329
|
+
/* off_t mpg123_timeframe(mpg123_handle *mh, double sec); */
|
|
330
|
+
long attribute_align_arg mpg123_timeframe(mpg123_handle *mh, double sec)
|
|
331
|
+
{
|
|
332
|
+
long val;
|
|
333
|
+
off_t largeval;
|
|
334
|
+
|
|
335
|
+
largeval = MPG123_LARGENAME(mpg123_timeframe)(mh, sec);
|
|
336
|
+
val = largeval;
|
|
337
|
+
if(val != largeval)
|
|
338
|
+
{
|
|
339
|
+
mh->err = MPG123_LFS_OVERFLOW;
|
|
340
|
+
return MPG123_ERR;
|
|
341
|
+
}
|
|
342
|
+
return val;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/* Now something less simple: Index retrieval and manipulation.
|
|
346
|
+
The index is an _array_ of off_t, which means that I need to construct a copy with translated long values. */
|
|
347
|
+
#undef mpg123_index
|
|
348
|
+
/* int mpg123_index(mpg123_handle *mh, off_t **offsets, off_t *step, size_t *fill) */
|
|
349
|
+
int attribute_align_arg mpg123_index(mpg123_handle *mh, long **offsets, long *step, size_t *fill)
|
|
350
|
+
{
|
|
351
|
+
int err;
|
|
352
|
+
size_t i;
|
|
353
|
+
long smallstep;
|
|
354
|
+
size_t thefill;
|
|
355
|
+
off_t largestep;
|
|
356
|
+
off_t *largeoffsets;
|
|
357
|
+
struct wrap_data *whd;
|
|
358
|
+
|
|
359
|
+
whd = wrap_get(mh);
|
|
360
|
+
if(whd == NULL) return MPG123_ERR;
|
|
361
|
+
|
|
362
|
+
err = MPG123_LARGENAME(mpg123_index)(mh, &largeoffsets, &largestep, &thefill);
|
|
363
|
+
if(err != MPG123_OK) return err;
|
|
364
|
+
|
|
365
|
+
/* For a _very_ large file, even the step could overflow. */
|
|
366
|
+
smallstep = largestep;
|
|
367
|
+
if(smallstep != largestep)
|
|
368
|
+
{
|
|
369
|
+
mh->err = MPG123_LFS_OVERFLOW;
|
|
370
|
+
return MPG123_ERR;
|
|
371
|
+
}
|
|
372
|
+
if(step != NULL) *step = smallstep;
|
|
373
|
+
|
|
374
|
+
/* When there are no values stored, there is no table content to take care of.
|
|
375
|
+
Table pointer does not matter. Mission completed. */
|
|
376
|
+
if(thefill == 0) return MPG123_OK;
|
|
377
|
+
|
|
378
|
+
if(fill != NULL) *fill = thefill;
|
|
379
|
+
|
|
380
|
+
/* Construct a copy of the index to hand over to the small-minded client. */
|
|
381
|
+
*offsets = safe_realloc(whd->indextable, (*fill)*sizeof(long));
|
|
382
|
+
if(*offsets == NULL)
|
|
383
|
+
{
|
|
384
|
+
mh->err = MPG123_OUT_OF_MEM;
|
|
385
|
+
return MPG123_ERR;
|
|
386
|
+
}
|
|
387
|
+
whd->indextable = *offsets;
|
|
388
|
+
/* Elaborate conversion of each index value, with overflow check. */
|
|
389
|
+
for(i=0; i<*fill; ++i)
|
|
390
|
+
{
|
|
391
|
+
whd->indextable[i] = largeoffsets[i];
|
|
392
|
+
if(whd->indextable[i] != largeoffsets[i])
|
|
393
|
+
{
|
|
394
|
+
mh->err = MPG123_LFS_OVERFLOW;
|
|
395
|
+
return MPG123_ERR;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
/* If we came that far... there should be a valid copy of the table now. */
|
|
399
|
+
return MPG123_OK;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/* The writing does basically the same than the above, just the opposite.
|
|
403
|
+
Oh, and the overflow checks are not needed -- off_t is bigger than long. */
|
|
404
|
+
#undef mpg123_set_index
|
|
405
|
+
/* int mpg123_set_index(mpg123_handle *mh, off_t *offsets, off_t step, size_t fill); */
|
|
406
|
+
int attribute_align_arg mpg123_set_index(mpg123_handle *mh, long *offsets, long step, size_t fill)
|
|
407
|
+
{
|
|
408
|
+
int err;
|
|
409
|
+
size_t i;
|
|
410
|
+
struct wrap_data *whd;
|
|
411
|
+
off_t *indextmp;
|
|
412
|
+
|
|
413
|
+
whd = wrap_get(mh);
|
|
414
|
+
if(whd == NULL) return MPG123_ERR;
|
|
415
|
+
|
|
416
|
+
/* Expensive temporary storage... for staying outside at the API layer. */
|
|
417
|
+
indextmp = malloc(fill*sizeof(off_t));
|
|
418
|
+
if(indextmp == NULL)
|
|
419
|
+
{
|
|
420
|
+
mh->err = MPG123_OUT_OF_MEM;
|
|
421
|
+
return MPG123_ERR;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
if(fill > 0 && offsets == NULL)
|
|
425
|
+
{
|
|
426
|
+
mh->err = MPG123_BAD_INDEX_PAR;
|
|
427
|
+
err = MPG123_ERR;
|
|
428
|
+
}
|
|
429
|
+
else
|
|
430
|
+
{
|
|
431
|
+
/* Fill the large-file copy of the provided index, then feed it to mpg123. */
|
|
432
|
+
for(i=0; i<fill; ++i)
|
|
433
|
+
indextmp[i] = offsets[i];
|
|
434
|
+
|
|
435
|
+
err = MPG123_LARGENAME(mpg123_set_index)(mh, indextmp, step, fill);
|
|
436
|
+
}
|
|
437
|
+
free(indextmp);
|
|
438
|
+
|
|
439
|
+
return err;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/* So... breathe... a couple of simple wrappers before the big mess. */
|
|
443
|
+
#undef mpg123_position
|
|
444
|
+
/* int mpg123_position( mpg123_handle *mh, off_t frame_offset, off_t buffered_bytes, off_t *current_frame, off_t *frames_left, double *current_seconds, double *seconds_left); */
|
|
445
|
+
int attribute_align_arg mpg123_position(mpg123_handle *mh, long frame_offset, long buffered_bytes, long *current_frame, long *frames_left, double *current_seconds, double *seconds_left)
|
|
446
|
+
{
|
|
447
|
+
off_t curframe, frameleft;
|
|
448
|
+
long small_curframe, small_frameleft;
|
|
449
|
+
int err;
|
|
450
|
+
|
|
451
|
+
err = MPG123_LARGENAME(mpg123_position)(mh, frame_offset, buffered_bytes, &curframe, &frameleft, current_seconds, seconds_left);
|
|
452
|
+
if(err != MPG123_OK) return err;
|
|
453
|
+
|
|
454
|
+
small_curframe = curframe;
|
|
455
|
+
small_frameleft = frameleft;
|
|
456
|
+
if(small_curframe != curframe || small_frameleft != frameleft)
|
|
457
|
+
{
|
|
458
|
+
mh->err = MPG123_LFS_OVERFLOW;
|
|
459
|
+
return MPG123_ERR;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
if(current_frame != NULL) *current_frame = small_curframe;
|
|
463
|
+
|
|
464
|
+
if(frames_left != NULL) *frames_left = small_frameleft;
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
return MPG123_OK;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
#undef mpg123_length
|
|
471
|
+
/* off_t mpg123_length(mpg123_handle *mh); */
|
|
472
|
+
long attribute_align_arg mpg123_length(mpg123_handle *mh)
|
|
473
|
+
{
|
|
474
|
+
long val;
|
|
475
|
+
off_t largeval;
|
|
476
|
+
|
|
477
|
+
largeval = MPG123_LARGENAME(mpg123_length)(mh);
|
|
478
|
+
val = largeval;
|
|
479
|
+
if(val != largeval)
|
|
480
|
+
{
|
|
481
|
+
mh->err = MPG123_LFS_OVERFLOW;
|
|
482
|
+
return MPG123_ERR;
|
|
483
|
+
}
|
|
484
|
+
return val;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/* The simplest wrapper of all... */
|
|
488
|
+
#undef mpg123_set_filesize
|
|
489
|
+
/* int mpg123_set_filesize(mpg123_handle *mh, off_t size); */
|
|
490
|
+
int attribute_align_arg mpg123_set_filesize(mpg123_handle *mh, long size)
|
|
491
|
+
{
|
|
492
|
+
return MPG123_LARGENAME(mpg123_set_filesize)(mh, size);
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
/* =========================================
|
|
497
|
+
THE BOUNDARY OF SANITY
|
|
498
|
+
Behold, stranger!
|
|
499
|
+
========================================= */
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
/*
|
|
503
|
+
The messy part: Replacement of I/O core (actally, this is only due to lseek()).
|
|
504
|
+
Both descriptor and handle replaced I/O are mapped to replaced handle I/O, the handle wrapping over the actual callbacks and the actual handle/descriptor.
|
|
505
|
+
You got multiple levels of handles and callbacks to think about. Have fun reading and comprehending.
|
|
506
|
+
*/
|
|
507
|
+
|
|
508
|
+
/* Could go into compat.h ... Windows needs that flag. */
|
|
509
|
+
#ifndef O_BINARY
|
|
510
|
+
#define O_BINARY 0
|
|
511
|
+
#endif
|
|
512
|
+
|
|
513
|
+
/* Read callback needs nothing special. */
|
|
514
|
+
ssize_t wrap_read(void* handle, void *buf, size_t count)
|
|
515
|
+
{
|
|
516
|
+
struct wrap_data *ioh = handle;
|
|
517
|
+
switch(ioh->iotype)
|
|
518
|
+
{
|
|
519
|
+
case IO_FD: return ioh->r_read(ioh->fd, buf, count);
|
|
520
|
+
case IO_HANDLE: return ioh->r_h_read(ioh->handle, buf, count);
|
|
521
|
+
}
|
|
522
|
+
error("Serious breakage - bad IO type in LFS wrapper!");
|
|
523
|
+
return -1;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
/* Seek callback needs protection from too big offsets. */
|
|
527
|
+
off_t wrap_lseek(void *handle, off_t offset, int whence)
|
|
528
|
+
{
|
|
529
|
+
struct wrap_data *ioh = handle;
|
|
530
|
+
long smalloff = offset;
|
|
531
|
+
if(smalloff == offset)
|
|
532
|
+
{
|
|
533
|
+
switch(ioh->iotype)
|
|
534
|
+
{
|
|
535
|
+
case IO_FD: return ioh->r_lseek(ioh->fd, smalloff, whence);
|
|
536
|
+
case IO_HANDLE: return ioh->r_h_lseek(ioh->handle, smalloff, whence);
|
|
537
|
+
}
|
|
538
|
+
error("Serious breakage - bad IO type in LFS wrapper!");
|
|
539
|
+
return -1;
|
|
540
|
+
}
|
|
541
|
+
else
|
|
542
|
+
{
|
|
543
|
+
errno = EOVERFLOW;
|
|
544
|
+
return -1;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
|
|
549
|
+
/*
|
|
550
|
+
Now, let's replace the API dealing with replacement I/O.
|
|
551
|
+
Start with undefining the renames...
|
|
552
|
+
*/
|
|
553
|
+
|
|
554
|
+
#undef mpg123_replace_reader
|
|
555
|
+
#undef mpg123_replace_reader_handle
|
|
556
|
+
#undef mpg123_open
|
|
557
|
+
#undef mpg123_open_fd
|
|
558
|
+
#undef mpg123_open_handle
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
/* Normal reader replacement needs fallback implementations. */
|
|
562
|
+
static ssize_t fallback_read(int fd, void *buf, size_t count)
|
|
563
|
+
{
|
|
564
|
+
return read(fd, buf, count);
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
static long fallback_lseek(int fd, long offset, int whence)
|
|
568
|
+
{
|
|
569
|
+
/* Since the offset is long int already, the returned value really should fit into a long... but whatever. */
|
|
570
|
+
long newpos_long;
|
|
571
|
+
off_t newpos;
|
|
572
|
+
newpos = lseek(fd, offset, whence);
|
|
573
|
+
newpos_long = newpos;
|
|
574
|
+
if(newpos_long == newpos)
|
|
575
|
+
return newpos_long;
|
|
576
|
+
else
|
|
577
|
+
{
|
|
578
|
+
errno = EOVERFLOW;
|
|
579
|
+
return -1;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
/* Reader replacement prepares the hidden handle storage for next mpg123_open_fd() or plain mpg123_open(). */
|
|
584
|
+
int attribute_align_arg mpg123_replace_reader(mpg123_handle *mh, ssize_t (*r_read) (int, void *, size_t), long (*r_lseek)(int, long, int) )
|
|
585
|
+
{
|
|
586
|
+
struct wrap_data* ioh;
|
|
587
|
+
|
|
588
|
+
if(mh == NULL) return MPG123_ERR;
|
|
589
|
+
|
|
590
|
+
mpg123_close(mh);
|
|
591
|
+
ioh = wrap_get(mh);
|
|
592
|
+
if(ioh == NULL) return MPG123_ERR;
|
|
593
|
+
|
|
594
|
+
/* If both callbacks are NULL, switch totally to internal I/O, else just use fallback for at most half of them. */
|
|
595
|
+
if(r_read == NULL && r_lseek == NULL)
|
|
596
|
+
{
|
|
597
|
+
/* Only the type is actually important to disable the code. */
|
|
598
|
+
ioh->iotype = 0;
|
|
599
|
+
ioh->fd = -1;
|
|
600
|
+
ioh->r_read = NULL;
|
|
601
|
+
ioh->r_lseek = NULL;
|
|
602
|
+
}
|
|
603
|
+
else
|
|
604
|
+
{
|
|
605
|
+
ioh->iotype = IO_FD;
|
|
606
|
+
ioh->fd = -1; /* On next mpg123_open_fd(), this gets a value. */
|
|
607
|
+
ioh->r_read = r_read != NULL ? r_read : fallback_read;
|
|
608
|
+
ioh->r_lseek = r_lseek != NULL ? r_lseek : fallback_lseek;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
/* The real reader replacement will happen while opening. */
|
|
612
|
+
return MPG123_OK;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
int attribute_align_arg mpg123_replace_reader_handle(mpg123_handle *mh, ssize_t (*r_read) (void*, void *, size_t), long (*r_lseek)(void*, long, int), void (*cleanup)(void*))
|
|
616
|
+
{
|
|
617
|
+
struct wrap_data* ioh;
|
|
618
|
+
|
|
619
|
+
if(mh == NULL) return MPG123_ERR;
|
|
620
|
+
|
|
621
|
+
mpg123_close(mh);
|
|
622
|
+
ioh = wrap_get(mh);
|
|
623
|
+
if(ioh == NULL) return MPG123_ERR;
|
|
624
|
+
|
|
625
|
+
ioh->iotype = IO_HANDLE;
|
|
626
|
+
ioh->handle = NULL;
|
|
627
|
+
ioh->r_h_read = r_read;
|
|
628
|
+
ioh->r_h_lseek = r_lseek;
|
|
629
|
+
ioh->h_cleanup = cleanup;
|
|
630
|
+
|
|
631
|
+
/* The real reader replacement will happen while opening. */
|
|
632
|
+
return MPG123_OK;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
/*
|
|
636
|
+
The open routines always need to watch out for a prepared wrapper handle to use replaced normal I/O.
|
|
637
|
+
Two cases to consider:
|
|
638
|
+
1. Plain normal open using internal I/O.
|
|
639
|
+
2. Client called mpg123_replace_reader() before.
|
|
640
|
+
The second case needs hackery to activate the client I/O callbacks. For that, we create a custom I/O handle and use the guts of mpg123_open_fd() on it.
|
|
641
|
+
*/
|
|
642
|
+
int attribute_align_arg mpg123_open(mpg123_handle *mh, const char *path)
|
|
643
|
+
{
|
|
644
|
+
struct wrap_data* ioh;
|
|
645
|
+
|
|
646
|
+
if(mh == NULL) return MPG123_ERR;
|
|
647
|
+
|
|
648
|
+
ioh = mh->wrapperdata;
|
|
649
|
+
/* Mimic the use of mpg123_replace_reader() functions by lower levels...
|
|
650
|
+
IO_HANDLE is not valid here, though. Only IO_FD. */
|
|
651
|
+
if(ioh != NULL && ioh->iotype == IO_FD)
|
|
652
|
+
{
|
|
653
|
+
int err;
|
|
654
|
+
err = MPG123_LARGENAME(mpg123_replace_reader_handle)(mh, wrap_read, wrap_lseek, wrap_io_cleanup);
|
|
655
|
+
if(err != MPG123_OK) return MPG123_ERR;
|
|
656
|
+
|
|
657
|
+
/* The above call implied mpg123_close() already */
|
|
658
|
+
/*
|
|
659
|
+
I really need to open the file here... to be able to use the replacer handle I/O ...
|
|
660
|
+
my_fd is used to indicate closing of the descriptor on cleanup.
|
|
661
|
+
*/
|
|
662
|
+
ioh->my_fd = compat_open(path, O_RDONLY|O_BINARY);
|
|
663
|
+
if(ioh->my_fd < 0)
|
|
664
|
+
{
|
|
665
|
+
if(!(mh->p.flags & MPG123_QUIET)) error2("Cannot open file %s: %s", path, strerror(errno));
|
|
666
|
+
|
|
667
|
+
mh->err = MPG123_BAD_FILE;
|
|
668
|
+
return MPG123_ERR;
|
|
669
|
+
}
|
|
670
|
+
/* Store a copy of the descriptor where it is actually used. */
|
|
671
|
+
ioh->fd = ioh->my_fd;
|
|
672
|
+
/* Initiate I/O operating on my handle now. */
|
|
673
|
+
err = open_stream_handle(mh, ioh);
|
|
674
|
+
if(err != MPG123_OK)
|
|
675
|
+
{
|
|
676
|
+
wrap_io_cleanup(ioh);
|
|
677
|
+
return MPG123_ERR;
|
|
678
|
+
}
|
|
679
|
+
/* All fine... */
|
|
680
|
+
return MPG123_OK;
|
|
681
|
+
}
|
|
682
|
+
else return MPG123_LARGENAME(mpg123_open)(mh, path);
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
/*
|
|
686
|
+
This is in fact very similar to the above:
|
|
687
|
+
The open routines always need to watch out for a prepared wrapper handle to use replaced normal I/O.
|
|
688
|
+
Two cases to consider:
|
|
689
|
+
1. Plain normal open_fd using internal I/O.
|
|
690
|
+
2. Client called mpg123_replace_reader() before.
|
|
691
|
+
The second case needs hackery to activate the client I/O callbacks. For that, we create a custom I/O handle and use the guts of mpg123_open_fd() on it.
|
|
692
|
+
*/
|
|
693
|
+
|
|
694
|
+
int attribute_align_arg mpg123_open_fd(mpg123_handle *mh, int fd)
|
|
695
|
+
{
|
|
696
|
+
struct wrap_data* ioh;
|
|
697
|
+
|
|
698
|
+
if(mh == NULL) return MPG123_ERR;
|
|
699
|
+
|
|
700
|
+
mpg123_close(mh);
|
|
701
|
+
ioh = mh->wrapperdata;
|
|
702
|
+
if(ioh != NULL && ioh->iotype == IO_FD)
|
|
703
|
+
{
|
|
704
|
+
int err;
|
|
705
|
+
err = MPG123_LARGENAME(mpg123_replace_reader_handle)(mh, wrap_read, wrap_lseek, wrap_io_cleanup);
|
|
706
|
+
if(err != MPG123_OK) return MPG123_ERR;
|
|
707
|
+
|
|
708
|
+
/* The above call implied mpg123_close() already */
|
|
709
|
+
|
|
710
|
+
/* Store the real file descriptor inside the handle. */
|
|
711
|
+
ioh->fd = fd;
|
|
712
|
+
/* Initiate I/O operating on my handle now. */
|
|
713
|
+
err = open_stream_handle(mh, ioh);
|
|
714
|
+
if(err != MPG123_OK)
|
|
715
|
+
{
|
|
716
|
+
wrap_io_cleanup(ioh);
|
|
717
|
+
return MPG123_ERR;
|
|
718
|
+
}
|
|
719
|
+
/* All fine... */
|
|
720
|
+
return MPG123_OK;
|
|
721
|
+
}
|
|
722
|
+
else return MPG123_LARGENAME(mpg123_open_fd)(mh, fd);
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
int attribute_align_arg mpg123_open_handle(mpg123_handle *mh, void *handle)
|
|
726
|
+
{
|
|
727
|
+
struct wrap_data* ioh;
|
|
728
|
+
|
|
729
|
+
if(mh == NULL) return MPG123_ERR;
|
|
730
|
+
|
|
731
|
+
mpg123_close(mh);
|
|
732
|
+
ioh = mh->wrapperdata;
|
|
733
|
+
if(ioh != NULL && ioh->iotype == IO_HANDLE && ioh->r_h_read != NULL)
|
|
734
|
+
{
|
|
735
|
+
/* Wrap the custom handle into my handle. */
|
|
736
|
+
int err;
|
|
737
|
+
err = MPG123_LARGENAME(mpg123_replace_reader_handle)(mh, wrap_read, wrap_lseek, wrap_io_cleanup);
|
|
738
|
+
if(err != MPG123_OK) return MPG123_ERR;
|
|
739
|
+
|
|
740
|
+
ioh->handle = handle;
|
|
741
|
+
/* No extra error handling, keep behaviour of the original open_handle. */
|
|
742
|
+
return open_stream_handle(mh, ioh);
|
|
743
|
+
}
|
|
744
|
+
else
|
|
745
|
+
{
|
|
746
|
+
/* This is an error ... you need to prepare the I/O before using it. */
|
|
747
|
+
mh->err = MPG123_BAD_CUSTOM_IO;
|
|
748
|
+
return MPG123_ERR;
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
|