?? av_headset_kalimba.c
字號(hào):
/****************************************************************************
Copyright (C) Cambridge Silicon Radio Ltd. 2004
FILE NAME
av_headset_kalimiba.c
DESCRIPTION
NOTES
*/
/****************************************************************************
Header files
*/
#include "av_headset_private.h"
#include "av_headset_kalimba.h"
#include <file.h>
#include <kalimba.h>
#include <kalimba_standard_messages.h>
#include <panic.h>
#include <pcm.h>
#include <stdlib.h>
#include <string.h>
static uint32 GetSampleRateValue(vm_pcm_rate rate)
{
switch (rate)
{
case VM_PCM_RATE_8K: return 8000;
case VM_PCM_RATE_11K025: return 11025;
case VM_PCM_RATE_16K: return 16000;
case VM_PCM_RATE_22K05: return 22050;
case VM_PCM_RATE_24K: return 24000;
case VM_PCM_RATE_32K: return 32000;
case VM_PCM_RATE_44K1: return 44100;
case VM_PCM_RATE_48K: return 48000;
}
return 48000;
}
/* Configure the physical codec depending on the AV codec params negotiated */
static void configureCodec(avTaskData *theAvApp)
{
uint32 sampleRate = GetSampleRateValue(theAvApp->rate);
/* Disconnect anything already connected to PCM slots 0 and 1 */
StreamDisconnect(StreamPcmSource(0), StreamPcmSink(0));
StreamDisconnect(StreamPcmSource(1), StreamPcmSink(1));
/*
Set both ports to external to allow reassigning of internal DACs below.
(A DAC can only be routed to one port at a time!)
*/
(void) PanicFalse(PcmRoute(0, VM_PCM_NONE, PCM_NO_SYNC));
(void) PanicFalse(PcmRoute(1, VM_PCM_NONE, PCM_NO_SYNC));
/* Is it mono playback? */
if (theAvApp->channel_mode == a2dp_mono)
{
/* Mono - Set both DACs to play the output of port 0. */
(void) PanicFalse(PcmRateAndRoute(0, PCM_NO_SYNC, sampleRate, 8000, VM_PCM_INTERNAL_A_AND_B));
}
else
{
/*
Stereo - Configure port 0 and 1 to be left and right channels
and synchronise buffer offsets for stereo playback.
*/
(void) PanicFalse(PcmRateAndRoute(0, PCM_NO_SYNC, sampleRate, 8000, VM_PCM_INTERNAL_A));
(void) PanicFalse(PcmRateAndRoute(1, 0, sampleRate, 8000, VM_PCM_INTERNAL_B));
}
}
/*************************************************************************
NAME
avHeadsetStartKalimba
DESCRIPTION
Initialise Kalimba and routing for SBC encoding
RETURNS
*/
void avHeadsetStartKalimba(avTaskData *theAvApp)
{
/* Configure the DACs for the codec configuration */
configureCodec(theAvApp);
/* Start decode */
A2dpAudioCodecEnable(theAvApp->a2dp, theAvApp->media_sink);
/* Is it mono playback? */
if (theAvApp->channel_mode == a2dp_mono)
{
/* Plug port 0 into both DACs */
(void) StreamConnect(StreamKalimbaSource(0),StreamPcmSink(0));
}
else
{
/* Plug port 0 into Left DAC */
(void)StreamConnect(StreamKalimbaSource(0),StreamPcmSink(0));
/* Plug port 1 into Right DAC */
(void)StreamConnect(StreamKalimbaSource(1),StreamPcmSink(1));
}
/* Start decode */
(void) PanicFalse(KalimbaSendMessage(KALIMBA_MSG_GO,0,0,0,0));
}
/*************************************************************************
NAME
avHeadsetStopKalimba
DESCRIPTION
Stop Kalimba and power it down.
RETURNS
*/
void avHeadsetStopKalimba(const avTaskData *theAvApp)
{
/* Stop decode */
A2dpAudioCodecDisable(theAvApp->a2dp, theAvApp->media_sink);
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -