const char *SoundDriver_Allegro::Start(const char * const *parm) { if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, NULL)) { DEBUG(driver, 0, "allegro: install_allegro failed '%s'", allegro_error); return "Failed to set up Allegro"; } _allegro_instance_count++; /* Initialise the sound */ if (install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL) != 0) { DEBUG(driver, 0, "allegro: install_sound failed '%s'", allegro_error); return "Failed to set up Allegro sound"; } /* Okay, there's no soundcard */ if (digi_card == DIGI_NONE) { DEBUG(driver, 0, "allegro: no sound card found"); return "No sound card found"; } int hz = GetDriverParamInt(parm, "hz", 44100); _buffer_size = GetDriverParamInt(parm, "samples", 1024) * hz / 11025; _stream = play_audio_stream(_buffer_size, 16, true, hz, 255, 128); MxInitialize(hz); return NULL; }
const char *SoundDriver_Win32::Start(const char * const *parm) { WAVEFORMATEX wfex; wfex.wFormatTag = WAVE_FORMAT_PCM; wfex.nChannels = 2; wfex.wBitsPerSample = 16; wfex.nSamplesPerSec = GetDriverParamInt(parm, "hz", 44100); wfex.nBlockAlign = (wfex.nChannels * wfex.wBitsPerSample) / 8; wfex.nAvgBytesPerSec = wfex.nSamplesPerSec * wfex.nBlockAlign; /* Limit buffer size to prevent overflows. */ _bufsize = GetDriverParamInt(parm, "bufsize", (GB(GetVersion(), 0, 8) > 5) ? 8192 : 4096); _bufsize = min(_bufsize, UINT16_MAX); try { if (NULL == (_event = CreateEvent(NULL, FALSE, FALSE, NULL))) throw "Failed to create event"; if (waveOutOpen(&_waveout, WAVE_MAPPER, &wfex, (DWORD_PTR)_event, 0, CALLBACK_EVENT) != MMSYSERR_NOERROR) throw "waveOutOpen failed"; MxInitialize(wfex.nSamplesPerSec); PrepareHeader(&_wave_hdr[0]); PrepareHeader(&_wave_hdr[1]); if (NULL == (_thread = CreateThread(NULL, 8192, SoundThread, 0, 0, &_threadId))) throw "Failed to create thread"; } catch (const char *error) { this->Stop(); return error; } return NULL; }
const char *VideoDriver_Null::Start(const char * const *parm) { this->ticks = GetDriverParamInt(parm, "ticks", 1000); _screen.width = _screen.pitch = _cur_resolution.width; _screen.height = _cur_resolution.height; _screen.dst_ptr = NULL; ScreenSizeChanged(); /* Do not render, nor blit */ DEBUG(misc, 1, "Forcing blitter 'null'..."); BlitterFactoryBase::SelectBlitter("null"); return NULL; }
const char *SoundDriver_SDL::Start(const char * const *parm) { SDL_AudioSpec spec; const char *s = SdlOpen(SDL_INIT_AUDIO); if (s != NULL) return s; spec.freq = GetDriverParamInt(parm, "hz", 44100); spec.format = AUDIO_S16SYS; spec.channels = 2; spec.samples = 512; spec.callback = fill_sound_buffer; MxInitialize(spec.freq); SDL_CALL SDL_OpenAudio(&spec, &spec); SDL_CALL SDL_PauseAudio(0); return NULL; }
const char *VideoDriver_Null::Start(const char * const *parm) { #ifdef _MSC_VER /* Disable the MSVC assertion message box. */ _set_error_mode(_OUT_TO_STDERR); #endif this->ticks = GetDriverParamInt(parm, "ticks", 1000); _screen.width = _screen.pitch = _cur_resolution.width; _screen.height = _cur_resolution.height; _screen.dst_ptr = NULL; ScreenSizeChanged(); /* Do not render, nor blit */ DEBUG(misc, 1, "Forcing blitter 'null'..."); BlitterFactory::SelectBlitter("null"); return NULL; }
const char *VideoDriver_SDL::Start(const char * const *parm) { char buf[30]; _use_hwpalette = GetDriverParamInt(parm, "hw_palette", 2); const char *s = SdlOpen(SDL_INIT_VIDEO); if (s != NULL) return s; GetVideoModes(); if (!CreateMainSurface(_cur_resolution.width, _cur_resolution.height)) { return SDL_CALL SDL_GetError(); } SDL_CALL SDL_VideoDriverName(buf, sizeof buf); DEBUG(driver, 1, "SDL: using driver '%s'", buf); MarkWholeScreenDirty(); SetupKeyboard(); _draw_threaded = GetDriverParam(parm, "no_threads") == NULL && GetDriverParam(parm, "no_thread") == NULL; return NULL; }