0006-staticerrorhack.patch 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781
  1. --- a/dynamic_mod.c
  2. +++ b/dynamic_mod.c
  3. @@ -28,6 +28,8 @@
  4. mikmod_loader mikmod = {
  5. 0, NULL
  6. };
  7. +
  8. +#undef MOD_DYNAMIC
  9. #ifdef MOD_DYNAMIC
  10. int Mix_InitMOD()
  11. --- a/Makefile.in
  12. +++ b/Makefile.in
  13. @@ -47,7 +47,7 @@
  14. LT_REVISION = @LT_REVISION@
  15. LT_LDFLAGS = -no-undefined -rpath $(libdir) -release $(LT_RELEASE) -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
  16. -all: $(srcdir)/configure Makefile $(objects) $(objects)/$(TARGET) $(objects)/playwave$(EXE) $(objects)/playmus$(EXE)
  17. +all: $(srcdir)/configure Makefile $(objects) $(objects)/$(TARGET)
  18. $(srcdir)/configure: $(srcdir)/configure.in
  19. @echo "Warning, configure.in is out of date"
  20. --- a/playmus.c
  21. +++ b/playmus.c
  22. @@ -1,247 +0,0 @@
  23. -/*
  24. - PLAYMUS: A test application for the SDL mixer library.
  25. - Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
  26. -
  27. - This software is provided 'as-is', without any express or implied
  28. - warranty. In no event will the authors be held liable for any damages
  29. - arising from the use of this software.
  30. -
  31. - Permission is granted to anyone to use this software for any purpose,
  32. - including commercial applications, and to alter it and redistribute it
  33. - freely, subject to the following restrictions:
  34. -
  35. - 1. The origin of this software must not be misrepresented; you must not
  36. - claim that you wrote the original software. If you use this software
  37. - in a product, an acknowledgment in the product documentation would be
  38. - appreciated but is not required.
  39. - 2. Altered source versions must be plainly marked as such, and must not be
  40. - misrepresented as being the original software.
  41. - 3. This notice may not be removed or altered from any source distribution.
  42. -*/
  43. -
  44. -/* $Id$ */
  45. -
  46. -#include <stdlib.h>
  47. -#include <stdio.h>
  48. -#include <string.h>
  49. -
  50. -#ifdef unix
  51. -#include <unistd.h>
  52. -#endif
  53. -
  54. -#include "SDL.h"
  55. -#include "SDL_mixer.h"
  56. -
  57. -#ifdef HAVE_SIGNAL_H
  58. -#include <signal.h>
  59. -#endif
  60. -
  61. -
  62. -static int audio_open = 0;
  63. -static Mix_Music *music = NULL;
  64. -static int next_track = 0;
  65. -
  66. -void CleanUp(int exitcode)
  67. -{
  68. - if( Mix_PlayingMusic() ) {
  69. - Mix_FadeOutMusic(1500);
  70. - SDL_Delay(1500);
  71. - }
  72. - if ( music ) {
  73. - Mix_FreeMusic(music);
  74. - music = NULL;
  75. - }
  76. - if ( audio_open ) {
  77. - Mix_CloseAudio();
  78. - audio_open = 0;
  79. - }
  80. - SDL_Quit();
  81. - exit(exitcode);
  82. -}
  83. -
  84. -void Usage(char *argv0)
  85. -{
  86. - fprintf(stderr, "Usage: %s [-i] [-l] [-8] [-r rate] [-c channels] [-b buffers] [-v N] [-rwops] <musicfile>\n", argv0);
  87. -}
  88. -
  89. -/*#define SEEK_TEST */
  90. -void Menu(void)
  91. -{
  92. - char buf[10];
  93. -
  94. - printf("Available commands: (p)ause (r)esume (h)alt volume(v#) > ");
  95. - fflush(stdin);
  96. - if (scanf("%s",buf) == 1) {
  97. - switch(buf[0]){
  98. -#if defined(SEEK_TEST)
  99. - case '0': Mix_SetMusicPosition(0); break;
  100. - case '1': Mix_SetMusicPosition(10);break;
  101. - case '2': Mix_SetMusicPosition(20);break;
  102. - case '3': Mix_SetMusicPosition(30);break;
  103. - case '4': Mix_SetMusicPosition(40);break;
  104. -#endif /* SEEK_TEST */
  105. - case 'p': case 'P':
  106. - Mix_PauseMusic();
  107. - break;
  108. - case 'r': case 'R':
  109. - Mix_ResumeMusic();
  110. - break;
  111. - case 'h': case 'H':
  112. - Mix_HaltMusic();
  113. - break;
  114. - case 'v': case 'V':
  115. - Mix_VolumeMusic(atoi(buf+1));
  116. - break;
  117. - }
  118. - }
  119. - printf("Music playing: %s Paused: %s\n", Mix_PlayingMusic() ? "yes" : "no",
  120. - Mix_PausedMusic() ? "yes" : "no");
  121. -}
  122. -
  123. -#ifdef HAVE_SIGNAL_H
  124. -
  125. -void IntHandler(int sig)
  126. -{
  127. - switch (sig) {
  128. - case SIGINT:
  129. - next_track++;
  130. - break;
  131. - }
  132. -}
  133. -
  134. -#endif
  135. -
  136. -int main(int argc, char *argv[])
  137. -{
  138. - SDL_RWops *rwfp = NULL;
  139. - int audio_rate;
  140. - Uint16 audio_format;
  141. - int audio_channels;
  142. - int audio_buffers;
  143. - int audio_volume = MIX_MAX_VOLUME;
  144. - int looping = 0;
  145. - int interactive = 0;
  146. - int rwops = 0;
  147. - int i;
  148. -
  149. - /* Initialize variables */
  150. - audio_rate = 22050;
  151. - audio_format = AUDIO_S16;
  152. - audio_channels = 2;
  153. - audio_buffers = 4096;
  154. -
  155. - /* Check command line usage */
  156. - for ( i=1; argv[i] && (*argv[i] == '-'); ++i ) {
  157. - if ( (strcmp(argv[i], "-r") == 0) && argv[i+1] ) {
  158. - ++i;
  159. - audio_rate = atoi(argv[i]);
  160. - } else
  161. - if ( strcmp(argv[i], "-m") == 0 ) {
  162. - audio_channels = 1;
  163. - } else
  164. - if ( (strcmp(argv[i], "-c") == 0) && argv[i+1] ) {
  165. - ++i;
  166. - audio_channels = atoi(argv[i]);
  167. - } else
  168. - if ( (strcmp(argv[i], "-b") == 0) && argv[i+1] ) {
  169. - ++i;
  170. - audio_buffers = atoi(argv[i]);
  171. - } else
  172. - if ( (strcmp(argv[i], "-v") == 0) && argv[i+1] ) {
  173. - ++i;
  174. - audio_volume = atoi(argv[i]);
  175. - } else
  176. - if ( strcmp(argv[i], "-l") == 0 ) {
  177. - looping = -1;
  178. - } else
  179. - if ( strcmp(argv[i], "-i") == 0 ) {
  180. - interactive = 1;
  181. - } else
  182. - if ( strcmp(argv[i], "-8") == 0 ) {
  183. - audio_format = AUDIO_U8;
  184. - } else
  185. - if ( strcmp(argv[i], "-rwops") == 0 ) {
  186. - rwops = 1;
  187. - } else {
  188. - Usage(argv[0]);
  189. - return(1);
  190. - }
  191. - }
  192. - if ( ! argv[i] ) {
  193. - Usage(argv[0]);
  194. - return(1);
  195. - }
  196. -
  197. - /* Initialize the SDL library */
  198. - if ( SDL_Init(SDL_INIT_AUDIO) < 0 ) {
  199. - fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
  200. - return(255);
  201. - }
  202. -
  203. -#ifdef HAVE_SIGNAL_H
  204. - signal(SIGINT, IntHandler);
  205. - signal(SIGTERM, CleanUp);
  206. -#endif
  207. -
  208. - /* Open the audio device */
  209. - if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) < 0) {
  210. - fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError());
  211. - return(2);
  212. - } else {
  213. - Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels);
  214. - printf("Opened audio at %d Hz %d bit %s (%s), %d bytes audio buffer\n", audio_rate,
  215. - (audio_format&0xFF),
  216. - (audio_channels > 2) ? "surround" : (audio_channels > 1) ? "stereo" : "mono",
  217. - (audio_format&0x1000) ? "BE" : "LE",
  218. - audio_buffers );
  219. - }
  220. - audio_open = 1;
  221. -
  222. - /* Set the music volume */
  223. - Mix_VolumeMusic(audio_volume);
  224. -
  225. - /* Set the external music player, if any */
  226. - Mix_SetMusicCMD(SDL_getenv("MUSIC_CMD"));
  227. -
  228. - while (argv[i]) {
  229. - next_track = 0;
  230. -
  231. - /* Load the requested music file */
  232. - if ( rwops ) {
  233. - rwfp = SDL_RWFromFile(argv[i], "rb");
  234. - music = Mix_LoadMUS_RW(rwfp);
  235. - } else {
  236. - music = Mix_LoadMUS(argv[i]);
  237. - }
  238. - if ( music == NULL ) {
  239. - fprintf(stderr, "Couldn't load %s: %s\n",
  240. - argv[i], SDL_GetError());
  241. - CleanUp(2);
  242. - }
  243. -
  244. - /* Play and then exit */
  245. - printf("Playing %s\n", argv[i]);
  246. - Mix_FadeInMusic(music,looping,2000);
  247. - while ( !next_track && (Mix_PlayingMusic() || Mix_PausedMusic()) ) {
  248. - if(interactive)
  249. - Menu();
  250. - else
  251. - SDL_Delay(100);
  252. - }
  253. - Mix_FreeMusic(music);
  254. - if ( rwops ) {
  255. - SDL_RWclose(rwfp);
  256. - }
  257. - music = NULL;
  258. -
  259. - /* If the user presses Ctrl-C more than once, exit. */
  260. - SDL_Delay(500);
  261. - if ( next_track > 1 ) break;
  262. -
  263. - i++;
  264. - }
  265. - CleanUp(0);
  266. -
  267. - /* Not reached, but fixes compiler warnings */
  268. - return 0;
  269. -}
  270. +int main(){}
  271. --- a/playwave.c
  272. +++ b/playwave.c
  273. @@ -1,501 +0,0 @@
  274. -/*
  275. - PLAYWAVE: A test application for the SDL mixer library.
  276. - Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
  277. -
  278. - This software is provided 'as-is', without any express or implied
  279. - warranty. In no event will the authors be held liable for any damages
  280. - arising from the use of this software.
  281. -
  282. - Permission is granted to anyone to use this software for any purpose,
  283. - including commercial applications, and to alter it and redistribute it
  284. - freely, subject to the following restrictions:
  285. -
  286. - 1. The origin of this software must not be misrepresented; you must not
  287. - claim that you wrote the original software. If you use this software
  288. - in a product, an acknowledgment in the product documentation would be
  289. - appreciated but is not required.
  290. - 2. Altered source versions must be plainly marked as such, and must not be
  291. - misrepresented as being the original software.
  292. - 3. This notice may not be removed or altered from any source distribution.
  293. -*/
  294. -
  295. -/* $Id$ */
  296. -
  297. -#include <stdlib.h>
  298. -#include <stdio.h>
  299. -#include <string.h>
  300. -
  301. -#ifdef unix
  302. -#include <unistd.h>
  303. -#endif
  304. -
  305. -#include "SDL.h"
  306. -#include "SDL_mixer.h"
  307. -
  308. -#ifdef HAVE_SIGNAL_H
  309. -#include <signal.h>
  310. -#endif
  311. -
  312. -
  313. -/*
  314. - * rcg06132001 various mixer tests. Define the ones you want.
  315. - */
  316. -/*#define TEST_MIX_DECODERS*/
  317. -/*#define TEST_MIX_VERSIONS*/
  318. -/*#define TEST_MIX_CHANNELFINISHED*/
  319. -/*#define TEST_MIX_PANNING*/
  320. -/*#define TEST_MIX_DISTANCE*/
  321. -/*#define TEST_MIX_POSITION*/
  322. -
  323. -
  324. -#if (defined TEST_MIX_POSITION)
  325. -
  326. -#if (defined TEST_MIX_PANNING)
  327. -#error TEST_MIX_POSITION interferes with TEST_MIX_PANNING.
  328. -#endif
  329. -
  330. -#if (defined TEST_MIX_DISTANCE)
  331. -#error TEST_MIX_POSITION interferes with TEST_MIX_DISTANCE.
  332. -#endif
  333. -
  334. -#endif
  335. -
  336. -
  337. -/* rcg06192001 for debugging purposes. */
  338. -static void output_test_warnings(void)
  339. -{
  340. -#if (defined TEST_MIX_CHANNELFINISHED)
  341. - fprintf(stderr, "Warning: TEST_MIX_CHANNELFINISHED is enabled in this binary...\n");
  342. -#endif
  343. -#if (defined TEST_MIX_PANNING)
  344. - fprintf(stderr, "Warning: TEST_MIX_PANNING is enabled in this binary...\n");
  345. -#endif
  346. -#if (defined TEST_MIX_VERSIONS)
  347. - fprintf(stderr, "Warning: TEST_MIX_VERSIONS is enabled in this binary...\n");
  348. -#endif
  349. -#if (defined TEST_MIX_DISTANCE)
  350. - fprintf(stderr, "Warning: TEST_MIX_DISTANCE is enabled in this binary...\n");
  351. -#endif
  352. -#if (defined TEST_MIX_POSITION)
  353. - fprintf(stderr, "Warning: TEST_MIX_POSITION is enabled in this binary...\n");
  354. -#endif
  355. -}
  356. -
  357. -
  358. -static int audio_open = 0;
  359. -static Mix_Chunk *wave = NULL;
  360. -
  361. -/* rcg06042009 Report available decoders. */
  362. -#if (defined TEST_MIX_DECODERS)
  363. -static void report_decoders(void)
  364. -{
  365. - int i, total;
  366. -
  367. - printf("Supported decoders...\n");
  368. - total = Mix_GetNumChunkDecoders();
  369. - for (i = 0; i < total; i++) {
  370. - fprintf(stderr, " - chunk decoder: %s\n", Mix_GetChunkDecoder(i));
  371. - }
  372. -
  373. - total = Mix_GetNumMusicDecoders();
  374. - for (i = 0; i < total; i++) {
  375. - fprintf(stderr, " - music decoder: %s\n", Mix_GetMusicDecoder(i));
  376. - }
  377. -}
  378. -#endif
  379. -
  380. -/* rcg06192001 Check new Mixer version API. */
  381. -#if (defined TEST_MIX_VERSIONS)
  382. -static void output_versions(const char *libname, const SDL_version *compiled,
  383. - const SDL_version *linked)
  384. -{
  385. - fprintf(stderr,
  386. - "This program was compiled against %s %d.%d.%d,\n"
  387. - " and is dynamically linked to %d.%d.%d.\n", libname,
  388. - compiled->major, compiled->minor, compiled->patch,
  389. - linked->major, linked->minor, linked->patch);
  390. -}
  391. -
  392. -static void test_versions(void)
  393. -{
  394. - SDL_version compiled;
  395. - const SDL_version *linked;
  396. -
  397. - SDL_VERSION(&compiled);
  398. - linked = SDL_Linked_Version();
  399. - output_versions("SDL", &compiled, linked);
  400. -
  401. - SDL_MIXER_VERSION(&compiled);
  402. - linked = Mix_Linked_Version();
  403. - output_versions("SDL_mixer", &compiled, linked);
  404. -}
  405. -#endif
  406. -
  407. -
  408. -#ifdef TEST_MIX_CHANNELFINISHED /* rcg06072001 */
  409. -static volatile int channel_is_done = 0;
  410. -static void SDLCALL channel_complete_callback (int chan)
  411. -{
  412. - Mix_Chunk *done_chunk = Mix_GetChunk(chan);
  413. - fprintf(stderr, "We were just alerted that Mixer channel #%d is done.\n", chan);
  414. - fprintf(stderr, "Channel's chunk pointer is (%p).\n", done_chunk);
  415. - fprintf(stderr, " Which %s correct.\n", (wave == done_chunk) ? "is" : "is NOT");
  416. - channel_is_done = 1;
  417. -}
  418. -#endif
  419. -
  420. -
  421. -/* rcg06192001 abstract this out for testing purposes. */
  422. -static int still_playing(void)
  423. -{
  424. -#ifdef TEST_MIX_CHANNELFINISHED
  425. - return(!channel_is_done);
  426. -#else
  427. - return(Mix_Playing(0));
  428. -#endif
  429. -}
  430. -
  431. -
  432. -#if (defined TEST_MIX_PANNING)
  433. -static void do_panning_update(void)
  434. -{
  435. - static Uint8 leftvol = 128;
  436. - static Uint8 rightvol = 128;
  437. - static Uint8 leftincr = -1;
  438. - static Uint8 rightincr = 1;
  439. - static int panningok = 1;
  440. - static Uint32 next_panning_update = 0;
  441. -
  442. - if ((panningok) && (SDL_GetTicks() >= next_panning_update)) {
  443. - panningok = Mix_SetPanning(0, leftvol, rightvol);
  444. - if (!panningok) {
  445. - fprintf(stderr, "Mix_SetPanning(0, %d, %d) failed!\n",
  446. - (int) leftvol, (int) rightvol);
  447. - fprintf(stderr, "Reason: [%s].\n", Mix_GetError());
  448. - }
  449. -
  450. - if ((leftvol == 255) || (leftvol == 0)) {
  451. - if (leftvol == 255)
  452. - printf("All the way in the left speaker.\n");
  453. - leftincr *= -1;
  454. - }
  455. -
  456. - if ((rightvol == 255) || (rightvol == 0)) {
  457. - if (rightvol == 255)
  458. - printf("All the way in the right speaker.\n");
  459. - rightincr *= -1;
  460. - }
  461. -
  462. - leftvol += leftincr;
  463. - rightvol += rightincr;
  464. - next_panning_update = SDL_GetTicks() + 10;
  465. - }
  466. -}
  467. -#endif
  468. -
  469. -
  470. -#if (defined TEST_MIX_DISTANCE)
  471. -static void do_distance_update(void)
  472. -{
  473. - static Uint8 distance = 1;
  474. - static Uint8 distincr = 1;
  475. - static int distanceok = 1;
  476. - static Uint32 next_distance_update = 0;
  477. -
  478. - if ((distanceok) && (SDL_GetTicks() >= next_distance_update)) {
  479. - distanceok = Mix_SetDistance(0, distance);
  480. - if (!distanceok) {
  481. - fprintf(stderr, "Mix_SetDistance(0, %d) failed!\n", (int) distance);
  482. - fprintf(stderr, "Reason: [%s].\n", Mix_GetError());
  483. - }
  484. -
  485. - if (distance == 0) {
  486. - printf("Distance at nearest point.\n");
  487. - distincr *= -1;
  488. - }
  489. - else if (distance == 255) {
  490. - printf("Distance at furthest point.\n");
  491. - distincr *= -1;
  492. - }
  493. -
  494. - distance += distincr;
  495. - next_distance_update = SDL_GetTicks() + 15;
  496. - }
  497. -}
  498. -#endif
  499. -
  500. -
  501. -#if (defined TEST_MIX_POSITION)
  502. -static void do_position_update(void)
  503. -{
  504. - static Sint16 distance = 1;
  505. - static Sint8 distincr = 1;
  506. - static Uint16 angle = 0;
  507. - static Sint8 angleincr = 1;
  508. - static int positionok = 1;
  509. - static Uint32 next_position_update = 0;
  510. -
  511. - if ((positionok) && (SDL_GetTicks() >= next_position_update)) {
  512. - positionok = Mix_SetPosition(0, angle, distance);
  513. - if (!positionok) {
  514. - fprintf(stderr, "Mix_SetPosition(0, %d, %d) failed!\n",
  515. - (int) angle, (int) distance);
  516. - fprintf(stderr, "Reason: [%s].\n", Mix_GetError());
  517. - }
  518. -
  519. - if (angle == 0) {
  520. - printf("Due north; now rotating clockwise...\n");
  521. - angleincr = 1;
  522. - }
  523. -
  524. - else if (angle == 360) {
  525. - printf("Due north; now rotating counter-clockwise...\n");
  526. - angleincr = -1;
  527. - }
  528. -
  529. - distance += distincr;
  530. -
  531. - if (distance < 0) {
  532. - distance = 0;
  533. - distincr = 3;
  534. - printf("Distance is very, very near. Stepping away by threes...\n");
  535. - } else if (distance > 255) {
  536. - distance = 255;
  537. - distincr = -3;
  538. - printf("Distance is very, very far. Stepping towards by threes...\n");
  539. - }
  540. -
  541. - angle += angleincr;
  542. - next_position_update = SDL_GetTicks() + 30;
  543. - }
  544. -}
  545. -#endif
  546. -
  547. -
  548. -static void CleanUp(int exitcode)
  549. -{
  550. - if ( wave ) {
  551. - Mix_FreeChunk(wave);
  552. - wave = NULL;
  553. - }
  554. - if ( audio_open ) {
  555. - Mix_CloseAudio();
  556. - audio_open = 0;
  557. - }
  558. - SDL_Quit();
  559. -
  560. - exit(exitcode);
  561. -}
  562. -
  563. -
  564. -static void Usage(char *argv0)
  565. -{
  566. - fprintf(stderr, "Usage: %s [-8] [-r rate] [-c channels] [-f] [-F] [-l] [-m] <wavefile>\n", argv0);
  567. -}
  568. -
  569. -
  570. -/*
  571. - * rcg06182001 This is sick, but cool.
  572. - *
  573. - * Actually, it's meant to be an example of how to manipulate a voice
  574. - * without having to use the mixer effects API. This is more processing
  575. - * up front, but no extra during the mixing process. Also, in a case like
  576. - * this, when you need to touch the whole sample at once, it's the only
  577. - * option you've got. And, with the effects API, you are altering a copy of
  578. - * the original sample for each playback, and thus, your changes aren't
  579. - * permanent; here, you've got a reversed sample, and that's that until
  580. - * you either reverse it again, or reload it.
  581. - */
  582. -static void flip_sample(Mix_Chunk *wave)
  583. -{
  584. - Uint16 format;
  585. - int channels, i, incr;
  586. - Uint8 *start = wave->abuf;
  587. - Uint8 *end = wave->abuf + wave->alen;
  588. -
  589. - Mix_QuerySpec(NULL, &format, &channels);
  590. - incr = (format & 0xFF) * channels;
  591. -
  592. - end -= incr;
  593. -
  594. - switch (incr) {
  595. - case 8:
  596. - for (i = wave->alen / 2; i >= 0; i -= 1) {
  597. - Uint8 tmp = *start;
  598. - *start = *end;
  599. - *end = tmp;
  600. - start++;
  601. - end--;
  602. - }
  603. - break;
  604. -
  605. - case 16:
  606. - for (i = wave->alen / 2; i >= 0; i -= 2) {
  607. - Uint16 tmp = *start;
  608. - *((Uint16 *) start) = *((Uint16 *) end);
  609. - *((Uint16 *) end) = tmp;
  610. - start += 2;
  611. - end -= 2;
  612. - }
  613. - break;
  614. -
  615. - case 32:
  616. - for (i = wave->alen / 2; i >= 0; i -= 4) {
  617. - Uint32 tmp = *start;
  618. - *((Uint32 *) start) = *((Uint32 *) end);
  619. - *((Uint32 *) end) = tmp;
  620. - start += 4;
  621. - end -= 4;
  622. - }
  623. - break;
  624. -
  625. - default:
  626. - fprintf(stderr, "Unhandled format in sample flipping.\n");
  627. - return;
  628. - }
  629. -}
  630. -
  631. -
  632. -int main(int argc, char *argv[])
  633. -{
  634. - int audio_rate;
  635. - Uint16 audio_format;
  636. - int audio_channels;
  637. - int loops = 0;
  638. - int i;
  639. - int reverse_stereo = 0;
  640. - int reverse_sample = 0;
  641. -
  642. -#ifdef HAVE_SETBUF
  643. - setbuf(stdout, NULL); /* rcg06132001 for debugging purposes. */
  644. - setbuf(stderr, NULL); /* rcg06192001 for debugging purposes, too. */
  645. -#endif
  646. - output_test_warnings();
  647. -
  648. - /* Initialize variables */
  649. - audio_rate = MIX_DEFAULT_FREQUENCY;
  650. - audio_format = MIX_DEFAULT_FORMAT;
  651. - audio_channels = 2;
  652. -
  653. - /* Check command line usage */
  654. - for ( i=1; argv[i] && (*argv[i] == '-'); ++i ) {
  655. - if ( (strcmp(argv[i], "-r") == 0) && argv[i+1] ) {
  656. - ++i;
  657. - audio_rate = atoi(argv[i]);
  658. - } else
  659. - if ( strcmp(argv[i], "-m") == 0 ) {
  660. - audio_channels = 1;
  661. - } else
  662. - if ( (strcmp(argv[i], "-c") == 0) && argv[i+1] ) {
  663. - ++i;
  664. - audio_channels = atoi(argv[i]);
  665. - } else
  666. - if ( strcmp(argv[i], "-l") == 0 ) {
  667. - loops = -1;
  668. - } else
  669. - if ( strcmp(argv[i], "-8") == 0 ) {
  670. - audio_format = AUDIO_U8;
  671. - } else
  672. - if ( strcmp(argv[i], "-f") == 0 ) { /* rcg06122001 flip stereo */
  673. - reverse_stereo = 1;
  674. - } else
  675. - if ( strcmp(argv[i], "-F") == 0 ) { /* rcg06172001 flip sample */
  676. - reverse_sample = 1;
  677. - } else {
  678. - Usage(argv[0]);
  679. - return(1);
  680. - }
  681. - }
  682. - if ( ! argv[i] ) {
  683. - Usage(argv[0]);
  684. - return(1);
  685. - }
  686. -
  687. - /* Initialize the SDL library */
  688. - if ( SDL_Init(SDL_INIT_AUDIO) < 0 ) {
  689. - fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
  690. - return(255);
  691. - }
  692. -#ifdef HAVE_SIGNAL_H
  693. - signal(SIGINT, CleanUp);
  694. - signal(SIGTERM, CleanUp);
  695. -#endif
  696. -
  697. - /* Open the audio device */
  698. - if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, 4096) < 0) {
  699. - fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError());
  700. - CleanUp(2);
  701. - } else {
  702. - Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels);
  703. - printf("Opened audio at %d Hz %d bit %s", audio_rate,
  704. - (audio_format&0xFF),
  705. - (audio_channels > 2) ? "surround" :
  706. - (audio_channels > 1) ? "stereo" : "mono");
  707. - if ( loops ) {
  708. - printf(" (looping)\n");
  709. - } else {
  710. - putchar('\n');
  711. - }
  712. - }
  713. - audio_open = 1;
  714. -
  715. -#if (defined TEST_MIX_VERSIONS)
  716. - test_versions();
  717. -#endif
  718. -
  719. -#if (defined TEST_MIX_DECODERS)
  720. - report_decoders();
  721. -#endif
  722. -
  723. - /* Load the requested wave file */
  724. - wave = Mix_LoadWAV(argv[i]);
  725. - if ( wave == NULL ) {
  726. - fprintf(stderr, "Couldn't load %s: %s\n",
  727. - argv[i], SDL_GetError());
  728. - CleanUp(2);
  729. - }
  730. -
  731. - if (reverse_sample) {
  732. - flip_sample(wave);
  733. - }
  734. -
  735. -#ifdef TEST_MIX_CHANNELFINISHED /* rcg06072001 */
  736. - Mix_ChannelFinished(channel_complete_callback);
  737. -#endif
  738. -
  739. - if ( (!Mix_SetReverseStereo(MIX_CHANNEL_POST, reverse_stereo)) &&
  740. - (reverse_stereo) )
  741. - {
  742. - printf("Failed to set up reverse stereo effect!\n");
  743. - printf("Reason: [%s].\n", Mix_GetError());
  744. - }
  745. -
  746. - /* Play and then exit */
  747. - Mix_PlayChannel(0, wave, loops);
  748. -
  749. - while (still_playing()) {
  750. -
  751. -#if (defined TEST_MIX_PANNING) /* rcg06132001 */
  752. - do_panning_update();
  753. -#endif
  754. -
  755. -#if (defined TEST_MIX_DISTANCE) /* rcg06192001 */
  756. - do_distance_update();
  757. -#endif
  758. -
  759. -#if (defined TEST_MIX_POSITION) /* rcg06202001 */
  760. - do_position_update();
  761. -#endif
  762. -
  763. - SDL_Delay(1);
  764. -
  765. - } /* while still_playing() loop... */
  766. -
  767. - CleanUp(0);
  768. -
  769. - /* Not reached, but fixes compiler warnings */
  770. - return 0;
  771. -}
  772. -
  773. -/* end of playwave.c ... */
  774. -
  775. +int main(){}