📄 gogo_a.c
字号:
num += 3; continue; } // -riff normal : mp3+TAG // -riff wave : RIFF/WAVE // -riff rmp : RIFF/RMP if(strcasecmp("-riff",argv[num])==0){ if(num+1>=argc) break; if(strcasecmp("wave",argv[num+1])==0){ gogo_opts.optOUTPUT_FORMAT = MC_OUTPUT_NORMAL; } else if(strcasecmp("wave",argv[num+1])==0){ gogo_opts.optOUTPUT_FORMAT = MC_OUTPUT_RIFF_WAVE; } else if(strcasecmp("wave",argv[num+1])==0){ gogo_opts.optOUTPUT_FORMAT = MC_OUTPUT_RIFF_RMP; } num += 2; continue; } // -priority normal : normal priority // -priority num if(strcasecmp("-priority",argv[num])==0){ if(num+1>=argc) break; if(strcasecmp("normal",argv[num+1])==0){ gogo_opts.optTHREAD_PRIORITY = 10; } else { gogo_opts.optTHREAD_PRIORITY = atol(argv[num+1]); } num += 2; continue; } // -readthread num if(strcasecmp("-readthread",argv[num])==0){ if(num+1>=argc) break; gogo_opts.optREADTHREAD_PRIORITY = atol(argv[num+1]); num += 2; continue; } // -i // -i- if(strcasecmp("-i",argv[num])==0){ gogo_opts.optVERIFY = 1; num += 1; continue; } if(strcasecmp("-i-",argv[num])==0){ gogo_opts.optVERIFY = 0; num += 1; continue; } // -o directory_path if(strcasecmp("-o",argv[num])==0){ if(num+1>=argc) break; strncpy((char *)gogo_opts.optOUTPUTDIR,argv[num+1],1023); gogo_opts.optOUTPUTDIR[1023] = '\0'; num += 2; continue; } num += 1; } return;}// gogo.dll or gogo.lib 偺娭悢傪梡偄偨 mp3 嶌惉晹暘偼暿僗儗僢僪偵偰峴偆丅丂// 僗儗僢僪嶌惉偵偼 CreateMPGEthread() 傪梡偄傞丅// 偦偺僗儗僢僪偼丄gogo_buffer_termination 偑旕 0 偵側偭偨偲偒昁偢廔椆偡傞丅// 偦偺僗儗僢僪偑廔椆偟偨偙偲偼丄IsTerminatedMPGEthread()偵傛傝専抦偡傞丅// 僗儗僢僪偑廔椆偟偨偙偲傪妋擣偟偰偐傜 close_output() 偼姰椆偡傞丅 // 僨乕僞偺搉偟偼 gogo_buffer 偵偰峴偆偑丄僶僢僼傽偑堦攖偺偲偒偼丄尦僗儗僢僪偑// 掆巭偟丄僶僢僼傽偺撉傒崬傒懸婡帪偼 gogo 梡僗儗僢僪偑掆巭偡傞丅static int __stdcall MPGEthread(void){ MERET rval; struct MCP_INPDEV_USERFUNC mcp_inpdev_userfunc; unsigned long gogo_vercode; char gogo_verstring[1024]; gogo_buffer_reset(); rval = MPGE_initializeWork(); if(rval != ME_NOERR){ gogo_error(rval); gogo_buffer_termination = -1; MPGE_endCoder(); return -1; } MPGE_getVersion(&gogo_vercode,gogo_verstring); ctl->cmsg(CMSG_INFO, VERB_NORMAL, "Gogo: %s", gogo_verstring); memset(&mcp_inpdev_userfunc,0,sizeof(struct MCP_INPDEV_USERFUNC)); mcp_inpdev_userfunc.pUserFunc = (MPGE_USERFUNC)gogoUserFunc; mcp_inpdev_userfunc.nSize = MC_INPDEV_MEMORY_NOSIZE; mcp_inpdev_userfunc.nBit = (dpm.encoding & PE_16BIT) ? 16 : 8; mcp_inpdev_userfunc.nFreq = dpm.rate; mcp_inpdev_userfunc.nChn = (dpm.encoding & PE_MONO) ? 1 : 2;#if !defined ( IA_W32GUI ) && !defined ( IA_W32G_SYN ) if(use_gogo_commandline_options && gogo_commandline_options!=NULL){ gogo_opts_reset(); set_gogo_opts_use_commandline_options(gogo_commandline_options); }#else gogo_ConfigDialogInfoApply();#endif // title偑偁傞応崌偼僨僼僅儖僩偱TAG晅壛 if (tag_title != NULL) { gogo_opts_id3_tag(tag_title, NULL, NULL, NULL, NULL, -1); } set_gogo_opts(); rval = MPGE_setConfigure( MC_INPUTFILE,MC_INPDEV_USERFUNC,(UPARAM)&mcp_inpdev_userfunc); if(rval != ME_NOERR){ gogo_error(rval); gogo_buffer_termination = -1; MPGE_endCoder(); return -1; } if(gogo_vercode<300){ rval = MPGE_setConfigure(MC_STARTOFFSET,(UPARAM)0,(UPARAM)0); if(rval != ME_NOERR){ gogo_error(rval); gogo_buffer_termination = -1; MPGE_endCoder(); return -1; } }#if 0 rval = MPGE_setConfigure(MC_INPFREQ,(UPARAM)dpm.rate,(UPARAM)0); if(rval != ME_NOERR){ gogo_error(rval); gogo_buffer_termination = -1; MPGE_endCoder(); return -1; }#endif if(gogo_vercode<300){ rval = MPGE_setConfigure(MC_BYTE_SWAP,(UPARAM)((dpm.encoding & PE_BYTESWAP) ? TRUE : FALSE),(UPARAM)0); if(rval != ME_NOERR){ gogo_error(rval); gogo_buffer_termination = -1; MPGE_endCoder(); return -1; } rval = MPGE_setConfigure(MC_8BIT_PCM,(UPARAM)((dpm.encoding & PE_16BIT) ? FALSE : TRUE),(UPARAM)0); if(rval != ME_NOERR){ gogo_error(rval); gogo_buffer_termination = -1; MPGE_endCoder(); return -1; } rval = MPGE_setConfigure(MC_MONO_PCM,(UPARAM)((dpm.encoding & PE_MONO) ? TRUE : FALSE),(UPARAM)0); if(rval != ME_NOERR){ gogo_error(rval); gogo_buffer_termination = -1; MPGE_endCoder(); return -1; } } rval = MPGE_detectConfigure(); if( rval != ME_NOERR ){ gogo_error(rval); gogo_buffer_termination = -1; MPGE_endCoder(); return -1; } else {// UPARAM curFrame;// curFrame = 0; do {// ctl->cmsg(CMSG_INFO, VERB_DEBUG,"gogo_a : frame %d",curFrame);// curFrame++; rval = MPGE_processFrame(); } while( rval == ME_NOERR ); if( rval != ME_EMPTYSTREAM ){ gogo_buffer_termination = -1; gogo_error(rval); } } MPGE_closeCoder(); MPGE_endCoder(); return 0;}// Whether the thread of gogo.dll is terminated ?static int IsTerminatedMPGEthread(void){#ifndef __W32__#else DWORD dwRes; if(hMPGEthread==NULL) return 1; dwRes = WaitForSingleObject(hMPGEthread,0); if(dwRes==WAIT_TIMEOUT){ return 0; } else { return 1; }#endif}// Create the thread of gogo.dllstatic int CreateMPGEthread(void){ // gogo 梡偺僗儗僢僪偑廔椆偟偰偄傞偐妋擣偡傞丅 gogo_buffer_termination = 1; while(!IsTerminatedMPGEthread()){#ifndef __W32__ usleep(100);#else Sleep(0); Sleep(100);#endif } gogo_buffer_termination = 0; // gogo 梡偺僗儗僢僪傪嶌惉偡傞丅#ifndef __W32__#else // 僴儞僪儖偼僋儘乕僘偟偰偍偔丅 if(hMPGEthread!=NULL){ CloseHandle(hMPGEthread); } hMPGEthread = (HANDLE)crt_beginthreadex(NULL,0,(LPTHREAD_START_ROUTINE)MPGEthread,NULL,0,&dwMPGEthreadID); if(hMPGEthread==(HANDLE)-1 || hMPGEthread==NULL){ hMPGEthread = NULL; ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "gogo_a : cannot create thread."); return -1; }#endif return 0;}/**********************************************************************/#if defined ( IA_W32GUI ) || defined ( IA_W32G_SYN )extern volatile int w32g_gogo_id3_tag_dialog(void);extern int w32g_interactive_id3_tag_set;#endifstatic int gogo_output_open(const char *fname){ if(fname[0]=='\0') return -1; if(!gogo_opts_initflag) gogo_opts_init(); strncpy((char *)gogo_opts.output_name,fname,1023); gogo_opts.output_name[1023] = '\0';#if defined ( IA_W32GUI ) || defined ( IA_W32G_SYN ) gogo_opts_reset_tag(); if(w32g_interactive_id3_tag_set){ // 墘憈帪偵ID3僞僌忣曬擖椡僟僀傾儘僌傪奐偔丅 w32g_gogo_id3_tag_dialog(); }#endif if(CreateMPGEthread()){ gogo_buffer_termination = -1; return -1; } return 0;}static int auto_gogo_output_open(const char *input_filename, const char *title){ char *output_filename;#if !defined ( IA_W32GUI ) && !defined ( IA_W32G_SYN ) output_filename = create_auto_output_name(input_filename,"mp3",NULL,0);#else gogo_ConfigDialogInfoApply(); switch(gogo_opts.optOUTPUT_FORMAT){ case MC_OUTPUT_NORMAL: output_filename = create_auto_output_name(input_filename,"mp3",(char *)w32g_output_dir,w32g_auto_output_mode); break; case MC_OUTPUT_RIFF_WAVE: output_filename = create_auto_output_name(input_filename,"wav",(char *)w32g_output_dir,w32g_auto_output_mode); break; case MC_OUTPUT_RIFF_RMP: output_filename = create_auto_output_name(input_filename,"rmp",(char *)w32g_output_dir,w32g_auto_output_mode); break; default: output_filename = create_auto_output_name(input_filename,"mp3",(char *)w32g_output_dir,w32g_auto_output_mode); break; }#endif if(output_filename==NULL){ return -1; } if (tag_title != NULL) { free(tag_title); tag_title = NULL; } if (title != NULL) { tag_title = (char *)safe_malloc(sizeof(char)*(strlen(title)+1)); strcpy(tag_title, title); } if((dpm.fd = gogo_output_open(output_filename)) == -1) { free(output_filename); return -1; } if(dpm.name != NULL){ free(dpm.name); dpm.name = NULL; } dpm.name = output_filename; ctl->cmsg(CMSG_INFO, VERB_NORMAL, "Output %s", dpm.name); return 0;}#ifdef AU_GOGO_DLL extern int gogo_dll_check(void);#endifstatic int open_output(void){ int include_enc, exclude_enc;#ifdef AU_VORBIS_DLL if(!gogo_dll_check()){ ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "can not find gogo.dll."); return -1; }#endif include_enc = exclude_enc = 0; if(dpm.encoding & PE_24BIT) { /* 24 bit is not supported */ exclude_enc |= PE_24BIT; include_enc |= PE_16BIT; } if(dpm.encoding & PE_16BIT || dpm.encoding & PE_24BIT) {#ifdef LITTLE_ENDIAN exclude_enc |= PE_BYTESWAP;#else include_enc |= PE_BYTESWAP;#endif /* LITTLE_ENDIAN */ include_enc |= PE_SIGNED; } else { exclude_enc |= PE_SIGNED;#if 0 } else if(!(dpm.encoding & (PE_ULAW|PE_ALAW))){ exclude_enc = PE_SIGNED;#endif } dpm.encoding = validate_encoding(dpm.encoding, include_enc, exclude_enc);#if !defined ( IA_W32GUI ) && !defined ( IA_W32G_SYN ) if(dpm.name == NULL) { dpm.flag |= PF_AUTO_SPLIT_FILE; dpm.name = NULL; } else { dpm.flag &= ~PF_AUTO_SPLIT_FILE; if((dpm.fd = gogo_output_open(dpm.name)) == -1) return -1; }#else if(w32g_auto_output_mode>0){ dpm.flag |= PF_AUTO_SPLIT_FILE; dpm.name = NULL; } else { dpm.flag &= ~PF_AUTO_SPLIT_FILE; if((dpm.fd = gogo_output_open(dpm.name)) == -1) return -1; }#endif return 0;}static int output_data(char *readbuffer, int32 bytes){ int32 rest_bytes = bytes; int32 out_bytes = 0; if(dpm.fd<0) return 0; gogo_buffer_init(); if(bytes>gogo_buffer_size){ gogo_buffer_termination = -1; ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "gogo_a : buffer size is small."); return -1; } for(;;){ int32 size; if(bytes<=0) break; if(gogo_buffer_termination<0){ ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "gogo_a : output_data error."); return -1; } if(gogo_buffer_termination) return out_bytes; if(gogo_lock()){ ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "gogo_a : lock error."); gogo_buffer_termination = -1; return -1; } size = __gogo_buffer_push(readbuffer,bytes); readbuffer += size; bytes -= size; out_bytes += size; gogo_unlock(); if(bytes>0){#ifndef __W32__ usleep(100);#else Sleep(0); Sleep(100);#endif } } return out_bytes;}static void close_output(void){ if (dpm.fd < 0) return; gogo_buffer_termination = 1; for (;;) { if (IsTerminatedMPGEthread()) { break; }#ifndef __W32__ usleep(100000);#else Sleep(100);#endif } dpm.fd = -1;}static int acntl(int request, void *arg){ switch(request) { case PM_REQ_PLAY_START: if(dpm.flag & PF_AUTO_SPLIT_FILE) return auto_gogo_output_open(current_file_info->filename,current_file_info->seq_name); break; case PM_REQ_PLAY_END: if(dpm.flag & PF_AUTO_SPLIT_FILE) { close_output(); return 0; } break; case PM_REQ_DISCARD:#if 1 gogo_buffer_reset();#endif return 0; case PM_REQ_FLUSH: case PM_REQ_OUTPUT_FINISH: break; default: break; } return -1;}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -