⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 av_stream_control.c

📁 bluelab 3.52 里面的立体声程序源代码
💻 C
字号:
/****************************************************************************
Copyright (C) Cambridge Silicon Radio Ltd. 2004-2006
Part of BlueLab 3.5.2-release

FILE NAME
    av_stream_control.c

DESCRIPTION
    Handles the actual AV streaming on Kalimba.

*/


/****************************************************************************
    Header files
*/
#include "headset_private.h"
#include "av_stream_control.h"
#include "cvc_headset.h"
#include "headset_codec.h"
#include "headset_common.h"
#include "headset_power.h"
#include "headset_tones.h"
#include "headset_volume.h"

#include <codec.h>
#include <file.h>
#include <kalimba.h>
#include <kalimba_standard_messages.h>
#include <panic.h>
#include <pcm.h>
#include <stdlib.h>
#include <string.h>
#include <transform.h>


#ifdef DEBUG_AVSTREAM
#define AVSTREAM_DEBUG(x) DEBUG(x)
#else
#define AVSTREAM_DEBUG(x) 
#endif





/**************************************************************************/
void avHeadsetConnectKalimbaToPcm(a2dp_channel_mode chn_mode)
{
    /* is it mono playback? */
    if (chn_mode == a2dp_mono)
    {
        AVSTREAM_DEBUG(("AV: Mono\n"));
        /* plug port 0 into both DACs */
        (void) PanicFalse(StreamConnect(StreamKalimbaSource(0),StreamPcmSink(0)));
    }
    else
    {
        AVSTREAM_DEBUG(("AV: Stereo\n"));
        /* plug port 0 into Left DAC */
        (void) PanicFalse(StreamConnect(StreamKalimbaSource(0),StreamPcmSink(0)));

        /* plug port 1 into Right DAC */
        (void) PanicFalse(StreamConnect(StreamKalimbaSource(1),StreamPcmSink(1)));
    }
}


/**************************************************************************/
void avHeadsetStartKalimba(headsetTaskData* app)
{
    AVSTREAM_DEBUG(("AV: Start Kalimba\n"));
    
    /* Start decode */
    A2dpAudioCodecEnable(app->a2dp, app->media_sink);
   
    avHeadsetConnectKalimbaToPcm(app->channel_mode);    

    /* Start decode */
    if(!KalimbaSendMessage(KALIMBA_MSG_GO,0,0,0,0))
    {
        AVSTREAM_DEBUG(("AV: Message KALIMBA_MSG_GO failed!\n"));
        Panic();
    }
        

/*    app->led_state |= LED_STREAMING; removed by HJB*/
	app->led_state |= LED_CONNECTED;
    app->active_profile = av_active;
    app->av_stream_stopped = FALSE;
}


/**************************************************************************/
void avHeadsetAvStreamStop(headsetTaskData* app, bool send_suspend)
{
    if (app->av_stream_stopped || !app->media_sink)
        return;

    AVSTREAM_DEBUG(("AV: Stream Stop...\n"));

    /* Stop decode */
    A2dpAudioCodecDisable(app->a2dp, app->media_sink);

    if (send_suspend)
        A2dpSuspend(app->a2dp, app->media_sink);

 /*   app->led_state &= ~LED_STREAMING;  removed by HJB*/
    app->av_stream_stopped = TRUE;
    
    /* Start the timer to shut down the audio amp */
    MessageSendLater(getAppTask(), APP_AMP_IDLE_IND, 0, AMP_IDLE_TIMER);
}


/**************************************************************************/
void avHeadsetAvStreamStart(headsetTaskData* app)
{
    if (!app->av_stream_stopped || !app->media_sink)
        return;

    AVSTREAM_DEBUG(("AV: Stream Start...\n"));
    
    if (isTonePlaying(app->pcm_audio_state))
    {
        setPcmState(app, pcm_tone_to_av);
        AVSTREAM_DEBUG(("AV: Tone playing\n"));
        return;
    }
    else
    {
        setPcmState(app, pcm_av);
    }
    
    /* Set the local volume to mute */
    headsetUpdateVolume(app->codec_task, 0);
    
#ifdef INCLUDE_CVC
    if (app->cvc.hfkdspready)
    {
        CvcHeadsetUnloaded(app);
        KalimbaPowerOff();
    }
#endif
   
    /* Make sure amp is powered on */
    headsetPowerAmp(app, TRUE);

    /* Cancel the timer to shut down the audio amp */
    MessageCancelAll(getAppTask(), APP_AMP_IDLE_IND);

    /* Configure the DACs for the codec configuration */
    codec_configure_AvStream(app);

    if (app->sent_suspend)
    {
        A2dpStart(app->a2dp, app->media_sink);
        app->sent_suspend = FALSE;
    }
    else
        avHeadsetStartKalimba(app);
    
    /* Set the local volume back to what it was */
    headsetUpdateVolume(app->codec_task, app->speaker_volume.av_volume);

    /* app->led_state |= LED_STREAMING; */
	app->led_state |= LED_CONNECTED;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -