Exemplo n.º 1
0
	THREAD(SleepMode, arg)
	{
		struct _tm current_Time;
		getDateTime(&current_Time);
		int temp = current_Time.tm_min;
		int volume = 0;
		setGVolume(volume);
		NutThreadCreate("fs", StreamMusic, NULL, 512);
		for (;;) {
			
			getDateTime(&current_Time);
			if (temp > 45)
			{
				if (current_Time.tm_min >= temp - 45 && current_Time.tm_min < 45)
				{
					stopStream();
					break;
				}
			}
			else
			{
				if (current_Time.tm_min >= (temp + 15))
				{
					stopStream();
					break;
				}
			}
			NutSleep(20000);
			volume+=1;
			setGVolume(volume);
			printf("test3 min:%d", current_Time.tm_min);


		}
	}
Exemplo n.º 2
0
void KLController::h_connect(bool result)
{
    if(!result) {
        stopStream();
    }
    emit _available(result);
}
Exemplo n.º 3
0
EngineNetworkStream::~EngineNetworkStream() {
    if (m_streamStartTimeUs >= 0) {
        stopStream();
    }
    delete m_pOutputFifo;
    delete m_pInputFifo;
}
Exemplo n.º 4
0
void LiveWidget::disconnectStream()
{
    stopStream(this->deviceName, this->deviceChannel);

    this->deviceName.clear();
    this->deviceChannel.clear();
}
Exemplo n.º 5
0
DialogConsole::DialogConsole( QWidget * parent, Qt::WFlags f) : QDialog(parent, f)
{
	setupUi(this);
	setFocusPolicy(Qt::StrongFocus);

    connect(pbSend, SIGNAL(clicked()), this, SLOT(sendData())); 
    connect(pbOpen,SIGNAL(clicked()),this,SLOT(openFile()));
    connect(baudCombo, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeBaudrate(QString)));
    connect(pbStop,SIGNAL(clicked()),this,SLOT(stopStream()));

    connect(parityNrb,SIGNAL(toggled(bool)),this,SLOT(parityToggle(bool)));
    connect(parityErb,SIGNAL(toggled(bool)),this,SLOT(parityToggle(bool)));
    connect(parityOrb,SIGNAL(toggled(bool)),this,SLOT(parityToggle(bool)));
    connect(lEdit_CD,SIGNAL(textChanged(QString)),this,SLOT(updateMapCD(QString)));
    connect(lEdit_CS,SIGNAL(textChanged(QString)),this,SLOT(updateMapCS(QString)));
    connect(lEdit_ER,SIGNAL(textChanged(QString)),this,SLOT(updateMapER(QString)));
    connect(lEdit_RD,SIGNAL(textChanged(QString)),this,SLOT(updateMapRD(QString)));
    connect(lEdit_RR,SIGNAL(textChanged(QString)),this,SLOT(updateMapRR(QString)));
    connect(lEdit_RS,SIGNAL(textChanged(QString)),this,SLOT(updateMapRS(QString)));
    connect(lEdit_SD,SIGNAL(textChanged(QString)),this,SLOT(updateMapSD(QString)));

    pSIO = (Csio *) parent;
    currentIndex=0;
    parity = NONE;
	
}
Exemplo n.º 6
0
	void terminatePortAudio() {
		//Done with port audio, terminate it
		stopStream(stream);

		PaError err = Pa_Terminate();
		if (err != paNoError)
			Logger::logError("PortAudio error:") << Pa_GetErrorText(err) << endl;
	}
Exemplo n.º 7
0
void FormStreamingImp::toggleSafeMode()
{
  #ifdef MANT
  if( webcam_opened ) 
     stopStream();
   safe_image_plugin = !safe_image_plugin;
  #endif
}
Exemplo n.º 8
0
// destructor
slgAudio::~slgAudio(){
    if( m_audio )
    {
        stopStream();
        closeStream();
    }
    delete m_audio;
    m_audio = NULL;
}
Exemplo n.º 9
0
/* AudioEntryPanel::onBtnStop
 * Called when the stop button is pressed
 *******************************************************************/
