* Initializes the audio subsystem. */
| 636 | * Initializes the audio subsystem. |
| 637 | */ |
| 638 | void Game::initAudio() |
| 639 | { |
| 640 | Uint16 format; |
| 641 | if (Options::audioBitDepth == 8) |
| 642 | format = AUDIO_S8; |
| 643 | else |
| 644 | format = AUDIO_S16SYS; |
| 645 | if (Mix_OpenAudio(Options::audioSampleRate, format, 2, 1024) != 0) |
| 646 | { |
| 647 | Log(LOG_ERROR) << Mix_GetError(); |
| 648 | Log(LOG_WARNING) << "No sound device detected, audio disabled."; |
| 649 | Options::mute = true; |
| 650 | } |
| 651 | else |
| 652 | { |
| 653 | Mix_AllocateChannels(16); |
| 654 | // Set up UI channels |
| 655 | Mix_ReserveChannels(3); |
| 656 | Mix_GroupChannels(1, 2, 0); |
| 657 | Log(LOG_INFO) << "SDL_mixer initialized successfully."; |
| 658 | setVolume(Options::soundVolume, Options::musicVolume, Options::uiVolume); |
| 659 | } |
| 660 | } |
| 661 | |
| 662 | } |