示例#1
0
/****************************************************************************
DESCRIPTION
    sets the current A2dp volume
    
*/
void VolumeSetA2dp(uint16 index, uint16 oldVolume)
{               
    if(theHeadset.audioData.gVolMaps[ theHeadset.a2dp_link_data->gAvVolumeLevel[index] ].A2dpGain == VOLUME_A2DP_MUTE_GAIN)
    {                   
        /* if actual mute enabled, activate it now */
        if(theHeadset.audioData.gVolMaps[ oldVolume ].A2dpGain != VOLUME_A2DP_MUTE_GAIN)
        {
            VOL_DEBUG(("VOL: A2dp mute\n"));
            AudioSetMode(AUDIO_MODE_MUTE_SPEAKER, NULL);
        }
    }                
    else
    {
        VOL_DEBUG(("VOL: A2dp set vol [%d][%d]\n", theHeadset.a2dp_link_data->gAvVolumeLevel[index], theHeadset.audioData.gVolMaps[ theHeadset.a2dp_link_data->gAvVolumeLevel[index] ].A2dpGain - 1));
        AudioSetVolume ( theHeadset.audioData.gVolMaps[ theHeadset.a2dp_link_data->gAvVolumeLevel[index] ].A2dpGain - 1 , theHeadset.codec_task ) ;
    }
    /* set volume level in audio plugin */
    if ((theHeadset.audioData.gVolMaps[ theHeadset.a2dp_link_data->gAvVolumeLevel[index] ].A2dpGain != VOLUME_A2DP_MUTE_GAIN) && (theHeadset.audioData.gVolMaps[ oldVolume ].A2dpGain == VOLUME_A2DP_MUTE_GAIN))
    {
        /* the audio was muted but now should be un-muted as above minimum volume */   
        VOL_DEBUG(("VOL: A2dp unmute\n"));
        AudioSetMode(AUDIO_MODE_CONNECTED, NULL);
    }         
    /* play tone if applicable */
#if 1
    if(theHeadset.audioData.gVolMaps[theHeadset.a2dp_link_data->gAvVolumeLevel[index]].Tone)
    {
    	if(stateManagerGetState() == headsetA2DPStreaming)
		{
        	TonesPlayTone(theHeadset.audioData.gVolMaps[theHeadset.a2dp_link_data->gAvVolumeLevel[index]].Tone ,theHeadset.features.QueueVolumeTones, FALSE);
    	}
    }
#endif
}
示例#2
0
/****************************************************************************
NAME    
    sinkAudioSetEnhancement
DESCRIPTION
    updates the current audio enhancement settings and updates the dsp if it
    is currently running and streaming a2dp music.

RETURNS
    void
*/
void sinkAudioSetEnhancement(uint16 enhancement, bool enable)
{
    a2dp_stream_state a2dpStatePri = a2dp_stream_idle;
    a2dp_stream_state a2dpStateSec = a2dp_stream_idle;   
    Sink a2dpSinkPri = 0;
    Sink a2dpSinkSec = 0;
    uint16 lEnhancements;
    
    /* user has changed an enhancement default, set flag to indicate user values should be used and not 
       dsp default values */
    if(enhancement != MUSIC_CONFIG_SUB_WOOFER_BYPASS)    
    {
        /* don't update for sub woofer only changes */        
        theSink.a2dp_link_data->a2dp_audio_mode_params.music_mode_enhancements |= MUSIC_CONFIG_DATA_VALID;
    }
    
    /* take local copy as enhancement bits are inverted in the dsp */
    lEnhancements = theSink.a2dp_link_data->a2dp_audio_mode_params.music_mode_enhancements;
                
    /* if an enhancement is being enabled add to enables bitmask */
    if(enable)        
        lEnhancements |= enhancement;
    /* otherwise remove it */    
    else
        lEnhancements &= ~enhancement;
   
    /* determine if value has changed and needs to be committed to PS */
    if(theSink.a2dp_link_data->a2dp_audio_mode_params.music_mode_enhancements != lEnhancements)
    {
        theSink.a2dp_link_data->a2dp_audio_mode_params.music_mode_enhancements = lEnhancements;
        configManagerWriteSessionData () ; 
    }

    /* now decide whether the music manager is currently running and an update of 
       configuration is required */
         
    /* if a2dp connected obtain the current streaming state for primary a2dp connection */
    getA2dpStreamData(a2dp_primary,   &a2dpSinkPri, &a2dpStatePri);

    /* if a2dp connected obtain the current streaming state for secondary a2dp connection */
    getA2dpStreamData(a2dp_secondary, &a2dpSinkSec, &a2dpStateSec);
 
    /* Determine which a2dp source this is for */
    if(((a2dpStatePri == a2dp_stream_streaming) && (a2dpSinkPri == theSink.routed_audio))||
       ((a2dpStateSec == a2dp_stream_streaming) && (a2dpSinkSec == theSink.routed_audio))
#ifdef ENABLE_USB
       ||((usbAudioSinkMatch(theSink.routed_audio) && (theSink.usb.config.plugin_type == usb_plugin_stereo)))
#endif
#ifdef ENABLE_WIRED        
       ||(wiredAudioSinkMatch(theSink.routed_audio))
#endif        
      )
    {                
        AudioSetMode(AUDIO_MODE_CONNECTED, &theSink.a2dp_link_data->a2dp_audio_mode_params);
    }
}
示例#3
0
/****************************************************************************
NAME 
 VolumeMuteOn

DESCRIPTION
 Enables Mute

RETURNS
 void
    
*/
void VolumeMuteOn ( void )
{
    VOL_DEBUG(("VOL: Mute\n")) ;        
    
	/* If headset wants to mute on or receive +VGM = 0 command from one AG, 
	   Send command to both AGs and mute itself 
	*/
	if(theHeadset.features.EnableSyncMuteMicophones)
	{
		VOL_DEBUG(("VOL: Send AT+VGM = 0 to AG1 if AG1 does not require to mute Mic\n")) ;
		if( !theHeadset.profile_data[PROFILE_INDEX(hfp_primary_link)].audio.gAgSyncMuteFlag )
			HfpVolumeSyncMicrophoneGainRequest(hfp_primary_link, 0);
		else
			theHeadset.profile_data[PROFILE_INDEX(hfp_primary_link)].audio.gAgSyncMuteFlag = 0;
			
		/* if AG2 is connected, send a message to AG2 */
   		if((theHeadset.conf->no_of_profiles_connected > 1))
   		{
			VOL_DEBUG(("VOL: Send AT+VGM = 0 to AG2 if AG2 does not require to mute Mic\n")) ;
			if( !theHeadset.profile_data[PROFILE_INDEX(hfp_secondary_link)].audio.gAgSyncMuteFlag )
				HfpVolumeSyncMicrophoneGainRequest(hfp_secondary_link, 0);
			else
				theHeadset.profile_data[PROFILE_INDEX(hfp_secondary_link)].audio.gAgSyncMuteFlag = 0;
		}     
	}

    if (theHeadset.features.MuteSpeakerAndMic)
        AudioSetMode ( AUDIO_MODE_MUTE_BOTH , NULL ) ;
    else
        AudioSetMode ( AUDIO_MODE_MUTE_MIC , NULL) ;

    PioSetMicrophoneBias ( FALSE ) ; 
 
    /*update the mutestate*/    
    theHeadset.gMuted = TRUE ;
	
	if(theHeadset.conf->timeouts.MuteRemindTime_s !=0)
    	MessageSendLater( &theHeadset.task , EventMuteReminder , 0 ,D_SEC(theHeadset.conf->timeouts.MuteRemindTime_s ) ) ;
}
示例#4
0
文件: sink_usb.c 项目: NemProjects/BC
/****************************************************************************
NAME 
    usbAudioSetVolume
    
DESCRIPTION
    Set USB audio volume
    
RETURNS
    void
*/ 
void usbAudioSetVolume(void)
{
    if(usbAudioSinkMatch(theSink.routed_audio) && USB_CLASS_ENABLED(USB_DEVICE_CLASS_AUDIO))
    {
        Task plugin;
        AUDIO_MODE_T mode;
        uint16 volume = usbGetVolume(&mode);
        
        /* get usb plugin being used */
        usbAudioGetPluginInfo(&plugin, theSink.usb.config.plugin_type, theSink.usb.config.plugin_index);      
        /* Set volume if USB audio connected */
        AudioSetVolume(volume, TonesGetToneVolume(FALSE), plugin);
        /* use a2dp connect parameters */
        AudioSetMode(mode, &theSink.a2dp_link_data->a2dp_audio_mode_params);
    }
}
示例#5
0
/****************************************************************************
NAME 
 VolumeMuteOff

DESCRIPTION
 Disables Mute

RETURNS
 void
    
*/
void VolumeMuteOff ( void )
{
	/*update the mutestate*/    
    VOL_DEBUG(("VOL: UnMute\n")) ;        
    theHeadset.gMuted = FALSE ;
    
	/* If headset wants to mute off, detect which AG has active sco and sent mute off */
		/* If headset wants to mute on or receive +VGM = 0 command from one AG, 
	   Send command to both AG mute itself 
	*/
	if(theHeadset.features.EnableSyncMuteMicophones)
	{
		VOL_DEBUG(("VOL: Send AT+VGM = 1 to AG1 if AG1 does not require to unmute Mic\n")) ; 
		if( !theHeadset.profile_data[PROFILE_INDEX(hfp_primary_link)].audio.gAgSyncMuteFlag )
            HfpVolumeSyncMicrophoneGainRequest(hfp_primary_link, 0);
		else
			theHeadset.profile_data[PROFILE_INDEX(hfp_primary_link)].audio.gAgSyncMuteFlag = 0;
			
		/* if AG2 is connected, send a message to AG2 */
 		if((theHeadset.conf->no_of_profiles_connected > 1) )
   		{
    		VOL_DEBUG(("VOL: Send AT+VGM = 1 to AG2 if AG2 does not require to unmute Mic\n")) ; 
			if( !theHeadset.profile_data[PROFILE_INDEX(hfp_secondary_link)].audio.gAgSyncMuteFlag )
				HfpVolumeSyncMicrophoneGainRequest(hfp_secondary_link, 0);
			else
				theHeadset.profile_data[PROFILE_INDEX(hfp_secondary_link)].audio.gAgSyncMuteFlag = 0;
		}     
	}

	/*cancel any mute reminders*/
    MessageCancelAll( &theHeadset.task , EventMuteReminder ) ;
    
    AudioSetMode ( AUDIO_MODE_CONNECTED , NULL ) ;  
    
	if (theHeadset.sco_sink)
	{
    	    /*set the mic bias*/
	    PioSetMicrophoneBias ( TRUE ) ;
	}
}
void handleUEMessage( Task task, MessageId id, Message message )
{ 
    headsetHfpState lState = stateManagerGetHfpState() ;
    
    /* If we do not want the event received to be indicated then set this to FALSE. */
    bool lIndicateEvent = TRUE ;

	if (theHeadset.ProfileLibrariesInitialising)
	{
		if (!eventAllowedWhileProfilesInitialising(id))
		{
			EVENTS_DEBUG(("Event 0x%x while profiles initialising - queue\n",id));
			MessageSendConditionally(&theHeadset.task, id, 0, &theHeadset.ProfileLibrariesInitialising);
			return;
		}
	}    
    
    /* Deal with user generated Event specific actions*/
    switch ( id )
    {   
            /*these are the events that are not user generated and can occur at any time*/
        case EventOkBattery:
        case EventChargerDisconnected:
        case EventLEDEventComplete:
        case EventTrickleCharge:
		case EventFastCharge:
        case EventLowBattery:
        case EventPowerOff:
        case EventLinkLoss:
        case EventSLCConnected:
		case EventA2dpConnected:
        case EventError:
        case EventChargeError:
        case EventCancelLedIndication:
        case EventAutoSwitchOff:
		case EventHfpReconnectFailed:
		case EventA2dpReconnectFailed:
            /*do nothing for these events*/
        break ;
        default:
        break;
    }
    
    
    switch (id)
    {
    case EventPowerOn:
        EVENTS_DEBUG(("EventPowerOn\n"));
		
		if (!theHeadset.headsetPoweredOn)
		{
			theHeadset.headsetPoweredOn = TRUE;
			theHeadset.a2dp_list_index = 0xf;
			theHeadset.hfp_list_index = 0xf;
			theHeadset.switch_a2dp_source = FALSE;
		
        	stateManagerPowerOn();
			
			if(theHeadset.Timeouts.EncryptionRefreshTimeout_m != 0)
				MessageSendLater(&theHeadset.task, APP_EVENT_REFRESH_ENCRYPTION, 0, D_MIN(theHeadset.Timeouts.EncryptionRefreshTimeout_m));
			
        	theHeadset.PowerOffIsEnabled = TRUE ;
		}
		else
		{
			lIndicateEvent = FALSE ;
		}
        break;
    case EventPowerOff:
        EVENTS_DEBUG(("EventPowerOff\n"));
		if (!theHeadset.PowerOffIsEnabled)
		{
			EVENTS_DEBUG(("Power off disabled - ignore event\n"));
			lIndicateEvent = FALSE ;
			break;
		}
		
		theHeadset.headsetPoweredOn = FALSE;
		theHeadset.a2dp_list_index = 0xf;
		theHeadset.hfp_list_index = 0xf;
		theHeadset.switch_a2dp_source = FALSE;
		
        stateManagerEnterPoweringOffState();
        AuthResetConfirmationFlags();
        if (theHeadset.gMuted)
            VolumeMuteOff() ;
        hfpCallClearQueuedEvent() ;
		
		if(theHeadset.Timeouts.EncryptionRefreshTimeout_m != 0)
    		MessageCancelAll ( &theHeadset.task, APP_EVENT_REFRESH_ENCRYPTION) ;
		
        MessageCancelAll ( &theHeadset.task , EventPairingFail) ;
        break;
    case EventEnterPairing:    
		EVENTS_DEBUG(("EventEnterPairing\n"));
        stateManagerEnterConnDiscoverableState( ) ;       
        break ;
    case EventPairingFail:  
        EVENTS_DEBUG(("EventPairingFail\n"));
        if (lState != headsetTestMode)
        {      
			stateManagerEnterHfpConnectableState( TRUE) ; 
        }
        break ;    
    case EventPairingSuccessful:
        EVENTS_DEBUG(("EventPairingSuccessful\n"));
        if (lState == headsetConnDiscoverable)
        {
            stateManagerEnterHfpConnectableState( FALSE) ;
        }
        break ;
    case EventConfirmationAccept:
        EVENTS_DEBUG(("EventConfirmationAccept\n"));
        headsetPairingAcceptRes();
        break;
    case EventConfirmationReject:
        EVENTS_DEBUG(("EventConfirmationReject\n"));
        headsetPairingRejectRes();
        break;
    case EventToggleDebugKeys:
        EVENTS_DEBUG(("EventToggleDebugKeys\n"));
        /* if debug keys functionality enabled toggle current state */
        if (theHeadset.features.debugKeysEnabled)
        {
            ConnectionSmSecModeConfig(&theHeadset.task,
                                      cl_sm_wae_acl_owner_none,
                                      !theHeadset.debugKeysInUse,
                                      TRUE);
        }
        break;
    case EventSLCConnected:
        EVENTS_DEBUG(("EventSLCConnected\n"));
        hfpCallRecallQueuedEvent() ;
        break;
    case EventLinkLoss:
        EVENTS_DEBUG(("EventLinkLoss\n"));        
        break;
    case EventSLCDisconnected:
        EVENTS_DEBUG(("EventSLCDisconnected\n"));
		if (lState == headsetPoweringOn )
			lIndicateEvent = FALSE ;
		
        theHeadset.voice_recognition_enabled = FALSE;
        break;
    case EventEstablishSLC:   
		EVENTS_DEBUG(("EventEstablishSLC\n"));
		
		/* Cancel inquiry and throw away results if one is in progress */
        inquiryStop();
		
		if (theHeadset.slcConnectFromPowerOn)
		{
			/* This is from power on so carry out the power on connect sequence */
			lIndicateEvent = FALSE ;			
		}
		else
		{
		    bdaddr bd_addr;
			/* Try a connection attempt to Last AG. */       
    		if (!hfpSlcConnectBdaddrRequest( hfp_handsfree_profile, &bd_addr ) )
				lIndicateEvent = FALSE ;
		}
        
        break;
    case EventHfpReconnectFailed:
        EVENTS_DEBUG(("EventHfpReconnectFailed\n"));
        break;
	case EventA2dpReconnectFailed:
        EVENTS_DEBUG(("EventA2dpReconnectFailed\n"));
        break;
    case EventInitateVoiceDial:                   
		EVENTS_DEBUG(("EventInitateVoiceDial [%d]\n", theHeadset.voice_recognition_enabled )) ; 
        /* Toggle the voice dial behaviour depending on whether we are currently active */
        if (theHeadset.voice_recognition_enabled)
        {
            hfpCallCancelVoiceDial() ;
            lIndicateEvent = FALSE ;
        }
        else
        {     
            if (!hfpCallInitiateVoiceDial())
				lIndicateEvent = FALSE ;
        }            
        break ;
    case EventLastNumberRedial:          
		if (theHeadset.features.LNRCancelsVoiceDialIfActive)
		{
			if (theHeadset.voice_recognition_enabled)
			{
				MessageSend(&theHeadset.task, EventInitateVoiceDial, 0);
				lIndicateEvent = FALSE ;
				break;
			}
		}
		
		EVENTS_DEBUG(("EventLastNumberRedial\n" )) ; 
		
        if (!hfpCallInitiateLNR())
			lIndicateEvent = FALSE ;
        break ;
    case EventAnswer:
        EVENTS_DEBUG(("EventAnswer\n" )) ;		
        /* Call the HFP lib function, this will determine the AT cmd to send
           depending on whether the profile instance is HSP or HFP compliant. */ 
        hfpCallAnswer();
        break ; 
    case EventReject:
        EVENTS_DEBUG(("EventReject\n" )) ;
        /* Reject incoming call - only valid for instances of HFP. */ 
        hfpCallReject();
        break ;
    case EventCancelEnd:
		if (theHeadset.features.EndCallWithNoSCOtransfersAudio && !HfpGetAudioSink(theHeadset.hfp_hsp))
		{
			lIndicateEvent = FALSE;
			MessageSend(&theHeadset.task, EventTransferToggle, 0);
		}
		else
		{
        	EVENTS_DEBUG(("EventCancelEnd\n" )) ;
        	/* Terminate the current ongoing call process */
        	hfpCallHangUp();
		}
        break ;
    case EventTransferToggle :
	    EVENTS_DEBUG(("EventTransferToggle\n")) ;    
        hfpCallTransferToggle() ;
	    break ;
    case EventSCOLinkOpen :        
        EVENTS_DEBUG(("EventScoLinkOpen\n")) ;
        break ;
    case EventSCOLinkClose:        
        EVENTS_DEBUG(("EventScoLinkClose\n")) ;
        break ;        
    case EventResetPairedDeviceList:          
		EVENTS_DEBUG(("EventResetPairedDeviceList\n")) ;  
        if ( stateManagerIsHfpConnected () )
        {
            /* Then we have an SLC active */
            hfpSlcDisconnect();
        }             
		if ( stateManagerIsA2dpConnected() )
    	{      
       		a2dpDisconnectRequest();
    	}
        configManagerReset() ;
        break ;
    case EventToggleMute:
        EVENTS_DEBUG(("EventToggleMute\n")) ;
        VolumeToggleMute() ;
        break ;    
    case EventMuteOn :
        EVENTS_DEBUG(("EventMuteOn\n")) ;
        VolumeMuteOn() ;
        break ;
    case EventMuteOff:
        EVENTS_DEBUG(("EventMuteOff\n")) ;
        VolumeMuteOff() ;
        break ;
    case EventMuteReminder :        
        EVENTS_DEBUG(("EventMuteReminder\n")) ;
        MessageSendLater( &theHeadset.task , EventMuteReminder , 0 ,D_SEC(theHeadset.Timeouts.MuteRemindTime_s ) )  ;            
        break;
    case EventEnterDutState :
        EVENTS_DEBUG(("EventEnterDutState\n")) ;            
		stateManagerEnterTestModeState() ;
        break;  
	case EventEnterDutMode :
        EVENTS_DEBUG(("EventEnterDutMode\n")) ; 
		if (lState != headsetTestMode)
        {
        	MessageSend( task , EventEnterDutState, 0 ) ;
        }
		ConnectionEnterDutMode();
        break;
	case EventEnterTXContTestMode:
		EVENTS_DEBUG(("EventEnterTXContTestMode\n"));
		if (lState != headsetTestMode)
        {
        	MessageSend( task , EventEnterDutState, 0 ) ;
        }
		MessageSendLater( task , APP_TX_TEST_MODE, 0, 1000 ) ;
		break;
    case EventResetComplete:
        EVENTS_DEBUG(("EventResetComplete\n"));
        break;
    case EventError:        
        EVENTS_DEBUG(("EventError\n")) ;
        break;
    case EventEndOfCall :        
        EVENTS_DEBUG(("EventEndOfCall\n")) ;
        break;    
	case EventA2dpConnected:
        EVENTS_DEBUG(("EventA2dpConnected\n")) ;		
        break;    
	case EventA2dpDisconnected:
        EVENTS_DEBUG(("EventA2dpDisconnected\n")) ;
		if (lState == headsetPoweringOn )
			lIndicateEvent = FALSE ;
        break; 
	case EventVolumeMax:
		EVENTS_DEBUG(("EventVolumeMax\n"));
		break;
	case EventVolumeMin:
		EVENTS_DEBUG(("EventVolumeMin\n"));
		break;
	case EventPlay:		
		EVENTS_DEBUG(("EventPlay\n"));
		/* Always indicate play event as will try to connect A2DP if not already connected */
		avrcpEventPlay();		
		break;
	case EventPause:		
		EVENTS_DEBUG(("EventPause\n"));
		avrcpEventPause();		
		break;
	case EventStop:		
		EVENTS_DEBUG(("EventStop\n"));
		avrcpEventStop();		
		break;
	case EventSkipForward:		
		/* Only indicate event if AVRCP connected */
		if ( stateManagerIsAvrcpConnected() )
		{
			EVENTS_DEBUG(("EventSkipForward\n"));
			avrcpEventSkipForward();
		}
		else
		{
			lIndicateEvent = FALSE ;
		}
		break;
	case EventSkipBackward:		
		/* Only indicate event if AVRCP connected */
		if ( stateManagerIsAvrcpConnected() )
		{
			EVENTS_DEBUG(("EventSkipBackward\n"));
			avrcpEventSkipBackward();	
		}
		else
		{
			lIndicateEvent = FALSE ;
		}
		break;
	case EventFFWDPress:		
		if ( stateManagerIsAvrcpConnected() )
		{
			EVENTS_DEBUG(("EventFFWDPress\n"));
			avrcpEventFastForwardPress();
		}
		else
		{
			lIndicateEvent = FALSE ;
		}
		break;
	case EventFFWDRelease:		
		if ( stateManagerIsAvrcpConnected() )
		{
			EVENTS_DEBUG(("EventFFWDRelease\n"));
			avrcpEventFastForwardRelease();
		}
		else
		{
			lIndicateEvent = FALSE ;
		}
		break;
	case EventRWDPress:		
		if ( stateManagerIsAvrcpConnected() )
		{
			EVENTS_DEBUG(("EventRWDPress\n"));
			avrcpEventFastRewindPress();
		}
		else
		{
			lIndicateEvent = FALSE ;
		}
		break;
	case EventRWDRelease:		
		if ( stateManagerIsAvrcpConnected() )
		{
			EVENTS_DEBUG(("EventRWDRelease\n"));
			avrcpEventFastRewindRelease();
		}
		else
		{
			lIndicateEvent = FALSE ;
		}
		break;		
	case EventEnterDFUMode:
		EVENTS_DEBUG(("EventEnterDFUMode\n"));
		BootSetMode(0);
		break;		
	case EventSwitchA2dpSource:
		EVENTS_DEBUG(("EventSwitchA2dpSource\n"));
		a2dpSwitchSource();
		break;
	case EventSwitchAudioMode:
		EVENTS_DEBUG(("EventSwitchAudioMode\n"));
		if (theHeadset.eqMode >= eq_mode_passthrough)
		{
			theHeadset.eqMode = eq_mode_level1;
		}
		else
		{
			theHeadset.eqMode++;	
		}
		if ((theHeadset.dsp_process == dsp_process_a2dp))
		{
			/* Set audio mode for A2DP only (not used for Faststream) */
			AudioSetMode(theHeadset.eqMode, 0);
		}
		break;
	case EventToggleLEDS:
		EVENTS_DEBUG(("EventToggleLEDS\n"));
		
#ifdef ROM_LEDS			
		LedManagerToggleLEDS();
#endif
		
		break;
		
	/* threeway calling events */
	case EventThreeWayReleaseAllHeld:
		EVENTS_DEBUG(("EventThreeWayReleaseAllHeld\n"));
        HfpMultipleCallsReleaseHeldOrRejectWaiting(theHeadset.hfp);
        break;
 	case EventThreeWayAcceptWaitingReleaseActive:
        EVENTS_DEBUG(("EventThreeWayAcceptWaitingReleaseActive\n"));
        HfpMultipleCallsReleaseActiveAcceptOther(theHeadset.hfp);
        break;
	case EventThreeWayAcceptWaitingHoldActive:
		EVENTS_DEBUG(("EventThreeWayAcceptWaitingHoldActive\n"));
		HfpMultipleCallsHoldActiveAcceptOther(theHeadset.hfp);
		break;
	case EventThreeWayAddHeldTo3Way:
 		EVENTS_DEBUG(("EventThreeWayAddHeldTo3Way\n"));
		HfpMultipleCallsAddHeldCall(theHeadset.hfp);
 		break;
	case EventThreeWayConnect2Disconnect:
 		EVENTS_DEBUG(("EventThreeWayConnect2Disconnect\n"));
		HfpMultipleCallsExplicitCallTransfer(theHeadset.hfp);
		break;
        /* end threeway calling events */
		
	case EventRssiPair:
        EVENTS_DEBUG(("EventRssiPair\n"));
		/* start inquiry on this event */
        inquiryStart();
        break;
    case EventRssiPairReminder:
        EVENTS_DEBUG(("EventRssiPairReminder\n"));
		inquiryReminder();
        break;
    case EventRssiPairTimeout:
        EVENTS_DEBUG(("EventRssiPairTimeout\n"));
		/* Stop any pending inquiry now as this pairing mode has timed out */
        inquiryStop();
        break;

    default:
        EVENTS_DEBUG(("UNHANDLED EVENT: 0x%x\n",id));
        lIndicateEvent = FALSE ;
        break;
    }    
    
    if ( lIndicateEvent )
    {
        LEDManagerIndicateEvent ( id ) ;
    }   
}
/****************************************************************************
NAME 
    a2dpStreamConnectA2dpAudio

DESCRIPTION
    To connnect the audio plugin for a2dp audio streaming;
 
*/
void a2dpStreamConnectA2dpAudio(Sink media_sink)
{
    uint16 i, counter = 0;
    Sink media_sink_arr[MAX_NUM_DEV_CONNECTIONS];
    
    DEBUG_A2DP(("a2dpStreamConnectA2dpAudio\n"));
    
    MessageCancelAll(&the_app->task, APP_CONNECT_A2DP_AUDIO);
    
    if (the_app->active_encoder == EncoderAv)
    {
        /* This indicates streaming is already active and now a second audio connection has
           to be routed. Use the AudioSetMode function to start the second audio stream. 
        */
        dualstream_mode_params *dual_mode = (dualstream_mode_params *)PanicUnlessMalloc(sizeof(dualstream_mode_params));
        dual_mode->connect_sink = TRUE; /* Indicate the audio is being connected */
        dual_mode->media_sink = media_sink; /* Supply the second media sink that is being connected */
        AudioSetMode(AUDIO_MODE_CONNECTED, (void*)dual_mode);

        DEBUG_A2DP(("AudioSetMode connect_sink:0x%x \n",(uint16)media_sink));
    }
    else
    {
        /* No audio is currently active, so route the audio for all active streams */
        for (i = 0; i < MAX_NUM_DEV_CONNECTIONS; i++)
        {
            if ((the_app->dev_inst[i] != NULL) && (the_app->dev_inst[i]->a2dp_state == A2dpStateStreaming))
            {
                DEBUG_A2DP(("*** streaming found i:%d a2dp:0x%x sink:0x%x ***\n",i,(uint16)the_app->dev_inst[i]->a2dp, (uint16)the_app->dev_inst[i]->a2dp_media_sink));
                media_sink_arr[counter++] = the_app->dev_inst[i]->a2dp_media_sink;
            }
        }
    
        /* Pass the second media sink as a parameter into the AudioConnect function that the audio plugin
           can recognise. 
        */
        if (counter > 1)
        {
            the_app->a2dp_data.codecData.media_sink_b = media_sink_arr[1];
        }
        else
        {
            the_app->a2dp_data.codecData.media_sink_b = 0;
        }
        
        /* Connect the audio plugin */
        AudioConnect(the_app->a2dp_audio_plugin , 
                 media_sink_arr[0] , 
                 AUDIO_SINK_AV ,
                 the_app->codecTask,
                 0x0a , 
                 the_app->a2dp_sample_rate ,  
                 (TRUE), 
                 AUDIO_MODE_CONNECTED, 
                 (source_codec_data_type *) &the_app->a2dp_data.codecData ) ;
        
        the_app->active_encoder = EncoderAv;
        
        DEBUG_A2DP(("AudioConnect devices:%d\n",counter));
    }
}
示例#8
0
/****************************************************************************
NAME    
    audio_update_mode_parameters - The audio parameters have changed so update the audio mode 
*/
void audio_update_mode_parameters(void)
{
    AudioSetMode(volume_get_mute_mode(), &theSource->audio_data.audio_a2dp_mode_params);
}