seal 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (421) hide show
  1. data/.yardopts +1 -0
  2. data/LICENSE +13 -0
  3. data/README.md +265 -0
  4. data/ext/seal/extconf.rb +45 -0
  5. data/include/al/al.h +724 -0
  6. data/include/al/alc.h +277 -0
  7. data/include/al/efx-presets.h +402 -0
  8. data/include/al/efx.h +758 -0
  9. data/include/mpg123/mpg123.h +1034 -0
  10. data/include/ogg/config_types.h +25 -0
  11. data/include/ogg/ogg.h +210 -0
  12. data/include/ogg/os_types.h +147 -0
  13. data/include/seal.h +23 -0
  14. data/include/seal/buf.h +143 -0
  15. data/include/seal/core.h +95 -0
  16. data/include/seal/efs.h +112 -0
  17. data/include/seal/err.h +93 -0
  18. data/include/seal/fmt.h +58 -0
  19. data/include/seal/listener.h +103 -0
  20. data/include/seal/raw.h +86 -0
  21. data/include/seal/rvb.h +520 -0
  22. data/include/seal/src.h +413 -0
  23. data/include/seal/stream.h +81 -0
  24. data/include/vorbis/codec.h +243 -0
  25. data/include/vorbis/vorbisfile.h +206 -0
  26. data/mpg123/AUTHORS +150 -0
  27. data/mpg123/COPYING +773 -0
  28. data/mpg123/ChangeLog +3 -0
  29. data/mpg123/INSTALL +111 -0
  30. data/mpg123/Makefile.am +99 -0
  31. data/mpg123/Makefile.in +1043 -0
  32. data/mpg123/NEWS +1200 -0
  33. data/mpg123/NEWS.libmpg123 +133 -0
  34. data/mpg123/README +203 -0
  35. data/mpg123/TODO +38 -0
  36. data/mpg123/aclocal.m4 +1168 -0
  37. data/mpg123/build/config.guess +1530 -0
  38. data/mpg123/build/config.sub +1782 -0
  39. data/mpg123/build/depcomp +707 -0
  40. data/mpg123/build/install-sh +527 -0
  41. data/mpg123/build/ltmain.sh +9655 -0
  42. data/mpg123/build/missing +330 -0
  43. data/mpg123/configure +20267 -0
  44. data/mpg123/configure.ac +2178 -0
  45. data/mpg123/doc/ACCURACY +2 -0
  46. data/mpg123/doc/BENCHMARKING +110 -0
  47. data/mpg123/doc/BUGS +3 -0
  48. data/mpg123/doc/CONTACT +17 -0
  49. data/mpg123/doc/LICENSE +22 -0
  50. data/mpg123/doc/Makefile.am +32 -0
  51. data/mpg123/doc/Makefile.in +490 -0
  52. data/mpg123/doc/PATENTS +39 -0
  53. data/mpg123/doc/README.3DNOW +56 -0
  54. data/mpg123/doc/README.gain +171 -0
  55. data/mpg123/doc/README.remote +218 -0
  56. data/mpg123/doc/ROAD_TO_LGPL +270 -0
  57. data/mpg123/doc/THANKS +13 -0
  58. data/mpg123/doc/TODO +63 -0
  59. data/mpg123/doc/doxy_examples.c +21 -0
  60. data/mpg123/doc/doxygen.conf +41 -0
  61. data/mpg123/doc/doxyhead.xhtml +12 -0
  62. data/mpg123/doc/examples/dump_seekindex.c +41 -0
  63. data/mpg123/doc/examples/extract_frames.c +92 -0
  64. data/mpg123/doc/examples/feedseek.c +238 -0
  65. data/mpg123/doc/examples/id3dump.c +178 -0
  66. data/mpg123/doc/examples/mpg123_to_wav.c +118 -0
  67. data/mpg123/doc/examples/mpglib.c +92 -0
  68. data/mpg123/doc/examples/scan.c +47 -0
  69. data/mpg123/doc/libmpg123_speed.txt +84 -0
  70. data/mpg123/equalize.dat +37 -0
  71. data/mpg123/libmpg123.pc.in +11 -0
  72. data/mpg123/m4/addrconfig.m4 +34 -0
  73. data/mpg123/m4/libtool.m4 +7982 -0
  74. data/mpg123/m4/ltoptions.m4 +384 -0
  75. data/mpg123/m4/ltsugar.m4 +123 -0
  76. data/mpg123/m4/ltversion.m4 +23 -0
  77. data/mpg123/m4/lt~obsolete.m4 +98 -0
  78. data/mpg123/makedll.sh +19 -0
  79. data/mpg123/man1/mpg123.1 +512 -0
  80. data/mpg123/mpg123.spec +68 -0
  81. data/mpg123/mpg123.spec.in +68 -0
  82. data/mpg123/ports/MSVC++/2005/libmpg123/libmpg123.vcproj +741 -0
  83. data/mpg123/ports/MSVC++/2008/dump_seekindex/dump_seekindex.vcproj +194 -0
  84. data/mpg123/ports/MSVC++/2008/feedseek/feedseek.vcproj +195 -0
  85. data/mpg123/ports/MSVC++/2008/libmpg123/libmpg123.vcproj +1357 -0
  86. data/mpg123/ports/MSVC++/2008/mpg123.sln +44 -0
  87. data/mpg123/ports/MSVC++/2008/mpglib/mpglib.vcproj +191 -0
  88. data/mpg123/ports/MSVC++/2008/scan/scan.vcproj +195 -0
  89. data/mpg123/ports/MSVC++/2008clr/2008clr.sln +81 -0
  90. data/mpg123/ports/MSVC++/2008clr/examples/ReplaceReaderclr/Program.cs +435 -0
  91. data/mpg123/ports/MSVC++/2008clr/examples/ReplaceReaderclr/Properties/AssemblyInfo.cs +36 -0
  92. data/mpg123/ports/MSVC++/2008clr/examples/ReplaceReaderclr/ReplaceReaderclr.csproj +72 -0
  93. data/mpg123/ports/MSVC++/2008clr/examples/feedseekclr/Program.cs +331 -0
  94. data/mpg123/ports/MSVC++/2008clr/examples/feedseekclr/Properties/AssemblyInfo.cs +36 -0
  95. data/mpg123/ports/MSVC++/2008clr/examples/feedseekclr/feedseekclr.csproj +71 -0
  96. data/mpg123/ports/MSVC++/2008clr/examples/scanclr/Program.cs +79 -0
  97. data/mpg123/ports/MSVC++/2008clr/examples/scanclr/Properties/AssemblyInfo.cs +36 -0
  98. data/mpg123/ports/MSVC++/2008clr/examples/scanclr/scanclr.csproj +70 -0
  99. data/mpg123/ports/MSVC++/2008clr/mpg123clr/AssemblyInfo.cpp +76 -0
  100. data/mpg123/ports/MSVC++/2008clr/mpg123clr/ReadMe.txt +165 -0
  101. data/mpg123/ports/MSVC++/2008clr/mpg123clr/advanced.cpp +91 -0
  102. data/mpg123/ports/MSVC++/2008clr/mpg123clr/advanced.h +130 -0
  103. data/mpg123/ports/MSVC++/2008clr/mpg123clr/dllmain.cpp +19 -0
  104. data/mpg123/ports/MSVC++/2008clr/mpg123clr/enum.h +218 -0
  105. data/mpg123/ports/MSVC++/2008clr/mpg123clr/error.cpp +48 -0
  106. data/mpg123/ports/MSVC++/2008clr/mpg123clr/error.h +134 -0
  107. data/mpg123/ports/MSVC++/2008clr/mpg123clr/id3v1.cpp +92 -0
  108. data/mpg123/ports/MSVC++/2008clr/mpg123clr/id3v1.h +132 -0
  109. data/mpg123/ports/MSVC++/2008clr/mpg123clr/id3v2.cpp +138 -0
  110. data/mpg123/ports/MSVC++/2008clr/mpg123clr/id3v2.h +152 -0
  111. data/mpg123/ports/MSVC++/2008clr/mpg123clr/mpg123clr.cpp +896 -0
  112. data/mpg123/ports/MSVC++/2008clr/mpg123clr/mpg123clr.h +953 -0
  113. data/mpg123/ports/MSVC++/2008clr/mpg123clr/mpg123clr.rc +102 -0
  114. data/mpg123/ports/MSVC++/2008clr/mpg123clr/mpg123clr.vcproj +328 -0
  115. data/mpg123/ports/MSVC++/2008clr/mpg123clr/resource.h +14 -0
  116. data/mpg123/ports/MSVC++/2008clr/mpg123clr/stdafx.cpp +8 -0
  117. data/mpg123/ports/MSVC++/2008clr/mpg123clr/stdafx.h +38 -0
  118. data/mpg123/ports/MSVC++/2008clr/mpg123clr/string.cpp +166 -0
  119. data/mpg123/ports/MSVC++/2008clr/mpg123clr/string.h +265 -0
  120. data/mpg123/ports/MSVC++/2008clr/mpg123clr/targetver.h +24 -0
  121. data/mpg123/ports/MSVC++/2008clr/mpg123clr/text.cpp +67 -0
  122. data/mpg123/ports/MSVC++/2008clr/mpg123clr/text.h +111 -0
  123. data/mpg123/ports/MSVC++/2010/dump_seekindex/dump_seekindex.vcxproj +90 -0
  124. data/mpg123/ports/MSVC++/2010/dump_seekindex/dump_seekindex.vcxproj.filters +6 -0
  125. data/mpg123/ports/MSVC++/2010/feedseek/feedseek.vcxproj +95 -0
  126. data/mpg123/ports/MSVC++/2010/feedseek/feedseek.vcxproj.filters +6 -0
  127. data/mpg123/ports/MSVC++/2010/libmpg123/libmpg123.vcxproj +960 -0
  128. data/mpg123/ports/MSVC++/2010/libmpg123/libmpg123.vcxproj.user +3 -0
  129. data/mpg123/ports/MSVC++/2010/libmpg123/yasm.exe +0 -0
  130. data/mpg123/ports/MSVC++/2010/mpg123.sln +38 -0
  131. data/mpg123/ports/MSVC++/2010/scan/scan.vcxproj +93 -0
  132. data/mpg123/ports/MSVC++/2010/scan/scan.vcxproj.filters +6 -0
  133. data/mpg123/ports/MSVC++/CMP3Stream/INCLUDE/CORE/CORE_FileIn.H +15 -0
  134. data/mpg123/ports/MSVC++/CMP3Stream/INCLUDE/CORE/SourceFilter_MP3.H +139 -0
  135. data/mpg123/ports/MSVC++/CMP3Stream/INCLUDE/IIEP_Def.H +206 -0
  136. data/mpg123/ports/MSVC++/CMP3Stream/INCLUDE/IIEP_FileIn.H +167 -0
  137. data/mpg123/ports/MSVC++/CMP3Stream/README +4 -0
  138. data/mpg123/ports/MSVC++/CMP3Stream/SOURCE/CORE_FileIn.CPP +462 -0
  139. data/mpg123/ports/MSVC++/CMP3Stream/SOURCE/CORE_Log.CPP +122 -0
  140. data/mpg123/ports/MSVC++/CMP3Stream/SOURCE/CORE_Mutex.CPP +35 -0
  141. data/mpg123/ports/MSVC++/CMP3Stream/SOURCE/SourceFilter_MP3Stream.CPP +586 -0
  142. data/mpg123/ports/MSVC++/CMP3Stream/libMPG123/PLACE_LIBMPG123_SOURCES_HERE +0 -0
  143. data/mpg123/ports/MSVC++/CMP3Stream/libMPG123/libMPG123.vcproj +245 -0
  144. data/mpg123/ports/MSVC++/config.h +35 -0
  145. data/mpg123/ports/MSVC++/examples/feedseek.c +240 -0
  146. data/mpg123/ports/MSVC++/examples/scan.c +47 -0
  147. data/mpg123/ports/MSVC++/mpg123.h +46 -0
  148. data/mpg123/ports/MSVC++/msvc.c +59 -0
  149. data/mpg123/ports/README +26 -0
  150. data/mpg123/ports/Sony_PSP/Makefile.psp +38 -0
  151. data/mpg123/ports/Sony_PSP/README +11 -0
  152. data/mpg123/ports/Sony_PSP/config.h +368 -0
  153. data/mpg123/ports/Sony_PSP/readers.c.patch +2 -0
  154. data/mpg123/ports/Xcode/config.h +197 -0
  155. data/mpg123/ports/Xcode/mpg123.h +17 -0
  156. data/mpg123/ports/Xcode/mpg123.xcodeproj/project.pbxproj +670 -0
  157. data/mpg123/ports/mpg123_.pas +478 -0
  158. data/mpg123/scripts/benchmark-cpu.pl +56 -0
  159. data/mpg123/scripts/tag_lyrics.py +76 -0
  160. data/mpg123/src/Makefile.am +186 -0
  161. data/mpg123/src/Makefile.in +1097 -0
  162. data/mpg123/src/audio.c +725 -0
  163. data/mpg123/src/audio.h +106 -0
  164. data/mpg123/src/buffer.c +312 -0
  165. data/mpg123/src/buffer.h +45 -0
  166. data/mpg123/src/common.c +240 -0
  167. data/mpg123/src/common.h +29 -0
  168. data/mpg123/src/config.h.in +436 -0
  169. data/mpg123/src/control_generic.c +809 -0
  170. data/mpg123/src/equalizer.c +48 -0
  171. data/mpg123/src/genre.c +271 -0
  172. data/mpg123/src/genre.h +15 -0
  173. data/mpg123/src/getlopt.c +148 -0
  174. data/mpg123/src/getlopt.h +77 -0
  175. data/mpg123/src/httpget.c +700 -0
  176. data/mpg123/src/httpget.h +66 -0
  177. data/mpg123/src/legacy_module.c +74 -0
  178. data/mpg123/src/libmpg123/Makefile.am +141 -0
  179. data/mpg123/src/libmpg123/Makefile.in +919 -0
  180. data/mpg123/src/libmpg123/compat.c +138 -0
  181. data/mpg123/src/libmpg123/compat.h +178 -0
  182. data/mpg123/src/libmpg123/dct36_3dnow.S +505 -0
  183. data/mpg123/src/libmpg123/dct36_3dnowext.S +512 -0
  184. data/mpg123/src/libmpg123/dct64.c +174 -0
  185. data/mpg123/src/libmpg123/dct64_3dnow.S +712 -0
  186. data/mpg123/src/libmpg123/dct64_3dnowext.S +714 -0
  187. data/mpg123/src/libmpg123/dct64_altivec.c +315 -0
  188. data/mpg123/src/libmpg123/dct64_i386.c +336 -0
  189. data/mpg123/src/libmpg123/dct64_i486.c +342 -0
  190. data/mpg123/src/libmpg123/dct64_mmx.S +811 -0
  191. data/mpg123/src/libmpg123/dct64_neon.S +297 -0
  192. data/mpg123/src/libmpg123/dct64_neon_float.S +270 -0
  193. data/mpg123/src/libmpg123/dct64_sse.S +454 -0
  194. data/mpg123/src/libmpg123/dct64_sse_float.S +401 -0
  195. data/mpg123/src/libmpg123/dct64_x86_64.S +464 -0
  196. data/mpg123/src/libmpg123/dct64_x86_64_float.S +426 -0
  197. data/mpg123/src/libmpg123/debug.h +171 -0
  198. data/mpg123/src/libmpg123/decode.h +268 -0
  199. data/mpg123/src/libmpg123/dither.c +119 -0
  200. data/mpg123/src/libmpg123/dither.h +23 -0
  201. data/mpg123/src/libmpg123/equalizer.c +17 -0
  202. data/mpg123/src/libmpg123/equalizer_3dnow.S +70 -0
  203. data/mpg123/src/libmpg123/feature.c +106 -0
  204. data/mpg123/src/libmpg123/format.c +521 -0
  205. data/mpg123/src/libmpg123/frame.c +1046 -0
  206. data/mpg123/src/libmpg123/frame.h +410 -0
  207. data/mpg123/src/libmpg123/gapless.h +119 -0
  208. data/mpg123/src/libmpg123/getbits.h +100 -0
  209. data/mpg123/src/libmpg123/getcpuflags.S +91 -0
  210. data/mpg123/src/libmpg123/getcpuflags.h +47 -0
  211. data/mpg123/src/libmpg123/huffman.h +340 -0
  212. data/mpg123/src/libmpg123/icy.c +32 -0
  213. data/mpg123/src/libmpg123/icy.h +38 -0
  214. data/mpg123/src/libmpg123/icy2utf8.c +438 -0
  215. data/mpg123/src/libmpg123/icy2utf8.h +10 -0
  216. data/mpg123/src/libmpg123/id3.c +999 -0
  217. data/mpg123/src/libmpg123/id3.h +43 -0
  218. data/mpg123/src/libmpg123/index.c +134 -0
  219. data/mpg123/src/libmpg123/index.h +59 -0
  220. data/mpg123/src/libmpg123/intsym.h +256 -0
  221. data/mpg123/src/libmpg123/l12_integer_tables.h +278 -0
  222. data/mpg123/src/libmpg123/l2tables.h +164 -0
  223. data/mpg123/src/libmpg123/l3_integer_tables.h +1002 -0
  224. data/mpg123/src/libmpg123/layer1.c +155 -0
  225. data/mpg123/src/libmpg123/layer2.c +371 -0
  226. data/mpg123/src/libmpg123/layer3.c +2053 -0
  227. data/mpg123/src/libmpg123/lfs_alias.c +252 -0
  228. data/mpg123/src/libmpg123/lfs_wrap.c +751 -0
  229. data/mpg123/src/libmpg123/libmpg123.c +1607 -0
  230. data/mpg123/src/libmpg123/mangle.h +74 -0
  231. data/mpg123/src/libmpg123/mpeghead.h +87 -0
  232. data/mpg123/src/libmpg123/mpg123.h.in +1075 -0
  233. data/mpg123/src/libmpg123/mpg123lib_intern.h +338 -0
  234. data/mpg123/src/libmpg123/ntom.c +148 -0
  235. data/mpg123/src/libmpg123/optimize.c +964 -0
  236. data/mpg123/src/libmpg123/optimize.h +219 -0
  237. data/mpg123/src/libmpg123/parse.c +1179 -0
  238. data/mpg123/src/libmpg123/parse.h +25 -0
  239. data/mpg123/src/libmpg123/reader.h +137 -0
  240. data/mpg123/src/libmpg123/readers.c +1235 -0
  241. data/mpg123/src/libmpg123/sample.h +152 -0
  242. data/mpg123/src/libmpg123/stringbuf.c +163 -0
  243. data/mpg123/src/libmpg123/synth.c +816 -0
  244. data/mpg123/src/libmpg123/synth.h +196 -0
  245. data/mpg123/src/libmpg123/synth_3dnow.S +318 -0
  246. data/mpg123/src/libmpg123/synth_3dnowext.S +6 -0
  247. data/mpg123/src/libmpg123/synth_8bit.c +142 -0
  248. data/mpg123/src/libmpg123/synth_8bit.h +86 -0
  249. data/mpg123/src/libmpg123/synth_altivec.c +1057 -0
  250. data/mpg123/src/libmpg123/synth_arm.S +271 -0
  251. data/mpg123/src/libmpg123/synth_arm_accurate.S +287 -0
  252. data/mpg123/src/libmpg123/synth_i486.c +252 -0
  253. data/mpg123/src/libmpg123/synth_i586.S +336 -0
  254. data/mpg123/src/libmpg123/synth_i586_dither.S +375 -0
  255. data/mpg123/src/libmpg123/synth_mmx.S +125 -0
  256. data/mpg123/src/libmpg123/synth_mono.h +64 -0
  257. data/mpg123/src/libmpg123/synth_neon.S +123 -0
  258. data/mpg123/src/libmpg123/synth_neon_accurate.S +173 -0
  259. data/mpg123/src/libmpg123/synth_neon_float.S +149 -0
  260. data/mpg123/src/libmpg123/synth_neon_s32.S +168 -0
  261. data/mpg123/src/libmpg123/synth_ntom.h +213 -0
  262. data/mpg123/src/libmpg123/synth_real.c +404 -0
  263. data/mpg123/src/libmpg123/synth_s32.c +411 -0
  264. data/mpg123/src/libmpg123/synth_sse.S +6 -0
  265. data/mpg123/src/libmpg123/synth_sse3d.h +246 -0
  266. data/mpg123/src/libmpg123/synth_sse_accurate.S +294 -0
  267. data/mpg123/src/libmpg123/synth_sse_float.S +241 -0
  268. data/mpg123/src/libmpg123/synth_sse_s32.S +306 -0
  269. data/mpg123/src/libmpg123/synth_stereo_neon.S +175 -0
  270. data/mpg123/src/libmpg123/synth_stereo_neon_accurate.S +262 -0
  271. data/mpg123/src/libmpg123/synth_stereo_neon_float.S +220 -0
  272. data/mpg123/src/libmpg123/synth_stereo_neon_s32.S +247 -0
  273. data/mpg123/src/libmpg123/synth_stereo_sse_accurate.S +508 -0
  274. data/mpg123/src/libmpg123/synth_stereo_sse_float.S +416 -0
  275. data/mpg123/src/libmpg123/synth_stereo_sse_s32.S +540 -0
  276. data/mpg123/src/libmpg123/synth_stereo_x86_64.S +335 -0
  277. data/mpg123/src/libmpg123/synth_stereo_x86_64_accurate.S +454 -0
  278. data/mpg123/src/libmpg123/synth_stereo_x86_64_float.S +396 -0
  279. data/mpg123/src/libmpg123/synth_stereo_x86_64_s32.S +473 -0
  280. data/mpg123/src/libmpg123/synth_x86_64.S +244 -0
  281. data/mpg123/src/libmpg123/synth_x86_64_accurate.S +301 -0
  282. data/mpg123/src/libmpg123/synth_x86_64_float.S +259 -0
  283. data/mpg123/src/libmpg123/synth_x86_64_s32.S +312 -0
  284. data/mpg123/src/libmpg123/synths.h +52 -0
  285. data/mpg123/src/libmpg123/tabinit.c +294 -0
  286. data/mpg123/src/libmpg123/tabinit_mmx.S +210 -0
  287. data/mpg123/src/libmpg123/testcpu.c +35 -0
  288. data/mpg123/src/libmpg123/true.h +14 -0
  289. data/mpg123/src/local.c +63 -0
  290. data/mpg123/src/local.h +21 -0
  291. data/mpg123/src/metaprint.c +373 -0
  292. data/mpg123/src/metaprint.h +17 -0
  293. data/mpg123/src/module.c +306 -0
  294. data/mpg123/src/module.h +48 -0
  295. data/mpg123/src/mpg123.c +1405 -0
  296. data/mpg123/src/mpg123app.h +171 -0
  297. data/mpg123/src/output/Makefile.am +213 -0
  298. data/mpg123/src/output/Makefile.in +1238 -0
  299. data/mpg123/src/output/aix.c +300 -0
  300. data/mpg123/src/output/alib.c +209 -0
  301. data/mpg123/src/output/alsa.c +297 -0
  302. data/mpg123/src/output/arts.c +117 -0
  303. data/mpg123/src/output/coreaudio.c +370 -0
  304. data/mpg123/src/output/dummy.c +78 -0
  305. data/mpg123/src/output/esd.c +167 -0
  306. data/mpg123/src/output/hp.c +184 -0
  307. data/mpg123/src/output/jack.c +450 -0
  308. data/mpg123/src/output/mint.c +197 -0
  309. data/mpg123/src/output/nas.c +335 -0
  310. data/mpg123/src/output/openal.c +197 -0
  311. data/mpg123/src/output/os2.c +665 -0
  312. data/mpg123/src/output/oss.c +319 -0
  313. data/mpg123/src/output/portaudio.c +255 -0
  314. data/mpg123/src/output/pulse.c +164 -0
  315. data/mpg123/src/output/sdl.c +206 -0
  316. data/mpg123/src/output/sgi.c +213 -0
  317. data/mpg123/src/output/sndio.c +161 -0
  318. data/mpg123/src/output/sun.c +281 -0
  319. data/mpg123/src/output/win32.c +229 -0
  320. data/mpg123/src/playlist.c +596 -0
  321. data/mpg123/src/playlist.h +52 -0
  322. data/mpg123/src/resolver.c +319 -0
  323. data/mpg123/src/resolver.h +25 -0
  324. data/mpg123/src/sfifo.c +146 -0
  325. data/mpg123/src/sfifo.h +95 -0
  326. data/mpg123/src/streamdump.c +74 -0
  327. data/mpg123/src/streamdump.h +20 -0
  328. data/mpg123/src/term.c +479 -0
  329. data/mpg123/src/term.h +81 -0
  330. data/mpg123/src/tests/noise.c +52 -0
  331. data/mpg123/src/tests/plain_id3.c +109 -0
  332. data/mpg123/src/tests/seek_accuracy.c +261 -0
  333. data/mpg123/src/tests/seek_whence.c +56 -0
  334. data/mpg123/src/tests/testtext.h +34 -0
  335. data/mpg123/src/tests/text.c +80 -0
  336. data/mpg123/src/wav.c +464 -0
  337. data/mpg123/src/wavhead.h +68 -0
  338. data/mpg123/src/win32_net.c +599 -0
  339. data/mpg123/src/win32_support.c +191 -0
  340. data/mpg123/src/win32_support.h +152 -0
  341. data/mpg123/src/xfermem.c +321 -0
  342. data/mpg123/src/xfermem.h +74 -0
  343. data/mpg123/windows-builds.sh +137 -0
  344. data/msvc/lib/OpenAL32.lib +0 -0
  345. data/spec/fixtures/heal.ogg +0 -0
  346. data/spec/fixtures/tone_up.wav +0 -0
  347. data/spec/seal/buffer_spec.rb +37 -0
  348. data/spec/seal/core_spec.rb +29 -0
  349. data/spec/seal/effect_slot_spec.rb +38 -0
  350. data/spec/seal/listener_spec.rb +33 -0
  351. data/spec/seal/reverb_spec.rb +51 -0
  352. data/spec/seal/source_spec.rb +370 -0
  353. data/spec/seal/stream_spec.rb +38 -0
  354. data/spec/spec_helper.rb +45 -0
  355. data/spec/support/attribute_examples.rb +75 -0
  356. data/spec/support/audio_object_with_format.rb +27 -0
  357. data/spec/support/movable_object.rb +22 -0
  358. data/src/libogg/bitwise.c +857 -0
  359. data/src/libogg/framing.c +2093 -0
  360. data/src/libvorbis/backends.h +144 -0
  361. data/src/libvorbis/bitrate.c +253 -0
  362. data/src/libvorbis/bitrate.h +59 -0
  363. data/src/libvorbis/block.c +1046 -0
  364. data/src/libvorbis/codebook.c +484 -0
  365. data/src/libvorbis/codebook.h +119 -0
  366. data/src/libvorbis/codec_internal.h +167 -0
  367. data/src/libvorbis/envelope.c +375 -0
  368. data/src/libvorbis/envelope.h +80 -0
  369. data/src/libvorbis/floor0.c +221 -0
  370. data/src/libvorbis/floor1.c +1100 -0
  371. data/src/libvorbis/highlevel.h +58 -0
  372. data/src/libvorbis/info.c +668 -0
  373. data/src/libvorbis/lookup.c +94 -0
  374. data/src/libvorbis/lookup.h +32 -0
  375. data/src/libvorbis/lookup_data.h +192 -0
  376. data/src/libvorbis/lpc.c +160 -0
  377. data/src/libvorbis/lpc.h +29 -0
  378. data/src/libvorbis/lsp.c +456 -0
  379. data/src/libvorbis/lsp.h +28 -0
  380. data/src/libvorbis/mapping0.c +816 -0
  381. data/src/libvorbis/masking.h +785 -0
  382. data/src/libvorbis/mdct.c +563 -0
  383. data/src/libvorbis/mdct.h +71 -0
  384. data/src/libvorbis/misc.h +57 -0
  385. data/src/libvorbis/os.h +186 -0
  386. data/src/libvorbis/psy.c +1206 -0
  387. data/src/libvorbis/psy.h +154 -0
  388. data/src/libvorbis/registry.c +45 -0
  389. data/src/libvorbis/registry.h +32 -0
  390. data/src/libvorbis/res0.c +889 -0
  391. data/src/libvorbis/scales.h +90 -0
  392. data/src/libvorbis/sharedbook.c +579 -0
  393. data/src/libvorbis/smallft.c +1255 -0
  394. data/src/libvorbis/smallft.h +34 -0
  395. data/src/libvorbis/synthesis.c +184 -0
  396. data/src/libvorbis/vorbisfile.c +2337 -0
  397. data/src/libvorbis/window.c +2135 -0
  398. data/src/libvorbis/window.h +26 -0
  399. data/src/rubyext.c +2329 -0
  400. data/src/seal/buf.c +124 -0
  401. data/src/seal/core.c +283 -0
  402. data/src/seal/efs.c +74 -0
  403. data/src/seal/err.c +118 -0
  404. data/src/seal/fmt.c +86 -0
  405. data/src/seal/listener.c +111 -0
  406. data/src/seal/mpg.c +174 -0
  407. data/src/seal/mpg.h +24 -0
  408. data/src/seal/ov.c +180 -0
  409. data/src/seal/ov.h +22 -0
  410. data/src/seal/raw.c +59 -0
  411. data/src/seal/reader.c +102 -0
  412. data/src/seal/reader.h +59 -0
  413. data/src/seal/rvb.c +368 -0
  414. data/src/seal/src.c +654 -0
  415. data/src/seal/stream.c +109 -0
  416. data/src/seal/threading.c +66 -0
  417. data/src/seal/threading.h +20 -0
  418. data/src/seal/wav.c +297 -0
  419. data/src/seal/wav.h +23 -0
  420. data/src/win32api.rb +29 -0
  421. metadata +563 -0
