⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sndplayer.c

📁 The combined demo is dedicated for S1C33L05, so DMT33L05 should be used to load and run the demo. F
💻 C
字号:
//--------------------------------------------------------------------------------- 
//
//      Copyright (C) SEIKO EPSON CORP. 2004 
//
//      GROUP					: SEE LSI
//      FILE                    : sndplayer.c
//      MODULE                  : g723.1 player
//      Function description    : application 
//      Revision history        :                                                                                               
//                                Date            userName        	Description
//                                2004/06/7       David.Ji		      	start
//
//      Notes                   : 
//
//---------------------------------------------------------------------------------
//---------------------------------------------------------------------------------
// Include files (#include)
//---------------------------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ros33.h"
#include "sysGUI.h"
#include "appres.h"
#include "main.h"
#include "comFS.h"
#include "g723adec.h"


#define LCLG_dt5              0x84
#define LCLG_dt2              0x81

//---------------------------------------------------------------------------------
// Marco definition
//---------------------------------------------------------------------------------
#define IDC_TOOLBAR   100
#define IDC_LISTBOX   110

#define IDC_BAR       502
#define IDC_BAR_PLAY  503
#define	IDC_BAR_PAUSE 504
#define	IDC_BAR_STOP  505
#define	IDC_BAR_FRWD  506
#define	IDC_BAR_BKWD  507
#define	IDC_BAR_EXIT  508	  
  
#define	BARITEM       6


T_UBYTE* gSpkParams; 

T_MODULE T_WORD Snd_FreeRes();
T_MODULE T_WORD Snd_InitRes();

/******************************************************************
 * FUNCTION: SndPlayerWinProc(
 *
 * PURPOSE:
 *		disk manager win proc
 *
 * PARAMETERS
 *    Input:
 *    Output:
 *    InOut:
 *
 * Return value:
 *
 * Reentrant : No
*****************************************************************/
T_FS_FILECTL stFileCtl;
T_UBYTE ubPlayerStatus;

T_BYTE* pButtonSnd[BARITEM];

