qcc51xx如何配置spdif输入

发布于:2024-06-01 ⋅ 阅读:(75) ⋅ 点赞:(0)

 qcc51xx如何配置spdif输入

/*
Copyright (c) 2005 - 2018 Qualcomm Technologies International, Ltd.
*/
/**
\file
\ingroup sink_app
\brief
    This file handles all Synchronous connection messages

*/


/****************************************************************************
    Header files
*/
#ifdef ENABLE_GAA
#include <sink2gaa.h>
#endif /* ENABLE_GAA */
#include "sink_private_data.h"
#include "sink_main_task.h"
#include "sink_audio.h"
#include "sink_hfp_data.h"
#include "sink_statemanager.h"
#include "sink_powermanager.h"
#include "sink_pio.h"
#include "sink_link_policy.h"
#include "sink_tones.h"
#include "sink_volume.h"
#include "sink_speech_recognition.h"
#include "sink_wired.h"
#include "sink_display.h"
#include "sink_audio_routing.h"
#include "sink_peer.h"
#include "sink_swat.h"
#include "sink_ba.h"
#include "sink_ba_broadcaster.h"
#include "sink_ble.h"
#include "sink_callmanager.h"
#include "sink_malloc_debug.h"
#include "sink_usb.h"

#include <audio_plugin_voice_variants.h>
#include <audio_plugin_output_variants.h>
#include <connection.h>
#include <hfp.h>
#include <stdlib.h>
#include <audio.h>
#include <audio_plugin_if.h>
#include <sink.h>
#include <bdaddr.h>
#include <inquiry.h>
#include "sink_sc.h"
#include "sink_gaia.h"

/* Audio params used for second SCO */
const hfp_audio_params multipoint_params = {8000, 7, sync_air_coding_cvsd, sync_retx_power_usage};

#define ALLOWANCE_FOR_TRANSITION_IN_HFP_CALL_STATE        1000

#ifdef DEBUG_AUDIO

#define AUD_DEBUG(x) DEBUG(x)
#else
#define AUD_DEBUG(x)
#endif

/****************************************************************************
NAME
    audioPriorLatency

DESCRIPTION
    Return initial latency estimate for given endpoint codec

RETURNS
    Predicted latency in milliseconds
*/
uint16 audioPriorLatency(uint8 seid)
{
 
    uint16 latency_ms;

#if defined ENABLE_PEER && defined PEER_TWS
    if (peerIsThisDeviceTwsSlave())
    {
 
        /* TWS Master will send time-to-play values when it relays, hence target latency on slave should be zero */
        latency_ms = AUDIO_LATENCY_TWS_NULL;
    }
    else
#endif /* defined ENABLE_PEER && defined PEER_TWS */
    {
 
        switch (seid & BASE_SEID_MASK)
        {
 
        case FASTSTREAM_SEID:
        case APTX_SPRINT_SEID:
        case APTX_LL_SEID:
            latency_ms = AUDIO_LATENCY_SHORT_MS;
            break;

        case APTXHD_SEID:
            latency_ms = AUDIO_LATENCY_LONG_MS;
            break;

        case AAC_SEID:
            /* Use the same latency for AAC regardless of whether we are in TWS or non-TWS use case
              * This will only work if the AAC decoder is capable of latency this high in non-TWS cases
              */
            latency_ms = AUDIO_LATENCY_AAC_MS;
            break;

        case APTX_SEID:
            latency_ms = AUDIO_LATENCY_APTX_MS;
            break;

        case SBC_SEID:
            latency_ms = AUDIO_LATENCY_SBC_MS;
            break;

        case MP3_SEID:
            latency_ms = AUDIO_LATENCY_MP3_MS;
            break;

        default:
            latency_ms = AUDIO_LATENCY_NORMAL_MS;
            break;
        }
    }

    AUD_DEBUG(("AUD: seid=%u latency=%u\n", seid, latency_ms));
    return latency_ms;
}
/****************************************************************************
NAME
    getScoPriorityFromHfpPriority

DESCRIPTION
    obtain the current sco priority level of the AG priority passed in

RETURNS
    current sco priority level, if any, may not have a sco
*/
audio_priority getScoPriorityFromHfpPriority(hfp_link_priority priority)
{
 
    AUD_DEBUG(("AUD: GetScoPriority - %d=%d\n",priority,sinkHfpDataGetScoPriority(PROFILE_INDEX(OTHER_PROFILE(priority))))) ;
    return sinkHfpDataGetScoPriority(PROFILE_INDEX(OTHER_PROFILE(priority)));
}