void AudioEntryPanel::onBtnStop(wxCommandEvent& e)
{
	// Stop playing
	stopStream();
	timer_seek->Stop();

	// Reset
	resetStream();
	slider_seek->SetValue(0);
}
Exemplo n.º 10
0
void LiveWidget::closeApplication(const CloseApplicationEvent& event)
{
    stopStream(this->deviceName, this->deviceChannel);

    libvlc_media_player_release(this->vlcMediaPlayer);
    libvlc_release(this->vlcInstance);

    this->vlcMediaPlayer = NULL;
    this->vlcInstance = NULL;
}
Exemplo n.º 11
0
enum audio::orchestra::error audio::orchestra::api::Core::abortStream() {
	if (verifyStream() != audio::orchestra::error_none) {
		return audio::orchestra::error_fail;
	}
	if (m_state == audio::orchestra::state::stopped) {
		ATA_ERROR("the stream is already stopped!");
		return audio::orchestra::error_warning;
	}
	m_private->drainCounter = 2;
	return stopStream();
}
Exemplo n.º 12
0
void CleanUpEverything()
{
   auto glbl = globalStruct::GetGlobals();
   if (!glbl)
      return;

   auto svr = glbl->GetServer();
   if (svr)
   {
      svr->Stop();
   }

   auto strm = glbl->GetStreamer();
   if (strm)
   {
      strm->stopStream();
   }
   auto pipe = glbl->GetPipe();
   if (pipe)
   {
      pipe->Cleanup();
   }
   glbl->work_guard.reset();
   auto svc = glbl->GetService();

   glbl->ResetAllPointers();

   svr.reset();
   strm.reset();
   pipe.reset();

   if (svc && !svc->stopped())
   {
      svc->stop();
   }
   std::for_each(glbl->globalThreads.begin(), glbl->globalThreads.end(),
                 [](decltype(*glbl->globalThreads.begin())& thr)
                 {
                    thr.join();
                 });
   svc.reset();
   auto trkr = glbl->GetTracker();
   if (trkr)
   {
      trkr->WaitUntilThreadVecEmpty();
      trkr.reset();
      std::shared_ptr<FunctionUsageTracker> resetTracker;
      std::atomic_store(&glbl->fcnTracker, resetTracker);
      std::this_thread::sleep_for(std::chrono::seconds(10)); // Wait some time for threads to exit
   }
   glbl.reset();
   globalStruct::nullifyGlobals();
}
Exemplo n.º 13
0
// RtAudio configuration
void slgAudio::openStream( RtAudioCallback callback, void * userData ){
    if( !callback )
    {
        std::cerr << "No callback provided!" << std::endl;
        exit(1);
    }
    if( m_audio != NULL ){
        stopStream();
        closeStream();
    }
    
    RtAudio::StreamOptions options;
    //options.flags = RTAUDIO_NONINTERLEAVED;
    options.flags = RTAUDIO_SCHEDULE_REALTIME;
    options.priority = 1;

    // set input and output parameters to default
    RtAudio::StreamParameters iParams, oParams;

    //TODO: propose a choice of device not just default
    iParams.deviceId = m_audio->getDefaultInputDevice();
    iParams.nChannels = 2;
    iParams.firstChannel = 0;
    oParams.deviceId = m_audio->getDefaultOutputDevice();
    oParams.nChannels = 2;
    oParams.firstChannel = 0;
    
    RtAudioFormat sample_format = ( sizeof(SAMPLE) == 8 ) ? RTAUDIO_FLOAT64 : RTAUDIO_FLOAT32;
    //open stream
    //!!! RTAUDIO_FLOAT32 and not 64...
    try {
    m_audio->openStream( &oParams, &iParams, sample_format, m_sampleRate, &m_bufferSize, callback, userData, &options);
    } 
    catch ( RtAudioError& e ) {
        try { // again
            std::cout<<"hack!"<<std::endl;
            // HACK: bump the oparams device id (on some systems, default in/out devices differ)
            oParams.deviceId++;
            // try to open stream
            m_audio->openStream( &oParams, &iParams, sample_format,
                                m_sampleRate, &m_bufferSize, callback, userData );
        } 
        catch( RtAudioError & e ) {
            // error message
            std::cerr << "[slgAudio]: cannot initialize real-time audio I/O..." << std::endl;
            std::cerr << "[slgAudio]: | - " << e.getMessage() << std::endl;
            // clean up
            delete m_audio;
            m_audio = NULL;
            // done
        }
    }
}
Exemplo n.º 14
0
void LiveWidget::streamMenuActionTriggered(QAction* action)
{
    if (!action->text().contains(':') && !action->text().contains(','))
        return;

    stopStream(this->deviceName, this->deviceChannel);

    this->useKey = action->text().contains("(Key)");
    this->deviceName = action->text().split(',').at(0).split(':').at(1).trimmed();
    this->deviceChannel = action->text().split(',').at(1).split(':').at(1).trimmed().split(' ').at(0).trimmed();

    startStream(this->deviceName, this->deviceChannel);
}
Exemplo n.º 15
0
VRDeviceClient::~VRDeviceClient(void)
	{
	/* Leave streaming mode: */
	if(streaming)
		stopStream();
	
	/* Deactivate client: */
	if(active)
		deactivate();
	
	/* Disconnect from server: */
	pipe.writeMessage(VRDevicePipe::DISCONNECT_REQUEST);
	pipe.flush();
	}
