/****************************************************************************
DESCRIPTION
	Disconnect Sync audio
*/
void CsrSbcEncoderPluginDisconnect( void ) 
{   
    uint16 i;
    
    if (!SBC)
        Panic() ;
            
    StreamDisconnect(0, StreamKalimbaSink(0));

    KalimbaPowerOff() ;
  
    for (i = 0; i < MAX_AUDIO_SINKS; i++)
	{
		if (SBC->media_sink[i] != 0)
		{										
			/* Disconnect the Kalimba source from the media sink */
            StreamDisconnect(StreamKalimbaSource(i+2), SBC->media_sink[i]);
            
            PRINT(("Audio Plugin: Disconnect media i:%d sink:0x%x\n",i,(uint16)SBC->media_sink[i]));
                
            /* clear the audio sink */	
	        SBC->media_sink[i] = 0;			            
		}
	}
        
    free (SBC);
    SBC = NULL ;        
}
/****************************************************************************
NAME 
    a2dpStreamStartDsp

DESCRIPTION
    To load the corresponding DSP kap file for the selected audio plugin, and set 
    the encoder mode.
    
    As the same dsp kap file is used for both USB source and Analogue source, it is 
    better to load the kap file in application instead of plugin library.
 
*/
void a2dpStreamStartDsp(bool isA2DPstreaming)
{    
#ifdef KAL_MSG
    uint16 codec_type = CodecSbc;
    FILE_INDEX index  = FILE_NONE;
    
    DEBUG_A2DP(("a2dpStreamStartDsp %d\n",isA2DPstreaming));

    /* Power off the kalimba first before load the Kap file again */
    KalimbaPowerOff() ;
     
    /* This will be changed if one kap file supports both usb and analogue source types */
    if (isA2DPstreaming)
    {
        Task audio_plugin = initA2dpPlugin(the_app->a2dp_active_seid);
    
        the_app->a2dp_audio_plugin = audio_plugin;
    
        /* Select the corresponding kap file */
        if ( (audio_plugin == (TaskData *)&csr_sbc_encoder_plugin) )
        {
            index = FileFind(FILE_ROOT, sbc_encoder, sizeof(sbc_encoder)-1); 
            codec_type = CodecSbc;
        }
    }
    else
    {    
        /* we should load the source type, and can not set as the default type: SourceUsb*/
        the_app->aghfp_audio_plugin  = initScoPlugin();
        
        /* Select the corresponding kap file */
        index = FileFind(FILE_ROOT, sbc_encoder, sizeof(sbc_encoder)-1);
    }

    /* Load the DSP Kap file */
    if (index == FILE_NONE)
        Panic();
    if (!KalimbaLoad(index))
        Panic();    

    DEBUG_A2DP(("KalimbaLoad %s\n",sbc_encoder));
    
    /* Register the Kalimba message */
    MessageKalimbaTask(&the_app->task);
    
    /* send the codec type to kalimba, this is necessary as codecs share kap files */
    if (codec_type != CodecMp3) 
    {
        if (!KalimbaSendMessage(KALIMBA_CODEC_TYPE_MESSAGE, codec_type,0,0,0))
        {
            Panic();
        }
    }
#else
    DEBUG_A2DP(("a2dpStreamStartDsp %d\n",isA2DPstreaming));
#endif	
}
示例#3
0
void CsrSubwooferPluginDisconnect(void)
{
    /* Disconnect the appropriate input to Kalimba */
    if (plugin_data->input == SUBWOOFER_INPUT_ADC)
    {
        PRINT(("[SW_PLUGIN : Disconnect ADC to Kalimba\n"));
        StreamDisconnect(plugin_data->audio_source, StreamKalimbaSink(DSP_INPUT_PORT_ADC));
    }
    else if (plugin_data->input == SUBWOOFER_INPUT_ESCO)
    {
        PRINT(("[SW_PLUGIN] Disconnect eSCO to Kalimba\n"));
        StreamDisconnect(plugin_data->audio_source, StreamKalimbaSink(DSP_INPUT_PORT_ESCO));
        StreamConnectDispose(plugin_data->audio_source);
    }
    else if (plugin_data->input == SUBWOOFER_INPUT_L2CAP)
    {
        PRINT(("[SW_PLUGIN] Disconnect L2CAP to Kalimba\n"));
        StreamDisconnect(plugin_data->audio_source, StreamKalimbaSink(DSP_INPUT_PORT_L2CAP));
        StreamConnectDispose(plugin_data->audio_source);
    }
    
    /* Disconnect the appropriate output from Kalimba */
    if (plugin_data->output == SUBWOOFER_OUTPUT_DAC)
    {
        PRINT(("[SW_PLUGIN] Disconnect Kalimba to DAC\n"));
        StreamDisconnect(StreamKalimbaSource(DSP_OUTPUT_PORT_DAC), plugin_data->codec_sink);
    }
    else if (plugin_data->output == SUBWOOFER_OUTPUT_I2S)
    {
        PRINT(("[SW_PLUGIN] Disconnect Kalimba to I2S\n"));
        CsrI2SAudioOutputDisconnect(TRUE);                                 
    }
    
    /* dispose of any remaining messages in the queue */
    (void) MessageCancelAll( (TaskData*)&csr_subwoofer_plugin, MESSAGE_FROM_KALIMBA);
    MessageKalimbaTask( NULL );
   
    /* Everything has been disconnected so power down Kalimba */
    KalimbaPowerOff();
    
    /* reset flags */
    SetAudioInUse(FALSE);
    SetCurrentDspStatus(DSP_NOT_LOADED);

    /* Free the memory allocated to use for the plugin as it's no longer valid */
    free(plugin_data);
    plugin_data = NULL;
}
/****************************************************************************
DESCRIPTION
	Disconnect Sync audio
*/
void CsrA2dpDecoderPluginDisconnect( void )
{
    if (!DECODER)
        Panic() ;

        /*disconnect the pcm streams*/
    StreamDisconnect(StreamPcmSource(0), StreamPcmSink(0));
	StreamDisconnect(StreamPcmSource(1), StreamPcmSink(1));

	   /* For sinks disconnect the source in case its currently being disposed. */
    StreamDisconnect(StreamSourceFromSink(DECODER->media_sink ), 0);
    StreamConnectDispose (StreamSourceFromSink(DECODER->media_sink)) ;

    KalimbaPowerOff() ;

    free (DECODER);
    DECODER = NULL ;
}
示例#5
0
void A2dpStopKalimbaStreaming(void)
{
    KalimbaPowerOff();
}