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