public virtual int hleAudioInputBlocking(int maxSamples, int frequency, TPointer buffer) { if (!inputDeviceInitialized) { IntBuffer majorVersion = BufferUtils.createIntBuffer(1); IntBuffer minorVersion = BufferUtils.createIntBuffer(1); ALC10.alcGetInteger(null, ALC10.ALC_MAJOR_VERSION, majorVersion); ALC10.alcGetInteger(null, ALC10.ALC_MINOR_VERSION, minorVersion); Console.WriteLine(string.Format("OpenAL Version {0:D}.{1:D}, extensions {2}", majorVersion.get(0), minorVersion.get(0), ALC10.alcGetString(null, ALC10.ALC_EXTENSIONS))); inputDevice = ALC11.alcCaptureOpenDevice(null, frequency, AL10.AL_FORMAT_MONO16, 10 * 1024); if (inputDevice != null) { ALC11.alcCaptureStart(inputDevice); } else { Console.WriteLine(string.Format("No audio input device available, faking.")); } inputDeviceInitialized = true; } blockThreadInput(buffer.Address, maxSamples, frequency); return(0); }
public override void stop() { if (inputDevice != null) { ALC11.alcCaptureCloseDevice(inputDevice); inputDevice = null; } inputDeviceInitialized = false; captureBuffer = null; base.stop(); }
protected internal virtual void hleAudioBlockingInput(int threadId, int addr, int samples, int frequency) { int availableSamples = hleAudioGetInputLength(); if (log.TraceEnabled) { log.trace(string.Format("hleAudioBlockingInput available samples: {0:D} from {1:D}", availableSamples, samples)); } int bufferBytes = samples << 1; if (inputDevice == null) { // No input device available, fake device input Memory.Instance.memset(addr, (sbyte)0, bufferBytes); Modules.ThreadManForUserModule.hleUnblockThread(threadId); } else if (availableSamples >= samples) { if (captureBuffer == null || captureBuffer.capacity() < bufferBytes) { captureBuffer = BufferUtils.createByteBuffer(bufferBytes); } else { captureBuffer.rewind(); } ALC11.alcCaptureSamples(inputDevice, captureBuffer, samples); captureBuffer.rewind(); IMemoryWriter memoryWriter = MemoryWriter.getMemoryWriter(addr, samples, 2); for (int i = 0; i < samples; i++) { short sample = captureBuffer.Short; memoryWriter.writeNext(sample & 0xFFFF); } if (log.TraceEnabled) { log.trace(string.Format("hleAudioBlockingInput returning {0:D} samples: {1}", samples, Utilities.getMemoryDump(addr, bufferBytes, 2, 16))); } Modules.ThreadManForUserModule.hleUnblockThread(threadId); } else { blockThreadInput(threadId, addr, samples, frequency, availableSamples); } }