VideoGrabber::~VideoGrabber() { closeDevices(); delete channel; delete buffer; videoGrabber = 0; }
void MidiApple::updateDeviceList() { closeDevices(); openDevices(); emit readablePortsChanged(); emit writablePortsChanged(); }
void close() { if (isRunning) { stopThread (2000); isRunning = false; closeDevices(); } }
RTC::ReturnCode_t HockeyArmController::onFinalize() { ; /* --- アームを停止位置(角度:(pi/2,0)[rad])に移動する --- */ g_posController[0].moveTo(0 + INIT_ENC_X, 500); g_posController[1].moveTo(0 + INIT_ENC_Y, 500); while (!g_posController[0].isMoved() || !g_posController[1].isMoved()) { usleep(100); } fprintf(stderr, "ARM finalize OK!\n"); /* --- 位置決め制御を停止する --- */ g_posController[0].stop(); g_posController[1].stop(); /* --- A-IOボードをクローズする --- */ closeDevices(1, g_opened[0]); closeDevices(2, g_opened[1]); return RTC::RTC_OK; }
static void closeAndExit(int sig) { // Stop running threads running = 0; // Wait for the trheads to stop. pthread_join(cmd_thread, NULL); pthread_join(btn_thread, NULL); closeButtonSHM(SHM_NAME); closeDevices(); closeQueue(); syslog (LOG_INFO, "Program stopped by User %d", getuid()); closelog(); exit(0); }
void SDLEventReader::closeSDL() { pollRateTimer.stop(); SDL_Event event; closeDevices(); // Clear any pending events while (SDL_PollEvent(&event) > 0) { } SDL_Quit(); sdlIsOpen = false; emit sdlClosed(); }
void VideoGrabber::Main() { if ( !channel ) return ; PTRACE( 1, "Going to grab from video device" ); while ( run ) { mutex.Wait(); State s = state; mutex.Signal(); // prepare for the state... closeDevices(); switch( s ) { case SPreview: if( !openDevices() ) { stopPreview(); ancaInfo->setInt( VG_STATE, VG_IDLE ); } break; case SCall: openReader(); break; case SSleep: break; } preparing = false; // do switch( s ) { case SSleep: case SCall: goSleep(); break; case SPreview: while ( state == SPreview && run && !reconfigure ) { channel->Read( buffer, bufferSize ); channel->Write( buffer, bufferSize ); Sleep( 50 ); } } } }
MidiApple::~MidiApple() { closeDevices(); }
MidiWinMM::~MidiWinMM() { closeDevices(); }
String open (const BigInteger& inputChannels, const BigInteger& outputChannels, double requestedSampleRate, int bufferSize) { close(); if (sampleRate != (int) requestedSampleRate) return "Sample rate not allowed"; lastError = String::empty; int preferredBufferSize = (bufferSize <= 0) ? getDefaultBufferSize() : bufferSize; numDeviceInputChannels = 0; numDeviceOutputChannels = 0; activeOutputChans = outputChannels; activeOutputChans.setRange (2, activeOutputChans.getHighestBit(), false); numClientOutputChannels = activeOutputChans.countNumberOfSetBits(); activeInputChans = inputChannels; activeInputChans.setRange (2, activeInputChans.getHighestBit(), false); numClientInputChannels = activeInputChans.countNumberOfSetBits(); actualBufferSize = preferredBufferSize; inputChannelBuffer.setSize (2, actualBufferSize); inputChannelBuffer.clear(); outputChannelBuffer.setSize (2, actualBufferSize); outputChannelBuffer.clear(); JNIEnv* env = getEnv(); if (numClientOutputChannels > 0) { numDeviceOutputChannels = 2; outputDevice = GlobalRef (env->NewObject (AudioTrack, AudioTrack.constructor, STREAM_MUSIC, sampleRate, CHANNEL_OUT_STEREO, ENCODING_PCM_16BIT, (jint) (minBufferSizeOut * numDeviceOutputChannels * sizeof (int16)), MODE_STREAM)); if (env->CallIntMethod (outputDevice, AudioTrack.getState) != STATE_UNINITIALIZED) isRunning = true; else outputDevice.clear(); // failed to open the device } if (numClientInputChannels > 0 && numDeviceInputChannelsAvailable > 0) { numDeviceInputChannels = jmin (numClientInputChannels, numDeviceInputChannelsAvailable); inputDevice = GlobalRef (env->NewObject (AudioRecord, AudioRecord.constructor, 0 /* (default audio source) */, sampleRate, numDeviceInputChannelsAvailable > 1 ? CHANNEL_IN_STEREO : CHANNEL_IN_MONO, ENCODING_PCM_16BIT, (jint) (minBufferSizeIn * numDeviceInputChannels * sizeof (int16)))); if (env->CallIntMethod (inputDevice, AudioRecord.getState) != STATE_UNINITIALIZED) isRunning = true; else inputDevice.clear(); // failed to open the device } if (isRunning) { if (outputDevice != nullptr) env->CallVoidMethod (outputDevice, AudioTrack.play); if (inputDevice != nullptr) env->CallVoidMethod (inputDevice, AudioRecord.startRecording); startThread (8); } else { closeDevices(); } return lastError; }