Ignore:
Timestamp:
Oct 2, 2023, 11:34:35 PM (23 months ago)
Author:
gyoung
Message:

Remaining changes from merge with Lars 2.9 branch

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/classes/mm-progs/audioconverter/audconv.c

    r48 r104  
    1818 * along with this program; see the file COPYING.  If not, write to
    1919 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
    20  */         
     20 */
    2121/*
    2222 * If you need another license for your project/product (commercial,
    2323 * noncommercial, whatever) contact me at
    24  * 
     24 *
    2525 * http://www.os2world.com/cdwriting
    2626 * http://www.geocities.com/SiliconValley/Sector/5785/
     
    7070//#define INI_NAME_COLOR        "color"
    7171
    72 void HlpSendCommandToObject(char* chrObject, char* command);
     72void HlpSendCommandToObject(PSZ chrObject, PSZ command);
    7373BOOL 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);
     74BOOL IniSaveWindowPos(PSZ iniFile, PSZ chrApp, PSZ chrKey, HWND hwnd);
     75BOOL IniRestoreWindowPos(PSZ iniFile, PSZ chrApp, PSZ chrKey, HWND hwnd);
     76BOOL IniSaveWindowClrs(PSZ chrIniFile, PSZ chrApp , HWND hwnd);
     77BOOL IniRestoreWindowClrs(PSZ chrIniFile, PSZ chrApp , HWND hwnd);
     78BOOL HlpBuildMMProgIniFileName(PSZ chrProgname, PSZ chrBuffer, ULONG ulBufferSize);
     79HMODULE queryResModuleHandle(PSZ chrExePath);
    8080void 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,
     81BOOL getMessage(PSZ text,ULONG ulID, LONG lSizeText, HMODULE hResource,HWND hwnd);
     82ULONG messageBox( PSZ text, ULONG ulTextID , LONG lSizeText,
     83                  PSZ title, ULONG ulTitleID, LONG lSizeTitle,
    8484                  HMODULE hResource, HWND hwnd, ULONG ulFlags);
    8585
     
    9090BOOL bHaveWindowPos=FALSE;
    9191
    92 char chrTargetName[CCHMAXPATH]={0};
    93 char chrSourceName[CCHMAXPATH]={0};
    94 char chrProcName[CCHMAXPATH]={0};
    95 char chrIniFile[CCHMAXPATH];
     92UCHAR chrTargetName[CCHMAXPATH]={0};
     93UCHAR chrSourceName[CCHMAXPATH]={0};
     94UCHAR chrProcName[CCHMAXPATH]={0};
     95UCHAR chrIniFile[CCHMAXPATH];
    9696
    9797int numArgs;
     
    118118void pmUsage();
    119119
    120 BOOL createTargetName(char *sourceName, char *chrExt)
     120BOOL createTargetName(PSZ sourceName, PSZ chrExt)
    121121{
    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)
    126126    *textPtr=0;
    127127  else
    128     textPtr=chrTargetName;
     128    textPtr=(PCHAR)chrTargetName;
    129129  strcat(textPtr,".");
    130   strcat(textPtr, chrExt);
     130  strcat(textPtr, (PCHAR)chrExt);
    131131#if 0
    132132        WinMessageBox( HWND_DESKTOP, HWND_DESKTOP, textPtr,
     
    153153            '\0',
    154154            sizeof(MMFORMATINFO) );
    155    
     155
    156156    mmFormatInfo.ulMediaType |= MMIO_MEDIATYPE_AUDIO;
    157     mmFormatInfo.ulFlags|=MMIO_CANWRITETRANSLATED;   
     157    mmFormatInfo.ulFlags|=MMIO_CANWRITETRANSLATED;
    158158    ulReturnCode = mmioQueryFormatCount ( &mmFormatInfo,
    159159                                          &lNumIOProcs,
    160160                                          0,
    161161                                          0 );
    162    
     162
    163163    if( ulReturnCode != MMIO_SUCCESS )
    164164      {
     
    181181        return FALSE;
    182182      }
    183    
     183
    184184    /*
    185185     * call mmioGetFormats to get info on the formats supported.
     
    199199        return FALSE;
    200200      }
    201    
     201
    202202    if( lFormatsRead != lNumIOProcs )
    203203      {
     
    214214    for ( index = 0, sIdx=0; index <lNumIOProcs; index++ )
    215215      {
    216         char szName[CCHMAXPATH];
    217 
    218         mmioGetFormatName(pmmFormatInfoArray, szName, &lBytesRead, 0L, 0L);       
     216        UCHAR szName[CCHMAXPATH];
     217
     218        mmioGetFormatName(pmmFormatInfoArray, szName, &lBytesRead, 0L, 0L);
    219219        /* Insert NULL string terminator */
    220         *( szName + lBytesRead ) = (CHAR)NULL;
     220        *( szName + lBytesRead ) = 0;
    221221
    222222#ifdef DEBUG
    223         SysWriteToTrapLog("%d  IO-Proc: %s, %s\n", index, 
     223        SysWriteToTrapLog("%d  IO-Proc: %s, %s\n", index,
    224224                          pmmFormatInfoArray->szDefaultFormatExt,
    225225                          szName);
     
    231231            WinSendMsg(hwndDrop, LM_INSERTITEM,(MPARAM)LIT_END,
    232232                       (MPARAM)szName);
    233            
    234            
     233
     234
    235235            iPrivIOProc[sIdx]=index;
    236            
     236
    237237#ifdef DEBUG
    238238            SysWriteToTrapLog("-- %d  %d, sIdx: %d %s\n", index, iPrivIOProc[sIdx], sIdx,
     
    240240                              );
    241241#endif
    242            
    243            
     242
     243
    244244            /* Set text field */
    245245            if(bNoProcGiven) {
    246246              WinSetWindowText(hwndDrop, szName);
    247               createTargetName(chrSourceName, pmmFormatInfoArray->szDefaultFormatExt);
     247              createTargetName(chrSourceName, (PSZ)pmmFormatInfoArray->szDefaultFormatExt);
    248248              iIoProc=iPrivIOProc[sIdx];
    249249              bNoProcGiven=FALSE;
    250250            }
    251251            else {
    252               if(!stricmp(szName, chrProcName)) {
     252              if(!stricmp((PCHAR)szName, (PCHAR)chrProcName)) {
    253253                WinSetWindowText(hwndDrop, szName);
    254254                /* Create target name */
    255                 createTargetName(chrSourceName, pmmFormatInfoArray->szDefaultFormatExt);
     255                createTargetName(chrSourceName, (PSZ)pmmFormatInfoArray->szDefaultFormatExt);
    256256                iIoProc=iPrivIOProc[sIdx];
    257257              }
     
    262262        /*
    263263         *  advance to next entry in mmFormatInfo array
    264          */       
     264         */
    265265        pmmFormatInfoArray++;
    266266      }
     
    268268}
    269269
    270 BOOL queryAudioInfo(char *chrFile)
     270BOOL queryAudioInfo(PSZ chrFile)
    271271{
    272272  HMMIO hmmio;
     
    275275  LONG lBytesRead=0;
    276276  APIRET rc;
    277  
     277
    278278  memset(&mmioinfo,0, sizeof(mmioinfo));
    279279  mmioinfo.ulTranslate = MMIO_TRANSLATEHEADER;
     
    321321#endif
    322322
    323 void _Optlink convertThreadFunc (void *arg)
     323void convertThreadFunc (void *arg)
    324324{
    325325  HAB  hab;
     
    337337      LONG lBytesWritten=0;
    338338      ULONG rc;
    339       PBYTE buffer;
     339      PCHAR buffer=NULL;
    340340
    341341      do {
     
    349349        if((hmmio=mmioOpen(chrSourceName, &mmioinfo,MMIO_READ))==NULLHANDLE)
    350350          {
    351             char text[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)"",
    354354                          text,
    355355                          0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
     
    360360                           &lBytesRead, 0, 0);
    361361        if(rc!=MMIO_SUCCESS) {
    362           char text[500];
     362          UCHAR text[500];
    363363          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)"",
    366366                        text,
    367367                        0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
     
    380380        if((hmmioTarget=mmioOpen(chrTargetName, &mmioinfo, MMIO_WRITE|MMIO_CREATE))==NULLHANDLE)
    381381          {
    382             char chrError[CCHMAXPATH];
    383             char text[500];
     382            UCHAR chrError[64];
     383            UCHAR text[CCHMAXPATH*2];
    384384            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);
    387387            mmioClose(hmmio,0);
    388             WinMessageBox(hwnd, hwnd, "",
     388            WinMessageBox(hwnd, hwnd, (PSZ)"",
    389389                          text,
    390390                          0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
     
    394394        rc = mmioSetHeader(hmmioTarget, &mmAudioHeader,sizeof(MMAUDIOHEADER),
    395395                           &lBytesWritten, 0, 0);
    396        
     396
    397397        /* Get buffer */
    398         if((buffer=(void*)malloc(CONVERTBUFFERSIZE))==NULLHANDLE) {
    399           char text[500];
     398        if((buffer=(PCHAR)malloc(CONVERTBUFFERSIZE))==NULLHANDLE) {
     399          UCHAR text[500];
    400400          mmioClose(hmmio, 0);
    401401          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)"",
    404404                        text,
    405405                        0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
    406          
     406
    407407          break;
    408408        }
     
    421421        }while(rc!=0 && rc!=MMIO_ERROR && !bBreak/*&& lBytesWritten <1000000*/);
    422422        if(rc==MMIO_ERROR) {
    423           char text[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)"",
    426426                        text,
    427427                        0UL, MB_OK | MB_ICONEXCLAMATION|MB_MOVEABLE );
    428428        }
    429429        if(!bBreak) {
    430           char chrCommand[CCHMAXPATH*2];
     430          UCHAR chrCommand[CCHMAXPATH*2];
    431431          WinSendMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(MSG_CONVERTPERCENT), MPFROMLONG(100));
    432432          /* 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);
    435435          HlpSendCommandToObject(chrSourceName, chrCommand);
    436436        }
     
    443443      }
    444444      while(TRUE);
    445       WinSendMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(MSG_CONVERTDONE), 0);     
     445      WinSendMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(MSG_CONVERTDONE), 0);
    446446      WinDestroyMsgQueue(hmq);
    447447    }
     
    464464MRESULT EXPENTRY decodeStatusDialogProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
    465465{
    466   char text[CCHMAXPATH*4 +10];
    467   char title[CCHMAXPATH*4];
     466  UCHAR text[CCHMAXPATH*4 +10];
     467  UCHAR title[CCHMAXPATH*4];
    468468  SWCNTRL swctl;
    469469  PID pid;
     
    471471
    472472  switch (msg)
    473     {     
     473    {
    474474    case WM_INITDLG:
    475475
     
    493493
    494494      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
    498498      /* Filename */
    499499      WinSetWindowText(WinWindowFromID(hwnd,IDST_CONVERTNAME), chrSourceName);
    500      
     500
    501501      /* Set dialog font to WarpSans for Warp 4 and above */
    502502      if(SysQueryOSRelease()>=40) {
     
    507507
    508508      /* Set percent bars to 0. */
    509       WinSetWindowText(WinWindowFromID(hwnd,IDBAR_CONVERTPROGRESS),"0#0%");
     509      WinSetWindowText(WinWindowFromID(hwnd,IDBAR_CONVERTPROGRESS),(PSZ)"0#0%");
    510510
    511511      WinSendMsg(WinWindowFromID(hwnd,IDEF_CONVERTTARGETNAME), EM_SETTEXTLIMIT,MPFROMSHORT((SHORT)CCHMAXPATH),0);
     
    516516      /* Channels */
    517517      getMessage(title, IDSTR_CONVERTCHANNELS, sizeof(title), RESSOURCEHANDLE, hwnd);
    518       sprintf(text, title, sChannels);
     518      sprintf((PCHAR)text, (PCHAR)title, sChannels);
    519519      WinSetWindowText(WinWindowFromID(hwnd,IDST_CONVERTCHANNELS),text);
    520520
    521521      /* Samplerate */
    522522      getMessage(title, IDSTR_CONVERTSAMPLERATE, sizeof(title), RESSOURCEHANDLE, hwnd);
    523       sprintf(text, title, iSampleRate);
     523      sprintf((PCHAR)text, (PCHAR)title, iSampleRate);
    524524      WinSetWindowText(WinWindowFromID(hwnd,IDST_CONVERTSAMPLERATE),text);
    525525
    526526      /* Playtime */
    527527      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);
    529529      WinSetWindowText(WinWindowFromID(hwnd,IDST_CONVERTPLAYTIME),text);
    530530
     
    551551            iPercent=0;
    552552
    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 %. */
    554554          sprintf(text,"%d#%d%%", iPercent, iPercent);
    555555          WinSetWindowText(WinWindowFromID(hwnd,IDBAR_CONVERTPROGRESS), text);
     
    593593
    594594           createTargetName(chrSourceName, pMemFormatInfo[iIoProc].szDefaultFormatExt);
    595            WinSetWindowText( WinWindowFromID(hwnd,IDEF_CONVERTTARGETNAME), chrTargetName );           
     595           WinSetWindowText( WinWindowFromID(hwnd,IDEF_CONVERTTARGETNAME), chrTargetName );
    596596         }
    597597        }
     
    613613        case IDPB_CONVERTBROWSE:
    614614          {
    615             char chrTitle[200];
     615            UCHAR chrTitle[200];
    616616            FILEDLG fd = { 0 };
    617617            /* User pressed the browse button */
     
    652652            ULONG ulDiskNum;
    653653            char cLetter;
    654            
     654
    655655            WinQueryWindowText( WinWindowFromID(hwnd,IDEF_CONVERTTARGETNAME), sizeof(chrTargetName), chrTargetName );
    656656
     
    669669            if(lFreeSpace<lAudioSize) {
    670670              /*
    671                 Text:   
    672                 Title: 
    673                 */       
     671                Text:
     672                Title:
     673                */
    674674              getMessage(title, IDSTR_CONVERTNOSPACETEXT,sizeof(title), RESSOURCEHANDLE, hwnd);
    675675              sprintf(text,title,lAudioSize/1000000 );
     
    681681            else {
    682682              /* Start decoding an audio file */
    683               WinEnableWindow( WinWindowFromID(hwnd,IDPB_CONVERTOK), FALSE);           
     683              WinEnableWindow( WinWindowFromID(hwnd,IDPB_CONVERTOK), FALSE);
    684684              WinEnableWindow( WinWindowFromID(hwnd,IDPB_CONVERTABORT), TRUE);
    685685              convertAudioFile(hwnd);
    686686            }
    687            
     687
    688688            break;
    689689          }
     
    695695      break;
    696696    }/* switch */
    697  
     697
    698698  return WinDefDlgProc( hwnd, msg, mp1, mp2);
    699699}
     
    726726  if(hab) {
    727727    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 */
    730730      if(argc<NUMPARAMS-1) {/* Not the actual num of params */
    731731        pmUsage();
     
    740740          strcpy(chrProcName, "");
    741741        }
    742         /* Get our ressource dll */ 
     742        /* Get our ressource dll */
    743743        //   RESSOURCEHANDLE=0;
    744744        RESSOURCEHANDLE=queryResModuleHandle(argv[0]);
     
    751751            {
    752752              /*
    753                 Text:   
    754                 Title:  "Installation problem"                       
    755                 */             
     753                Text:
     754                Title:  "Installation problem"
     755                */
    756756              messageBox( text, IDSTR_CONVERTDIALOGERROR , sizeof(text),
    757757                          title, IDSTR_INSTALLERRORTITLE , sizeof(title),
     
    762762              DosBeep(100,600);
    763763              return( 1 );
    764             }   
     764            }
    765765        }
    766766      }
Note: See TracChangeset for help on using the changeset viewer.