| 1 | /* | 
|---|
| 2 | * pmmp3dec.c (C) Chris Wohlgemuth 2002 | 
|---|
| 3 | * | 
|---|
| 4 | * This helper decodes an MP3 | 
|---|
| 5 | */ | 
|---|
| 6 | /* | 
|---|
| 7 | * This program is free software; you can redistribute it and/or modify | 
|---|
| 8 | * it under the terms of the GNU General Public License as published by | 
|---|
| 9 | * the Free Software Foundation; either version 2, or (at your option) | 
|---|
| 10 | * any later version. | 
|---|
| 11 | * | 
|---|
| 12 | * This program is distributed in the hope that it will be useful, | 
|---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
| 15 | * GNU General Public License for more details. | 
|---|
| 16 | * | 
|---|
| 17 | * You should have received a copy of the GNU General Public License | 
|---|
| 18 | * along with this program; see the file COPYING.  If not, write to | 
|---|
| 19 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | 
|---|
| 20 | */ | 
|---|
| 21 | /* | 
|---|
| 22 | * If you need another license for your project/product (commercial, | 
|---|
| 23 | * noncommercial, whatever) contact me at | 
|---|
| 24 | * | 
|---|
| 25 | * http://www.os2world.com/cdwriting | 
|---|
| 26 | * http://www.geocities.com/SiliconValley/Sector/5785/ | 
|---|
| 27 | * | 
|---|
| 28 | */ | 
|---|
| 29 |  | 
|---|
| 30 | #define INCL_DOS | 
|---|
| 31 | #define INCL_DOSFILEMGR | 
|---|
| 32 | #define INCL_DOSERRORS | 
|---|
| 33 | #define INCL_WIN | 
|---|
| 34 | #define INCL_OS2MM | 
|---|
| 35 | #define INCL_MMIOOS2 | 
|---|
| 36 | #define INCL_MCIOS2 | 
|---|
| 37 |  | 
|---|
| 38 | #include <os2.h> | 
|---|
| 39 |  | 
|---|
| 40 | #include <sys\types.h> | 
|---|
| 41 | #include <sys\stat.h> | 
|---|
| 42 | #include <stdio.h> | 
|---|
| 43 | #include <stdlib.h> | 
|---|
| 44 | #include <string.h> | 
|---|
| 45 | #include <ctype.h> | 
|---|
| 46 | #include "os2me.h" | 
|---|
| 47 | #include "common.h" | 
|---|
| 48 | #include "mmres.h" | 
|---|
| 49 | #include "mmprogs_defaults.h" | 
|---|
| 50 |  | 
|---|
| 51 | #include "sys_funcs.h" | 
|---|
| 52 |  | 
|---|
| 53 | #if 0 | 
|---|
| 54 | #define  _PMPRINTF_ | 
|---|
| 55 | #include "U:/PMPRINTF/PMPRINTF.H" | 
|---|
| 56 | #endif | 
|---|
| 57 |  | 
|---|
| 58 | #define MSG_CONVERTDONE    1L | 
|---|
| 59 | #define MSG_CONVERTPERCENT 2L | 
|---|
| 60 | #define MSG_CONVERTERROR   3L | 
|---|
| 61 |  | 
|---|
| 62 | #define ID_TIMER 1 | 
|---|
| 63 | #define TIMER_DELAY        200 | 
|---|
| 64 |  | 
|---|
| 65 | #define CONVERTBUFFERSIZE  500000 | 
|---|
| 66 | #define NUMPARAMS  3 | 
|---|
| 67 | /* argv[0]: progname | 
|---|
| 68 | * argv[1]: wavefile | 
|---|
| 69 | * argv[2]: IO proc name | 
|---|
| 70 | */ | 
|---|
| 71 |  | 
|---|
| 72 | //#define DEBUG | 
|---|
| 73 |  | 
|---|
| 74 | //#define INI_NAME_APP        "audioconv" | 
|---|
| 75 | //#define INI_NAME_COLOR        "color" | 
|---|
| 76 |  | 
|---|
| 77 | void HlpSendCommandToObject(PSZ chrObject, PSZ command); | 
|---|
| 78 | BOOL percentRegisterBarClass(void); | 
|---|
| 79 | BOOL IniSaveWindowPos(PSZ iniFile, PSZ chrApp, PSZ chrKey, HWND hwnd); | 
|---|
| 80 | BOOL IniRestoreWindowPos(PSZ iniFile, PSZ chrApp, PSZ chrKey, HWND hwnd); | 
|---|
| 81 | BOOL IniSaveWindowClrs(PSZ chrIniFile, PSZ chrApp , HWND hwnd); | 
|---|
| 82 | BOOL IniRestoreWindowClrs(PSZ chrIniFile, PSZ chrApp , HWND hwnd); | 
|---|
| 83 | BOOL HlpBuildMMProgIniFileName(PSZ chrProgname, PSZ chrBuffer, ULONG ulBufferSize); | 
|---|
| 84 | HMODULE queryResModuleHandle(PSZ chrExePath); | 
|---|
| 85 | void freeResHandle(void); | 
|---|
| 86 | BOOL getMessage(PSZ text,ULONG ulID, LONG lSizeText, HMODULE hResource,HWND hwnd); | 
|---|
| 87 | ULONG messageBox( PSZ text, ULONG ulTextID , LONG lSizeText, | 
|---|
| 88 | PSZ title, ULONG ulTitleID, LONG lSizeTitle, | 
|---|
| 89 | HMODULE hResource, HWND hwnd, ULONG ulFlags); | 
|---|
| 90 |  | 
|---|
| 91 |  | 
|---|
| 92 | char logName[]="convert.log"; | 
|---|
| 93 |  | 
|---|
| 94 | extern SWP swpWindow; | 
|---|
| 95 | BOOL bHaveWindowPos=FALSE; | 
|---|
| 96 |  | 
|---|
| 97 | UCHAR chrTargetName[CCHMAXPATH]={0}; | 
|---|
| 98 | UCHAR chrSourceName[CCHMAXPATH]={0}; | 
|---|
| 99 | UCHAR chrProcName[CCHMAXPATH]={0}; | 
|---|
| 100 | UCHAR chrIniFile[CCHMAXPATH]; | 
|---|
| 101 |  | 
|---|
| 102 | int numArgs; | 
|---|
| 103 | char* params[NUMPARAMS]; | 
|---|
| 104 |  | 
|---|
| 105 | #define NUMIOPROCS 1000 | 
|---|
| 106 | int iIoProc;     /* Position of IO-Proc in global data area of MMOS2. 0 based */ | 
|---|
| 107 | int iPrivIOProc[NUMIOPROCS]; /* Number of possible IO-Procs. I'm lazy here and use a static array. | 
|---|
| 108 | If there ever will be more than 1000 procs there'll be a problem... */ | 
|---|
| 109 |  | 
|---|
| 110 |  | 
|---|
| 111 | int iSampleRate; | 
|---|
| 112 | int iBitsPerSample; | 
|---|
| 113 | SHORT sChannels; | 
|---|
| 114 | ULONG lSec; | 
|---|
| 115 | ULONG lAudioSize; | 
|---|
| 116 |  | 
|---|
| 117 | TID tidThread=0; | 
|---|
| 118 | BOOL bBreak=FALSE; | 
|---|
| 119 | PMMFORMATINFO pMemFormatInfo=NULLHANDLE; | 
|---|
| 120 | HMODULE RESSOURCEHANDLE=0; | 
|---|
| 121 | BOOL bNoProcGiven=FALSE; | 
|---|
| 122 |  | 
|---|
| 123 | void pmUsage(void); | 
|---|
| 124 |  | 
|---|
| 125 | BOOL createTargetName(PSZ sourceName, PSZ chrExt) | 
|---|
| 126 | { | 
|---|
| 127 | PCHAR textPtr=NULL; | 
|---|
| 128 |  | 
|---|
| 129 | strcpy((PCHAR)chrTargetName, (PCHAR)sourceName); | 
|---|
| 130 | if((textPtr=strrchr((PCHAR)chrTargetName, '.'))!=NULL) | 
|---|
| 131 | *textPtr=0; | 
|---|
| 132 | else | 
|---|
| 133 | textPtr=(PCHAR)chrTargetName; | 
|---|
| 134 | strcat(textPtr,"."); | 
|---|
| 135 | strcat(textPtr, (PCHAR)chrExt); | 
|---|
| 136 | #if 0 | 
|---|
| 137 | WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, textPtr, | 
|---|
| 138 | "", | 
|---|
| 139 | 0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE ); | 
|---|
| 140 | #endif | 
|---|
| 141 | return TRUE; | 
|---|
| 142 | } | 
|---|
| 143 |  | 
|---|
| 144 | BOOL insertIOProcItems( HWND hwndDrop ) | 
|---|
| 145 | { | 
|---|
| 146 | //    CHAR          szBuffer[ sizeof( FOURCC ) + CCHMAXPATH + 4 ]; | 
|---|
| 147 | MMFORMATINFO  mmFormatInfo; | 
|---|
| 148 | PMMFORMATINFO pmmFormatInfoArray; | 
|---|
| 149 | ULONG         ulReturnCode; | 
|---|
| 150 | LONG          lFormatsRead; | 
|---|
| 151 | LONG          index; | 
|---|
| 152 | LONG          lBytesRead; | 
|---|
| 153 |  | 
|---|
| 154 |  | 
|---|
| 155 | LONG lNumIOProcs; | 
|---|
| 156 | int sIdx; | 
|---|
| 157 | memset( &mmFormatInfo, | 
|---|
| 158 | '\0', | 
|---|
| 159 | sizeof(MMFORMATINFO) ); | 
|---|
| 160 |  | 
|---|
| 161 | mmFormatInfo.ulMediaType |= MMIO_MEDIATYPE_AUDIO; | 
|---|
| 162 | mmFormatInfo.ulFlags|=MMIO_CANWRITETRANSLATED; | 
|---|
| 163 | ulReturnCode = mmioQueryFormatCount ( &mmFormatInfo, | 
|---|
| 164 | &lNumIOProcs, | 
|---|
| 165 | 0, | 
|---|
| 166 | 0 ); | 
|---|
| 167 |  | 
|---|
| 168 | if( ulReturnCode != MMIO_SUCCESS ) | 
|---|
| 169 | { | 
|---|
| 170 | /* | 
|---|
| 171 | * Error - mmioQueryFormatCount failed. | 
|---|
| 172 | */ | 
|---|
| 173 | return FALSE; | 
|---|
| 174 | } | 
|---|
| 175 |  | 
|---|
| 176 | /* | 
|---|
| 177 | * Allocate enough memory for n number of FormatInfo blocks | 
|---|
| 178 | */ | 
|---|
| 179 | pmmFormatInfoArray = (PMMFORMATINFO) malloc (lNumIOProcs * sizeof( MMFORMATINFO ) ); | 
|---|
| 180 | pMemFormatInfo=pmmFormatInfoArray; | 
|---|
| 181 | if( pmmFormatInfoArray == NULL ) | 
|---|
| 182 | { | 
|---|
| 183 | /* | 
|---|
| 184 | * Could not allocate enough memory for mmFormatInfo array. | 
|---|
| 185 | */ | 
|---|
| 186 | return FALSE; | 
|---|
| 187 | } | 
|---|
| 188 |  | 
|---|
| 189 | /* | 
|---|
| 190 | * call mmioGetFormats to get info on the formats supported. | 
|---|
| 191 | */ | 
|---|
| 192 | ulReturnCode = mmioGetFormats( &mmFormatInfo, | 
|---|
| 193 | lNumIOProcs, | 
|---|
| 194 | pmmFormatInfoArray, | 
|---|
| 195 | &lFormatsRead, | 
|---|
| 196 | 0, | 
|---|
| 197 | 0 ); | 
|---|
| 198 | if( ulReturnCode != MMIO_SUCCESS ) | 
|---|
| 199 | { | 
|---|
| 200 | /* | 
|---|
| 201 | *  mmioGetFormats failed. | 
|---|
| 202 | */ | 
|---|
| 203 | free(pmmFormatInfoArray); | 
|---|
| 204 | return FALSE; | 
|---|
| 205 | } | 
|---|
| 206 |  | 
|---|
| 207 | if( lFormatsRead != lNumIOProcs ) | 
|---|
| 208 | { | 
|---|
| 209 | /* | 
|---|
| 210 | * Error in MMIO - number of formats read in by | 
|---|
| 211 | * mmioGetFormats is not equal to number of formats | 
|---|
| 212 | * found by mmioQueryFormatCount. | 
|---|
| 213 | */ | 
|---|
| 214 | free(pmmFormatInfoArray); | 
|---|
| 215 | return FALSE; | 
|---|
| 216 | } | 
|---|
| 217 |  | 
|---|
| 218 |  | 
|---|
| 219 | for ( index = 0, sIdx=0; index <lNumIOProcs; index++ ) | 
|---|
| 220 | { | 
|---|
| 221 | UCHAR szName[CCHMAXPATH]; | 
|---|
| 222 |  | 
|---|
| 223 | mmioGetFormatName(pmmFormatInfoArray, szName, &lBytesRead, 0L, 0L); | 
|---|
| 224 | /* Insert NULL string terminator */ | 
|---|
| 225 | *( szName + lBytesRead ) = 0; | 
|---|
| 226 |  | 
|---|
| 227 | #ifdef DEBUG | 
|---|
| 228 | SysWriteToTrapLog("%d  IO-Proc: %s, %s\n", index, | 
|---|
| 229 | pmmFormatInfoArray->szDefaultFormatExt, | 
|---|
| 230 | szName); | 
|---|
| 231 | #endif | 
|---|
| 232 |  | 
|---|
| 233 | if(pmmFormatInfoArray->ulFlags & MMIO_CANWRITETRANSLATED) | 
|---|
| 234 | { | 
|---|
| 235 | /* Insert into list box */ | 
|---|
| 236 | WinSendMsg(hwndDrop, LM_INSERTITEM,(MPARAM)LIT_END, | 
|---|
| 237 | (MPARAM)szName); | 
|---|
| 238 |  | 
|---|
| 239 |  | 
|---|
| 240 | iPrivIOProc[sIdx]=index; | 
|---|
| 241 |  | 
|---|
| 242 | #ifdef DEBUG | 
|---|
| 243 | SysWriteToTrapLog("-- %d  %d, sIdx: %d %s\n", index, iPrivIOProc[sIdx], sIdx, | 
|---|
| 244 | pmmFormatInfoArray->szDefaultFormatExt | 
|---|
| 245 | ); | 
|---|
| 246 | #endif | 
|---|
| 247 |  | 
|---|
| 248 |  | 
|---|
| 249 | /* Set text field */ | 
|---|
| 250 | if(bNoProcGiven) { | 
|---|
| 251 | WinSetWindowText(hwndDrop, szName); | 
|---|
| 252 | createTargetName(chrSourceName, (PSZ)pmmFormatInfoArray->szDefaultFormatExt); | 
|---|
| 253 | iIoProc=iPrivIOProc[sIdx]; | 
|---|
| 254 | bNoProcGiven=FALSE; | 
|---|
| 255 | } | 
|---|
| 256 | else { | 
|---|
| 257 | if(!stricmp((PCHAR)szName, (PCHAR)chrProcName)) { | 
|---|
| 258 | WinSetWindowText(hwndDrop, szName); | 
|---|
| 259 | /* Create target name */ | 
|---|
| 260 | createTargetName(chrSourceName, (PSZ)pmmFormatInfoArray->szDefaultFormatExt); | 
|---|
| 261 | iIoProc=iPrivIOProc[sIdx]; | 
|---|
| 262 | } | 
|---|
| 263 | sIdx++; | 
|---|
| 264 | } | 
|---|
| 265 | } | 
|---|
| 266 |  | 
|---|
| 267 | /* | 
|---|
| 268 | *  advance to next entry in mmFormatInfo array | 
|---|
| 269 | */ | 
|---|
| 270 | pmmFormatInfoArray++; | 
|---|
| 271 | } | 
|---|
| 272 | return TRUE; | 
|---|
| 273 | } | 
|---|
| 274 |  | 
|---|
| 275 | BOOL queryAudioInfo(PSZ chrFile) | 
|---|
| 276 | { | 
|---|
| 277 | HMMIO hmmio; | 
|---|
| 278 | MMAUDIOHEADER mmAudioHeader; | 
|---|
| 279 | MMIOINFO mmioinfo; | 
|---|
| 280 | LONG lBytesRead=0; | 
|---|
| 281 | APIRET rc; | 
|---|
| 282 |  | 
|---|
| 283 | memset(&mmioinfo,0, sizeof(mmioinfo)); | 
|---|
| 284 | mmioinfo.ulTranslate = MMIO_TRANSLATEHEADER; | 
|---|
| 285 | mmioinfo.ulFlags=MMIO_READ|MMIO_DENYNONE; | 
|---|
| 286 | /* open source file */ | 
|---|
| 287 | if((hmmio=mmioOpen(chrFile, &mmioinfo,MMIO_READ))==NULLHANDLE) | 
|---|
| 288 | { | 
|---|
| 289 | return FALSE; | 
|---|
| 290 | } | 
|---|
| 291 | memset(&mmAudioHeader,0,sizeof(MMAUDIOHEADER)); | 
|---|
| 292 | rc = mmioGetHeader(hmmio, &mmAudioHeader,sizeof(MMAUDIOHEADER), | 
|---|
| 293 | &lBytesRead, 0, 0); | 
|---|
| 294 | if(rc!=MMIO_SUCCESS) { | 
|---|
| 295 | mmioClose(hmmio, 0); | 
|---|
| 296 | //    fprintf(stderr,"mmioGetHeader error!\n"); | 
|---|
| 297 | return FALSE; | 
|---|
| 298 | } | 
|---|
| 299 |  | 
|---|
| 300 | iSampleRate=mmAudioHeader.mmXWAVHeader.WAVEHeader.ulSamplesPerSec; | 
|---|
| 301 | sChannels=mmAudioHeader.mmXWAVHeader.WAVEHeader.usChannels; | 
|---|
| 302 | iBitsPerSample=mmAudioHeader.mmXWAVHeader.WAVEHeader.usBitsPerSample; | 
|---|
| 303 | lSec=mmAudioHeader.mmXWAVHeader.XWAVHeaderInfo.ulAudioLengthInBytes/ | 
|---|
| 304 | mmAudioHeader.mmXWAVHeader.WAVEHeader.ulAvgBytesPerSec; | 
|---|
| 305 | lAudioSize=mmAudioHeader.mmXWAVHeader.XWAVHeaderInfo.ulAudioLengthInBytes; | 
|---|
| 306 |  | 
|---|
| 307 | /* close source */ | 
|---|
| 308 | mmioClose(hmmio,0); | 
|---|
| 309 | return TRUE; | 
|---|
| 310 | } | 
|---|
| 311 |  | 
|---|
| 312 | #if 0 | 
|---|
| 313 | BOOL createTargetName(char *sourceName) | 
|---|
| 314 | { | 
|---|
| 315 | char *textPtr; | 
|---|
| 316 |  | 
|---|
| 317 | strcpy(chrTargetName, sourceName); | 
|---|
| 318 | if((textPtr=strrchr(chrTargetName, '.'))!=NULLHANDLE) | 
|---|
| 319 | *textPtr=0; | 
|---|
| 320 | else | 
|---|
| 321 | textPtr=chrTargetName; | 
|---|
| 322 | strcat(textPtr, ".wav"); | 
|---|
| 323 |  | 
|---|
| 324 | return TRUE; | 
|---|
| 325 | } | 
|---|
| 326 | #endif | 
|---|
| 327 |  | 
|---|
| 328 | void convertThreadFunc (void *arg) | 
|---|
| 329 | { | 
|---|
| 330 | HAB  hab; | 
|---|
| 331 | HMQ  hmq; | 
|---|
| 332 | HWND hwnd=(HWND)arg; | 
|---|
| 333 |  | 
|---|
| 334 | hab=WinInitialize(0); | 
|---|
| 335 | if(hab) { | 
|---|
| 336 | hmq=WinCreateMsgQueue(hab,0); | 
|---|
| 337 | if(hmq) { | 
|---|
| 338 | HMMIO hmmio, hmmioTarget; | 
|---|
| 339 | MMIOINFO mmioinfo; | 
|---|
| 340 | MMAUDIOHEADER mmAudioHeader; | 
|---|
| 341 | LONG lBytesRead=0; | 
|---|
| 342 | LONG lBytesWritten=0; | 
|---|
| 343 | ULONG rc; | 
|---|
| 344 | PCHAR buffer=NULL; | 
|---|
| 345 |  | 
|---|
| 346 | do { | 
|---|
| 347 | /*******************************/ | 
|---|
| 348 | /* Set up/open the SOURCE file */ | 
|---|
| 349 | /*******************************/ | 
|---|
| 350 | memset(&mmioinfo,0, sizeof(mmioinfo)); | 
|---|
| 351 | mmioinfo.ulTranslate = MMIO_TRANSLATEHEADER | MMIO_TRANSLATEDATA; | 
|---|
| 352 | mmioinfo.ulFlags=MMIO_READ|MMIO_DENYNONE; | 
|---|
| 353 |  | 
|---|
| 354 | if((hmmio=mmioOpen(chrSourceName, &mmioinfo,MMIO_READ))==NULLHANDLE) | 
|---|
| 355 | { | 
|---|
| 356 | UCHAR text[500]; | 
|---|
| 357 | sprintf((PCHAR)text,/* sizeof(text)-1,*/"mmioOpen error with file %s\n", chrSourceName); | 
|---|
| 358 | WinMessageBox(hwnd, hwnd, (PSZ)"", | 
|---|
| 359 | text, | 
|---|
| 360 | 0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE ); | 
|---|
| 361 | break; | 
|---|
| 362 | } | 
|---|
| 363 | memset(&mmAudioHeader,0,sizeof(MMAUDIOHEADER)); | 
|---|
| 364 | rc = mmioGetHeader(hmmio, &mmAudioHeader,sizeof(MMAUDIOHEADER), | 
|---|
| 365 | &lBytesRead, 0, 0); | 
|---|
| 366 | if(rc!=MMIO_SUCCESS) { | 
|---|
| 367 | UCHAR text[500]; | 
|---|
| 368 | mmioClose(hmmio, 0); | 
|---|
| 369 | sprintf((PCHAR)text, /*sizeof(text)-1,*/"mmioGetHeader error!"); | 
|---|
| 370 | WinMessageBox(hwnd, hwnd, (PSZ)"", | 
|---|
| 371 | text, | 
|---|
| 372 | 0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE ); | 
|---|
| 373 | break; | 
|---|
| 374 | } | 
|---|
| 375 |  | 
|---|
| 376 | /*******************************/ | 
|---|
| 377 | /* Set up/open the TARGET file */ | 
|---|
| 378 | /*******************************/ | 
|---|
| 379 | memset(&mmioinfo,0, sizeof(mmioinfo)); | 
|---|
| 380 | mmioinfo.ulTranslate = MMIO_TRANSLATEHEADER | MMIO_TRANSLATEDATA; | 
|---|
| 381 | mmioinfo.ulFlags=MMIO_WRITE|MMIO_CREATE; | 
|---|
| 382 |  | 
|---|
| 383 | //  mmioinfo.fccIOProc=mmioStringToFOURCC("WAVE", MMIO_TOUPPER); | 
|---|
| 384 | mmioinfo.fccIOProc=pMemFormatInfo[iIoProc].fccIOProc; | 
|---|
| 385 | if((hmmioTarget=mmioOpen(chrTargetName, &mmioinfo, MMIO_WRITE|MMIO_CREATE))==NULLHANDLE) | 
|---|
| 386 | { | 
|---|
| 387 | UCHAR chrError[64]; | 
|---|
| 388 | UCHAR text[CCHMAXPATH*2]; | 
|---|
| 389 | rc=mmioGetLastError(hmmioTarget); | 
|---|
| 390 | mciGetErrorString(mmioinfo.ulErrorRet ,chrError, sizeof(chrError)-1); | 
|---|
| 391 | sprintf((PCHAR)text, /*sizeof(text)-1,*/"mmioOpen error with file %s:\n%s\n%lu", chrTargetName, chrError,mmioinfo.ulErrorRet); | 
|---|
| 392 | mmioClose(hmmio,0); | 
|---|
| 393 | WinMessageBox(hwnd, hwnd, (PSZ)"", | 
|---|
| 394 | text, | 
|---|
| 395 | 0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE ); | 
|---|
| 396 | break; | 
|---|
| 397 | } | 
|---|
| 398 | /* Set parameters */ | 
|---|
| 399 | rc = mmioSetHeader(hmmioTarget, &mmAudioHeader,sizeof(MMAUDIOHEADER), | 
|---|
| 400 | &lBytesWritten, 0, 0); | 
|---|
| 401 |  | 
|---|
| 402 | /* Get buffer */ | 
|---|
| 403 | if((buffer=(PCHAR)malloc(CONVERTBUFFERSIZE))==NULLHANDLE) { | 
|---|
| 404 | UCHAR text[500]; | 
|---|
| 405 | mmioClose(hmmio, 0); | 
|---|
| 406 | mmioClose(hmmioTarget,0); | 
|---|
| 407 | sprintf((PCHAR)text, /*sizeof(text)-1,*/"Can't get memory buffer!"); | 
|---|
| 408 | WinMessageBox(hwnd, hwnd, (PSZ)"", | 
|---|
| 409 | text, | 
|---|
| 410 | 0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE ); | 
|---|
| 411 |  | 
|---|
| 412 | break; | 
|---|
| 413 | } | 
|---|
| 414 |  | 
|---|
| 415 | /* convert */ | 
|---|
| 416 | lBytesWritten=0; | 
|---|
| 417 | do{ | 
|---|
| 418 | rc=mmioRead(hmmio, buffer, CONVERTBUFFERSIZE); | 
|---|
| 419 | if(bBreak) | 
|---|
| 420 | break; | 
|---|
| 421 | if(rc!=0 && rc!=MMIO_ERROR ) { | 
|---|
| 422 | mmioWrite(hmmioTarget, buffer, rc); | 
|---|
| 423 | lBytesWritten+=rc; | 
|---|
| 424 | WinSendMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(MSG_CONVERTPERCENT), MPFROMLONG((lBytesWritten)/(lAudioSize/100))); | 
|---|
| 425 | } | 
|---|
| 426 | }while(rc!=0 && rc!=MMIO_ERROR && !bBreak/*&& lBytesWritten <1000000*/); | 
|---|
| 427 | if(rc==MMIO_ERROR) { | 
|---|
| 428 | UCHAR text[500]; | 
|---|
| 429 | sprintf((PCHAR)text, /*sizeof(text)-1,*/"Error while reading audio data!"); | 
|---|
| 430 | WinMessageBox(hwnd, hwnd, (PSZ)"", | 
|---|
| 431 | text, | 
|---|
| 432 | 0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE ); | 
|---|
| 433 | } | 
|---|
| 434 | if(!bBreak) { | 
|---|
| 435 | UCHAR chrCommand[CCHMAXPATH*2]; | 
|---|
| 436 | WinSendMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(MSG_CONVERTPERCENT), MPFROMLONG(100)); | 
|---|
| 437 | /* Refresh details view */ | 
|---|
| 438 | HlpSendCommandToObject(chrTargetName, (PSZ)"CWAUDIOREFRESH=1"); | 
|---|
| 439 | sprintf((PCHAR)chrCommand,"CWAUDIOCOPYTAGTO=%s;", chrTargetName); | 
|---|
| 440 | HlpSendCommandToObject(chrSourceName, chrCommand); | 
|---|
| 441 | } | 
|---|
| 442 | free(buffer); | 
|---|
| 443 | /* close source */ | 
|---|
| 444 | mmioClose(hmmio,0); | 
|---|
| 445 | /* close target */ | 
|---|
| 446 | mmioClose(hmmioTarget,0); | 
|---|
| 447 | break; | 
|---|
| 448 | } | 
|---|
| 449 | while(TRUE); | 
|---|
| 450 | WinSendMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(MSG_CONVERTDONE), 0); | 
|---|
| 451 | WinDestroyMsgQueue(hmq); | 
|---|
| 452 | } | 
|---|
| 453 | WinTerminate(hab); | 
|---|
| 454 | } | 
|---|
| 455 | tidThread=0; | 
|---|
| 456 | bBreak=FALSE; | 
|---|
| 457 | } | 
|---|
| 458 |  | 
|---|
| 459 | void convertAudioFile(HWND hwnd) | 
|---|
| 460 | { | 
|---|
| 461 | tidThread=_beginthread(convertThreadFunc,NULL,  8192*16, (void*)hwnd); //Fehlerbehandlung fehlt | 
|---|
| 462 | if(tidThread==-1) { | 
|---|
| 463 | DosBeep(100, 500); | 
|---|
| 464 | tidThread=0; | 
|---|
| 465 | } | 
|---|
| 466 | } | 
|---|
| 467 |  | 
|---|
| 468 | /* This Proc handles the on-the-fly data CD writing */ | 
|---|
| 469 | MRESULT EXPENTRY decodeStatusDialogProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 
|---|
| 470 | { | 
|---|
| 471 | UCHAR text[CCHMAXPATH*4 +10]; | 
|---|
| 472 | UCHAR title[CCHMAXPATH*4]; | 
|---|
| 473 | SWCNTRL swctl; | 
|---|
| 474 | PID pid; | 
|---|
| 475 | int iPercent; | 
|---|
| 476 |  | 
|---|
| 477 | switch (msg) | 
|---|
| 478 | { | 
|---|
| 479 | case WM_INITDLG: | 
|---|
| 480 |  | 
|---|
| 481 | /* Add switch entry */ | 
|---|
| 482 | memset(&swctl,0,sizeof(swctl)); | 
|---|
| 483 | WinQueryWindowProcess(hwnd,&pid,NULL); | 
|---|
| 484 | swctl.hwnd=hwnd; | 
|---|
| 485 | swctl.uchVisibility=SWL_VISIBLE; | 
|---|
| 486 | swctl.idProcess=pid; | 
|---|
| 487 | swctl.bProgType=PROG_DEFAULT; | 
|---|
| 488 | swctl.fbJump=SWL_JUMPABLE; | 
|---|
| 489 | WinAddSwitchEntry(&swctl); | 
|---|
| 490 |  | 
|---|
| 491 | #if 0 | 
|---|
| 492 | sprintf(text,"1: %s, 2: %s, 3: %s 4: %s 5: %s 6: %s",params[1],params[2],params[3], | 
|---|
| 493 | params[4], params[4],params[4]); | 
|---|
| 494 | WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, text, | 
|---|
| 495 | params[4], | 
|---|
| 496 | 0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE ); | 
|---|
| 497 | #endif | 
|---|
| 498 |  | 
|---|
| 499 | WinSendMsg(WinWindowFromID(hwnd,IDST_CONVERTNAME),EM_SETTEXTLIMIT,MPFROMSHORT((SHORT)CCHMAXPATH),0); | 
|---|
| 500 |  | 
|---|
| 501 | WinSetWindowText(WinWindowFromID(hwnd,IDST_CONVERTCDBITS), (PSZ)""); | 
|---|
| 502 |  | 
|---|
| 503 | /* Filename */ | 
|---|
| 504 | WinSetWindowText(WinWindowFromID(hwnd,IDST_CONVERTNAME), chrSourceName); | 
|---|
| 505 |  | 
|---|
| 506 | /* Set dialog font to WarpSans for Warp 4 and above */ | 
|---|
| 507 | if(SysQueryOSRelease()>=40) { | 
|---|
| 508 | WinSetPresParam(hwnd, | 
|---|
| 509 | PP_FONTNAMESIZE,(ULONG)sizeof(DEFAULT_DIALOG_FONT), | 
|---|
| 510 | DEFAULT_DIALOG_FONT ); | 
|---|
| 511 | } | 
|---|
| 512 |  | 
|---|
| 513 | /* Set percent bars to 0. */ | 
|---|
| 514 | WinSetWindowText(WinWindowFromID(hwnd,IDBAR_CONVERTPROGRESS),(PSZ)"0#0%"); | 
|---|
| 515 |  | 
|---|
| 516 | WinSendMsg(WinWindowFromID(hwnd,IDEF_CONVERTTARGETNAME), EM_SETTEXTLIMIT,MPFROMSHORT((SHORT)CCHMAXPATH),0); | 
|---|
| 517 | insertIOProcItems( WinWindowFromID(hwnd, IDDD_IOPROC) ); | 
|---|
| 518 | WinSetWindowText( WinWindowFromID(hwnd,IDEF_CONVERTTARGETNAME), chrTargetName ); | 
|---|
| 519 | WinEnableWindow( WinWindowFromID(hwnd,IDPB_CONVERTABORT), FALSE); | 
|---|
| 520 |  | 
|---|
| 521 | /* Channels */ | 
|---|
| 522 | getMessage(title, IDSTR_CONVERTCHANNELS, sizeof(title), RESSOURCEHANDLE, hwnd); | 
|---|
| 523 | sprintf((PCHAR)text, (PCHAR)title, sChannels); | 
|---|
| 524 | WinSetWindowText(WinWindowFromID(hwnd,IDST_CONVERTCHANNELS),text); | 
|---|
| 525 |  | 
|---|
| 526 | /* Samplerate */ | 
|---|
| 527 | getMessage(title, IDSTR_CONVERTSAMPLERATE, sizeof(title), RESSOURCEHANDLE, hwnd); | 
|---|
| 528 | sprintf((PCHAR)text, (PCHAR)title, iSampleRate); | 
|---|
| 529 | WinSetWindowText(WinWindowFromID(hwnd,IDST_CONVERTSAMPLERATE),text); | 
|---|
| 530 |  | 
|---|
| 531 | /* Playtime */ | 
|---|
| 532 | getMessage(title, IDSTR_CONVERTPLAYTIME, sizeof(title), RESSOURCEHANDLE, hwnd); | 
|---|
| 533 | sprintf((PCHAR)text, (PCHAR)title, lSec/60, lSec%60); | 
|---|
| 534 | WinSetWindowText(WinWindowFromID(hwnd,IDST_CONVERTPLAYTIME),text); | 
|---|
| 535 |  | 
|---|
| 536 | IniRestoreWindowPos(chrIniFile, INI_AUDIOCONV_APP, INI_WINDOWPOS_KEY, hwnd); | 
|---|
| 537 | IniRestoreWindowClrs(chrIniFile, INI_AUDIOCONV_APP , hwnd); | 
|---|
| 538 |  | 
|---|
| 539 | WinSetFocus(HWND_DESKTOP, hwnd); | 
|---|
| 540 | return (MRESULT) TRUE; | 
|---|
| 541 |  | 
|---|
| 542 | /* WM_APPTERMINATENOTIFY messages are sent from the helper programs e.g. format checker. */ | 
|---|
| 543 | case WM_APPTERMINATENOTIFY: | 
|---|
| 544 | switch(LONGFROMMP(mp1)) | 
|---|
| 545 | { | 
|---|
| 546 | case MSG_CONVERTERROR: | 
|---|
| 547 | case MSG_CONVERTDONE: | 
|---|
| 548 | WinEnableWindow( WinWindowFromID(hwnd,IDPB_CONVERTOK), TRUE); | 
|---|
| 549 | WinEnableWindow( WinWindowFromID(hwnd,IDPB_CONVERTABORT), FALSE); | 
|---|
| 550 | break; | 
|---|
| 551 | case  MSG_CONVERTPERCENT: | 
|---|
| 552 | iPercent=LONGFROMMP(mp2); | 
|---|
| 553 | if(iPercent>100) | 
|---|
| 554 | iPercent=100; | 
|---|
| 555 | if(iPercent<0) | 
|---|
| 556 | iPercent=0; | 
|---|
| 557 |  | 
|---|
| 558 | /* Update track percent bar value. The helper prog sends us the actual decoded %. */ | 
|---|
| 559 | sprintf(text,"%d#%d%%", iPercent, iPercent); | 
|---|
| 560 | WinSetWindowText(WinWindowFromID(hwnd,IDBAR_CONVERTPROGRESS), text); | 
|---|
| 561 | break; | 
|---|
| 562 | default: | 
|---|
| 563 | break; | 
|---|
| 564 | } | 
|---|
| 565 | return FALSE; | 
|---|
| 566 |  | 
|---|
| 567 | case WM_CLOSE: | 
|---|
| 568 | if(tidThread) { | 
|---|
| 569 | bBreak=TRUE; | 
|---|
| 570 | if(!WinStartTimer(WinQueryAnchorBlock(hwnd), hwnd, ID_TIMER, TIMER_DELAY)) | 
|---|
| 571 | { | 
|---|
| 572 | /* Save window position */ | 
|---|
| 573 | IniSaveWindowPos(chrIniFile, INI_AUDIOCONV_APP, INI_WINDOWPOS_KEY, hwnd); | 
|---|
| 574 | IniSaveWindowClrs(chrIniFile, INI_AUDIOCONV_APP , hwnd); | 
|---|
| 575 | WinDismissDlg(hwnd,0); | 
|---|
| 576 | } | 
|---|
| 577 | else | 
|---|
| 578 | return FALSE; | 
|---|
| 579 | } | 
|---|
| 580 | /* Save window position */ | 
|---|
| 581 | IniSaveWindowPos(chrIniFile, INI_AUDIOCONV_APP, INI_WINDOWPOS_KEY, hwnd); | 
|---|
| 582 | IniSaveWindowClrs(chrIniFile, INI_AUDIOCONV_APP , hwnd); | 
|---|
| 583 | WinDismissDlg(hwnd,0); | 
|---|
| 584 | return FALSE; | 
|---|
| 585 | case WM_CONTROL: | 
|---|
| 586 | if(SHORT1FROMMP(mp1)==IDDD_IOPROC) | 
|---|
| 587 | { | 
|---|
| 588 | if(SHORT2FROMMP(mp1)==EN_CHANGE) { | 
|---|
| 589 | SHORT sIdx; | 
|---|
| 590 | sIdx=SHORT1FROMMR(WinSendMsg(HWNDFROMMP(mp2),LM_QUERYSELECTION, MPFROMLONG(LIT_FIRST),0)); | 
|---|
| 591 | iIoProc=iPrivIOProc[sIdx]; | 
|---|
| 592 |  | 
|---|
| 593 | #ifdef DEBUG | 
|---|
| 594 | SysWriteToTrapLog("sIdx: %d  IO-Proc Idx: %d %s\n", sIdx, iPrivIOProc[sIdx], | 
|---|
| 595 | pMemFormatInfo[iIoProc].szDefaultFormatExt | 
|---|
| 596 | ); | 
|---|
| 597 | #endif | 
|---|
| 598 |  | 
|---|
| 599 | createTargetName(chrSourceName, pMemFormatInfo[iIoProc].szDefaultFormatExt); | 
|---|
| 600 | WinSetWindowText( WinWindowFromID(hwnd,IDEF_CONVERTTARGETNAME), chrTargetName ); | 
|---|
| 601 | } | 
|---|
| 602 | } | 
|---|
| 603 | break; | 
|---|
| 604 | case WM_TIMER: | 
|---|
| 605 | if(SHORT1FROMMP(mp1)==ID_TIMER) | 
|---|
| 606 | { | 
|---|
| 607 | if(!tidThread) { | 
|---|
| 608 | /* Convert thread ended. Quit. */ | 
|---|
| 609 | WinStopTimer(WinQueryAnchorBlock(hwnd), hwnd, ID_TIMER); | 
|---|
| 610 | WinPostMsg(hwnd, WM_CLOSE, 0, 0); | 
|---|
| 611 | } | 
|---|
| 612 | return MRFALSE; | 
|---|
| 613 | } | 
|---|
| 614 | break; | 
|---|
| 615 | case WM_COMMAND: | 
|---|
| 616 | switch(SHORT1FROMMP(mp1)) | 
|---|
| 617 | { | 
|---|
| 618 | case IDPB_CONVERTBROWSE: | 
|---|
| 619 | { | 
|---|
| 620 | UCHAR chrTitle[200]; | 
|---|
| 621 | FILEDLG fd = { 0 }; | 
|---|
| 622 | /* User pressed the browse button */ | 
|---|
| 623 | fd.cbSize = sizeof( fd ); | 
|---|
| 624 | /* It's an centered 'Open'-dialog */ | 
|---|
| 625 | fd.fl = FDS_OPEN_DIALOG|FDS_CENTER; | 
|---|
| 626 | /* Set the title of the file dialog */ | 
|---|
| 627 | fd.pszTitle = chrTitle; | 
|---|
| 628 | if(!getMessage(chrTitle, IDSTR_AUDIOBROWSETITLE, sizeof(chrTitle), RESSOURCEHANDLE, hwnd)) | 
|---|
| 629 | fd.pszTitle = "Wave name"; | 
|---|
| 630 | /* Only show * files */ | 
|---|
| 631 | //sprintf(fd.szFullFile,"%s","*"); | 
|---|
| 632 | strcpy(fd.szFullFile, chrTargetName); | 
|---|
| 633 | if( WinFileDlg( HWND_DESKTOP, hwnd, &fd ) == NULLHANDLE ) | 
|---|
| 634 | { | 
|---|
| 635 | /* WinFileDlg failed */ | 
|---|
| 636 | break; | 
|---|
| 637 | } | 
|---|
| 638 | if( fd.lReturn == DID_OK ) | 
|---|
| 639 | { | 
|---|
| 640 | WinSetWindowText( WinWindowFromID(hwnd,IDEF_CONVERTTARGETNAME), fd.szFullFile ); | 
|---|
| 641 | } | 
|---|
| 642 | break; | 
|---|
| 643 | } | 
|---|
| 644 | case IDPB_CONVERTCLOSE: | 
|---|
| 645 | bBreak=TRUE; | 
|---|
| 646 | if(!WinStartTimer(WinQueryAnchorBlock(hwnd), hwnd, ID_TIMER, TIMER_DELAY)) | 
|---|
| 647 | WinPostMsg(hwnd, WM_CLOSE, 0, 0);/* Timer error so do a hard quit */ | 
|---|
| 648 | break; | 
|---|
| 649 | case IDPB_CONVERTABORT: | 
|---|
| 650 | bBreak=TRUE; | 
|---|
| 651 | WinEnableWindow( WinWindowFromID(hwnd,IDPB_CONVERTABORT), FALSE); | 
|---|
| 652 | break; | 
|---|
| 653 | case IDPB_CONVERTOK: | 
|---|
| 654 | { | 
|---|
| 655 | FSALLOCATE fsAlloc; | 
|---|
| 656 | ULONG lFreeSpace; | 
|---|
| 657 | ULONG ulDiskNum; | 
|---|
| 658 | char cLetter; | 
|---|
| 659 | ULONG cUnitAvail; | 
|---|
| 660 |  | 
|---|
| 661 | WinQueryWindowText( WinWindowFromID(hwnd,IDEF_CONVERTTARGETNAME), sizeof(chrTargetName), chrTargetName ); | 
|---|
| 662 |  | 
|---|
| 663 | /* Check if diskspace is sufficient. Only for *.wav */ | 
|---|
| 664 | if(!stricmp(pMemFormatInfo[iIoProc].szDefaultFormatExt, "WAV")) { | 
|---|
| 665 | cLetter=tolower(chrTargetName[0]); | 
|---|
| 666 | ulDiskNum=cLetter-'a'+1; | 
|---|
| 667 | if(DosQueryFSInfo(ulDiskNum, FSIL_ALLOC,&fsAlloc,sizeof(fsAlloc))) | 
|---|
| 668 | lFreeSpace=0; | 
|---|
| 669 | else{ | 
|---|
| 670 | cUnitAvail=0xFFFFFFFF/(fsAlloc.cbSector*fsAlloc.cSectorUnit); | 
|---|
| 671 | if(fsAlloc.cUnitAvail > cUnitAvail) | 
|---|
| 672 | lFreeSpace=0xFFFFFFFF; | 
|---|
| 673 | else | 
|---|
| 674 | lFreeSpace=fsAlloc.cUnitAvail*fsAlloc.cbSector*fsAlloc.cSectorUnit; | 
|---|
| 675 | } | 
|---|
| 676 | } | 
|---|
| 677 | else | 
|---|
| 678 | lFreeSpace=lAudioSize; /* Fake sufficient space */ | 
|---|
| 679 |  | 
|---|
| 680 | if(lFreeSpace<lAudioSize) { | 
|---|
| 681 | /* | 
|---|
| 682 | Text: | 
|---|
| 683 | Title: | 
|---|
| 684 | */ | 
|---|
| 685 | getMessage(title, IDSTR_CONVERTNOSPACETEXT,sizeof(title), RESSOURCEHANDLE, hwnd); | 
|---|
| 686 | sprintf(text,title,lAudioSize/1000000 ); | 
|---|
| 687 | getMessage(title, IDSTR_CONVERTNOSPACETITLE,sizeof(title), RESSOURCEHANDLE, hwnd); | 
|---|
| 688 | WinMessageBox( HWND_DESKTOP, hwnd, text, | 
|---|
| 689 | title, | 
|---|
| 690 | 1234UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE ); | 
|---|
| 691 | } | 
|---|
| 692 | else { | 
|---|
| 693 | /* Start decoding an audio file */ | 
|---|
| 694 | WinEnableWindow( WinWindowFromID(hwnd,IDPB_CONVERTOK), FALSE); | 
|---|
| 695 | WinEnableWindow( WinWindowFromID(hwnd,IDPB_CONVERTABORT), TRUE); | 
|---|
| 696 | convertAudioFile(hwnd); | 
|---|
| 697 | } | 
|---|
| 698 |  | 
|---|
| 699 | break; | 
|---|
| 700 | } | 
|---|
| 701 | default: | 
|---|
| 702 | break; | 
|---|
| 703 | } | 
|---|
| 704 | return (MRESULT) FALSE; | 
|---|
| 705 | default: | 
|---|
| 706 | break; | 
|---|
| 707 | }/* switch */ | 
|---|
| 708 |  | 
|---|
| 709 | return WinDefDlgProc( hwnd, msg, mp1, mp2); | 
|---|
| 710 | } | 
|---|
| 711 |  | 
|---|
| 712 |  | 
|---|
| 713 | int main (int argc, char *argv[]) | 
|---|
| 714 | { | 
|---|
| 715 | HAB  hab; | 
|---|
| 716 | HMQ  hmq; | 
|---|
| 717 | char text[CCHMAXPATH]; | 
|---|
| 718 | char title[CCHMAXPATH]; | 
|---|
| 719 | short a; | 
|---|
| 720 |  | 
|---|
| 721 | /* Create a copy of the args */ | 
|---|
| 722 | /* argv[0]: progname | 
|---|
| 723 | * argv[1]: wavefile | 
|---|
| 724 | * argv[2]: IO proc name | 
|---|
| 725 | */ | 
|---|
| 726 |  | 
|---|
| 727 |  | 
|---|
| 728 | numArgs=argc; | 
|---|
| 729 |  | 
|---|
| 730 | for(a=0;a<argc;a++) | 
|---|
| 731 | { | 
|---|
| 732 | params[a]=argv[a]; | 
|---|
| 733 | } | 
|---|
| 734 |  | 
|---|
| 735 |  | 
|---|
| 736 | hab=WinInitialize(0); | 
|---|
| 737 | if(hab) { | 
|---|
| 738 | hmq=WinCreateMsgQueue(hab,0); | 
|---|
| 739 | if(hmq) { | 
|---|
| 740 | /* Check if user started prog by hand */ | 
|---|
| 741 | if(argc<NUMPARAMS-1) {/* Not the actual num of params */ | 
|---|
| 742 | pmUsage(); | 
|---|
| 743 | } | 
|---|
| 744 | else { | 
|---|
| 745 | /* Save source name */ | 
|---|
| 746 | strcpy(chrSourceName,params[1]); | 
|---|
| 747 | if(argc==NUMPARAMS) | 
|---|
| 748 | strcpy(chrProcName,params[2]); | 
|---|
| 749 | else { | 
|---|
| 750 | bNoProcGiven=TRUE; | 
|---|
| 751 | strcpy(chrProcName, ""); | 
|---|
| 752 | } | 
|---|
| 753 | /* Get our ressource dll */ | 
|---|
| 754 | //   RESSOURCEHANDLE=0; | 
|---|
| 755 | RESSOURCEHANDLE=queryResModuleHandle(argv[0]); | 
|---|
| 756 | HlpBuildMMProgIniFileName(argv[0], chrIniFile, sizeof(chrIniFile)); | 
|---|
| 757 | /* Register the percent bar window class */ | 
|---|
| 758 | percentRegisterBarClass(); | 
|---|
| 759 | /* Get audio file characteristics */ | 
|---|
| 760 | if(queryAudioInfo(chrSourceName)) { | 
|---|
| 761 | if( WinDlgBox( HWND_DESKTOP, NULLHANDLE, decodeStatusDialogProc, RESSOURCEHANDLE, IDDLG_CONVERT, 0) == DID_ERROR ) | 
|---|
| 762 | { | 
|---|
| 763 | /* | 
|---|
| 764 | Text: | 
|---|
| 765 | Title:  "Installation problem" | 
|---|
| 766 | */ | 
|---|
| 767 | messageBox( text, IDSTR_CONVERTDIALOGERROR , sizeof(text), | 
|---|
| 768 | title, IDSTR_INSTALLERRORTITLE , sizeof(title), | 
|---|
| 769 | RESSOURCEHANDLE, HWND_DESKTOP, MB_OK | MB_ICONEXCLAMATION | MB_MOVEABLE); | 
|---|
| 770 | freeResHandle(); | 
|---|
| 771 | WinDestroyMsgQueue( hmq ); | 
|---|
| 772 | WinTerminate( hab ); | 
|---|
| 773 | DosBeep(100,600); | 
|---|
| 774 | return( 1 ); | 
|---|
| 775 | } | 
|---|
| 776 | } | 
|---|
| 777 | } | 
|---|
| 778 | freeResHandle(); | 
|---|
| 779 | WinDestroyMsgQueue(hmq); | 
|---|
| 780 | } | 
|---|
| 781 | WinTerminate(hab); | 
|---|
| 782 | } | 
|---|
| 783 | return 0; | 
|---|
| 784 | } | 
|---|