Changeset 104 for trunk/classes/mm-progs/audioconverter/audconv.c
- Timestamp:
- Oct 2, 2023, 11:34:35 PM (23 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to
/branches/v2.9 merged eligible /branches/v2.9_Lars merged eligible
-
Property svn:mergeinfo
set to
-
trunk/classes/mm-progs/audioconverter/audconv.c
r48 r104 18 18 * along with this program; see the file COPYING. If not, write to 19 19 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 20 */ 20 */ 21 21 /* 22 22 * If you need another license for your project/product (commercial, 23 23 * noncommercial, whatever) contact me at 24 * 24 * 25 25 * http://www.os2world.com/cdwriting 26 26 * http://www.geocities.com/SiliconValley/Sector/5785/ … … 70 70 //#define INI_NAME_COLOR "color" 71 71 72 void HlpSendCommandToObject( char* chrObject, char*command);72 void HlpSendCommandToObject(PSZ chrObject, PSZ command); 73 73 BOOL percentRegisterBarClass(void); 74 BOOL IniSaveWindowPos( char * iniFile, char* chrApp, char *chrKey, HWND hwnd);75 BOOL IniRestoreWindowPos( char * iniFile, char* chrApp, char *chrKey, HWND hwnd);76 BOOL IniSaveWindowClrs( char * chrIniFile, char*chrApp , HWND hwnd);77 BOOL IniRestoreWindowClrs( char * chrIniFile, char*chrApp , HWND hwnd);78 BOOL HlpBuildMMProgIniFileName( char* chrProgname, char *chrBuffer, ULONG ulBufferSize);79 HMODULE queryResModuleHandle( char *chrExePath);74 BOOL IniSaveWindowPos(PSZ iniFile, PSZ chrApp, PSZ chrKey, HWND hwnd); 75 BOOL IniRestoreWindowPos(PSZ iniFile, PSZ chrApp, PSZ chrKey, HWND hwnd); 76 BOOL IniSaveWindowClrs(PSZ chrIniFile, PSZ chrApp , HWND hwnd); 77 BOOL IniRestoreWindowClrs(PSZ chrIniFile, PSZ chrApp , HWND hwnd); 78 BOOL HlpBuildMMProgIniFileName(PSZ chrProgname, PSZ chrBuffer, ULONG ulBufferSize); 79 HMODULE queryResModuleHandle(PSZ chrExePath); 80 80 void freeResHandle(); 81 BOOL getMessage( char*text,ULONG ulID, LONG lSizeText, HMODULE hResource,HWND hwnd);82 ULONG messageBox( char*text, ULONG ulTextID , LONG lSizeText,83 char*title, ULONG ulTitleID, LONG lSizeTitle,81 BOOL getMessage(PSZ text,ULONG ulID, LONG lSizeText, HMODULE hResource,HWND hwnd); 82 ULONG messageBox( PSZ text, ULONG ulTextID , LONG lSizeText, 83 PSZ title, ULONG ulTitleID, LONG lSizeTitle, 84 84 HMODULE hResource, HWND hwnd, ULONG ulFlags); 85 85 … … 90 90 BOOL bHaveWindowPos=FALSE; 91 91 92 charchrTargetName[CCHMAXPATH]={0};93 charchrSourceName[CCHMAXPATH]={0};94 charchrProcName[CCHMAXPATH]={0};95 charchrIniFile[CCHMAXPATH];92 UCHAR chrTargetName[CCHMAXPATH]={0}; 93 UCHAR chrSourceName[CCHMAXPATH]={0}; 94 UCHAR chrProcName[CCHMAXPATH]={0}; 95 UCHAR chrIniFile[CCHMAXPATH]; 96 96 97 97 int numArgs; … … 118 118 void pmUsage(); 119 119 120 BOOL createTargetName( char *sourceName, char *chrExt)120 BOOL createTargetName(PSZ sourceName, PSZ chrExt) 121 121 { 122 char *textPtr;123 124 strcpy( chrTargetName,sourceName);125 if((textPtr=strrchr( chrTargetName, '.'))!=NULLHANDLE)122 PCHAR textPtr=NULL; 123 124 strcpy((PCHAR)chrTargetName, (PCHAR)sourceName); 125 if((textPtr=strrchr((PCHAR)chrTargetName, '.'))!=NULL) 126 126 *textPtr=0; 127 127 else 128 textPtr= chrTargetName;128 textPtr=(PCHAR)chrTargetName; 129 129 strcat(textPtr,"."); 130 strcat(textPtr, chrExt);130 strcat(textPtr, (PCHAR)chrExt); 131 131 #if 0 132 132 WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, textPtr, … … 153 153 '\0', 154 154 sizeof(MMFORMATINFO) ); 155 155 156 156 mmFormatInfo.ulMediaType |= MMIO_MEDIATYPE_AUDIO; 157 mmFormatInfo.ulFlags|=MMIO_CANWRITETRANSLATED; 157 mmFormatInfo.ulFlags|=MMIO_CANWRITETRANSLATED; 158 158 ulReturnCode = mmioQueryFormatCount ( &mmFormatInfo, 159 159 &lNumIOProcs, 160 160 0, 161 161 0 ); 162 162 163 163 if( ulReturnCode != MMIO_SUCCESS ) 164 164 { … … 181 181 return FALSE; 182 182 } 183 183 184 184 /* 185 185 * call mmioGetFormats to get info on the formats supported. … … 199 199 return FALSE; 200 200 } 201 201 202 202 if( lFormatsRead != lNumIOProcs ) 203 203 { … … 214 214 for ( index = 0, sIdx=0; index <lNumIOProcs; index++ ) 215 215 { 216 charszName[CCHMAXPATH];217 218 mmioGetFormatName(pmmFormatInfoArray, szName, &lBytesRead, 0L, 0L); 216 UCHAR szName[CCHMAXPATH]; 217 218 mmioGetFormatName(pmmFormatInfoArray, szName, &lBytesRead, 0L, 0L); 219 219 /* Insert NULL string terminator */ 220 *( szName + lBytesRead ) = (CHAR)NULL;220 *( szName + lBytesRead ) = 0; 221 221 222 222 #ifdef DEBUG 223 SysWriteToTrapLog("%d IO-Proc: %s, %s\n", index, 223 SysWriteToTrapLog("%d IO-Proc: %s, %s\n", index, 224 224 pmmFormatInfoArray->szDefaultFormatExt, 225 225 szName); … … 231 231 WinSendMsg(hwndDrop, LM_INSERTITEM,(MPARAM)LIT_END, 232 232 (MPARAM)szName); 233 234 233 234 235 235 iPrivIOProc[sIdx]=index; 236 236 237 237 #ifdef DEBUG 238 238 SysWriteToTrapLog("-- %d %d, sIdx: %d %s\n", index, iPrivIOProc[sIdx], sIdx, … … 240 240 ); 241 241 #endif 242 243 242 243 244 244 /* Set text field */ 245 245 if(bNoProcGiven) { 246 246 WinSetWindowText(hwndDrop, szName); 247 createTargetName(chrSourceName, pmmFormatInfoArray->szDefaultFormatExt);247 createTargetName(chrSourceName, (PSZ)pmmFormatInfoArray->szDefaultFormatExt); 248 248 iIoProc=iPrivIOProc[sIdx]; 249 249 bNoProcGiven=FALSE; 250 250 } 251 251 else { 252 if(!stricmp( szName,chrProcName)) {252 if(!stricmp((PCHAR)szName, (PCHAR)chrProcName)) { 253 253 WinSetWindowText(hwndDrop, szName); 254 254 /* Create target name */ 255 createTargetName(chrSourceName, pmmFormatInfoArray->szDefaultFormatExt);255 createTargetName(chrSourceName, (PSZ)pmmFormatInfoArray->szDefaultFormatExt); 256 256 iIoProc=iPrivIOProc[sIdx]; 257 257 } … … 262 262 /* 263 263 * advance to next entry in mmFormatInfo array 264 */ 264 */ 265 265 pmmFormatInfoArray++; 266 266 } … … 268 268 } 269 269 270 BOOL queryAudioInfo( char *chrFile)270 BOOL queryAudioInfo(PSZ chrFile) 271 271 { 272 272 HMMIO hmmio; … … 275 275 LONG lBytesRead=0; 276 276 APIRET rc; 277 277 278 278 memset(&mmioinfo,0, sizeof(mmioinfo)); 279 279 mmioinfo.ulTranslate = MMIO_TRANSLATEHEADER; … … 321 321 #endif 322 322 323 void _OptlinkconvertThreadFunc (void *arg)323 void convertThreadFunc (void *arg) 324 324 { 325 325 HAB hab; … … 337 337 LONG lBytesWritten=0; 338 338 ULONG rc; 339 P BYTE buffer;339 PCHAR buffer=NULL; 340 340 341 341 do { … … 349 349 if((hmmio=mmioOpen(chrSourceName, &mmioinfo,MMIO_READ))==NULLHANDLE) 350 350 { 351 chartext[500];352 snprintf( text, sizeof(text)-1,"mmioOpen error with file %s\n", chrSourceName);353 WinMessageBox(hwnd, hwnd, "",351 UCHAR text[500]; 352 snprintf((PCHAR)text, sizeof(text)-1,"mmioOpen error with file %s\n", chrSourceName); 353 WinMessageBox(hwnd, hwnd, (PSZ)"", 354 354 text, 355 355 0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE ); … … 360 360 &lBytesRead, 0, 0); 361 361 if(rc!=MMIO_SUCCESS) { 362 chartext[500];362 UCHAR text[500]; 363 363 mmioClose(hmmio, 0); 364 snprintf( text, sizeof(text)-1,"mmioGetHeader error!");365 WinMessageBox(hwnd, hwnd, "",364 snprintf((PCHAR)text, sizeof(text)-1,"mmioGetHeader error!"); 365 WinMessageBox(hwnd, hwnd, (PSZ)"", 366 366 text, 367 367 0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE ); … … 380 380 if((hmmioTarget=mmioOpen(chrTargetName, &mmioinfo, MMIO_WRITE|MMIO_CREATE))==NULLHANDLE) 381 381 { 382 char chrError[CCHMAXPATH];383 char text[500];382 UCHAR chrError[64]; 383 UCHAR text[CCHMAXPATH*2]; 384 384 rc=mmioGetLastError(hmmioTarget); 385 mciGetErrorString(mmioinfo.ulErrorRet ,chrError, sizeof(chrError) );386 snprintf( text, sizeof(text)-1,"mmioOpen error with file %s:\n%s\n%d", chrTargetName, chrError,mmioinfo.ulErrorRet);385 mciGetErrorString(mmioinfo.ulErrorRet ,chrError, sizeof(chrError)-1); 386 snprintf((PCHAR)text, sizeof(text)-1,"mmioOpen error with file %s:\n%s\n%lu", chrTargetName, chrError,mmioinfo.ulErrorRet); 387 387 mmioClose(hmmio,0); 388 WinMessageBox(hwnd, hwnd, "",388 WinMessageBox(hwnd, hwnd, (PSZ)"", 389 389 text, 390 390 0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE ); … … 394 394 rc = mmioSetHeader(hmmioTarget, &mmAudioHeader,sizeof(MMAUDIOHEADER), 395 395 &lBytesWritten, 0, 0); 396 396 397 397 /* Get buffer */ 398 if((buffer=( void*)malloc(CONVERTBUFFERSIZE))==NULLHANDLE) {399 chartext[500];398 if((buffer=(PCHAR)malloc(CONVERTBUFFERSIZE))==NULLHANDLE) { 399 UCHAR text[500]; 400 400 mmioClose(hmmio, 0); 401 401 mmioClose(hmmioTarget,0); 402 snprintf( text, sizeof(text)-1,"Can't get memory buffer!");403 WinMessageBox(hwnd, hwnd, "",402 snprintf((PCHAR)text, sizeof(text)-1,"Can't get memory buffer!"); 403 WinMessageBox(hwnd, hwnd, (PSZ)"", 404 404 text, 405 405 0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE ); 406 406 407 407 break; 408 408 } … … 421 421 }while(rc!=0 && rc!=MMIO_ERROR && !bBreak/*&& lBytesWritten <1000000*/); 422 422 if(rc==MMIO_ERROR) { 423 chartext[500];424 snprintf( text, sizeof(text)-1,"Error while reading audio data!");425 WinMessageBox(hwnd, hwnd, "",423 UCHAR text[500]; 424 snprintf((PCHAR)text, sizeof(text)-1,"Error while reading audio data!"); 425 WinMessageBox(hwnd, hwnd, (PSZ)"", 426 426 text, 427 427 0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE ); 428 428 } 429 429 if(!bBreak) { 430 charchrCommand[CCHMAXPATH*2];430 UCHAR chrCommand[CCHMAXPATH*2]; 431 431 WinSendMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(MSG_CONVERTPERCENT), MPFROMLONG(100)); 432 432 /* Refresh details view */ 433 HlpSendCommandToObject(chrTargetName, "CWAUDIOREFRESH=1");434 sprintf( chrCommand,"CWAUDIOCOPYTAGTO=%s;", chrTargetName);433 HlpSendCommandToObject(chrTargetName, (PSZ)"CWAUDIOREFRESH=1"); 434 sprintf((PCHAR)chrCommand,"CWAUDIOCOPYTAGTO=%s;", chrTargetName); 435 435 HlpSendCommandToObject(chrSourceName, chrCommand); 436 436 } … … 443 443 } 444 444 while(TRUE); 445 WinSendMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(MSG_CONVERTDONE), 0); 445 WinSendMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(MSG_CONVERTDONE), 0); 446 446 WinDestroyMsgQueue(hmq); 447 447 } … … 464 464 MRESULT EXPENTRY decodeStatusDialogProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 465 465 { 466 chartext[CCHMAXPATH*4 +10];467 chartitle[CCHMAXPATH*4];466 UCHAR text[CCHMAXPATH*4 +10]; 467 UCHAR title[CCHMAXPATH*4]; 468 468 SWCNTRL swctl; 469 469 PID pid; … … 471 471 472 472 switch (msg) 473 { 473 { 474 474 case WM_INITDLG: 475 475 … … 493 493 494 494 WinSendMsg(WinWindowFromID(hwnd,IDST_CONVERTNAME),EM_SETTEXTLIMIT,MPFROMSHORT((SHORT)CCHMAXPATH),0); 495 496 WinSetWindowText(WinWindowFromID(hwnd,IDST_CONVERTCDBITS), "");497 495 496 WinSetWindowText(WinWindowFromID(hwnd,IDST_CONVERTCDBITS), (PSZ)""); 497 498 498 /* Filename */ 499 499 WinSetWindowText(WinWindowFromID(hwnd,IDST_CONVERTNAME), chrSourceName); 500 500 501 501 /* Set dialog font to WarpSans for Warp 4 and above */ 502 502 if(SysQueryOSRelease()>=40) { … … 507 507 508 508 /* Set percent bars to 0. */ 509 WinSetWindowText(WinWindowFromID(hwnd,IDBAR_CONVERTPROGRESS), "0#0%");509 WinSetWindowText(WinWindowFromID(hwnd,IDBAR_CONVERTPROGRESS),(PSZ)"0#0%"); 510 510 511 511 WinSendMsg(WinWindowFromID(hwnd,IDEF_CONVERTTARGETNAME), EM_SETTEXTLIMIT,MPFROMSHORT((SHORT)CCHMAXPATH),0); … … 516 516 /* Channels */ 517 517 getMessage(title, IDSTR_CONVERTCHANNELS, sizeof(title), RESSOURCEHANDLE, hwnd); 518 sprintf( text,title, sChannels);518 sprintf((PCHAR)text, (PCHAR)title, sChannels); 519 519 WinSetWindowText(WinWindowFromID(hwnd,IDST_CONVERTCHANNELS),text); 520 520 521 521 /* Samplerate */ 522 522 getMessage(title, IDSTR_CONVERTSAMPLERATE, sizeof(title), RESSOURCEHANDLE, hwnd); 523 sprintf( text,title, iSampleRate);523 sprintf((PCHAR)text, (PCHAR)title, iSampleRate); 524 524 WinSetWindowText(WinWindowFromID(hwnd,IDST_CONVERTSAMPLERATE),text); 525 525 526 526 /* Playtime */ 527 527 getMessage(title, IDSTR_CONVERTPLAYTIME, sizeof(title), RESSOURCEHANDLE, hwnd); 528 sprintf( text,title, lSec/60, lSec%60);528 sprintf((PCHAR)text, (PCHAR)title, lSec/60, lSec%60); 529 529 WinSetWindowText(WinWindowFromID(hwnd,IDST_CONVERTPLAYTIME),text); 530 530 … … 551 551 iPercent=0; 552 552 553 /* Update track percent bar value. The helper prog sends us the actual decoded %. */ 553 /* Update track percent bar value. The helper prog sends us the actual decoded %. */ 554 554 sprintf(text,"%d#%d%%", iPercent, iPercent); 555 555 WinSetWindowText(WinWindowFromID(hwnd,IDBAR_CONVERTPROGRESS), text); … … 593 593 594 594 createTargetName(chrSourceName, pMemFormatInfo[iIoProc].szDefaultFormatExt); 595 WinSetWindowText( WinWindowFromID(hwnd,IDEF_CONVERTTARGETNAME), chrTargetName ); 595 WinSetWindowText( WinWindowFromID(hwnd,IDEF_CONVERTTARGETNAME), chrTargetName ); 596 596 } 597 597 } … … 613 613 case IDPB_CONVERTBROWSE: 614 614 { 615 charchrTitle[200];615 UCHAR chrTitle[200]; 616 616 FILEDLG fd = { 0 }; 617 617 /* User pressed the browse button */ … … 652 652 ULONG ulDiskNum; 653 653 char cLetter; 654 654 655 655 WinQueryWindowText( WinWindowFromID(hwnd,IDEF_CONVERTTARGETNAME), sizeof(chrTargetName), chrTargetName ); 656 656 … … 669 669 if(lFreeSpace<lAudioSize) { 670 670 /* 671 Text: 672 Title: 673 */ 671 Text: 672 Title: 673 */ 674 674 getMessage(title, IDSTR_CONVERTNOSPACETEXT,sizeof(title), RESSOURCEHANDLE, hwnd); 675 675 sprintf(text,title,lAudioSize/1000000 ); … … 681 681 else { 682 682 /* Start decoding an audio file */ 683 WinEnableWindow( WinWindowFromID(hwnd,IDPB_CONVERTOK), FALSE); 683 WinEnableWindow( WinWindowFromID(hwnd,IDPB_CONVERTOK), FALSE); 684 684 WinEnableWindow( WinWindowFromID(hwnd,IDPB_CONVERTABORT), TRUE); 685 685 convertAudioFile(hwnd); 686 686 } 687 687 688 688 break; 689 689 } … … 695 695 break; 696 696 }/* switch */ 697 697 698 698 return WinDefDlgProc( hwnd, msg, mp1, mp2); 699 699 } … … 726 726 if(hab) { 727 727 hmq=WinCreateMsgQueue(hab,0); 728 if(hmq) { 729 /* Check if user started prog by hand */ 728 if(hmq) { 729 /* Check if user started prog by hand */ 730 730 if(argc<NUMPARAMS-1) {/* Not the actual num of params */ 731 731 pmUsage(); … … 740 740 strcpy(chrProcName, ""); 741 741 } 742 /* Get our ressource dll */ 742 /* Get our ressource dll */ 743 743 // RESSOURCEHANDLE=0; 744 744 RESSOURCEHANDLE=queryResModuleHandle(argv[0]); … … 751 751 { 752 752 /* 753 Text: 754 Title: "Installation problem" 755 */ 753 Text: 754 Title: "Installation problem" 755 */ 756 756 messageBox( text, IDSTR_CONVERTDIALOGERROR , sizeof(text), 757 757 title, IDSTR_INSTALLERRORTITLE , sizeof(title), … … 762 762 DosBeep(100,600); 763 763 return( 1 ); 764 } 764 } 765 765 } 766 766 }
Note:
See TracChangeset
for help on using the changeset viewer.