Exemplo n.º 16
0
	void buttonHandler(int keyvalue)
	{
		if(old != keyvalue){
			//printf("%d",keyvalue);
			stateMenu(keyvalue);
			old = keyvalue;
			switch (keyvalue) {
			case KEY_01:
				NutThreadCreate("Bs", SleepMode, NULL, 512);
				break;
			case KEY_02:
				
				break;
			case KEY_03:
				alarmOn = 1;
				printf("DEBUG: Beep on\n");
				NutThreadCreate("Bq", AlarmBeep,NULL,512);
				break;
			case KEY_04:
				break;
			case KEY_05:
				break;
			case KEY_ALT:
				printf("Stop alarm");
				alarmOn=0;
				stopStream();
				break;
			case KEY_ESC:
				break;
			case KEY_UP:
				break;
			case KEY_OK:
				break;
			case KEY_LEFT:
				break;
			case KEY_DOWN:
				break;
			case KEY_RIGHT:
				break;
			case KEY_RESET:       // powerbutton +alt key
				printf("reset");
				resetEEPROM();
				reset();
				break;
			default:
				break;
			}
		}
	}
Exemplo n.º 17
0
OSStatus AkVCam::PluginInterfacePrivate::DeviceStopStream(CMIOHardwarePlugInRef self,
                                                          CMIODeviceID device,
                                                          CMIOStreamID stream)
{
    AkPluginPrivateIntefaceLogID(device);
    OSStatus status = kCMIOHardwareUnspecifiedError;

    if (!self)
        return status;

    auto _self = reinterpret_cast<PluginInterfacePrivate *>(self);
    auto object = reinterpret_cast<Device *>(_self->self->findObject(device));

    if (object)
        status = object->stopStream(stream);

    return status;
}
Exemplo n.º 18
0
/* AudioEntryPanel::loadEntry
 * Loads an entry into the audio entry panel
 *******************************************************************/
