am_tone_sequence_handler.cc
来自「Motorola synergy audio component」· CC 代码 · 共 735 行 · 第 1/2 页
CC
735 行
/* (c) Copyright Motorola 1996 - 2004 All rights reserved. Motorola Confidential Proprietary Contains confidential proprietary information of Motorola, Inc. Reverse engineering is prohibited. The copyright notice does not imply publication. DESCRIPTION: This file deals with setting the correct instruction mask and hardware parameters to be sent to the hw layer *************** REVISION HISTORY ********************************************* Date Author Reference ======== ======== ========================== 2004-08-18 w18944 CR - LIBee26692 Make CTG powerdown tone have lower priority 2004-11-05 w17860 LIBff24932 P4.4 Feature # 12583 Memory Reduction - Remove Voice Dial and Voice Tag 2004-06-29 w16355 CR - LIBdd80946 PTT updates. 2004-06-09 w17860 CR - LIBee10733 Audio codec enabled all the time even when there is no audio - Ensured the audio codec is turned off after playing tone in silent and vibrate profiles. 2004-05-10 w17860 LIBee08172 Make a seperate tone request for MFT Vib from MME 02/23/2004 w18944 CR - LIBdd72710 WAV UI sounds 01/29/2004 w18944 CR - LIBdd69286 Alert ramp up 08/28/2003 rnistala CR - LIBdd33145 Added a new find function that takes only the tone type as input. 02-05-13 w17860 CR - LIBbb32471 ST::WAP Download:0 Playing melodie while reading SMS resets melodie - Alerts are given higher priority than keypress and UI tones 01-12-20 ktang CR - LIBbb13753 Audio Media Request Redirection 00-08-14 ktang CR - CSGce68045 Analog Network DTMF fixes - Added data field Uplink to the class, and overloaded function Push so passing Uplink as to it is supported 00-06-19 Bill Choi CR 66394 Add sequence id support for tones Holmes Chuang *//************** INCLUDES ******************************************************/#include <SUAPI/suapi.h>#include <ENGINE_AUDIO/audio_conditional_compile_def.h>#include <audio/AM_Tone_Sequence_Handler.H>#include <SYNERGY_DEVICE_LAYER/dl_audio_auf.h>#include <ENGINE_AUDIO/am_c_utilities.h>extern "C"{void main_powerdown ();};// ==============================================================================// Constructor to initialize the class//// ==============================================================================Tone_Item::Tone_Item(){ Init();}// ==============================================================================// initialize the class//// ==============================================================================void Tone_Item::Init(){ ToneEvent.type = DL_AUDIO_TONE_TYPE_INVALID_TONE; Path = AM_AUDIO_PATH_ID_INVALID_TONE; Priority = AM_AUDIO_PRIORITY_INVALID; SequenceID = 0; DSPSequenceID = 0; VolumeStep = INVALID_VOLUME_STEP; VibrateType = DL_AUDIO_TONE_TYPE_INVALID_TONE; Uplink = FALSE; SamplingRate = AM_SAMPLING_RATE_08_00; Used = FALSE; Next = NULL; Prev = NULL; AppliedVol = INVALID_VOLUME_STEP; status = AM_TONE_INIT;}// ==============================================================================// Declaration of EventQueueHandler//// ==============================================================================Event_Queue_Handler eventqueuehandler;// ==============================================================================// Constructor of Event_Queue_Handler// Initialize variables//// ==============================================================================Event_Queue_Handler::Event_Queue_Handler(){ Head = NULL; Current_DSP_Sequence_ID = 0;}// ==============================================================================// Destructor of Event_Queue_Handler// does nothing...//// ==============================================================================Event_Queue_Handler::~Event_Queue_Handler(){}// ==============================================================================// Push the item onto the queue.// this is a priority queue. Lowest to Highest is the order// if the priority of the queue item is the same it goes last in last out.// // for example if I want to insert a tone with priority 3// and my current queue priority looks like this...// // \/ <- I would insert it here...// 1,1,1,1,2,2,2,2,3,3,3,3,4,5,6,7,8.// ==============================================================================BOOL Event_Queue_Handler::Push(TD_AUD_TONE_REQ_TONE_TYPE_T tone_event, AM_AUDIO_PATH_TYPE path){ TD_AUD_TONE_UNION_T tone; tone.type = tone_event; TD_AUD_MEDIA_INFO_T mediaInfo = {NULL, INVALID_SEQ_NUMBER}; return (Push(tone, path, INVALID_SEQ_NUMBER, INVALID_VOLUME_STEP, DL_AUDIO_TONE_TYPE_INVALID_TONE, FALSE, mediaInfo, INVALID_VOLUME_STEP, AM_SAMPLING_RATE_08_00));}BOOL Event_Queue_Handler::Push(TD_AUD_TONE_UNION_T tone_event, AM_AUDIO_PATH_TYPE path, TD_AUD_TONE_SEQUENCE_NUMBER_T seq, TD_AUD_VOLUME_SETTING_T vol_step, TD_AUD_TONE_REQ_TONE_TYPE_T vibtype, TD_AUD_TONE_UPLINK_T uplink, TD_AUD_MEDIA_INFO_T mediaInfo, UINT8 applied_vol, TD_AM_SAMPLING_RATE_T samplingrate) { Tone_Item *current = NULL; current = FindFreeItem(); BOOL Success = FALSE; if(current != NULL && ((tone_event.fields.id >= DL_AUDIO_TONE_TYPE_UI_LITE_ID_LIMIT && tone_event.fields.id < DL_AUDIO_TONE_TYPE_KEY_LITE_ID_LIMIT) || FindItem(tone_event.type, seq) == NULL)) { current->SequenceID = seq; current->ToneEvent = tone_event; current->Path = path; current->DSPSequenceID = GenerateDSP_SequenceNumber(); current->VolumeStep = vol_step; current->VibrateType = vibtype; current->Uplink = uplink; current->MediaInfo = mediaInfo; current->SamplingRate = samplingrate; current->AppliedVol = applied_vol; current->status = AM_TONE_START; current->Priority = GetPriority(current); Insert(current); Success = TRUE; } // Are we about to process PTT audio? if ( tone_event.fields.id == DL_AUDIO_TONE_TYPE_MULTIMEDIA_PTT ) { // Until we stop the PTT tone type, we are in a push to talk session. // When in speakerphone mode for PTT, we must route all tones to the // internal speakerphone. We cannot check for the PTT tone since we // we will process other tones during a PTT session. // Therefore, we use a boolean that is true from the start request // until the stop request to indicate that we are in a PTT session, // so that we can correctly route tones for PTT. am_set_ptt_session_state( TRUE ); } return Success;}// ==============================================================================// Generates a unique DSP sequence number to match the one that the // Device Layer sends us. We are reusing the time stamp which is only// one byte long, so we need to manage this ourselves.// ==============================================================================UINT8 Event_Queue_Handler::GenerateDSP_SequenceNumber(){ ++Current_DSP_Sequence_ID; if(Current_DSP_Sequence_ID == 0) { ++Current_DSP_Sequence_ID; } return Current_DSP_Sequence_ID;}// ==============================================================================// Find an item in our array to use. // ==============================================================================Tone_Item * Event_Queue_Handler::FindFreeItem(){ for(int i = 0 ; i < MAX_TONE_SEQUENCE_HANDLER_SIZE; i++) { if(!Pool[i].Used) { return &Pool[i]; } }// main_powerdown(); //help we ran out of space...... return NULL;}// ==============================================================================// Reorders the HiFi item that got suspended by AM, for LoFi audio to play.// We will just move the item to underneath the LoFi audio in the Q.// ==============================================================================void Event_Queue_Handler::RenewItem(Tone_Item *item){ // if item is NULL, invalid request if (item != NULL) { // if item->Next is NULL, whats the point... if(item->Next != NULL) { Tone_Item* up = item; Tone_Item* down = item->Next; // First, find the right place where we want to reposition this item // for simplicity, we re-insert this item at the bottom of those of // the same priority. while (down != NULL && down->Priority <= item->Priority) { up = down; down = down->Next; } if (up != item) { // First, take item out of the double link list Detach(item); // Now we need to insert item to underneath 'up' item->Next = down; up->Next = item; item->Prev = up; if (down != NULL) { down->Prev = item; } } } UpdateStatus(item, AM_TONE_PAUSE); } }// ==============================================================================// Insert hte item according to its priority// ==============================================================================void Event_Queue_Handler::Insert(Tone_Item *item){ item->Used = TRUE; if(Head == NULL) { Head = item; Head->Next = NULL; Head->Prev = NULL; } else { Tone_Item *current = Head; while(current != NULL) { /* Queue UI tones, Stack other tones. This way UI tones don't get interrupted as often */ if( ((item->Priority <= current->Priority) && (item->Priority != AM_AUDIO_PRIORITY_UI_IND)) || (item->Priority < current->Priority) ) { if ( (current->status == AM_TONE_PLAY) && ((current->SamplingRate != AM_SAMPLING_RATE_08_00 && item->SamplingRate == AM_SAMPLING_RATE_08_00) || (current->SamplingRate == AM_SAMPLING_RATE_08_00 && item->SamplingRate != AM_SAMPLING_RATE_08_00)) ) { if (item->ToneEvent.fields.id == DL_AUDIO_TONE_TYPE_MULTIMEDIA_LO_FI && current->ToneEvent.fields.id == DL_AUDIO_TONE_TYPE_MULTIMEDIA_MIDI) { item->SamplingRate = current->SamplingRate; } else { MME_RESM_AM_Tone_Indication(current->ToneEvent.fields.id, MME_RESM_AUD_PAUSE); if(current->Next == NULL) { current->Next = item; item->Prev = current; item->Next = NULL; current = current->Next; } current = current->Next; continue; } } if(current == Head) { item->Next = Head; Head->Prev = item; item->Prev = NULL; Head = item; } else { item->Next = current; current->Prev->Next = item; item->Prev = current->Prev; current->Prev = item; } current = NULL; // exit out of the loop } else { if(current->Next == NULL) {
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?