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

📄 playlist.c

📁 神龙解压卡Linux下的完整开发包,绝对是超值超值超值
💻 C
字号:
/******************************************************************** Copyright (c) 2001 Sigma Designs Inc. All rights reserved. ********************************************************************//**  @file playlist.c @brief Sample C files showing how to use the external API of the CARIBBEAN driver.  This sample shows how to initialise the Caribbean driver, then open an URL and play it.  @date   2001-12-15*/#define ALLOW_OS_CODE #include "rmexternalapi.h"#include <stdio.h>#include <stdlib.h>#include <string.h>#ifndef WIN32#include <unistd.h>#include <setjmp.h>#else#include <Windows.h>#endif#define TOTAL_MEMORY_NEEDED (8*1024*1024)#define MAX_BOARDS 4char play[50][255];int  totPlayCount;int  nowPlaying;int  donePlaying;int  closedstate;int  loopCount;typedef struct {	RMuint32 addr;	RMuint32 val;} ebiPIOAccess_type;jmp_buf g_env;void apidemopaniccallback(RMuint32 reason);void apidemopaniccallback(RMuint32 reason){	longjmp(g_env,(int)reason);}void callback(RMTcontrolInterface ctrl, void *userData, RMmessage message, RMuint32 val);void callback(RMTcontrolInterface ctrl, void *userData, RMmessage message, RMuint32 val){	RMcontrolInterfaceInputType type;	RMTfileControl ctrl_file;	RMTvodControl  ctrl_vod;	if (message == RM_MESSAGE_EOS) { 		fprintf(stderr,"Receive callback Message : EOS\n");		type = RMFGetControlInterfaceInputType(ctrl);		switch (type) {		case RM_INPUT_VOD:                        RMFGetControlHandle((void **) &ctrl_vod, RM_CONTROL_VOD, ctrl);			RMFStopVOD(ctrl_vod);			donePlaying=1;			break;		case RM_INPUT_FILE:                        RMFGetControlHandle((void **) &ctrl_file, RM_CONTROL_FILE, ctrl);			RMFStopFile(ctrl_file);			donePlaying=1;			break;		default:			break;		}	}}int readPlayList(char* FileNamePlayList);int readPlayList(char* FileNamePlayList){   char temp[255];   int count = 0;   int length = 0;   FILE *fp;   if ( !(fp=fopen(FileNamePlayList,"r")) ) {      printf("Can't open play list: %s\n", FileNamePlayList);      fclose(fp);      return(2);   }   while(1) {      if( !fgets(temp, 255, fp) )          break;      /* get rid of line feed */      length = strlen(temp);      temp[length-1] = temp[length];      strcpy(&play[count][0],temp);      count++;   }   fclose(fp);   totPlayCount+=count;   nowPlaying = 0;   loopCount = 0;   return(0);}int main(int argc, char **argv){	int rc;	RMTcontrolInterface ctrl[MAX_BOARDS] = {(RMTcontrolInterface) NULL, };	RMcontrolInterfaceInputType type;	RMTfileControl ctrl_file;	RMTvodControl  ctrl_vod;	RMTpropertyControl ctrl_prop;	RMuint8 *pStart;	RMuint32 board;	ebiPIOAccess_type pio;     if(argc <= 1){      	fprintf(stderr,"Usage playlist <Playlist.txt>\nTo log the output : playlist MyList.txt > outputlog.txt 2>&1\n");	return 1;      }      rc = readPlayList(argv[1]);      if ( rc ) {           fprintf(stderr,"\n\nExiting. Error in obtaining playlist. Error %d\n",rc);           exit(-1);      }	pStart=(RMuint8 *)malloc(TOTAL_MEMORY_NEEDED*MAX_BOARDS);	if (pStart==NULL) {		fprintf(stderr,"Cannot allocate %d bytes.\n",TOTAL_MEMORY_NEEDED*MAX_BOARDS);		return 1;	}	rc=setjmp(g_env);	if (rc == 0) {		fprintf(stderr,"Saved context for panic situation OK\n");	}	else {		fprintf(stderr,"CARIBBEAN called RMPanic with RMstatus %d. Exiting\n",rc);		if (rc==RM_ERRORGRAPHMISSINGNODEORMODULE) 			fprintf(stderr,				"you are missing a required shared library\n"				"run again in gdb with breakpoint on longjmp;\n"				"go back in the stack until RMCreateInstance() and\n"				"print *(int *)($fp+8) gives the missing cid\n");		return -1;	}	EnterCaribbean(pStart,TOTAL_MEMORY_NEEDED*MAX_BOARDS,RM_ALIGNMENTNONE,apidemopaniccallback);	donePlaying = 1;      	board = 0;	closedstate = 1;	do{		nowPlaying = -1;        	loopCount++;        	do{		    if(closedstate == 1 && donePlaying == 1 ){			  if (RMFOpenUrlControlInterface(&play[++nowPlaying][0], &(ctrl[board]), &callback, NULL) != RM_OK)    {            				fprintf(stderr,"Can't play file for some reason.\n");					donePlaying = 1;					closedstate = 1;					fprintf(stderr,"continue on next file item : %d.\n",nowPlaying+1);			  }else{				closedstate = 0;				// ----- C command        			pio.addr = 7;        			pio.val  = 0;        			type = RMFGetControlInterfaceInputType(ctrl[board]);        			RMFGetControlHandle((void **) &ctrl_prop, RM_CONTROL_PROPERTY, ctrl[board]);        			RMFSetGenericProperty(ctrl_prop, RM_PROPERTY_HWLIB, "BOARDINFO_SET", "ebiPIOAccess", &pio, sizeof(ebiPIOAccess_type));        			// ----- end of C command        			type = RMFGetControlInterfaceInputType(ctrl[board]);        			switch (type) {					case RM_INPUT_VOD:	                			RMFGetControlHandle((void **) &ctrl_vod, RM_CONTROL_VOD, ctrl[board]);        	            			fprintf(stderr,"\n\nPlaying: Item %d of %d (%d tot plays);  %s\n",                                              		nowPlaying+1, totPlayCount,loopCount,                                              		&play[nowPlaying][0]);                	    			donePlaying = 0;                    				RMFPlayVOD(ctrl_vod);						break;					case RM_INPUT_FILE:	 					RMFGetControlHandle((void **) &ctrl_file, RM_CONTROL_FILE, ctrl[board]);			    			fprintf(stderr,"\n\nPlaying: Item %d of %d (%d tot plays);  %s\n",                                              		nowPlaying+1, totPlayCount,loopCount,                                              		&play[nowPlaying][0]);                	    			donePlaying = 0;                    				RMFPlayFile(ctrl_file);						break;					default:						goto cleanup;				}			  }			}			else if (closedstate == 0 && donePlaying == 1){				if (ctrl[board] != NULL){					RMFCloseControlInterface(ctrl[board]);					closedstate = 1;					fprintf(stderr,"interface closed\n");				}			}		sleep (1);		} while (nowPlaying+1 <= totPlayCount );        fprintf(stderr,"Done play list. Start over.\n");	} while(1); cleanup:	for (board=0 ; board<MAX_BOARDS ; board++) {		if (ctrl[board] != NULL)			RMFCloseControlInterface(ctrl[board]);	}	fprintf(stderr,"interface closed\n");	if (ExitCaribbean(NULL)==RM_OK) {		free(pStart);		fprintf(stderr,"exit caribbean and freed memory space\n");		return 0;	}	else{		fprintf(stderr,"Problems to ExitCaribbean\n");		return 1;	}}

⌨️ 快捷键说明

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