<commit_before>#include "device_impl.h"
#include "../logger.h"
#include "check.h"
#include <AL/alc.h>
#include <AL/alext.h>
#include <cstdint>
#include <sstream>

namespace audio
{
namespace priv
{
static bool has_efx(ALCdevice* dev)
{
	return (alcIsExtensionPresent(dev, "ALC_EXT_EFX") == AL_TRUE); // ALC_TRUE
}

static std::string info()
{
	std::stringstream ss;
	if(alGetString(AL_VERSION))
		ss << "OpenAL version: " << alGetString(AL_VERSION) << std::endl;
	if(alGetString(AL_RENDERER))
		ss << "OpenAL renderer: " << alGetString(AL_RENDERER) << std::endl;
	if(alGetString(AL_VENDOR))
		ss << "OpenAL vendor: " << alGetString(AL_VENDOR) << std::endl;
	if(alGetString(AL_EXTENSIONS))
		ss << "OpenAL extensions: " << alGetString(AL_EXTENSIONS) << std::endl;

	return ss.str();
}

device_impl::device_impl(int devnum)
{
	// device name
	auto devices = enumerate();
	for(const auto& dev : devices)
	{
		log_info("Audio device: " + dev);
	}

	if(devnum >= 0 && devnum < int(devices.size()))
		_device_id = devices[std::size_t(devnum)];

	// select device
	dev = alcOpenDevice(_device_id.empty() ? 0 : _device_id.c_str());

	if(!dev)
	{
		log_error("Cant open audio device: " + _device_id);
		return;
	}
	bool has_efx_ = has_efx(dev);

	ALint attribs[4] = {0};
	attribs[0] = ALC_MAX_AUXILIARY_SENDS;
	attribs[1] = 4;

	// select device
	ctx = alcCreateContext(dev, has_efx_ ? attribs : nullptr);

	if(!ctx)
	{
		log_error("Cant create audio context for device: " + _device_id);
		return;
	}
	enable();

	alCheck(alDistanceModel(AL_LINEAR_DISTANCE));

	_info = info();
}

device_impl::~device_impl()
{<commit_msg>added log<commit_after>#include "device_impl.h"
#include "../logger.h"
#include "check.h"
#include <AL/alc.h>
#include <AL/alext.h>
#include <cstdint>
#include <sstream>

namespace audio
{
namespace priv
{
static bool has_efx(ALCdevice* dev)
{
	return (alcIsExtensionPresent(dev, "ALC_EXT_EFX") == AL_TRUE); // ALC_TRUE
}

static std::string info()
{
	std::stringstream ss;
	if(alGetString(AL_VERSION))
		ss << "OpenAL version: " << alGetString(AL_VERSION) << std::endl;
	if(alGetString(AL_RENDERER))
		ss << "OpenAL renderer: " << alGetString(AL_RENDERER) << std::endl;
	if(alGetString(AL_VENDOR))
		ss << "OpenAL vendor: " << alGetString(AL_VENDOR) << std::endl;
	if(alGetString(AL_EXTENSIONS))
		ss << "OpenAL extensions: " << alGetString(AL_EXTENSIONS) << std::endl;

	return ss.str();
}

device_impl::device_impl(int devnum)
{
	// device name
	auto devices = enumerate();
	for(const auto& dev : devices)
	{
		log_info("Audio device: " + dev);
	}

	if(devnum >= 0 && devnum < int(devices.size()))
		_device_id = devices[std::size_t(devnum)];

	// select device
	dev = alcOpenDevice(_device_id.empty() ? 0 : _device_id.c_str());

	if(!dev)
	{
		log_error("Cant open audio device: " + _device_id);
		return;
	}
	bool has_efx_ = has_efx(dev);

	ALint attribs[4] = {0};
	attribs[0] = ALC_MAX_AUXILIARY_SENDS;
	attribs[1] = 4;

	// select device
	ctx = alcCreateContext(dev, has_efx_ ? attribs : nullptr);

	if(!ctx)
	{
		log_error("Cant create audio context for device: " + _device_id);
		return;
	}
	enable();

	alCheck(alDistanceModel(AL_LINEAR_DISTANCE));

	_info = info();

	log_info("Using open audio device: " + _device_id);
}

device_impl::~device_impl()
{
{'fraction_non_alphanumeric': 0.16575091575091574, 'fraction_numerical': 0.004273504273504274, 'mean_word_length': 5.057301293900185, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 13, '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': '235022', 'n_tokens_mistral': 1345, 'n_tokens_neox': 1309, 'n_words': 250}