jxrc_t_pixelFormat jxrc_image_pixelformat(jxr_container_t container, int imagenum) { unsigned char guid[16]; int i; assert(imagenum < container->image_count); unsigned ifd_cnt = container->table_cnt[imagenum]; struct ifd_table*ifd = container->table[imagenum]; unsigned idx; for (idx = 0 ; idx < ifd_cnt ; idx += 1) { if (ifd[idx].tag == 0xbc01) break; } assert(idx < ifd_cnt); assert(ifd[idx].tag == 0xbc01); assert(ifd[idx].cnt == 16); memcpy(guid, ifd[idx].value_.p_byte, 16); for(i=0; i< NUM_GUIDS; i++) { if(isEqualGUID(guid, jxr_guids[i])) { break; } } if(i==NUM_GUIDS) assert(0); return (jxrc_t_pixelFormat)i; }
signed int findCacheItemByGUID(LPGUID lpGuid, bool isSource) { int i; for (i = 0; i < g_cacheCount; i++) { if (isSource == g_audioDeviceCache[i].isSource && isEqualGUID(lpGuid, &(g_audioDeviceCache[i].guid))) { return i; } } return -1; }
bool DS_addDeviceRef(signed int deviceID) { HWND ownerWindow; HRESULT res = DS_OK; LPDIRECTSOUND8 devPlay; LPDIRECTSOUNDCAPTURE8 devCapture; LPGUID lpGuid = NULL; if (g_audioDeviceCache[deviceID].dev == NULL) { /* Create DirectSound */ //TRACE1("Creating DirectSound object for device %d\n", deviceID); lpGuid = &(g_audioDeviceCache[deviceID].guid); if (isEqualGUID(lpGuid, NULL)) { lpGuid = NULL; } if (g_audioDeviceCache[deviceID].isSource) { #if 0 //CoInitialize(NULL); res = DirectSoundCreate8(lpGuid, &devPlay, NULL); //生成DirectSound接口对象 #else res = CoInitializeEx(NULL, 0); res = CoCreateInstance(CLSID_DirectSound8, NULL, CLSCTX_INPROC_SERVER, IID_IDirectSound8, (LPVOID*)&devPlay); devPlay->Initialize(NULL); #endif g_audioDeviceCache[deviceID].dev = (void*) devPlay; } else { res = DirectSoundCaptureCreate8(lpGuid, &devCapture, NULL); g_audioDeviceCache[deviceID].dev = (void*) devCapture; } g_audioDeviceCache[deviceID].refCount = 0; if (FAILED(res)) { ERROR1("DS_addDeviceRef: ERROR: Failed to create DirectSound: %s", TranslateDSError(res)); g_audioDeviceCache[deviceID].dev = NULL; return false; } if (g_audioDeviceCache[deviceID].isSource) { ownerWindow = GetForegroundWindow(); if (ownerWindow == NULL) { ownerWindow = GetDesktopWindow(); } //TRACE0("DS_addDeviceRef: Setting cooperative level\n"); res = devPlay->SetCooperativeLevel(ownerWindow, DSSCL_PRIORITY); //设置应用程序对声音设备的合作级别 if (FAILED(res)) { ERROR1("DS_addDeviceRef: ERROR: Failed to set cooperative level: %s", TranslateDSError(res)); return false; } } } g_audioDeviceCache[deviceID].refCount++; return true; }