bool AudioEntryPanel::loadEntry(ArchiveEntry* entry)
{
	// Are we reopening the same entry? For example having looked at
	// a text file or image or any other non-audio entry, then
	// going back to the original audio entry? Then no need to do
	// abort the current song to restart it.
	if (this->entry == entry)
		return true;

	// Stop anything currently playing
	stopStream();
	resetStream();
	opened = false;

	// Enable all playback controls initially
	slider_seek->Enable();
	btn_play->Enable();
	btn_pause->Enable();

	btn_stop->Enable();
	btn_prev->Enable();
	btn_next->Enable();

	// Reset seek slider
	slider_seek->SetValue(0);

	// Delete previous temp file
	if (wxFileExists(prevfile))
		wxRemoveFile(prevfile);

	// Open new data
	this->entry = entry;
	open();

	// Autoplay if option is on
	if (snd_autoplay)
	{
		startStream();
		timer_seek->Start(10);
	}

	Refresh();
	return true;
}
Exemplo n.º 19
0
JackLayer::~JackLayer()
{
    stopStream();

    for (auto p : out_ports_)
        jack_port_unregister(playbackClient_, p);
    for (auto p : in_ports_)
        jack_port_unregister(captureClient_, p);

    if (jack_client_close(playbackClient_))
        RING_ERR("JACK client could not close");
    if (jack_client_close(captureClient_))
        RING_ERR("JACK client could not close");

    for (auto r : out_ringbuffers_)
        jack_ringbuffer_free(r);
    for (auto r : in_ringbuffers_)
        jack_ringbuffer_free(r);
}
void offMenu(int input)
{
	switch(input)
	{
	case KEY_OK:
		stopStream();
		break;
	case KEY_LEFT:
		stateMenu = onMenu;
		break;
	case KEY_RIGHT:
		stateMenu = onMenu;
		break;
	default:
		break;
	}
	clearScreen();
	drawMenu();
}
Exemplo n.º 21
0
void LiveWidget::toggleWindowMode()
{
    stopStream(this->deviceName, this->deviceChannel);

    if (this->windowMode)
    {
        this->windowModeAction->blockSignals(true);
        this->windowModeAction->setChecked(false);
        this->windowModeAction->blockSignals(false);

        this->liveDialog->hide();
    }
    else
    {
        this->liveDialog->visible();
    }

    this->windowMode = !this->windowMode;
    setupRenderTarget(this->windowMode);
    startStream(this->deviceName, this->deviceChannel);
}
Exemplo n.º 22
0
THREAD(FallingAsleep, arg)
{
    printf("falling asleep started\n");
    for(;;)
    {
        int volumeGoal = 254;
        
        //Dont start yet if no sound is playing
        while(VsGetStatus() != VS_STATUS_RUNNING)
            NutSleep(50);

        //Get the amount of seconds from the fallingAsleepTime minutes
        long totalSeconds = (long)fallingAsleepTime * 1000 * 60;
        printf("totalseconds = %lu\n", totalSeconds);
        //Get the time to sleep before "increasing" the volume. Divide the totalSeconds by the volumeGoal to get a smooth transition
        long sleepTime = totalSeconds / volumeGoal;
        printf("sleeptime = %lu\n", sleepTime);
        int currentVolume = VsGetVolume();
        
        //"Increase" the volume until it hits the goal
        while(currentVolume < volumeGoal)
        {
            NutSleep(sleepTime);
            VsSetVolume(currentVolume + 1, currentVolume + 1);
            printf("Falling Asleep Mode tick now. Volume lowered %d", VsGetVolume());
            currentVolume++;
        }
        
        //Call stopStream in network.c
        stopStream();
        //Turn off falling asleep mode
        fallingAsleepMode = 0;
        //Reset volume
        VsSetVolume(0, 0);
        //Exit the thread
        NutThreadExit();
    }
}
Exemplo n.º 23
0
void StartRecv(const std::shared_ptr<NamedPipe>& pipe)
{
   char* SomeBuffer = new char[1024];
   std::weak_ptr<NamedPipe> wptr = pipe;
   ::boost::asio::async_read(
       pipe->GetHandle(), boost::asio::buffer(SomeBuffer, 1024),
       [SomeBuffer, wptr](const boost::system::error_code& ec, std::size_t) mutable
       {
          delete [] SomeBuffer;
          auto sptr = wptr.lock();
          if (!sptr)
             return;
          auto globals = globalStruct::GetGlobals();
          if (!globals)
             return;
          if (ec && (ec != boost::asio::error::operation_aborted)) // We'll be
                                                                   // responsible for
                                                                   // this.
          {
             auto strm = globals->GetStreamer();
             if (strm)
                strm->stopStream();
             // restart the server

             auto pipe = std::atomic_load(&globals->pipe);
             std::shared_ptr<NamedPipe> nullPipe;
             std::atomic_store(&globals->pipe, nullPipe);
             sptr->Cleanup();
             auto svr = globals->GetServer();
             if (!svr)
                return;
             svr->Stop();
             globals->ClearReadCollection();
             StartNamedPipeServer(*globals);
          }
       });
}
Exemplo n.º 24
0
void KLController::close()
{
    if(!isOpened()) {
        if(sensor) {
            safeRelease(sensor);
        }
        if(checkThread) {
            checkThread->stop();
            checkThread->wait();
        }
        return;
    }
    HRESULT hr = sensor->Close();
    if(SUCCEEDED(hr)) {
        checkThread->stop();
        checkThread->wait();
        safeRelease(sensor);
        qDebug()<<"[KLController] Closed";
        stopStream();
        emit _open(false);
    } else {
        emit _hrError(hr);
    }
}
Exemplo n.º 25
0
/* start / stop movie */
void FormStreamingImp::grabMovie()
{
#ifdef WITH_XVID_RECORD
   if( on_movie_record == true )
     {
	on_movie_record = false;
	if( !movie_grabber.stop() )
	  {
	     handleError();
	     return;
	  }
	emit setStatus(QString(tr("Grabacion Finalizada")));
	return;
     }
   else if( current_webcam->isStreaming() ) 
     { 
	stopStream();
     }
   
   QString saveTo = QFileDialog::getSaveFileName(this,tr("Guardar video en..."),getenv("HOME"),tr("Video (*.avi)"));
   //no permitir cambio de size mientras graba!
   if( saveTo.isEmpty() )
     return;

   movie_grabber.setParameters(saveTo,current_webcam->getSourceSize()); //size or sourcesize?
   if( !movie_grabber.start() )
     {
	handleError();
	return;
     }

   emit setStatus(QString(tr("El video sera guarduado en %1").arg(saveTo)));

   on_movie_record = true;
#endif
}
Exemplo n.º 26
0
bool BoardFXO::KhompPvtFXO::doChannelAnswer(CommandRequest &cmd)
{
    DBG(FUNC, PVT_FMT(_target, "(FXO) c"));

    bool ret = true;

    try
    {
        ScopedPvtLock lock(this);

        // is this a collect call?
        bool has_recv_collect_call = _call->_collect_call;

        if(has_recv_collect_call)
            DBG(FUNC, PVT_FMT(target(), "receive a collect call"));

        if(call()->_flags.check(Kflags::DROP_COLLECT))
            DBG(FUNC, PVT_FMT(target(), "flag DROP_COLLECT == true"));

        // do we have to drop collect calls?
        bool has_drop_collect_call = call()->_flags.check(Kflags::DROP_COLLECT);

        // do we have to drop THIS call?
        bool do_drop_call = has_drop_collect_call && has_recv_collect_call;

        if(!do_drop_call)
        {
            command(KHOMP_LOG, CM_CONNECT);
        }

        if(has_drop_collect_call)
        {
            if(has_recv_collect_call)
            {
                usleep(75000);

                DBG(FUNC, PVT_FMT(target(), "disconnecting collect call doChannelAnswer FXO"));
                command(KHOMP_LOG,CM_DISCONNECT);

                // thou shalt not talk anymore!
                stopListen();
                stopStream();
            }
            else
            {
                DBG(FUNC, PVT_FMT(target(), "dropping collect call at doChannelAnswer FXO"));
                command(KHOMP_LOG, CM_DROP_COLLECT_CALL);
            }
        }

        ret = KhompPvt::doChannelAnswer(cmd);

    }
    catch (ScopedLockFailed & err)
    {
        LOG(ERROR, PVT_FMT(_target,"(FXO) r (unable to lock %s!)") % err._msg.c_str() );
        return false;
    }

    DBG(FUNC, PVT_FMT(_target, "(FXO) r"));

    return ret;
}
Exemplo n.º 27
0
/* AudioEntryPanel::onBtnPause
 * Called when the pause button is pressed
 *******************************************************************/
void AudioEntryPanel::onBtnPause(wxCommandEvent& e)
{
	// Stop playing (no reset)
	stopStream();
	timer_seek->Stop();
}