<commit_before>//
//  yas_audio_tap_node.cpp
//  Copyright (c) 2015 <NAME>.
//

#include "yas_audio_tap_node.h"

using namespace yas;

#pragma mark - node_core

namespace yas
{
    class audio_tap_node_core : public audio_node_core
    {
       public:
        audio_tap_node::render_f render_function;
    };
}

#pragma mark - tap_node

class audio_tap_node::impl
{
   public:
    render_f render_function;

    void set_node_core_on_render(const audio_node_core_sptr &node_core)
    {
        std::lock_guard<std::recursive_mutex> lock(_mutex);
        _node_core_on_render = node_core;
    }

    audio_node_core_sptr node_core_on_render() const
    {
        std::lock_guard<std::recursive_mutex> lock(_mutex);
        return _node_core_on_render;
    }

   private:
    audio_node_core_sptr _node_core_on_render;
    mutable std::recursive_mutex _mutex;
};

audio_tap_node_sptr audio_tap_node::create()
{
    return audio_tap_node_sptr(new audio_tap_node());
}

audio_tap_node::audio_tap_node() : audio_node(), _impl(std::make_unique<impl>())
{
}

audio_tap_node::~audio_tap_node() = default;

void audio_tap_node::set_render_function(const render_f &render_function)
{
    _impl->render_function = render_function;

    update_node_core();
}

uint32_t audio_tap_node::input_bus_count() const
{
    return 1;
}

uint32_t audio_tap_node::output_bus_count() const
{
    return 1;
}

void audio_tap_node::render(const audio_pcm_buffer_sptr &buffer, const uint32_t bus_idx, const audio_time_sptr &when)
{
    super_class::render(buffer, bus_idx, when);

    if (auto core = node_core()) {
        _impl->set_node_core_on_render(core);

        audio_tap_node_core *tap_node_core = dynamic_cast<audio_tap_node_core *>(core.get());
        auto &render_function = tap_node_core->render_function;

        if (render_function) {
            render_function(buffer, bus_idx, when);
        } else {
            render_source(buffer, bus_idx, when);
        }

        _impl->set_node_core_on_render(nullptr);
    }
}

audio_connection_sptr audio_tap_node::input_connection_on_render(const uint32_t bus_idx) const
{
    return _impl->node_core_on_render()->input_connection(bus_idx);
}

audio_connection_sptr audio_tap_node::output_connection_on_render(const uint32_t bus_idx) const
{
    return _impl->node_core_on_render()->output_connection(bus_idx);
}

audio_connection_smap audio_tap_node::input_connections_on_render() const
{
    return _impl->node_core_on_render()->input_connections();
}

audio_connection_smap audio_tap_node::output_connections_on_render() const
{
    return _impl->node_core_on_render()->output_connections();
}<commit_msg>node_core_on_render<commit_after>//
//  yas_audio_tap_node.cpp
//  Copyright (c) 2015 <NAME>.
//

#include "yas_audio_tap_node.h"

using namespace yas;

#pragma mark - node_core

namespace yas
{
    class audio_tap_node_core : public audio_node_core
    {
       public:
        audio_tap_node::render_f render_function;
    };
}

#pragma mark - tap_node

class audio_tap_node::impl
{
   public:
    render_f render_function;
    audio_node_core_sptr node_core_on_render;
};

audio_tap_node_sptr audio_tap_node::create()
{
    return audio_tap_node_sptr(new audio_tap_node());
}

audio_tap_node::audio_tap_node() : audio_node(), _impl(std::make_unique<impl>())
{
}

audio_tap_node::~audio_tap_node() = default;

void audio_tap_node::set_render_function(const render_f &render_function)
{
    _impl->render_function = render_function;

    update_node_core();
}

uint32_t audio_tap_node::input_bus_count() const
{
    return 1;
}

uint32_t audio_tap_node::output_bus_count() const
{
    return 1;
}

void audio_tap_node::render(const audio_pcm_buffer_sptr &buffer, const uint32_t bus_idx, const audio_time_sptr &when)
{
    super_class::render(buffer, bus_idx, when);

    if (auto core = node_core()) {
        _impl->node_core_on_render = core;

        audio_tap_node_core *tap_node_core = dynamic_cast<audio_tap_node_core *>(core.get());
        auto &render_function = tap_node_core->render_function;

        if (render_function) {
            render_function(buffer, bus_idx, when);
        } else {
            render_source(buffer, bus_idx, when);
        }

        _impl->node_core_on_render = nullptr;
    }
}

audio_connection_sptr audio_tap_node::input_connection_on_render(const uint32_t bus_idx) const
{
    return _impl->node_core_on_render->input_connection(bus_idx);
}

audio_connection_sptr audio_tap_node::output_connection_on_render(const uint32_t bus_idx) const
{
    return _impl->node_core_on_render->output_connection(bus_idx);
}

audio_connection_smap audio_tap_node::input_connections_on_render() const
{
    return _impl->node_core_on_render->input_connections();
}

audio_connection_smap audio_tap_node::output_connections_on_render() const
{
    return _impl->node_core_on_render->output_connections();
}
{'fraction_non_alphanumeric': 0.10079901659496004, 'fraction_numerical': 0.006556033599672198, 'mean_word_length': 4.7367802585193886, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6529679', 'n_tokens_mistral': 1804, 'n_tokens_neox': 1711, 'n_words': 259}