static void shutdown_dynlib(void) { if (op_dll) { _al_close_library(op_dll); op_dll = NULL; op_virgin = true; } }
/* The close method should close the device, freeing any resources, and allow other processes to use the device */ static void _dsound_close() { ALLEGRO_DEBUG("Releasing device\n"); device->Release(); ALLEGRO_DEBUG("Released device\n"); _al_close_library(_al_dsound_module); ALLEGRO_INFO("DirectSound closed\n"); }
/* The open method starts up the driver and should lock the device, using the previously set paramters, or defaults. It shouldn't need to start sending audio data to the device yet, however. */ static int _dsound_open() { HRESULT hr; ALLEGRO_DEBUG("Loading DirectSound module\n"); /* load DirectSound module */ _al_dsound_module = _al_open_library(_al_dsound_module_name); if (_al_dsound_module == NULL) { ALLEGRO_ERROR("Failed to open '%s' library\n", _al_dsound_module_name); return 1; } /* import DirectSound create proc */ _al_dsound_create = (DIRECTSOUNDCREATE8PROC)_al_import_symbol(_al_dsound_module, "DirectSoundCreate8"); if (_al_dsound_create == NULL) { ALLEGRO_ERROR("DirectSoundCreate8 not in %s\n", _al_dsound_module_name); _al_close_library(_al_dsound_module); return 1; } ALLEGRO_INFO("Starting DirectSound...\n"); /* FIXME: Use default device until we have device enumeration */ hr = _al_dsound_create(NULL, &device, NULL); if (FAILED(hr)) { ALLEGRO_ERROR("DirectSoundCreate8 failed\n"); _al_close_library(_al_dsound_module); return 1; } ALLEGRO_DEBUG("DirectSoundCreate8 succeeded\n"); /* FIXME: The window specified here is probably very wrong. NULL won't work either. */ hr = device->SetCooperativeLevel(GetForegroundWindow(), DSSCL_PRIORITY); if (FAILED(hr)) { ALLEGRO_ERROR("SetCooperativeLevel failed\n"); _al_close_library(_al_dsound_module); return 1; } return 0; }
static void shutdown_libdumb(void) { if (libdumb_loaded) { lib.dumb_exit(); libdumb_loaded = false; } #ifdef ALLEGRO_CFG_ACODEC_DUMB_DLL if (dumb_dll) { _al_close_library(dumb_dll); dumb_dll = NULL; } #endif }
bool _al_win_init_touch_input_api(void) { /* Reference counter will be negative if we already tried to initialize the driver. * Lack of touch input API is persistent state, so do not test for it again. */ if (touch_input_api_reference_counter < 0) return false; /* Increase API reference counter if it is already initialized. */ if (touch_input_api_reference_counter > 0) { touch_input_api_reference_counter++; return true; } /* Open handle to user32.dll. This one should be always present. */ user32_module = _al_open_library("user32.dll"); if (NULL == user32_module) return false; _al_win_close_touch_input_handle = (CLOSETOUCHINPUTHANDLEPROC)_al_import_symbol(user32_module, "CloseTouchInputHandle"); _al_win_get_touch_input_info = (GETTOUCHINPUTINFOPROC) _al_import_symbol(user32_module, "GetTouchInputInfo"); _al_win_is_touch_window = (ISTOUCHWINDOWPROC) _al_import_symbol(user32_module, "IsTouchWindow"); _al_win_register_touch_window = (REGISTERTOUCHWINDOWPROC) _al_import_symbol(user32_module, "RegisterTouchWindow"); _al_win_unregister_touch_window = (UNREGISTERTOUCHWINDOWPROC)_al_import_symbol(user32_module, "UnregisterTouchWindow"); if (NULL == _al_win_close_touch_input_handle || NULL == _al_win_get_touch_input_info || NULL == _al_win_is_touch_window || NULL == _al_win_register_touch_window || NULL == _al_win_unregister_touch_window) { _al_close_library(user32_module); _al_win_close_touch_input_handle = NULL; _al_win_get_touch_input_info = NULL; _al_win_is_touch_window = NULL; _al_win_register_touch_window = NULL; _al_win_unregister_touch_window = NULL; /* Mark as 'do not try this again'. */ touch_input_api_reference_counter = -1; ALLEGRO_WARN("failed loading the touch input API\n"); return false; } /* Set initial reference count. */ touch_input_api_reference_counter = 1; ALLEGRO_INFO("touch input API installed successfully\n"); return true; }
void _al_win_exit_touch_input_api(void) { if (touch_input_api_reference_counter > 1) { --touch_input_api_reference_counter; return; } if (touch_input_api_reference_counter != 1) return; _al_close_library(user32_module); _al_win_close_touch_input_handle = NULL; _al_win_get_touch_input_info = NULL; _al_win_is_touch_window = NULL; _al_win_register_touch_window = NULL; _al_win_unregister_touch_window = NULL; touch_input_api_reference_counter = 0; }
bool _al_open_native_text_log(ALLEGRO_NATIVE_DIALOG *textlog) { LPCSTR font_name; HWND hWnd; HWND hLog; WNDCLASSA text_log_class; RECT client_rect; HFONT hFont; MSG msg; BOOL ret; al_lock_mutex(textlog->tl_text_mutex); /* Prepare text log class info. */ if (!wlog_class_registered) { memset(&text_log_class, 0, sizeof(text_log_class)); text_log_class.hInstance = (HINSTANCE)GetModuleHandle(NULL); text_log_class.lpszClassName = "Allegro Text Log"; text_log_class.lpfnWndProc = wlog_text_log_callback; text_log_class.hIcon = NULL; text_log_class.hCursor = NULL; text_log_class.lpszMenuName = NULL; text_log_class.hbrBackground = (HBRUSH)GetStockObject(GRAY_BRUSH); if (RegisterClassA(&text_log_class) == 0) { /* Failure, window class is a basis and we do not have one. */ al_unlock_mutex(textlog->tl_text_mutex); return false; } wlog_class_registered++; } /* Load RichEdit control. */ if (!wlog_rich_edit_module) { if ((wlog_rich_edit_module = _al_open_library("msftedit.dll"))) { /* 4.1 and emulation of 3.0, 2.0, 1.0 */ wlog_edit_control = L"RICHEDIT50W"; /*MSFTEDIT_CLASS*/ wlog_unicode = true; } else if ((wlog_rich_edit_module = _al_open_library("riched20.dll"))) { /* 3.0, 2.0 */ wlog_edit_control = L"RichEdit20W"; /*RICHEDIT_CLASS*/ wlog_unicode = true; } else if ((wlog_rich_edit_module = _al_open_library("riched32.dll"))) { /* 1.0 */ wlog_edit_control = L"RichEdit"; /*RICHEDIT_CLASS*/ wlog_unicode = false; } else { wlog_edit_control = L"EDIT"; wlog_unicode = false; } } /* Create text log window. */ hWnd = CreateWindowA("Allegro Text Log", al_cstr(textlog->title), WS_CAPTION | WS_SIZEBOX | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SYSMENU, CW_USEDEFAULT, CW_USEDEFAULT, 640, 480, NULL, NULL, (HINSTANCE)GetModuleHandle(NULL), textlog); if (!hWnd) { if (wlog_rich_edit_module) { _al_close_library(wlog_rich_edit_module); wlog_rich_edit_module = NULL; } UnregisterClassA("Allegro Text Log", (HINSTANCE)GetModuleHandle(NULL)); al_unlock_mutex(textlog->tl_text_mutex); return false; } /* Get client area of the log window. */ GetClientRect(hWnd, &client_rect); /* Create edit control. */ hLog = CreateWindowW(wlog_edit_control, NULL, WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_MULTILINE | ES_WANTRETURN | ES_AUTOVSCROLL | ES_READONLY, client_rect.left, client_rect.top, client_rect.right - client_rect.left, client_rect.bottom - client_rect.top, hWnd, NULL, (HINSTANCE)GetModuleHandle(NULL), NULL); if (!hLog) { if (wlog_rich_edit_module) { _al_close_library(wlog_rich_edit_module); wlog_rich_edit_module = NULL; } DestroyWindow(hWnd); UnregisterClassA("Allegro Text Log", (HINSTANCE)GetModuleHandle(NULL)); al_unlock_mutex(textlog->tl_text_mutex); return false; } /* Enable double-buffering. */ SetWindowLong(hLog, GWL_EXSTYLE, GetWindowLong(hLog, GWL_EXSTYLE) | 0x02000000L/*WS_EX_COMPOSITED*/); /* Select font name. */ if (textlog->flags & ALLEGRO_TEXTLOG_MONOSPACE) font_name = "Courier New"; else font_name = "Arial"; /* Create font and set font. */ hFont = CreateFont(-11, 0, 0, 0, FW_LIGHT, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_MODERN | FIXED_PITCH, font_name); /* Assign font to the text log. */ if (hFont) { SendMessage(hLog, WM_SETFONT, (WPARAM)hFont, 0); } /* Set background color of RichEdit control. */ if (wlog_rich_edit_module) { SendMessage(hLog, EM_SETBKGNDCOLOR, 0, (LPARAM)RGB(16, 16, 16)); } /* We are ready to show our window. */ ShowWindow(hWnd, SW_NORMAL); /* Save handles for future use. */ textlog->window = hWnd; textlog->tl_textview = hLog; textlog->is_active = true; /* Now notify al_show_native_textlog that the text log is ready. */ textlog->tl_done = true; al_signal_cond(textlog->tl_text_cond); al_unlock_mutex(textlog->tl_text_mutex); /* Process messages. */ while ((ret = GetMessage(&msg, NULL, 0, 0)) != 0) { if (ret != -1 && msg.message != WM_QUIT) { /* Intercept child window key down messages. Needed to track * hit of ESCAPE key while text log have focus. */ if (msg.hwnd != textlog->window && msg.message == WM_KEYDOWN) { PostMessage(textlog->window, WM_KEYDOWN, msg.wParam, msg.lParam); } TranslateMessage(&msg); DispatchMessage(&msg); } else break; } /* Close window. Should be already closed, this is just sanity. */ if (IsWindow(textlog->window)) { DestroyWindow(textlog->window); } /* Release font. We don't want to leave any garbage. */ DeleteObject(hFont); /* Release RichEdit module. */ if (wlog_rich_edit_module) { _al_close_library(wlog_rich_edit_module); wlog_rich_edit_module = NULL; } /* Unregister window class. */ if (--wlog_class_registered == 0) { UnregisterClassA("Allegro Text Log", (HINSTANCE)GetModuleHandle(NULL)); } /* Notify everyone that we're gone. */ al_lock_mutex(textlog->tl_text_mutex); textlog->tl_done = true; al_signal_cond(textlog->tl_text_cond); al_unlock_mutex(textlog->tl_text_mutex); return true; }