static void Mint_InitAudio(_THIS, SDL_AudioSpec *spec) { int channels_mode, prediv; void *buffer; Buffoper(0); Settracks(0,0); Setmontracks(0); switch (spec->format & 0xff) { case 8: if (spec->channels==2) { channels_mode=STEREO8; } else { channels_mode=MONO8; } break; case 16: if (spec->channels==2) { channels_mode=STEREO16; } else { channels_mode=MONO16; } break; default: channels_mode=STEREO16; break; } if (Setmode(channels_mode)<0) { DEBUG_PRINT((DEBUG_NAME "Setmode() failed\n")); } prediv = MINTAUDIO_frequencies[MINTAUDIO_numfreq].predivisor; Devconnect(DMAPLAY, DAC, CLKEXT, prediv, 1); buffer = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf]; if (Setbuffer(0, buffer, buffer + spec->size)<0) { DEBUG_PRINT((DEBUG_NAME "Setbuffer() failed\n")); } if (NSetinterrupt(2, SI_PLAY, Mint_GsxbInterrupt)<0) { DEBUG_PRINT((DEBUG_NAME "NSetinterrupt() failed\n")); } Buffoper(SB_PLA_ENA|SB_PLA_RPT); DEBUG_PRINT((DEBUG_NAME "hardware initialized\n")); }
static void Mint_CloseAudio(_THIS) { Buffoper(0); if (NSetinterrupt(2, SI_NONE, Mint_GsxbNullInterrupt)<0) { DEBUG_PRINT((DEBUG_NAME "NSetinterrupt() failed in close\n")); } while (SDL_MintAudio_mutex != 0) { } if (SDL_MintAudio_audiobuf[0]) { Mfree(SDL_MintAudio_audiobuf[0]); SDL_MintAudio_audiobuf[0] = SDL_MintAudio_audiobuf[1] = NULL; } Unlocksnd(); }
static void Mint_CloseAudio(_THIS) { /* Stop replay */ Buffoper(0); /* Uninstall interrupt */ if (NSetinterrupt(2, SI_NONE, SDL_MintAudio_EmptyGsxbInterrupt)<0) { DEBUG_PRINT((DEBUG_NAME "NSetinterrupt() failed in close\n")); } /* Wait if currently playing sound */ while (SDL_MintAudio_mutex != 0) { } /* Clear buffers */ if (SDL_MintAudio_audiobuf[0]) { Mfree(SDL_MintAudio_audiobuf[0]); SDL_MintAudio_audiobuf[0] = SDL_MintAudio_audiobuf[1] = NULL; } /* Unlock sound system */ Unlocksnd(); }