Skip to content

Instantly share code, notes, and snippets.

View Fahrradkette's full-sized avatar

Fahrradkette Fahrradkette

View GitHub Profile
@Fahrradkette
Fahrradkette / udp_proxy.py
Last active February 28, 2018 00:10
UDP lag-inducing proxy server using python asyncio
import asyncio
import sys
class FakeServerProtocol(asyncio.DatagramProtocol):
def __init__(self, target_addr, stc_delay, cts_delay, loop=None):
self.loop = loop
if self.loop is None:
self.loop = asyncio.get_event_loop()
self.transport = None
self.target_addr = target_addr
@Fahrradkette
Fahrradkette / gist:6049434
Last active December 20, 2015 01:29
Closes actual device
private static void OpenAlCloseDevice()
{
StopAllSounds();
IntPtr Context, Device;
Al.alDeleteBuffers(1, ref buffer);
Al.alDeleteSources(1, ref source);
Context = Alc.alcGetCurrentContext();
Device = Alc.alcGetContextsDevice(Context);
Alc.alcMakeContextCurrent(IntPtr.Zero);
Alc.alcDestroyContext(Context);
@Fahrradkette
Fahrradkette / gist:6049300
Last active December 20, 2015 01:29
returns a list of available devices if (on windows vista and 7) the ALC_ENUMERATE_ALL_EXT is present. If only ALC_ENUMERATION_EXT is present it returns (on windows vista and 7) the default device. It may returns all the devices on a unix. If no extension is present it returns the default device. We might change it so it returns null instead.
public static readonly string [] OpenAlGetDeviceList
{
get
{
string[] DeviceList;
if (Alc.alcIsExtensionPresent(IntPtr.Zero, "ALC_ENUMERATE_ALL_EXT") == Alc.ALC_TRUE)
{
DeviceList = Alc.alcGetStringv(IntPtr.Zero, Alc.ALC_ALL_DEVICES_SPECIFIER);
if (Al.alGetError() != Al.AL_NO_ERROR)
throw new InvalidOperationException("Can't get OpenAL device list.");