<commit_before>/// @file
/// @author  <NAME>
/// @version 3.0
/// 
/// @section LICENSE
/// 
/// This program is free software; you can redistribute it and/or modify it under
/// the terms of the BSD license: http://www.opensource.org/licenses/bsd-license.php
/// 
/// @section DESCRIPTION
/// 
/// iOS specific OpenAL code

#if defined(HAVE_OPENAL) && defined(_IOS)

#import <AVFoundation/AVFoundation.h>
#include "OpenAL_AudioManager.h"

static bool active = true, restoreSessionFailed = false;
static int restoreAttempts = 0;

// on iOS, interruptions such as receiving a call and cancelling it or receiving an alarm cause problems
// with openAL. So this situation needs to be handled properly. 
// reference article: http://benbritten.com/2009/02/02/restarting-openal-after-application-interruption-on-the-iphone/
// modifed to use never iOS apis then the ones in the article

bool restoreiOSAudioSession()
{
	NSError* err = nil;
	[[AVAudioSession sharedInstance] setActive:YES error:&err];

	if (err != nil)
	{
		restoreSessionFailed = true;
		restoreAttempts++;
		return 0;
	}
	else if (restoreAttempts > 0)
	{
		NSLog(@"Succeded restoring iOS Audio Session after %d attempts.", restoreAttempts);
	}
	((xal::OpenAL_AudioManager*) xal::mgr)->resumeOpenALContext();
	active = true;<commit_msg>more logging added to openal<commit_after>/// @file
/// @author  <NAME>
/// @version 3.0
/// 
/// @section LICENSE
/// 
/// This program is free software; you can redistribute it and/or modify it under
/// the terms of the BSD license: http://www.opensource.org/licenses/bsd-license.php
/// 
/// @section DESCRIPTION
/// 
/// iOS specific OpenAL code

#if defined(HAVE_OPENAL) && defined(_IOS)

#import <AVFoundation/AVFoundation.h>
#include "OpenAL_AudioManager.h"

static bool active = true, restoreSessionFailed = false;
static int restoreAttempts = 0;

// on iOS, interruptions such as receiving a call and cancelling it or receiving an alarm cause problems
// with openAL. So this situation needs to be handled properly. 
// reference article: http://benbritten.com/2009/02/02/restarting-openal-after-application-interruption-on-the-iphone/
// modifed to use never iOS apis then the ones in the article

bool restoreiOSAudioSession()
{
	NSError* err = nil;
	[[AVAudioSession sharedInstance] setActive:YES error:&err];

	if (err != nil)
	{
		restoreSessionFailed = true;
		restoreAttempts++;
		if (restoreAttempts % 20 == 0)
			NSLog(@"Failed restoring iOS Audio Session after %d attempts. Will keep trying...", restoreAttempts);
		return 0;
	}
	else if (restoreAttempts > 0)
	{
		NSLog(@"Succeded restoring iOS Audio Session after %d attempts.", restoreAttempts);
	}
	((xal::OpenAL_AudioManager*) xal::mgr)->resumeOpenALContext();
	active = true;
{'fraction_non_alphanumeric': 0.1262277191706075, 'fraction_numerical': 0.010549290651145871, 'mean_word_length': 3.963898916967509, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '907447', 'n_tokens_mistral': 906, 'n_tokens_neox': 838, 'n_words': 273}