META_MELODY_cb.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:9k
源码类别:

MTK

开发平台:

C++ Builder

  1. /*****************************************************************************
  2. *  Copyright Statement:
  3. *  --------------------
  4. *  This software is protected by Copyright and the information contained
  5. *  herein is confidential. The software may not be copied and the information
  6. *  contained herein may not be used or disclosed except with the written
  7. *  permission of MediaTek Inc. (C) 2005
  8. *
  9. *  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  10. *  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  11. *  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
  12. *  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  13. *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  14. *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  15. *  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  16. *  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  17. *  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
  18. *  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
  19. *  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
  20. *  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
  21. *
  22. *  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
  23. *  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  24. *  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  25. *  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
  26. *  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
  27. *
  28. *  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
  29. *  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
  30. *  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
  31. *  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
  32. *  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
  33. *
  34. *****************************************************************************/
  35. /*****************************************************************************
  36.  *
  37.  * Filename:
  38.  * ---------
  39.  *   META_Melody_cb.cpp
  40.  *
  41.  * Project:
  42.  * --------
  43.  *   Maui META APP
  44.  *
  45.  * Description:
  46.  * ------------
  47.  *   Melody callback source
  48.  *
  49.  * Author:
  50.  * -------
  51.  *  Andy Ueng (mtk00490)
  52.  *
  53.  *============================================================================
  54.  *             HISTORY
  55.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  56.  *------------------------------------------------------------------------------
  57.  * $Revision$
  58.  * $Modtime$
  59.  * $Log$
  60.  * 
  61.  *------------------------------------------------------------------------------
  62.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  63.  *============================================================================
  64.  ****************************************************************************/
  65. #include <windows.h>
  66. #pragma hdrstop
  67. #include "meta.h"
  68. #include "meta_msg.h"
  69. #include "META_MELODY_cb.h"
  70. #include "form_Melody.h"
  71. //------------------------------------------------------------------------------
  72. extern TfrmMelody *frmMelody;
  73. extern HANDLE hForm_PostMsgTarget;
  74. //------------------------------------------------------------------------------
  75. //Midi Call back function
  76. //------------------------------------------------------------------------------
  77.    void l1sp_headset_ind_cb( BOOL bInsert )
  78.    {
  79. //        META_LAB_MainForm->i_CB_Msg_id = eL1SP_HEADSET_IND;
  80.        PostMessage(
  81.                      hForm_PostMsgTarget,
  82.                      WM_L1SP_HEADSET_IND,
  83.                      bInsert,    // unsigned short -> unsigned int
  84.                      bInsert    // int -> long
  85.                    );
  86. //        META_LAB_MainForm->l1sp_headset_insert = bInsert;
  87.    }
  88. //------------------------------------------------------------------------------
  89. // marked by Andy Ueng
  90. //  void  midi_download_cb( FdmWriteMelody_Cnf *cnf )
  91. //  {
  92. ////     META_LAB_MainForm->i_CB_Msg_id = eMIDI_DOWNLOAD;
  93. //       PostMessage(
  94. //                     hForm_PostMsgTarget,
  95. //                     WM_MIDI_DOWNLOAD,
  96. //                     cnf->status,    // unsigned short -> unsigned int
  97. //                     0    // int -> long
  98. //                   );
  99. //
  100. //  }
  101. // end of marked
  102. //------------------------------------------------------------------------------
  103. // modified by Andy Ueng
  104.   // void midi_play_cnf_cb( FT_MELODY_PLAY_CNF *cnf)
  105.    void __stdcall melody_play_cnf_cb( const FT_MELODY_PLAY_CNF *cnf, short token, void *usrData)
  106.    // end of added
  107.    {
  108.       // modified by Andy Ueng
  109.      // if ( cnf->ok != 0)
  110.      if ( cnf.status == STATUS_MELODY_PLAY_SUCCESS)
  111.      // end of modified
  112.       {
  113.        frmMelody->sb_L1sp->Panels->Items[0]->Text = (AnsiString) "  Play Melody successfully";
  114.        frmMelody->sb_L1sp->Panels->Items[1]->Text = (AnsiString) "";
  115. //        META_LAB_MainForm->i_CB_Msg_id = eMIDI_PLAY_CNF;
  116.          // PostMessage(
  117.          //              hForm_PostMsgTarget,
  118.          //              WM_MIDI_PLAY_CNF,
  119.          //              0,    // unsigned short -> unsigned int
  120.          //            //  cnf->ok    // int -> long // modified by Andy Ueng
  121.          //            cnf.status
  122.          //          );
  123.       } else
  124.       {
  125.         Application->MessageBox( "Play Melody Failure", "FAILURE", MB_OK );
  126.         frmMelody->btnPlayMelody->Enabled = true;
  127.         frmMelody->btnStopPlayMelody->Enabled = false;
  128. //        META_LAB_MainForm->i_CB_Msg_id = eMIDI_PLAY_FAIL;
  129.         //  PostMessage(
  130.         //               hForm_PostMsgTarget,
  131.         //               WM_MIDI_PLAY_FAIL,
  132.         //               0,    // unsigned short -> unsigned int
  133.         //               cnf.status    // int -> long
  134.         //           );
  135.       }
  136.    }
  137. //------------------------------------------------------------------------------
  138.   // modified by Andy Ueng
  139. //   void midi_play_over_ind_cb()
  140.  void __stdcall melody_play_over_ind_cb(const short token, void *usrData)
  141.  // end of modified
  142.    {
  143.     // static unsigned char melody_play_times = 0;
  144.     // melody_play_times++;
  145.     // if(melody_play_times == frmMelody->repeats)
  146.        {
  147.         frmMelody->sb_L1sp->Panels->Items[0]->Text = (AnsiString) "  play Melody finish";
  148.         frmMelody->sb_L1sp->Panels->Items[1]->Text = (AnsiString) "";
  149.         frmMelody->btnPlayMelody->Enabled = true;
  150.         frmMelody->btnStopPlayMelody->Enabled = false;
  151.        }
  152.    //  else
  153.    //    {
  154.    //     char buf[20];
  155.    //     sprintf(buf, "%d times", melody_play_times);
  156.    //     frmMelody->sb_L1sp->Panels->Items[0]->Text = "  playing Melody";
  157.    //     frmMelody->sb_L1sp->Panels->Items[1]->Text = buf;
  158.    //    }
  159.         //  PostMessage(
  160.         //               hForm_PostMsgTarget,
  161.         //               WM_MIDI_PLAY_OVER,
  162.         //               0,    // unsigned short -> unsigned int
  163.         //               0    // int -> long
  164.         //           );
  165.    }
  166. //------------------------------------------------------------------------------
  167. // marked by Andy Ueng
  168. //  void midi_info_cnf_cb( MelodyInformation *cnf  )
  169. //  {
  170. ////       META_LAB_MainForm->i_CB_Msg_id  =  eMIDI_INFO;
  171. //          PostMessage(
  172. //                       hForm_PostMsgTarget,
  173. //                       WM_MIDI_INFO,
  174. //                       cnf->recordNum,    // unsigned char -> unsigned int
  175. //                       (long) &(cnf->record)    // int -> long
  176. //                   );
  177. //
  178. //
  179. //  }
  180. // end of marked
  181. //------------------------------------------------------------------------------
  182. void __stdcall melody_stop_cnf_cb( const FT_MELODY_STOP_CNF *cnf, const short token, void *usrData)
  183.    {
  184.       // modified by Andy Ueng
  185.      // if ( cnf->ok != 0)
  186.      if ( cnf.status == STATUS_IMELODY_STOP_SUCCESS)
  187.      // end of modified
  188.       {
  189.         frmMelody->sb_L1sp->Panels->Items[0]->Text = "  Stop play Melody successfully";
  190.         frmMelody->sb_L1sp->Panels->Items[1]->Text = "";
  191.         frmMelody->btnPlayMelody->Enabled = true;
  192.         frmMelody->btnStopPlayMelody->Enabled = false;
  193. //        META_LAB_MainForm->i_CB_Msg_id = eMIDI_PLAY_CNF;
  194.         //  PostMessage(
  195.         //               hForm_PostMsgTarget,
  196.         //               WM_IMELODY_STOP_CNF,
  197.         //               0,    // unsigned short -> unsigned int
  198.         //             //  cnf->ok    // int -> long // modified by Andy Ueng
  199.         //             cnf.status
  200.         //           );
  201.       } else
  202.       {
  203.       Application->MessageBox( "Stop play Melody Failure", "FAILURE", MB_OK );
  204.         frmMelody->sb_L1sp->Panels->Items[0]->Text = "  Stop play Melody fail";
  205.         frmMelody->sb_L1sp->Panels->Items[1]->Text = "";
  206.         frmMelody->btnPlayMelody->Enabled = true;
  207.         frmMelody->btnStopPlayMelody->Enabled = false;
  208. //        META_LAB_MainForm->i_CB_Msg_id = eMIDI_PLAY_FAIL;
  209.          // PostMessage(
  210.          //              hForm_PostMsgTarget,
  211.          //              WM_IMELODY_STOP_FAIL,
  212.          //              0,    // unsigned short -> unsigned int
  213.          //             // cnf->ok    // int -> long // modified by Andy Ueng
  214.          //             cnf.status
  215.         //           );
  216.       }
  217.    }