T_WORD SndplayerWinProc(T_GUI_HWND hWnd, T_WORD message, T_GUI_WPARAM wParam, T_GUI_LPARAM lParam)
{
	T_MODULE T_GUI_HWND hChildWnd1, hChildWnd2;

	T_MODULE T_FS_FILELIST stFileEntry;

	T_MODULE T_GUI_ToolBarItemInfo  pData;
	T_MODULE T_GUI_Bitmap *pButtonBmptmp[BARITEM];
	
	T_MODULE T_GUI_HICON hIcon;
	T_MODULE T_BYTE *pIconBuf;
	
	T_MODULE T_BYTE InitRes = 0;
	T_MODULE T_WORD OldSel, CurSel;
	
	T_BYTE tempString[20];

    switch (message)
    {
		case MSG_CREATE:
		{
		T_GUI_HDC hdc;
		T_WORD i; 		
		T_GUI_ListBoxItemInfo  lbii;

		hdc = fnGUI_BeginPaint(hWnd);
		hChildWnd1 = fnGUI_CreateWindow (CTRL_TOOLBAR,
		                                 "",
                        				 WS_CHILD | WS_VISIBLE,
                                         IDC_TOOLBAR,
                                         3, 5, 170, 50, hWnd, 0);
        
        if(Snd_InitRes() != 1)
        {
        	for(i =0; i<BARITEM; i++)	
        		pButtonSnd[i]=(T_BYTE*)pSysButton;
        }
        else	
        	InitRes = 1;
        
        for(i=0;i<BARITEM;i++)
        {

        	pButtonBmptmp[i] = (T_GUI_Bitmap *) calloc(1,sizeof(T_GUI_Bitmap));
        	pData.InsPos = i+1;
            pData.id = IDC_BAR+i+1;
            pData.ItemType = TYPE_BMPITEM ;
               
            fnGUI_LoadBitmapFromBmpMemory(hdc,pButtonBmptmp[i],pButtonSnd[i]);
		
            pData.Bmp = pButtonBmptmp[i];
            pData.ItemHint = NULL;
            pData.Caption = NULL ;
            pData.dwAddData = 0 ;

            fnGUI_SendMessage(hChildWnd1,MSG_TB_ADDITEM,0, (T_GUI_LPARAM)&pData);
        }
        
        /* show snd file */
        hChildWnd2 = fnGUI_CreateWindow (CTRL_LISTBOX,
              							 "Listbox",
                                         WS_VISIBLE | WS_BORDER | STY_LB_NOTIFY 
			                             | STY_LB_USEICON | WS_VSCROLL,
                                         IDC_LISTBOX,
                                         3, 30, 170, 90, hWnd, 0);
		
		pIconBuf = (T_BYTE *)ComFS_Loadfile("system\\sndlist.ico");
			
		if(pIconBuf == 0)
				hIcon = fnGUI_LoadIconFromMemory(hdc,pSysIcon, 1);
		else
				hIcon = fnGUI_LoadIconFromMemory(hdc,(T_CONST T_BYTE *)pIconBuf, 0);
		
		if(ComFS_GetFilelist("voice\\*.*", (_A_NORMAL ), &stFileEntry) != FS_SUCCESS)
		{
			fnGUI_EndPaint(hWnd,hdc);
			break;
		}	
		
		for(i = 0; i< stFileEntry.usFileCnt; i++){
			lbii.CMFlag = FLAG_CM_BLANK;
			lbii.string = stFileEntry.stFilelist[i].name;
			lbii.hIcon = hIcon;
			fnGUI_SendMessage (	hChildWnd2,	MSG_LB_ADDSTRING, 0, (T_GUI_LPARAM)&lbii);
		}
		
		fnGUI_EndPaint(hWnd,hdc);
		
		fnGUI_SendMessage(hChildWnd2, MSG_LB_SETCURSEL, (T_GUI_WPARAM)0, 0);
		
		/* internal ram cache */
  		g723aDecodeCopy();
  		gSpkParams = 0L;
  		ubPlayerStatus = PY_IDLE;
  		
  		OldSel=CurSel=0;
  		
  		//optimize resource
		fnGuiTM_Stop();
		seLcd_ChgCLK(LCLG_dt5);
		}
		break;
		
    	case MSG_PAINT:
		break;
    	
        case MSG_COMMAND:
        {
        	T_WORD code = LOHWORD(wParam);
            T_WORD id = HIHWORD(wParam);
 
            switch (id)
            {
                case IDC_BAR_PLAY:
                {
                	if(CurSel == -1)
                		break;
                	
                	if((ubPlayerStatus == PY_PAUSE) && (OldSel == CurSel))
                	{
                		Demog723Continue();
                		ubPlayerStatus = PY_PLAY;
                		break;
                	}
                	
                	if(( ubPlayerStatus == PY_PLAY ) && (OldSel != CurSel))
                	{
                		Demog723Stop();
                		free(stFileCtl.pFileData);
                	}
                	
                	sprintf(tempString,"voice\\%s",stFileEntry.stFilelist[CurSel].name);	
                	stFileCtl.pFileData = ComFS_Loadfile(tempString);
                	
					if(stFileCtl.pFileData == 0L)
						break;
					

                	Demog723Play( stFileCtl.pFileData);
                	ubPlayerStatus = PY_PLAY;
                	OldSel = CurSel;
				
				}
                break;

                case IDC_BAR_PAUSE:
                {
                	if(ubPlayerStatus == PY_PLAY)
                	{
                		Demog723Pause();
                		ubPlayerStatus = PY_PAUSE;
                	}
                }
                break;
                
                case  IDC_BAR_STOP :
                	if( ubPlayerStatus != PY_IDLE )
                	{
                		Demog723Stop();
                		free(stFileCtl.pFileData);
                		ubPlayerStatus == PY_IDLE;
                	}
                break;
                
                case IDC_BAR_FRWD:
                {
                	CurSel ++;
                	if(CurSel > stFileEntry.usFileCnt)
                		CurSel = 0;
                	fnGUI_SendMessage(hChildWnd2, MSG_LB_SETCURSEL, (T_GUI_WPARAM)CurSel, 0);
                		
                }
                break;

				case IDC_BAR_BKWD:
				{
					CurSel --;
                	if(CurSel == -1)
                		CurSel = stFileEntry.usFileCnt;
                	fnGUI_SendMessage(hChildWnd2, MSG_LB_SETCURSEL, (T_GUI_WPARAM)CurSel, 0);
				}
                break;
                
                case IDC_BAR_EXIT:
                	if( ubPlayerStatus == PY_PLAY )
                	{
                		Demog723Stop();
                		free(stFileCtl.pFileData);
                		ubPlayerStatus == PY_IDLE;
                	}
                	//free resource
					fnGuiTM_Start();
					seLcd_ChgCLK(LCLG_dt2);
						
                	fnGUI_PostMessage (hWnd, MSG_CLOSE, 0, 0);
                break;
           }
           
           /* check listbox item message */
           /* note, code&id exchanged    */
           if((code == IDC_LISTBOX) && (id == SIG_LB_CLICKED))
           {
		       	T_WORD tempSel;
		       	tempSel = fnGUI_SendMessage (hChildWnd2, MSG_LB_GETCURSEL, 0, 0);
		       	if(tempSel != CurSel)
		       		OldSel = CurSel;
		       	CurSel = tempSel;
		   }
        }
        break ;
        
        case MSG_TIMER:
		break;
			
        case MSG_CLOSE:
        {
        		T_WORD i;
        		
				fnGUI_DestroyIcon (hIcon);
	    		free(pIconBuf); 
	    		if(InitRes = 1)
	    		{
        			Snd_FreeRes();	
        			InitRes = 0;
        		}
        		for(i =0; i<BARITEM; i++)
        		{
	        		fnGUI_UnLoadBitmap(pButtonBmptmp[i]);	
	    		}
        	    fnGUI_DestroyMainWindow (hChildWnd1 );
        	    fnGUI_DestroyMainWindow (hChildWnd2);
        		fnGUI_DestroyMainWindow (hWnd );
        }
        break;
    }

    return fnGUI_DefaultMainWinProc(hWnd, message, wParam, lParam);
}

