Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
* LICENSE file in the root directory of this source tree.
*/

#include "libspdl/core/detail/logging.h"
#include "libspdl/common/logging.h"

#include <fmt/core.h>

namespace spdl::core::detail {
namespace spdl::common {

// TODO: Add stacktrace
std::string get_err_str(
Expand All @@ -29,4 +29,4 @@ std::string get_internal_err_str(
location.line());
}

} // namespace spdl::core::detail
} // namespace spdl::common
35 changes: 19 additions & 16 deletions src/libspdl/core/detail/logging.h → src/libspdl/common/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

#pragma once

#include <libspdl/core/types.h>
#include <glog/logging.h>

#include <exception>
#include <stdexcept>
#include <string_view>
#include <version>

Expand All @@ -27,7 +27,7 @@
"Neither <source_location> or <experimental/source_location> is available."
#endif

namespace spdl::core::detail {
namespace spdl::common {

#if defined SPDL_USE_CUDA && __has_include(<experimental/source_location>)
using std::experimental::source_location;
Expand All @@ -45,20 +45,23 @@ std::string get_internal_err_str(
const std::string_view msg,
const source_location& location);

} // namespace spdl::core::detail
/// Exception thrown when unexpected internal error occurs.
class InternalError : public std::logic_error {
using std::logic_error::logic_error;
};

#define SPDL_FAIL(msg) \
throw std::runtime_error( \
spdl::core::detail::get_err_str( \
msg, spdl::core::detail::source_location::current()))
} // namespace spdl::common

#define SPDL_FAIL_INTERNAL(msg) \
throw spdl::core::InternalError( \
spdl::core::detail::get_internal_err_str( \
msg, spdl::core::detail::source_location::current()))
#define SPDL_FAIL(msg) \
throw std::runtime_error( \
spdl::common::get_err_str( \
msg, spdl::common::source_location::current()))

#include <glog/logging.h>
#define SPDL_FAIL_INTERNAL(msg) \
throw spdl::common::InternalError( \
spdl::common::get_internal_err_str( \
msg, spdl::common::source_location::current()))

#define SPDL_WARN(msg) \
LOG(WARNING) << (spdl::core::detail::get_err_str( \
msg, spdl::core::detail::source_location::current()))
#define SPDL_WARN(msg) \
LOG(WARNING) << (spdl::common::get_err_str( \
msg, spdl::common::source_location::current()))
23 changes: 23 additions & 0 deletions src/libspdl/common/tracing.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/

#pragma once

#ifndef SPDL_USE_TRACING

#define TRACE_COUNTER(...)
#define TRACE_EVENT(...)
#define TRACE_EVENT_BEGIN(...)
#define TRACE_EVENT_END(...)
#define TRACE_EVENT_INSTANT(...)

#else

#include <libspdl/common/tracing/perfetto.h>

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
* LICENSE file in the root directory of this source tree.
*/

#include "libspdl/core/detail/tracing.h"

#ifdef SPDL_USE_TRACING
#include "libspdl/common/tracing/perfetto.h"

#include <glog/logging.h>

Expand Down Expand Up @@ -56,5 +54,3 @@ void stop_tracing_session(std::unique_ptr<perfetto::TracingSession> session) {
}

} // namespace spdl::core::detail

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,6 @@

#pragma once

#ifndef SPDL_USE_TRACING

#define TRACE_COUNTER(...)
#define TRACE_EVENT(...)
#define TRACE_EVENT_BEGIN(...)
#define TRACE_EVENT_END(...)
#define TRACE_EVENT_INSTANT(...)

#else

#include <perfetto.h>

