PIBIO_SENSOR_ATTACH_FN 콜백 함수(winbio_adapter.h)
센서 어댑터가 생체 인식 단위의 처리 파이프라인에 추가되면 Windows 생체 인식 프레임워크에서 호출됩니다. 이 함수의 목적은 이후 생체 인식 작업에 필요한 초기화를 수행하는 것입니다.
구문
PIBIO_SENSOR_ATTACH_FN PibioSensorAttachFn;
HRESULT PibioSensorAttachFn(
[in, out] PWINBIO_PIPELINE Pipeline
)
{...}
매개 변수
[in, out] Pipeline
작업을 수행하는 생체 인식 단위와 연결된 WINBIO_PIPELINE 구조체에 대한 포인터입니다.
반환 값
함수가 성공하면 S_OK를 반환합니다. 함수가 실패하는 경우 오류를 나타내려면 다음 HRESULT 값 중 하나를 반환해야 합니다.
반환 코드 | 설명 |
---|---|
|
Pipeline 인수는 NULL일 수 없습니다. |
|
메모리가 부족하여 작업을 완료할 수 없습니다. |
|
Pipeline 인수가 가리키는 WINBIO_PIPELINE 구조체의 SensorContext 멤버가 NULL이 아닙니다. |
설명
이 함수는 생체 인식 단위에 대해 엔진 및 스토리지 어댑터를 초기화하기 전에 호출됩니다. 따라서 이 함수는 파이프라인 개체의 EngineInterface 및 StorageInterface 멤버가 가리키는 WINBIO_ENGINE_INTERFACE 또는 WINBIO_STORAGE_INTERFACE 구조체에서 참조하는 함수를 호출해서는 안 됩니다.
WINBIO_PIPELINE 구조체의 SensorHandle 멤버는 이 메서드가 호출되기 전에 유효한 핸들을 포함하므로 SensorAdapterAttach 구현은 필요한 경우 핸들을 사용하여 센서 디바이스에 액세스할 수 있습니다.
이 함수를 구현할 때 어댑터에 필요한 모든 리소스를 할당 및 관리하고 생체 인식 단위 파이프라인에 연결해야 합니다. 이렇게 하려면 힙에 프라이빗 WINBIO_SENSOR_CONTEXT 구조를 할당하고, 초기화하고, 파이프라인 개체의 SensorContext 멤버에서 주소를 설정합니다.
이 함수에서 사용하는 엔진 어댑터 리소스를 만들고 초기화하는 동안 오류가 발생하는 경우 반환하기 전에 필요한 정리를 수행해야 합니다.
이 함수를 호출할 때 SensorContext 필드가 NULL 이 아닌 경우 SensorAdapterDetach 에 대한 이전 호출로 파이프라인이 제대로 다시 설정되지 않았으며 Windows 생체 인식 프레임워크에 문제를 알리기 위해 WINBIO_E_INVALID_DEVICE_STATE 반환해야 합니다.
예제
다음 의사 코드는 이 함수의 가능한 구현 중 하나를 보여 줍니다. 이 예제는 컴파일되지 않습니다. 목적에 맞게 조정해야 합니다.
//////////////////////////////////////////////////////////////////////////////////////////
//
// SensorAdapterAttach
//
// Purpose:
// Performs any initialization required for later biometric operations.
//
// Parameters:
// Pipeline - Pointer to a WINBIO_PIPELINE structure associated with
// the biometric unit performing the operation.
//
static HRESULT
WINAPI
SensorAdapterAttach(
__inout PWINBIO_PIPELINE Pipeline
)
{
HRESULT hr = S_OK;
PWINBIO_SENSOR_CONTEXT newContext = NULL;
// Verify that the Pipeline parameter is not NULL.
if (!ARGUMENT_PRESENT(Pipeline))
{
hr = E_POINTER;
goto cleanup;
}
// Validate the current sensor state.
if (Pipeline->SensorContext != NULL)
{
hr = WINBIO_E_INVALID_DEVICE_STATE;
goto cleanup;
}
// Use a custom function (_AdapterAlloc) to allocate memory for the
// sensor adapter context.
newContext = (PWINBIO_SENSOR_CONTEXT)_AdapterAlloc(sizeof(WINBIO_SENSOR_CONTEXT));
if (newContext == NULL)
{
hr = E_OUTOFMEMORY;
goto cleanup;
}
// Create a manual reset event to monitor overlapped I/O.
newContext->Overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
if (newContext->Overlapped.hEvent == NULL)
{
hr = E_OUTOFMEMORY;
goto cleanup;
}
// Initialize any required context fields. This example assumes that your
// sensor context points to a capture buffer and an attributes buffer.
newContext->CaptureBuffer = NULL;
newContext->CaptureBufferSize = 0;
newContext->AttributesBuffer = NULL;
newContext->AttributesBufferSize = sizeof (WINBIO_SENSOR_ATTRIBUTES);
// Transfer ownership of the new sensor context structure to the
// pipeline.
Pipeline->SensorContext = newContext;
newContext = NULL;
cleanup:
if (FAILED(hr) && newContext != NULL)
{
CloseHandle( newContext->Overlapped.hEvent;
_AdapterRelease( newContext );
newContext = NULL;
}
return hr;
}
요구 사항
요구 사항 | 값 |
---|---|
지원되는 최소 클라이언트 | Windows 7 [데스크톱 앱만 해당] |
지원되는 최소 서버 | Windows Server 2008 R2 [데스크톱 앱만 해당] |
대상 플랫폼 | Windows |
헤더 | winbio_adapter.h(Winbio_adapter.h 포함) |