static void find_capture_device(OpenALInformation* info) { const char *user_device = os_config_read_string( "Sound", "CaptureDevice", NULL ); const char *default_device = info->default_capture_device.c_str(); // in case they are the same, we only want to test it once if ( (user_device && default_device) && !strcmp(user_device, default_device) ) { user_device = NULL; } for (auto& device : info->capture_devices) { OALdevice new_device(device.c_str()); if (user_device && !strcmp(device.c_str(), user_device)) { new_device.type = OAL_DEVICE_USER; } else if (default_device && !strcmp(device.c_str(), default_device)) { new_device.type = OAL_DEVICE_DEFAULT; } CaptureDevices.push_back( new_device ); } if ( CaptureDevices.empty() ) { return; } std::sort( CaptureDevices.begin(), CaptureDevices.end(), openal_device_sort_func ); // for each device that we have available, try and figure out which to use for (size_t idx = 0; idx < CaptureDevices.size(); idx++) { const ALCchar *device_name = CaptureDevices[idx].device_name.c_str(); ALCdevice *device = alcCaptureOpenDevice(device_name, 22050, AL_FORMAT_MONO8, 22050 * 2); if (device == NULL) { continue; } if (alcGetError(device) != ALC_NO_ERROR) { alcCaptureCloseDevice(device); continue; } // ok, we should be good with this one Capture_device = CaptureDevices[idx].device_name; alcCaptureCloseDevice(device); break; } }
ALCvoid ReleaseALC(ALCvoid) { free(alcDeviceList); alcDeviceList = NULL; alcDeviceListSize = 0; free(alcAllDeviceList); alcAllDeviceList = NULL; alcAllDeviceListSize = 0; free(alcCaptureDeviceList); alcCaptureDeviceList = NULL; alcCaptureDeviceListSize = 0; free(alcDefaultDeviceSpecifier); alcDefaultDeviceSpecifier = NULL; free(alcDefaultAllDeviceSpecifier); alcDefaultAllDeviceSpecifier = NULL; free(alcCaptureDefaultDeviceSpecifier); alcCaptureDefaultDeviceSpecifier = NULL; #ifdef _DEBUG if(g_ulDeviceCount > 0) AL_PRINT("exit(): closing %u Device%s\n", g_ulDeviceCount, (g_ulDeviceCount>1)?"s":""); #endif while(g_pDeviceList) { if(g_pDeviceList->IsCaptureDevice) alcCaptureCloseDevice(g_pDeviceList); else alcCloseDevice(g_pDeviceList); } }
AudioAnalyzer::AudioAnalyzer(int frequency_, int captureSize_) : frequency(frequency_), captureSize(captureSize_), initialized(false) { ALenum errorCode=0; inputDevice = alcCaptureOpenDevice(NULL, frequency, AL_FORMAT_MONO16, frequency/2); if (inputDevice == NULL) { Logger::Instance()->OutputString("Error: alcCaptureOpenDevice"); return; } errorCode = alcGetError(inputDevice); if (errorCode != AL_NO_ERROR) { Logger::Instance()->OutputString("Error: alcCaptureOpenDevice -- ?"); return; } alcCaptureStart(inputDevice); // Begin capturing errorCode = alcGetError(inputDevice); if (errorCode != AL_NO_ERROR) { Logger::Instance()->OutputString("Error: alcCaptureStart"); alcCaptureCloseDevice(inputDevice); return; } capturedBuffer = new short[captureSize]; ffted = new float[captureSize]; ar = new float[captureSize]; ai = new float[captureSize]; initialized = true; Logger::Instance()->OutputString("OpenAL succeeded"); }
void Audio::closeInput() { if (alInDev) alcCaptureCloseDevice(alInDev); userCount = 0; }
static void alccaptureclose(void *handle) { if(handle == (void*)1) { return; } alcCaptureCloseDevice(handle); }
void* recAndSend(void * param){ ALshort alrecBuffer[SAMPLESIZE]; ALint alSample; ALCdevice* device = alcOpenDevice(NULL); ALCcontext* context = alcCreateContext(device, NULL); alcMakeContextCurrent(context); ALCdevice* alDevice = alcCaptureOpenDevice(NULL, SRATE, AL_FORMAT_MONO16, SAMPLESIZE); alcGetError(alDevice); alcCaptureStart(alDevice); alcGetError(alDevice); while (1){ alcGetIntegerv(alDevice, ALC_CAPTURE_SAMPLES, (ALCsizei)sizeof(ALint), &alSample); alcGetError(alDevice); if(alSample > SAMPLESIZE/2) { alcCaptureSamples(alDevice, (ALCvoid *)alrecBuffer, alSample); int n; socklen_t addrlen = sizeof(senderinfo); int i; for(i=0; i<alSample; i++){ if(abs((int)alrecBuffer[i]) > (0.8*INT16_MAX) ) break; } if(i==alSample) continue; if((n = sendto(sock, alrecBuffer, alSample*2, 0, (struct sockaddr *)&senderinfo, addrlen)) != alSample*2){ perror("sendto"); exit(1); } } if(callFlag==OFF) break; } alcCaptureCloseDevice(alDevice); alcCaptureStop(alDevice); alcCloseDevice(device); // fprintf(stderr, "close recAndSend\n"); }
void Audio::openInput(const QString& inDevDescr) { auto* tmp = alInDev; alInDev = nullptr; if (tmp) alcCaptureCloseDevice(tmp); int stereoFlag = av_DefaultSettings.audio_channels==1 ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16; if (inDevDescr.isEmpty()) alInDev = alcCaptureOpenDevice(nullptr,av_DefaultSettings.audio_sample_rate, stereoFlag, (av_DefaultSettings.audio_frame_duration * av_DefaultSettings.audio_sample_rate * 4) / 1000 * av_DefaultSettings.audio_channels); else alInDev = alcCaptureOpenDevice(inDevDescr.toStdString().c_str(),av_DefaultSettings.audio_sample_rate, stereoFlag, (av_DefaultSettings.audio_frame_duration * av_DefaultSettings.audio_sample_rate * 4) / 1000 * av_DefaultSettings.audio_channels); if (!alInDev) qWarning() << "Audio: Cannot open input audio device"; else qDebug() << "Audio: Opening audio input "<<inDevDescr; Core::getInstance()->resetCallSources(); // Force to regen each group call's sources // Restart the capture if necessary if (userCount.load() != 0 && alInDev) alcCaptureStart(alInDev); }
void dscap_release_buffer() { if (ds_capture_device != NULL) { OpenAL_C_ErrorPrint( alcCaptureCloseDevice(ds_capture_device) ); ds_capture_device = NULL; } }
int psm_record::stop(){ if(context_->device){ alcCaptureStop(context_->device); alcCaptureCloseDevice(context_->device); context_->device = NULL; } return 0; }
OpenALReader::~OpenALReader() { if(m_device) { //alcCaptureStop(m_device); alcCaptureCloseDevice(m_device); } }
// close the DirectSoundCapture system void dscap_close() { dscap_stop_record(); if (ds_capture_device != NULL) { OpenAL_C_ErrorPrint( alcCaptureCloseDevice(ds_capture_device) ); ds_capture_device = NULL; } }
void RecordingDevice::stop() { if (!isRecording()) return; alcCaptureStop(device); alcCaptureCloseDevice(device); device = nullptr; }
CaptureStreamT::~CaptureStreamT() { if (m_IsCapturing) { alcCaptureStop(m_CaptureDevice); m_IsCapturing=false; } alcCaptureCloseDevice(m_CaptureDevice); }
AudioAnalyzer::~AudioAnalyzer(void) { if (!initialized) return; alcCaptureStop(inputDevice); alcCaptureCloseDevice(inputDevice); delete[] capturedBuffer; delete[] ffted; delete[] ar; delete[] ai; }
/** * @brief Close active audio input device. */ void OpenAL::cleanupInput() { if (!alInDev) return; qDebug() << "Closing audio input"; alcCaptureStop(alInDev); if (alcCaptureCloseDevice(alInDev) == ALC_TRUE) alInDev = nullptr; else qWarning() << "Failed to close input"; }
void SoundRecorder::cleanup() { // Stop the capture alcCaptureStop(captureDevice); // Get the samples left in the buffer processCapturedSamples(); // Close the device alcCaptureCloseDevice(captureDevice); captureDevice = NULL; }
static gboolean gst_openal_src_unprepare (GstAudioSrc * asrc) { GstOpenalSrc *osrc = GST_OPENAL_SRC (asrc); GST_INFO_OBJECT (osrc, "Close device : %s", osrc->deviceName); if (osrc->deviceHandle) { alcCaptureStop (osrc->deviceHandle); alcCaptureCloseDevice (osrc->deviceHandle); } return TRUE; }
ALCvoid ReleaseALC(ALCvoid) { #ifdef _DEBUG if(g_ulDeviceCount > 0) AL_PRINT("exit(): closing %u Device%s\n", g_ulDeviceCount, (g_ulDeviceCount>1)?"s":""); #endif while(g_pDeviceList) { if(g_pDeviceList->IsCaptureDevice) alcCaptureCloseDevice(g_pDeviceList); else alcCloseDevice(g_pDeviceList); } }
static gboolean gst_openal_src_unprepare (GstAudioSrc * audiosrc) { GstOpenalSrc *openalsrc = GST_OPENAL_SRC (audiosrc); if (openalsrc->device) { alcCaptureStop (openalsrc->device); if (alcCaptureCloseDevice (openalsrc->device) == ALC_FALSE) { GST_ELEMENT_ERROR (openalsrc, RESOURCE, CLOSE, ("Could not close device."), GST_ALC_ERROR (openalsrc->device)); return FALSE; } } return TRUE; }
void cAudioCapture::shutdownOpenALDevice() { cAudioMutexBasicLock lock(Mutex); if(Capturing) stopCapture(); if(CaptureDevice) { alcCaptureCloseDevice(CaptureDevice); CaptureDevice = NULL; Ready = false; getLogger()->logDebug("AudioCapture", "OpenAL Capture Device Closed."); signalEvent(ON_RELEASE); } checkError(); CaptureBuffer.clear(); }
/** Open an input device, use before suscribing */ void Audio::openInput(const QString& inDevDescr) { QMutexLocker lock(&audioInLock); if (alInDev) { #if (!FIX_SND_PCM_PREPARE_BUG) qDebug() << "stopping capture"; alcCaptureStop(alInDev); #endif alcCaptureCloseDevice(alInDev); } alInDev = nullptr; /// TODO: Try to actually detect if our audio source is stereo int stereoFlag = AUDIO_CHANNELS == 1 ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16; const uint32_t sampleRate = AUDIO_SAMPLE_RATE; const uint16_t frameDuration = AUDIO_FRAME_DURATION; const uint32_t chnls = AUDIO_CHANNELS; const ALCsizei bufSize = (frameDuration * sampleRate * 4) / 1000 * chnls; if (inDevDescr.isEmpty()) alInDev = alcCaptureOpenDevice(nullptr, sampleRate, stereoFlag, bufSize); else alInDev = alcCaptureOpenDevice(inDevDescr.toStdString().c_str(), sampleRate, stereoFlag, bufSize); if (alInDev) qDebug() << "Opening audio input "<<inDevDescr; else qWarning() << "Cannot open input audio device " + inDevDescr; Core* core = Core::getInstance(); if (core) core->getAv()->resetCallSources(); // Force to regen each group call's sources // Restart the capture if necessary if (alInDev) { alcCaptureStart(alInDev); } else { #if (FIX_SND_PCM_PREPARE_BUG) alcCaptureStart(alInDev); #endif } }
void Audio::closeInput() { qDebug() << "Closing input"; QMutexLocker lock(audioInLock); if (alInDev) { if (alcCaptureCloseDevice(alInDev) == ALC_TRUE) { alInDev = nullptr; userCount = 0; } else { qWarning() << "Failed to close input"; } } }
/** Open an input device, use before suscribing */ void Audio::openInput(const QString& inDevDescr) { QMutexLocker lock(&audioInLock); if (alInDev) { #if (!FIX_SND_PCM_PREPARE_BUG) qDebug() << "stopping capture"; alcCaptureStop(alInDev); #endif alcCaptureCloseDevice(alInDev); } alInDev = nullptr; int stereoFlag = av_DefaultSettings.audio_channels==1 ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16; const uint32_t sampleRate = av_DefaultSettings.audio_sample_rate; const uint16_t frameDuration = av_DefaultSettings.audio_frame_duration; const uint32_t chnls = av_DefaultSettings.audio_channels; const ALCsizei bufSize = (frameDuration * sampleRate * 4) / 1000 * chnls; if (inDevDescr.isEmpty()) alInDev = alcCaptureOpenDevice(nullptr, sampleRate, stereoFlag, bufSize); else alInDev = alcCaptureOpenDevice(inDevDescr.toStdString().c_str(), sampleRate, stereoFlag, bufSize); if (alInDev) qDebug() << "Opening audio input "<<inDevDescr; else qWarning() << "Cannot open input audio device " + inDevDescr; Core* core = Core::getInstance(); if (core) core->resetCallSources(); // Force to regen each group call's sources // Restart the capture if necessary if (alInDev) { alcCaptureStart(alInDev); } else { #if (FIX_SND_PCM_PREPARE_BUG) alcCaptureStart(alInDev); #endif } }
const QString& AudioRecorder::stopRecord() { m_updateRecordTimer.stop(); alcCaptureStop(m_recordDevice); alcCaptureCloseDevice(m_recordDevice); uint8_t* data = (uint8_t*)m_sampleArray.data(); size_t size = m_sampleArray.size(); if (size > 0) writeFrame((uint8_t*)m_sampleArray.data(), size); m_sampleArray.clear(); cleanupRecorder(); return m_filePath; }
spp_AudioManager::~spp_AudioManager() { //deleting all the stored buffers UnloadAllSounds(); RemoveAllProcessingPlugIns(); //deleting the listener delete mpListener; StopDebugMode(); //closing OpenAL alcMakeContextCurrent(NULL); alcDestroyContext(mpContext); alcCloseDevice(mpDevice); alcCaptureCloseDevice(mpRecordingDevice); }
ALCvoid ReleaseALC(ALCvoid) { ALCdevice *Dev; #ifdef _DEBUG if(g_ulContextCount > 0) AL_PRINT("exit() %u device(s) and %u context(s) NOT deleted\n", g_ulDeviceCount, g_ulContextCount); #endif while(g_pDeviceList) { Dev = g_pDeviceList; g_pDeviceList = g_pDeviceList->next; if(Dev->IsCaptureDevice) alcCaptureCloseDevice(Dev); else alcCloseDevice(Dev); } }
DeviceError close_device(DeviceType type, uint32_t device_idx) { if (device_idx >= MAX_DEVICES) return de_InvalidSelection; lock; Device* device = running[type][device_idx]; if (!device) { unlock; return de_DeviceNotActive; } if ( !(device->ref_count--) ) { running[type][device_idx] = NULL; unlock; DeviceError rc = de_None; if (type == input) { if ( !alcCaptureCloseDevice(device->dhndl) ) rc = de_AlError; } else { if (alcGetCurrentContext() != device->ctx) alcMakeContextCurrent(device->ctx); alDeleteSources(1, &device->source); alDeleteBuffers(OPENAL_BUFS, device->buffers); if ( !alcCloseDevice(device->dhndl) ) rc = de_AlError; alcMakeContextCurrent(NULL); if ( device->ctx ) alcDestroyContext(device->ctx); } free(device); return rc; } unlock; return de_None; }
/** Close an input device, please don't use unless everyone's unsuscribed */ void Audio::closeInput() { qDebug() << "Closing input"; QMutexLocker locker(&audioInLock); if (alInDev) { #if (!FIX_SND_PCM_PREPARE_BUG) qDebug() << "stopping capture"; alcCaptureStop(alInDev); #endif if (alcCaptureCloseDevice(alInDev) == ALC_TRUE) { alInDev = nullptr; inputSubscriptions = 0; } else { qWarning() << "Failed to close input"; } } }
Core::~Core() { if (tox) { saveConfiguration(); toxav_kill(toxav); tox_kill(tox); } if (videobuf) { delete[] videobuf; videobuf=nullptr; } if (alContext) { alcMakeContextCurrent(nullptr); alcDestroyContext(alContext); } if (alOutDev) alcCloseDevice(alOutDev); if (alInDev) alcCaptureCloseDevice(alInDev); }
ALCboolean CDECL wine_alcCaptureCloseDevice(ALCdevice *device) { return alcCaptureCloseDevice(device); }