PERFETTO_DEFINE_CATEGORIES(
Expand All @@ -37,5 +27,3 @@ std::unique_ptr<perfetto::TracingSession> start_tracing_session(
void stop_tracing_session(std::unique_ptr<perfetto::TracingSession> sess);

} // namespace spdl::core::detail

#endif
2 changes: 1 addition & 1 deletion src/libspdl/core/buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <libspdl/core/buffer.h>

#include "libspdl/core/detail/logging.h"
#include "libspdl/common/logging.h"

#include <fmt/format.h>
#include <glog/logging.h>
Expand Down
2 changes: 1 addition & 1 deletion src/libspdl/core/codec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

#include <libspdl/core/codec.h>

#include "libspdl/common/logging.h"
#include "libspdl/core/detail/ffmpeg/compat.h"
#include "libspdl/core/detail/ffmpeg/logging.h"
#include "libspdl/core/detail/logging.h"

#include <fmt/core.h>
#include <fmt/format.h>
Expand Down
4 changes: 2 additions & 2 deletions src/libspdl/core/decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

#include <libspdl/core/decoder.h>

#include "libspdl/common/logging.h"
#include "libspdl/common/tracing.h"
#include "libspdl/core/detail/ffmpeg/ctx_utils.h"
#include "libspdl/core/detail/ffmpeg/decoder.h"
#include "libspdl/core/detail/ffmpeg/filter_graph.h"
#include "libspdl/core/detail/logging.h"
#include "libspdl/core/detail/tracing.h"

namespace spdl::core {
////////////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion src/libspdl/core/demuxing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

#include <libspdl/core/demuxing.h>

#include "libspdl/common/tracing.h"
#include "libspdl/core/detail/ffmpeg/demuxer.h"
#include "libspdl/core/detail/ffmpeg/logging.h"
#include "libspdl/core/detail/tracing.h"

namespace spdl::core {
namespace detail {
Expand Down
4 changes: 2 additions & 2 deletions src/libspdl/core/detail/ffmpeg/bsf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#include "libspdl/core/detail/ffmpeg/bsf.h"
#include "libspdl/core/detail/ffmpeg/logging.h"

#include "libspdl/core/detail/logging.h"
#include "libspdl/core/detail/tracing.h"
#include "libspdl/common/logging.h"
#include "libspdl/common/tracing.h"

namespace spdl::core::detail {
namespace {
Expand Down
4 changes: 2 additions & 2 deletions src/libspdl/core/detail/ffmpeg/conversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

#include <libspdl/core/conversion.h>

#include "libspdl/common/logging.h"
#include "libspdl/common/tracing.h"
#include "libspdl/core/detail/ffmpeg/compat.h"
#include "libspdl/core/detail/ffmpeg/logging.h"
#include "libspdl/core/detail/ffmpeg/wrappers.h"
#include "libspdl/core/detail/logging.h"
#include "libspdl/core/detail/tracing.h"

#include <fmt/format.h>
#include <glog/logging.h>
Expand Down
2 changes: 1 addition & 1 deletion src/libspdl/core/detail/ffmpeg/ctx_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

#include "libspdl/core/detail/ffmpeg/ctx_utils.h"

#include "libspdl/common/tracing.h"
#include "libspdl/core/detail/ffmpeg/compat.h"
#include "libspdl/core/detail/ffmpeg/logging.h"
#include "libspdl/core/detail/tracing.h"

#include <fmt/format.h>
#include <glog/logging.h>
Expand Down
2 changes: 1 addition & 1 deletion src/libspdl/core/detail/ffmpeg/decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
#include <libspdl/core/rational_utils.h>
#include <libspdl/core/utils.h>

#include "libspdl/common/tracing.h"
#include "libspdl/core/detail/ffmpeg/ctx_utils.h"
#include "libspdl/core/detail/ffmpeg/logging.h"
#include "libspdl/core/detail/tracing.h"

#include <glog/logging.h>

Expand Down
4 changes: 2 additions & 2 deletions src/libspdl/core/detail/ffmpeg/demuxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

#include <libspdl/core/rational_utils.h>

#include "libspdl/common/logging.h"
#include "libspdl/common/tracing.h"
#include "libspdl/core/detail/ffmpeg/logging.h"
#include "libspdl/core/detail/logging.h"
#include "libspdl/core/detail/tracing.h"

#include <fmt/format.h>

Expand Down
2 changes: 1 addition & 1 deletion src/libspdl/core/detail/ffmpeg/encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
#include "libspdl/core/detail/ffmpeg/encoder.h"

#include <libspdl/core/generator.h>
#include "libspdl/common/logging.h"
#include "libspdl/core/detail/ffmpeg/compat.h"
#include "libspdl/core/detail/ffmpeg/ctx_utils.h"
#include "libspdl/core/detail/ffmpeg/logging.h"
#include "libspdl/core/detail/logging.h"

#include <fmt/core.h>
#include <fmt/format.h>
Expand Down
2 changes: 1 addition & 1 deletion src/libspdl/core/detail/ffmpeg/filter_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

#include "libspdl/core/detail/ffmpeg/filter_graph.h"

#include "libspdl/common/tracing.h"
#include "libspdl/core/detail/ffmpeg/compat.h"
#include "libspdl/core/detail/ffmpeg/logging.h"
#include "libspdl/core/detail/tracing.h"

#include <fmt/format.h>
#include <glog/logging.h>
Expand Down
2 changes: 1 addition & 1 deletion src/libspdl/core/detail/ffmpeg/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#pragma once

#include "libspdl/core/detail/logging.h"
#include "libspdl/common/logging.h"

#include <fmt/core.h>

Expand Down
2 changes: 1 addition & 1 deletion src/libspdl/core/detail/ffmpeg/muxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

#include "libspdl/core/detail/ffmpeg/muxer.h"

#include "libspdl/common/logging.h"
#include "libspdl/core/detail/ffmpeg/compat.h"
#include "libspdl/core/detail/ffmpeg/ctx_utils.h"
#include "libspdl/core/detail/ffmpeg/logging.h"
#include "libspdl/core/detail/ffmpeg/wrappers.h"
#include "libspdl/core/detail/logging.h"

#include <fmt/core.h>
#include <fmt/format.h>
Expand Down
2 changes: 1 addition & 1 deletion src/libspdl/core/detail/ffmpeg/wrappers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

#include "libspdl/core/detail/ffmpeg/wrappers.h"

#include "libspdl/common/tracing.h"
#include "libspdl/core/detail/ffmpeg/logging.h"
#include "libspdl/core/detail/tracing.h"

namespace spdl::core::detail {

Expand Down
2 changes: 1 addition & 1 deletion src/libspdl/core/frames.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
#include <libspdl/core/types.h>
#include <libspdl/core/utils.h>

#include "libspdl/common/tracing.h"
#include "libspdl/core/detail/ffmpeg/compat.h"
#include "libspdl/core/detail/ffmpeg/logging.h"
#include "libspdl/core/detail/ffmpeg/wrappers.h"
#include "libspdl/core/detail/tracing.h"

#include <algorithm>
#include <cassert>
Expand Down
2 changes: 1 addition & 1 deletion src/libspdl/core/muxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

#include <libspdl/core/muxer.h>

#include "libspdl/common/logging.h"
#include "libspdl/core/detail/ffmpeg/muxer.h"
#include "libspdl/core/detail/logging.h"

#include <fmt/core.h>

Expand Down
2 changes: 1 addition & 1 deletion src/libspdl/core/packets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

#include <libspdl/core/rational_utils.h>

#include "libspdl/common/tracing.h"
#include "libspdl/core/detail/ffmpeg/logging.h"
#include "libspdl/core/detail/tracing.h"

#include <fmt/core.h>

Expand Down
4 changes: 2 additions & 2 deletions src/libspdl/core/storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

#include <libspdl/core/storage.h>

#include "libspdl/core/detail/logging.h"
#include "libspdl/core/detail/tracing.h"
#include "libspdl/common/logging.h"
#include "libspdl/common/tracing.h"

#include <utility>

Expand Down
6 changes: 0 additions & 6 deletions src/libspdl/core/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <cstdint>
#include <map>
#include <optional>
#include <stdexcept>
#include <string>

#define SPDL_DEFAULT_BUFFER_SIZE 8096
Expand Down Expand Up @@ -177,9 +176,4 @@ using VideoEncodeConfig = EncodeConfigBase<MediaType::Video>;
/// Audio encoding configuration type alias.
using AudioEncodeConfig = EncodeConfigBase<MediaType::Audio>;

/// Exception thrown when unexpected internal error occurs.
class InternalError : public std::logic_error {
using std::logic_error::logic_error;
};

} // namespace spdl::core
4 changes: 2 additions & 2 deletions src/libspdl/core/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

#include <libspdl/core/utils.h>

#include "libspdl/common/logging.h"
#include "libspdl/common/tracing.h"
#include "libspdl/core/detail/ffmpeg/ctx_utils.h"
#include "libspdl/core/detail/ffmpeg/filter_graph.h"
#include "libspdl/core/detail/logging.h"
#include "libspdl/core/detail/tracing.h"

#include <fmt/core.h>
#include <glog/logging.h>
Expand Down
2 changes: 1 addition & 1 deletion src/libspdl/cuda/color_conversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <libspdl/cuda/buffer.h>
#include <libspdl/cuda/color_conversion.h>

#include "libspdl/core/detail/logging.h"
#include "libspdl/common/logging.h"
#include "libspdl/cuda/detail/color_conversion.h"

#include <fmt/core.h>
Expand Down
2 changes: 1 addition & 1 deletion src/libspdl/cuda/detail/color_conversion.cu
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* LICENSE file in the root directory of this source tree.
*/

#include "libspdl/core/detail/tracing.h"
#include "libspdl/common/tracing.h"
#include "libspdl/cuda/detail/color_conversion.h"
#include "libspdl/cuda/detail/utils.h"

Expand Down
Loading
Loading