loud_speaker.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:8k
- /*****************************************************************************
- * Copyright Statement:
- * --------------------
- * This software is protected by Copyright and the information contained
- * herein is confidential. The software may not be copied and the information
- * contained herein may not be used or disclosed except with the written
- * permission of MediaTek Inc. (C) 2005
- *
- * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
- * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
- * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
- * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
- * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
- * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
- * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
- * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
- * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
- * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
- *
- * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
- * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
- * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
- * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
- * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
- *
- * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
- * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
- * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
- * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
- * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
- *
- *****************************************************************************/
- /*****************************************************************************
- *
- * Filename:
- * ---------
- * loud_speaker.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * Loud speaker audio test source
- *
- * Author:
- * -------
- * Andy Ueng (mtk00490)
- *
- *============================================================================
- * HISTORY
- * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *------------------------------------------------------------------------------
- * $Revision$
- * $Modtime$
- * $Log$
- *
- *------------------------------------------------------------------------------
- * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *============================================================================
- ****************************************************************************/
- //---------------------------------------------------------------------------
- #include <IniFiles.hpp>
- #pragma hdrstop
- #ifndef _LOUD_SPEAKER_H_
- #include "loud_speaker.h"
- #endif
- #ifndef _MAN_ACTIVE_H_
- #include "man_active.h"
- #endif
- #ifndef _FT_UTILS_H_
- #include "ft_utils.h"
- #endif
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- //===========================================================================
- static CLOUDSPEAKER* g_loud_speaker_ptr;
- static bool g_bIsRunning = false;
- //============================= static function ==============================
- static void Req_Set_Freq_Vol_Tone(void)
- {
- g_loud_speaker_ptr->Req_Set_Freq_Vol_Tone();
- }
- //---------------------------------------------------------------------------
- static void Req_Audio_Stop(void)
- {
- g_loud_speaker_ptr->Req_Audio_Stop();
- }
- //---------------------------------------------------------------------------
- static void __stdcall CNF_AudioStop(const AUDIO_RESULT status, const short token, void *usrData)
- {
- g_loud_speaker_ptr->CNF_AudioStop(status, token, usrData);
- }
- //==============================================================================
- CLOUDSPEAKER::CLOUDSPEAKER(void)
- {
- g_bIsRunning = false;
- ConfirmCallback = NULL;
- }
- //---------------------------------------------------------------------------
- CLOUDSPEAKER::~CLOUDSPEAKER()
- {
- g_bIsRunning = false;
- ConfirmCallback = NULL;
- }
- //---------------------------------------------------------------------------
- void CLOUDSPEAKER::Confirm(E_METAAPP_RESULT_T confirm_state)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- g_bIsRunning = false;
- if (NULL == ConfirmCallback)
- {
- return;
- }
- m_eConfirmState = confirm_state;
- if (m_eConfirmState != METAAPP_SUCCESS)
- {
- META_CancelAllBlockingCall_r(m_META_HANDLE_Obj.Get_MainHandle());
- }
- ActiveMan->SetActiveFunction(ConfirmCallback);
- }
- //==============================================================================
- void CLOUDSPEAKER::Req_Set_Freq_Vol_Tone_Start(Audio_Set_Freq_Vol_Tone_Req_T req)
- {
- g_loud_speaker_ptr = this;
- g_bIsRunning = true;
- m_sFreqVolTone = req;
- ActiveMan->SetActiveFunction(::Req_Set_Freq_Vol_Tone);
- }
- //---------------------------------------------------------------------------
- void CLOUDSPEAKER::Req_Set_Freq_Vol_Tone(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- META_RESULT MetaResult = META_Audio_Play_Freq_Vol_Tone_r(m_META_HANDLE_Obj.Get_MainHandle(), 5000, &m_sFreqVolTone);
- if (MetaResult != META_SUCCESS)
- {
- if (MetaResult != META_TIMEOUT)
- {
- Confirm(METAAPP_FAIL);
- }
- else
- {
- Confirm(METAAPP_TIMEOUT);
- }
- }
- Confirm(METAAPP_SUCCESS);
- }
- //===========================================================================
- void CLOUDSPEAKER::Req_Audio_Stop_Start(void)
- {
- g_loud_speaker_ptr = this;
- g_bIsRunning = true;
- ActiveMan->SetActiveFunction(::Req_Audio_Stop);
- }
- //---------------------------------------------------------------------------
- void CLOUDSPEAKER::Req_Audio_Stop(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- META_RESULT MetaResult = META_Audio_Stop_Freq_Vol_Tone_r(m_META_HANDLE_Obj.Get_MainHandle(), 5000);
- if (MetaResult != META_SUCCESS)
- {
- if (MetaResult != META_TIMEOUT)
- {
- Confirm(METAAPP_FAIL);
- }
- else
- {
- Confirm(METAAPP_TIMEOUT);
- }
- }
- }
- //---------------------------------------------------------------------------
- void __stdcall CLOUDSPEAKER::CNF_AudioStop(const AUDIO_RESULT status, const short token, void *usrData)
- {
- if (status != AUD_RES_OK)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- Confirm(METAAPP_SUCCESS);
- }
- //===========================================================================
- ///////////////////////////// Query ///////////////////////////
- //===========================================================================
- bool CLOUDSPEAKER::Query_Loud_Speaker_Test_Support_Start(void)
- {
- META_RESULT MetaResult = META_QueryIfFunctionSupportedByTarget_r(m_META_HANDLE_Obj.Get_MainHandle(), 300, "META_Audio_Play_Freq_Vol_Tone_r");
- if (MetaResult != META_SUCCESS)
- {
- return false;
- }
- return true;
- }
- //===========================================================================
- //////////////////////////// Global information ///////////////////////////
- //===========================================================================
- E_METAAPP_RESULT_T CLOUDSPEAKER::Get_ConfirmState(void)
- {
- return m_eConfirmState;
- }