<commit_before>#include "stdafx.h"
#include "EventWrapper.h"
#include "AudioEndPointLibrary.h"
#include "Audio.EndPoint.Controller.Wrapper.h"
#include "Events.h"
#include "AudioDeviceWrapper.h"

using namespace AudioEndPoint;

namespace AudioEndPointControllerWrapper {
    EventWrapper::EventWrapper()
    {
        try
        {
            m_added = CAudioEndPointLibrary::GetInstance().Signals->DeviceAdded.Register([](AudioDevicePtr device)
            {
                AudioController::RaiseAdded(gcnew DeviceAddedEvent(gcnew AudioDeviceWrapper(device)));
            });

            m_removed = CAudioEndPointLibrary::GetInstance().Signals->DeviceRemoved.Register([](AudioDevicePtr device)
            {
                AudioController::RaiseRemoved(gcnew DeviceRemovedEvent(gcnew AudioDeviceWrapper(device)));
            });

            m_default = CAudioEndPointLibrary::GetInstance().Signals->DeviceDefaultChanged.Register([](AudioDevicePtr device, ERole role)
            {
                AudioController::RaiseDefault(gcnew DeviceDefaultChangedEvent(gcnew AudioDeviceWrapper(device), static_cast<Role>(role)));
            });

            m_state = CAudioEndPointLibrary::GetInstance().Signals->DeviceStateChanged.Register([](AudioDevicePtr device, DefSound::EDeviceState prev, DefSound::EDeviceState cur)
            {
                AudioController::RaiseState(gcnew DeviceStateChangedEvent(gcnew AudioDeviceWrapper(device), static_cast<DeviceState>(prev), static_cast<DeviceState>(cur)));
            });
            m_loaded = true;
        } catch(...)
        {
            m_loaded = false;
        }
    }
    EventWrapper::~EventWrapper()
    {
        m_added.m_signal->Unregister(m_added);
        m_removed.m_signal->Unregister(m_removed);
        m_default.m_signal->Unregister(m_default);
        m_state.m_signal->Unregister(m_state);
        if(m_loaded)
        {
            try
            {
                CAudioEndPointLibrary::GetInstance().UnRegisterNotificationClient();
            }
            catch (...)
            {

            }
        }
    }
}<commit_msg>The library auto unregister itself<commit_after>#include "stdafx.h"
#include "EventWrapper.h"
#include "AudioEndPointLibrary.h"
#include "Audio.EndPoint.Controller.Wrapper.h"
#include "Events.h"
#include "AudioDeviceWrapper.h"

using namespace AudioEndPoint;

namespace AudioEndPointControllerWrapper {
    EventWrapper::EventWrapper()
    {
        try
        {
            m_added = CAudioEndPointLibrary::GetInstance().Signals->DeviceAdded.Register([](AudioDevicePtr device)
            {
                AudioController::RaiseAdded(gcnew DeviceAddedEvent(gcnew AudioDeviceWrapper(device)));
            });

            m_removed = CAudioEndPointLibrary::GetInstance().Signals->DeviceRemoved.Register([](AudioDevicePtr device)
            {
                AudioController::RaiseRemoved(gcnew DeviceRemovedEvent(gcnew AudioDeviceWrapper(device)));
            });

            m_default = CAudioEndPointLibrary::GetInstance().Signals->DeviceDefaultChanged.Register([](AudioDevicePtr device, ERole role)
            {
                AudioController::RaiseDefault(gcnew DeviceDefaultChangedEvent(gcnew AudioDeviceWrapper(device), static_cast<Role>(role)));
            });

            m_state = CAudioEndPointLibrary::GetInstance().Signals->DeviceStateChanged.Register([](AudioDevicePtr device, DefSound::EDeviceState prev, DefSound::EDeviceState cur)
            {
                AudioController::RaiseState(gcnew DeviceStateChangedEvent(gcnew AudioDeviceWrapper(device), static_cast<DeviceState>(prev), static_cast<DeviceState>(cur)));
            });
            m_loaded = true;
        } catch(...)
        {
            m_loaded = false;
        }
    }
    EventWrapper::~EventWrapper()
    {
        m_added.m_signal->Unregister(m_added);
        m_removed.m_signal->Unregister(m_removed);
        m_default.m_signal->Unregister(m_default);
        m_state.m_signal->Unregister(m_state);
    }
}
{'fraction_non_alphanumeric': 0.11119402985074626, 'fraction_numerical': 0.0, 'mean_word_length': 2.892545982575024, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 25, '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': '5444822', 'n_tokens_mistral': 1084, 'n_tokens_neox': 1083, 'n_words': 132}