#include "StdAfx.h"
+#include "ffmpeg.h"
+
#include <core/frame/audio_channel_layout.h>
#include <common/except.h>
for (int i = 0; i < output.num_channels; ++i)
result << L"|c" << i << L"=c" << i;
- CASPAR_LOG(debug) << "[audio_channel_remapper] Passthru " << input.num_channels << " channels into " << output.num_channels;
+ CASPAR_LOG(trace) << "[audio_channel_remapper] Passthru " << input.num_channels << " channels into " << output.num_channels;
return result.str();
}
}
- CASPAR_LOG(debug) << L"[audio_channel_remapper] Using mix config: " << *mix_config;
+ CASPAR_LOG(trace) << L"[audio_channel_remapper] Using mix config: " << *mix_config;
// Split on | to find the output sections
std::vector<std::wstring> output_sections;
if (output_layout_ == audio_channel_layout::invalid())
CASPAR_THROW_EXCEPTION(invalid_argument() << msg_info(L"Output audio channel layout is invalid"));
- CASPAR_LOG(debug) << L"[audio_channel_remapper] Input: " << input_layout_.print();
- CASPAR_LOG(debug) << L"[audio_channel_remapper] Output: " << output_layout_.print();
+ CASPAR_LOG(trace) << L"[audio_channel_remapper] Input: " << input_layout_.print();
+ CASPAR_LOG(trace) << L"[audio_channel_remapper] Output: " << output_layout_.print();
if (!the_same_layouts_)
{
auto mix_config = mix_repo->get_config(input_layout_.type, output_layout_.type);
auto pan_filter = u8(generate_pan_filter_str(input_layout_, output_layout_, mix_config));
- CASPAR_LOG(debug) << "[audio_channel_remapper] Using audio filter: " << pan_filter;
+ CASPAR_LOG(trace) << "[audio_channel_remapper] Using audio filter: " << pan_filter;
+ auto logging_disabled = ffmpeg::temporary_disable_logging_for_thread(true);
filter_.reset(new ffmpeg::audio_filter(
boost::rational<int>(1, 1),
48000,
pan_filter));
}
else
- CASPAR_LOG(debug) << "[audio_channel_remapper] No remapping/mixing needed because the input and output layout is equal.";
+ CASPAR_LOG(trace) << "[audio_channel_remapper] No remapping/mixing needed because the input and output layout is equal.";
}
audio_buffer mix_and_rearrange(audio_buffer input)
#include "producer/util/util.h"
#include <common/log.h>
+#include <common/os/general_protection_fault.h>
#include <core/consumer/frame_consumer.h>
#include <core/producer/frame_producer.h>
#include <core/system_info_provider.h>
#include <boost/property_tree/ptree.hpp>
+#include <boost/thread/tss.hpp>
#include <tbb/recursive_mutex.h>
{
return make_version(::swscale_version());
}
+bool& get_disable_logging_for_thread()
+{
+ static boost::thread_specific_ptr<bool> disable_logging_for_thread;
+
+ auto local = disable_logging_for_thread.get();
+
+ if (!local)
+ {
+ local = new bool(false);
+ disable_logging_for_thread.reset(local);
+ }
+
+ return *local;
+}
+
+void disable_logging_for_thread()
+{
+ get_disable_logging_for_thread() = true;
+}
+
+bool is_logging_disabled_for_thread()
+{
+ return get_disable_logging_for_thread();
+}
+
+std::shared_ptr<void> temporary_disable_logging_for_thread(bool disable)
+{
+ if (!disable || is_logging_disabled_for_thread())
+ return std::shared_ptr<void>();
+
+ disable_logging_for_thread();
+
+ return std::shared_ptr<void>(nullptr, [](void*)
+ {
+ get_disable_logging_for_thread() = false; // Only works correctly if destructed in same thread as original caller.
+ });
+}
+
+void log_for_thread(void* ptr, int level, const char* fmt, va_list vl)
+{
+ ensure_gpf_handler_installed_for_thread("ffmpeg-thread");
+ if (!get_disable_logging_for_thread()) // It does not matter what the value of the bool is
+ log_callback(ptr, level, fmt, vl);
+}
void init(core::module_dependencies dependencies)
{
av_lockmgr_register(ffmpeg_lock_callback);
- av_log_set_callback(log_callback);
+ av_log_set_callback(log_for_thread);
avfilter_register_all();
//fix_yadif_filter_format_query();
void init(core::module_dependencies dependencies);
void uninit();
+void disable_logging_for_thread();
+std::shared_ptr<void> temporary_disable_logging_for_thread(bool disable);
+bool is_logging_disabled_for_thread();
}}
#include "ffmpeg_producer.h"
#include "../ffmpeg_error.h"
+#include "../ffmpeg.h"
#include "muxer/frame_muxer.h"
#include "input/input.h"
constraints_.width.set(video_decoder_->width());
constraints_.height.set(video_decoder_->height());
- CASPAR_LOG(info) << print() << L" " << video_decoder_->print();
+ if (!is_logging_disabled_for_thread())
+ CASPAR_LOG(info) << print() << L" " << video_decoder_->print();
}
catch(averror_stream_not_found&)
{
decode_next_frame();
- CASPAR_LOG(info) << print() << L" Initialized";
+ if (!is_logging_disabled_for_thread())
+ CASPAR_LOG(info) << print() << L" Initialized";
}
// frame_producer
#include "audio_filter.h"
#include "../../ffmpeg_error.h"
+#include "../../ffmpeg.h"
#include <common/assert.h>
#include <common/except.h>
audio_graph_in_ = filt_asrc;
audio_graph_out_ = filt_asink;
- CASPAR_LOG(info)
- << u16(std::string("\n")
- + avfilter_graph_dump(
- audio_graph_.get(),
- nullptr));
+ if (!is_logging_disabled_for_thread())
+ CASPAR_LOG(info)
+ << u16(std::string("\n")
+ + avfilter_graph_dump(
+ audio_graph_.get(),
+ nullptr));
}
void configure_filtergraph(
#include "filter.h"
#include "../../ffmpeg_error.h"
+#include "../../ffmpeg.h"
#include <common/assert.h>
#include <common/except.h>
video_graph_in_ = filt_vsrc;
video_graph_out_ = filt_vsink;
- CASPAR_LOG(info)
- << u16(std::string("\n")
- + avfilter_graph_dump(
- video_graph_.get(),
- nullptr));
+ if (!is_logging_disabled_for_thread())
+ CASPAR_LOG(info)
+ << u16(std::string("\n")
+ + avfilter_graph_dump(
+ video_graph_.get(),
+ nullptr));
}
void configure_filtergraph(
#include "../util/util.h"
#include "../../ffmpeg_error.h"
+#include "../../ffmpeg.h"
#include <common/diagnostics/graph.h>
#include <common/executor.h>
eof_ = false;
graph_->set_tag(diagnostics::tag_severity::INFO, "seek");
- CASPAR_LOG(debug) << print() << " Seeking: " << target;
+ if (!is_logging_disabled_for_thread())
+ CASPAR_LOG(debug) << print() << " Seeking: " << target;
int flags = AVSEEK_FLAG_FRAME;
if(target == 0)
#include "../filter/filter.h"
#include "../util/util.h"
+#include "../../ffmpeg.h"
#include <core/producer/frame_producer.h>
#include <core/frame/draw_frame.h>
if (previous_frame_ && video->data[0] && is_frame_format_changed(*previous_frame_, *video))
{
// Fixes bug where avfilter crashes server on some DV files (starts in YUV420p but changes to YUV411p after the first frame).
- CASPAR_LOG(info) << L"[frame_muxer] Frame format has changed. Resetting display mode.";
+ if (!ffmpeg::is_logging_disabled_for_thread())
+ CASPAR_LOG(info) << L"[frame_muxer] Frame format has changed. Resetting display mode.";
display_mode_ = display_mode::invalid;
}
if(display_mode_ == display_mode::invalid)
{
- CASPAR_LOG(warning) << L"[frame_muxer] Auto-transcode: Failed to detect display-mode.";
+ if (!ffmpeg::is_logging_disabled_for_thread())
+ CASPAR_LOG(warning) << L"[frame_muxer] Auto-transcode: Failed to detect display-mode.";
display_mode_ = display_mode::simple;
}
std::vector<AVPixelFormat>(),
u8(filter_str)));
- CASPAR_LOG(info) << L"[frame_muxer] " << display_mode_ << L" " << print_mode(frame->width, frame->height, in_fps_, frame->interlaced_frame > 0);
+ if (!ffmpeg::is_logging_disabled_for_thread())
+ CASPAR_LOG(info) << L"[frame_muxer] " << display_mode_ << L" " << print_mode(frame->width, frame->height, in_fps_, frame->interlaced_frame > 0);
}
uint32_t calc_nb_frames(uint32_t nb_frames) const