Mercurial > hg > dmlib
comparison ppl.c @ 290:61cab36b6d32
Improve locking.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 11 Oct 2012 14:03:25 +0300 |
parents | 1e89cd081956 |
children | bc2e8ce003d7 |
comparison
equal
deleted
inserted
replaced
289:4d053d9e6439 | 290:61cab36b6d32 |
---|---|
553 jvmMute(engine.dev, i, mute); | 553 jvmMute(engine.dev, i, mute); |
554 } | 554 } |
555 | 555 |
556 int main(int argc, char *argv[]) | 556 int main(int argc, char *argv[]) |
557 { | 557 { |
558 BOOL initSDL = FALSE; | 558 BOOL initSDL = FALSE, audioInit = FALSE; |
559 DMResource *file = NULL; | 559 DMResource *file = NULL; |
560 int result = -1; | 560 int result = -1; |
561 BOOL muteState = FALSE; | 561 BOOL muteState = FALSE; |
562 | 562 |
563 memset(&engine, 0, sizeof(engine)); | 563 memset(&engine, 0, sizeof(engine)); |
691 { | 691 { |
692 dmError("Couldn't open SDL audio: %s\n", | 692 dmError("Couldn't open SDL audio: %s\n", |
693 SDL_GetError()); | 693 SDL_GetError()); |
694 goto error_exit; | 694 goto error_exit; |
695 } | 695 } |
696 audioInit = TRUE; | |
696 | 697 |
697 // Initialize player | 698 // Initialize player |
698 if ((engine.plr = jmpInit(engine.dev)) == NULL) | 699 if ((engine.plr = jmpInit(engine.dev)) == NULL) |
699 { | 700 { |
700 dmError("jmpInit() returned NULL\n"); | 701 dmError("jmpInit() returned NULL\n"); |
904 | 905 |
905 error_exit: | 906 error_exit: |
906 if (engine.screen) | 907 if (engine.screen) |
907 SDL_FreeSurface(engine.screen); | 908 SDL_FreeSurface(engine.screen); |
908 | 909 |
909 SDL_LockAudio(); | 910 dmMsg(0, "Audio shutdown.\n"); |
910 SDL_PauseAudio(1); | 911 if (audioInit) |
912 { | |
913 SDL_LockAudio(); | |
914 SDL_PauseAudio(1); | |
915 SDL_UnlockAudio(); | |
916 SDL_CloseAudio(); | |
917 } | |
918 | |
911 jmpClose(engine.plr); | 919 jmpClose(engine.plr); |
912 jvmClose(engine.dev); | 920 jvmClose(engine.dev); |
913 jssFreeModule(engine.mod); | 921 jssFreeModule(engine.mod); |
914 SDL_UnlockAudio(); | |
915 | 922 |
916 dmFreeBitmapFont(font); | 923 dmFreeBitmapFont(font); |
917 | 924 |
918 if (initSDL) | 925 if (initSDL) |
919 SDL_Quit(); | 926 SDL_Quit(); |