void x_async_sound_init() { if (!g_sound.g_audio_enable) { printf("sound disabled : discarding openal driver\n"); return ; } if (dev) { printf("err: async_sound_init already initialized!"); return ; } dev = alcOpenDevice(NULL); if(!dev) { fprintf(stderr, "Oops\n"); return ; } ctx = alcCreateContext(dev, NULL); alcMakeContextCurrent(ctx); if(!ctx) { fprintf(stderr, "Oops2\n"); return ; } alGenBuffers(AL_NUM_BUFFERS, buffers); alGenSources(1, &source); if(alGetError() != AL_NO_ERROR) { fprintf(stderr, "Error generating :(\n"); return ; } resetQueues(); x_preload_sounds(); }
/*----------------------------------------------------------------------------*/ static void changeMode(struct Can *interface, enum Mode mode) { if (interface->mode != mode) { interface->mode = mode; LPC_CAN_Type * const reg = interface->base.reg; uint32_t value = reg->MOD & ~(MOD_LOM | MOD_STM); switch (interface->mode) { case MODE_LISTENER: /* * Notice: CAN peripheral in the Listen Only mode cannot receive * unacknowledged messages due to a hardware issue in the CPU. */ value |= MOD_LOM; break; case MODE_LOOPBACK: value |= MOD_STM; break; default: break; } /* Return pending message descriptors to the pool */ resetQueues(interface); /* Enable Reset mode to configure LOM and STM bits */ reg->MOD |= MOD_RM; /* Change test settings */ reg->MOD = value; } }