<commit_before>#include <Display.h>
#include <Utils.h>
#include <SDL.h>
#include <Surface.h>
#include <nme/NmeCffi.h>
#include <KeyCodes.h>
#include <map>
#include <Sound.h>

#ifdef NME_MIXER
#include <SDL_mixer.h>
#endif


namespace nme
{
   

static int sgDesktopWidth = 0;
static int sgDesktopHeight = 0;
static Rect sgWindowRect = Rect(0, 0, 0, 0);
static bool sgInitCalled = false;
static bool sgJoystickEnabled = false;
static int  sgShaderFlags = 0;
static bool sgIsOGL2 = false;

enum { NO_TOUCH = -1 };


int InitSDL()
{   
   if (sgInitCalled)
      return 0;
      
   sgInitCalled = true;
   
   #ifdef NME_MIXER
   int audioFlag = SDL_INIT_AUDIO;
   #else
   int audioFlag = 0;
   #endif
   int err = SDL_Init(SDL_INIT_VIDEO | audioFlag | SDL_INIT_TIMER);
   
   if (err == 0 && SDL_InitSubSystem (SDL_INIT_JOYSTICK) == 0)
   {
      sgJoystickEnabled = true;
   }
   
   return err;
}

static void openAudio()
{
   gSDLAudioState = sdaOpen;

   #ifdef HX_WINDOWS
   int chunksize = 2048;
   #else
   int chunksize = 4096;
   #endif
   
   int frequency = 44100;
   //int frequency = MIX_DEFAULT_FREQUENCY //22050
   //The default frequency would have less latency, but is incompatible with the average MP3 file
   
   if (Mix_OpenAudio(frequency, MIX_DEFAULT_FORMAT, MIX_DEFAULT_CHANNELS, chunksize) != 0)
   {
      fprintf(stderr,"Could not open sound: %s\n", Mix_GetError());
      gSDLAudioState = sdaError;
   }
}

void InitSDLAudio()
{
   SDL_Init(SDL_INIT_AUDIO);
   openAudio();
}



class SDLSurf : public Surface
{<commit_msg>Fix for using SDL2 without Mixer<commit_after>#include <Display.h>
#include <Utils.h>
#include <SDL.h>
#include <Surface.h>
#include <nme/NmeCffi.h>
#include <KeyCodes.h>
#include <map>
#include <Sound.h>

#ifdef NME_MIXER
#include <SDL_mixer.h>
#endif


namespace nme
{
   

static int sgDesktopWidth = 0;
static int sgDesktopHeight = 0;
static Rect sgWindowRect = Rect(0, 0, 0, 0);
static bool sgInitCalled = false;
static bool sgJoystickEnabled = false;
static int  sgShaderFlags = 0;
static bool sgIsOGL2 = false;

enum { NO_TOUCH = -1 };


int InitSDL()
{   
   if (sgInitCalled)
      return 0;
      
   sgInitCalled = true;
   
   #ifdef NME_MIXER
   int audioFlag = SDL_INIT_AUDIO;
   #else
   int audioFlag = 0;
   #endif
   int err = SDL_Init(SDL_INIT_VIDEO | audioFlag | SDL_INIT_TIMER);
   
   if (err == 0 && SDL_InitSubSystem (SDL_INIT_JOYSTICK) == 0)
   {
      sgJoystickEnabled = true;
   }
   
   return err;
}

static void openAudio()
{
   #ifdef NME_MIXER
   gSDLAudioState = sdaOpen;

   #ifdef HX_WINDOWS
   int chunksize = 2048;
   #else
   int chunksize = 4096;
   #endif
   
   int frequency = 44100;
   //int frequency = MIX_DEFAULT_FREQUENCY //22050
   //The default frequency would have less latency, but is incompatible with the average MP3 file
   
   if (Mix_OpenAudio(frequency, MIX_DEFAULT_FORMAT, MIX_DEFAULT_CHANNELS, chunksize) != 0)
   {
      fprintf(stderr,"Could not open sound: %s\n", Mix_GetError());
      gSDLAudioState = sdaError;
   }
   #endif
}

void InitSDLAudio()
{
   SDL_Init(SDL_INIT_AUDIO);
   openAudio();
}



class SDLSurf : public Surface
{
{'fraction_non_alphanumeric': 0.10416005080978089, 'fraction_numerical': 0.02127659574468085, 'mean_word_length': 3.3448275862068964, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '4487819', 'n_tokens_mistral': 1275, 'n_tokens_neox': 1174, 'n_words': 306}