@@ -0,0 +1,17 @@
1
+ /*
2
+ metaprint: display of meta data (including filtering of UTF8 to ASCII)
3
+
4
+ copyright 2006-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 Thomas Orgis
7
+ */
8
+
9
+ #ifndef MPG123_METAPRINT_H
10
+ #define MPG123_METAPRINT_H
11
+
12
+ #include "mpg123app.h"
13
+
14
+ void print_id3_tag(mpg123_handle *mh, int long_meta, FILE *out);
15
+ void print_icy(mpg123_handle *mh, FILE *out);
16
+
17
+ #endif
@@ -0,0 +1,306 @@
1
+ /*
2
+ module.c: modular code loader
3
+
4
+ copyright 1995-2011 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 Nicholas J Humfrey
7
+ */
8
+
9
+ #include <dirent.h>
10
+ #include <sys/stat.h>
11
+ #include <unistd.h>
12
+ #include <errno.h>
13
+ #include <ctype.h>
14
+ #include <ltdl.h>
15
+
16
+ #include "mpg123app.h"
17
+ #include "debug.h"
18
+
19
+ #ifndef HAVE_LTDL
20
+ #error Cannot build without LTDL library support
21
+ #endif
22
+
23
+ #define MODULE_SYMBOL_PREFIX "mpg123_"
24
+ #define MODULE_SYMBOL_SUFFIX "_module_info"
25
+
26
+ /* It's nasty to hardcode that here...
27
+ also it does need hacking around libtool's hardcoded .la paths:
28
+ When the .la file is in the same dir as .so file, you need libdir='.' in there. */
29
+ static const char* modulesearch[] =
30
+ {
31
+ "../lib/mpg123"
32
+ ,"plugins"
33
+ };
34
+
35
+ static char *get_the_cwd(); /* further down... */
36
+ static char *get_module_dir()
37
+ {
38
+ /* Either PKGLIBDIR is accessible right away or we search for some possible plugin dirs relative to binary path. */
39
+ DIR* dir = NULL;
40
+ char *moddir = NULL;
41
+ const char *defaultdir;
42
+ /* Compiled-in default module dir or environment variable MPG123_MODDIR. */
43
+ defaultdir = getenv("MPG123_MODDIR");
44
+ if(defaultdir == NULL)
45
+ defaultdir=PKGLIBDIR;
46
+
47
+ dir = opendir(defaultdir);
48
+ if(dir != NULL)
49
+ {
50
+ size_t l = strlen(defaultdir);
51
+
52
+ if(param.verbose > 1) fprintf(stderr, "Using default module dir: %s\n", defaultdir);
53
+ moddir = malloc(l+1);
54
+ if(moddir != NULL)
55
+ {
56
+ strcpy(moddir, defaultdir);
57
+ moddir[l] = 0;
58
+ }
59
+ closedir(dir);
60
+ }
61
+ else /* Search relative to binary. */
62
+ {
63
+ size_t i;
64
+ for(i=0; i<sizeof(modulesearch)/sizeof(char*); ++i)
65
+ {
66
+ const char *testpath = modulesearch[i];
67
+ size_t l;
68
+ if(binpath != NULL) l = strlen(binpath) + strlen(testpath) + 1;
69
+ else l = strlen(testpath);
70
+
71
+ moddir = malloc(l+1);
72
+ if(moddir != NULL)
73
+ {
74
+ if(binpath==NULL) /* a copy of testpath, when there is no prefix */
75
+ snprintf(moddir, l+1, "%s", testpath);
76
+ else
77
+ snprintf(moddir, l+1, "%s/%s", binpath, testpath);
78
+
79
+ moddir[l] = 0;
80
+ if(param.verbose > 1) fprintf(stderr, "Looking for module dir: %s\n", moddir);
81
+
82
+ dir = opendir(moddir);
83
+ closedir(dir);
84
+
85
+ if(dir != NULL) break; /* found it! */
86
+ else{ free(moddir); moddir=NULL; }
87
+ }
88
+ }
89
+ }
90
+ if(param.verbose > 1) fprintf(stderr, "Module dir: %s\n", moddir != NULL ? moddir : "<nil>");
91
+ return moddir;
92
+ }
93
+
94
+ /* Open a module */
95
+ mpg123_module_t*
96
+ open_module( const char* type, const char* name )
97
+ {
98
+ lt_dlhandle handle = NULL;
99
+ mpg123_module_t *module = NULL;
100
+ char* module_path = NULL;
101
+ size_t module_path_len = 0;
102
+ char* module_symbol = NULL;
103
+ size_t module_symbol_len = 0;
104
+ char *workdir = NULL;
105
+ char *moddir = NULL;
106
+ workdir = get_the_cwd();
107
+ moddir = get_module_dir();
108
+ if(workdir == NULL || moddir == NULL)
109
+ {
110
+ error("Failure getting workdir or moddir!");
111
+ if(workdir == NULL) fprintf(stderr, "Hint: I need to know the current working directory to be able to come back after hunting modules. I will not leave because I do not know where I am.\n");
112
+
113
+ if(workdir != NULL) free(workdir);
114
+ if(moddir != NULL) free(moddir);
115
+ return NULL;
116
+ }
117
+
118
+ /* Initialize libltdl */
119
+ if (lt_dlinit()) error( "Failed to initialise libltdl" );
120
+
121
+ if(chdir(moddir) != 0)
122
+ {
123
+ error2("Failed to enter module directory %s: %s", moddir, strerror(errno));
124
+ goto om_bad;
125
+ }
126
+ /* Work out the path of the module to open */
127
+ /* Note that we need to open ./file, not just file! */
128
+ module_path_len = 2 + strlen(type) + 1 + strlen(name) + strlen(MODULE_FILE_SUFFIX) + 1;
129
+ module_path = malloc( module_path_len );
130
+ if (module_path == NULL) {
131
+ error1( "Failed to allocate memory for module name: %s", strerror(errno) );
132
+ goto om_bad;
133
+ }
134
+ snprintf( module_path, module_path_len, "./%s_%s%s", type, name, MODULE_FILE_SUFFIX );
135
+ /* Display the path of the module created */
136
+ if(param.verbose > 1) fprintf(stderr, "Module path: %s\n", module_path );
137
+
138
+ /* Open the module */
139
+ handle = lt_dlopen( module_path );
140
+ free( module_path );
141
+ if (handle==NULL) {
142
+ error2( "Failed to open module %s: %s", name, lt_dlerror() );
143
+ if(param.verbose > 1)
144
+ fprintf(stderr, "Note: This could be because of braindead path in the .la file...\n");
145
+
146
+ goto om_bad;
147
+ }
148
+
149
+ /* Work out the symbol name */
150
+ module_symbol_len = strlen( MODULE_SYMBOL_PREFIX ) +
151
+ strlen( type ) +
152
+ strlen( MODULE_SYMBOL_SUFFIX ) + 1;
153
+ module_symbol = malloc(module_symbol_len);
154
+ snprintf( module_symbol, module_symbol_len, "%s%s%s", MODULE_SYMBOL_PREFIX, type, MODULE_SYMBOL_SUFFIX );
155
+ debug1( "Module symbol: %s", module_symbol );
156
+
157
+ /* Get the information structure from the module */
158
+ module = (mpg123_module_t*)lt_dlsym(handle, module_symbol );
159
+ free( module_symbol );
160
+ if (module==NULL) {
161
+ error1( "Failed to get module symbol: %s", lt_dlerror() );
162
+ goto om_latebad;
163
+ }
164
+
165
+ /* Check the API version */
166
+ if (MPG123_MODULE_API_VERSION > module->api_version) {
167
+ error( "API version of module is too old" );
168
+ goto om_latebad;
169
+ } else if (MPG123_MODULE_API_VERSION > module->api_version) {
170
+ error( "API version of module is too new" );
171
+ goto om_latebad;
172
+ }
173
+
174
+ /* Store handle in the data structure */
175
+ module->handle = handle;
176
+
177
+ goto om_end;
178
+ om_latebad:
179
+ lt_dlclose( handle );
180
+ om_bad:
181
+ module = NULL;
182
+ om_end:
183
+ chdir(workdir);
184
+ free(moddir);
185
+ free(workdir);
186
+ return module;
187
+ }
188
+
189
+
190
+ void close_module( mpg123_module_t* module )
191
+ {
192
+ lt_dlhandle handle = module->handle;
193
+ int err = lt_dlclose( handle );
194
+
195
+ if (err) error1("Failed to close module: %s", lt_dlerror() );
196
+
197
+ }
198
+
199
+ #define PATH_STEP 50
200
+ static char *get_the_cwd()
201
+ {
202
+ size_t bs = PATH_STEP;
203
+ char *buf = malloc(bs);
204
+ errno = 0;
205
+ while((buf != NULL) && getcwd(buf, bs) == NULL)
206
+ {
207
+ char *buf2;
208
+ if(errno != ERANGE)
209
+ {
210
+ error1("getcwd returned unexpected error: %s", strerror(errno));
211
+ free(buf);
212
+ return NULL;
213
+ }
214
+ buf2 = realloc(buf, bs+=PATH_STEP);
215
+ if(buf2 == NULL){ free(buf); buf = NULL; }
216
+ else debug1("pwd: increased buffer to %lu", (unsigned long)bs);
217
+
218
+ buf = buf2;
219
+ }
220
+ return buf;
221
+ }
222
+
223
+ void list_modules()
224
+ {
225
+ DIR* dir = NULL;
226
+ struct dirent *dp = NULL;
227
+ char *workdir = NULL;
228
+ char *moddir = NULL;
229
+
230
+ moddir = get_module_dir();
231
+ /* Open the module directory */
232
+ dir = opendir(moddir);
233
+ if (dir==NULL) {
234
+ error2("Failed to open the module directory (%s): %s\n", PKGLIBDIR, strerror(errno));
235
+ free(moddir);
236
+ exit(-1);
237
+ }
238
+
239
+ workdir = get_the_cwd();
240
+ if(chdir(moddir) != 0)
241
+ {
242
+ error2("Failed to enter module directory (%s): %s\n", PKGLIBDIR, strerror(errno));
243
+ closedir( dir );
244
+ free(workdir);
245
+ free(moddir);
246
+ exit(-1);
247
+ }
248
+ /* Display the program title */
249
+ /* print_title(stderr); */
250
+
251
+ /* List the output modules */
252
+ printf("\n");
253
+ printf("Available modules\n");
254
+ printf("-----------------\n");
255
+
256
+ while( (dp = readdir(dir)) != NULL ) {
257
+ struct stat fst;
258
+ if(stat(dp->d_name, &fst) != 0) continue;
259
+ if(S_ISREG(fst.st_mode)) /* Allow links? */
260
+ {
261
+ char* ext = dp->d_name + strlen( dp->d_name ) - strlen( MODULE_FILE_SUFFIX );
262
+ if (strcmp(ext, MODULE_FILE_SUFFIX) == 0)
263
+ {
264
+ char *module_name = NULL;
265
+ char *module_type = NULL;
266
+ char *uscore_pos = NULL;
267
+ mpg123_module_t *module = NULL;
268
+
269
+ /* Extract the module type */
270
+ module_type = strdup( dp->d_name );
271
+ uscore_pos = strchr( module_type, '_' );
272
+ if (uscore_pos==NULL || (uscore_pos>=module_type+strlen(module_type)+1) )
273
+ {
274
+ free(module_type);
275
+ continue;
276
+ }
277
+
278
+ *uscore_pos = '\0';
279
+
280
+ /* Extract the short name of the module */
281
+ module_name = strdup( dp->d_name + strlen( module_type ) + 1 );
282
+ module_name[ strlen( module_name ) - strlen( MODULE_FILE_SUFFIX ) ] = '\0';
283
+
284
+ /* Open the module */
285
+ module = open_module( module_type, module_name );
286
+ if (module) {
287
+ printf("%-15s%s %s\n", module->name, module_type, module->description );
288
+
289
+ /* Close the module again */
290
+ close_module( module );
291
+ }
292
+
293
+ free( module_name );
294
+ free( module_type );
295
+ }
296
+ }
297
+ }
298
+
299
+ chdir(workdir);
300
+ free(workdir);
301
+ closedir( dir );
302
+ free(moddir);
303
+ exit(0);
304
+ }
305
+
306
+
@@ -0,0 +1,48 @@
1
+ /*
2
+ module: module loading and listing interface
3
+
4
+ copyright ?-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
+ */
7
+
8
+ #ifndef _MPG123_MODULE_H_
9
+ #define _MPG123_MODULE_H_
10
+
11
+ /* Pulled in by mpg123app.h! */
12
+
13
+ #ifdef HAVE_LTDL
14
+ #include <ltdl.h>
15
+ #endif
16
+
17
+ #define MPG123_MODULE_API_VERSION (1)
18
+
19
+ /* The full structure is delared in audio.h */
20
+ struct audio_output_struct;
21
+
22
+ typedef struct mpg123_module_struct {
23
+ const int api_version; /* module API version number */
24
+
25
+ const char* name; /* short name of the module */
26
+ const char* description; /* description of what the module does */
27
+ const char* revision; /* source code revision */
28
+
29
+ #ifdef HAVE_LTDL
30
+ lt_dlhandle handle; /* ltdl handle - set by open_module */
31
+ #else
32
+ void* handle;
33
+ #endif
34
+
35
+ /* Initialisers - set to NULL if unsupported by module */
36
+ int (*init_output)(struct audio_output_struct* ao); /* audio output - returns 0 on success */
37
+
38
+ } mpg123_module_t;
39
+
40
+
41
+
42
+ /* ------ Declarations from "module.c" ------ */
43
+
44
+ mpg123_module_t* open_module( const char* type, const char* name );
45
+ void close_module( mpg123_module_t* module );
46
+ void list_modules();
47
+
48
+ #endif
@@ -0,0 +1,1405 @@
1
+ /*
2
+ mpg123: main code of the program (not of the decoder...)
3
+
4
+ copyright 1995-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 Michael Hipp
7
+ */
8
+
9
+ #define ME "main"
10
+ #include "mpg123app.h"
11
+ #include "mpg123.h"
12
+ #include "local.h"
13
+
14
+ #ifdef HAVE_SYS_WAIT_H
15
+ #include <sys/wait.h>
16
+ #endif
17
+ #ifdef HAVE_SYS_RESOURCE_H
18
+ #include <sys/resource.h>
19
+ #endif
20
+
21
+ #include <errno.h>
22
+ #include <string.h>
23
+ #include <fcntl.h>
24
+ #include <time.h>
25
+
26
+ #ifdef HAVE_SCHED_H
27
+ #include <sched.h>
28
+ #endif
29
+
30
+ /* be paranoid about setpriority support */
31
+ #ifndef PRIO_PROCESS
32
+ #undef HAVE_SETPRIORITY
33
+ #endif
34
+
35
+ #include "common.h"
36
+ #include "getlopt.h"
37
+ #include "buffer.h"
38
+ #include "term.h"
39
+ #include "playlist.h"
40
+ #include "httpget.h"
41
+ #include "metaprint.h"
42
+ #include "httpget.h"
43
+ #include "streamdump.h"
44
+
45
+ #include "debug.h"
46
+
47
+ static void usage(int err);
48
+ static void want_usage(char* arg);
49
+ static void long_usage(int err);
50
+ static void want_long_usage(char* arg);
51
+ static void print_title(FILE* o);
52
+ static void give_version(char* arg);
53
+
54
+ struct parameter param = {
55
+ FALSE , /* aggressiv */
56
+ FALSE , /* shuffle */
57
+ FALSE , /* remote */
58
+ FALSE , /* remote to stderr */
59
+ DECODE_AUDIO , /* write samples to audio device */
60
+ FALSE , /* silent operation */
61
+ FALSE , /* xterm title on/off */
62
+ 0 , /* second level buffer size */
63
+ 0 , /* verbose level */
64
+ DEFAULT_OUTPUT_MODULE, /* output module */
65
+ NULL, /* output device */
66
+ 0, /* destination (headphones, ...) */
67
+ #ifdef HAVE_TERMIOS
68
+ FALSE , /* term control */
69
+ MPG123_TERM_USR1,
70
+ MPG123_TERM_USR2,
71
+ #endif
72
+ FALSE , /* checkrange */
73
+ 0 , /* force_reopen, always (re)opens audio device for next song */
74
+ /* test_cpu flag is valid for multi and 3dnow.. even if 3dnow is built alone; ensure it appears only once */
75
+ FALSE , /* normal operation */
76
+ FALSE, /* try to run process in 'realtime mode' */
77
+ #ifdef HAVE_WINDOWS_H
78
+ 0, /* win32 process priority */
79
+ #endif
80
+ NULL, /* wav,cdr,au Filename */
81
+ 0, /* default is to play all titles in playlist */
82
+ NULL, /* no playlist per default */
83
+ 0 /* condensed id3 per default */
84
+ ,0 /* list_cpu */
85
+ ,NULL /* cpu */
86
+ #ifdef FIFO
87
+ ,NULL
88
+ #endif
89
+ ,0 /* timeout */
90
+ ,1 /* loop */
91
+ ,0 /* delay */
92
+ ,0 /* index */
93
+ /* Parameters for mpg123 handle, defaults are queried from library! */
94
+ ,0 /* down_sample */
95
+ ,0 /* rva */
96
+ ,0 /* halfspeed */
97
+ ,0 /* doublespeed */
98
+ ,0 /* start_frame */
99
+ ,-1 /* frame_number */
100
+ ,0 /* outscale */
101
+ ,0 /* flags */
102
+ ,0 /* force_rate */
103
+ ,1 /* ICY */
104
+ ,1024 /* resync_limit */
105
+ ,0 /* smooth */
106
+ ,0.0 /* pitch */
107
+ ,0 /* appflags */
108
+ ,NULL /* proxyurl */
109
+ ,0 /* keep_open */
110
+ ,0 /* force_utf8 */
111
+ ,INDEX_SIZE
112
+ ,NULL /* force_encoding */
113
+ ,1. /* preload */
114
+ ,-1 /* preframes */
115
+ ,-1 /* gain */
116
+ ,NULL /* stream dump file */
117
+ ,0 /* ICY interval */
118
+ };
119
+
120
+ mpg123_handle *mh = NULL;
121
+ off_t framenum;
122
+ off_t frames_left;
123
+ audio_output_t *ao = NULL;
124
+ txfermem *buffermem = NULL;
125
+ char *prgName = NULL;
126
+ /* ThOr: pointers are not TRUE or FALSE */
127
+ char *equalfile = NULL;
128
+ struct httpdata htd;
129
+ int fresh = TRUE;
130
+ int have_output = FALSE; /* If we are past the output init step. */
131
+
132
+ int buffer_fd[2];
133
+ int buffer_pid;
134
+ size_t bufferblock = 0;
135
+
136
+ static int intflag = FALSE;
137
+ static int skip_tracks = 0;
138
+ int OutputDescriptor;
139
+
140
+ static int filept = -1;
141
+
142
+ static int network_sockets_used = 0; /* Win32 socket open/close Support */
143
+
144
+ char *binpath; /* Path to myself. */
145
+
146
+ /* File-global storage of command line arguments.
147
+ They may be needed for cleanup after charset conversion. */
148
+ static char **argv = NULL;
149
+ static int argc = 0;
150
+
151
+ /* Cleanup marker to know that we intiialized libmpg123 already. */
152
+ static int cleanup_mpg123 = FALSE;
153
+
154
+ void set_intflag()
155
+ {
156
+ debug("set_intflag TRUE");
157
+ intflag = TRUE;
158
+ skip_tracks = 0;
159
+ }
160
+
161
+ #if !defined(WIN32) && !defined(GENERIC)
162
+ static void catch_interrupt(void)
163
+ {
164
+ intflag = TRUE;
165
+ }
166
+ #endif
167
+
168
+ /* oh, what a mess... */
169
+ void next_track(void)
170
+ {
171
+ intflag = TRUE;
172
+ ++skip_tracks;
173
+ }
174
+
175
+ void prev_track(void)
176
+ {
177
+ if(pl.pos > 2) pl.pos -= 2;
178
+ else pl.pos = 0;
179
+
180
+ next_track();
181
+ }
182
+
183
+ void safe_exit(int code)
184
+ {
185
+ char *dummy, *dammy;
186
+
187
+ dump_close();
188
+ #ifdef HAVE_TERMIOS
189
+ if(param.term_ctrl)
190
+ term_restore();
191
+ #endif
192
+ if(have_output) exit_output(ao, intflag);
193
+
194
+ if(mh != NULL) mpg123_delete(mh);
195
+
196
+ if(cleanup_mpg123) mpg123_exit();
197
+
198
+ httpdata_free(&htd);
199
+
200
+ #ifdef WANT_WIN32_UNICODE
201
+ win32_cmdline_free(argc, argv); /* This handles the premature argv == NULL, too. */
202
+ #endif
203
+ #if defined (WANT_WIN32_SOCKETS)
204
+ win32_net_deinit();
205
+ #endif
206
+ /* It's ugly... but let's just fix this still-reachable memory chunk of static char*. */
207
+ split_dir_file("", &dummy, &dammy);
208
+ exit(code);
209
+ }
210
+
211
+ /* returns 1 if reset_audio needed instead */
212
+ static void set_output_module( char *arg )
213
+ {
214
+ unsigned int i;
215
+
216
+ /* Search for a colon and set the device if found */
217
+ for(i=0; i< strlen( arg ); i++) {
218
+ if (arg[i] == ':') {
219
+ arg[i] = 0;
220
+ param.output_device = &arg[i+1];
221
+ debug1("Setting output device: %s", param.output_device);
222
+ break;
223
+ }
224
+ }
225
+ /* Set the output module */
226
+ param.output_module = arg;
227
+ debug1("Setting output module: %s", param.output_module );
228
+ }
229
+
230
+ static void set_output_flag(int flag)
231
+ {
232
+ if(param.output_flags <= 0) param.output_flags = flag;
233
+ else param.output_flags |= flag;
234
+ }
235
+
236
+ static void set_output_h(char *a)
237
+ {
238
+ set_output_flag(AUDIO_OUT_HEADPHONES);
239
+ }
240
+
241
+ static void set_output_s(char *a)
242
+ {
243
+ set_output_flag(AUDIO_OUT_INTERNAL_SPEAKER);
244
+ }
245
+
246
+ static void set_output_l(char *a)
247
+ {
248
+ set_output_flag(AUDIO_OUT_LINE_OUT);
249
+ }
250
+
251
+ static void set_output(char *arg)
252
+ {
253
+ /* If single letter, it's the legacy output switch for AIX/HP/Sun.
254
+ If longer, it's module[:device] . If zero length, it's rubbish. */
255
+ if(strlen(arg) <= 1) switch(arg[0])
256
+ {
257
+ case 'h': set_output_h(arg); break;
258
+ case 's': set_output_s(arg); break;
259
+ case 'l': set_output_l(arg); break;
260
+ default:
261
+ error1("\"%s\" is no valid output", arg);
262
+ safe_exit(1);
263
+ }
264
+ else set_output_module(arg);
265
+ }
266
+
267
+ static void set_verbose (char *arg)
268
+ {
269
+ param.verbose++;
270
+ }
271
+
272
+ static void set_quiet (char *arg)
273
+ {
274
+ param.verbose=0;
275
+ param.quiet=TRUE;
276
+ }
277
+
278
+ static void set_out_wav(char *arg)
279
+ {
280
+ param.outmode = DECODE_WAV;
281
+ param.filename = arg;
282
+ }
283
+
284
+ void set_out_cdr(char *arg)
285
+ {
286
+ param.outmode = DECODE_CDR;
287
+ param.filename = arg;
288
+ }
289
+
290
+ void set_out_au(char *arg)
291
+ {
292
+ param.outmode = DECODE_AU;
293
+ param.filename = arg;
294
+ }
295
+
296
+ static void set_out_file(char *arg)
297
+ {
298
+ param.outmode=DECODE_FILE;
299
+ #ifdef WIN32
300
+ #ifdef WANT_WIN32_UNICODE
301
+ wchar_t *argw = NULL;
302
+ OutputDescriptor = win32_utf8_wide(arg, &argw, NULL);
303
+ if(argw != NULL)
304
+ {
305
+ OutputDescriptor=_wopen(argw,_O_CREAT|_O_WRONLY|_O_BINARY|_O_TRUNC,0666);
306
+ free(argw);
307
+ }
308
+ #else
309
+ OutputDescriptor=_open(arg,_O_CREAT|_O_WRONLY|_O_BINARY|_O_TRUNC,0666);
310
+ #endif /*WANT_WIN32_UNICODE*/
311
+ #else /*WIN32*/
312
+ OutputDescriptor=open(arg,O_CREAT|O_WRONLY|O_TRUNC,0666);
313
+ #endif /*WIN32*/
314
+ if(OutputDescriptor==-1)
315
+ {
316
+ error2("Can't open %s for writing (%s).\n",arg,strerror(errno));
317
+ safe_exit(1);
318
+ }
319
+ }
320
+
321
+ static void set_out_stdout(char *arg)
322
+ {
323
+ param.outmode=DECODE_FILE;
324
+ param.remote_err=TRUE;
325
+ OutputDescriptor=STDOUT_FILENO;
326
+ #ifdef WIN32
327
+ _setmode(STDOUT_FILENO, _O_BINARY);
328
+ #endif
329
+ }
330
+
331
+ static void set_out_stdout1(char *arg)
332
+ {
333
+ param.outmode=DECODE_AUDIOFILE;
334
+ param.remote_err=TRUE;
335
+ OutputDescriptor=STDOUT_FILENO;
336
+ #ifdef WIN32
337
+ _setmode(STDOUT_FILENO, _O_BINARY);
338
+ #endif
339
+ }
340
+
341
+ #if !defined (HAVE_SCHED_SETSCHEDULER) && !defined (HAVE_WINDOWS_H)
342
+ static void realtime_not_compiled(char *arg)
343
+ {
344
+ fprintf(stderr,"Option '-T / --realtime' not compiled into this binary.\n");
345
+ }
346
+ #endif
347
+
348
+ static int frameflag; /* ugly, but that's the way without hacking getlopt */
349
+ static void set_frameflag(char *arg)
350
+ {
351
+ /* Only one mono flag at a time! */
352
+ if(frameflag & MPG123_FORCE_MONO) param.flags &= ~MPG123_FORCE_MONO;
353
+ param.flags |= frameflag;
354
+ }
355
+ static void unset_frameflag(char *arg)
356
+ {
357
+ param.flags &= ~frameflag;
358
+ }
359
+
360
+ static int appflag; /* still ugly, but works */
361
+ static void set_appflag(char *arg)
362
+ {
363
+ param.appflags |= appflag;
364
+ }
365
+ /* static void unset_appflag(char *arg)
366
+ {
367
+ param.appflags &= ~appflag;
368
+ } */
369
+
370
+ /* Please note: GLO_NUM expects point to LONG! */
371
+ /* ThOr:
372
+ * Yeah, and despite that numerous addresses to int variables were
373
+ passed.
374
+ * That's not good on my Alpha machine with int=32bit and long=64bit!
375
+ * Introduced GLO_INT and GLO_LONG as different bits to make that clear.
376
+ * GLO_NUM no longer exists.
377
+ */
378
+ #ifdef OPT_3DNOW
379
+ static int dnow = 0; /* helper for mapping the old 3dnow options */
380
+ #endif
381
+ topt opts[] = {
382
+ {'k', "skip", GLO_ARG | GLO_LONG, 0, &param.start_frame, 0},
383
+ {'2', "2to1", GLO_INT, 0, &param.down_sample, 1},
384
+ {'4', "4to1", GLO_INT, 0, &param.down_sample, 2},
385
+ {'t', "test", GLO_INT, 0, &param.outmode, DECODE_TEST},
386
+ {'s', "stdout", GLO_INT, set_out_stdout, &param.outmode, DECODE_FILE},
387
+ {'S', "STDOUT", GLO_INT, set_out_stdout1, &param.outmode,DECODE_AUDIOFILE},
388
+ {'O', "outfile", GLO_ARG | GLO_CHAR, set_out_file, NULL, 0},
389
+ {'c', "check", GLO_INT, 0, &param.checkrange, TRUE},
390
+ {'v', "verbose", 0, set_verbose, 0, 0},
391
+ {'q', "quiet", 0, set_quiet, 0, 0},
392
+ {'y', "no-resync", GLO_INT, set_frameflag, &frameflag, MPG123_NO_RESYNC},
393
+ /* compatibility, no-resync is to be used nowadays */
394
+ {0, "resync", GLO_INT, set_frameflag, &frameflag, MPG123_NO_RESYNC},
395
+ {'0', "single0", GLO_INT, set_frameflag, &frameflag, MPG123_MONO_LEFT},
396
+ {0, "left", GLO_INT, set_frameflag, &frameflag, MPG123_MONO_LEFT},
397
+ {'1', "single1", GLO_INT, set_frameflag, &frameflag, MPG123_MONO_RIGHT},
398
+ {0, "right", GLO_INT, set_frameflag, &frameflag, MPG123_MONO_RIGHT},
399
+ {'m', "singlemix", GLO_INT, set_frameflag, &frameflag, MPG123_MONO_MIX},
400
+ {0, "mix", GLO_INT, set_frameflag, &frameflag, MPG123_MONO_MIX},
401
+ {0, "mono", GLO_INT, set_frameflag, &frameflag, MPG123_MONO_MIX},
402
+ {0, "stereo", GLO_INT, set_frameflag, &frameflag, MPG123_FORCE_STEREO},
403
+ {0, "reopen", GLO_INT, 0, &param.force_reopen, 1},
404
+ {'g', "gain", GLO_ARG | GLO_LONG, 0, &param.gain, 0},
405
+ {'r', "rate", GLO_ARG | GLO_LONG, 0, &param.force_rate, 0},
406
+ {0, "8bit", GLO_INT, set_frameflag, &frameflag, MPG123_FORCE_8BIT},
407
+ {0, "float", GLO_INT, set_frameflag, &frameflag, MPG123_FORCE_FLOAT},
408
+ {0, "headphones", 0, set_output_h, 0,0},
409
+ {0, "speaker", 0, set_output_s, 0,0},
410
+ {0, "lineout", 0, set_output_l, 0,0},
411
+ {'o', "output", GLO_ARG | GLO_CHAR, set_output, 0, 0},
412
+ {0, "list-modules",0, list_modules, NULL, 0},
413
+ {'a', "audiodevice", GLO_ARG | GLO_CHAR, 0, &param.output_device, 0},
414
+ {'f', "scale", GLO_ARG | GLO_LONG, 0, &param.outscale, 0},
415
+ {'n', "frames", GLO_ARG | GLO_LONG, 0, &param.frame_number, 0},
416
+ #ifdef HAVE_TERMIOS
417
+ {'C', "control", GLO_INT, 0, &param.term_ctrl, TRUE},
418
+ {0, "ctrlusr1", GLO_ARG | GLO_CHAR, 0, &param.term_usr1, 0},
419
+ {0, "ctrlusr2", GLO_ARG | GLO_CHAR, 0, &param.term_usr2, 0},
420
+ #endif
421
+ #ifndef NOXFERMEM
422
+ {'b', "buffer", GLO_ARG | GLO_LONG, 0, &param.usebuffer, 0},
423
+ {0, "smooth", GLO_INT, 0, &param.smooth, 1},
424
+ #endif
425
+ {'R', "remote", GLO_INT, 0, &param.remote, TRUE},
426
+ {0, "remote-err", GLO_INT, 0, &param.remote_err, TRUE},
427
+ {'d', "doublespeed", GLO_ARG | GLO_LONG, 0, &param.doublespeed, 0},
428
+ {'h', "halfspeed", GLO_ARG | GLO_LONG, 0, &param.halfspeed, 0},
429
+ {'p', "proxy", GLO_ARG | GLO_CHAR, 0, &param.proxyurl, 0},
430
+ {'@', "list", GLO_ARG | GLO_CHAR, 0, &param.listname, 0},
431
+ /* 'z' comes from the the german word 'zufall' (eng: random) */
432
+ {'z', "shuffle", GLO_INT, 0, &param.shuffle, 1},
433
+ {'Z', "random", GLO_INT, 0, &param.shuffle, 2},
434
+ {'E', "equalizer", GLO_ARG | GLO_CHAR, 0, &equalfile,1},
435
+ #ifdef HAVE_SETPRIORITY
436
+ {0, "aggressive", GLO_INT, 0, &param.aggressive, 2},
437
+ #endif
438
+ #ifdef OPT_3DNOW
439
+ #define SET_3DNOW 1
440
+ #define SET_I586 2
441
+ {0, "force-3dnow", GLO_CHAR, 0, &dnow, SET_3DNOW},
442
+ {0, "no-3dnow", GLO_CHAR, 0, &dnow, SET_I586},
443
+ {0, "test-3dnow", GLO_INT, 0, &param.test_cpu, TRUE},
444
+ #endif
445
+ {0, "cpu", GLO_ARG | GLO_CHAR, 0, &param.cpu, 0},
446
+ {0, "test-cpu", GLO_INT, 0, &param.test_cpu, TRUE},
447
+ {0, "list-cpu", GLO_INT, 0, &param.list_cpu , 1},
448
+ #ifdef NETWORK
449
+ {'u', "auth", GLO_ARG | GLO_CHAR, 0, &httpauth, 0},
450
+ #endif
451
+ #if defined (HAVE_SCHED_SETSCHEDULER) || defined (HAVE_WINDOWS_H)
452
+ /* check why this should be a long variable instead of int! */
453
+ {'T', "realtime", GLO_LONG, 0, &param.realtime, TRUE },
454
+ #else
455
+ {'T', "realtime", 0, realtime_not_compiled, 0, 0 },
456
+ #endif
457
+ #ifdef HAVE_WINDOWS_H
458
+ {0, "priority", GLO_ARG | GLO_INT, 0, &param.w32_priority, 0},
459
+ #endif
460
+ {0, "title", GLO_INT, 0, &param.xterm_title, TRUE },
461
+ {'w', "wav", GLO_ARG | GLO_CHAR, set_out_wav, 0, 0 },
462
+ {0, "cdr", GLO_ARG | GLO_CHAR, set_out_cdr, 0, 0 },
463
+ {0, "au", GLO_ARG | GLO_CHAR, set_out_au, 0, 0 },
464
+ {0, "gapless", GLO_INT, set_frameflag, &frameflag, MPG123_GAPLESS},
465
+ {0, "no-gapless", GLO_INT, unset_frameflag, &frameflag, MPG123_GAPLESS},
466
+ {'?', "help", 0, want_usage, 0, 0 },
467
+ {0 , "longhelp" , 0, want_long_usage, 0, 0 },
468
+ {0 , "version" , 0, give_version, 0, 0 },
469
+ {'l', "listentry", GLO_ARG | GLO_LONG, 0, &param.listentry, 0 },
470
+ {0, "rva-mix", GLO_INT, 0, &param.rva, 1 },
471
+ {0, "rva-radio", GLO_INT, 0, &param.rva, 1 },
472
+ {0, "rva-album", GLO_INT, 0, &param.rva, 2 },
473
+ {0, "rva-audiophile", GLO_INT, 0, &param.rva, 2 },
474
+ {0, "no-icy-meta", GLO_INT, 0, &param.talk_icy, 0 },
475
+ {0, "long-tag", GLO_INT, 0, &param.long_id3, 1 },
476
+ #ifdef FIFO
477
+ {0, "fifo", GLO_ARG | GLO_CHAR, 0, &param.fifo, 0},
478
+ #endif
479
+ {0, "timeout", GLO_ARG | GLO_LONG, 0, &param.timeout, 0},
480
+ {0, "loop", GLO_ARG | GLO_LONG, 0, &param.loop, 0},
481
+ {'i', "index", GLO_INT, 0, &param.index, 1},
482
+ {'D', "delay", GLO_ARG | GLO_INT, 0, &param.delay, 0},
483
+ {0, "resync-limit", GLO_ARG | GLO_LONG, 0, &param.resync_limit, 0},
484
+ {0, "pitch", GLO_ARG|GLO_DOUBLE, 0, &param.pitch, 0},
485
+ {0, "ignore-mime", GLO_INT, set_appflag, &appflag, MPG123APP_IGNORE_MIME },
486
+ {0, "lyrics", GLO_INT, set_appflag, &appflag, MPG123APP_LYRICS},
487
+ {0, "keep-open", GLO_INT, 0, &param.keep_open, 1},
488
+ {0, "utf8", GLO_INT, 0, &param.force_utf8, 1},
489
+ {0, "fuzzy", GLO_INT, set_frameflag, &frameflag, MPG123_FUZZY},
490
+ {0, "index-size", GLO_ARG|GLO_LONG, 0, &param.index_size, 0},
491
+ {0, "no-seekbuffer", GLO_INT, unset_frameflag, &frameflag, MPG123_SEEKBUFFER},
492
+ {'e', "encoding", GLO_ARG|GLO_CHAR, 0, &param.force_encoding, 0},
493
+ {0, "preload", GLO_ARG|GLO_DOUBLE, 0, &param.preload, 0},
494
+ {0, "preframes", GLO_ARG|GLO_LONG, 0, &param.preframes, 0},
495
+ {0, "skip-id3v2", GLO_INT, set_frameflag, &frameflag, MPG123_SKIP_ID3V2},
496
+ {0, "streamdump", GLO_ARG|GLO_CHAR, 0, &param.streamdump, 0},
497
+ {0, "icy-interval", GLO_ARG|GLO_LONG, 0, &param.icy_interval, 0},
498
+ {0, "ignore-streamlength", GLO_INT, set_frameflag, &frameflag, MPG123_IGNORE_STREAMLENGTH},
499
+ {0, 0, 0, 0, 0, 0}
500
+ };
501
+
502
+ /*
503
+ * Change the playback sample rate.
504
+ * Consider that changing it after starting playback is not covered by gapless code!
505
+ */
506
+ static void reset_audio(long rate, int channels, int format)
507
+ {
508
+ #ifndef NOXFERMEM
509
+ if (param.usebuffer) {
510
+ /* wait until the buffer is empty,
511
+ * then tell the buffer process to
512
+ * change the sample rate. [OF]
513
+ */
514
+ while (xfermem_get_usedspace(buffermem) > 0)
515
+ if (xfermem_block(XF_WRITER, buffermem) == XF_CMD_TERMINATE) {
516
+ intflag = TRUE;
517
+ break;
518
+ }
519
+ buffermem->freeindex = -1;
520
+ buffermem->readindex = 0; /* I know what I'm doing! ;-) */
521
+ buffermem->freeindex = 0;
522
+ if (intflag)
523
+ return;
524
+ buffermem->rate = pitch_rate(rate);
525
+ buffermem->channels = channels;
526
+ buffermem->format = format;
527
+ buffer_reset();
528
+ }
529
+ else
530
+ {
531
+ #endif
532
+ if(ao == NULL)
533
+ {
534
+ error("Audio handle should not be NULL here!");
535
+ safe_exit(98);
536
+ }
537
+ ao->rate = pitch_rate(rate);
538
+ ao->channels = channels;
539
+ ao->format = format;
540
+ if(reset_output(ao) < 0)
541
+ {
542
+ error1("failed to reset audio device: %s", strerror(errno));
543
+ safe_exit(1);
544
+ }
545
+ #ifndef NOXFERMEM
546
+ }
547
+ #endif
548
+ }
549
+
550
+ static int open_track_fd (void)
551
+ {
552
+ /* Let reader handle invalid filept */
553
+ if(mpg123_open_fd(mh, filept) != MPG123_OK)
554
+ {
555
+ error2("Cannot open fd %i: %s", filept, mpg123_strerror(mh));
556
+ return 0;
557
+ }
558
+ debug("Track successfully opened.");
559
+ fresh = TRUE;
560
+ return 1;
561
+ /*1 for success, 0 for failure */
562
+ }
563
+
564
+ /* 1 on success, 0 on failure */
565
+ int open_track(char *fname)
566
+ {
567
+ filept=-1;
568
+ httpdata_reset(&htd);
569
+ if(MPG123_OK != mpg123_param(mh, MPG123_ICY_INTERVAL, 0, 0))
570
+ error1("Cannot (re)set ICY interval: %s", mpg123_strerror(mh));
571
+ if(!strcmp(fname, "-"))
572
+ {
573
+ filept = STDIN_FILENO;
574
+ #ifdef WIN32
575
+ _setmode(STDIN_FILENO, _O_BINARY);
576
+ #endif
577
+ return open_track_fd();
578
+ }
579
+ else if (!strncmp(fname, "http://", 7)) /* http stream */
580
+ {
581
+ #if defined (WANT_WIN32_SOCKETS)
582
+ if(param.streamdump != NULL)
583
+ {
584
+ fprintf(stderr, "\nWarning: win32 networking conflicts with stream dumping. Aborting the dump.\n");
585
+ dump_close();
586
+ }
587
+ /*Use recv instead of stdio functions */
588
+ win32_net_replace(mh);
589
+ filept = win32_net_http_open(fname, &htd);
590
+ #else
591
+ filept = http_open(fname, &htd);
592
+ #endif
593
+ network_sockets_used = 1;
594
+ /* utf-8 encoded URLs might not work under Win32 */
595
+
596
+ /* now check if we got sth. and if we got sth. good */
597
+ if( (filept >= 0) && (htd.content_type.p != NULL)
598
+ && !APPFLAG(MPG123APP_IGNORE_MIME) && !(debunk_mime(htd.content_type.p) & IS_FILE) )
599
+ {
600
+ error1("Unknown mpeg MIME type %s - is it perhaps a playlist (use -@)?", htd.content_type.p == NULL ? "<nil>" : htd.content_type.p);
601
+ error("If you know the stream is mpeg1/2 audio, then please report this as "PACKAGE_NAME" bug");
602
+ return 0;
603
+ }
604
+ if(filept < 0)
605
+ {
606
+ error1("Access to http resource %s failed.", fname);
607
+ return 0;
608
+ }
609
+ if(MPG123_OK != mpg123_param(mh, MPG123_ICY_INTERVAL, htd.icy_interval, 0))
610
+ error1("Cannot set ICY interval: %s", mpg123_strerror(mh));
611
+ if(param.verbose > 1) fprintf(stderr, "Info: ICY interval %li\n", (long)htd.icy_interval);
612
+ }
613
+
614
+ if(param.icy_interval > 0)
615
+ {
616
+ if(MPG123_OK != mpg123_param(mh, MPG123_ICY_INTERVAL, param.icy_interval, 0))
617
+ error1("Cannot set ICY interval: %s", mpg123_strerror(mh));
618
+ if(param.verbose > 1) fprintf(stderr, "Info: Forced ICY interval %li\n", param.icy_interval);
619
+ }
620
+
621
+ debug("OK... going to finally open.");
622
+ /* Now hook up the decoder on the opened stream or the file. */
623
+ if(network_sockets_used)
624
+ {
625
+ return open_track_fd();
626
+ }
627
+ else if(mpg123_open(mh, fname) != MPG123_OK)
628
+ {
629
+ error2("Cannot open %s: %s", fname, mpg123_strerror(mh));
630
+ return 0;
631
+ }
632
+ debug("Track successfully opened.");
633
+
634
+ fresh = TRUE;
635
+ return 1;
636
+ }
637
+
638
+ /* for symmetry */
639
+ void close_track(void)
640
+ {
641
+ mpg123_close(mh);
642
+ #if defined (WANT_WIN32_SOCKETS)
643
+ if (network_sockets_used)
644
+ win32_net_close(filept);
645
+ filept = -1;
646
+ return;
647
+ #endif
648
+ network_sockets_used = 0;
649
+ if(filept > -1) close(filept);
650
+ filept = -1;
651
+ }
652
+
653
+ /* return 1 on success, 0 on failure */
654
+ int play_frame(void)
655
+ {
656
+ unsigned char *audio;
657
+ int mc;
658
+ size_t bytes;
659
+ debug("play_frame");
660
+ /* The first call will not decode anything but return MPG123_NEW_FORMAT! */
661
+ mc = mpg123_decode_frame(mh, &framenum, &audio, &bytes);
662
+ /* Play what is there to play (starting with second decode_frame call!) */
663
+ if(bytes)
664
+ {
665
+ if(param.frame_number > -1) --frames_left;
666
+ if(fresh && framenum >= param.start_frame)
667
+ {
668
+ fresh = FALSE;
669
+ }
670
+ /* Normal flushing of data, includes buffer decoding. */
671
+ if(flush_output(ao, audio, bytes) < (int)bytes && !intflag)
672
+ {
673
+ error("Deep trouble! Cannot flush to my output anymore!");
674
+ safe_exit(133);
675
+ }
676
+ if(param.checkrange)
677
+ {
678
+ long clip = mpg123_clip(mh);
679
+ if(clip > 0) fprintf(stderr,"%ld samples clipped\n", clip);
680
+ }
681
+ }
682
+ /* Special actions and errors. */
683
+ if(mc != MPG123_OK)
684
+ {
685
+ if(mc == MPG123_ERR || mc == MPG123_DONE)
686
+ {
687
+ if(mc == MPG123_ERR) error1("...in decoding next frame: %s", mpg123_strerror(mh));
688
+ return 0;
689
+ }
690
+ if(mc == MPG123_NO_SPACE)
691
+ {
692
+ error("I have not enough output space? I didn't plan for this.");
693
+ return 0;
694
+ }
695
+ if(mc == MPG123_NEW_FORMAT)
696
+ {
697
+ long rate;
698
+ int channels, format;
699
+ mpg123_getformat(mh, &rate, &channels, &format);
700
+ if(param.verbose > 2) fprintf(stderr, "\nNote: New output format %liHz %ich, format %i\n", rate, channels, format);
701
+
702
+ if(!param.quiet)
703
+ {
704
+ fprintf(stderr, "\n");
705
+ if(param.verbose) print_header(mh);
706
+ else print_header_compact(mh);
707
+ }
708
+ reset_audio(rate, channels, format);
709
+ }
710
+ }
711
+ return 1;
712
+ }
713
+
714
+ void buffer_drain(void)
715
+ {
716
+ #ifndef NOXFERMEM
717
+ int s;
718
+ while ((s = xfermem_get_usedspace(buffermem)))
719
+ {
720
+ struct timeval wait170 = {0, 170000};
721
+ if(intflag) break;
722
+ buffer_ignore_lowmem();
723
+ if(param.verbose) print_stat(mh,0,s);
724
+ #ifdef HAVE_TERMIOS
725
+ if(param.term_ctrl) term_control(mh, ao);
726
+ #endif
727
+ select(0, NULL, NULL, NULL, &wait170);
728
+ }
729
+ #endif
730
+ }
731
+
732
+ /* Return TRUE if we should continue (second interrupt happens quickly), skipping tracks, or FALSE if we should die. */
733
+ #if !defined(WIN32) && !defined(GENERIC)
734
+ int skip_or_die(struct timeval *start_time)
735
+ {
736
+ /*
737
+ * When HAVE_TERMIOS is defined, there is 'q' to terminate a list of songs, so
738
+ * no pressing need to keep up this first second SIGINT hack that was too
739
+ * often mistaken as a bug. [dk]
740
+ * ThOr: Yep, I deactivated the Ctrl+C hack for active control modes.
741
+ * Though, some sort of hack remains, still using intflag for track skip.
742
+ */
743
+ #ifdef HAVE_TERMIOS
744
+ if(!param.term_ctrl)
745
+ #endif
746
+ {
747
+ struct timeval now;
748
+ unsigned long secdiff;
749
+ gettimeofday (&now, NULL);
750
+ secdiff = (now.tv_sec - start_time->tv_sec) * 1000;
751
+ if(now.tv_usec >= start_time->tv_usec)
752
+ secdiff += (now.tv_usec - start_time->tv_usec) / 1000;
753
+ else
754
+ secdiff -= (start_time->tv_usec - now.tv_usec) / 1000;
755
+ if (secdiff < 1000)
756
+ {
757
+ debug("got the second interrupt: out of here!");
758
+ return FALSE;
759
+ }
760
+ else
761
+ {
762
+ debug("It's a track advancement message.");
763
+ ++skip_tracks;
764
+ }
765
+ }
766
+ #ifdef HAVE_TERMIOS
767
+ else if(skip_tracks == 0)
768
+ {
769
+ debug("breaking up");
770
+ return FALSE;
771
+ }
772
+ #endif
773
+ return TRUE; /* Track advancement... no instant kill on generic/windows... */
774
+ }
775
+ #else
776
+ /* On generic systems and win32, there is no decision here... just TRUE. */
777
+ #define skip_or_die(a) TRUE
778
+ #endif
779
+
780
+ int main(int sys_argc, char ** sys_argv)
781
+ {
782
+ int result;
783
+ long parr;
784
+ char *fname;
785
+ int libpar = 0;
786
+ mpg123_pars *mp;
787
+ #if !defined(WIN32) && !defined(GENERIC)
788
+ struct timeval start_time;
789
+ #endif
790
+
791
+ #if defined (WANT_WIN32_UNICODE)
792
+ if(win32_cmdline_utf8(&argc, &argv) != 0)
793
+ {
794
+ error("Cannot convert command line to UTF8!");
795
+ safe_exit(76);
796
+ }
797
+ #else
798
+ argv = sys_argv;
799
+ argc = sys_argc;
800
+ #endif
801
+ #if defined (WANT_WIN32_SOCKETS)
802
+ win32_net_init();
803
+ #endif
804
+
805
+ /* Extract binary and path, take stuff before/after last / or \ . */
806
+ if((prgName = strrchr(argv[0], '/')) || (prgName = strrchr(argv[0], '\\')))
807
+ {
808
+ /* There is some explicit path. */
809
+ prgName[0] = 0; /* End byte for path. */
810
+ prgName++;
811
+ binpath = argv[0];
812
+ }
813
+ else
814
+ {
815
+ prgName = argv[0]; /* No path separators there. */
816
+ binpath = NULL; /* No path at all. */
817
+ }
818
+
819
+ /* Need to initialize mpg123 lib here for default parameter values. */
820
+
821
+ result = mpg123_init();
822
+ if(result != MPG123_OK)
823
+ {
824
+ error1("Cannot initialize mpg123 library: %s", mpg123_plain_strerror(result));
825
+ safe_exit(77);
826
+ }
827
+ cleanup_mpg123 = TRUE;
828
+
829
+ mp = mpg123_new_pars(&result); /* This may get leaked on premature exit(), which is mainly a cosmetic issue... */
830
+ if(mp == NULL)
831
+ {
832
+ error1("Crap! Cannot get mpg123 parameters: %s", mpg123_plain_strerror(result));
833
+ safe_exit(78);
834
+ }
835
+
836
+ /* get default values */
837
+ mpg123_getpar(mp, MPG123_DOWN_SAMPLE, &parr, NULL);
838
+ param.down_sample = (int) parr;
839
+ mpg123_getpar(mp, MPG123_RVA, &param.rva, NULL);
840
+ mpg123_getpar(mp, MPG123_DOWNSPEED, &param.halfspeed, NULL);
841
+ mpg123_getpar(mp, MPG123_UPSPEED, &param.doublespeed, NULL);
842
+ mpg123_getpar(mp, MPG123_OUTSCALE, &param.outscale, NULL);
843
+ mpg123_getpar(mp, MPG123_FLAGS, &parr, NULL);
844
+ mpg123_getpar(mp, MPG123_INDEX_SIZE, &param.index_size, NULL);
845
+ param.flags = (int) parr;
846
+ param.flags |= MPG123_SEEKBUFFER; /* Default on, for HTTP streams. */
847
+ mpg123_getpar(mp, MPG123_RESYNC_LIMIT, &param.resync_limit, NULL);
848
+ mpg123_getpar(mp, MPG123_PREFRAMES, &param.preframes, NULL);
849
+
850
+ #ifdef OS2
851
+ _wildcard(&argc,&argv);
852
+ #endif
853
+
854
+ while ((result = getlopt(argc, argv, opts)))
855
+ switch (result) {
856
+ case GLO_UNKNOWN:
857
+ fprintf (stderr, "%s: Unknown option \"%s\".\n",
858
+ prgName, loptarg);
859
+ usage(1);
860
+ case GLO_NOARG:
861
+ fprintf (stderr, "%s: Missing argument for option \"%s\".\n",
862
+ prgName, loptarg);
863
+ usage(1);
864
+ }
865
+ /* Do this _after_ parameter parsing. */
866
+ check_locale(); /* Check/set locale; store if it uses UTF-8. */
867
+
868
+ if(param.list_cpu)
869
+ {
870
+ const char **all_dec = mpg123_decoders();
871
+ printf("Builtin decoders:");
872
+ while(*all_dec != NULL){ printf(" %s", *all_dec); ++all_dec; }
873
+ printf("\n");
874
+ mpg123_delete_pars(mp);
875
+ return 0;
876
+ }
877
+ if(param.test_cpu)
878
+ {
879
+ const char **all_dec = mpg123_supported_decoders();
880
+ printf("Supported decoders:");
881
+ while(*all_dec != NULL){ printf(" %s", *all_dec); ++all_dec; }
882
+ printf("\n");
883
+ mpg123_delete_pars(mp);
884
+ return 0;
885
+ }
886
+ if(param.gain != -1)
887
+ {
888
+ warning("The parameter -g is deprecated and may be removed in the future.");
889
+ }
890
+
891
+ if (loptind >= argc && !param.listname && !param.remote) usage(1);
892
+ /* Init audio as early as possible.
893
+ If there is the buffer process to be spawned, it shouldn't carry the mpg123_handle with it. */
894
+ bufferblock = mpg123_safe_buffer(); /* Can call that before mpg123_init(), it's stateless. */
895
+ if(init_output(&ao) < 0)
896
+ {
897
+ error("Failed to initialize output, goodbye.");
898
+ mpg123_delete_pars(mp);
899
+ return 99; /* It's safe here... nothing nasty happened yet. */
900
+ }
901
+ have_output = TRUE;
902
+
903
+ /* ========================================================================================================= */
904
+ /* Enterning the leaking zone... we start messing with stuff here that should be taken care of when leaving. */
905
+ /* Don't just exit() or return out... */
906
+ /* ========================================================================================================= */
907
+
908
+ httpdata_init(&htd);
909
+
910
+ #if !defined(WIN32) && !defined(GENERIC)
911
+ if (param.remote)
912
+ {
913
+ param.verbose = 0;
914
+ param.quiet = 1;
915
+ param.flags |= MPG123_QUIET;
916
+ }
917
+ #endif
918
+
919
+ /* Set the frame parameters from command line options */
920
+ if(param.quiet) param.flags |= MPG123_QUIET;
921
+
922
+ #ifdef OPT_3DNOW
923
+ if(dnow != 0) param.cpu = (dnow == SET_3DNOW) ? "3dnow" : "i586";
924
+ #endif
925
+ if(param.cpu != NULL && (!strcmp(param.cpu, "auto") || !strcmp(param.cpu, ""))) param.cpu = NULL;
926
+ if(!( MPG123_OK == (result = mpg123_par(mp, MPG123_VERBOSE, param.verbose, 0))
927
+ && ++libpar
928
+ && MPG123_OK == (result = mpg123_par(mp, MPG123_FLAGS, param.flags, 0))
929
+ && ++libpar
930
+ && MPG123_OK == (result = mpg123_par(mp, MPG123_DOWN_SAMPLE, param.down_sample, 0))
931
+ && ++libpar
932
+ && MPG123_OK == (result = mpg123_par(mp, MPG123_RVA, param.rva, 0))
933
+ && ++libpar
934
+ && MPG123_OK == (result = mpg123_par(mp, MPG123_FORCE_RATE, param.force_rate, 0))
935
+ && ++libpar
936
+ && MPG123_OK == (result = mpg123_par(mp, MPG123_DOWNSPEED, param.halfspeed, 0))
937
+ && ++libpar
938
+ && MPG123_OK == (result = mpg123_par(mp, MPG123_UPSPEED, param.doublespeed, 0))
939
+ && ++libpar
940
+ && MPG123_OK == (result = mpg123_par(mp, MPG123_ICY_INTERVAL, 0, 0))
941
+ && ++libpar
942
+ && MPG123_OK == (result = mpg123_par(mp, MPG123_RESYNC_LIMIT, param.resync_limit, 0))
943
+ && ++libpar
944
+ && MPG123_OK == (result = mpg123_par(mp, MPG123_TIMEOUT, param.timeout, 0))
945
+ && ++libpar
946
+ && MPG123_OK == (result = mpg123_par(mp, MPG123_OUTSCALE, param.outscale, 0))
947
+ && ++libpar
948
+ && MPG123_OK == (result = mpg123_par(mp, MPG123_PREFRAMES, param.preframes, 0))
949
+ ))
950
+ {
951
+ error2("Cannot set library parameter %i: %s", libpar, mpg123_plain_strerror(result));
952
+ safe_exit(45);
953
+ }
954
+ if (!(param.listentry < 0) && !param.quiet) print_title(stderr); /* do not pollute stdout! */
955
+
956
+ {
957
+ long default_index;
958
+ mpg123_getpar(mp, MPG123_INDEX_SIZE, &default_index, NULL);
959
+ if( param.index_size != default_index && (result = mpg123_par(mp, MPG123_INDEX_SIZE, param.index_size, 0.)) != MPG123_OK )
960
+ error1("Setting of frame index size failed: %s", mpg123_plain_strerror(result));
961
+ }
962
+
963
+ if(param.force_rate && param.down_sample)
964
+ {
965
+ error("Down sampling and fixed rate options not allowed together!");
966
+ safe_exit(1);
967
+ }
968
+
969
+ /* Now actually get an mpg123_handle. */
970
+ mh = mpg123_parnew(mp, param.cpu, &result);
971
+ if(mh == NULL)
972
+ {
973
+ error1("Crap! Cannot get a mpg123 handle: %s", mpg123_plain_strerror(result));
974
+ safe_exit(77);
975
+ }
976
+ mpg123_delete_pars(mp); /* Don't need the parameters anymore ,they're in the handle now. */
977
+
978
+ /* Prepare stream dumping, possibly replacing mpg123 reader. */
979
+ if(dump_open(mh) != 0) safe_exit(78);
980
+
981
+ /* Now either check caps myself or query buffer for that. */
982
+ audio_capabilities(ao, mh);
983
+
984
+ load_equalizer(mh);
985
+
986
+ #ifdef HAVE_SETPRIORITY
987
+ if(param.aggressive) { /* tst */
988
+ int mypid = getpid();
989
+ setpriority(PRIO_PROCESS,mypid,-20);
990
+ }
991
+ #endif
992
+
993
+ #if defined (HAVE_SCHED_SETSCHEDULER) && !defined (__CYGWIN__) && !defined (HAVE_WINDOWS_H)
994
+ /* Cygwin --realtime seems to fail when accessing network, using win32 set priority instead */
995
+ /* MinGW may have pthread installed, we prefer win32API */
996
+ if (param.realtime) { /* Get real-time priority */
997
+ struct sched_param sp;
998
+ fprintf(stderr,"Getting real-time priority\n");
999
+ memset(&sp, 0, sizeof(struct sched_param));
1000
+ sp.sched_priority = sched_get_priority_min(SCHED_FIFO);
1001
+ if (sched_setscheduler(0, SCHED_RR, &sp) == -1)
1002
+ fprintf(stderr,"Can't get real-time priority\n");
1003
+ }
1004
+ #endif
1005
+
1006
+ #ifdef HAVE_WINDOWS_H
1007
+ /* argument "3" is equivalent to realtime priority class */
1008
+ win32_set_priority( param.realtime ? 3 : param.w32_priority);
1009
+ #endif
1010
+
1011
+ if(!param.remote) prepare_playlist(argc, argv);
1012
+
1013
+ #if !defined(WIN32) && !defined(GENERIC)
1014
+ /* Remote mode is special... but normal console and terminal-controlled operation needs to catch the SIGINT.
1015
+ For one it serves for track skip when not in terminal control mode.
1016
+ The more important use being a graceful exit, including telling the buffer process what's going on. */
1017
+ if(!param.remote) catchsignal (SIGINT, catch_interrupt);
1018
+ #endif
1019
+
1020
+ if(param.remote) {
1021
+ int ret;
1022
+ ret = control_generic(mh);
1023
+ safe_exit(ret);
1024
+ }
1025
+ #ifdef HAVE_TERMIOS
1026
+ debug1("param.term_ctrl: %i", param.term_ctrl);
1027
+ if(param.term_ctrl)
1028
+ term_init();
1029
+ #endif
1030
+ while ((fname = get_next_file()))
1031
+ {
1032
+ char *dirname, *filename;
1033
+ /* skip_tracks includes the previous one. */
1034
+ if(skip_tracks) --skip_tracks;
1035
+ if(skip_tracks)
1036
+ {
1037
+ debug("Skipping this track.");
1038
+ continue;
1039
+ }
1040
+ if(param.delay > 0)
1041
+ {
1042
+ /* One should enable terminal control during that sleeping phase! */
1043
+ if(param.verbose > 2) fprintf(stderr, "Note: pausing %i seconds before next track.\n", param.delay);
1044
+ output_pause(ao);
1045
+ #ifdef WIN32
1046
+ Sleep(param.delay*1000);
1047
+ #else
1048
+ sleep(param.delay);
1049
+ #endif
1050
+ output_unpause(ao);
1051
+ }
1052
+ frames_left = param.frame_number;
1053
+ debug1("Going to play %s", strcmp(fname, "-") ? fname : "standard input");
1054
+
1055
+ if(intflag || !open_track(fname))
1056
+ {
1057
+ #ifdef HAVE_TERMIOS
1058
+ /* We need the opportunity to cancel in case of --loop -1 . */
1059
+ if(param.term_ctrl) term_control(mh, ao);
1060
+ #endif
1061
+ /* No wait for a second interrupt before we started playing. */
1062
+ if(intflag) break;
1063
+
1064
+ continue;
1065
+ }
1066
+
1067
+ if(!param.quiet) fprintf(stderr, "\n");
1068
+ if(param.index)
1069
+ {
1070
+ if(param.verbose) fprintf(stderr, "indexing...\r");
1071
+ mpg123_scan(mh);
1072
+ }
1073
+ /*
1074
+ Only trigger a seek if we do not want to start with the first frame.
1075
+ Rationale: Because of libmpg123 sample accuracy, this could cause an unnecessary backwards seek, that even may fail on non-seekable streams.
1076
+ For start frame of 0, we are already at the correct position!
1077
+ */
1078
+ framenum = 0;
1079
+ if(param.start_frame > 0)
1080
+ framenum = mpg123_seek_frame(mh, param.start_frame, SEEK_SET);
1081
+
1082
+ if(framenum < 0)
1083
+ {
1084
+ error1("Initial seek failed: %s", mpg123_strerror(mh));
1085
+ if(mpg123_errcode(mh) == MPG123_BAD_OUTFORMAT)
1086
+ {
1087
+ fprintf(stderr, "%s", "So, you have trouble getting an output format... this is the matrix of currently possible formats:\n");
1088
+ print_capabilities(ao, mh);
1089
+ fprintf(stderr, "%s", "Somehow the input data and your choices don't allow one of these.\n");
1090
+ }
1091
+ mpg123_close(mh);
1092
+ continue;
1093
+ }
1094
+
1095
+ if (!param.quiet)
1096
+ {
1097
+ if (split_dir_file(fname ? fname : "standard input",
1098
+ &dirname, &filename))
1099
+ fprintf(stderr, "Directory: %s\n", dirname);
1100
+
1101
+ #ifdef HAVE_TERMIOS
1102
+ /* Reminder about terminal usage. */
1103
+ if(param.term_ctrl) term_hint();
1104
+ #endif
1105
+
1106
+
1107
+ fprintf(stderr, "Playing MPEG stream %lu of %lu: %s ...\n", (unsigned long)pl.pos, (unsigned long)pl.fill, filename);
1108
+ if(htd.icy_name.fill) fprintf(stderr, "ICY-NAME: %s\n", htd.icy_name.p);
1109
+ if(htd.icy_url.fill) fprintf(stderr, "ICY-URL: %s\n", htd.icy_url.p);
1110
+
1111
+ #if !defined(GENERIC)
1112
+ {
1113
+ const char *term_type;
1114
+ term_type = getenv("TERM");
1115
+ if (term_type && param.xterm_title &&
1116
+ (!strncmp(term_type,"xterm",5) || !strncmp(term_type,"rxvt",4)))
1117
+ {
1118
+ fprintf(stderr, "\033]0;%s\007", filename);
1119
+ }
1120
+ }
1121
+ #endif
1122
+
1123
+ }
1124
+ /* Rethink that SIGINT logic... */
1125
+ #if !defined(WIN32) && !defined(GENERIC)
1126
+ #ifdef HAVE_TERMIOS
1127
+ if(!param.term_ctrl)
1128
+ #endif
1129
+ gettimeofday (&start_time, NULL);
1130
+ #endif
1131
+
1132
+ while(!intflag)
1133
+ {
1134
+ int meta;
1135
+ if(param.frame_number > -1)
1136
+ {
1137
+ debug1("frames left: %li", (long) frames_left);
1138
+ if(!frames_left) break;
1139
+ }
1140
+ if(!play_frame()) break;
1141
+ if(!param.quiet)
1142
+ {
1143
+ meta = mpg123_meta_check(mh);
1144
+ if(meta & (MPG123_NEW_ID3|MPG123_NEW_ICY))
1145
+ {
1146
+ if(meta & MPG123_NEW_ID3) print_id3_tag(mh, param.long_id3, stderr);
1147
+ if(meta & MPG123_NEW_ICY) print_icy(mh, stderr);
1148
+
1149
+ mpg123_meta_free(mh); /* Do not waste memory after delivering. */
1150
+ }
1151
+ }
1152
+ if(!fresh && param.verbose)
1153
+ {
1154
+ #ifndef NOXFERMEM
1155
+ if (param.verbose > 1 || !(framenum & 0x7))
1156
+ print_stat(mh,0,xfermem_get_usedspace(buffermem));
1157
+ #else
1158
+ if(param.verbose > 1 || !(framenum & 0x7)) print_stat(mh,0,0);
1159
+ #endif
1160
+ }
1161
+ #ifdef HAVE_TERMIOS
1162
+ if(!param.term_ctrl) continue;
1163
+ else term_control(mh, ao);
1164
+ #endif
1165
+ }
1166
+
1167
+ if(!param.smooth && param.usebuffer) buffer_drain();
1168
+ if(param.verbose) print_stat(mh,0,xfermem_get_usedspace(buffermem));
1169
+
1170
+ if(!param.quiet)
1171
+ {
1172
+ double secs;
1173
+ long frank;
1174
+ fprintf(stderr, "\n");
1175
+ if(mpg123_getstate(mh, MPG123_FRANKENSTEIN, &frank, NULL) == MPG123_OK && frank)
1176
+ fprintf(stderr, "This was a Frankenstein track.\n");
1177
+
1178
+ mpg123_position(mh, 0, 0, NULL, NULL, &secs, NULL);
1179
+ fprintf(stderr,"[%d:%02d] Decoding of %s finished.\n", (int)(secs / 60), ((int)secs) % 60, filename);
1180
+ }
1181
+ else if(param.verbose) fprintf(stderr, "\n");
1182
+
1183
+ mpg123_close(mh);
1184
+
1185
+ if (intflag)
1186
+ {
1187
+ if(!skip_or_die(&start_time)) break;
1188
+
1189
+ intflag = FALSE;
1190
+
1191
+ #ifndef NOXFERMEM
1192
+ if(!param.smooth && param.usebuffer) buffer_resync();
1193
+ #endif
1194
+ }
1195
+ } /* end of loop over input files */
1196
+ /* Ensure we played everything. */
1197
+ if(param.smooth && param.usebuffer)
1198
+ {
1199
+ buffer_drain();
1200
+ buffer_resync();
1201
+ }
1202
+ /* Free up memory used by playlist */
1203
+ if(!param.remote) free_playlist();
1204
+
1205
+ safe_exit(0); /* That closes output and restores terminal, too. */
1206
+ return 0;
1207
+ }
1208
+
1209
+ static void print_title(FILE *o)
1210
+ {
1211
+ fprintf(o, "High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3\n");
1212
+ fprintf(o, "\tversion %s; written and copyright by Michael Hipp and others\n", PACKAGE_VERSION);
1213
+ fprintf(o, "\tfree software (LGPL/GPL) without any warranty but with best wishes\n");
1214
+ }
1215
+
1216
+ static void usage(int err) /* print syntax & exit */
1217
+ {
1218
+ FILE* o = stdout;
1219
+ if(err)
1220
+ {
1221
+ o = stderr;
1222
+ fprintf(o, "You made some mistake in program usage... let me briefly remind you:\n\n");
1223
+ }
1224
+ print_title(o);
1225
+ fprintf(o,"\nusage: %s [option(s)] [file(s) | URL(s) | -]\n", prgName);
1226
+ fprintf(o,"supported options [defaults in brackets]:\n");
1227
+ fprintf(o," -v increase verbosity level -q quiet (don't print title)\n");
1228
+ fprintf(o," -t testmode (no output) -s write to stdout\n");
1229
+ fprintf(o," -w <filename> write Output as WAV file\n");
1230
+ fprintf(o," -k n skip first n frames [0] -n n decode only n frames [all]\n");
1231
+ fprintf(o," -c check range violations -y DISABLE resync on errors\n");
1232
+ fprintf(o," -b n output buffer: n Kbytes [0] -f n change scalefactor [%li]\n", param.outscale);
1233
+ fprintf(o," -r n set/force samplerate [auto]\n");
1234
+ fprintf(o," -os,-ol,-oh output to built-in speaker,line-out connector,headphones\n");
1235
+ #ifdef NAS
1236
+ fprintf(o," -a d set NAS server\n");
1237
+ #elif defined(SGI)
1238
+ fprintf(o," -a [1..4] set RAD device\n");
1239
+ #else
1240
+ fprintf(o," -a d set audio device\n");
1241
+ #endif
1242
+ fprintf(o," -2 downsample 1:2 (22 kHz) -4 downsample 1:4 (11 kHz)\n");
1243
+ fprintf(o," -d n play every n'th frame only -h n play every frame n times\n");
1244
+ fprintf(o," -0 decode channel 0 (left) only -1 decode channel 1 (right) only\n");
1245
+ fprintf(o," -m mix both channels (mono) -p p use HTTP proxy p [$HTTP_PROXY]\n");
1246
+ #ifdef HAVE_SCHED_SETSCHEDULER
1247
+ fprintf(o," -@ f read filenames/URLs from f -T get realtime priority\n");
1248
+ #else
1249
+ fprintf(o," -@ f read filenames/URLs from f\n");
1250
+ #endif
1251
+ fprintf(o," -z shuffle play (with wildcards) -Z random play\n");
1252
+ fprintf(o," -u a HTTP authentication string -E f Equalizer, data from file\n");
1253
+ fprintf(o," -C enable control keys --no-gapless not skip junk/padding in mp3s\n");
1254
+ fprintf(o," -? this help --version print name + version\n");
1255
+ fprintf(o,"See the manpage %s(1) or call %s with --longhelp for more parameters and information.\n", prgName,prgName);
1256
+ safe_exit(err);
1257
+ }
1258
+
1259
+ static void want_usage(char* arg)
1260
+ {
1261
+ usage(0);
1262
+ }
1263
+
1264
+ static void long_usage(int err)
1265
+ {
1266
+ char *enclist;
1267
+ FILE* o = stdout;
1268
+ if(err)
1269
+ {
1270
+ o = stderr;
1271
+ fprintf(o, "You made some mistake in program usage... let me remind you:\n\n");
1272
+ }
1273
+ print_title(o);
1274
+ fprintf(o,"\nusage: %s [option(s)] [file(s) | URL(s) | -]\n", prgName);
1275
+
1276
+ fprintf(o,"\ninput options\n\n");
1277
+ fprintf(o," -k <n> --skip <n> skip n frames at beginning\n");
1278
+ fprintf(o," --skip-id3v2 skip ID3v2 tags without parsing\n");
1279
+ fprintf(o," -n --frames <n> play only <n> frames of every stream\n");
1280
+ fprintf(o," --fuzzy Enable fuzzy seeks (guessing byte offsets or using approximate seek points from Xing TOC)\n");
1281
+ fprintf(o," -y --no-resync DISABLES resync on error (--resync is deprecated)\n");
1282
+ fprintf(o," -p <f> --proxy <f> set WWW proxy\n");
1283
+ fprintf(o," -u --auth set auth values for HTTP access\n");
1284
+ fprintf(o," --ignore-mime ignore HTTP MIME types (content-type)\n");
1285
+ fprintf(o," -@ <f> --list <f> play songs in playlist <f> (plain list, m3u, pls (shoutcast))\n");
1286
+ fprintf(o," -l <n> --listentry <n> play nth title in playlist; show whole playlist for n < 0\n");
1287
+ fprintf(o," --loop <n> loop track(s) <n> times, < 0 means infinite loop (not with --random!)\n");
1288
+ fprintf(o," --keep-open (--remote mode only) keep loaded file open after reaching end\n");
1289
+ fprintf(o," --timeout <n> Timeout in seconds before declaring a stream dead (if <= 0, wait forever)\n");
1290
+ fprintf(o," -z --shuffle shuffle song-list before playing\n");
1291
+ fprintf(o," -Z --random full random play\n");
1292
+ fprintf(o," --no-icy-meta Do not accept ICY meta data\n");
1293
+ fprintf(o," -i --index index / scan through the track before playback\n");
1294
+ fprintf(o," --index-size <n> change size of frame index\n");
1295
+ fprintf(o," --preframes <n> number of frames to decode in advance after seeking (to keep layer 3 bit reservoir happy)\n");
1296
+ fprintf(o," --resync-limit <n> Set number of bytes to search for valid MPEG data; <0 means search whole stream.\n");
1297
+ fprintf(o," --streamdump <f> Dump a copy of input data (as read by libmpg123) to given file.\n");
1298
+ fprintf(o," --icy-interval <n> Enforce ICY interval in bytes (for playing a stream dump.\n");
1299
+ fprintf(o," --ignore-streamlength Ignore header info about length of MPEG streams.");
1300
+ fprintf(o,"\noutput/processing options\n\n");
1301
+ fprintf(o," -o <o> --output <o> select audio output module\n");
1302
+ fprintf(o," --list-modules list the available modules\n");
1303
+ fprintf(o," -a <d> --audiodevice <d> select audio device\n");
1304
+ fprintf(o," -s --stdout write raw audio to stdout (host native format)\n");
1305
+ fprintf(o," -S --STDOUT play AND output stream (not implemented yet)\n");
1306
+ fprintf(o," -w <f> --wav <f> write samples as WAV file in <f> (- is stdout)\n");
1307
+ fprintf(o," --au <f> write samples as Sun AU file in <f> (- is stdout)\n");
1308
+ fprintf(o," --cdr <f> write samples as raw CD audio file in <f> (- is stdout)\n");
1309
+ fprintf(o," --reopen force close/open on audiodevice\n");
1310
+ #ifdef OPT_MULTI
1311
+ fprintf(o," --cpu <string> set cpu optimization\n");
1312
+ fprintf(o," --test-cpu list optimizations possible with cpu and exit\n");
1313
+ fprintf(o," --list-cpu list builtin optimizations and exit\n");
1314
+ #endif
1315
+ #ifdef OPT_3DNOW
1316
+ fprintf(o," --test-3dnow display result of 3DNow! autodetect and exit (obsoleted by --cpu)\n");
1317
+ fprintf(o," --force-3dnow force use of 3DNow! optimized routine (obsoleted by --test-cpu)\n");
1318
+ fprintf(o," --no-3dnow force use of floating-pointer routine (obsoleted by --cpu)\n");
1319
+ #endif
1320
+ fprintf(o," -g --gain [DEPRECATED] set audio hardware output gain\n");
1321
+ fprintf(o," -f <n> --scale <n> scale output samples (soft gain - based on 32768), default=%li)\n", param.outscale);
1322
+ fprintf(o," --rva-mix,\n");
1323
+ fprintf(o," --rva-radio use RVA2/ReplayGain values for mix/radio mode\n");
1324
+ fprintf(o," --rva-album,\n");
1325
+ fprintf(o," --rva-audiophile use RVA2/ReplayGain values for album/audiophile mode\n");
1326
+ fprintf(o," -0 --left --single0 play only left channel\n");
1327
+ fprintf(o," -1 --right --single1 play only right channel\n");
1328
+ fprintf(o," -m --mono --mix mix stereo to mono\n");
1329
+ fprintf(o," --stereo duplicate mono channel\n");
1330
+ fprintf(o," -r --rate force a specific audio output rate\n");
1331
+ fprintf(o," -2 --2to1 2:1 downsampling\n");
1332
+ fprintf(o," -4 --4to1 4:1 downsampling\n");
1333
+ fprintf(o," --pitch <value> set hardware pitch (speedup/down, 0 is neutral; 0.05 is 5%%)\n");
1334
+ fprintf(o," --8bit force 8 bit output\n");
1335
+ fprintf(o," --float force floating point output (internal precision)\n");
1336
+ audio_enclist(&enclist);
1337
+ fprintf(o," -e <c> --encoding <c> force a specific encoding (%s)\n", enclist != NULL ? enclist : "OOM!");
1338
+ fprintf(o," -d n --doublespeed n play only every nth frame\n");
1339
+ fprintf(o," -h n --halfspeed n play every frame n times\n");
1340
+ fprintf(o," --equalizer exp.: scales freq. bands acrd. to 'equalizer.dat'\n");
1341
+ fprintf(o," --gapless remove padding/junk on mp3s (best with Lame tag)\n");
1342
+ fprintf(o," This is on by default when libmpg123 supports it.\n");
1343
+ fprintf(o," --no-gapless disable gapless mode, not remove padding/junk\n");
1344
+ fprintf(o," -D n --delay n insert a delay of n seconds before each track\n");
1345
+ fprintf(o," -o h --headphones (aix/hp/sun) output on headphones\n");
1346
+ fprintf(o," -o s --speaker (aix/hp/sun) output on speaker\n");
1347
+ fprintf(o," -o l --lineout (aix/hp/sun) output to lineout\n");
1348
+ #ifndef NOXFERMEM
1349
+ fprintf(o," -b <n> --buffer <n> set play buffer (\"output cache\")\n");
1350
+ fprintf(o," --preload <value> fraction of buffer to fill before playback\n");
1351
+ fprintf(o," --smooth keep buffer over track boundaries\n");
1352
+ #endif
1353
+
1354
+ fprintf(o,"\nmisc options\n\n");
1355
+ fprintf(o," -t --test only decode, no output (benchmark)\n");
1356
+ fprintf(o," -c --check count and display clipped samples\n");
1357
+ fprintf(o," -v[*] --verbose increase verboselevel\n");
1358
+ fprintf(o," -q --quiet quiet mode\n");
1359
+ #ifdef HAVE_TERMIOS
1360
+ fprintf(o," -C --control enable terminal control keys\n");
1361
+ fprintf(o," --ctrlusr1 <c> control key (characer) to map to SIGUSR1\n");
1362
+ fprintf(o," (default is for stop/start)\n");
1363
+ fprintf(o," --ctrlusr2 <c> control key (characer) to map to SIGUSR2\n");
1364
+ fprintf(o," (default is for next track)\n");
1365
+ #endif
1366
+ #ifndef GENERIC
1367
+ fprintf(o," --title set xterm/rxvt title to filename\n");
1368
+ #endif
1369
+ fprintf(o," --long-tag spacy id3 display with every item on a separate line\n");
1370
+ fprintf(o," --lyrics show lyrics (from ID3v2 USLT frame)\n");
1371
+ fprintf(o," --utf8 Regardless of environment, print metadata in UTF-8.\n");
1372
+ fprintf(o," -R --remote generic remote interface\n");
1373
+ fprintf(o," --remote-err force use of stderr for generic remote interface\n");
1374
+ #ifdef FIFO
1375
+ fprintf(o," --fifo <path> open a FIFO at <path> for commands instead of stdin\n");
1376
+ #endif
1377
+ #ifdef HAVE_SETPRIORITY
1378
+ fprintf(o," --aggressive tries to get higher priority (nice)\n");
1379
+ #endif
1380
+ #if defined (HAVE_SCHED_SETSCHEDULER) || defined (HAVE_WINDOWS_H)
1381
+ fprintf(o," -T --realtime tries to get realtime priority\n");
1382
+ #endif
1383
+ #ifdef HAVE_WINDOWS_H
1384
+ fprintf(o," --priority <n> use specified process priority\n");
1385
+ fprintf(o," accepts -2 to 3 as integer arguments\n");
1386
+ fprintf(o," -2 as idle, 0 as normal and 3 as realtime.\n");
1387
+ #endif
1388
+ fprintf(o," -? --help give compact help\n");
1389
+ fprintf(o," --longhelp give this long help listing\n");
1390
+ fprintf(o," --version give name / version string\n");
1391
+
1392
+ fprintf(o,"\nSee the manpage %s(1) for more information.\n", prgName);
1393
+ safe_exit(err);
1394
+ }
1395
+
1396
+ static void want_long_usage(char* arg)
1397
+ {
1398
+ long_usage(0);
1399
+ }
1400
+
1401
+ static void give_version(char* arg)
1402
+ {
1403
+ fprintf(stdout, PACKAGE_NAME" "PACKAGE_VERSION"\n");
1404
+ safe_exit(0);
1405
+ }