void ExecutionObjectSwitch::select(ExecutionObject* executionObject) {
		vector<FormatterEvent*>* eventsVector;
		vector<FormatterEvent*>::iterator i;
		SwitchEvent* switchEvent;

		if (executionObject != NULL &&
				containsExecutionObject(executionObject->getId())) {

			cout << "ExecutionObjectSwitch::select '";
			cout << executionObject->getId() << "'" << endl;

			selectedObject = executionObject;

		} else {
			selectedObject = NULL;
			eventsVector = getEvents();
			if (eventsVector != NULL) {
				i = eventsVector->begin();
				while (i != eventsVector->end()) {
					switchEvent = (SwitchEvent*)(*i);
					switchEvent->setMappedEvent(NULL);
					++i;
				}
				delete eventsVector;
				eventsVector = NULL;
			}
		}
	}
void ExecutionObjectSwitch::select(ExecutionObject* executionObject) {
    vector<FormatterEvent*>* events;
    SwitchEvent* switchEvent;

    if (executionObject != NULL &&
            containsExecutionObject(executionObject->getId())) {

        selectedObject = executionObject;

    } else {
        selectedObject = NULL;
        events = getEvents();
        if (events != NULL) {
            vector<FormatterEvent*>::iterator i;
            i = events->begin();
            while (i != events->end()) {
                switchEvent = (SwitchEvent*)(*i);
                switchEvent->setMappedEvent(NULL);
                ++i;
            }
            delete events;
            events = NULL;
        }
    }
}
void FMRadio::Notify(const SwitchEvent& aEvent)
{
  if (mHeadphoneState != aEvent.status()) {
    LOG("Antenna state is changed!");
    mHeadphoneState = aEvent.status();
    DispatchTrustedEvent(ANTENNA_STATE_CHANGED_EVENT_NAME);
  }
}
Exemple #4
0
void
FMRadio::Notify(const SwitchEvent& aEvent)
{
  MOZ_ASSERT(!mHasInternalAntenna);

  if (mHeadphoneState != aEvent.status()) {
    mHeadphoneState = aEvent.status();

    DispatchTrustedEvent(NS_LITERAL_STRING("antennaavailablechange"));
  }
}
 void Notify(const SwitchEvent& aEvent) {
   NotifyHeadphonesStatus(aEvent.status());
   // When user pulled out the headset, a delay of routing here can avoid the leakage of audio from speaker.
   if (aEvent.status() == SWITCH_STATE_OFF && sSwitchDone) {
     MessageLoop::current()->PostDelayedTask(
       FROM_HERE, NewRunnableFunction(&ProcessDelayedAudioRoute, SWITCH_STATE_OFF), 1000);
     sSwitchDone = false;
   } else if (aEvent.status() != SWITCH_STATE_OFF) {
     InternalSetAudioRoutes(aEvent.status());
     sSwitchDone = true;
   }
 }
void
AudioChannelManager::Notify(const SwitchEvent& aEvent)
{
  if (aEvent.status() == SWITCH_STATE_ON ||
      aEvent.status() == SWITCH_STATE_HEADSET ||
      aEvent.status() == SWITCH_STATE_HEADPHONE) {
    mState = SWITCH_STATE_ON;
  } else {
    mState = SWITCH_STATE_OFF;
  }

  DispatchTrustedEvent(NS_LITERAL_STRING("headphoneschange"));
}
 virtual void Notify(const SwitchEvent& aEvent)
 {
   DBG("UsbCable switch device: %d state: %s\n",
       aEvent.device(), SwitchStateStr(aEvent));
   XRE_GetIOMessageLoop()->PostTask(
       FROM_HERE,
       NewRunnableFunction(UsbCableEventIOThread));
 }
Exemple #8
0
void
NotifySwitchChange(const SwitchEvent& aEvent)
{
  // When callback this notification, main thread may call unregister function
  // first. We should check if this pointer is valid.
  if (!sSwitchObserverLists)
    return;

  SwitchObserverList& observer = GetSwitchObserverList(aEvent.device());
  observer.Broadcast(aEvent);
}
Exemple #9
0
  void Notify(const SwitchEvent& aEvent) {
    NotifyHeadphonesStatus(aEvent.status());
    // When user pulled out the headset, a delay of routing here can avoid the leakage of audio from speaker.
    if (aEvent.status() == SWITCH_STATE_OFF && sSwitchDone) {
      MessageLoop::current()->PostDelayedTask(
        FROM_HERE, NewRunnableFunction(&ProcessDelayedAudioRoute, SWITCH_STATE_OFF), 1000);
      sSwitchDone = false;
    } else if (aEvent.status() != SWITCH_STATE_OFF) {
      InternalSetAudioRoutes(aEvent.status());
      sSwitchDone = true;
    }
    // Handle the coexistence of a2dp / headset device, latest one wins.
#if ANDROID_VERSION >= 17
    int32_t forceUse = 0;
    mAudioManager->GetForceForUse(AUDIO_POLICY_FORCE_FOR_MEDIA, &forceUse);
    if (aEvent.status() != SWITCH_STATE_OFF && sBluetoothA2dpEnabled) {
      mAudioManager->SetForceForUse(AUDIO_POLICY_FORCE_FOR_MEDIA, AUDIO_POLICY_FORCE_NO_BT_A2DP);
    } else if (forceUse == AUDIO_POLICY_FORCE_NO_BT_A2DP) {
      mAudioManager->SetForceForUse(AUDIO_POLICY_FORCE_FOR_MEDIA, AUDIO_POLICY_FORCE_NONE);
    }
#endif
  }
 void Notify(const SwitchEvent& aEvent) {
   InternalSetAudioRoutes(aEvent.status());
   NotifyHeadphonesStatus(aEvent.status());
 }