/******************************************************************
 * FUNCTION: Snd_InitRes()
 *
 * PURPOSE:
 *
 * PARAMETERS
 * Return value:
*****************************************************************/
T_MODULE T_WORD Snd_InitRes()
{
		T_BYTE *pBmpBuf;
        
        pBmpBuf = (char *)ComFS_Loadfile("system\\sndplay.bmp");
        if(pBmpBuf == 0)
        	return -1;
        pButtonSnd[0] = pBmpBuf;
        
        pBmpBuf = (char *)ComFS_Loadfile("system\\sndpause.bmp");
        if(pBmpBuf == 0)
        	return -1;
        pButtonSnd[1] = pBmpBuf;
        
        pBmpBuf = (char *)ComFS_Loadfile("system\\sndstop.bmp");
        if(pBmpBuf == 0)
        	return -1;
        pButtonSnd[2] = pBmpBuf;
        
        pBmpBuf = (char *)ComFS_Loadfile("system\\sndfwd.bmp");
        if(pBmpBuf == 0)
        	return -1;
        pButtonSnd[3] = pBmpBuf;
        
        pBmpBuf = (char *)ComFS_Loadfile("system\\sndback.bmp");
        if(pBmpBuf == 0)
        	return -1;
        pButtonSnd[4] = pBmpBuf;
        
        pBmpBuf = (char *)ComFS_Loadfile("system\\sndexit.bmp");
        if(pBmpBuf == 0)
        	return -1;
        pButtonSnd[5] = pBmpBuf;

		return 1;
	
}

/******************************************************************
 * FUNCTION: Dict_FreeRes()
 *
 * PURPOSE:
 *
 * PARAMETERS
 * Return value:
*****************************************************************/
T_MODULE T_WORD Snd_FreeRes()
{
	T_BYTE i;
	
	for(i=0; i<6; i++)	
		free(pButtonSnd[i]);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -