From 26f1b7eac5e2dd3b36dbae38dfdc0ae270705aea Mon Sep 17 00:00:00 2001 From: ronag Date: Wed, 21 Mar 2012 18:54:52 +0000 Subject: [PATCH] 2.1.0: -oal_consumer: Lazy initialization. git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.1.0@2701 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d --- README.txt | 36 ++++++++++++++------- modules/ffmpeg/consumer/ffmpeg_consumer.cpp | 36 ++++++++++----------- modules/oal/consumer/oal_consumer.cpp | 15 ++++++--- 3 files changed, 53 insertions(+), 34 deletions(-) diff --git a/README.txt b/README.txt index bbb14739a..c417efa72 100644 --- a/README.txt +++ b/README.txt @@ -9,32 +9,44 @@ Please note that while the current CasparCG Client (version 1.8) will continue to work with CasparCG Server 2.0, you won't be able to trigger many of the new features. Please use the provided AIR app to try out the new functionality or add the new features to you -control application (you can find the documentation on the wiki or ask in the forums). +control application (you can find the documentation on the wiki or ask in the forums). + +====================================================================================================== +INSTALLATION ====================================================================================================== -INSTALLATION ====================================================================================================== -You can place the CasparCG Server 2.0 folder anywhere you like, and even move it. -If you don't already have Flash installed, use the bundled version in the Flash folder +You can place the CasparCG Server 2.0 folder anywhere you like, and even move it. + +If you don't already have Flash installed, use the bundled version in the Flash folder + +====================================================================================================== +CONFIGURATION ====================================================================================================== -CONFIGURATION ====================================================================================================== By default, CasparCG Server will look in the media folder for videos, audio and images files. Flash templates are stored in the templates folder. If you want to change the location (for example to a faster disk) -you just change the paths in the casparcg.config file. -* How to enable Screen consumer +you just change the paths in the casparcg.config file. + +* How to enable Screen consumer + Open casparcg.config and use the following node for consumers: - -* How to enable a DeckLink card and how to get video in and key output. -Open casparcg.config and use the following node for consumers: + + +* How to enable a DeckLink card and how to get video in and key output. + +Open casparcg.config and use the following node for consumers: + - + + # Tip: - At the bottom of the casparcg.config file you will find comments which document additional settings. + +At the bottom of the casparcg.config file you will find comments which document additional settings. ====================================================================================================== LICENSING diff --git a/modules/ffmpeg/consumer/ffmpeg_consumer.cpp b/modules/ffmpeg/consumer/ffmpeg_consumer.cpp index 2d6351326..437511c92 100644 --- a/modules/ffmpeg/consumer/ffmpeg_consumer.cpp +++ b/modules/ffmpeg/consumer/ffmpeg_consumer.cpp @@ -462,9 +462,9 @@ public: av_frame->top_field_first = format_desc_.field_mode == core::field_mode::upper; av_frame->pts = frame_number_++; - AVPacket pkt; - av_init_packet(&pkt); - pkt.data = nullptr; + AVPacket pkt; + av_init_packet(&pkt); + pkt.data = nullptr; pkt.size = 0; int got_packet = 0; @@ -473,10 +473,10 @@ public: if(!got_packet) return; - - if (pkt.pts != AV_NOPTS_VALUE) - pkt.pts = av_rescale_q(pkt.pts, enc->time_base, video_st_->time_base); - if (pkt.dts != AV_NOPTS_VALUE) + + if (pkt.pts != AV_NOPTS_VALUE) + pkt.pts = av_rescale_q(pkt.pts, enc->time_base, video_st_->time_base); + if (pkt.dts != AV_NOPTS_VALUE) pkt.dts = av_rescale_q(pkt.dts, enc->time_base, video_st_->time_base); pkt.stream_index = video_st_->index; @@ -511,13 +511,13 @@ public: while(audio_buffer_.size() >= frame_size) { - std::shared_ptr av_frame(avcodec_alloc_frame(), av_free); - avcodec_get_frame_defaults(av_frame.get()); + std::shared_ptr av_frame(avcodec_alloc_frame(), av_free); + avcodec_get_frame_defaults(av_frame.get()); av_frame->nb_samples = frame_size / (enc->channels * av_get_bytes_per_sample(enc->sample_fmt)); - AVPacket pkt; - av_init_packet(&pkt); - pkt.data = nullptr; + AVPacket pkt; + av_init_packet(&pkt); + pkt.data = nullptr; pkt.size = 0; THROW_ON_ERROR2(avcodec_fill_audio_frame(av_frame.get(), enc->channels, enc->sample_fmt, audio_buffer_.data(), frame_size, 1), "[ffmpeg_consumer]"); @@ -530,12 +530,12 @@ public: if(!got_packet) return; - - if (pkt.pts != AV_NOPTS_VALUE) - pkt.pts = av_rescale_q(pkt.pts, enc->time_base, audio_st_->time_base); - if (pkt.dts != AV_NOPTS_VALUE) - pkt.dts = av_rescale_q(pkt.dts, enc->time_base, audio_st_->time_base); - if (pkt.duration > 0) + + if (pkt.pts != AV_NOPTS_VALUE) + pkt.pts = av_rescale_q(pkt.pts, enc->time_base, audio_st_->time_base); + if (pkt.dts != AV_NOPTS_VALUE) + pkt.dts = av_rescale_q(pkt.dts, enc->time_base, audio_st_->time_base); + if (pkt.duration > 0) pkt.duration = static_cast(av_rescale_q(pkt.duration, enc->time_base, audio_st_->time_base)); pkt.stream_index = audio_st_->index; diff --git a/modules/oal/consumer/oal_consumer.cpp b/modules/oal/consumer/oal_consumer.cpp index 37bb8f271..7d76538f4 100644 --- a/modules/oal/consumer/oal_consumer.cpp +++ b/modules/oal/consumer/oal_consumer.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include @@ -92,10 +93,16 @@ public: } }; -struct oal_consumer : public core::frame_consumer +void init_device() { - static device device_; + static std::unique_ptr instance; + static boost::once_flag f = BOOST_ONCE_INIT; + + boost::call_once(f, []{instance.reset(new device());}); +} +struct oal_consumer : public core::frame_consumer +{ spl::shared_ptr graph_; boost::timer perf_timer_; int channel_index_; @@ -115,6 +122,8 @@ public: { buffers_.assign(0); + init_device(); + graph_->set_color("tick-time", diagnostics::color(0.0f, 0.6f, 0.9f)); graph_->set_color("dropped-frame", diagnostics::color(0.3f, 0.6f, 0.3f)); graph_->set_color("late-frame", diagnostics::color(0.6f, 0.3f, 0.3f)); @@ -240,8 +249,6 @@ public: } }; -device oal_consumer::device_; - spl::shared_ptr create_consumer(const std::vector& params) { if(params.size() < 1 || params[0] != L"AUDIO") -- 2.39.2