/****************************************************************************
NAME
    setScoPriorityFromHfpPriority

DESCRIPTION
    sets the current sco priority level of the AG priority passed in

RETURNS
    nothing
*/
void setScoPriorityFromHfpPriority(hfp_link_priority priority, audio_priority level)
{
 
    AUD_DEBUG(("AUD: SetScoPriority - %d=%d\n",priority,level)) ;
    if(priority != hfp_invalid_link)
      sinkHfpDataSetScoPriority(level,PROFILE_INDEX(OTHER_PROFILE(priority)));
}


/****************************************************************************
NAME
    audioGetLinkPriority

DESCRIPTION
    Common method of getting the link we want to manipulate audio settings on

RETURNS

*/
hfp_link_priority audioGetLinkPriority ( bool audio )
{
 
    hfp_link_priority priority;

    /* See if we can get a link from the device audio sink... */
    priority = HfpLinkPriorityFromAudioSink(sinkAudioGetRoutedVoiceSink());

    /* if the call is in outgoing call state */
    if(!priority)
        priority = HfpLinkPriorityFromCallState(hfp_call_state_outgoing);

    /* If that fails see if we have an active call... */
    if(priority == hfp_invalid_link)
        priority = HfpLinkPriorityWithActiveCall(audio);

    /* if there is an incoming call [get first incoming] */
    if(priority == hfp_invalid_link)
        priority = HfpGetFirstIncomingCallPriority();

    /* If we got something return it, otherwise return primary link */
    return ((priority != hfp_invalid_link) ? priority : hfp_primary_link);
}

/****************************************************************************
NAME
    audioSwapMediaChannel

DESCRIPTION
    attempt to swap between media channels if two channels exist and one of them
    is currentyl being routed to the speaker.
RETURNS
    successful or not status
*/
bool audioSwapMediaChannel(void)
{
 
    a2dp_stream_state a2dpStatePri = a2dp_stream_idle;
    a2dp_stream_state a2dpStateSec = a2dp_stream_idle;
    Sink a2dpSinkPri = 0;
    Sink a2dpSinkSec = 0;

    /* 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);

    /* check whether a2dp pri is currently being routed and a2dp sec is available */
    if((sinkAudioGetRoutedAudioSink() == a2dpSinkPri)&&(a2dpSinkSec)&&(a2dpStateSec == a2dp_stream_streaming))
    {
 
        /* swap to a2dp secondary */
        audioDisconnectRoutedAudio();
        audioRouteSpecificA2dpSource(audio_source_a2dp_2);
        return TRUE;
    }
    /* check whether a2dp sec is currently being routed and swap to a2dp pri */
    else if((sinkAudioGetRoutedAudioSink() == a2dpSinkSec)&&(a2dpSinkPri)&&(a2dpStatePri == a2dp_stream_streaming))
    {
 
        audioDisconnectRoutedAudio();
        audioRouteSpecificA2dpSource(audio_source_a2dp_1);
        return TRUE;
    }
    /* not possible to swap media channels */
    return FALSE;
}

/****************************************************************************
NAME
    audioShutDownForUpgrade

DESCRIPTION
    Disconnects any routed voice/audio sources and once the audio busy 
    pointer is cleared, messages sink_upgrade to proceed

RETURNS
    void
*/
void audioShutDownForUpgrade(Task task, MessageId id)
{
 
    audioDisconnectRoutedVoice();
    audioSuspendDisconnectAudioSource();

    MessageSendConditionallyOnTask(task, id, NULL, AudioBusyPtr());
}

/****************************************************************************
NAME
    audioGetSettings


网站公告

今日签到

点亮在社区的每一天
去签到

热门文章