コード例 #1
0
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;
	}
}
コード例 #2
0
ファイル: ALc.c プロジェクト: SergeStinckwich/openqwaq
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);
    }
}
コード例 #3
0
ファイル: AudioAnalyzer.cpp プロジェクト: HsienYu/Live-Coder
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");
}
コード例 #4
0
ファイル: audio.cpp プロジェクト: justzx2011/qTox
void Audio::closeInput()
{
    if (alInDev)
        alcCaptureCloseDevice(alInDev);

    userCount = 0;
}
コード例 #5
0
ファイル: audio.c プロジェクト: wieker-official/uTox
static void alccaptureclose(void *handle) {
    if(handle == (void*)1) {
        return;
    }

    alcCaptureCloseDevice(handle);
}
コード例 #6
0
ファイル: main.c プロジェクト: vetus-rector/Code
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");
}
コード例 #7
0
ファイル: audio.cpp プロジェクト: justzx2011/qTox
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);
}
コード例 #8
0
void dscap_release_buffer()
{
	if (ds_capture_device != NULL) {
		OpenAL_C_ErrorPrint( alcCaptureCloseDevice(ds_capture_device) );
		ds_capture_device = NULL;
	}
}
コード例 #9
0
ファイル: psm_record.cpp プロジェクト: lencho/oriole
 int psm_record::stop(){
     if(context_->device){
         alcCaptureStop(context_->device);
         alcCaptureCloseDevice(context_->device);
         context_->device = NULL;
     }
     return 0;
 }
コード例 #10
0
ファイル: OpenALReader.cpp プロジェクト: carldong/audaspace
OpenALReader::~OpenALReader()
{
	if(m_device)
	{
		//alcCaptureStop(m_device);
		alcCaptureCloseDevice(m_device);
	}
}
コード例 #11
0
// 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;
	}
}
コード例 #12
0
void RecordingDevice::stop()
{
	if (!isRecording())
		return;

	alcCaptureStop(device);
	alcCaptureCloseDevice(device);
	device = nullptr;
}
コード例 #13
0
ファイル: CaptureStream.cpp プロジェクト: mark711/Cafu
CaptureStreamT::~CaptureStreamT()
{
    if (m_IsCapturing)
    {
        alcCaptureStop(m_CaptureDevice);
        m_IsCapturing=false;
    }

    alcCaptureCloseDevice(m_CaptureDevice);
}
コード例 #14
0
ファイル: AudioAnalyzer.cpp プロジェクト: HsienYu/Live-Coder
AudioAnalyzer::~AudioAnalyzer(void)
{
	if (!initialized)
		return;
	
    alcCaptureStop(inputDevice);
    alcCaptureCloseDevice(inputDevice);
    delete[] capturedBuffer;
    delete[] ffted;
	delete[] ar;
	delete[] ai;
}
コード例 #15
0
ファイル: openal.cpp プロジェクト: initramfs/qTox
/**
 * @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";
}
コード例 #16
0
ファイル: SoundRecorder.cpp プロジェクト: Sonkun/SFML
void SoundRecorder::cleanup()
{
    // Stop the capture
    alcCaptureStop(captureDevice);

    // Get the samples left in the buffer
    processCapturedSamples();

    // Close the device
    alcCaptureCloseDevice(captureDevice);
    captureDevice = NULL;
}
コード例 #17
0
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;
}
コード例 #18
0
ファイル: ALc.c プロジェクト: ghoulsblade/vegaogre
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);
    }
}
コード例 #19
0
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;
}
コード例 #20
0
ファイル: cAudioCapture.cpp プロジェクト: ComradeKeys/cAudio
	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();
	}
コード例 #21
0
ファイル: audio.cpp プロジェクト: czaks/qTox
/**
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
    }
}
コード例 #22
0
ファイル: audio.cpp プロジェクト: NEOhidra/qTox
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";
        }
    }
}
コード例 #23
0
ファイル: audio.cpp プロジェクト: Zer0-One/qTox
/**
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
    }
}
コード例 #24
0
ファイル: AudioRecorder.cpp プロジェクト: bbgram/bbgram
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;
}
コード例 #25
0
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);
}
コード例 #26
0
ファイル: ALc.c プロジェクト: xiaobinshe/multitv
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);
    }
}
コード例 #27
0
ファイル: device.c プロジェクト: chu888chu888/toxic
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;
}
コード例 #28
0
ファイル: audio.cpp プロジェクト: czaks/qTox
/**
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";
        }
    }
}
コード例 #29
0
ファイル: core.cpp プロジェクト: ReDetection/qTox
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);
}
コード例 #30
0
ファイル: openal.c プロジェクト: AmesianX/RosWine
ALCboolean CDECL wine_alcCaptureCloseDevice(ALCdevice *device)
{
    return alcCaptureCloseDevice(device);
}