* Consolidate logging style

* Linux build break

* Fixing more Linux issues
This commit is contained in:
wes-b 2019-03-27 11:01:19 -07:00 коммит произвёл GitHub
Родитель b3a427b80a
Коммит 36e7f8fb9d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
24 изменённых файлов: 370 добавлений и 471 удалений

Просмотреть файл

@ -56,11 +56,11 @@ used with CPP and destroy being used with C, or vise-vesa, the types get c or cp
pContextWrapper = ALLOCATE(PUB_HANDLE_TYPE(_public_handle_name_)); \
if (pContextWrapper == NULL) \
{ \
IF_LOGGER(logger_error(LOGGER_K4A, "Failed to allocate " #_public_handle_name_);) return NULL; \
IF_LOGGER(LOG_ERROR("Failed to allocate " #_public_handle_name_, 0);) return NULL; \
} \
else \
{ \
IF_LOGGER(logger_trace(LOGGER_K4A, "Created " #_public_handle_name_ " %p", pContextWrapper);) \
IF_LOGGER(LOG_TRACE("Created " #_public_handle_name_ " %p", pContextWrapper);) \
} \
pContextWrapper->handleType = PRIV_HANDLE_TYPE(_public_handle_name_); \
*handle = (_public_handle_name_)pContextWrapper; \
@ -73,7 +73,7 @@ used with CPP and destroy being used with C, or vise-vesa, the types get c or cp
if ((handle == NULL) || \
((PUB_HANDLE_TYPE(_public_handle_name_) *)handle)->handleType != PRIV_HANDLE_TYPE(_public_handle_name_)) \
{ \
IF_LOGGER(logger_error(LOGGER_K4A, "Invalid " #_public_handle_name_ " %p", handle);) \
IF_LOGGER(LOG_ERROR("Invalid " #_public_handle_name_ " %p", handle);) \
return NULL; \
} \
return &(((PUB_HANDLE_TYPE(_public_handle_name_) *)handle)->context); \
@ -83,7 +83,7 @@ used with CPP and destroy being used with C, or vise-vesa, the types get c or cp
static inline void _public_handle_name_##_destroy(_public_handle_name_ handle) \
{ \
(void)_public_handle_name_##_get_context(handle); \
IF_LOGGER(logger_trace(LOGGER_K4A, "Destroyed " #_public_handle_name_ " %p", handle);) \
IF_LOGGER(LOG_TRACE("Destroyed " #_public_handle_name_ " %p", handle);) \
((PUB_HANDLE_TYPE(_public_handle_name_) *)handle)->handleType = NULL; \
DESTROY((PUB_HANDLE_TYPE(_public_handle_name_) *)handle); \
}

Просмотреть файл

@ -37,19 +37,6 @@ K4A_DECLARE_HANDLE(logger_t);
*/
#define LOGGER_K4A "K4A"
#define LOGGER_ALLOCATOR "Allocator"
#define LOGGER_API "K4aApi"
#define LOGGER_CALIBRATION "Calibration"
#define LOGGER_COLOR "Color"
#define LOGGER_COLOR_MCU "ColorMcu"
#define LOGGER_DEPTH "Depth"
#define LOGGER_DEPTH_MCU "DepthMcu"
#define LOGGER_IMU "Imu"
#define LOGGER_LOGGER "Logger"
#define LOGGER_QUEUE "Queue"
#define LOGGER_RECORD "K4aRecordApi"
#define LOGGER_USB_CMD "UsbCmd"
/** Default logging settings
*/
#define K4A_ENABLE_LOG_TO_A_FILE "K4A_ENABLE_LOG_TO_A_FILE"
@ -290,6 +277,8 @@ FORCEINLINE void TraceInvalidHandle(int result,
}
// Logs a message
#define LOG_TRACE(message, ...) \
logger_trace(LOGGER_K4A, "%s (%d): %s(). " message, __FILE__, __LINE__, __func__, __VA_ARGS__)
#define LOG_INFO(message, ...) \
logger_info(LOGGER_K4A, "%s (%d): %s(). " message, __FILE__, __LINE__, __func__, __VA_ARGS__)
#define LOG_WARNING(message, ...) \

Просмотреть файл

@ -150,11 +150,10 @@ template<typename T> T *read_element(k4a_playback_context_t *context, EbmlElemen
}
catch (std::ios_base::failure e)
{
logger_error(LOGGER_RECORD,
"Failed to read element %s in recording '%s': %s",
T::ClassInfos.GetName(),
context->file_path,
e.what());
LOG_ERROR("Failed to read element %s in recording '%s': %s",
T::ClassInfos.GetName(),
context->file_path,
e.what());
return nullptr;
}
}
@ -177,9 +176,8 @@ template<typename T> std::unique_ptr<T> find_next(k4a_playback_context_t *contex
{
if (!element->IsFiniteSize())
{
logger_error(LOGGER_RECORD,
"Failed to read recording: Element Id '%x' has unknown size",
EbmlId(*element).GetValue());
LOG_ERROR("Failed to read recording: Element Id '%x' has unknown size",
EbmlId(*element).GetValue());
delete element;
return nullptr;
}
@ -201,19 +199,16 @@ template<typename T> std::unique_ptr<T> find_next(k4a_playback_context_t *contex
{
if (!search)
{
logger_error(LOGGER_RECORD,
"Failed to read recording: Element Id '%x' not found",
T::ClassInfos.GlobalId.GetValue());
LOG_ERROR("Failed to read recording: Element Id '%x' not found", T::ClassInfos.GlobalId.GetValue());
}
return nullptr;
}
else if (EbmlId(*element) != T::ClassInfos.GlobalId)
{
logger_error(LOGGER_RECORD,
"Failed to read recording: Expected element %s (id %x), found id '%x'",
T::ClassInfos.GetName(),
T::ClassInfos.GlobalId.GetValue(),
EbmlId(*element).GetValue());
LOG_ERROR("Failed to read recording: Expected element %s (id %x), found id '%x'",
T::ClassInfos.GetName(),
T::ClassInfos.GlobalId.GetValue(),
EbmlId(*element).GetValue());
delete element;
return nullptr;
}
@ -222,11 +217,7 @@ template<typename T> std::unique_ptr<T> find_next(k4a_playback_context_t *contex
}
catch (std::ios_base::failure e)
{
logger_error(LOGGER_RECORD,
"Failed to find %s in recording '%s': %s",
T::ClassInfos.GetName(),
context->file_path,
e.what());
LOG_ERROR("Failed to find %s in recording '%s': %s", T::ClassInfos.GetName(), context->file_path, e.what());
return nullptr;
}
}
@ -244,14 +235,14 @@ k4a_result_t read_offset(k4a_playback_context_t *context, std::unique_ptr<T> &el
{
if (read_element<T>(context, element_out.get()) == NULL)
{
logger_error(LOGGER_RECORD, "Failed to read element: %s at offset %llu", typeid(T).name(), offset);
LOG_ERROR("Failed to read element: %s at offset %llu", typeid(T).name(), offset);
return K4A_RESULT_FAILED;
}
return K4A_RESULT_SUCCEEDED;
}
else
{
logger_error(LOGGER_RECORD, "Element not found at offset: %s at offset %llu", typeid(T).name(), offset);
LOG_ERROR("Element not found at offset: %s at offset %llu", typeid(T).name(), offset);
return K4A_RESULT_FAILED;
}
}

Просмотреть файл

@ -156,7 +156,7 @@ long allocator_test_for_leaks(void)
if (g_allocated_image_count_user || g_allocated_image_count_depth || g_allocated_image_count_color ||
g_allocated_image_count_imu || g_allocated_image_count_usb_depth || g_allocated_image_count_usb_imu)
{
logger_critical(LOGGER_ALLOCATOR,
logger_critical(LOGGER_K4A,
"Leaked usr:%d, color:%d, depth:%d, imu:%d, usb depth:%d, usb imu%d",
g_allocated_image_count_user,
g_allocated_image_count_color,

Просмотреть файл

@ -388,7 +388,7 @@ static k4a_result_t get_camera_calibration(char *json, k4a_calibration_camera_t
const char *error_ptr = cJSON_GetErrorPtr();
if (error_ptr != NULL)
{
logger_error(LOGGER_CALIBRATION, "cJSON_Parse error %s", error_ptr);
LOG_ERROR("cJSON_Parse error %s", error_ptr);
}
return K4A_RESULT_FAILED;
}
@ -467,7 +467,7 @@ static k4a_result_t get_imu_calibration(char *json, k4a_calibration_imu_t *cal,
const char *error_ptr = cJSON_GetErrorPtr();
if (error_ptr != NULL)
{
logger_error(LOGGER_CALIBRATION, "cJSON_Parse error %s", error_ptr);
LOG_ERROR("cJSON_Parse error %s", error_ptr);
}
return K4A_RESULT_FAILED;
}

Просмотреть файл

@ -82,10 +82,9 @@ drop_sample(capturesync_context_t *sync, k4a_wait_result_t *wresult, bool color_
if (drop_into_queue)
{
// Log the capture being dropped on the floor
logger_info("capturesync_drop",
"Dropping sample TS:%10lld type:%s",
frame_info->ts,
color_capture ? "Color" : "Depth");
LOG_INFO("capturesync_drop, Dropping sample TS:%10lld type:%s",
frame_info->ts,
color_capture ? "Color" : "Depth");
// If drop_into_queue is provided, then that caller wants the capture to placed into the provided queue, if no
// drop_into_queue is provided, then it is dropped on the floor
@ -139,10 +138,9 @@ drop_sample(capturesync_context_t *sync, k4a_wait_result_t *wresult, bool color_
static void replace_sample(capturesync_context_t *sync, k4a_capture_t capture_new, frame_info_t *frame_info)
{
// Log the capture being dropped
logger_error("capturesync_drop",
"Releasing capture early due to full queue TS:%10lld type:%s",
frame_info->ts,
frame_info->color_capture ? "Color" : "Depth");
LOG_ERROR("capturesync_drop, releasing capture early due to full queue TS:%10lld type:%s",
frame_info->ts,
frame_info->color_capture ? "Color" : "Depth");
if (!sync->synchronized_images_only)
{
@ -203,7 +201,7 @@ void capturesync_add_capture(capturesync_t capturesync_handle,
queue_error(sync->depth_ir.queue);
queue_error(sync->color.queue);
logger_warn("capturesync_link", "Capture Error Detected, %s", color_capture ? "Color " : "Depth ");
LOG_WARNING("Capture Error Detected, %s", color_capture ? "Color " : "Depth ");
// Reflect the low level error in the current result
result = capture_result;
@ -246,12 +244,11 @@ void capturesync_add_capture(capturesync_t capturesync_handle,
{
if (sync->enable_ts_logging)
{
logger_info("capturesync_ts",
"Arriving capture, TS:%10lld, %s, Color TS:%10lld, Depth TS:%10lld",
ts_raw_capture,
color_capture ? "Color " : "Depth ",
sync->color.ts,
sync->depth_ir.ts);
LOG_INFO("capturesync_ts, Arriving capture, TS:%10lld, %s, Color TS:%10lld, Depth TS:%10lld",
ts_raw_capture,
color_capture ? "Color " : "Depth ",
sync->color.ts,
sync->depth_ir.ts);
}
if (sync->sync_captures == false || sync->disable_sync == true)
@ -266,7 +263,7 @@ void capturesync_add_capture(capturesync_t capturesync_handle,
// started. This code protects against the depth timestamps from being reported before the reset happens.
if (ts_raw_capture / sync->fps_period > 10)
{
logger_warn("capturesync_ts", "Dropping depth capture as TS is too large TS:%10lld", ts_raw_capture);
LOG_WARNING("Dropping depth capture as TS is too large TS:%10lld", ts_raw_capture);
result = K4A_RESULT_FAILED; // Not an error, just a graceful exit
}
else
@ -362,10 +359,7 @@ void capturesync_add_capture(capturesync_t capturesync_handle,
{
if (sync->enable_ts_logging)
{
logger_info("capturesync_link",
",TS_Color, %10lld, TS_Depth, %10lld,",
sync->color.ts,
sync->depth_ir.ts);
LOG_INFO("capturesync_link,TS_Color, %10lld, TS_Depth, %10lld,", sync->color.ts, sync->depth_ir.ts);
}
k4a_capture_t merged = merge_captures(sync->depth_ir.capture, sync->color.capture);
@ -382,7 +376,7 @@ void capturesync_add_capture(capturesync_t capturesync_handle,
if (wresult == K4A_WAIT_RESULT_FAILED)
{
sync->running = false;
logger_error("capturesync", "Error encountered access queue");
LOG_ERROR("CaptureSync, error encountered access queue", 0);
}
}
}

Просмотреть файл

@ -122,7 +122,7 @@ void color_capture_available(k4a_result_t result, k4a_capture_t capture_handle,
if (result != K4A_RESULT_SUCCEEDED)
{
assert(capture_handle == NULL);
logger_warn(LOGGER_COLOR, "A streaming color transfer failed");
LOG_WARNING("A streaming color transfer failed", 0);
return;
}
}

Просмотреть файл

@ -44,7 +44,7 @@ CFrameContext::CFrameContext(IMFSample *pSample)
if (FAILED(hr = m_sp2DBuffer->Lock2DSize(
MF2DBuffer_LockFlags_ReadWrite, &pScanline, &lPitch, &m_pBuffer, &m_bufferLength)))
{
logger_error(LOGGER_COLOR, "failed to lock 2D frame buffer: 0x%08x", hr);
LOG_ERROR("failed to lock 2D frame buffer: 0x%08x", hr);
assert(0);
}
}
@ -53,14 +53,14 @@ CFrameContext::CFrameContext(IMFSample *pSample)
m_sp2DBuffer = nullptr; // Make sure 2D buffer is not set.
if (FAILED(hr = m_spMediaBuffer->Lock(&m_pBuffer, nullptr, &m_bufferLength)))
{
logger_error(LOGGER_COLOR, "failed to lock frame buffer: 0x%08x", hr);
LOG_ERROR("failed to lock frame buffer: 0x%08x", hr);
assert(0);
}
}
}
else
{
logger_error(LOGGER_COLOR, "failed to get color frame media buffer: 0x%08x", hr);
LOG_ERROR("failed to get color frame media buffer: 0x%08x", hr);
assert(0);
}
@ -109,9 +109,7 @@ CFrameContext::CFrameContext(IMFSample *pSample)
if (pItem->Size == 0)
{
logger_error(LOGGER_COLOR,
"frame metadata id %d has zero buffer size",
pItem->MetadataId);
LOG_ERROR("frame metadata id %d has zero buffer size", pItem->MetadataId);
break;
}
@ -128,14 +126,14 @@ CFrameContext::CFrameContext(IMFSample *pSample)
if (FAILED(hr = spRawMetadataBuffer->Unlock()))
{
logger_error(LOGGER_COLOR, "failed to unlock metadata raw buffer: 0x%08x", hr);
LOG_ERROR("failed to unlock metadata raw buffer: 0x%08x", hr);
}
}
}
}
else
{
logger_warn(LOGGER_COLOR, "No metadata attached to the sample");
LOG_WARNING("No metadata attached to the sample", 0);
}
}
}
@ -150,7 +148,7 @@ CFrameContext::~CFrameContext()
{
if (FAILED(hr = m_sp2DBuffer->Unlock2D()))
{
logger_error(LOGGER_COLOR, "failed to unlock 2D frame buffer: 0x%08x", hr);
LOG_ERROR("failed to unlock 2D frame buffer: 0x%08x", hr);
assert(0);
}
}
@ -158,7 +156,7 @@ CFrameContext::~CFrameContext()
{
if (FAILED(hr = m_spMediaBuffer->Unlock()))
{
logger_error(LOGGER_COLOR, "failed to unlock frame buffer: 0x%08x", hr);
LOG_ERROR("failed to unlock frame buffer: 0x%08x", hr);
assert(0);
}
}
@ -196,7 +194,7 @@ CMFCameraReader::~CMFCameraReader()
HRESULT hr = MFShutdown();
if (FAILED(hr))
{
logger_error(LOGGER_COLOR, "MFShutdown failed: 0x%08x", hr);
LOG_ERROR("MFShutdown failed: 0x%08x", hr);
}
}
@ -219,52 +217,52 @@ HRESULT CMFCameraReader::RuntimeClassInitialize(GUID *containerId)
// Find Color Camera
if (FAILED(hr = FindEdenColorCamera(containerId, spDevice)))
{
logger_error(LOGGER_COLOR, "Failed to find color camera in open camera: 0x%08x", hr);
LOG_ERROR("Failed to find color camera in open camera: 0x%08x", hr);
return hr;
}
// Activate Color Media Source
if (FAILED(hr = spDevice->ActivateObject(IID_PPV_ARGS(&spColorSource))))
{
logger_error(LOGGER_COLOR, "Failed to activate source in open camera: 0x%08x", hr);
LOG_ERROR("Failed to activate source in open camera: 0x%08x", hr);
return hr;
}
// Create Source Reader
if (FAILED(hr = MFCreateAttributes(&spAttributes, 3)))
{
logger_error(LOGGER_COLOR, "Failed to create attribute bag in open camera: 0x%08x", hr);
LOG_ERROR("Failed to create attribute bag in open camera: 0x%08x", hr);
return hr;
}
if (FAILED(hr = spAttributes->SetUnknown(MF_SOURCE_READER_ASYNC_CALLBACK, this)))
{
logger_error(LOGGER_COLOR, "Failed to register callback in open camera: 0x%08x", hr);
LOG_ERROR("Failed to register callback in open camera: 0x%08x", hr);
return hr;
}
if (FAILED(hr = spAttributes->SetUINT32(MF_SOURCE_READER_ENABLE_ADVANCED_VIDEO_PROCESSING, 1)))
{
logger_error(LOGGER_COLOR, "Failed to set Advanced video processing: 0x%08x", hr);
LOG_ERROR("Failed to set Advanced video processing: 0x%08x", hr);
return hr;
}
if (FAILED(hr = spAttributes->SetUINT32(MF_XVP_DISABLE_FRC, 1)))
{
logger_error(LOGGER_COLOR, "Failed to disable frame rate control: 0x%08x", hr);
LOG_ERROR("Failed to disable frame rate control: 0x%08x", hr);
return hr;
}
if (FAILED(
hr = MFCreateSourceReaderFromMediaSource(spColorSource.Get(), spAttributes.Get(), &m_spSourceReader)))
{
logger_error(LOGGER_COLOR, "Failed to create reader in open camera: 0x%08x", hr);
LOG_ERROR("Failed to create reader in open camera: 0x%08x", hr);
return hr;
}
if (FAILED(hr = m_spSourceReader->SetStreamSelection((DWORD)MF_SOURCE_READER_ALL_STREAMS, FALSE)))
{
logger_error(LOGGER_COLOR, "Failed to deselect stream in open camera: 0x%08x", hr);
LOG_ERROR("Failed to deselect stream in open camera: 0x%08x", hr);
return hr;
}
@ -273,7 +271,7 @@ HRESULT CMFCameraReader::RuntimeClassInitialize(GUID *containerId)
GUID_NULL,
IID_PPV_ARGS(&m_spKsControl))))
{
logger_error(LOGGER_COLOR, "Failed to get camera control interface in open camera: 0x%08x", hr);
LOG_ERROR("Failed to get camera control interface in open camera: 0x%08x", hr);
return hr;
}
@ -281,7 +279,7 @@ HRESULT CMFCameraReader::RuntimeClassInitialize(GUID *containerId)
if (m_hStreamFlushed == NULL || m_hStreamFlushed == INVALID_HANDLE_VALUE)
{
hr = HRESULT_FROM_WIN32(GetLastError());
logger_error(LOGGER_COLOR, "Failed to create event in open camera: 0x%08x", hr);
LOG_ERROR("Failed to create event in open camera: 0x%08x", hr);
return hr;
}
}
@ -328,7 +326,7 @@ k4a_result_t CMFCameraReader::Start(const UINT32 width,
guidOutputSubType = MFVideoFormat_ARGB32;
break;
default:
logger_error(LOGGER_COLOR, "Image Format %d is invalid", imageFormat);
LOG_ERROR("Image Format %d is invalid", imageFormat);
return K4A_RESULT_FAILED;
}
@ -355,7 +353,7 @@ k4a_result_t CMFCameraReader::Start(const UINT32 width,
if (FAILED(hr = MFGetAttributeSize(spMediaType.Get(), MF_MT_FRAME_SIZE, &tempWidth, &tempHeight)))
{
logger_error(LOGGER_COLOR, "Failed to get available frame size at start: 0x%08x", hr);
LOG_ERROR("Failed to get available frame size at start: 0x%08x", hr);
return k4aResultFromHRESULT(hr);
}
if (FAILED(hr = MFGetAttributeRatio(spMediaType.Get(),
@ -363,12 +361,12 @@ k4a_result_t CMFCameraReader::Start(const UINT32 width,
&tempFpsNumerator,
&tempFpsDenominator)))
{
logger_error(LOGGER_COLOR, "Failed to get available frame rate at start: 0x%08x", hr);
LOG_ERROR("Failed to get available frame rate at start: 0x%08x", hr);
return k4aResultFromHRESULT(hr);
}
if (FAILED(hr = spMediaType->GetGUID(MF_MT_SUBTYPE, &tempSubType)))
{
logger_error(LOGGER_COLOR, "Failed to get available color format at start: 0x%08x", hr);
LOG_ERROR("Failed to get available color format at start: 0x%08x", hr);
return k4aResultFromHRESULT(hr);
}
@ -384,7 +382,7 @@ k4a_result_t CMFCameraReader::Start(const UINT32 width,
}
else
{
logger_error(LOGGER_COLOR, "Failed to enumerate media type at start: 0x%08x", hr);
LOG_ERROR("Failed to enumerate media type at start: 0x%08x", hr);
return k4aResultFromHRESULT(hr);
}
@ -398,7 +396,7 @@ k4a_result_t CMFCameraReader::Start(const UINT32 width,
if (FAILED(hr = m_spSourceReader.As(&spSourceReaderEx)))
{
logger_error(LOGGER_COLOR, "Failed to get source reader extension at start: 0x%08x", hr);
LOG_ERROR("Failed to get source reader extension at start: 0x%08x", hr);
return k4aResultFromHRESULT(hr);
}
DWORD dwStreamFlags = 0;
@ -407,7 +405,7 @@ k4a_result_t CMFCameraReader::Start(const UINT32 width,
spMediaType.Get(),
&dwStreamFlags)))
{
logger_error(LOGGER_COLOR, "Failed to set media type at start: 0x%08x", hr);
LOG_ERROR("Failed to set media type at start: 0x%08x", hr);
return k4aResultFromHRESULT(hr);
}
@ -416,21 +414,21 @@ k4a_result_t CMFCameraReader::Start(const UINT32 width,
// Create Output Media type
if (FAILED(hr = MFCreateMediaType(&spOutputMediaType)))
{
logger_error(LOGGER_COLOR, "Failed to create output media type at start: 0x%08x", hr);
LOG_ERROR("Failed to create output media type at start: 0x%08x", hr);
return k4aResultFromHRESULT(hr);
}
// Copy all items from device type to output type
if (FAILED(hr = spMediaType->CopyAllItems(spOutputMediaType.Get())))
{
logger_error(LOGGER_COLOR, "Failed to copy device type to output type at start: 0x%08x", hr);
LOG_ERROR("Failed to copy device type to output type at start: 0x%08x", hr);
return k4aResultFromHRESULT(hr);
}
// Modify output media type
if (FAILED(hr = spOutputMediaType->SetGUID(MF_MT_SUBTYPE, guidOutputSubType)))
{
logger_error(LOGGER_COLOR, "Failed to set output subtype at start: 0x%08x", hr);
LOG_ERROR("Failed to set output subtype at start: 0x%08x", hr);
return k4aResultFromHRESULT(hr);
}
}
@ -443,13 +441,13 @@ k4a_result_t CMFCameraReader::Start(const UINT32 width,
nullptr,
spOutputMediaType.Get())))
{
logger_error(LOGGER_COLOR, "Failed to set output media type at start: 0x%08x", hr);
LOG_ERROR("Failed to set output media type at start: 0x%08x", hr);
return k4aResultFromHRESULT(hr);
}
}
else
{
logger_error(LOGGER_COLOR, "Can not find requested sensor mode");
LOG_ERROR("Can not find requested sensor mode", 0);
return K4A_RESULT_FAILED;
}
@ -471,17 +469,17 @@ k4a_result_t CMFCameraReader::Start(const UINT32 width,
}
else
{
logger_error(LOGGER_COLOR, "Failed to request first sample at start: 0x%08x", hr);
LOG_ERROR("Failed to request first sample at start: 0x%08x", hr);
}
}
else
{
logger_error(LOGGER_COLOR, "Failed to select stream at start: 0x%08x", hr);
LOG_ERROR("Failed to select stream at start: 0x%08x", hr);
}
}
else
{
logger_warn(LOGGER_COLOR, "Start request in started state");
LOG_WARNING("Start request in started state", 0);
}
return k4aResultFromHRESULT(hr);
@ -514,7 +512,7 @@ void CMFCameraReader::Stop()
}
else
{
logger_error(LOGGER_COLOR, "Failed to request flush for stop: 0x%08x", hr);
LOG_ERROR("Failed to request flush for stop: 0x%08x", hr);
}
lock.Unlock(); // Wait without lock
@ -885,14 +883,14 @@ STDMETHODIMP CMFCameraReader::OnReadSample(HRESULT hrStatus,
if (FAILED(hr = m_spSourceReader->ReadSample(
(DWORD)MF_SOURCE_READER_FIRST_VIDEO_STREAM, 0, nullptr, nullptr, nullptr, nullptr)))
{
logger_error(LOGGER_COLOR, "Failed to request sample: 0x%08x", hr);
LOG_ERROR("Failed to request sample: 0x%08x", hr);
}
}
}
else
{
hr = hrStatus;
logger_error(LOGGER_COLOR, "Pipeline propagate error to callback: 0x%08x", hr);
LOG_ERROR("Pipeline propagate error to callback: 0x%08x", hr);
// Notify upper layers of failed status
m_pCallback(K4A_RESULT_FAILED, NULL, m_pCallbackContext);
}
@ -924,15 +922,13 @@ STDMETHODIMP CMFCameraReader::OnFlush(DWORD dwStreamIndex)
}
else
{
logger_error(LOGGER_COLOR, "Failed to deselect stream for stop: 0x%08x", hr);
LOG_ERROR("Failed to deselect stream for stop: 0x%08x", hr);
}
}
if (SetEvent(m_hStreamFlushed) == 0)
{
logger_error(LOGGER_COLOR,
"Failed to set flushed event after flushing: 0x%08x",
HRESULT_FROM_WIN32(GetLastError()));
LOG_ERROR("Failed to set flushed event after flushing: 0x%08x", HRESULT_FROM_WIN32(GetLastError()));
}
m_flushing = false;
@ -959,7 +955,7 @@ HRESULT CMFCameraReader::FindEdenColorCamera(GUID *containerId, ComPtr<IMFActiva
hr = MFCreateAttributes(&spConfig, 2);
if (FAILED(hr))
{
logger_error(LOGGER_COLOR, "Failed to create attribute bag to find color camera: 0x%08x", hr);
LOG_ERROR("Failed to create attribute bag to find color camera: 0x%08x", hr);
goto exit;
}
@ -967,7 +963,7 @@ HRESULT CMFCameraReader::FindEdenColorCamera(GUID *containerId, ComPtr<IMFActiva
hr = spConfig->SetGUID(MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE, MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID);
if (FAILED(hr))
{
logger_error(LOGGER_COLOR, "Failed to set video capture attribute to find color camera: 0x%08x", hr);
LOG_ERROR("Failed to set video capture attribute to find color camera: 0x%08x", hr);
goto exit;
}
@ -975,7 +971,7 @@ HRESULT CMFCameraReader::FindEdenColorCamera(GUID *containerId, ComPtr<IMFActiva
hr = spConfig->SetGUID(MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_CATEGORY, vidcapCategoryGuid);
if (FAILED(hr))
{
logger_error(LOGGER_COLOR, "Failed to set video category to find color camera: 0x%08x", hr);
LOG_ERROR("Failed to set video category to find color camera: 0x%08x", hr);
goto exit;
}
@ -983,7 +979,7 @@ HRESULT CMFCameraReader::FindEdenColorCamera(GUID *containerId, ComPtr<IMFActiva
hr = MFEnumDeviceSources(spConfig.Get(), &ppDevices, &count);
if (FAILED(hr))
{
logger_error(LOGGER_COLOR, "Failed to enumerate device: 0x%08x", hr);
LOG_ERROR("Failed to enumerate device: 0x%08x", hr);
goto exit;
}

Просмотреть файл

@ -32,7 +32,7 @@ k4a_result_t UVCCameraReader::Init(const char *serialNumber)
{
if (IsInitialized())
{
logger_error(LOGGER_COLOR, "Camera reader is already initialized");
LOG_ERROR("Camera reader is already initialized", 0);
return K4A_RESULT_FAILED;
}
@ -42,7 +42,7 @@ k4a_result_t UVCCameraReader::Init(const char *serialNumber)
uvc_error_t res = uvc_init(&m_pContext, NULL);
if (res < 0)
{
logger_error(LOGGER_COLOR, "Failed to initialize libuvc: %s", uvc_strerror(res));
LOG_ERROR("Failed to initialize libuvc: %s", uvc_strerror(res));
return K4A_RESULT_FAILED;
}
@ -50,7 +50,7 @@ k4a_result_t UVCCameraReader::Init(const char *serialNumber)
res = uvc_find_device(m_pContext, &m_pDevice, COLOR_CAMERA_VID, COLOR_CAMERA_PID, serialNumber);
if (res < 0)
{
logger_error(LOGGER_COLOR, "Can't find UVC device: %s", uvc_strerror(res));
LOG_ERROR("Can't find UVC device: %s", uvc_strerror(res));
Shutdown();
return K4A_RESULT_FAILED;
@ -60,7 +60,7 @@ k4a_result_t UVCCameraReader::Init(const char *serialNumber)
res = uvc_open(m_pDevice, &m_pDeviceHandle);
if (res < 0)
{
logger_error(LOGGER_COLOR, "Can't open UVC device: %s", uvc_strerror(res));
LOG_ERROR("Can't open UVC device: %s", uvc_strerror(res));
Shutdown();
return K4A_RESULT_FAILED;
@ -82,13 +82,13 @@ k4a_result_t UVCCameraReader::Start(const uint32_t width,
if (!IsInitialized())
{
logger_error(LOGGER_COLOR, "Camera reader is not initialized");
LOG_ERROR("Camera reader is not initialized", 0);
return K4A_RESULT_FAILED;
}
if (m_streaming)
{
logger_error(LOGGER_COLOR, "Camera stream already started");
LOG_ERROR("Camera stream already started", 0);
return K4A_RESULT_FAILED;
}
@ -121,7 +121,7 @@ k4a_result_t UVCCameraReader::Start(const uint32_t width,
frameFormat = UVC_COLOR_FORMAT_MJPEG;
break;
default:
logger_error(LOGGER_COLOR, "Unsupported format %d", imageFormat);
LOG_ERROR("Unsupported format %d", imageFormat);
return K4A_RESULT_FAILED;
}
@ -134,13 +134,12 @@ k4a_result_t UVCCameraReader::Start(const uint32_t width,
if (res < 0)
{
logger_error(LOGGER_COLOR,
"Failed to get stream control for resolution (%d, %d) - %d fps - format (%d): %s",
width,
height,
(int)fps,
imageFormat,
uvc_strerror(res));
LOG_ERROR("Failed to get stream control for resolution (%d, %d) - %d fps - format (%d): %s",
width,
height,
(int)fps,
imageFormat,
uvc_strerror(res));
return K4A_RESULT_FAILED;
}
@ -151,7 +150,7 @@ k4a_result_t UVCCameraReader::Start(const uint32_t width,
res = uvc_start_streaming(m_pDeviceHandle, &ctrl, UVCFrameCallback, this, 0);
if (res < 0)
{
logger_error(LOGGER_COLOR, "Failed to start streaming: %s", uvc_strerror(res));
LOG_ERROR("Failed to start streaming: %s", uvc_strerror(res));
// Clear
m_width_pixels = 0;
@ -174,7 +173,7 @@ void UVCCameraReader::Stop()
{
if (!IsInitialized())
{
logger_warn(LOGGER_COLOR, "Camera reader is not initialized but in streaming state");
LOG_WARNING("Camera reader is not initialized but in streaming state", 0);
}
m_streaming = false;
@ -231,7 +230,7 @@ k4a_result_t UVCCameraReader::GetCameraControl(const k4a_color_control_command_t
RETURN_VALUE_IF_ARG(K4A_RESULT_FAILED, pValue == NULL);
if (!IsInitialized())
{
logger_error(LOGGER_COLOR, "Camera reader is not initialized");
LOG_ERROR("Camera reader is not initialized", 0);
return K4A_RESULT_FAILED;
}
uvc_error_t res = UVC_SUCCESS;
@ -247,7 +246,7 @@ k4a_result_t UVCCameraReader::GetCameraControl(const k4a_color_control_command_t
res = uvc_get_ae_mode(m_pDeviceHandle, &ae_mode, UVC_GET_CUR);
if (res < 0)
{
logger_error(LOGGER_COLOR, "Failed to get auto exposure mode: %s", uvc_strerror(res));
LOG_ERROR("Failed to get auto exposure mode: %s", uvc_strerror(res));
return K4A_RESULT_FAILED;
}
@ -261,7 +260,7 @@ k4a_result_t UVCCameraReader::GetCameraControl(const k4a_color_control_command_t
}
else
{
logger_error(LOGGER_COLOR, "Invalid auto exposure mode returned: %d", ae_mode);
LOG_ERROR("Invalid auto exposure mode returned: %d", ae_mode);
return K4A_RESULT_FAILED;
}
@ -269,7 +268,7 @@ k4a_result_t UVCCameraReader::GetCameraControl(const k4a_color_control_command_t
res = uvc_get_exposure_abs(m_pDeviceHandle, &exposure_time, UVC_GET_CUR);
if (res < 0)
{
logger_error(LOGGER_COLOR, "Failed to get exposure time abs: %s", uvc_strerror(res));
LOG_ERROR("Failed to get exposure time abs: %s", uvc_strerror(res));
return K4A_RESULT_FAILED;
}
@ -282,7 +281,7 @@ k4a_result_t UVCCameraReader::GetCameraControl(const k4a_color_control_command_t
res = uvc_get_ae_priority(m_pDeviceHandle, &priority, UVC_GET_CUR);
if (res < 0)
{
logger_error(LOGGER_COLOR, "Failed to get auto exposure priority: %s", uvc_strerror(res));
LOG_ERROR("Failed to get auto exposure priority: %s", uvc_strerror(res));
return K4A_RESULT_FAILED;
}
*pValue = (int32_t)priority;
@ -294,7 +293,7 @@ k4a_result_t UVCCameraReader::GetCameraControl(const k4a_color_control_command_t
res = uvc_get_brightness(m_pDeviceHandle, &brightness, UVC_GET_CUR);
if (res < 0)
{
logger_error(LOGGER_COLOR, "Failed to get brightness: %s", uvc_strerror(res));
LOG_ERROR("Failed to get brightness: %s", uvc_strerror(res));
return K4A_RESULT_FAILED;
}
*pValue = (int32_t)brightness;
@ -306,7 +305,7 @@ k4a_result_t UVCCameraReader::GetCameraControl(const k4a_color_control_command_t
res = uvc_get_contrast(m_pDeviceHandle, &contrast, UVC_GET_CUR);
if (res < 0)
{
logger_error(LOGGER_COLOR, "Failed to get contrast: %s", uvc_strerror(res));
LOG_ERROR("Failed to get contrast: %s", uvc_strerror(res));
return K4A_RESULT_FAILED;
}
*pValue = (int32_t)contrast;
@ -318,7 +317,7 @@ k4a_result_t UVCCameraReader::GetCameraControl(const k4a_color_control_command_t
res = uvc_get_saturation(m_pDeviceHandle, &saturation, UVC_GET_CUR);
if (res < 0)
{
logger_error(LOGGER_COLOR, "Failed to get saturation: %s", uvc_strerror(res));
LOG_ERROR("Failed to get saturation: %s", uvc_strerror(res));
return K4A_RESULT_FAILED;
}
*pValue = (int32_t)saturation;
@ -330,7 +329,7 @@ k4a_result_t UVCCameraReader::GetCameraControl(const k4a_color_control_command_t
res = uvc_get_sharpness(m_pDeviceHandle, &sharpness, UVC_GET_CUR);
if (res < 0)
{
logger_error(LOGGER_COLOR, "Failed to get sharpness: %s", uvc_strerror(res));
LOG_ERROR("Failed to get sharpness: %s", uvc_strerror(res));
return K4A_RESULT_FAILED;
}
*pValue = (int32_t)sharpness;
@ -344,7 +343,7 @@ k4a_result_t UVCCameraReader::GetCameraControl(const k4a_color_control_command_t
res = uvc_get_white_balance_temperature_auto(m_pDeviceHandle, &wb_mode, UVC_GET_CUR);
if (res < 0)
{
logger_error(LOGGER_COLOR, "Failed to get auto white balance temperature mode: %s", uvc_strerror(res));
LOG_ERROR("Failed to get auto white balance temperature mode: %s", uvc_strerror(res));
return K4A_RESULT_FAILED;
}
@ -358,7 +357,7 @@ k4a_result_t UVCCameraReader::GetCameraControl(const k4a_color_control_command_t
}
else
{
logger_error(LOGGER_COLOR, "Invalid auto white balance temperature mode returned: %d", wb_mode);
LOG_ERROR("Invalid auto white balance temperature mode returned: %d", wb_mode);
return K4A_RESULT_FAILED;
}
@ -366,7 +365,7 @@ k4a_result_t UVCCameraReader::GetCameraControl(const k4a_color_control_command_t
res = uvc_get_white_balance_temperature(m_pDeviceHandle, &white_balance, UVC_GET_CUR);
if (res < 0)
{
logger_error(LOGGER_COLOR, "Failed to get white balance temperature: %s", uvc_strerror(res));
LOG_ERROR("Failed to get white balance temperature: %s", uvc_strerror(res));
return K4A_RESULT_FAILED;
}
@ -379,7 +378,7 @@ k4a_result_t UVCCameraReader::GetCameraControl(const k4a_color_control_command_t
res = uvc_get_backlight_compensation(m_pDeviceHandle, &backlight_compensation, UVC_GET_CUR);
if (res < 0)
{
logger_error(LOGGER_COLOR, "Failed to get backlight compensation: %s", uvc_strerror(res));
LOG_ERROR("Failed to get backlight compensation: %s", uvc_strerror(res));
return K4A_RESULT_FAILED;
}
*pValue = (int32_t)backlight_compensation;
@ -391,7 +390,7 @@ k4a_result_t UVCCameraReader::GetCameraControl(const k4a_color_control_command_t
res = uvc_get_gain(m_pDeviceHandle, &gain, UVC_GET_CUR);
if (res < 0)
{
logger_error(LOGGER_COLOR, "Failed to get gain: %s", uvc_strerror(res));
LOG_ERROR("Failed to get gain: %s", uvc_strerror(res));
return K4A_RESULT_FAILED;
}
*pValue = (int32_t)gain;
@ -403,14 +402,14 @@ k4a_result_t UVCCameraReader::GetCameraControl(const k4a_color_control_command_t
res = uvc_get_power_line_frequency(m_pDeviceHandle, &powerline_freq, UVC_GET_CUR);
if (res < 0)
{
logger_error(LOGGER_COLOR, "Failed to get powerline frequency: %s", uvc_strerror(res));
LOG_ERROR("Failed to get powerline frequency: %s", uvc_strerror(res));
return K4A_RESULT_FAILED;
}
*pValue = (int32_t)powerline_freq;
}
break;
default:
logger_error(LOGGER_COLOR, "Unsupported control: %d\n", command);
LOG_ERROR("Unsupported control: %d\n", command);
return K4A_RESULT_FAILED;
}
@ -423,7 +422,7 @@ k4a_result_t UVCCameraReader::SetCameraControl(const k4a_color_control_command_t
{
if (!IsInitialized())
{
logger_error(LOGGER_COLOR, "Camera reader is not initialized");
LOG_ERROR("Camera reader is not initialized", 0);
return K4A_RESULT_FAILED;
}
uvc_error_t res = UVC_SUCCESS;
@ -438,14 +437,14 @@ k4a_result_t UVCCameraReader::SetCameraControl(const k4a_color_control_command_t
res = uvc_set_ae_mode(m_pDeviceHandle, UVC_AUTO_EXPOSURE_MODE_MANUAL);
if (res < 0)
{
logger_error(LOGGER_COLOR, "Failed to set auto exposure mode: %s", uvc_strerror(res));
LOG_ERROR("Failed to set auto exposure mode: %s", uvc_strerror(res));
return K4A_RESULT_FAILED;
}
res = uvc_set_exposure_abs(m_pDeviceHandle, exposure_time);
if (res < 0)
{
logger_error(LOGGER_COLOR, "Failed to set exposure time abs: %s", uvc_strerror(res));
LOG_ERROR("Failed to set exposure time abs: %s", uvc_strerror(res));
return K4A_RESULT_FAILED;
}
}
@ -454,13 +453,13 @@ k4a_result_t UVCCameraReader::SetCameraControl(const k4a_color_control_command_t
res = uvc_set_ae_mode(m_pDeviceHandle, UVC_AUTO_EXPOSURE_MODE_APERTURE_PRIORITY);
if (res < 0)
{
logger_error(LOGGER_COLOR, "Failed to set auto exposure mode: %s", uvc_strerror(res));
LOG_ERROR("Failed to set auto exposure mode: %s", uvc_strerror(res));
return K4A_RESULT_FAILED;
}
}
else
{
logger_error(LOGGER_COLOR, "Invalid color control mode\n");
LOG_ERROR("Invalid color control mode\n", 0);
return K4A_RESULT_FAILED;
}
break;
@ -470,13 +469,13 @@ k4a_result_t UVCCameraReader::SetCameraControl(const k4a_color_control_command_t
res = uvc_set_ae_priority(m_pDeviceHandle, (uint8_t)newValue);
if (res < 0)
{
logger_error(LOGGER_COLOR, "Failed to set auto exposure priority: %s", uvc_strerror(res));
LOG_ERROR("Failed to set auto exposure priority: %s", uvc_strerror(res));
return K4A_RESULT_FAILED;
}
}
else
{
logger_error(LOGGER_COLOR, "Invalid color control mode\n");
LOG_ERROR("Invalid color control mode\n", 0);
return K4A_RESULT_FAILED;
}
break;
@ -486,13 +485,13 @@ k4a_result_t UVCCameraReader::SetCameraControl(const k4a_color_control_command_t
res = uvc_set_brightness(m_pDeviceHandle, (int16_t)newValue);
if (res < 0)
{
logger_error(LOGGER_COLOR, "Failed to set brightness: %s", uvc_strerror(res));
LOG_ERROR("Failed to set brightness: %s", uvc_strerror(res));
return K4A_RESULT_FAILED;
}
}
else
{
logger_error(LOGGER_COLOR, "Invalid color control mode\n");
LOG_ERROR("Invalid color control mode\n", 0);
return K4A_RESULT_FAILED;
}
break;
@ -502,13 +501,13 @@ k4a_result_t UVCCameraReader::SetCameraControl(const k4a_color_control_command_t
res = uvc_set_contrast(m_pDeviceHandle, (uint16_t)newValue);
if (res < 0)
{
logger_error(LOGGER_COLOR, "Failed to set contrast: %s", uvc_strerror(res));
LOG_ERROR("Failed to set contrast: %s", uvc_strerror(res));
return K4A_RESULT_FAILED;
}
}
else
{
logger_error(LOGGER_COLOR, "Invalid color control mode\n");
LOG_ERROR("Invalid color control mode\n", 0);
return K4A_RESULT_FAILED;
}
break;
@ -518,13 +517,13 @@ k4a_result_t UVCCameraReader::SetCameraControl(const k4a_color_control_command_t
res = uvc_set_saturation(m_pDeviceHandle, (uint16_t)newValue);
if (res < 0)
{
logger_error(LOGGER_COLOR, "Failed to set saturation: %s", uvc_strerror(res));
LOG_ERROR("Failed to set saturation: %s", uvc_strerror(res));
return K4A_RESULT_FAILED;
}
}
else
{
logger_error(LOGGER_COLOR, "Invalid color control mode\n");
LOG_ERROR("Invalid color control mode\n", 0);
return K4A_RESULT_FAILED;
}
break;
@ -534,13 +533,13 @@ k4a_result_t UVCCameraReader::SetCameraControl(const k4a_color_control_command_t
res = uvc_set_sharpness(m_pDeviceHandle, (uint16_t)newValue);
if (res < 0)
{
logger_error(LOGGER_COLOR, "Failed to set sharpness: %s", uvc_strerror(res));
LOG_ERROR("Failed to set sharpness: %s", uvc_strerror(res));
return K4A_RESULT_FAILED;
}
}
else
{
logger_error(LOGGER_COLOR, "Invalid color control mode\n");
LOG_ERROR("Invalid color control mode\n", 0);
return K4A_RESULT_FAILED;
}
break;
@ -550,14 +549,14 @@ k4a_result_t UVCCameraReader::SetCameraControl(const k4a_color_control_command_t
res = uvc_set_white_balance_temperature_auto(m_pDeviceHandle, 0);
if (res < 0)
{
logger_error(LOGGER_COLOR, "Failed to set auto white balance temperature mode: %s", uvc_strerror(res));
LOG_ERROR("Failed to set auto white balance temperature mode: %s", uvc_strerror(res));
return K4A_RESULT_FAILED;
}
res = uvc_set_white_balance_temperature(m_pDeviceHandle, (uint16_t)newValue);
if (res < 0)
{
logger_error(LOGGER_COLOR, "Failed to set white balance temerature: %s", uvc_strerror(res));
LOG_ERROR("Failed to set white balance temerature: %s", uvc_strerror(res));
return K4A_RESULT_FAILED;
}
}
@ -566,13 +565,13 @@ k4a_result_t UVCCameraReader::SetCameraControl(const k4a_color_control_command_t
res = uvc_set_white_balance_temperature_auto(m_pDeviceHandle, 1);
if (res < 0)
{
logger_error(LOGGER_COLOR, "Failed to set auto white balance temperature mode: %s", uvc_strerror(res));
LOG_ERROR("Failed to set auto white balance temperature mode: %s", uvc_strerror(res));
return K4A_RESULT_FAILED;
}
}
else
{
logger_error(LOGGER_COLOR, "Invalid color control mode\n");
LOG_ERROR("Invalid color control mode\n", 0);
return K4A_RESULT_FAILED;
}
break;
@ -582,13 +581,13 @@ k4a_result_t UVCCameraReader::SetCameraControl(const k4a_color_control_command_t
res = uvc_set_backlight_compensation(m_pDeviceHandle, (uint16_t)newValue);
if (res < 0)
{
logger_error(LOGGER_COLOR, "Failed to set backlight compensation: %s", uvc_strerror(res));
LOG_ERROR("Failed to set backlight compensation: %s", uvc_strerror(res));
return K4A_RESULT_FAILED;
}
}
else
{
logger_error(LOGGER_COLOR, "Invalid color control mode\n");
LOG_ERROR("Invalid color control mode\n", 0);
return K4A_RESULT_FAILED;
}
break;
@ -598,13 +597,13 @@ k4a_result_t UVCCameraReader::SetCameraControl(const k4a_color_control_command_t
res = uvc_set_gain(m_pDeviceHandle, (uint16_t)newValue);
if (res < 0)
{
logger_error(LOGGER_COLOR, "Failed to set gain: %s", uvc_strerror(res));
LOG_ERROR("Failed to set gain: %s", uvc_strerror(res));
return K4A_RESULT_FAILED;
}
}
else
{
logger_error(LOGGER_COLOR, "Invalid color control mode\n");
LOG_ERROR("Invalid color control mode\n", 0);
return K4A_RESULT_FAILED;
}
break;
@ -614,18 +613,18 @@ k4a_result_t UVCCameraReader::SetCameraControl(const k4a_color_control_command_t
res = uvc_set_power_line_frequency(m_pDeviceHandle, (uint8_t)newValue);
if (res < 0)
{
logger_error(LOGGER_COLOR, "Failed to set powerline frequency: %s", uvc_strerror(res));
LOG_ERROR("Failed to set powerline frequency: %s", uvc_strerror(res));
return K4A_RESULT_FAILED;
}
}
else
{
logger_error(LOGGER_COLOR, "Invalid color control mode\n");
LOG_ERROR("Invalid color control mode\n", 0);
return K4A_RESULT_FAILED;
}
break;
default:
logger_error(LOGGER_COLOR, "Unsupported control: %d\n", command);
LOG_ERROR("Unsupported control: %d\n", command);
return K4A_RESULT_FAILED;
}
@ -688,7 +687,7 @@ void UVCCameraReader::Callback(uvc_frame_t *frame)
if (pItem->Size == 0)
{
logger_warn(LOGGER_COLOR, "frame metadata id %d has zero buffer size", pItem->MetadataId);
LOG_WARNING("frame metadata id %d has zero buffer size", pItem->MetadataId);
break;
}
@ -802,7 +801,7 @@ UVCCameraReader::DecodeMJPEGtoBGRA32(uint8_t *in_buf, const size_t in_size, uint
m_decoder = tjInitDecompress();
if (m_decoder == nullptr)
{
logger_error(LOGGER_COLOR, "MJPEG decoder initialization failed\n");
LOG_ERROR("MJPEG decoder initialization failed\n", 0);
return K4A_RESULT_FAILED;
}
}
@ -819,7 +818,7 @@ UVCCameraReader::DecodeMJPEGtoBGRA32(uint8_t *in_buf, const size_t in_size, uint
if (decompressStatus != 0)
{
logger_error(LOGGER_COLOR, "MJPEG decode failed: %d", decompressStatus);
LOG_ERROR("MJPEG decode failed: %d", decompressStatus);
return K4A_RESULT_FAILED;
}

Просмотреть файл

@ -237,7 +237,7 @@ k4a_result_t colormcu_set_multi_device_mode(colormcu_t colormcu_handle, k4a_devi
break;
default:
result = K4A_RESULT_FAILED;
logger_error("colormcu", "Unexpected value in config->wired_sync_mode:%d", config->wired_sync_mode);
LOG_ERROR("Unexpected value in config->wired_sync_mode:%d", config->wired_sync_mode);
break;
}

Просмотреть файл

@ -224,7 +224,7 @@ void depth_destroy(depth_t depth_handle)
static void log_device_info(depth_context_t *depth)
{
typedef void(logger_pfn_t)(const char *zone, const char *format, ...);
logger_pfn_t *logger = logger_info;
logger_pfn_t *logger = NULL;
if (logger_is_file_based())
{
@ -241,35 +241,35 @@ static void log_device_info(depth_context_t *depth)
logger = logger_info;
}
logger(LOGGER_API, "******************** Device Info ********************");
logger(LOGGER_API, "K4A SDK version: %s", K4A_VERSION_STR);
logger(LOGGER_K4A, "******************** Device Info ********************");
logger(LOGGER_K4A, "K4A SDK version: %s", K4A_VERSION_STR);
char serial_number[128];
size_t size = sizeof(serial_number);
if (depthmcu_get_serialnum(depth->depthmcu, serial_number, &size) == K4A_BUFFER_RESULT_SUCCEEDED)
{
logger(LOGGER_API, "Serial Number: %s", serial_number);
logger(LOGGER_K4A, "Serial Number: %s", serial_number);
}
k4a_version_t *ver = &depth->version.rgb;
logger(LOGGER_API, "RGB Sensor Version: %d.%d.%d", ver->major, ver->minor, ver->iteration);
logger(LOGGER_K4A, "RGB Sensor Version: %d.%d.%d", ver->major, ver->minor, ver->iteration);
ver = &depth->version.depth;
logger(LOGGER_API, "Depth Sensor Version:%d.%d.%d", ver->major, ver->minor, ver->iteration);
logger(LOGGER_K4A, "Depth Sensor Version:%d.%d.%d", ver->major, ver->minor, ver->iteration);
ver = &depth->version.audio;
logger(LOGGER_API, "Mic Array Version: %d.%d.%d", ver->major, ver->minor, ver->iteration);
logger(LOGGER_K4A, "Mic Array Version: %d.%d.%d", ver->major, ver->minor, ver->iteration);
ver = &depth->version.depth_sensor;
logger(LOGGER_API, "Sensor Config: %d.%d", ver->major, ver->minor);
logger(LOGGER_API, "Build type: %s", depth->version.firmware_build == 0 ? "Release" : "Debug");
logger(LOGGER_API,
logger(LOGGER_K4A, "Sensor Config: %d.%d", ver->major, ver->minor);
logger(LOGGER_K4A, "Build type: %s", depth->version.firmware_build == 0 ? "Release" : "Debug");
logger(LOGGER_K4A,
"Signature type: %s",
depth->version.firmware_signature == K4A_FIRMWARE_SIGNATURE_MSFT ?
"MSFT" :
(depth->version.firmware_signature == K4A_FIRMWARE_SIGNATURE_TEST ? "Test" : "Unsigned"));
logger(LOGGER_API, "****************************************************");
logger(LOGGER_K4A, "****************************************************");
}
/** see documentation for depthmcu_stream_cb_t

Просмотреть файл

@ -153,10 +153,9 @@ k4a_buffer_result_t depthmcu_get_serialnum(depthmcu_t depthmcu_handle, char *ser
|| !isgraph(temp_serial_number[i]) // Non-printable character
)
{
logger_error(LOGGER_DEPTH_MCU,
"depthmcu_get_serialnum found non-printable serial number (character %d is ASCII value %d)",
i,
temp_serial_number[i]);
LOG_ERROR("depthmcu_get_serialnum found non-printable serial number (character %d is ASCII value %d)",
i,
temp_serial_number[i]);
return K4A_BUFFER_RESULT_FAILED;
}
}

Просмотреть файл

@ -102,7 +102,7 @@ void imu_capture_ready(k4a_result_t result, k4a_image_t image, void *p_context)
// place capture in queue
if (result != K4A_RESULT_SUCCEEDED)
{
logger_warn(LOGGER_IMU, "A streaming IMU transfer failed");
LOG_WARNING("A streaming IMU transfer failed", 0);
// Notify queue of an error
queue_error(p_imu->queue);
}
@ -120,9 +120,7 @@ void imu_capture_ready(k4a_result_t result, k4a_image_t image, void *p_context)
if (capture_size < sizeof(imu_payload_metadata_t))
{
logger_error(LOGGER_IMU,
"IMU streaming payload size too small for imu_payload_metadata_t: %zu",
capture_size);
LOG_ERROR("IMU streaming payload size too small for imu_payload_metadata_t: %zu", capture_size);
return;
}
else
@ -132,10 +130,9 @@ void imu_capture_ready(k4a_result_t result, k4a_image_t image, void *p_context)
if (capture_size < sizeof(imu_payload_metadata_t) + (p_metadata->gyro.sample_count * sizeof(xyz_vector_t)))
{
logger_error(LOGGER_IMU,
"IMU streaming payload size too small for gyro samples: %u size: %zu",
p_metadata->gyro.sample_count,
capture_size);
LOG_ERROR("IMU streaming payload size too small for gyro samples: %u size: %zu",
p_metadata->gyro.sample_count,
capture_size);
return;
}
else
@ -147,10 +144,9 @@ void imu_capture_ready(k4a_result_t result, k4a_image_t image, void *p_context)
if (capture_size < sizeof(imu_payload_metadata_t) + (p_metadata->gyro.sample_count * sizeof(xyz_vector_t)) +
(p_metadata->accel.sample_count * sizeof(xyz_vector_t)))
{
logger_error(LOGGER_IMU,
"IMU streaming payload size too small for accelerometer samples: %u size: %zu",
p_metadata->accel.sample_count,
capture_size);
LOG_ERROR("IMU streaming payload size too small for accelerometer samples: %u size: %zu",
p_metadata->accel.sample_count,
capture_size);
return;
}
else
@ -161,8 +157,7 @@ void imu_capture_ready(k4a_result_t result, k4a_image_t image, void *p_context)
if (p_metadata->gyro.sample_count != p_metadata->accel.sample_count)
{
logger_warn(LOGGER_IMU,
"IMU payload sample accel(%d) != sample gyro(%d)",
LOG_WARNING("IMU payload sample accel(%d) != sample gyro(%d)",
p_metadata->accel.sample_count,
p_metadata->gyro.sample_count);
}

Просмотреть файл

@ -56,7 +56,7 @@ k4a_result_t queue_create(uint32_t queue_depth, const char *queue_name, queue_t
queue->name = queue_name;
if (queue->name == NULL)
{
queue->name = LOGGER_QUEUE;
queue->name = "Unknown queue";
}
queue->queue = malloc(sizeof(queue_entry_t) * queue->depth);
@ -109,7 +109,7 @@ k4a_wait_result_t queue_pop(queue_t queue_handle, int32_t wait_in_ms, k4a_captur
if (queue->enabled != true)
{
logger_error(queue->name, "Capture popped from disabled queue");
LOG_ERROR("%s: capture popped from disabled queue", queue->name);
wresult = K4A_WAIT_RESULT_FAILED;
}
@ -167,7 +167,7 @@ k4a_wait_result_t queue_pop(queue_t queue_handle, int32_t wait_in_ms, k4a_captur
if (queue->dropped_count != 0)
{
logger_warn(queue->name, "Dropped oldest %d captures from queue", queue->dropped_count);
LOG_WARNING("%s: Dropped oldest %d captures from queue", queue->name, queue->dropped_count);
queue->dropped_count = 0;
}
@ -199,7 +199,7 @@ void queue_push_w_dropped(queue_t queue_handle, k4a_capture_t capture, k4a_captu
if (queue->enabled == false)
{
logger_warn(queue->name, "Capture pushed into disabled queue");
LOG_WARNING("Capture pushed into disabled queue", queue->name);
}
else
{
@ -297,6 +297,6 @@ void queue_error(queue_t queue_handle)
queue->error = true;
Unlock(queue->lock);
logger_warn(LOGGER_QUEUE, "Error detected, shutting down queue and notifying consumers");
LOG_WARNING("Error detected, shutting down queue and notifying consumers", 0);
queue_disable(queue_handle);
}

Просмотреть файл

@ -28,11 +28,10 @@ std::unique_ptr<EbmlElement> next_child(k4a_playback_context_t *context, EbmlEle
}
catch (std::ios_base::failure e)
{
logger_error(LOGGER_RECORD,
"Failed to get next child (parent id %x) in recording '%s': %s",
EbmlId(*parent).GetValue(),
context->file_path,
e.what());
LOG_ERROR("Failed to get next child (parent id %x) in recording '%s': %s",
EbmlId(*parent).GetValue(),
context->file_path,
e.what());
return nullptr;
}
}
@ -49,11 +48,10 @@ k4a_result_t skip_element(k4a_playback_context_t *context, EbmlElement *element)
}
catch (std::ios_base::failure e)
{
logger_error(LOGGER_RECORD,
"Failed seek past element (id %x) in recording '%s': %s",
EbmlId(*element).GetValue(),
context->file_path,
e.what());
LOG_ERROR("Failed seek past element (id %x) in recording '%s': %s",
EbmlId(*element).GetValue(),
context->file_path,
e.what());
return K4A_RESULT_FAILED;
}
}
@ -62,7 +60,7 @@ void match_ebml_id(k4a_playback_context_t *context, EbmlId &id, uint64_t offset)
{
RETURN_VALUE_IF_ARG(VOID_VALUE, context == NULL);
logger_trace(LOGGER_RECORD, "Matching seek location: %x -> %llu", id.GetValue(), offset);
LOG_TRACE("Matching seek location: %x -> %llu", id.GetValue(), offset);
if (id == KaxSeekHead::ClassInfos.GlobalId || id == KaxChapters::ClassInfos.GlobalId ||
id == EbmlVoid::ClassInfos.GlobalId)
@ -98,7 +96,7 @@ void match_ebml_id(k4a_playback_context_t *context, EbmlId &id, uint64_t offset)
}
else
{
logger_warn(LOGGER_RECORD, "Unknown element being matched: %x at %llu", id.GetValue(), offset);
LOG_WARNING("Unknown element being matched: %x at %llu", id.GetValue(), offset);
}
}
@ -121,7 +119,7 @@ k4a_result_t parse_mkv(k4a_playback_context_t *context)
{
if (read_element<EbmlHead>(context, ebmlHead.get()) == NULL)
{
logger_error(LOGGER_RECORD, "Failed to read EBML head.");
LOG_ERROR("Failed to read EBML head.", 0);
return K4A_RESULT_FAILED;
}
@ -130,30 +128,27 @@ k4a_result_t parse_mkv(k4a_playback_context_t *context)
EDocTypeReadVersion &eDocTypeReadVersion = GetChild<EDocTypeReadVersion>(*ebmlHead);
if (eDocType.GetValue() != std::string("matroska"))
{
logger_error(LOGGER_RECORD, "DocType is not matroska: %s", eDocType.GetValue().c_str());
LOG_ERROR("DocType is not matroska: %s", eDocType.GetValue().c_str());
return K4A_RESULT_FAILED;
}
if (eDocTypeReadVersion.GetValue() > 2)
{
logger_error(LOGGER_RECORD,
"DocTypeReadVersion (%d) > 2 is not supported.",
eDocTypeReadVersion.GetValue());
LOG_ERROR("DocTypeReadVersion (%d) > 2 is not supported.", eDocTypeReadVersion.GetValue());
return K4A_RESULT_FAILED;
}
if (eDocTypeVersion.GetValue() < eDocTypeReadVersion.GetValue())
{
logger_error(LOGGER_RECORD,
"DocTypeVersion (%d) is great than DocTypeReadVersion (%d)",
eDocTypeVersion.GetValue(),
eDocTypeReadVersion.GetValue());
LOG_ERROR("DocTypeVersion (%d) is great than DocTypeReadVersion (%d)",
eDocTypeVersion.GetValue(),
eDocTypeReadVersion.GetValue());
return K4A_RESULT_FAILED;
}
}
else
{
logger_error(LOGGER_RECORD, "Matroska / EBML head is missing, recording is not valid.");
LOG_ERROR("Matroska / EBML head is missing, recording is not valid.", 0);
return K4A_RESULT_FAILED;
}
@ -197,7 +192,7 @@ k4a_result_t parse_mkv(k4a_playback_context_t *context)
if (context->first_cluster_offset == 0)
{
logger_error(LOGGER_RECORD, "Recording file does not contain any frames!");
LOG_ERROR("Recording file does not contain any frames!", 0);
return K4A_RESULT_FAILED;
}
@ -219,7 +214,7 @@ k4a_result_t parse_mkv(k4a_playback_context_t *context)
cluster_info_t *cluster_info = find_cluster(context, UINT64_MAX);
if (cluster_info == NULL)
{
logger_error(LOGGER_RECORD, "Failed to find end of recording.");
LOG_ERROR("Failed to find end of recording.", 0);
return K4A_RESULT_FAILED;
}
@ -228,7 +223,7 @@ k4a_result_t parse_mkv(k4a_playback_context_t *context)
std::shared_ptr<KaxCluster> last_cluster = load_cluster(context, cluster_info);
if (last_cluster == nullptr)
{
logger_error(LOGGER_RECORD, "Failed to load end of recording.");
LOG_ERROR("Failed to load end of recording.", 0);
return K4A_RESULT_FAILED;
}
for (EbmlElement *e : last_cluster->GetElementList())
@ -252,7 +247,7 @@ k4a_result_t parse_mkv(k4a_playback_context_t *context)
}
}
}
logger_trace(LOGGER_RECORD, "Found last timestamp: %llu", context->last_timestamp_ns);
LOG_TRACE("Found last timestamp: %llu", context->last_timestamp_ns);
return K4A_RESULT_SUCCEEDED;
}
@ -275,13 +270,13 @@ k4a_result_t populate_cluster_cache(k4a_playback_context_t *context)
// Read the first cluster to use as the cache root.
if (K4A_FAILED(seek_offset(context, context->first_cluster_offset)))
{
logger_error(LOGGER_RECORD, "Failed to seek to first recording cluster.");
LOG_ERROR("Failed to seek to first recording cluster.", 0);
return K4A_RESULT_FAILED;
}
std::shared_ptr<KaxCluster> first_cluster = find_next<KaxCluster>(context);
if (first_cluster == nullptr)
{
logger_error(LOGGER_RECORD, "Failed to read element for first recording cluster.");
LOG_ERROR("Failed to read element for first recording cluster.", 0);
return K4A_RESULT_FAILED;
}
@ -328,7 +323,7 @@ k4a_result_t populate_cluster_cache(k4a_playback_context_t *context)
}
else
{
logger_warn(LOGGER_RECORD, "Cluster or Cue entry is out of order.");
LOG_WARNING("Cluster or Cue entry is out of order.", 0);
}
}
}
@ -336,7 +331,7 @@ k4a_result_t populate_cluster_cache(k4a_playback_context_t *context)
}
else
{
logger_warn(LOGGER_RECORD, "Recording is missing Cue entries, playback performance may be impacted.");
LOG_WARNING("Recording is missing Cue entries, playback performance may be impacted.", 0);
}
return K4A_RESULT_SUCCEEDED;
@ -379,7 +374,7 @@ k4a_result_t parse_recording_config(k4a_playback_context_t *context)
if (context->calibration_attachment == NULL)
{
// The rest of the recording can still be read if no device calibration blob exists.
logger_warn(LOGGER_RECORD, "Device calibration is missing from recording.");
LOG_WARNING("Device calibration is missing from recording.", 0);
}
uint64_t frame_period_ns = 0;
@ -407,10 +402,7 @@ k4a_result_t parse_recording_config(k4a_playback_context_t *context)
}
if (context->record_config.color_resolution == K4A_COLOR_RESOLUTION_OFF)
{
logger_error(LOGGER_RECORD,
"Unsupported color resolution: %dx%d",
context->color_track.width,
context->color_track.height);
LOG_ERROR("Unsupported color resolution: %dx%d", context->color_track.width, context->color_track.height);
return K4A_RESULT_FAILED;
}
@ -427,7 +419,7 @@ k4a_result_t parse_recording_config(k4a_playback_context_t *context)
KaxTag *depth_mode_tag = get_tag(context, "K4A_DEPTH_MODE");
if (depth_mode_tag == NULL && (context->depth_track.track || context->ir_track.track))
{
logger_error(LOGGER_RECORD, "K4A_DEPTH_MODE tag is missing.");
LOG_ERROR("K4A_DEPTH_MODE tag is missing.", 0);
return K4A_RESULT_FAILED;
}
std::string depth_mode_str = get_tag_string(depth_mode_tag);
@ -448,7 +440,7 @@ k4a_result_t parse_recording_config(k4a_playback_context_t *context)
}
if (context->record_config.depth_mode == K4A_DEPTH_MODE_OFF)
{
logger_error(LOGGER_RECORD, "Unsupported depth mode: %s", depth_mode_str.c_str());
LOG_ERROR("Unsupported depth mode: %s", depth_mode_str.c_str());
return K4A_RESULT_FAILED;
}
@ -465,20 +457,18 @@ k4a_result_t parse_recording_config(k4a_playback_context_t *context)
}
else if (frame_period_ns != depth_period_ns)
{
logger_error(LOGGER_RECORD,
"Track frame durations don't match (Depth): %llu ns != %llu ns",
frame_period_ns,
depth_period_ns);
LOG_ERROR("Track frame durations don't match (Depth): %llu ns != %llu ns",
frame_period_ns,
depth_period_ns);
return K4A_RESULT_FAILED;
}
if (context->depth_track.width != depth_width || context->depth_track.height != depth_height)
{
logger_error(LOGGER_RECORD,
"Unsupported depth resolution / mode: %dx%d (%s)",
context->depth_track.width,
context->depth_track.height,
depth_mode_str.c_str());
LOG_ERROR("Unsupported depth resolution / mode: %dx%d (%s)",
context->depth_track.width,
context->depth_track.height,
depth_mode_str.c_str());
return K4A_RESULT_FAILED;
}
@ -500,10 +490,7 @@ k4a_result_t parse_recording_config(k4a_playback_context_t *context)
}
else if (frame_period_ns != ir_period_ns)
{
logger_error(LOGGER_RECORD,
"Track frame durations don't match (IR): %llu ns != %llu ns",
frame_period_ns,
ir_period_ns);
LOG_ERROR("Track frame durations don't match (IR): %llu ns != %llu ns", frame_period_ns, ir_period_ns);
return K4A_RESULT_FAILED;
}
@ -512,22 +499,20 @@ k4a_result_t parse_recording_config(k4a_playback_context_t *context)
if (context->ir_track.width != context->depth_track.width ||
context->ir_track.height != context->depth_track.height)
{
logger_error(LOGGER_RECORD,
"Depth and IR track have different resolutions: Depth %dx%d, IR %dx%d",
context->depth_track.width,
context->depth_track.height,
context->ir_track.width,
context->ir_track.height);
LOG_ERROR("Depth and IR track have different resolutions: Depth %dx%d, IR %dx%d",
context->depth_track.width,
context->depth_track.height,
context->ir_track.width,
context->ir_track.height);
return K4A_RESULT_FAILED;
}
}
else if (context->ir_track.width != depth_width || context->ir_track.height != depth_height)
{
logger_error(LOGGER_RECORD,
"Unsupported IR resolution / depth mode: %dx%d (%s)",
context->ir_track.width,
context->ir_track.height,
depth_mode_str.c_str());
LOG_ERROR("Unsupported IR resolution / depth mode: %dx%d (%s)",
context->ir_track.width,
context->ir_track.height,
depth_mode_str.c_str());
return K4A_RESULT_FAILED;
}
@ -551,10 +536,9 @@ k4a_result_t parse_recording_config(k4a_playback_context_t *context)
context->record_config.camera_fps = K4A_FRAMES_PER_SECOND_30;
break;
default:
logger_error(LOGGER_RECORD,
"Unsupported recording frame period: %llu ns (%llu fps)",
frame_period_ns,
(1_s / frame_period_ns));
LOG_ERROR("Unsupported recording frame period: %llu ns (%llu fps)",
frame_period_ns,
(1_s / frame_period_ns));
return K4A_RESULT_FAILED;
}
}
@ -589,9 +573,7 @@ k4a_result_t parse_recording_config(k4a_playback_context_t *context)
}
else
{
logger_error(LOGGER_RECORD,
"Tag K4A_DEPTH_DELAY_NS contains invalid value: %s",
get_tag_string(depth_delay_tag).c_str());
LOG_ERROR("Tag K4A_DEPTH_DELAY_NS contains invalid value: %s", get_tag_string(depth_delay_tag).c_str());
return K4A_RESULT_FAILED;
}
}
@ -622,7 +604,7 @@ k4a_result_t parse_recording_config(k4a_playback_context_t *context)
}
if (!sync_mode_found)
{
logger_error(LOGGER_RECORD, "Unsupported wired sync mode: %s", sync_mode_str.c_str());
LOG_ERROR("Unsupported wired sync mode: %s", sync_mode_str.c_str());
return K4A_RESULT_FAILED;
}
@ -641,9 +623,8 @@ k4a_result_t parse_recording_config(k4a_playback_context_t *context)
}
else
{
logger_error(LOGGER_RECORD,
"Tag K4A_SUBORDINATE_DELAY_NS contains invalid value: %s",
get_tag_string(subordinate_delay_tag).c_str());
LOG_ERROR("Tag K4A_SUBORDINATE_DELAY_NS contains invalid value: %s",
get_tag_string(subordinate_delay_tag).c_str());
return K4A_RESULT_FAILED;
}
}
@ -676,9 +657,7 @@ k4a_result_t parse_recording_config(k4a_playback_context_t *context)
}
else
{
logger_error(LOGGER_RECORD,
"Tag K4A_START_OFFSET_NS contains invalid value: %s",
get_tag_string(start_offset_tag).c_str());
LOG_ERROR("Tag K4A_START_OFFSET_NS contains invalid value: %s", get_tag_string(start_offset_tag).c_str());
return K4A_RESULT_FAILED;
}
}
@ -724,10 +703,9 @@ k4a_result_t read_bitmap_info_header(track_reader_t *track)
track->stride = track->width * 2;
break;
default:
logger_error(LOGGER_RECORD,
"Unsupported FOURCC format for track '%s': %x",
GetChild<KaxTrackName>(*track->track).GetValueUTF8().c_str(),
track->bitmap_header->biCompression);
LOG_ERROR("Unsupported FOURCC format for track '%s': %x",
GetChild<KaxTrackName>(*track->track).GetValueUTF8().c_str(),
track->bitmap_header->biCompression);
return K4A_RESULT_FAILED;
}
@ -735,10 +713,9 @@ k4a_result_t read_bitmap_info_header(track_reader_t *track)
}
else
{
logger_error(LOGGER_RECORD,
"Unsupported codec id for track '%s': %s",
GetChild<KaxTrackName>(*track->track).GetValueUTF8().c_str(),
codec_id.c_str());
LOG_ERROR("Unsupported codec id for track '%s': %s",
GetChild<KaxTrackName>(*track->track).GetValueUTF8().c_str(),
codec_id.c_str());
return K4A_RESULT_FAILED;
}
}
@ -912,19 +889,18 @@ k4a_result_t seek_offset(k4a_playback_context_t *context, uint64_t offset)
uint64_t file_offset = context->segment->GetGlobalPosition(offset);
try
{
logger_trace(LOGGER_RECORD, "Seeking to file position: %llu", file_offset);
LOG_TRACE("Seeking to file position: %llu", file_offset);
assert(file_offset <= INT64_MAX);
context->ebml_file->setFilePointer((int64_t)file_offset);
return K4A_RESULT_SUCCEEDED;
}
catch (std::ios_base::failure e)
{
logger_error(LOGGER_RECORD,
"Failed to seek file to %llu (relative %llu) '%s': %s",
file_offset,
offset,
context->file_path,
e.what());
LOG_ERROR("Failed to seek file to %llu (relative %llu) '%s': %s",
file_offset,
offset,
context->file_path,
e.what());
return K4A_RESULT_FAILED;
}
}
@ -1036,13 +1012,13 @@ cluster_info_t *next_cluster(k4a_playback_context_t *context, cluster_info_t *cu
// Read forward in file to find next cluster and fill in cache
if (K4A_FAILED(seek_offset(context, current_cluster->file_offset)))
{
logger_error(LOGGER_RECORD, "Failed to seek to current cluster element.");
LOG_ERROR("Failed to seek to current cluster element.", 0);
return NULL;
}
std::shared_ptr<KaxCluster> current_element = find_next<KaxCluster>(context);
if (current_element == nullptr)
{
logger_error(LOGGER_RECORD, "Failed to find current cluster element.");
LOG_ERROR("Failed to find current cluster element.", 0);
return NULL;
}
populate_cluster_info(context, current_element, current_cluster);
@ -1055,7 +1031,7 @@ cluster_info_t *next_cluster(k4a_playback_context_t *context, cluster_info_t *cu
// Seek to the end of the current cluster so that find_next returns the next cluster in the file.
if (K4A_FAILED(skip_element(context, current_element.get())))
{
logger_error(LOGGER_RECORD, "Failed to seek to next cluster element.");
LOG_ERROR("Failed to seek to next cluster element.", 0);
return NULL;
}
@ -1140,7 +1116,7 @@ std::shared_ptr<KaxCluster> load_cluster(k4a_playback_context_t *context, cluste
context->load_count++;
if (K4A_FAILED(seek_offset(context, cluster_info->file_offset)))
{
logger_error(LOGGER_RECORD, "Failed to seek to cluster at: %llu", cluster_info->file_offset);
LOG_ERROR("Failed to seek to cluster at: %llu", cluster_info->file_offset);
return nullptr;
}
cluster = find_next<KaxCluster>(context);
@ -1148,7 +1124,7 @@ std::shared_ptr<KaxCluster> load_cluster(k4a_playback_context_t *context, cluste
{
if (read_element<KaxCluster>(context, cluster.get()) == NULL)
{
logger_error(LOGGER_RECORD, "Failed to read cluster data at: %llu", cluster_info->file_offset);
LOG_ERROR("Failed to read cluster data at: %llu", cluster_info->file_offset);
return nullptr;
}
@ -1161,7 +1137,7 @@ std::shared_ptr<KaxCluster> load_cluster(k4a_playback_context_t *context, cluste
}
else
{
logger_error(LOGGER_RECORD, "Failed to find cluster element at: %llu", cluster_info->file_offset);
LOG_ERROR("Failed to find cluster element at: %llu", cluster_info->file_offset);
return nullptr;
}
}
@ -1190,7 +1166,7 @@ std::shared_ptr<read_block_t> find_next_block(k4a_playback_context_t *context, t
next_block->cluster = load_cluster(context, context->seek_cluster);
if (next_block->cluster == nullptr)
{
logger_error(LOGGER_RECORD, "Failed to load data cluster from disk.");
LOG_ERROR("Failed to load data cluster from disk.", 0);
return nullptr;
}
next_block->index = next ? 0 : ((int)next_block->cluster->ListSize() - 1);
@ -1255,7 +1231,7 @@ std::shared_ptr<read_block_t> find_next_block(k4a_playback_context_t *context, t
next_block->cluster = load_cluster(context, found_cluster_info);
if (next_block->cluster == nullptr)
{
logger_error(LOGGER_RECORD, "Failed to load next data cluster from disk.");
LOG_ERROR("Failed to load next data cluster from disk.", 0);
return nullptr;
}
next_block->index = next ? 0 : ((int)next_block->cluster->ListSize() - 1);
@ -1360,7 +1336,7 @@ k4a_result_t new_capture(k4a_playback_context_t *context,
}
else
{
logger_error(LOGGER_RECORD, "Capture being created from unknown track!");
LOG_ERROR("Capture being created from unknown track!", 0);
result = K4A_RESULT_FAILED;
}
@ -1414,7 +1390,7 @@ k4a_stream_result_t get_capture(k4a_playback_context_t *context, k4a_capture_t *
}
else
{
logger_trace(LOGGER_RECORD, "%s of recording reached", next ? "End" : "Beginning");
LOG_TRACE("%s of recording reached", next ? "End" : "Beginning");
blocks[i]->current_block = next_blocks[i];
}
}
@ -1506,12 +1482,11 @@ k4a_stream_result_t get_capture(k4a_playback_context_t *context, k4a_capture_t *
}
}
logger_trace(LOGGER_RECORD,
"Valid blocks: %d/%d, Start: %llu ms, End: %llu ms",
valid_blocks,
enabled_tracks,
timestamp_start_ns / 1_ms,
timestamp_end_ns / 1_ms);
LOG_TRACE("Valid blocks: %d/%d, Start: %llu ms, End: %llu ms",
valid_blocks,
enabled_tracks,
timestamp_start_ns / 1_ms,
timestamp_end_ns / 1_ms);
*capture_handle = NULL;
for (size_t i = 0; i < arraysize(blocks); i++)
@ -1544,7 +1519,7 @@ k4a_stream_result_t get_imu_sample(k4a_playback_context_t *context, k4a_imu_samp
return K4A_STREAM_RESULT_EOF;
}
logger_error(LOGGER_RECORD, "IMU playback is not yet supported.");
LOG_ERROR("IMU playback is not yet supported.", 0);
(void)next;
return K4A_STREAM_RESULT_FAILED;

Просмотреть файл

@ -97,7 +97,7 @@ populate_bitmap_info_header(BITMAPINFOHEADER *header, uint64_t width, uint64_t h
header->biSizeImage = sizeof(uint8_t) * header->biWidth * header->biHeight * 2;
break;
default:
logger_error(LOGGER_RECORD, "Unsupported color format specified in recording: %d", format);
LOG_ERROR("Unsupported color format specified in recording: %d", format);
return K4A_RESULT_FAILED;
}
@ -159,7 +159,7 @@ write_track_data(k4a_record_context_t *context, KaxTrackEntry *track, uint64_t t
if (Lock(context->pending_cluster_lock) != LOCK_OK)
{
logger_error(LOGGER_RECORD, "Failed to lock pending clusters");
LOG_ERROR("Failed to lock pending clusters", 0);
return K4A_RESULT_FAILED;
}
@ -182,7 +182,7 @@ write_track_data(k4a_record_context_t *context, KaxTrackEntry *track, uint64_t t
Unlock(context->pending_cluster_lock);
if (!context->writer_stopping && Condition_Post(context->writer_notify) != COND_OK)
{
logger_error(LOGGER_RECORD, "Failed to notify writer thread");
LOG_ERROR("Failed to notify writer thread", 0);
// Data was still written in this case, so don't return failure
}
@ -197,9 +197,7 @@ cluster_t *get_cluster_for_timestamp(k4a_record_context_t *context, uint64_t tim
if (context->last_written_timestamp > timestamp_ns)
{
logger_error(LOGGER_RECORD,
"The cluster containing the timestamp %d has already been written to disk.",
timestamp_ns);
LOG_ERROR("The cluster containing the timestamp %d has already been written to disk.", timestamp_ns);
return NULL;
}
@ -267,7 +265,7 @@ k4a_result_t write_cluster(k4a_record_context_t *context, cluster_t *cluster, ui
k4a_result_t result = K4A_RESULT_SUCCEEDED;
if (cluster->data.size() == 0)
{
logger_warn(LOGGER_RECORD, "Tried to write empty cluster to disk");
LOG_WARNING("Tried to write empty cluster to disk", 0);
return result;
}
@ -360,7 +358,7 @@ k4a_result_t write_cluster(k4a_record_context_t *context, cluster_t *cluster, ui
}
catch (std::ios_base::failure e)
{
logger_error(LOGGER_RECORD, "Failed to write recording data '%s': %s", context->file_path, e.what());
LOG_ERROR("Failed to write recording data '%s': %s", context->file_path, e.what());
result = K4A_RESULT_FAILED;
}
@ -391,7 +389,7 @@ static int matroska_writer_thread(void *context_ptr)
if (Lock(context->writer_lock) != LOCK_OK)
{
logger_error(LOGGER_RECORD, "Writer thread failed Lock");
LOG_ERROR("Writer thread failed Lock", 0);
result = K4A_RESULT_FAILED;
}
@ -423,7 +421,7 @@ static int matroska_writer_thread(void *context_ptr)
if (K4A_FAILED(result))
{
// write_cluster failures are not recoverable (file IO errors only, the file is likely corrupt)
logger_error(LOGGER_RECORD, "Cluster write failed, dropping cluster.");
LOG_ERROR("Cluster write failed, dropping cluster.", 0);
break;
}
}
@ -432,7 +430,7 @@ static int matroska_writer_thread(void *context_ptr)
COND_RESULT cond = Condition_Wait(context->writer_notify, context->writer_lock, oldest_cluster ? 1 : 100);
if (cond != COND_OK && cond != COND_TIMEOUT)
{
logger_error(LOGGER_RECORD, "Writer thread failed Condition_Wait: %d", cond);
LOG_ERROR("Writer thread failed Condition_Wait: %d", cond);
result = K4A_RESULT_FAILED;
break;
}
@ -441,7 +439,7 @@ static int matroska_writer_thread(void *context_ptr)
if (Unlock(context->writer_lock) != LOCK_OK)
{
logger_error(LOGGER_RECORD, "Writer thread failed Unlock");
LOG_ERROR("Writer thread failed Unlock", 0);
result = K4A_RESULT_FAILED;
}
@ -464,7 +462,7 @@ k4a_result_t start_matroska_writer_thread(k4a_record_context_t *context)
if (ThreadAPI_Create(&context->writer_thread, matroska_writer_thread, context) != THREADAPI_OK)
{
context->writer_thread = 0;
logger_error(LOGGER_RECORD, "Failed to start recording writer thread.");
LOG_ERROR("Failed to start recording writer thread.", 0);
return K4A_RESULT_FAILED;
}
@ -481,13 +479,13 @@ k4a_result_t stop_matroska_writer_thread(k4a_record_context_t *context)
if (Condition_Post(context->writer_notify) != COND_OK)
{
// If this fails, the thread will still eventually stop via the writer_stopping flag.
logger_warn(LOGGER_RECORD, "Failed to notify writer thread to stop.");
LOG_WARNING("Failed to notify writer thread to stop.", 0);
}
k4a_result_t result = K4A_RESULT_SUCCEEDED;
if (ThreadAPI_Join(context->writer_thread, (int *)&result) != THREADAPI_OK)
{
logger_error(LOGGER_RECORD, "Failed to stop recording writer thread.");
LOG_ERROR("Failed to stop recording writer thread.", 0);
result = K4A_RESULT_FAILED;
}

Просмотреть файл

@ -45,7 +45,7 @@ k4a_result_t k4a_playback_open(const char *path, k4a_playback_t *playback_handle
}
catch (std::ios_base::failure e)
{
logger_error(LOGGER_RECORD, "Unable to open file '%s': %s", path, e.what());
LOG_ERROR("Unable to open file '%s': %s", path, e.what());
result = K4A_RESULT_FAILED;
}
}
@ -61,7 +61,7 @@ k4a_result_t k4a_playback_open(const char *path, k4a_playback_t *playback_handle
context->seek_cluster = find_cluster(context, 0);
if (context->seek_cluster == nullptr)
{
logger_error(LOGGER_RECORD, "Failed to parse recording, recording is empty.");
LOG_ERROR("Failed to parse recording, recording is empty.", 0);
result = K4A_RESULT_FAILED;
}
}
@ -104,7 +104,7 @@ k4a_buffer_result_t k4a_playback_get_raw_calibration(k4a_playback_t playback_han
if (context->calibration_attachment == NULL)
{
logger_error(LOGGER_RECORD, "The device calibration is missing from the recording.");
LOG_ERROR("The device calibration is missing from the recording.", 0);
return K4A_BUFFER_RESULT_FAILED;
}
@ -143,7 +143,7 @@ k4a_result_t k4a_playback_get_calibration(k4a_playback_t playback_handle, k4a_ca
if (context->calibration_attachment == NULL)
{
logger_error(LOGGER_RECORD, "The device calibration is missing from the recording.");
LOG_ERROR("The device calibration is missing from the recording.", 0);
return K4A_RESULT_FAILED;
}
@ -325,10 +325,10 @@ void k4a_playback_close(const k4a_playback_t playback_handle)
k4a_playback_context_t *context = k4a_playback_t_get_context(playback_handle);
if (context != NULL)
{
logger_trace(LOGGER_RECORD, "File reading stats:");
logger_trace(LOGGER_RECORD, " Seek count: %llu", context->seek_count);
logger_trace(LOGGER_RECORD, " Cluster load count: %llu", context->load_count);
logger_trace(LOGGER_RECORD, " Cluster cache hits: %llu", context->cache_hits);
LOG_TRACE("File reading stats:", 0);
LOG_TRACE(" Seek count: %llu", context->seek_count);
LOG_TRACE(" Cluster load count: %llu", context->load_count);
LOG_TRACE(" Cluster cache hits: %llu", context->cache_hits);
try
{
context->ebml_file->close();

Просмотреть файл

@ -47,7 +47,7 @@ k4a_result_t k4a_record_create(const char *path,
}
catch (std::ios_base::failure e)
{
logger_error(LOGGER_RECORD, "Unable to open file '%s': %s", path, e.what());
LOG_ERROR("Unable to open file '%s': %s", path, e.what());
result = K4A_RESULT_FAILED;
}
}
@ -74,9 +74,7 @@ k4a_result_t k4a_record_create(const char *path,
{
if (!k4a_convert_resolution_to_width_height(device_config.color_resolution, &color_width, &color_height))
{
logger_error(LOGGER_RECORD,
"Unsupported color_resolution specified in recording: %d",
device_config.color_resolution);
LOG_ERROR("Unsupported color_resolution specified in recording: %d", device_config.color_resolution);
result = K4A_RESULT_FAILED;
}
}
@ -98,9 +96,7 @@ k4a_result_t k4a_record_create(const char *path,
color_mode_str << "MJPG_" << color_height << "P";
break;
default:
logger_error(LOGGER_RECORD,
"Unsupported color_format specified in recording: %d",
device_config.color_format);
LOG_ERROR("Unsupported color_format specified in recording: %d", device_config.color_format);
result = K4A_RESULT_FAILED;
}
}
@ -123,9 +119,7 @@ k4a_result_t k4a_record_create(const char *path,
{
if (!k4a_convert_depth_mode_to_width_height(depth_modes[i].first, &depth_width, &depth_height))
{
logger_error(LOGGER_RECORD,
"Unsupported depth_mode specified in recording: %d",
device_config.depth_mode);
LOG_ERROR("Unsupported depth_mode specified in recording: %d", device_config.depth_mode);
result = K4A_RESULT_FAILED;
}
depth_mode_str = depth_modes[i].second.c_str();
@ -134,9 +128,7 @@ k4a_result_t k4a_record_create(const char *path,
}
if (depth_width == 0 || depth_height == 0)
{
logger_error(LOGGER_RECORD,
"Unsupported depth_mode specified in recording: %d",
device_config.depth_mode);
LOG_ERROR("Unsupported depth_mode specified in recording: %d", device_config.depth_mode);
result = K4A_RESULT_FAILED;
}
}
@ -356,7 +348,7 @@ k4a_result_t k4a_record_add_tag(const k4a_record_t recording_handle, const char
if (context->header_written)
{
logger_error(LOGGER_RECORD, "Tags must be added before the recording header is written.");
LOG_ERROR("Tags must be added before the recording header is written.", 0);
return K4A_RESULT_FAILED;
}
@ -374,13 +366,13 @@ k4a_result_t k4a_record_add_imu_track(const k4a_record_t recording_handle)
if (context->header_written)
{
logger_error(LOGGER_RECORD, "The IMU track must be added before the recording header is written.");
LOG_ERROR("The IMU track must be added before the recording header is written.", 0);
return K4A_RESULT_FAILED;
}
if (context->imu_track != NULL)
{
logger_error(LOGGER_RECORD, "The IMU track has already been added to this recording.");
LOG_ERROR("The IMU track has already been added to this recording.", 0);
return K4A_RESULT_FAILED;
}
@ -401,7 +393,7 @@ k4a_result_t k4a_record_write_header(const k4a_record_t recording_handle)
if (context->header_written)
{
logger_error(LOGGER_RECORD, "The header for this recording has already been written.");
LOG_ERROR("The header for this recording has already been written.", 0);
return K4A_RESULT_FAILED;
}
@ -455,7 +447,7 @@ k4a_result_t k4a_record_write_header(const k4a_record_t recording_handle)
}
catch (std::ios_base::failure e)
{
logger_error(LOGGER_RECORD, "Failed to write recording header '%s': %s", context->file_path, e.what());
LOG_ERROR("Failed to write recording header '%s': %s", context->file_path, e.what());
return K4A_RESULT_FAILED;
}
@ -475,7 +467,7 @@ k4a_result_t k4a_record_write_capture(const k4a_record_t recording_handle, k4a_c
if (!context->header_written)
{
logger_error(LOGGER_RECORD, "The recording header needs to be written before any captures.");
LOG_ERROR("The recording header needs to be written before any captures.", 0);
return K4A_RESULT_FAILED;
}
@ -532,7 +524,7 @@ k4a_result_t k4a_record_write_capture(const k4a_record_t recording_handle, k4a_c
}
else
{
logger_error(LOGGER_RECORD, "Tried to write capture with unexpected image format.");
LOG_ERROR("Tried to write capture with unexpected image format.", 0);
result = K4A_RESULT_FAILED;
}
}
@ -552,7 +544,7 @@ k4a_result_t k4a_record_write_imu_sample(const k4a_record_t recording_handle, k4
if (!context->header_written)
{
logger_error(LOGGER_RECORD, "The recording header needs to be written before any imu samples.");
LOG_ERROR("The recording header needs to be written before any imu samples.", 0);
return K4A_RESULT_FAILED;
}
@ -678,7 +670,7 @@ k4a_result_t k4a_record_flush(const k4a_record_t recording_handle)
context->file_segment->SetSizeInfinite(true);
if (!context->file_segment->ForceSize(segment_size))
{
logger_error(LOGGER_RECORD, "Failed set file segment size.");
LOG_ERROR("Failed set file segment size.", 0);
}
context->file_segment->OverwriteHead(*context->ebml_file);
@ -688,7 +680,7 @@ k4a_result_t k4a_record_flush(const k4a_record_t recording_handle)
}
catch (std::ios_base::failure e)
{
logger_error(LOGGER_RECORD, "Failed to write recording '%s': %s", context->file_path, e.what());
LOG_ERROR("Failed to write recording '%s': %s", context->file_path, e.what());
result = K4A_RESULT_FAILED;
}
Unlock(context->pending_cluster_lock);
@ -721,7 +713,7 @@ void k4a_record_close(const k4a_record_t recording_handle)
}
catch (std::ios_base::failure e)
{
logger_error(LOGGER_RECORD, "Failed to close recording '%s': %s", context->file_path, e.what());
LOG_ERROR("Failed to close recording '%s': %s", context->file_path, e.what());
}
// After this destroy, logging will no longer happen.

Просмотреть файл

@ -285,14 +285,13 @@ k4a_result_t k4a_device_start_imu(k4a_device_t device_handle)
if (device->depth_started == false && device->color_started == false)
{
// Color camera resets the IMU timestamp so we avoid letting the IMU run without the camera already running.
logger_error(LOGGER_API,
"k4a_device_start_imu called while the color/depth camera is not running is not supported");
LOG_ERROR("k4a_device_start_imu called while the color/depth camera is not running is not supported", 0);
result = K4A_RESULT_FAILED;
}
if (K4A_SUCCEEDED(result))
{
logger_trace(LOGGER_API, "k4a_device_start_imu starting");
LOG_TRACE("k4a_device_start_imu starting", 0);
result = TRACE_CALL(imu_start(device->imu, color_get_sensor_start_time_tick(device->color)));
}
@ -305,7 +304,7 @@ k4a_result_t k4a_device_start_imu(k4a_device_t device_handle)
{
k4a_device_stop_imu(device_handle);
}
logger_info(LOGGER_API, "k4a_device_start_imu started");
LOG_INFO("k4a_device_start_imu started", 0);
return result;
}
@ -315,13 +314,13 @@ void k4a_device_stop_imu(k4a_device_t device_handle)
RETURN_VALUE_IF_HANDLE_INVALID(VOID_VALUE, k4a_device_t, device_handle);
k4a_context_t *device = k4a_device_t_get_context(device_handle);
logger_info(LOGGER_API, "k4a_device_stop_imu stopping");
LOG_INFO("k4a_device_stop_imu stopping", 0);
if (device->imu)
{
imu_stop(device->imu);
device->imu_started = false;
}
logger_trace(LOGGER_API, "k4a_device_stop_imu stopped");
LOG_TRACE("k4a_device_stop_imu stopped", 0);
}
k4a_result_t k4a_capture_create(k4a_capture_t *capture_handle)
@ -657,21 +656,19 @@ k4a_result_t k4a_device_start_cameras(k4a_device_t device_handle, k4a_device_con
k4a_result_t result = K4A_RESULT_SUCCEEDED;
k4a_context_t *device = k4a_device_t_get_context(device_handle);
logger_trace(LOGGER_API, "k4a_device_start_cameras starting");
LOG_TRACE("k4a_device_start_cameras starting", 0);
if (device->depth_started == true || device->color_started == true)
{
logger_error(LOGGER_API,
"k4a_device_start_cameras called while one of the sensors are running, depth:%d color:%d",
device->depth_started,
device->color_started);
LOG_ERROR("k4a_device_start_cameras called while one of the sensors are running, depth:%d color:%d",
device->depth_started,
device->color_started);
result = K4A_RESULT_FAILED;
}
if (device->imu_started == true)
{
// Color camera resets the IMU timestamp so we avoid that condition.
logger_error(LOGGER_API,
"k4a_device_start_cameras called while the IMU is running is not supported, stop the IMU");
LOG_ERROR("k4a_device_start_cameras called while the IMU is running is not supported, stop the IMU", 0);
result = K4A_RESULT_FAILED;
}
@ -725,7 +722,7 @@ k4a_result_t k4a_device_start_cameras(k4a_device_t device_handle, k4a_device_con
device->color_started = true;
}
}
logger_info(LOGGER_API, "k4a_device_start_cameras started");
LOG_INFO("k4a_device_start_cameras started", 0);
if (K4A_FAILED(result))
{
@ -740,7 +737,7 @@ void k4a_device_stop_cameras(k4a_device_t device_handle)
RETURN_VALUE_IF_HANDLE_INVALID(VOID_VALUE, k4a_device_t, device_handle);
k4a_context_t *device = k4a_device_t_get_context(device_handle);
logger_info(LOGGER_API, "k4a_device_stop_cameras stopping");
LOG_INFO("k4a_device_stop_cameras stopping", 0);
// Capturesync needs to stop before color so that all queues will purged
if (device->capturesync)
@ -761,7 +758,7 @@ void k4a_device_stop_cameras(k4a_device_t device_handle)
device->color_started = false;
}
logger_info(LOGGER_API, "k4a_device_stop_cameras stopped");
LOG_INFO("k4a_device_stop_cameras stopped", 0);
}
k4a_buffer_result_t k4a_device_get_serialnum(k4a_device_t device_handle,

Просмотреть файл

@ -431,7 +431,7 @@ k4a_transformation_t transformation_create(const k4a_calibration_t *calibration,
void transformation_destroy(k4a_transformation_t transformation_handle)
{
RETURN_VALUE_IF_HANDLE_INVALID(, k4a_transformation_t, transformation_handle);
RETURN_VALUE_IF_HANDLE_INVALID(VOID_VALUE, k4a_transformation_t, transformation_handle);
k4a_transformation_context_t *transformation_context = k4a_transformation_t_get_context(transformation_handle);
if (transformation_context->memory_depth_camera_xy_tables != 0)

Просмотреть файл

@ -27,7 +27,7 @@ TraceLibUsbError(int err, const char *szCall, const char *szFile, int line, cons
// Example print:
// depth.cpp (86): allocator_create(&depth->allocator) returned ERROR_NOT_FOUND in depth_create
logger_error(
LOG_ERROR(
LOGGER_K4A, "%s (%d): %s returned %s in %s ", szFile, line, szCall, libusb_error_name(err), szFunction);
result = K4A_RESULT_FAILED;
}
@ -539,17 +539,16 @@ static k4a_result_t usb_cmd_io(usbcmd_t usbcmd_handle,
result = K4A_RESULT_FAILED;
if ((cmd_data_size > 0) && (p_data != NULL))
{
logger_trace(LOGGER_USB_CMD,
"XFR: Cmd=%08x, CmdLength=%u, PayloadSize=%zu, CmdData=%08x %08x...",
cmd,
cmd_data_size,
payload_size,
p_data[0],
p_data[1]);
LOG_TRACE("XFR: Cmd=%08x, CmdLength=%u, PayloadSize=%zu, CmdData=%08x %08x...",
cmd,
cmd_data_size,
payload_size,
p_data[0],
p_data[1]);
}
else
{
logger_trace(LOGGER_USB_CMD, "XFR: Cmd=%08x, PayloadSize=%zu", cmd, payload_size);
LOG_TRACE("XFR: Cmd=%08x, PayloadSize=%zu", cmd, payload_size);
}
Lock(usbcmd->lock);
@ -585,9 +584,7 @@ static k4a_result_t usb_cmd_io(usbcmd_t usbcmd_handle,
USB_CMD_MAX_WAIT_TIME))) != LIBUSB_SUCCESS)
{
usb_transfer_count = 0;
logger_error(LOGGER_USB_CMD,
"Error calling libusb_bulk_transfer for tx, result:%s",
libusb_error_name(err));
LOG_ERROR("Error calling libusb_bulk_transfer for tx, result:%s", libusb_error_name(err));
goto exit;
}
@ -600,9 +597,7 @@ static k4a_result_t usb_cmd_io(usbcmd_t usbcmd_handle,
USB_CMD_MAX_WAIT_TIME)) != LIBUSB_SUCCESS))
{
usb_transfer_count = 0;
logger_error(LOGGER_USB_CMD,
"Error calling libusb_bulk_transfer for rx, result:%s",
libusb_error_name(err));
LOG_ERROR("Error calling libusb_bulk_transfer for rx, result:%s", libusb_error_name(err));
goto exit;
}
@ -620,21 +615,20 @@ static k4a_result_t usb_cmd_io(usbcmd_t usbcmd_handle,
(response_packet.packet_transaction_id != usb_cmd_pkt.header.packet_transaction_id) ||
(response_packet.packet_type != USB_CMD_PACKET_TYPE_RESPONSE))
{
logger_error(LOGGER_USB_CMD,
"Command(%08X) sequence ended in failure, "
"transationId %08X == %08X "
"Response size 0x%08X == 0x%08X "
"Packet status 0x%08x == 0x%08x "
"Packet type 0x%08x == 0x%08x",
cmd,
response_packet.packet_transaction_id,
usb_cmd_pkt.header.packet_transaction_id,
rx_size,
sizeof(response_packet),
response_packet.status,
0,
response_packet.packet_type,
USB_CMD_PACKET_TYPE_RESPONSE);
LOG_ERROR("Command(%08X) sequence ended in failure, "
"transationId %08X == %08X "
"Response size 0x%08X == 0x%08X "
"Packet status 0x%08x == 0x%08x "
"Packet type 0x%08x == 0x%08x",
cmd,
response_packet.packet_transaction_id,
usb_cmd_pkt.header.packet_transaction_id,
rx_size,
sizeof(response_packet),
response_packet.status,
0,
response_packet.packet_type,
USB_CMD_PACKET_TYPE_RESPONSE);
}
else
{
@ -644,16 +638,12 @@ static k4a_result_t usb_cmd_io(usbcmd_t usbcmd_handle,
}
else
{
logger_error(LOGGER_USB_CMD,
"Error calling libusb_bulk_transfer for status, result:%s",
libusb_error_name(err));
LOG_ERROR("Error calling libusb_bulk_transfer for status, result:%s", libusb_error_name(err));
}
}
else
{
logger_error(LOGGER_USB_CMD,
"Error calling libusb_bulk_transfer for initial tx, result:%s",
libusb_error_name(err));
LOG_ERROR("Error calling libusb_bulk_transfer for initial tx, result:%s", libusb_error_name(err));
}
exit:
@ -714,7 +704,7 @@ k4a_result_t usb_cmd_read(usbcmd_t usbcmd_handle,
if (K4A_SUCCEEDED(result) && cmd_status != 0)
{
logger_error(LOGGER_USB_CMD, "Read command(%08X) ended in failure, Command status 0x%08x", cmd, cmd_status);
LOG_ERROR("Read command(%08X) ended in failure, Command status 0x%08x", cmd, cmd_status);
result = K4A_RESULT_FAILED;
}
@ -809,7 +799,7 @@ k4a_result_t usb_cmd_write(usbcmd_t usbcmd_handle,
if (K4A_SUCCEEDED(result) && cmd_status != 0)
{
logger_error(LOGGER_USB_CMD, "Write command(%08X) ended in failure, Command status 0x%08x", cmd, cmd_status);
LOG_ERROR("Write command(%08X) ended in failure, Command status 0x%08x", cmd, cmd_status);
result = K4A_RESULT_FAILED;
}
@ -915,7 +905,7 @@ k4a_result_t usb_cmd_get_device_count(uint32_t *p_device_count)
if (p_device_count == NULL)
{
logger_error(LOGGER_USB_CMD, "Error p_device_count is NULL");
LOG_ERROR("Error p_device_count is NULL", 0);
return K4A_RESULT_FAILED;
}
@ -923,7 +913,7 @@ k4a_result_t usb_cmd_get_device_count(uint32_t *p_device_count)
// initialize library
if ((err = libusb_init(NULL)) < 0)
{
logger_error(LOGGER_USB_CMD, "Error calling libusb_init, result:%s", libusb_error_name(err));
LOG_ERROR("Error calling libusb_init, result:%s", libusb_error_name(err));
return K4A_RESULT_FAILED;
}
@ -936,12 +926,12 @@ k4a_result_t usb_cmd_get_device_count(uint32_t *p_device_count)
count = libusb_get_device_list(NULL, &dev_list); // get the list of devices
if (count > INT32_MAX)
{
logger_error(LOGGER_USB_CMD, "List too large");
LOG_ERROR("List too large", 0);
return K4A_RESULT_FAILED;
}
if (count == 0)
{
logger_error(LOGGER_USB_CMD, "No devices found");
LOG_ERROR("No devices found", 0);
return K4A_RESULT_FAILED;
}
@ -1009,7 +999,7 @@ k4a_result_t usb_cmd_path_get(usbcmd_t usbcmd_handle, uint8_t *p_bus, uint8_t *p
}
else
{
logger_error(LOGGER_USB_CMD, "Error usbcmd is NULL");
LOG_ERROR( "Error usbcmd is NULL",0);
result = K4A_RESULT_FAILED;
}
return result;

Просмотреть файл

@ -115,9 +115,7 @@ void LIBUSB_CALL usb_cmd_libusb_cb(struct libusb_transfer *p_bulk_transfer)
if ((err = libusb_submit_transfer(p_bulk_transfer)) != LIBUSB_SUCCESS)
{
result = K4A_RESULT_FAILED;
logger_error(LOGGER_USB_CMD,
"Error calling libusb_submit_transfer for tx, result:%s",
libusb_error_name(err));
LOG_ERROR("Error calling libusb_submit_transfer for tx, result:%s", libusb_error_name(err));
image_dec_ref(usbcmd->image[image_index]);
usbcmd->image[image_index] = NULL;
}
@ -133,9 +131,7 @@ void LIBUSB_CALL usb_cmd_libusb_cb(struct libusb_transfer *p_bulk_transfer)
// method submits until it gets an error from the submit call. The error produces the libusb_transfer_
// overflow error which shows up in the callback. It's ignored since it is expected behavior during
// the submission process and there are other trace messages that record the event.
logger_error(LOGGER_USB_CMD,
"Error LIBUSB transfer failed, result:%s",
libusb_error_name((int)p_bulk_transfer->status));
LOG_ERROR("Error LIBUSB transfer failed, result:%s", libusb_error_name((int)p_bulk_transfer->status));
// check if the error state can be propagated
if ((image_index < USB_CMD_MAX_XFR_COUNT) && (usbcmd->callback != NULL))
@ -193,7 +189,7 @@ static int usb_cmd_lib_usb_thread(void *var)
usbcmd->p_bulk_transfer[i] = libusb_alloc_transfer(0);
if (usbcmd->p_bulk_transfer[i] == NULL)
{
logger_error(LOGGER_USB_CMD, "libusb transfer could not be allocated");
LOG_ERROR("libusb transfer could not be allocated", 0);
result = K4A_RESULT_FAILED;
break;
}
@ -202,7 +198,7 @@ static int usb_cmd_lib_usb_thread(void *var)
if (K4A_FAILED(result))
{
logger_error(LOGGER_USB_CMD, "stream buffer could not be allocated");
LOG_ERROR("stream buffer could not be allocated", 0);
result = K4A_RESULT_FAILED;
break;
}
@ -221,9 +217,7 @@ static int usb_cmd_lib_usb_thread(void *var)
if (i == 0)
{
// Could not even submit one. This is an error
logger_error(LOGGER_USB_CMD,
"No libusb transfers could not be submitted, error:%s",
libusb_error_name(err));
LOG_ERROR("No libusb transfers could not be submitted, error:%s", libusb_error_name(err));
result = K4A_RESULT_FAILED;
}
else
@ -231,8 +225,7 @@ static int usb_cmd_lib_usb_thread(void *var)
// Could not allocate a transfer within the predefined amount.
// This could indicate other resource are competing and the allocation
// pool needs to be adjusted
logger_warn(LOGGER_USB_CMD,
"Less than optimal %d libusb transfers submitted. Please evaluate available resources",
LOG_WARNING("Less than optimal %d libusb transfers submitted. Please evaluate available resources",
i + 1);
}
@ -255,9 +248,7 @@ static int usb_cmd_lib_usb_thread(void *var)
if ((err = libusb_handle_events_timeout_completed(p_ctx, &tv, NULL)) < 0)
{
usbcmd->stream_going = false; // Close stream if error is detected
logger_error(LOGGER_USB_CMD,
"Error calling libusb_handle_events_timeout failed, result:%s",
libusb_error_name(err));
LOG_ERROR("Error calling libusb_handle_events_timeout failed, result:%s", libusb_error_name(err));
result = K4A_RESULT_FAILED;
}
}
@ -273,9 +264,7 @@ static int usb_cmd_lib_usb_thread(void *var)
// Service the library after cancellation
if ((err = libusb_handle_events_timeout_completed(p_ctx, &tv, NULL)) < 0)
{
logger_error(LOGGER_USB_CMD,
"Error calling libusb_handle_events_timeout failed, result:%s",
libusb_error_name(err));
LOG_ERROR("Error calling libusb_handle_events_timeout failed, result:%s", libusb_error_name(err));
result = K4A_RESULT_FAILED;
}
}
@ -321,7 +310,7 @@ k4a_result_t usb_cmd_stream_start(usbcmd_t usbcmd_handle, size_t payload_size)
if (usbcmd->stream_going)
{
// Steam already going (Error?)
logger_info(LOGGER_USB_CMD, "Stream already in progress");
LOG_INFO("Stream already in progress", 0);
}
else
{
@ -330,7 +319,7 @@ k4a_result_t usb_cmd_stream_start(usbcmd_t usbcmd_handle, size_t payload_size)
if (ThreadAPI_Create(&(usbcmd->stream_handle), usb_cmd_lib_usb_thread, usbcmd) != THREADAPI_OK)
{
usbcmd->stream_going = false;
logger_error(LOGGER_USB_CMD, "Could not start stream thread");
LOG_ERROR("Could not start stream thread", 0);
}
else
{

Просмотреть файл

@ -428,7 +428,7 @@ capturesync_push_single_capture(k4a_result_t status, capturesync_t sync, bool co
image_dec_ref(image);
image = NULL;
}
logger_info(zone, "Pushing a capture");
LOG_INFO("%s: Pushing a capture", zone);
capturesync_add_capture(sync, status, capture, color_capture);
capture_dec_ref(capture);
}
@ -478,7 +478,7 @@ static void capturesync_thread_generate_sample_ready(capturesync_test_t *test, k
} while ((timing[i].timestamp_usec != UINT64_MAX) && (*result == K4A_RESULT_SUCCEEDED));
logger_info(zone, "Thread exiting");
LOG_INFO("%s: Thread exiting", zone);
}
// Simulate either a streaming depth thread or streaming color thread
@ -550,12 +550,11 @@ static void capturesync_validate_synchronization(capturesync_test_timing_t *test
int i = 0;
do
{
logger_info("cs_main_test_thread",
"TS: %10lld C:%lld.%lld type: %s",
test_data[i].timestamp_usec,
test_data[i].timestamp_usec / FPS_30_IN_US, // frame period
test_data[i].timestamp_usec % FPS_30_IN_US * 10 / FPS_30_IN_US, // tenths of a frame period
(test_data[i].color_capture ? "color" : "depth"));
LOG_INFO("TS: %10lld C:%lld.%lld type: %s",
test_data[i].timestamp_usec,
test_data[i].timestamp_usec / FPS_30_IN_US, // frame period
test_data[i].timestamp_usec % FPS_30_IN_US * 10 / FPS_30_IN_US, // tenths of a frame period
(test_data[i].color_capture ? "color" : "depth"));
if (test_data[i].color_result != NO_CAPTURE && test_data[i].depth_result != NO_CAPTURE)
{
@ -563,7 +562,7 @@ static void capturesync_validate_synchronization(capturesync_test_timing_t *test
uint64_t ts_depth = 0;
uint64_t ts_ir16 = 0;
logger_info("cs_main_test_thread", "Waiting for capture upto %dms", WAIT_TEST_INFINITE);
LOG_INFO("Waiting for capture upto %dms", WAIT_TEST_INFINITE);
while (ts_color == 0 || ts_depth == 0 || ts_ir16 == 0)
{

Просмотреть файл

@ -11,7 +11,7 @@
{ \
if (!(x)) \
{ \
logger_error("PlaybackTest", "%s == false", #x); \
LOG_ERROR("PlaybackTest, %s == false", #x); \
exit(1); \
} \
}
@ -21,7 +21,7 @@
auto _actual = (actual); \
if (_actual != (expected)) \
{ \
logger_error("PlaybackTest", "%s is incorrect. Actual: %d, Expected: %d", #actual, _actual, (expected)); \
LOG_ERROR("PlaybackTest, %s is incorrect. Actual: %d, Expected: %d", #actual, _actual, (expected)); \
return false; \
} \
}
@ -100,7 +100,7 @@ bool validate_test_capture(k4a_capture_t capture,
k4a_image_t color_image = k4a_capture_get_color_image(capture);
if (color_image == NULL)
{
logger_error("PlaybackTest", "Color image is missing");
LOG_ERROR("PlaybackTest, Color image is missing", 0);
return false;
}
bool image_valid =
@ -108,13 +108,13 @@ bool validate_test_capture(k4a_capture_t capture,
k4a_image_release(color_image);
if (!image_valid)
{
logger_error("PlaybackTest", "Color image is invalid");
LOG_ERROR("PlaybackTest, Color image is invalid", 0);
return false;
}
}
else if (k4a_capture_get_color_image(capture) != NULL)
{
logger_error("PlaybackTest", "Color image is set when it should be NULL");
LOG_ERROR("PlaybackTest, Color image is set when it should be NULL", 0);
return false;
}
@ -129,7 +129,7 @@ bool validate_test_capture(k4a_capture_t capture,
k4a_image_t depth_image = k4a_capture_get_depth_image(capture);
if (depth_image == NULL)
{
logger_error("PlaybackTest", "Depth image is missing");
LOG_ERROR("PlaybackTest, Depth image is missing", 0);
return false;
}
bool image_valid = validate_test_image(depth_image,
@ -141,20 +141,20 @@ bool validate_test_capture(k4a_capture_t capture,
k4a_image_release(depth_image);
if (!image_valid)
{
logger_error("PlaybackTest", "Depth image is invalid");
LOG_ERROR("PlaybackTest, Depth image is invalid", 0);
return false;
}
}
else if (k4a_capture_get_depth_image(capture) != NULL)
{
logger_error("PlaybackTest", "Depth image is set when it should be NULL (Passive IR Mode)");
LOG_ERROR("PlaybackTest, Depth image is set when it should be NULL (Passive IR Mode)", 0);
return false;
}
k4a_image_t ir_image = k4a_capture_get_ir_image(capture);
if (ir_image == NULL)
{
logger_error("PlaybackTest", "IR image is missing");
LOG_ERROR("PlaybackTest, IR image is missing", 0);
return false;
}
bool image_valid =
@ -162,23 +162,23 @@ bool validate_test_capture(k4a_capture_t capture,
k4a_image_release(ir_image);
if (!image_valid)
{
logger_error("PlaybackTest", "IR image is invalid");
LOG_ERROR("PlaybackTest, IR image is invalid", 0);
return false;
}
}
else if (k4a_capture_get_depth_image(capture) != NULL)
{
logger_error("PlaybackTest", "Depth image is set when it should be NULL");
LOG_ERROR("PlaybackTest, Depth image is set when it should be NULL", 0);
return false;
}
else if (k4a_capture_get_ir_image(capture) != NULL)
{
logger_error("PlaybackTest", "IR image is set when it should be NULL");
LOG_ERROR("PlaybackTest, IR image is set when it should be NULL", 0);
return false;
}
return true;
}
logger_error("PlaybackTest", "Capture is NULL");
LOG_ERROR("PlaybackTest, Capture is NULL", 0);
return false;
}
@ -238,17 +238,13 @@ bool validate_test_image(k4a_image_t image,
{
if (buffer[i] != 0xAABBCCDD)
{
logger_error("PlaybackTest",
"Image data is incorrect (index %d): 0x%X != 0x%X",
i,
buffer[i],
0xAABBCCDD);
LOG_ERROR("PlaybackTest, Image data is incorrect (index %d): 0x%X != 0x%X", i, buffer[i], 0xAABBCCDD);
return false;
}
}
return true;
}
logger_error("PlaybackTest", "Image is NULL");
LOG_ERROR("PlaybackTest, Image is NULL", 0);
return false;
}