<commit_before>#include <iostream>

#ifdef ENABLE_AUDIO
#include "SDL_mixer.h"
#endif

#include "misc/audiomanager.h"
#include "resources/resourcemanager.h"

namespace Zabbr {
	#ifdef ENABLE_AUDIO
	/**
	 * Callback called when a channel stops playing.
	 *
	 * @param channel
	*/
	void onFinishChannel(int channel) {
		// We can not free the resource here
		// Chances are that it is freed by the resource manager
		// and we can't call SDL_Mixer function in this callback...
		// (according to SDL_Mixer docs)
		AudioManager::get().fFreedResources.push_back(AudioManager::get().fSoundResources[channel]);
		AudioManager::get().fSoundResources[channel] = 0;
	}
	#endif

	/**
	 * Constructor.
	*/
	AudioManager::AudioManager(): fMuted(false), fPlayMusic(false) {
		#ifdef ENABLE_AUDIO
		//Mix_Init(MIX_INIT_OGG);
		int error = Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 2, 4096);
		if (error != 0) {
			std::cerr << "Could not load audio: " << Mix_GetError() << std::endl;
		}
		Mix_ChannelFinished(&onFinishChannel);
		#endif
	}
	
	AudioManager::~AudioManager() {
		#ifdef ENABLE_AUDIO
		freeResources();
		Mix_CloseAudio();
		#endif<commit_msg>Play songs for bullets and clusterbombs<commit_after>#include <iostream>

#ifdef ENABLE_AUDIO
#include "SDL_mixer.h"
#endif

#include "misc/audiomanager.h"
#include "resources/resourcemanager.h"

namespace Zabbr {
	#ifdef ENABLE_AUDIO
	/**
	 * Callback called when a channel stops playing.
	 *
	 * @param channel
	*/
	void onFinishChannel(int channel) {
		// We can not free the resource here
		// Chances are that it is freed by the resource manager
		// and we can't call SDL_Mixer function in this callback...
		// (according to SDL_Mixer docs)
		AudioManager::get().fFreedResources.push_back(AudioManager::get().fSoundResources[channel]);
		AudioManager::get().fSoundResources[channel] = 0;
	}
	#endif

	/**
	 * Constructor.
	*/
	AudioManager::AudioManager(): fMuted(false), fPlayMusic(false) {
		#ifdef ENABLE_AUDIO
		//Mix_Init(MIX_INIT_OGG);
		int error = Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, 2, 2048);
		if (error != 0) {
			std::cerr << "Could not load audio: " << Mix_GetError() << std::endl;
		}
		Mix_ChannelFinished(&onFinishChannel);
		#endif
	}
	
	AudioManager::~AudioManager() {
		#ifdef ENABLE_AUDIO
		freeResources();
		Mix_CloseAudio();
		#endif
{'fraction_non_alphanumeric': 0.1298366294067068, 'fraction_numerical': 0.00816852966466036, 'mean_word_length': 4.514218009478673, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 5, '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': '6920841', 'n_tokens_mistral': 875, 'n_tokens_neox': 795, 'n_words': 188}