| 1 | /*
|
|---|
| 2 | * (C) Chris Wohlgemuth 2002-2003
|
|---|
| 3 | *
|
|---|
| 4 | */
|
|---|
| 5 | /*
|
|---|
| 6 | * This program is free software; you can redistribute it and/or modify
|
|---|
| 7 | * it under the terms of the GNU General Public License as published by
|
|---|
| 8 | * the Free Software Foundation; either version 2, or (at your option)
|
|---|
| 9 | * any later version.
|
|---|
| 10 | *
|
|---|
| 11 | * This program is distributed in the hope that it will be useful,
|
|---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 14 | * GNU General Public License for more details.
|
|---|
| 15 | *
|
|---|
| 16 | * You should have received a copy of the GNU General Public License
|
|---|
| 17 | * along with this program; see the file COPYING. If not, write to
|
|---|
| 18 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|---|
| 19 | */
|
|---|
| 20 | /*
|
|---|
| 21 | * If you need another license for your project/product contact me at
|
|---|
| 22 | *
|
|---|
| 23 | * http://www.os2world.com/cdwriting
|
|---|
| 24 | * http://www.geocities.com/SiliconValley/Sector/5785/
|
|---|
| 25 | */
|
|---|
| 26 |
|
|---|
| 27 | /*
|
|---|
| 28 | * This file was generated by the SOM Compiler and Emitter Framework.
|
|---|
| 29 | * Generated using:
|
|---|
| 30 | * SOM Emitter emitctm: 2.42
|
|---|
| 31 | */
|
|---|
| 32 |
|
|---|
| 33 | #ifndef SOM_Module_cwaudio_Source
|
|---|
| 34 | #define SOM_Module_cwaudio_Source
|
|---|
| 35 | #endif
|
|---|
| 36 | #define CWAudio_Class_Source
|
|---|
| 37 | #define M_CWAudio_Class_Source
|
|---|
| 38 |
|
|---|
| 39 | #define INCL_PM
|
|---|
| 40 | #define INCL_DOS
|
|---|
| 41 | #define INCL_WINWORKPLACE
|
|---|
| 42 | #define INCL_MMIOOS2
|
|---|
| 43 | #define INCL_DOSDEVIOCTL
|
|---|
| 44 | #define INCL_MCIOS2
|
|---|
| 45 | #define INCL_ERRORS
|
|---|
| 46 |
|
|---|
| 47 | #include <os2.h>
|
|---|
| 48 | #include <stdio.h>
|
|---|
| 49 | #include "os2me.h"
|
|---|
| 50 | #include "cwmmdataf.h"
|
|---|
| 51 | #include "cwaudio.ih"
|
|---|
| 52 | #include "except.h"
|
|---|
| 53 | #include "cwaudioinc.h"
|
|---|
| 54 | #include "cwmp3inc.h" /* */
|
|---|
| 55 | #include "cwogginc.h" /* */
|
|---|
| 56 | #include <wpdisk.h>
|
|---|
| 57 | #include <wpfolder.h>
|
|---|
| 58 |
|
|---|
| 59 | #include "ea_funcs.h" /* Functions to read and write EA of file system objects */
|
|---|
| 60 | #include "som_wps_funcs.h"
|
|---|
| 61 | #include "sys_funcs.h"
|
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 | /* Redefine function names */
|
|---|
| 65 | #define cwGetStringFromEA EARestoreString
|
|---|
| 66 | #define cwSaveStringToEA EASaveString
|
|---|
| 67 |
|
|---|
| 68 | char classDLLPath[CCHMAXPATH]={0};
|
|---|
| 69 | char chrHelpLibrary[CCHMAXPATH]={0};
|
|---|
| 70 | char chrInstallDir[CCHMAXPATH]={0};
|
|---|
| 71 | char chrMMAudioExt[200]={0};/* Array holding the extensions for wpclsQueryInstanceFilter() */
|
|---|
| 72 | char resDLLPath[CCHMAXPATH]={0};
|
|---|
| 73 |
|
|---|
| 74 | static PSZ pszAudioColTitles[NUM_AUDIO_FIELDS]= {"Playtime", "Bitrate", "Samplerate", "Channels", "Bits per sample",
|
|---|
| 75 | "Track Name","Artist","Album","Year","Comment","Genre"};
|
|---|
| 76 |
|
|---|
| 77 | char chrPlayTime[SIZE_TITLE]="";
|
|---|
| 78 | char chrBitRate[SIZE_TITLE]=""; /* New with 0.2.7 */
|
|---|
| 79 | char chrSampleRate[SIZE_TITLE]="";
|
|---|
| 80 | char chrChannels[SIZE_TITLE]="";
|
|---|
| 81 | char chrBPS[SIZE_TITLE]="";
|
|---|
| 82 | char chrName[SIZE_TITLE]="";
|
|---|
| 83 | char chrArtist[SIZE_TITLE]="";
|
|---|
| 84 | char chrAlbum[SIZE_TITLE]="";
|
|---|
| 85 | char chrYear[SIZE_TITLE]="";
|
|---|
| 86 | char chrComment[SIZE_TITLE]="";
|
|---|
| 87 | char chrGenre[SIZE_TITLE]="";
|
|---|
| 88 |
|
|---|
| 89 | static CLASSFIELDINFO cfiFieldInfo[NUM_AUDIO_FIELDS];
|
|---|
| 90 |
|
|---|
| 91 | extern PMMFORMATINFO g_pmmFormatInfoArray; /* in cwimage.c */
|
|---|
| 92 | extern LONG lNumIOProcs;/* Needed to know how many convert menus we have */
|
|---|
| 93 | int iRunningAudioFiles=0; /* Used to check if there's already an audio file started */
|
|---|
| 94 |
|
|---|
| 95 | extern char *genreList[];
|
|---|
| 96 | extern int iGenreLast;
|
|---|
| 97 |
|
|---|
| 98 | /* Global var with HAB */
|
|---|
| 99 | extern HAB globalHab;
|
|---|
| 100 |
|
|---|
| 101 | extern ULONG globalClassVolume;
|
|---|
| 102 |
|
|---|
| 103 | HWND globalHwndObjectPlay;
|
|---|
| 104 | MMAudio* globalObjectPlay;
|
|---|
| 105 |
|
|---|
| 106 | HMODULE queryModuleHandle(void);
|
|---|
| 107 | HMODULE queryResModuleHandle(void);
|
|---|
| 108 | PSZ queryModuleName(void);
|
|---|
| 109 | BOOL getMessage(char* text,ULONG ulID, LONG lSizeText, HMODULE hResource,HWND hwnd);
|
|---|
| 110 | ULONG messageBox( char* text, ULONG ulTextID , LONG lSizeText,
|
|---|
| 111 | char* title, ULONG ulTitleID, LONG lSizeTitle,
|
|---|
| 112 | HMODULE hResource, HWND hwnd, ULONG ulFlags);
|
|---|
| 113 |
|
|---|
| 114 | BOOL cwQueryCDDrives(int *iNumCD, int * iFirstDrive);
|
|---|
| 115 | void HlpSendCommandToObject(char* chrObject, char* command);
|
|---|
| 116 | PSZ _queryMp3HelpLibraryName(void);
|
|---|
| 117 | BOOL cwMoveNotebookButtonsWarp4(HWND hwndDlg, USHORT usID, USHORT usDelta);
|
|---|
| 118 | BOOL cwObjectIsOnCD(WPObject * somSelf);
|
|---|
| 119 | PSZ queryInstallDir(void);
|
|---|
| 120 |
|
|---|
| 121 | BOOL mmclsSetObjectType(WPFileSystem * somSelf);
|
|---|
| 122 | BOOL mmclsCreateTheDefaultTemplate(M_WPObject *somSelf,
|
|---|
| 123 | WPObject* Folder);
|
|---|
| 124 | ULONG launchPMProg(PSZ pszTitle, PSZ wrapperExe, PSZ parameters, WPObject *thisPtr, ULONG ulView);
|
|---|
| 125 | BOOL getStringFromRexxScript(PSZ rexxFile, char* chrResult, ULONG ulSize);
|
|---|
| 126 |
|
|---|
| 127 | /* Max string length for the EA values e.g. the trackname. If this value is increased the
|
|---|
| 128 | retstring length in the REXX function handler rxCallCWMMFunc() must also be increased! */
|
|---|
| 129 | #define MAX_EA_SIZE 256
|
|---|
| 130 |
|
|---|
| 131 |
|
|---|
| 132 |
|
|---|
| 133 | static PBYTE _readTrackInfoIntoMem(MMAudio *somSelf, char * chrEAName, PBYTE pByte, ULONG ulSize)
|
|---|
| 134 | {
|
|---|
| 135 | if(cwGetStringFromEA(somSelf, chrEAName , pByte, ulSize))
|
|---|
| 136 | {
|
|---|
| 137 | PBYTE pEAValue;
|
|---|
| 138 | ULONG ul, len;
|
|---|
| 139 |
|
|---|
| 140 | len=strlen(pByte);
|
|---|
| 141 | if( (pEAValue=_wpAllocMem(somSelf, len+1, &ul))!=NULLHANDLE) {
|
|---|
| 142 | strncpy(pEAValue, pByte, len);
|
|---|
| 143 | pEAValue[len]=0;
|
|---|
| 144 | return pEAValue;
|
|---|
| 145 | }
|
|---|
| 146 | }
|
|---|
| 147 | return NULLHANDLE;
|
|---|
| 148 | }
|
|---|
| 149 |
|
|---|
| 150 | void _fillEntryfieldsWithCurrentTrackNames( MMAudio *cwAudio, HWND hwnd)
|
|---|
| 151 | {
|
|---|
| 152 | MMAudioData *somThis = MMAudioGetData(cwAudio);
|
|---|
| 153 |
|
|---|
| 154 | if(_pszName)
|
|---|
| 155 | WinSetWindowText(WinWindowFromID(hwnd,IDEF_ID3NAME), _pszName);
|
|---|
| 156 | else
|
|---|
| 157 | WinSetWindowText(WinWindowFromID(hwnd,IDEF_ID3NAME), "");
|
|---|
| 158 |
|
|---|
| 159 | if(_pszArtist)
|
|---|
| 160 | WinSetWindowText(WinWindowFromID(hwnd, IDEF_ID3ARTIST), _pszArtist);
|
|---|
| 161 | else
|
|---|
| 162 | WinSetWindowText(WinWindowFromID(hwnd, IDEF_ID3ARTIST), "");
|
|---|
| 163 |
|
|---|
| 164 | if(_pszAlbum)
|
|---|
| 165 | WinSetWindowText(WinWindowFromID(hwnd,IDEF_ID3ALBUM), _pszAlbum);
|
|---|
| 166 | else
|
|---|
| 167 | WinSetWindowText(WinWindowFromID(hwnd,IDEF_ID3ALBUM), "");
|
|---|
| 168 |
|
|---|
| 169 | if(_pszComment)
|
|---|
| 170 | WinSetWindowText(WinWindowFromID(hwnd, IDEF_ID3COMMENT), _pszComment);
|
|---|
| 171 | else
|
|---|
| 172 | WinSetWindowText(WinWindowFromID(hwnd, IDEF_ID3COMMENT), "");
|
|---|
| 173 |
|
|---|
| 174 | if(_pszYear)
|
|---|
| 175 | WinSetWindowText(WinWindowFromID(hwnd,IDEF_ID3YEAR), _pszYear);
|
|---|
| 176 | else
|
|---|
| 177 | WinSetWindowText(WinWindowFromID(hwnd,IDEF_ID3YEAR), "");
|
|---|
| 178 |
|
|---|
| 179 | if(_pszGenre)
|
|---|
| 180 | WinSetWindowText(WinWindowFromID(hwnd,IDDD_ID3GENRE), _pszGenre);
|
|---|
| 181 | else
|
|---|
| 182 | WinSetWindowText(WinWindowFromID(hwnd,IDDD_ID3GENRE), "");
|
|---|
| 183 |
|
|---|
| 184 | #if 0
|
|---|
| 185 | if(_cwmmQueryTrackInfo(cwAudio, &chr, sizeof(tempChar), IDINFO_NAME))
|
|---|
| 186 | WinSetWindowText(WinWindowFromID(hwnd,IDEF_ID3NAME), chr);
|
|---|
| 187 | if(_cwmmQueryTrackInfo(cwAudio, &chr, sizeof(tempChar), IDINFO_ARTIST))
|
|---|
| 188 | WinSetWindowText(WinWindowFromID(hwnd, IDEF_ID3ARTIST),tempChar);
|
|---|
| 189 | if(_cwmmQueryTrackInfo(cwAudio, &chr, sizeof(tempChar), IDINFO_ALBUM))
|
|---|
| 190 | WinSetWindowText(WinWindowFromID(hwnd,IDEF_ID3ALBUM),tempChar);
|
|---|
| 191 | if(_cwmmQueryTrackInfo(cwAudio, &chr, sizeof(tempChar), IDINFO_COMMENT))
|
|---|
| 192 | WinSetWindowText(WinWindowFromID(hwnd, IDEF_ID3COMMENT),tempChar);
|
|---|
| 193 | if(_cwmmQueryTrackInfo(cwAudio, &chr, sizeof(tempChar), IDINFO_YEAR))
|
|---|
| 194 | WinSetWindowText(WinWindowFromID(hwnd,IDEF_ID3YEAR),tempChar);
|
|---|
| 195 | if(_cwmmQueryTrackInfo(cwAudio, &chr, sizeof(tempChar), IDINFO_GENRE))
|
|---|
| 196 | WinSetWindowText(WinWindowFromID(hwnd,IDDD_ID3GENRE),tempChar);
|
|---|
| 197 | #endif
|
|---|
| 198 | }
|
|---|
| 199 |
|
|---|
| 200 | /****************************************************************/
|
|---|
| 201 | /* */
|
|---|
| 202 | /* */
|
|---|
| 203 | /* */
|
|---|
| 204 | /* */
|
|---|
| 205 | /****************************************************************/
|
|---|
| 206 | static PBYTE _readTrackInfoFromTextFieldIntoMem(MMAudio *somSelf, PBYTE pByte, HWND hwnd)
|
|---|
| 207 | {
|
|---|
| 208 | ULONG ulLen;
|
|---|
| 209 | PBYTE pNewText;
|
|---|
| 210 | ULONG ul;
|
|---|
| 211 |
|
|---|
| 212 | ulLen=WinQueryWindowTextLength(hwnd)+1;
|
|---|
| 213 |
|
|---|
| 214 | /* Alloc mem for new string */
|
|---|
| 215 | if( (pNewText=_wpAllocMem(somSelf, ulLen, &ul))!=NULLHANDLE) {
|
|---|
| 216 | WinQueryWindowText(hwnd, ulLen, pNewText);
|
|---|
| 217 | _wpFreeMem(somSelf, pByte);
|
|---|
| 218 |
|
|---|
| 219 | return pNewText;
|
|---|
| 220 | }
|
|---|
| 221 |
|
|---|
| 222 | return pByte;
|
|---|
| 223 | }
|
|---|
| 224 |
|
|---|
| 225 | /****************************************************************/
|
|---|
| 226 | /* */
|
|---|
| 227 | /* WNDPROC: trackNameDlgProc() */
|
|---|
| 228 | /* */
|
|---|
| 229 | /* Window procedure handling the track information settings */
|
|---|
| 230 | /* page. The user may use the page to edit the information. */
|
|---|
| 231 | /* */
|
|---|
| 232 | /****************************************************************/
|
|---|
| 233 | static MRESULT EXPENTRY trackNameDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|---|
| 234 | {
|
|---|
| 235 | MMAudio *cwAudio;
|
|---|
| 236 |
|
|---|
| 237 |
|
|---|
| 238 | switch(msg) {
|
|---|
| 239 | case WM_INITDLG :
|
|---|
| 240 | cwAudio=(MMAudio*)PVOIDFROMMP(mp2);
|
|---|
| 241 |
|
|---|
| 242 | WinSetWindowULong(WinWindowFromID(hwnd,IDEF_ID3NAME),
|
|---|
| 243 | QWL_USER,(ULONG)cwAudio);//Save object ptr.
|
|---|
| 244 |
|
|---|
| 245 | if(somIsObj(cwAudio)) {
|
|---|
| 246 | int a;
|
|---|
| 247 | HWND hwndTemp;
|
|---|
| 248 | char name[50];
|
|---|
| 249 | MMAudioData *somThis = MMAudioGetData(cwAudio);
|
|---|
| 250 | /* Move default buttons on Warp 4 */
|
|---|
| 251 | cwMoveNotebookButtonsWarp4(hwnd, IDPB_ID3HELP, 15);
|
|---|
| 252 |
|
|---|
| 253 | if(!getMessage(name, IDSTR_TRACKNAME, sizeof(name), queryResModuleHandle(), hwnd))
|
|---|
| 254 | strcpy(name, "Track name");
|
|---|
| 255 | WinSetWindowText(WinWindowFromID(hwnd,IDGB_ID3TAGS), name);
|
|---|
| 256 |
|
|---|
| 257 | WinSendMsg(WinWindowFromID(hwnd,IDEF_ID3NAME),EM_SETTEXTLIMIT,MPFROMSHORT((SHORT)MAX_EA_SIZE-1),0);
|
|---|
| 258 | WinSendMsg(WinWindowFromID(hwnd,IDEF_ID3ARTIST),EM_SETTEXTLIMIT,MPFROMSHORT((SHORT)MAX_EA_SIZE-1),0);
|
|---|
| 259 | WinSendMsg(WinWindowFromID(hwnd,IDEF_ID3ALBUM),EM_SETTEXTLIMIT,MPFROMSHORT((SHORT)MAX_EA_SIZE-1),0);
|
|---|
| 260 | WinSendMsg(WinWindowFromID(hwnd,IDEF_ID3COMMENT),EM_SETTEXTLIMIT,MPFROMSHORT((SHORT)MAX_EA_SIZE-1),0);
|
|---|
| 261 | WinSendMsg(WinWindowFromID(hwnd,IDEF_ID3YEAR),EM_SETTEXTLIMIT,MPFROMSHORT((SHORT)MAX_EA_SIZE-1),0);
|
|---|
| 262 | WinSendMsg(WinWindowFromID(hwnd,IDDD_ID3GENRE),EM_SETTEXTLIMIT,MPFROMSHORT((SHORT)MAX_EA_SIZE-1),0);
|
|---|
| 263 | #if 0
|
|---|
| 264 | WinSendMsg(WinWindowFromID(hwnd,IDEF_ID3NAME),EM_SETTEXTLIMIT,MPFROMSHORT((SHORT)sizeof(_id3Name)-1),0);
|
|---|
| 265 | WinSendMsg(WinWindowFromID(hwnd,IDEF_ID3ARTIST),EM_SETTEXTLIMIT,MPFROMSHORT((SHORT)sizeof(_id3Artist)-1),0);
|
|---|
| 266 | WinSendMsg(WinWindowFromID(hwnd,IDEF_ID3ALBUM),EM_SETTEXTLIMIT,MPFROMSHORT((SHORT)sizeof(_id3Album)-1),0);
|
|---|
| 267 | WinSendMsg(WinWindowFromID(hwnd,IDEF_ID3COMMENT),EM_SETTEXTLIMIT,MPFROMSHORT((SHORT)sizeof(_id3Comment)-1),0);
|
|---|
| 268 | WinSendMsg(WinWindowFromID(hwnd,IDEF_ID3YEAR),EM_SETTEXTLIMIT,MPFROMSHORT((SHORT)sizeof(_id3Year)-1),0);
|
|---|
| 269 | #endif
|
|---|
| 270 | /* Fill drop downlist with knwon genres */
|
|---|
| 271 | hwndTemp=WinWindowFromID(hwnd, IDDD_ID3GENRE);
|
|---|
| 272 | for(a=0;a<=iGenreLast;a++)
|
|---|
| 273 | WinSendMsg(hwndTemp, LM_INSERTITEM, MPFROMSHORT(LIT_SORTASCENDING),MPFROMP(genreList[a]));
|
|---|
| 274 | _fillEntryfieldsWithCurrentTrackNames( cwAudio, hwnd);
|
|---|
| 275 | }
|
|---|
| 276 | WinSetWindowULong(WinQueryWindow(hwnd, QW_PARENT), QWL_HWNDFOCUSSAVE, hwnd);
|
|---|
| 277 | return (MRESULT)TRUE;
|
|---|
| 278 | /* This prevents switching the notebook page behind the open folder */
|
|---|
| 279 | case WM_WINDOWPOSCHANGED:
|
|---|
| 280 | {
|
|---|
| 281 | MRESULT mr;
|
|---|
| 282 |
|
|---|
| 283 | if(WinQueryFocus(HWND_DESKTOP)!=
|
|---|
| 284 | WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT), QW_PARENT)) {
|
|---|
| 285 | mp2=MPFROMLONG(LONGFROMMP(mp2)|0x80000);/*AWP_ACTIVATE 0x00080000L*/
|
|---|
| 286 | mr=WinDefDlgProc(hwnd, msg, mp1, mp2);
|
|---|
| 287 | return mr;
|
|---|
| 288 | }
|
|---|
| 289 | break;
|
|---|
| 290 | }
|
|---|
| 291 | case WM_FOCUSCHANGE:
|
|---|
| 292 | {
|
|---|
| 293 | if(!SHORT1FROMMP(mp2)) {
|
|---|
| 294 | if(HWNDFROMMP(mp1)==hwnd) {
|
|---|
| 295 | MRESULT mr;
|
|---|
| 296 |
|
|---|
| 297 | mr=WinDefDlgProc(hwnd, msg, mp1, mp2);
|
|---|
| 298 | WinSendMsg(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT), QW_PARENT), WM_SETFOCUS, MPFROMHWND(hwnd),
|
|---|
| 299 | (MPARAM)TRUE);
|
|---|
| 300 | return mr;
|
|---|
| 301 | }
|
|---|
| 302 | }
|
|---|
| 303 | break;
|
|---|
| 304 | }
|
|---|
| 305 | case WM_DESTROY:
|
|---|
| 306 | /* The notebook closes and gets destroyed */
|
|---|
| 307 | /* Set focus to desktop to prevent PM freeze */
|
|---|
| 308 | WinSetFocus(HWND_DESKTOP, HWND_DESKTOP);
|
|---|
| 309 | break;
|
|---|
| 310 | case WM_COMMAND:
|
|---|
| 311 | cwAudio=(MMAudio*) WinQueryWindowULong(WinWindowFromID(hwnd, IDEF_ID3NAME),QWL_USER);
|
|---|
| 312 | if(somIsObj(cwAudio)) {
|
|---|
| 313 | // char fName[100];
|
|---|
| 314 |
|
|---|
| 315 | switch(SHORT1FROMMP(mp1))
|
|---|
| 316 | {
|
|---|
| 317 | case IDPB_CANCEL:
|
|---|
| 318 | _fillEntryfieldsWithCurrentTrackNames( cwAudio, hwnd);
|
|---|
| 319 | break;
|
|---|
| 320 | case IDPB_ID3SAVE:
|
|---|
| 321 | {
|
|---|
| 322 | MMAudioData *somThis = MMAudioGetData(cwAudio);
|
|---|
| 323 |
|
|---|
| 324 | _pszName=_readTrackInfoFromTextFieldIntoMem(cwAudio, _pszName, WinWindowFromID(hwnd, IDEF_ID3NAME));
|
|---|
| 325 | _pszArtist=_readTrackInfoFromTextFieldIntoMem(cwAudio, _pszArtist, WinWindowFromID(hwnd, IDEF_ID3ARTIST));
|
|---|
| 326 | _pszAlbum=_readTrackInfoFromTextFieldIntoMem(cwAudio, _pszAlbum, WinWindowFromID(hwnd, IDEF_ID3ALBUM));
|
|---|
| 327 | _pszComment=_readTrackInfoFromTextFieldIntoMem(cwAudio, _pszComment, WinWindowFromID(hwnd, IDEF_ID3COMMENT));
|
|---|
| 328 | _pszYear=_readTrackInfoFromTextFieldIntoMem(cwAudio, _pszYear, WinWindowFromID(hwnd, IDEF_ID3YEAR));
|
|---|
| 329 | _pszGenre=_readTrackInfoFromTextFieldIntoMem(cwAudio, _pszGenre, WinWindowFromID(hwnd, IDDD_ID3GENRE));
|
|---|
| 330 | #if 0
|
|---|
| 331 | WinQueryWindowText(WinWindowFromID(hwnd, IDEF_ID3NAME), 100, fName);
|
|---|
| 332 | _cwmmSetTrackInfo(cwAudio, fName, 0, IDINFO_NAME);
|
|---|
| 333 | WinQueryWindowText(WinWindowFromID(hwnd, IDEF_ID3ARTIST), 100, fName);
|
|---|
| 334 | _cwmmSetTrackInfo(cwAudio, fName, 0, IDINFO_ARTIST);
|
|---|
| 335 | WinQueryWindowText(WinWindowFromID(hwnd, IDEF_ID3ALBUM), 100, fName);
|
|---|
| 336 | _cwmmSetTrackInfo(cwAudio, fName, 0, IDINFO_ALBUM);
|
|---|
| 337 | WinQueryWindowText(WinWindowFromID(hwnd, IDEF_ID3COMMENT), 100, fName);
|
|---|
| 338 | _cwmmSetTrackInfo(cwAudio, fName, 0, IDINFO_COMMENT);
|
|---|
| 339 | WinQueryWindowText(WinWindowFromID(hwnd, IDEF_ID3YEAR), 100, fName);
|
|---|
| 340 | _cwmmSetTrackInfo(cwAudio, fName, 0, IDINFO_YEAR);
|
|---|
| 341 | /* Find genre */
|
|---|
| 342 | WinQueryWindowText(WinWindowFromID(hwnd, IDDD_ID3GENRE), 100, fName);
|
|---|
| 343 | _cwmmSetTrackInfo(cwAudio, fName, 0, IDINFO_GENRE);
|
|---|
| 344 | #endif
|
|---|
| 345 | _wpSaveDeferred(cwAudio);
|
|---|
| 346 | }
|
|---|
| 347 | break;
|
|---|
| 348 | default:
|
|---|
| 349 | break;
|
|---|
| 350 | }
|
|---|
| 351 | }
|
|---|
| 352 | return (MRESULT) TRUE;
|
|---|
| 353 | default:
|
|---|
| 354 | break;
|
|---|
| 355 | }
|
|---|
| 356 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
|---|
| 357 | }
|
|---|
| 358 |
|
|---|
| 359 | /****************************************************************/
|
|---|
| 360 | /* */
|
|---|
| 361 | /* METHOD: cwmmAddTrackNamePage() */
|
|---|
| 362 | /* */
|
|---|
| 363 | /* Insert new settings notebook page showing track information. */
|
|---|
| 364 | /* The user may use this page to edit the information */
|
|---|
| 365 | /* */
|
|---|
| 366 | /****************************************************************/
|
|---|
| 367 | SOM_Scope ULONG SOMLINK cwaudio_cwmmAddTrackNamePage(MMAudio *somSelf,
|
|---|
| 368 | HWND hwndNotebook)
|
|---|
| 369 | {
|
|---|
| 370 | PAGEINFO pageinfo;
|
|---|
| 371 | char pageName[100];
|
|---|
| 372 |
|
|---|
| 373 | /* MMAudioData *somThis = MMAudioGetData(somSelf);*/
|
|---|
| 374 | MMAudioMethodDebug("MMAudio","cwaudio_cwmmAddTrackNamePage");
|
|---|
| 375 |
|
|---|
| 376 | //Clear the pageinfo structure
|
|---|
| 377 | memset((PCH)&pageinfo, 0, sizeof(PAGEINFO));
|
|---|
| 378 | //Fill the pageinfo structure
|
|---|
| 379 | pageinfo.cb = sizeof(PAGEINFO);
|
|---|
| 380 | pageinfo.hwndPage = NULLHANDLE;
|
|---|
| 381 | pageinfo.usPageStyleFlags = BKA_MAJOR | BKA_STATUSTEXTON;
|
|---|
| 382 | pageinfo.usPageInsertFlags = BKA_FIRST;
|
|---|
| 383 | //We want page numbers
|
|---|
| 384 | pageinfo.usSettingsFlags = SETTINGS_PAGE_NUMBERS;
|
|---|
| 385 | //The dialog procedure for this page
|
|---|
| 386 | pageinfo.pfnwp = trackNameDlgProc;
|
|---|
| 387 | //The resource DLL
|
|---|
| 388 | pageinfo.resid = queryResModuleHandle();
|
|---|
| 389 | //pageinfo.resid = queryModuleHandle();
|
|---|
| 390 | //The ID of the dialog template
|
|---|
| 391 | pageinfo.dlgid = IDDLG_ID3TAGS;
|
|---|
| 392 | //We need a pointer to our WPS-object in the dialog procedure
|
|---|
| 393 | //to call class functions
|
|---|
| 394 | pageinfo.pCreateParams = somSelf;
|
|---|
| 395 | //The ID of the help panel for this page
|
|---|
| 396 | pageinfo.idDefaultHelpPanel = TRACKNAME_SETTINGS_PANEL;
|
|---|
| 397 | //Tell the WPS the help library name
|
|---|
| 398 | pageinfo.pszHelpLibraryName = _queryMp3HelpLibraryName();
|
|---|
| 399 | //We have a major tab so we need a name
|
|---|
| 400 | if(!getMessage(pageName, ID_TRACKNAMEPAGENAME, sizeof(pageName), queryResModuleHandle(), hwndNotebook))
|
|---|
| 401 | strcpy(pageName, "~Track name");
|
|---|
| 402 | pageinfo.pszName = pageName;
|
|---|
| 403 | //Insert the page into the settings notebook
|
|---|
| 404 |
|
|---|
| 405 | return _wpInsertSettingsPage(somSelf,hwndNotebook,&pageinfo);
|
|---|
| 406 | }
|
|---|
| 407 |
|
|---|
| 408 | /* Remove all trailing spaces from a string. The string MUST be terminated by 0! */
|
|---|
| 409 | void _removeTrailingSpaces(char * chrString)
|
|---|
| 410 | {
|
|---|
| 411 | char *ptr;
|
|---|
| 412 |
|
|---|
| 413 | if((ptr=strrchr(chrString, 0))==NULLHANDLE)
|
|---|
| 414 | return;
|
|---|
| 415 |
|
|---|
| 416 | if(ptr==chrString)
|
|---|
| 417 | return;
|
|---|
| 418 |
|
|---|
| 419 | while(ptr>=chrString && (*ptr==0 || *ptr==' '))
|
|---|
| 420 | ptr--;
|
|---|
| 421 |
|
|---|
| 422 | *(++ptr)=0;
|
|---|
| 423 | }
|
|---|
| 424 |
|
|---|
| 425 |
|
|---|
| 426 | /****************************************************************/
|
|---|
| 427 | /* */
|
|---|
| 428 | /* WNDPROC: waveInfoDlgProc() */
|
|---|
| 429 | /* */
|
|---|
| 430 | /* Window procedure handling the wave information settings */
|
|---|
| 431 | /* page. */
|
|---|
| 432 | /* */
|
|---|
| 433 | /****************************************************************/
|
|---|
| 434 | static MRESULT EXPENTRY waveInfoDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|---|
| 435 | {
|
|---|
| 436 | MMAudio *cwAudio;
|
|---|
| 437 |
|
|---|
| 438 | switch(msg) {
|
|---|
| 439 | case WM_INITDLG :
|
|---|
| 440 | cwAudio=(MMAudio*)LONGFROMMP(mp2);
|
|---|
| 441 | if(somIsObj(cwAudio)) {
|
|---|
| 442 | char fName[CCHMAXPATH];
|
|---|
| 443 | MMAudioData *somThis = MMAudioGetData(cwAudio);
|
|---|
| 444 |
|
|---|
| 445 | sprintf(fName,"%d",_ulChannels);
|
|---|
| 446 | WinSetWindowText(WinWindowFromID(hwnd, IDST_CHANNELS),fName);
|
|---|
| 447 |
|
|---|
| 448 | sprintf(fName,"%d",_ulSampleRate);
|
|---|
| 449 | WinSetWindowText(WinWindowFromID(hwnd, IDST_SAMPLERATE),fName);
|
|---|
| 450 | sprintf(fName,"%d",_ulBPS);
|
|---|
| 451 | WinSetWindowText(WinWindowFromID(hwnd, IDST_BPS),fName);
|
|---|
| 452 | sprintf(fName,"%d:%02d",_ulPlaySecs/60, _ulPlaySecs%60);
|
|---|
| 453 | WinSetWindowText(WinWindowFromID(hwnd, IDST_PLAYTIME),fName);
|
|---|
| 454 | WinSetWindowULong(WinQueryWindow(hwnd, QW_PARENT), QWL_HWNDFOCUSSAVE, hwnd);
|
|---|
| 455 | }
|
|---|
| 456 | return (MRESULT)TRUE;
|
|---|
| 457 | /* This prevents switching the notebook page behind the open folder */
|
|---|
| 458 | case WM_WINDOWPOSCHANGED:
|
|---|
| 459 | {
|
|---|
| 460 | MRESULT mr;
|
|---|
| 461 |
|
|---|
| 462 | if(WinQueryFocus(HWND_DESKTOP)!=
|
|---|
| 463 | WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT), QW_PARENT)) {
|
|---|
| 464 | mp2=MPFROMLONG(LONGFROMMP(mp2)|0x80000);/*AWP_ACTIVATE 0x00080000L*/
|
|---|
| 465 | mr=WinDefDlgProc(hwnd, msg, mp1, mp2);
|
|---|
| 466 | return mr;
|
|---|
| 467 | }
|
|---|
| 468 | break;
|
|---|
| 469 | }
|
|---|
| 470 | case WM_FOCUSCHANGE:
|
|---|
| 471 | {
|
|---|
| 472 | if(!SHORT1FROMMP(mp2)) {
|
|---|
| 473 | if(HWNDFROMMP(mp1)==hwnd) {
|
|---|
| 474 | MRESULT mr;
|
|---|
| 475 |
|
|---|
| 476 | mr=WinDefDlgProc(hwnd, msg, mp1, mp2);
|
|---|
| 477 | WinSendMsg(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT), QW_PARENT),
|
|---|
| 478 | WM_SETFOCUS, MPFROMHWND(hwnd), (MPARAM)TRUE);
|
|---|
| 479 | return mr;
|
|---|
| 480 | }
|
|---|
| 481 | }
|
|---|
| 482 | break;
|
|---|
| 483 | }
|
|---|
| 484 | case WM_DESTROY:
|
|---|
| 485 | /* The notebook closes and gets destroyed */
|
|---|
| 486 | /* Set focus to desktop to prevent PM freeze */
|
|---|
| 487 | WinSetFocus(HWND_DESKTOP, HWND_DESKTOP);
|
|---|
| 488 | break;
|
|---|
| 489 | default:
|
|---|
| 490 | break;
|
|---|
| 491 | }
|
|---|
| 492 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
|---|
| 493 | }
|
|---|
| 494 |
|
|---|
| 495 |
|
|---|
| 496 | /****************************************************************/
|
|---|
| 497 | /* */
|
|---|
| 498 | /* METHOD: cwmmAddAudioInformationPage() */
|
|---|
| 499 | /* */
|
|---|
| 500 | /* Insert new settings notebook page showing audio information. */
|
|---|
| 501 | /* */
|
|---|
| 502 | /****************************************************************/
|
|---|
| 503 | SOM_Scope ULONG SOMLINK cwaudio_cwmmAddAudioInformationPage(MMAudio *somSelf,
|
|---|
| 504 | HWND hwndNotebook)
|
|---|
| 505 | {
|
|---|
| 506 | PAGEINFO pageinfo;
|
|---|
| 507 | char pageName[100];
|
|---|
| 508 |
|
|---|
| 509 | MMAudioData *somThis = MMAudioGetData(somSelf);
|
|---|
| 510 | MMAudioMethodDebug("MMAudio","cwaudio_cwmmAddWaveInformationPage");
|
|---|
| 511 |
|
|---|
| 512 |
|
|---|
| 513 | if(_ulFileSize!=_wpQueryFileSize(somSelf)) {
|
|---|
| 514 | /* The filesize changed, somebody altered the audio file so reread the info */
|
|---|
| 515 | if(!cwObjectIsOnCD(somSelf)) {
|
|---|
| 516 | /* Only get audio info when file isn't on CD. This speeds up opening of folders on CDs filled with
|
|---|
| 517 | MP3s. Doesn't hurt because folders of CDs open in normal details view as default so the audio info
|
|---|
| 518 | isn't necessary. When opening the settings notebook the info is reread anyway. */
|
|---|
| 519 |
|
|---|
| 520 | /* Get class object */
|
|---|
| 521 | M_CWMMDataFile *m_cwmmDataFile=_CWMMDataFile;
|
|---|
| 522 | /* Get data pointer of class object */
|
|---|
| 523 | //FIXME
|
|---|
| 524 | /* M_CWMMDataFileData *cwmmData = M_CWMMDataFileGetData(m_cwmmDataFile);*/
|
|---|
| 525 |
|
|---|
| 526 | /* Send the object pointer to the audio worker thread to read the audio info in the background. */
|
|---|
| 527 | // WinPostMsg(cwmmData->hwndAudioWorker , WM_APPTERMINATENOTIFY, somSelf, 0);
|
|---|
| 528 | WinPostMsg(__get_hwndAudioWorker(_CWMMDataFile), WM_APPTERMINATENOTIFY, somSelf, 0);
|
|---|
| 529 | }
|
|---|
| 530 | }
|
|---|
| 531 |
|
|---|
| 532 | //Clear the pageinfo structure
|
|---|
| 533 | memset((PCH)&pageinfo, 0, sizeof(PAGEINFO));
|
|---|
| 534 | //Fill the pageinfo structure
|
|---|
| 535 | pageinfo.cb = sizeof(PAGEINFO);
|
|---|
| 536 | pageinfo.hwndPage = NULLHANDLE;
|
|---|
| 537 | pageinfo.usPageStyleFlags = BKA_MAJOR | BKA_STATUSTEXTON;
|
|---|
| 538 | pageinfo.usPageInsertFlags = BKA_FIRST;
|
|---|
| 539 | //We want page numbers
|
|---|
| 540 | pageinfo.usSettingsFlags = SETTINGS_PAGE_NUMBERS;
|
|---|
| 541 | //The dialog procedure for this page
|
|---|
| 542 | pageinfo.pfnwp = waveInfoDlgProc;
|
|---|
| 543 | //The resource DLL
|
|---|
| 544 | pageinfo.resid = queryResModuleHandle();
|
|---|
| 545 | //pageinfo.resid = queryModuleHandle();
|
|---|
| 546 | //The ID of the dialog template
|
|---|
| 547 | pageinfo.dlgid = IDDLG_WAVEINFOPAGE;
|
|---|
| 548 | //We need a pointer to our WPS-object in the dialog procedure
|
|---|
| 549 | //to call class functions
|
|---|
| 550 | pageinfo.pCreateParams = somSelf;
|
|---|
| 551 | //The ID of the help panel for this page
|
|---|
| 552 | //pageinfo.idDefaultHelpPanel = IDDLG_GENERAL2PAGE;
|
|---|
| 553 | //Tell the WPS the help library name
|
|---|
| 554 | pageinfo.pszHelpLibraryName = NULLHANDLE;
|
|---|
| 555 | //We have a major tab so we need a name
|
|---|
| 556 | if(!getMessage(pageName, ID_WAVEINFOPAGENAME, sizeof(pageName), queryResModuleHandle(), hwndNotebook))
|
|---|
| 557 | strcpy(pageName, "~Audio information");
|
|---|
| 558 | pageinfo.pszName = pageName;
|
|---|
| 559 | //Insert the page into the settings notebook
|
|---|
| 560 | return _wpInsertSettingsPage(somSelf,hwndNotebook,&pageinfo);
|
|---|
| 561 | }
|
|---|
| 562 |
|
|---|
| 563 | /*
|
|---|
| 564 | * The prototype for cwaudio_cwmmSetTrackInfo was replaced by the following prototype:
|
|---|
| 565 | */
|
|---|
| 566 | SOM_Scope BOOL SOMLINK cwaudio_cwmmSetTrackInfo(MMAudio *somSelf,
|
|---|
| 567 | char* chrString,
|
|---|
| 568 | ULONG ulValue,
|
|---|
| 569 | int iWhich)
|
|---|
| 570 | {
|
|---|
| 571 | ULONG ulError;
|
|---|
| 572 | MMAudioData *somThis = MMAudioGetData(somSelf);
|
|---|
| 573 | MMAudioMethodDebug("MMAudio","cwaudio_cwmmSetIdInfo");
|
|---|
| 574 |
|
|---|
| 575 | if(iWhich<1||iWhich>IDINFO_LASTINFO)
|
|---|
| 576 | return FALSE;
|
|---|
| 577 |
|
|---|
| 578 | switch(iWhich)
|
|---|
| 579 | {
|
|---|
| 580 | case IDINFO_PLAYTIME:
|
|---|
| 581 | _ulPlaySecs=ulValue;
|
|---|
| 582 | sprintf(_chrPlayTime, "%02d:%02d",_ulPlaySecs/60, _ulPlaySecs%60);
|
|---|
| 583 | break;
|
|---|
| 584 |
|
|---|
| 585 | case IDINFO_BPS:
|
|---|
| 586 | _ulBPS=ulValue;
|
|---|
| 587 | sprintf(_chrBPS, "%d",_ulBPS);
|
|---|
| 588 | break;
|
|---|
| 589 | case IDINFO_CHANNELS:
|
|---|
| 590 | _ulChannels=ulValue;
|
|---|
| 591 | sprintf(_chrChannels, "%d",_ulChannels);
|
|---|
| 592 | break;
|
|---|
| 593 | case IDINFO_SAMPLERATE:
|
|---|
| 594 | _ulSampleRate=ulValue;
|
|---|
| 595 | sprintf(_chrSampleRate, "%d",_ulSampleRate);
|
|---|
| 596 | break;
|
|---|
| 597 |
|
|---|
| 598 | case IDINFO_NAME:
|
|---|
| 599 | {
|
|---|
| 600 | char chrEA[MAX_EA_SIZE];
|
|---|
| 601 | /* Make sure string isn't longer than defined EA size */
|
|---|
| 602 | my_strlcpy(chrEA, chrString, sizeof(chrEA));
|
|---|
| 603 | _pszName=somReallocString(somSelf, _pszName, chrEA, &ulError);
|
|---|
| 604 | break;
|
|---|
| 605 | }
|
|---|
| 606 | case IDINFO_ARTIST:
|
|---|
| 607 | {
|
|---|
| 608 | char chrEA[MAX_EA_SIZE];
|
|---|
| 609 | my_strlcpy(chrEA, chrString, sizeof(chrEA));
|
|---|
| 610 | _pszArtist=somReallocString(somSelf, _pszArtist, chrEA, &ulError);
|
|---|
| 611 | break;
|
|---|
| 612 | }
|
|---|
| 613 | case IDINFO_ALBUM:
|
|---|
| 614 | {
|
|---|
| 615 | char chrEA[MAX_EA_SIZE];
|
|---|
| 616 | /* Make sure string isn't longer than defined EA size */
|
|---|
| 617 | my_strlcpy(chrEA, chrString, sizeof(chrEA));
|
|---|
| 618 | _pszAlbum=somReallocString(somSelf, _pszAlbum, chrEA, &ulError);
|
|---|
| 619 | break;
|
|---|
| 620 | }
|
|---|
| 621 | case IDINFO_YEAR:
|
|---|
| 622 | {
|
|---|
| 623 | char chrEA[MAX_EA_SIZE];
|
|---|
| 624 | /* Make sure string isn't longer than defined EA size */
|
|---|
| 625 | my_strlcpy(chrEA, chrString, sizeof(chrEA));
|
|---|
| 626 | _pszYear=somReallocString(somSelf, _pszYear, chrEA, &ulError);
|
|---|
| 627 | break;
|
|---|
| 628 | }
|
|---|
| 629 | case IDINFO_COMMENT:
|
|---|
| 630 | {
|
|---|
| 631 | char chrEA[MAX_EA_SIZE];
|
|---|
| 632 | /* Make sure string isn't longer than defined EA size */
|
|---|
| 633 | my_strlcpy(chrEA, chrString, sizeof(chrEA));
|
|---|
| 634 | _pszComment=somReallocString(somSelf, _pszComment, chrEA, &ulError);
|
|---|
| 635 | break;
|
|---|
| 636 | }
|
|---|
| 637 | case IDINFO_GENRE:
|
|---|
| 638 | {
|
|---|
| 639 | char chrEA[MAX_EA_SIZE];
|
|---|
| 640 | /* Make sure string isn't longer than defined EA size */
|
|---|
| 641 | my_strlcpy(chrEA, chrString, sizeof(chrEA));
|
|---|
| 642 | _pszGenre=somReallocString(somSelf, _pszGenre, chrEA, &ulError);
|
|---|
| 643 | break;
|
|---|
| 644 | }
|
|---|
| 645 |
|
|---|
| 646 | #if 0
|
|---|
| 647 | case IDINFO_NAME:
|
|---|
| 648 | strncpy(_id3Name,chrString,sizeof(_id3Name));
|
|---|
| 649 | _id3Name[sizeof(_id3Name)-1]=0;
|
|---|
| 650 | _removeTrailingSpaces(_id3Name);
|
|---|
| 651 | break;
|
|---|
| 652 | case IDINFO_ARTIST:
|
|---|
| 653 | strncpy(_id3Artist,chrString,sizeof(_id3Artist));
|
|---|
| 654 | _id3Artist[sizeof(_id3Artist)-1]=0;
|
|---|
| 655 | _removeTrailingSpaces(_id3Artist);
|
|---|
| 656 | break;
|
|---|
| 657 | case IDINFO_ALBUM:
|
|---|
| 658 | strncpy(_id3Album, chrString, sizeof(_id3Album));
|
|---|
| 659 | _id3Album[sizeof(_id3Album)-1]=0;
|
|---|
| 660 | _removeTrailingSpaces(_id3Album);
|
|---|
| 661 | break;
|
|---|
| 662 | case IDINFO_YEAR:
|
|---|
| 663 | strncpy(_id3Year, chrString, sizeof(_id3Year));
|
|---|
| 664 | _id3Year[sizeof(_id3Year)-1]=0;
|
|---|
| 665 | _removeTrailingSpaces(_id3Year);
|
|---|
| 666 | break;
|
|---|
| 667 | case IDINFO_COMMENT:
|
|---|
| 668 | strncpy(_id3Comment,chrString, sizeof(_id3Comment));
|
|---|
| 669 | _id3Comment[sizeof(_id3Comment)]=0;
|
|---|
| 670 | _removeTrailingSpaces(_id3Comment);
|
|---|
| 671 | break;
|
|---|
| 672 | case IDINFO_GENRE:
|
|---|
| 673 | strncpy(_id3Genre, chrString, sizeof(_id3Genre));
|
|---|
| 674 | _id3Genre[sizeof(_id3Genre)-1]=0;
|
|---|
| 675 | _removeTrailingSpaces(_id3Genre);
|
|---|
| 676 | break;
|
|---|
| 677 | #endif
|
|---|
| 678 |
|
|---|
| 679 | default:
|
|---|
| 680 | return FALSE;
|
|---|
| 681 | }
|
|---|
| 682 |
|
|---|
| 683 |
|
|---|
| 684 | /* Return statement to be customized: */
|
|---|
| 685 | return TRUE;
|
|---|
| 686 | }
|
|---|
| 687 |
|
|---|
| 688 |
|
|---|
| 689 | /*
|
|---|
| 690 | * The prototype for cwaudio_cwmmQueryTrackInfo was replaced by the following prototype:
|
|---|
| 691 | */
|
|---|
| 692 |
|
|---|
| 693 | /*
|
|---|
| 694 | * SOM_Scope ULONG SOMLINK cwaudio_cwmmQueryTrackInfo(MMAudio *somSelf,
|
|---|
| 695 | * char** chrString,
|
|---|
| 696 | * ULONG ulSize,
|
|---|
| 697 | * int iWhich)
|
|---|
| 698 | */
|
|---|
| 699 |
|
|---|
| 700 | /*
|
|---|
| 701 | * The prototype for cwaudio_cwmmQueryTrackInfo was replaced by the following prototype:
|
|---|
| 702 | */
|
|---|
| 703 | SOM_Scope ULONG SOMLINK cwaudio_cwmmQueryTrackInfo(MMAudio *somSelf,
|
|---|
| 704 | PSZ chrString,
|
|---|
| 705 | ULONG ulSize,
|
|---|
| 706 | int iWhich)
|
|---|
| 707 | {
|
|---|
| 708 | MMAudioData *somThis = MMAudioGetData(somSelf);
|
|---|
| 709 | MMAudioMethodDebug("MMAudio","cwaudio_cwmmQueryTrackInfo");
|
|---|
| 710 |
|
|---|
| 711 | switch(iWhich)
|
|---|
| 712 | {
|
|---|
| 713 | case IDINFO_PLAYTIME:
|
|---|
| 714 | return _ulPlaySecs;
|
|---|
| 715 | case IDINFO_BPS:
|
|---|
| 716 | return _ulBPS;
|
|---|
| 717 | case IDINFO_CHANNELS:
|
|---|
| 718 | return _ulChannels;
|
|---|
| 719 | case IDINFO_SAMPLERATE:
|
|---|
| 720 | return _ulSampleRate;
|
|---|
| 721 | case IDINFO_BITRATE:
|
|---|
| 722 | return _ulBitRate;
|
|---|
| 723 |
|
|---|
| 724 | case IDINFO_NAME:
|
|---|
| 725 | {
|
|---|
| 726 | // char *chr=*chrString;
|
|---|
| 727 | if(!_pszName)
|
|---|
| 728 | return FALSE;
|
|---|
| 729 | if(ulSize>strlen(_pszName)) {
|
|---|
| 730 | strcpy(chrString, _pszName);
|
|---|
| 731 | }
|
|---|
| 732 | else {
|
|---|
| 733 | strncpy(chrString, _pszName, ulSize);
|
|---|
| 734 | chrString[ulSize-1]=0;
|
|---|
| 735 | }
|
|---|
| 736 | if(chrString[0]==0)
|
|---|
| 737 | return FALSE;
|
|---|
| 738 | else
|
|---|
| 739 | return TRUE;
|
|---|
| 740 | }
|
|---|
| 741 | case IDINFO_ARTIST:
|
|---|
| 742 | {
|
|---|
| 743 | // char *chr=*chrString;
|
|---|
| 744 | if(!_pszArtist)
|
|---|
| 745 | return FALSE;
|
|---|
| 746 | if(ulSize>strlen(_pszArtist)) {
|
|---|
| 747 | strcpy(chrString, _pszArtist);
|
|---|
| 748 | }
|
|---|
| 749 | else {
|
|---|
| 750 | strncpy(chrString, _pszArtist, ulSize);
|
|---|
| 751 | chrString[ulSize-1]=0;
|
|---|
| 752 | }
|
|---|
| 753 | if(chrString[0]==0)
|
|---|
| 754 | return FALSE;
|
|---|
| 755 | else
|
|---|
| 756 | return TRUE;
|
|---|
| 757 | }
|
|---|
| 758 | case IDINFO_ALBUM:
|
|---|
| 759 | {
|
|---|
| 760 | // char *chr=*chrString;
|
|---|
| 761 | if(!_pszAlbum)
|
|---|
| 762 | return FALSE;
|
|---|
| 763 | if(ulSize>strlen(_pszAlbum)) {
|
|---|
| 764 | strcpy(chrString, _pszAlbum);
|
|---|
| 765 | }
|
|---|
| 766 | else {
|
|---|
| 767 | strncpy(chrString, _pszAlbum, ulSize);
|
|---|
| 768 | chrString[ulSize-1]=0;
|
|---|
| 769 | }
|
|---|
| 770 | if(chrString[0]==0)
|
|---|
| 771 | return FALSE;
|
|---|
| 772 | else
|
|---|
| 773 | return TRUE;
|
|---|
| 774 | }
|
|---|
| 775 | case IDINFO_COMMENT:
|
|---|
| 776 | {
|
|---|
| 777 | // char *chr=*chrString;
|
|---|
| 778 | if(!_pszComment)
|
|---|
| 779 | return FALSE;
|
|---|
| 780 | if(ulSize>strlen(_pszComment)) {
|
|---|
| 781 | strcpy(chrString, _pszComment);
|
|---|
| 782 | }
|
|---|
| 783 | else {
|
|---|
| 784 | strncpy(chrString, _pszComment, ulSize);
|
|---|
| 785 | chrString[ulSize-1]=0;
|
|---|
| 786 | }
|
|---|
| 787 | if(chrString[0]==0)
|
|---|
| 788 | return FALSE;
|
|---|
| 789 | else
|
|---|
| 790 | return TRUE;
|
|---|
| 791 | }
|
|---|
| 792 | case IDINFO_YEAR:
|
|---|
| 793 | {
|
|---|
| 794 | // char *chr=*chrString;
|
|---|
| 795 | if(!_pszYear)
|
|---|
| 796 | return FALSE;
|
|---|
| 797 | if(ulSize>strlen(_pszYear)) {
|
|---|
| 798 | strcpy(chrString, _pszYear);
|
|---|
| 799 | }
|
|---|
| 800 | else {
|
|---|
| 801 | strncpy(chrString, _pszYear, ulSize);
|
|---|
| 802 | chrString[ulSize-1]=0;
|
|---|
| 803 | }
|
|---|
| 804 | if(chrString[0]==0)
|
|---|
| 805 | return FALSE;
|
|---|
| 806 | else
|
|---|
| 807 | return TRUE;
|
|---|
| 808 | }
|
|---|
| 809 | case IDINFO_GENRE:
|
|---|
| 810 | {
|
|---|
| 811 | // char *chr=*chrString;
|
|---|
| 812 | if(!_pszGenre)
|
|---|
| 813 | return FALSE;
|
|---|
| 814 |
|
|---|
| 815 | if(ulSize>=strlen(_pszGenre)) {
|
|---|
| 816 | strcpy(chrString, _pszGenre);
|
|---|
| 817 | }
|
|---|
| 818 | else {
|
|---|
| 819 | strncpy(chrString, _pszGenre, ulSize);
|
|---|
| 820 | chrString[ulSize-1]=0;
|
|---|
| 821 | }
|
|---|
| 822 | if(chrString[0]==0)
|
|---|
| 823 | return FALSE;
|
|---|
| 824 | else
|
|---|
| 825 | return TRUE;
|
|---|
| 826 | }
|
|---|
| 827 |
|
|---|
| 828 | #if 0
|
|---|
| 829 | case IDINFO_NAME:
|
|---|
| 830 | {
|
|---|
| 831 | char *chr=*chrString;
|
|---|
| 832 | if(ulSize>=sizeof(_id3Name)) {
|
|---|
| 833 | strncpy(chr, _id3Name, sizeof(_id3Name));
|
|---|
| 834 | chr[sizeof(_id3Name)-1]=0;
|
|---|
| 835 | }
|
|---|
| 836 | else {
|
|---|
| 837 | strncpy(chr, _id3Name, ulSize);
|
|---|
| 838 | chr[ulSize-1]=0;
|
|---|
| 839 | }
|
|---|
| 840 | if(chr[0]==0)
|
|---|
| 841 | return FALSE;
|
|---|
| 842 | else
|
|---|
| 843 | return TRUE;
|
|---|
| 844 | }
|
|---|
| 845 | case IDINFO_ARTIST:
|
|---|
| 846 | {
|
|---|
| 847 | char *chr=*chrString;
|
|---|
| 848 | if(ulSize>=sizeof(_id3Artist)) {
|
|---|
| 849 | strncpy(chr, _id3Artist, sizeof(_id3Artist));
|
|---|
| 850 | chr[sizeof(_id3Artist)-1]=0;
|
|---|
| 851 | }
|
|---|
| 852 | else {
|
|---|
| 853 | strncpy(chr, _id3Artist, ulSize);
|
|---|
| 854 | chr[ulSize-1]=0;
|
|---|
| 855 | }
|
|---|
| 856 | if(chr[0]==0)
|
|---|
| 857 | return FALSE;
|
|---|
| 858 | else
|
|---|
| 859 | return TRUE;
|
|---|
| 860 | }
|
|---|
| 861 | case IDINFO_ALBUM:
|
|---|
| 862 | {
|
|---|
| 863 | char *chr=*chrString;
|
|---|
| 864 | if(ulSize>=sizeof(_id3Album)) {
|
|---|
| 865 | strncpy(chr, _id3Album, sizeof(_id3Album));
|
|---|
| 866 | chr[sizeof(_id3Album)-1]=0;
|
|---|
| 867 | }
|
|---|
| 868 | else {
|
|---|
| 869 | strncpy(chr, _id3Album, ulSize);
|
|---|
| 870 | chr[ulSize-1]=0;
|
|---|
| 871 | }
|
|---|
| 872 | if(chr[0]==0)
|
|---|
| 873 | return FALSE;
|
|---|
| 874 | else
|
|---|
| 875 | return TRUE;
|
|---|
| 876 | }
|
|---|
| 877 | case IDINFO_COMMENT:
|
|---|
| 878 | {
|
|---|
| 879 | char *chr=*chrString;
|
|---|
| 880 | if(ulSize>=sizeof(_id3Comment)) {
|
|---|
| 881 | strncpy(chr, _id3Comment, sizeof(_id3Comment));
|
|---|
| 882 | chr[sizeof(_id3Comment)-1]=0;
|
|---|
| 883 | }
|
|---|
| 884 | else {
|
|---|
| 885 | strncpy(chr, _id3Comment, ulSize);
|
|---|
| 886 | chr[ulSize-1]=0;
|
|---|
| 887 | }
|
|---|
| 888 | if(chr[0]==0)
|
|---|
| 889 | return FALSE;
|
|---|
| 890 | else
|
|---|
| 891 | return TRUE;
|
|---|
| 892 | }
|
|---|
| 893 | case IDINFO_YEAR:
|
|---|
| 894 | {
|
|---|
| 895 | char *chr=*chrString;
|
|---|
| 896 | if(ulSize>=sizeof(_id3Year)) {
|
|---|
| 897 | strncpy(chr, _id3Year, sizeof(_id3Year));
|
|---|
| 898 | chr[sizeof(_id3Year)-1]=0;
|
|---|
| 899 | }
|
|---|
| 900 | else {
|
|---|
| 901 | strncpy(chr, _id3Year, ulSize);
|
|---|
| 902 | chr[ulSize-1]=0;
|
|---|
| 903 | }
|
|---|
| 904 | if(chr[0]==0)
|
|---|
| 905 | return FALSE;
|
|---|
| 906 | else
|
|---|
| 907 | return TRUE;
|
|---|
| 908 | }
|
|---|
| 909 | case IDINFO_GENRE:
|
|---|
| 910 | {
|
|---|
| 911 | char *chr=*chrString;
|
|---|
| 912 | if(ulSize>=sizeof(_id3Genre)) {
|
|---|
| 913 | strncpy(chr, _id3Genre, sizeof(_id3Genre));
|
|---|
| 914 | chr[sizeof(_id3Genre)-1]=0;
|
|---|
| 915 | }
|
|---|
| 916 | else {
|
|---|
| 917 | strncpy(chr, _id3Genre, ulSize);
|
|---|
| 918 | chr[ulSize-1]=0;
|
|---|
| 919 | }
|
|---|
| 920 | if(chr[0]==0)
|
|---|
| 921 | return FALSE;
|
|---|
| 922 | else
|
|---|
| 923 | return TRUE;
|
|---|
| 924 | }
|
|---|
| 925 | #endif
|
|---|
| 926 |
|
|---|
| 927 | default:
|
|---|
| 928 | break;
|
|---|
| 929 | }
|
|---|
| 930 |
|
|---|
| 931 | /* Return statement to be customized: */
|
|---|
| 932 | return 0;
|
|---|
| 933 | }
|
|---|
| 934 |
|
|---|
| 935 | /************************************************************/
|
|---|
| 936 | /* */
|
|---|
| 937 | /* */
|
|---|
| 938 | /* */
|
|---|
| 939 | /************************************************************/
|
|---|
| 940 | MRESULT EXPENTRY playObjectProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|---|
| 941 | {
|
|---|
| 942 |
|
|---|
| 943 | switch (msg)
|
|---|
| 944 | {
|
|---|
| 945 | case WM_APPTERMINATENOTIFY:
|
|---|
| 946 | {
|
|---|
| 947 | if(LONGFROMMP(mp1)==ACKEY_START)
|
|---|
| 948 | {
|
|---|
| 949 | unsigned char chrCommand[CCHMAXPATH*2];
|
|---|
| 950 | char chrDevice[20];
|
|---|
| 951 | char name[CCHMAXPATH];
|
|---|
| 952 | ULONG ulNameSize;
|
|---|
| 953 | char retMsg[20];
|
|---|
| 954 | APIRET rc;
|
|---|
| 955 | int iTime;
|
|---|
| 956 | OPENPARAMS * pParams;
|
|---|
| 957 | MMAudio * thisPtr;
|
|---|
| 958 |
|
|---|
| 959 | pParams=PVOIDFROMMP(mp2);/* Get parameter block */
|
|---|
| 960 | if(!pParams)
|
|---|
| 961 | {
|
|---|
| 962 | WinPostMsg(hwnd,WM_QUIT,0,0);
|
|---|
| 963 | return MRFALSE;
|
|---|
| 964 | }
|
|---|
| 965 |
|
|---|
| 966 | WinSetWindowULong(hwnd, QWL_USER, (ULONG)pParams);
|
|---|
| 967 |
|
|---|
| 968 | thisPtr=pParams->wpObject;
|
|---|
| 969 | if(somIsObj(thisPtr)) {
|
|---|
| 970 | SOMClass* mmMIDIClass=somGetSomClass("MMMIDI");
|
|---|
| 971 | MMAudioData *somThis;
|
|---|
| 972 | //FIXME
|
|---|
| 973 | // CWMMDataFileData *mmdf_somThis;
|
|---|
| 974 |
|
|---|
| 975 | somThis = MMAudioGetData(thisPtr);
|
|---|
| 976 | //mmdf_somThis = CWMMDataFileGetData(thisPtr);
|
|---|
| 977 |
|
|---|
| 978 | if(_somIsA(thisPtr, mmMIDIClass))
|
|---|
| 979 | strncpy(chrDevice,"SEQUENCER", sizeof(chrDevice));
|
|---|
| 980 | else
|
|---|
| 981 | strncpy(chrDevice,"WAVEAUDIO", sizeof(chrDevice));
|
|---|
| 982 |
|
|---|
| 983 | ulNameSize=sizeof(name);
|
|---|
| 984 | _wpQueryRealName(thisPtr, name, &ulNameSize, TRUE);
|
|---|
| 985 |
|
|---|
| 986 | /* Start audio file */
|
|---|
| 987 | sprintf(chrCommand,"open \"%s\" type %s alias wave%d SHAREABLE wait",name, chrDevice, thisPtr);
|
|---|
| 988 | rc = mciSendString( chrCommand, retMsg, sizeof(retMsg), hwnd, 0);
|
|---|
| 989 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
|---|
| 990 | WinPostMsg(hwnd,WM_QUIT,0,0);
|
|---|
| 991 | return MRFALSE;
|
|---|
| 992 | }
|
|---|
| 993 |
|
|---|
| 994 | /* Set time format */
|
|---|
| 995 | sprintf(chrCommand,"SET wave%d TIME FORMAT MILLISECONDS wait", thisPtr);
|
|---|
| 996 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
|---|
| 997 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
|---|
| 998 | WinPostMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(ACKEY_STOP), MPFROMP(thisPtr));
|
|---|
| 999 | return MRFALSE;
|
|---|
| 1000 | }
|
|---|
| 1001 |
|
|---|
| 1002 | sprintf(chrCommand,"STATUS wave%d LENGTH WAIT", thisPtr);
|
|---|
| 1003 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
|---|
| 1004 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
|---|
| 1005 | WinPostMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(ACKEY_STOP), MPFROMP(thisPtr));
|
|---|
| 1006 | return MRFALSE;
|
|---|
| 1007 | }
|
|---|
| 1008 |
|
|---|
| 1009 | iTime=atoi(retMsg);
|
|---|
| 1010 |
|
|---|
| 1011 | // sprintf(chrCommand,"SETPOSITIONADVISE wave%d ON EVERY %d NOTIFY", thisPtr, 3000);
|
|---|
| 1012 | // rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), hwnd, 0);
|
|---|
| 1013 |
|
|---|
| 1014 | if(iTime>1100)
|
|---|
| 1015 | iTime-=700;
|
|---|
| 1016 | else
|
|---|
| 1017 | iTime-=300;
|
|---|
| 1018 |
|
|---|
| 1019 | if(iTime<=0)
|
|---|
| 1020 | iTime=100;
|
|---|
| 1021 |
|
|---|
| 1022 | sprintf(chrCommand,"SETCUEPOINT wave%d ON at %d WAIT", thisPtr, iTime);
|
|---|
| 1023 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), hwnd, 0);
|
|---|
| 1024 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
|---|
| 1025 | WinPostMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(ACKEY_STOP), MPFROMP(thisPtr));
|
|---|
| 1026 | return MRFALSE;
|
|---|
| 1027 | }
|
|---|
| 1028 |
|
|---|
| 1029 | /* Set volume */
|
|---|
| 1030 | sprintf(chrCommand,"SET wave%d AUDIO VOLUME %d wait", thisPtr, globalClassVolume);
|
|---|
| 1031 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
|---|
| 1032 | /* Not able to set the volume isn't that bad so don't quit in case of an error. */
|
|---|
| 1033 | #if 0
|
|---|
| 1034 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
|---|
| 1035 | WinPostMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(ACKEY_STOP), MPFROMP(thisPtr));
|
|---|
| 1036 | return MRFALSE;
|
|---|
| 1037 | }
|
|---|
| 1038 | #endif
|
|---|
| 1039 |
|
|---|
| 1040 | WinStartTimer(WinQueryAnchorBlock(hwnd), hwnd, 1, 100);
|
|---|
| 1041 |
|
|---|
| 1042 | sprintf(chrCommand,"play wave%d ", thisPtr);
|
|---|
| 1043 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
|---|
| 1044 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
|---|
| 1045 | WinPostMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(ACKEY_STOP), MPFROMP(thisPtr));
|
|---|
| 1046 | return MRFALSE;
|
|---|
| 1047 | }
|
|---|
| 1048 |
|
|---|
| 1049 | /* Set Time in icon title to 00:00 */
|
|---|
| 1050 | strncpy(chrCommand, _wpQueryTitle(thisPtr), CCHMAXPATH);
|
|---|
| 1051 | if(_ulPlaySecs) {
|
|---|
| 1052 | sprintf(retMsg, "%02d:%02d", _ulPlaySecs/60, _ulPlaySecs%60);
|
|---|
| 1053 | strncat(chrCommand,"\n00:00 / ",sizeof(chrCommand)-1-strlen(chrCommand));
|
|---|
| 1054 | strncat(chrCommand, retMsg,sizeof(chrCommand)-1-strlen(chrCommand));
|
|---|
| 1055 | }
|
|---|
| 1056 | else
|
|---|
| 1057 | strncat(chrCommand,"\n00:00", sizeof(chrCommand)-1-strlen(chrCommand));
|
|---|
| 1058 |
|
|---|
| 1059 | _cwmmSetRecordTitles(thisPtr, chrCommand, FALSE);
|
|---|
| 1060 | WinStartTimer(WinQueryAnchorBlock(hwnd), hwnd, 1, 1000);
|
|---|
| 1061 | //FIXME
|
|---|
| 1062 | //mmdf_somThis->ulTrackStatus=TRACK_STATUS_PLAYING;
|
|---|
| 1063 | __set_ulTrackStatus( thisPtr,TRACK_STATUS_PLAYING);
|
|---|
| 1064 | break;
|
|---|
| 1065 | }/* somIsObj(thisPtr) */
|
|---|
| 1066 | }
|
|---|
| 1067 | else
|
|---|
| 1068 | {
|
|---|
| 1069 | MMAudio * thisPtr;
|
|---|
| 1070 |
|
|---|
| 1071 | thisPtr=(MMAudio *)PVOIDFROMMP(mp2);/* Get object ptr */
|
|---|
| 1072 | if(somIsObj(thisPtr)) {
|
|---|
| 1073 | switch(LONGFROMMP(mp1))
|
|---|
| 1074 | {
|
|---|
| 1075 | case ACKEY_VOLUME:
|
|---|
| 1076 | {
|
|---|
| 1077 | HWND globalHwndObjectPlay;
|
|---|
| 1078 | unsigned char chrCommand[CCHMAXPATH];
|
|---|
| 1079 | char retMsg[20];
|
|---|
| 1080 |
|
|---|
| 1081 | /* Set volume */
|
|---|
| 1082 | sprintf(chrCommand,"SET wave%d AUDIO VOLUME %d ", thisPtr, globalClassVolume);
|
|---|
| 1083 | mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
|---|
| 1084 | /* Not able to set the volume isn't that bad so don't quit in case of an error. */
|
|---|
| 1085 | break;
|
|---|
| 1086 | }
|
|---|
| 1087 | case ACKEY_STOP:
|
|---|
| 1088 | {
|
|---|
| 1089 | /* Stop playing */
|
|---|
| 1090 | unsigned char chrCommand[CCHMAXPATH];
|
|---|
| 1091 | char retMsg[20];
|
|---|
| 1092 |
|
|---|
| 1093 | //CWMMDataFileData *mmdf_somThis = CWMMDataFileGetData(thisPtr);
|
|---|
| 1094 |
|
|---|
| 1095 | WinStopTimer(WinQueryAnchorBlock(hwnd),hwnd,1 );
|
|---|
| 1096 |
|
|---|
| 1097 | sprintf(chrCommand,"stop wave%d wait", thisPtr);
|
|---|
| 1098 | mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
|---|
| 1099 |
|
|---|
| 1100 | sprintf(chrCommand,"close wave%d wait", thisPtr);
|
|---|
| 1101 | mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
|---|
| 1102 |
|
|---|
| 1103 | //FIXME
|
|---|
| 1104 | // mmdf_somThis->ulTrackStatus=TRACK_STATUS_STOPPED;
|
|---|
| 1105 | __set_ulTrackStatus(thisPtr, TRACK_STATUS_STOPPED);
|
|---|
| 1106 | WinPostMsg(hwnd,WM_QUIT,0,0);
|
|---|
| 1107 | break;
|
|---|
| 1108 | }
|
|---|
| 1109 | case ACKEY_PAUSE:
|
|---|
| 1110 | {
|
|---|
| 1111 | unsigned char chrCommand[CCHMAXPATH];
|
|---|
| 1112 | char retMsg[20];
|
|---|
| 1113 | APIRET rc;
|
|---|
| 1114 | // CWMMDataFileData *mmdf_somThis = CWMMDataFileGetData(thisPtr);
|
|---|
| 1115 |
|
|---|
| 1116 | sprintf(chrCommand,"STATUS wave%d MODE WAIT", thisPtr);
|
|---|
| 1117 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
|---|
| 1118 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
|---|
| 1119 | WinPostMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(ACKEY_STOP), MPFROMP(thisPtr));
|
|---|
| 1120 | return MRFALSE;
|
|---|
| 1121 | }
|
|---|
| 1122 |
|
|---|
| 1123 | if(!stricmp(retMsg, "playing"))
|
|---|
| 1124 | {
|
|---|
| 1125 | sprintf(chrCommand,"PAUSE wave%d wait", thisPtr);
|
|---|
| 1126 | rc=mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
|---|
| 1127 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
|---|
| 1128 | WinPostMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(ACKEY_STOP), MPFROMP(thisPtr));
|
|---|
| 1129 | return MRFALSE;
|
|---|
| 1130 | }
|
|---|
| 1131 | //FIXME
|
|---|
| 1132 | //mmdf_somThis->ulTrackStatus=TRACK_STATUS_PAUSED;
|
|---|
| 1133 | __set_ulTrackStatus(thisPtr, TRACK_STATUS_PAUSED);
|
|---|
| 1134 | }
|
|---|
| 1135 | break;
|
|---|
| 1136 | }
|
|---|
| 1137 | case ACKEY_RESUME:
|
|---|
| 1138 | {
|
|---|
| 1139 | unsigned char chrCommand[CCHMAXPATH];
|
|---|
| 1140 | char retMsg[20];
|
|---|
| 1141 | APIRET rc;
|
|---|
| 1142 | // CWMMDataFileData *mmdf_somThis = CWMMDataFileGetData(thisPtr);
|
|---|
| 1143 |
|
|---|
| 1144 | sprintf(chrCommand,"STATUS wave%d MODE WAIT", thisPtr);
|
|---|
| 1145 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
|---|
| 1146 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
|---|
| 1147 | WinPostMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(ACKEY_STOP), MPFROMP(thisPtr));
|
|---|
| 1148 | return MRFALSE;
|
|---|
| 1149 | }
|
|---|
| 1150 |
|
|---|
| 1151 | if(!stricmp(retMsg, "paused"))
|
|---|
| 1152 | {
|
|---|
| 1153 | sprintf(chrCommand,"RESUME wave%d wait", thisPtr);
|
|---|
| 1154 | rc=mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
|---|
| 1155 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
|---|
| 1156 | WinPostMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(ACKEY_STOP), MPFROMP(thisPtr));
|
|---|
| 1157 | return MRFALSE;
|
|---|
| 1158 | }
|
|---|
| 1159 | //FIXME
|
|---|
| 1160 | //mmdf_somThis->ulTrackStatus=TRACK_STATUS_PLAYING;
|
|---|
| 1161 | __set_ulTrackStatus(thisPtr, TRACK_STATUS_PLAYING);
|
|---|
| 1162 | }
|
|---|
| 1163 | break;
|
|---|
| 1164 | }
|
|---|
| 1165 | default:
|
|---|
| 1166 | break;
|
|---|
| 1167 | }
|
|---|
| 1168 | }/* if(thisPtr) */
|
|---|
| 1169 | return MRFALSE;
|
|---|
| 1170 | }
|
|---|
| 1171 | }
|
|---|
| 1172 | //case MM_MCIPOSITIONCHANGE:
|
|---|
| 1173 | case WM_TIMER:
|
|---|
| 1174 | if(SHORT1FROMMP(mp1)==1) {
|
|---|
| 1175 | MMAudio * thisPtr;
|
|---|
| 1176 | OPENPARAMS * pParams;
|
|---|
| 1177 | pParams=(OPENPARAMS*)WinQueryWindowULong(hwnd, QWL_USER);
|
|---|
| 1178 | thisPtr=pParams->wpObject;
|
|---|
| 1179 |
|
|---|
| 1180 | if(somIsObj(thisPtr)) {
|
|---|
| 1181 | char retMsg[50];
|
|---|
| 1182 | unsigned char chrCommand[CCHMAXPATH+20];
|
|---|
| 1183 | APIRET rc;
|
|---|
| 1184 | ULONG ulCur;
|
|---|
| 1185 | MMAudioData *somThis = MMAudioGetData(thisPtr);
|
|---|
| 1186 |
|
|---|
| 1187 | /* Check if folder closed. If yes stop playing */
|
|---|
| 1188 | if(!WinIsWindow(globalHab, pParams->hwndCnr)) {
|
|---|
| 1189 | WinPostMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(ACKEY_STOP), MPFROMP(thisPtr));
|
|---|
| 1190 | return MRFALSE;
|
|---|
| 1191 | }
|
|---|
| 1192 | /* Get current play position */
|
|---|
| 1193 | sprintf(chrCommand,"STATUS wave%d POSITION WAIT", thisPtr);
|
|---|
| 1194 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
|---|
| 1195 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
|---|
| 1196 | return MRFALSE;
|
|---|
| 1197 | }
|
|---|
| 1198 |
|
|---|
| 1199 | ulCur=atoi(retMsg);
|
|---|
| 1200 | if(ulCur) {
|
|---|
| 1201 | ulCur/=1000;
|
|---|
| 1202 | if(!ulCur)
|
|---|
| 1203 | ulCur=1;
|
|---|
| 1204 | }
|
|---|
| 1205 |
|
|---|
| 1206 | strncpy(chrCommand, _wpQueryTitle(thisPtr), CCHMAXPATH);
|
|---|
| 1207 | strncat(chrCommand,"\n",sizeof(chrCommand)-1-strlen(chrCommand));
|
|---|
| 1208 | if(_ulPlaySecs) {
|
|---|
| 1209 | sprintf(retMsg, "%02d:%02d / %02d:%02d", ulCur/60, ulCur%60, _ulPlaySecs/60, _ulPlaySecs%60);
|
|---|
| 1210 | strncat(chrCommand, retMsg,sizeof(chrCommand)-1-strlen(chrCommand));
|
|---|
| 1211 | }
|
|---|
| 1212 | else
|
|---|
| 1213 | {
|
|---|
| 1214 | sprintf(retMsg, "%02d:%02d", ulCur/60, ulCur%60);
|
|---|
| 1215 | strncat(chrCommand, retMsg,sizeof(chrCommand)-1-strlen(chrCommand));
|
|---|
| 1216 | }
|
|---|
| 1217 | if(_cwmmQueryTrackStatus(thisPtr)==TRACK_STATUS_PAUSED) {
|
|---|
| 1218 | if(!getMessage(retMsg, IDSTR_TRACKPAUSED, sizeof(retMsg), queryResModuleHandle(), HWND_DESKTOP))
|
|---|
| 1219 | strcpy(retMsg," (Paused)");
|
|---|
| 1220 | strncat(chrCommand, retMsg,sizeof(chrCommand)-1-strlen(chrCommand));
|
|---|
| 1221 | }
|
|---|
| 1222 | /* Set new time in icon title */
|
|---|
| 1223 | _cwmmSetRecordTitles(thisPtr, chrCommand, FALSE);
|
|---|
| 1224 | }
|
|---|
| 1225 | return MRFALSE;
|
|---|
| 1226 | }
|
|---|
| 1227 | break;
|
|---|
| 1228 | case MM_MCICUEPOINT:
|
|---|
| 1229 | {
|
|---|
| 1230 | /***********************************************/
|
|---|
| 1231 | /* The track is about to end */
|
|---|
| 1232 | /***********************************************/
|
|---|
| 1233 | MMAudio * thisPtr;
|
|---|
| 1234 | OPENPARAMS * pParams;
|
|---|
| 1235 | pParams=(OPENPARAMS*)WinQueryWindowULong(hwnd, QWL_USER);
|
|---|
| 1236 | thisPtr=pParams->wpObject;
|
|---|
| 1237 |
|
|---|
| 1238 | if(somIsObj(thisPtr)) {
|
|---|
| 1239 | unsigned char chrCommand[CCHMAXPATH];
|
|---|
| 1240 | char retMsg[20];
|
|---|
| 1241 |
|
|---|
| 1242 | sprintf(chrCommand,"STATUS wave%d MODE WAIT", thisPtr);
|
|---|
| 1243 | do {
|
|---|
| 1244 | APIRET rc;
|
|---|
| 1245 | retMsg[0]=0;
|
|---|
| 1246 | DosSleep(100);
|
|---|
| 1247 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
|---|
| 1248 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
|---|
| 1249 | WinPostMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(ACKEY_STOP), MPFROMP(thisPtr));
|
|---|
| 1250 |
|
|---|
| 1251 | return MRFALSE;
|
|---|
| 1252 | }
|
|---|
| 1253 | // WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, retMsg, "CWAudio", 1234, MB_OK|MB_MOVEABLE);
|
|---|
| 1254 | //HlpWriteToTrapLog("%s\n", retMsg);
|
|---|
| 1255 | } while(!stricmp(retMsg, "playing"));
|
|---|
| 1256 | /* The track ended. Call 'Stop' so the object title is updated and everything is cleaned up.
|
|---|
| 1257 | During handling of the 'Stop' message the WM_QUIT message will be posted to end the thread. */
|
|---|
| 1258 | //WinPostMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(ACKEY_NEXT), MPFROMP(thisPtr));
|
|---|
| 1259 | WinPostMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(ACKEY_STOP), MPFROMP(thisPtr));
|
|---|
| 1260 | }
|
|---|
| 1261 | return MRFALSE;
|
|---|
| 1262 | }
|
|---|
| 1263 | default:
|
|---|
| 1264 | break;
|
|---|
| 1265 | }
|
|---|
| 1266 | return WinDefWindowProc( hwnd, msg, mp1, mp2);
|
|---|
| 1267 | }
|
|---|
| 1268 |
|
|---|
| 1269 | /************************************************************/
|
|---|
| 1270 | /* */
|
|---|
| 1271 | /* This thread is used to handle the object in use emphasis.*/
|
|---|
| 1272 | /* Playing starts on the object window proc. */
|
|---|
| 1273 | /* */
|
|---|
| 1274 | /************************************************************/
|
|---|
| 1275 | void _Optlink playThreadFunc (void *arg)
|
|---|
| 1276 | {
|
|---|
| 1277 | HAB hab;
|
|---|
| 1278 | HMQ hmq;
|
|---|
| 1279 | QMSG qmsg;
|
|---|
| 1280 | OPENPARAMS * params;
|
|---|
| 1281 | CWMMDataFile *thisPtr;
|
|---|
| 1282 | BOOL bCntDecremented=FALSE; /* Flag telling if the play counter was decremented so another audio file may be started. */
|
|---|
| 1283 |
|
|---|
| 1284 | params=(OPENPARAMS*)arg;
|
|---|
| 1285 | if(!params) {
|
|---|
| 1286 | iRunningAudioFiles--;
|
|---|
| 1287 | if(iRunningAudioFiles<0)
|
|---|
| 1288 | iRunningAudioFiles=0;/* Should never happen... */
|
|---|
| 1289 | return;
|
|---|
| 1290 | }
|
|---|
| 1291 |
|
|---|
| 1292 | thisPtr=params->wpObject;
|
|---|
| 1293 | if(!somIsObj(thisPtr)) {
|
|---|
| 1294 | iRunningAudioFiles--;
|
|---|
| 1295 | if(iRunningAudioFiles<0)
|
|---|
| 1296 | iRunningAudioFiles=0;/* Should never happen... */
|
|---|
| 1297 | _wpFreeMem(thisPtr, (PBYTE)params);
|
|---|
| 1298 | return;
|
|---|
| 1299 | }
|
|---|
| 1300 |
|
|---|
| 1301 | /* Prevent starting of several audio files at the same time */
|
|---|
| 1302 | //if(iRunningAudioFiles<MAX_AUDIOFILE_STARTS+1) {
|
|---|
| 1303 | hab=WinInitialize(0);
|
|---|
| 1304 | if(hab) {
|
|---|
| 1305 | hmq=WinCreateMsgQueue(hab,0);
|
|---|
| 1306 | if(hmq) {
|
|---|
| 1307 | HWND hwnd;
|
|---|
| 1308 | BOOL notFound;
|
|---|
| 1309 |
|
|---|
| 1310 | //FIXME
|
|---|
| 1311 | //CWMMDataFileData *somThis = CWMMDataFileGetData(thisPtr);
|
|---|
| 1312 |
|
|---|
| 1313 | if(somIsObj(thisPtr)) {
|
|---|
| 1314 | params->useItem.type=USAGE_OPENVIEW;
|
|---|
| 1315 | params->viewItem.handle=NULLHANDLE;
|
|---|
| 1316 |
|
|---|
| 1317 | /* Create an invisible object window */
|
|---|
| 1318 | hwnd=WinCreateWindow(HWND_OBJECT,WC_STATIC,"playObj", 0, 0, 0, 0, 0,
|
|---|
| 1319 | NULLHANDLE, HWND_BOTTOM,12343,NULL,NULL);
|
|---|
| 1320 | if(hwnd) {
|
|---|
| 1321 | /* Window created. */
|
|---|
| 1322 | /* Set in use emphasis for object */
|
|---|
| 1323 | _wpAddToObjUseList(thisPtr, ¶ms->useItem);
|
|---|
| 1324 |
|
|---|
| 1325 | /* Subclass the object window with the audio object private window proc.
|
|---|
| 1326 | Every audio pbject has to set this in order to manage start/stop/resume command.
|
|---|
| 1327 | It's usually done in MMAudio::wpInitData(). */
|
|---|
| 1328 | WinSubclassWindow(hwnd, _cwmmQueryObjWindowProc(thisPtr));
|
|---|
| 1329 |
|
|---|
| 1330 | // DosSetPriority(PRTYS_THREAD, PRTYC_FOREGROUNDSERVER, 0, 0);
|
|---|
| 1331 |
|
|---|
| 1332 | /* Tell the window proc to start the file */
|
|---|
| 1333 | WinPostMsg(hwnd, WM_APPTERMINATENOTIFY, MPFROMLONG(ACKEY_START), MPFROMP(params));
|
|---|
| 1334 |
|
|---|
| 1335 | /* Save object window pointer in instance data */
|
|---|
| 1336 | //FIXME
|
|---|
| 1337 | //_hwndObjectPlay=hwnd;
|
|---|
| 1338 | __set_hwndObjectPlay(thisPtr, hwnd);
|
|---|
| 1339 | /* Needed for volume setting */
|
|---|
| 1340 | globalHwndObjectPlay=hwnd;
|
|---|
| 1341 | globalObjectPlay=thisPtr;
|
|---|
| 1342 |
|
|---|
| 1343 | while(WinGetMsg(hab,&qmsg,(HWND)NULL,0,0))
|
|---|
| 1344 | WinDispatchMsg(hab,&qmsg);
|
|---|
| 1345 | WinDestroyWindow(hwnd);
|
|---|
| 1346 | _cwmmSetRecordTitles(thisPtr, NULLHANDLE, FALSE);
|
|---|
| 1347 | }
|
|---|
| 1348 | if(somIsObj(thisPtr)) {
|
|---|
| 1349 | /* Remove in use emphasis */
|
|---|
| 1350 | _wpDeleteFromObjUseList(thisPtr, ¶ms->useItem);
|
|---|
| 1351 | //FIXME
|
|---|
| 1352 | //_hwndObjectPlay=NULLHANDLE;
|
|---|
| 1353 | __set_hwndObjectPlay(thisPtr, NULLHANDLE);
|
|---|
| 1354 | // _wpSetDefaultView(thisPtr, _ulPreviousView);
|
|---|
| 1355 | _wpSetDefaultView(thisPtr, __get_ulPreviousView(thisPtr));
|
|---|
| 1356 | }/* somIsObj() */
|
|---|
| 1357 |
|
|---|
| 1358 | iRunningAudioFiles--;
|
|---|
| 1359 | if(iRunningAudioFiles<0)
|
|---|
| 1360 | iRunningAudioFiles=0;/* Should never happen... */
|
|---|
| 1361 | bCntDecremented=TRUE;
|
|---|
| 1362 |
|
|---|
| 1363 | /* The track ended. Check if there're other tracks selected in
|
|---|
| 1364 | the container. If yes, start the next track. */
|
|---|
| 1365 | notFound=TRUE;
|
|---|
| 1366 | for(;;)
|
|---|
| 1367 | {
|
|---|
| 1368 | PMINIRECORDCORE pMrc, mrcTemp;
|
|---|
| 1369 | OPENPARAMS * pParams;
|
|---|
| 1370 | WPObject * contentObject;
|
|---|
| 1371 | SOMClass *cwAudioClass=somGetSomClass("MMAudio");
|
|---|
| 1372 |
|
|---|
| 1373 | pParams=params;
|
|---|
| 1374 |
|
|---|
| 1375 | /* Get MINIRECORDCORE */
|
|---|
| 1376 | if(!(pMrc=_wpQueryCoreRecord(thisPtr)))
|
|---|
| 1377 | break;
|
|---|
| 1378 |
|
|---|
| 1379 | if(!WinIsWindow(WinQueryAnchorBlock(HWND_DESKTOP), pParams->hwndCnr))
|
|---|
| 1380 | break; /* Container isn't valid. Probably the folder was closed. */
|
|---|
| 1381 |
|
|---|
| 1382 | // HlpWriteToTrapLog("Container is valid\n");
|
|---|
| 1383 | /* Remove selected state if any */
|
|---|
| 1384 | WinSendMsg(pParams->hwndCnr, CM_SETRECORDEMPHASIS, MPFROMP(pMrc), MPFROM2SHORT(FALSE, CRA_SELECTED));
|
|---|
| 1385 |
|
|---|
| 1386 | /* Get next selected audio file */
|
|---|
| 1387 | mrcTemp=(PMINIRECORDCORE)WinSendMsg(pParams->hwndCnr,CM_QUERYRECORDEMPHASIS, pMrc,
|
|---|
| 1388 | MPFROMSHORT(CRA_SELECTED));
|
|---|
| 1389 | if((int)mrcTemp==-1)
|
|---|
| 1390 | /* Wrong parameter -> user deleted the shadow. */
|
|---|
| 1391 | break;
|
|---|
| 1392 |
|
|---|
| 1393 | /* No selected files after the currently playing one. So start at the beginnning of the
|
|---|
| 1394 | container. */
|
|---|
| 1395 | if(!mrcTemp)
|
|---|
| 1396 | mrcTemp=(PMINIRECORDCORE)WinSendMsg(pParams->hwndCnr,CM_QUERYRECORDEMPHASIS, (MPARAM)CMA_FIRST,
|
|---|
| 1397 | MPFROMSHORT(CRA_SELECTED));
|
|---|
| 1398 | // HlpWriteToTrapLog("in Thread, iRunning: %d , mrcTemp %x\n", iRunningAudioFiles, mrcTemp);
|
|---|
| 1399 | while(notFound && mrcTemp && (int)mrcTemp!=-1){
|
|---|
| 1400 | contentObject=(WPObject*)OBJECT_FROM_PREC(mrcTemp);//Get object
|
|---|
| 1401 | if(somIsObj(contentObject)) {
|
|---|
| 1402 | /* Get file system object or NULL */
|
|---|
| 1403 | if((contentObject=somGetFileSystemObject(contentObject))==NULLHANDLE) {
|
|---|
| 1404 | mrcTemp=(PMINIRECORDCORE)WinSendMsg(pParams->hwndCnr,CM_QUERYRECORDEMPHASIS, mrcTemp,
|
|---|
| 1405 | MPFROMSHORT(CRA_SELECTED));
|
|---|
| 1406 | continue;
|
|---|
| 1407 | }
|
|---|
| 1408 | }
|
|---|
| 1409 | else
|
|---|
| 1410 | break;/* Error */
|
|---|
| 1411 |
|
|---|
| 1412 | if(_somIsA(contentObject, cwAudioClass)) {
|
|---|
| 1413 | notFound=FALSE;
|
|---|
| 1414 | }
|
|---|
| 1415 | else
|
|---|
| 1416 | {
|
|---|
| 1417 | /* Try next object */
|
|---|
| 1418 | mrcTemp=(PMINIRECORDCORE)WinSendMsg(pParams->hwndCnr,CM_QUERYRECORDEMPHASIS, mrcTemp,
|
|---|
| 1419 | MPFROMSHORT(CRA_SELECTED));
|
|---|
| 1420 | }
|
|---|
| 1421 | }; /* while */
|
|---|
| 1422 | if(notFound)
|
|---|
| 1423 | break;
|
|---|
| 1424 | /* Another audio file is selected. Start it. */
|
|---|
| 1425 | _wpViewObject(contentObject, params->hwndCnr, ID_MENU_START, NULLHANDLE);
|
|---|
| 1426 | break;
|
|---|
| 1427 | }; /* for() */
|
|---|
| 1428 | /* FIXME
|
|---|
| 1429 | Set global handle to NULL if no more files to play. Doing it this way we prevent a race condition
|
|---|
| 1430 | with the newly started thread. No really nice but simple. A mutex wouldn't help because we must
|
|---|
| 1431 | prevent that this ending thread overwrites the handle which may be set by the newly started thread. */
|
|---|
| 1432 | if(notFound) {
|
|---|
| 1433 | globalHwndObjectPlay=NULLHANDLE;
|
|---|
| 1434 | globalObjectPlay=NULLHANDLE;
|
|---|
| 1435 | }
|
|---|
| 1436 | }/* somIsObj() */
|
|---|
| 1437 | WinDestroyMsgQueue(hmq);
|
|---|
| 1438 | }
|
|---|
| 1439 | WinTerminate(hab);
|
|---|
| 1440 | }/* hab */
|
|---|
| 1441 | // }/* iRunningAudioFiles */
|
|---|
| 1442 |
|
|---|
| 1443 | if(!bCntDecremented) {
|
|---|
| 1444 | iRunningAudioFiles--;
|
|---|
| 1445 | if(iRunningAudioFiles<0)
|
|---|
| 1446 | iRunningAudioFiles=0;/* Should never happen... */
|
|---|
| 1447 | }
|
|---|
| 1448 | /* Free the parameter block */
|
|---|
| 1449 | _wpFreeMem(thisPtr, (PBYTE)params);
|
|---|
| 1450 | }
|
|---|
| 1451 |
|
|---|
| 1452 | /****************************************************************/
|
|---|
| 1453 | /* */
|
|---|
| 1454 | /* New method which starts playing of the file. Playing is done */
|
|---|
| 1455 | /* on a separate thread. */
|
|---|
| 1456 | /* */
|
|---|
| 1457 | /****************************************************************/
|
|---|
| 1458 | SOM_Scope void SOMLINK cwaudio_cwmmPlayTrack(MMAudio *somSelf,
|
|---|
| 1459 | HWND hwndCnr, BOOL bPlay)
|
|---|
| 1460 | {
|
|---|
| 1461 | ULONG ulError;
|
|---|
| 1462 | OPENPARAMS *pThreadParams;
|
|---|
| 1463 |
|
|---|
| 1464 | /* CWMMDataFileData *somThis = CWMMDataFileGetData(somSelf); */
|
|---|
| 1465 | MMAudioMethodDebug("MMAudio","cwaudio_cwmmPlayTrack");
|
|---|
| 1466 |
|
|---|
| 1467 | if(bPlay) { /* Start playing */
|
|---|
| 1468 | /* Check if there's a valid object window for handling the play messages. */
|
|---|
| 1469 | //FIXME
|
|---|
| 1470 | // if(!WinIsWindow(WinQueryAnchorBlock(HWND_DESKTOP),_hwndObjectPlay)) {
|
|---|
| 1471 | if(!WinIsWindow(WinQueryAnchorBlock(HWND_DESKTOP),__get_hwndObjectPlay(somSelf))) {
|
|---|
| 1472 | /* Start playing only if there's not an object window yet. This is only
|
|---|
| 1473 | a sanity check. If there's already an object window the track already is
|
|---|
| 1474 | started.
|
|---|
| 1475 | */
|
|---|
| 1476 | pThreadParams=(OPENPARAMS*)_wpAllocMem(somSelf, sizeof(OPENPARAMS), &ulError);
|
|---|
| 1477 | if(pThreadParams) {
|
|---|
| 1478 | char chrTitle[CCHMAXPATH];
|
|---|
| 1479 | char chrText[100];
|
|---|
| 1480 |
|
|---|
| 1481 | strncpy(chrTitle, _wpQueryTitle(somSelf), sizeof(chrTitle));
|
|---|
| 1482 | chrTitle[sizeof(chrTitle)-1]=0;
|
|---|
| 1483 | if(!getMessage(chrText, IDSTR_STARTINGTRACK, sizeof(chrText), queryResModuleHandle(), HWND_DESKTOP))
|
|---|
| 1484 | strcpy(chrText, "Starting Track...");;
|
|---|
| 1485 | strncat(chrTitle,"\n", sizeof(chrTitle)-1-strlen(chrTitle));
|
|---|
| 1486 | strncat(chrTitle, chrText, sizeof(chrTitle)-1-strlen(chrTitle));
|
|---|
| 1487 |
|
|---|
| 1488 | memset((void*)pThreadParams ,0, sizeof(OPENPARAMS));
|
|---|
| 1489 | pThreadParams->wpObject=somSelf;
|
|---|
| 1490 | pThreadParams->hwndCnr=hwndCnr;
|
|---|
| 1491 | pThreadParams->viewItem.view=ID_MENU_START;
|
|---|
| 1492 | if(_beginthread(playThreadFunc,NULL,8192*16,(void*)pThreadParams)) //Fehlerbehandlung fehlt
|
|---|
| 1493 | _cwmmSetRecordTitles(somSelf, chrTitle, FALSE);
|
|---|
| 1494 | }
|
|---|
| 1495 | }
|
|---|
| 1496 | }
|
|---|
| 1497 | else /* Stop playing. */
|
|---|
| 1498 | //FIXME
|
|---|
| 1499 | // if(WinIsWindow(WinQueryAnchorBlock(HWND_DESKTOP),_hwndObjectPlay))
|
|---|
| 1500 | // WinPostMsg(_hwndObjectPlay, WM_APPTERMINATENOTIFY, MPFROMLONG(ACKEY_STOP), MPFROMP(somSelf));
|
|---|
| 1501 | if(WinIsWindow(WinQueryAnchorBlock(HWND_DESKTOP),__get_hwndObjectPlay(somSelf)))
|
|---|
| 1502 | WinPostMsg(__get_hwndObjectPlay(somSelf), WM_APPTERMINATENOTIFY, MPFROMLONG(ACKEY_STOP), MPFROMP(somSelf));
|
|---|
| 1503 | }
|
|---|
| 1504 |
|
|---|
| 1505 |
|
|---|
| 1506 |
|
|---|
| 1507 | /*
|
|---|
| 1508 | This method is called to pause a playing track from the context menu.
|
|---|
| 1509 | */
|
|---|
| 1510 | /*
|
|---|
| 1511 | * LONG cwmmSetTrackVolume(in ULONG ulVolume);
|
|---|
| 1512 | * LONG cwmmQueryTrackVolume();
|
|---|
| 1513 | */
|
|---|
| 1514 |
|
|---|
| 1515 | SOM_Scope void SOMLINK cwaudio_cwmmPauseTrack(MMAudio *somSelf,
|
|---|
| 1516 | HWND hwndCnr,
|
|---|
| 1517 | ULONG ulAction)
|
|---|
| 1518 | {
|
|---|
| 1519 | /* CWMMDataFileData *somThis = CWMMDataFileGetData(somSelf);*/
|
|---|
| 1520 | MMAudioMethodDebug("MMAudio","cwaudio_cwmmPauseTrack");
|
|---|
| 1521 |
|
|---|
| 1522 | if(_cwmmQueryTrackStatus(somSelf)==TRACK_STATUS_STOPPED)
|
|---|
| 1523 | return;
|
|---|
| 1524 |
|
|---|
| 1525 | switch(ulAction)
|
|---|
| 1526 | {
|
|---|
| 1527 | case ACKEY_PAUSE:
|
|---|
| 1528 |
|
|---|
| 1529 | /* Already paused? Shouldn't happen but I've seen it. */
|
|---|
| 1530 | if(_cwmmQueryTrackStatus(somSelf)==TRACK_STATUS_PAUSED)
|
|---|
| 1531 | return;
|
|---|
| 1532 |
|
|---|
| 1533 | /* Post a message to the object window handling the commands. */
|
|---|
| 1534 | //FIXME
|
|---|
| 1535 | // if(WinIsWindow(WinQueryAnchorBlock(HWND_DESKTOP),_hwndObjectPlay))
|
|---|
| 1536 | // WinPostMsg(_hwndObjectPlay, WM_APPTERMINATENOTIFY, MPFROMLONG(ulAction), MPFROMP(somSelf));
|
|---|
| 1537 | if(WinIsWindow(WinQueryAnchorBlock(HWND_DESKTOP),__get_hwndObjectPlay(somSelf)))
|
|---|
| 1538 | WinPostMsg(__get_hwndObjectPlay(somSelf), WM_APPTERMINATENOTIFY, MPFROMLONG(ulAction), MPFROMP(somSelf));
|
|---|
| 1539 |
|
|---|
| 1540 | break;
|
|---|
| 1541 | case ACKEY_RESUME:
|
|---|
| 1542 |
|
|---|
| 1543 | if(_cwmmQueryTrackStatus(somSelf)==TRACK_STATUS_PLAYING)
|
|---|
| 1544 | return;
|
|---|
| 1545 | //FIXME
|
|---|
| 1546 | // if(WinIsWindow(WinQueryAnchorBlock(HWND_DESKTOP),_hwndObjectPlay))
|
|---|
| 1547 | // WinPostMsg(_hwndObjectPlay, WM_APPTERMINATENOTIFY, MPFROMLONG(ulAction), MPFROMP(somSelf));
|
|---|
| 1548 | if(WinIsWindow(WinQueryAnchorBlock(HWND_DESKTOP), __get_hwndObjectPlay(somSelf)))
|
|---|
| 1549 | WinPostMsg(__get_hwndObjectPlay(somSelf), WM_APPTERMINATENOTIFY, MPFROMLONG(ulAction), MPFROMP(somSelf));
|
|---|
| 1550 | break;
|
|---|
| 1551 | default:
|
|---|
| 1552 | break;
|
|---|
| 1553 | }
|
|---|
| 1554 | }
|
|---|
| 1555 |
|
|---|
| 1556 | #if 0
|
|---|
| 1557 | SOM_Scope long SOMLINK cwaudio_cwmmSetTrackVolume(MMAudio *somSelf,
|
|---|
| 1558 | ULONG ulVolume)
|
|---|
| 1559 | {
|
|---|
| 1560 | MMAudioData *somThis = MMAudioGetData(somSelf);
|
|---|
| 1561 | MMAudioMethodDebug("MMAudio","cwaudio_cwmmSetTrackVolume");
|
|---|
| 1562 |
|
|---|
| 1563 | /* Return statement to be customized: */
|
|---|
| 1564 | return -1;
|
|---|
| 1565 | }
|
|---|
| 1566 |
|
|---|
| 1567 | SOM_Scope long SOMLINK cwaudio_cwmmQueryTrackVolume(MMAudio *somSelf)
|
|---|
| 1568 | {
|
|---|
| 1569 | MMAudioData *somThis = MMAudioGetData(somSelf);
|
|---|
| 1570 | MMAudioMethodDebug("MMAudio","cwaudio_cwmmQueryTrackVolume");
|
|---|
| 1571 |
|
|---|
| 1572 | /* Return statement to be customized: */
|
|---|
| 1573 | return -1;
|
|---|
| 1574 | }
|
|---|
| 1575 | #endif
|
|---|
| 1576 |
|
|---|
| 1577 | /****************************************************************/
|
|---|
| 1578 | /*
|
|---|
| 1579 | Two new settings pages are added to every audio object:
|
|---|
| 1580 |
|
|---|
| 1581 | -Audio information showing playtime samplerate and so on.
|
|---|
| 1582 | -Track information for editing artist name, album name and so
|
|---|
| 1583 | on.
|
|---|
| 1584 |
|
|---|
| 1585 | */
|
|---|
| 1586 | /****************************************************************/
|
|---|
| 1587 | SOM_Scope BOOL SOMLINK cwaudio_wpAddSettingsPages(MMAudio *somSelf,
|
|---|
| 1588 | HWND hwndNotebook)
|
|---|
| 1589 | {
|
|---|
| 1590 | BOOL rc;
|
|---|
| 1591 |
|
|---|
| 1592 | /* MMAudioData *somThis = MMAudioGetData(somSelf);*/
|
|---|
| 1593 | MMAudioMethodDebug("MMAudio","cwaudio_wpAddSettingsPages");
|
|---|
| 1594 |
|
|---|
| 1595 |
|
|---|
| 1596 | rc= (MMAudio_parent_CWMMDataFile_wpAddSettingsPages(somSelf, hwndNotebook));
|
|---|
| 1597 |
|
|---|
| 1598 | return rc | _cwmmAddAudioInformationPage(somSelf, hwndNotebook)|
|
|---|
| 1599 | _cwmmAddTrackNamePage(somSelf, hwndNotebook);
|
|---|
| 1600 | }
|
|---|
| 1601 |
|
|---|
| 1602 | /*
|
|---|
| 1603 | * The prototype for cwaudio_wpQueryDetailsData was replaced by the following prototype:
|
|---|
| 1604 | */
|
|---|
| 1605 | SOM_Scope ULONG SOMLINK cwaudio_wpQueryDetailsData(MMAudio *somSelf,
|
|---|
| 1606 | PVOID* ppDetailsData,
|
|---|
| 1607 | PULONG pcp)
|
|---|
| 1608 | {
|
|---|
| 1609 | BOOL rcParent;
|
|---|
| 1610 | PAUDIODETAILS pAudioDetails;
|
|---|
| 1611 | MMAudioData *somThis = MMAudioGetData(somSelf);
|
|---|
| 1612 | MMAudioMethodDebug("MMAudio","cwaudio_wpQueryDetailsData");
|
|---|
| 1613 |
|
|---|
| 1614 | /* Call parent */
|
|---|
| 1615 | rcParent= (MMAudio_parent_CWMMDataFile_wpQueryDetailsData(somSelf,
|
|---|
| 1616 | ppDetailsData,
|
|---|
| 1617 | pcp));
|
|---|
| 1618 |
|
|---|
| 1619 | /* The WPS asks for data to be displayed */
|
|---|
| 1620 | if(ppDetailsData)
|
|---|
| 1621 | {
|
|---|
| 1622 | /* Fill the structure with the info to be displayed */
|
|---|
| 1623 | pAudioDetails=(PAUDIODETAILS)*ppDetailsData;
|
|---|
| 1624 | pAudioDetails->pszPlayTime=_chrPlayTime;
|
|---|
| 1625 | pAudioDetails->pszBitRate=_chrBitRate; /* New with 0.2.7 */
|
|---|
| 1626 | pAudioDetails->pszSampleRate=_chrSampleRate;
|
|---|
| 1627 | pAudioDetails->pszChannels=_chrChannels;
|
|---|
| 1628 | pAudioDetails->pszBPS=_chrBPS;
|
|---|
| 1629 |
|
|---|
| 1630 | pAudioDetails->pszName=_pszName;
|
|---|
| 1631 | pAudioDetails->pszArtist=_pszArtist;
|
|---|
| 1632 | pAudioDetails->pszAlbum=_pszAlbum;
|
|---|
| 1633 | pAudioDetails->pszYear=_pszYear;
|
|---|
| 1634 | pAudioDetails->pszComment=_pszComment;
|
|---|
| 1635 | pAudioDetails->pszGenre=_pszGenre;
|
|---|
| 1636 |
|
|---|
| 1637 | #if 0
|
|---|
| 1638 | pAudioDetails->pszName=_id3Name;
|
|---|
| 1639 | pAudioDetails->pszArtist=_id3Artist;
|
|---|
| 1640 | pAudioDetails->pszAlbum=_id3Album;
|
|---|
| 1641 | pAudioDetails->pszYear=_id3Year;
|
|---|
| 1642 | pAudioDetails->pszComment=_id3Comment;
|
|---|
| 1643 | pAudioDetails->pszGenre=_id3Genre;
|
|---|
| 1644 | #endif
|
|---|
| 1645 | *ppDetailsData=((PBYTE) (*ppDetailsData))+sizeof(*pAudioDetails);
|
|---|
| 1646 | }
|
|---|
| 1647 | else
|
|---|
| 1648 | {
|
|---|
| 1649 | /* Buffer size is queried */
|
|---|
| 1650 | if(pcp)
|
|---|
| 1651 | *pcp+=sizeof(*pAudioDetails);
|
|---|
| 1652 | }
|
|---|
| 1653 | return rcParent;
|
|---|
| 1654 | }
|
|---|
| 1655 |
|
|---|
| 1656 |
|
|---|
| 1657 | /*
|
|---|
| 1658 | * The prototype for cwaudio_wpRestoreState was replaced by the following prototype:
|
|---|
| 1659 | */
|
|---|
| 1660 | SOM_Scope BOOL SOMLINK cwaudio_wpRestoreState(MMAudio *somSelf,
|
|---|
| 1661 | ULONG ulReserved)
|
|---|
| 1662 | {
|
|---|
| 1663 | BOOL bRc;
|
|---|
| 1664 | char fName[CCHMAXPATH];
|
|---|
| 1665 | BOOL bReRead=FALSE;
|
|---|
| 1666 | ULONG ulError;
|
|---|
| 1667 | BOOL bIsMidi;
|
|---|
| 1668 | PBYTE pByte;
|
|---|
| 1669 |
|
|---|
| 1670 | MMAudioData *somThis = MMAudioGetData(somSelf);
|
|---|
| 1671 | MMAudioMethodDebug("MMAudio","cwaudio_wpRestoreState");
|
|---|
| 1672 |
|
|---|
| 1673 | bRc=(MMAudio_parent_CWMMDataFile_wpRestoreState(somSelf, ulReserved));
|
|---|
| 1674 |
|
|---|
| 1675 | _bNeedSaving=FALSE;
|
|---|
| 1676 |
|
|---|
| 1677 | /* Query the audio info */
|
|---|
| 1678 | if(!_wpRestoreLong(somSelf, "CWAudio", KEY_FILESIZE, &_ulFileSize))
|
|---|
| 1679 | bReRead=TRUE;
|
|---|
| 1680 | if(!_wpRestoreLong(somSelf, "CWAudio", KEY_TIME, &_ulPlaySecs))
|
|---|
| 1681 | bReRead=TRUE;
|
|---|
| 1682 | if(!_wpRestoreLong(somSelf, "CWAudio", KEY_CHANNELS, &_ulChannels))
|
|---|
| 1683 | bReRead=TRUE;
|
|---|
| 1684 | if(!_wpRestoreLong(somSelf, "CWAudio", KEY_SAMPLERATE, &_ulSampleRate))
|
|---|
| 1685 | bReRead=TRUE;
|
|---|
| 1686 | if(!_wpRestoreLong(somSelf, "CWAudio", KEY_BPS, &_ulBPS))
|
|---|
| 1687 | bReRead=TRUE;
|
|---|
| 1688 | if(!_wpRestoreLong(somSelf, "CWAudio", KEY_TIME_MS, &_ulPlayMsecs))
|
|---|
| 1689 | bReRead=TRUE;
|
|---|
| 1690 | if(!_wpRestoreLong(somSelf, "CWAudio", KEY_NUM_AUDIO_BYTES, &_ulNumAudioBytes))
|
|---|
| 1691 | bReRead=TRUE;
|
|---|
| 1692 |
|
|---|
| 1693 | /* New with 0.2.7 */
|
|---|
| 1694 | if(EARestoreString(somSelf, "MMBITRATE", _chrBitRate, sizeof(_chrBitRate))) {
|
|---|
| 1695 | _ulBitRate=atol(_chrBitRate);
|
|---|
| 1696 | }
|
|---|
| 1697 | else {
|
|---|
| 1698 | //SysWriteToTrapLog("No EA for %s\n", _wpQueryTitle(somSelf));
|
|---|
| 1699 | bReRead=TRUE;
|
|---|
| 1700 | }
|
|---|
| 1701 | /* Get audiotrack info from EA */
|
|---|
| 1702 | if( (pByte=_wpAllocMem(somSelf, MAX_EA_SIZE, &ulError))!=NULLHANDLE)
|
|---|
| 1703 | {
|
|---|
| 1704 | _pszName=_readTrackInfoIntoMem(somSelf, "MMTRACKNAME" , pByte, MAX_EA_SIZE);
|
|---|
| 1705 | _pszArtist=_readTrackInfoIntoMem(somSelf, "MMARTIST" , pByte, MAX_EA_SIZE);
|
|---|
| 1706 | _pszAlbum=_readTrackInfoIntoMem(somSelf, "MMALBUM" , pByte, MAX_EA_SIZE);
|
|---|
| 1707 | _pszYear=_readTrackInfoIntoMem(somSelf, "MMYEAR" , pByte, MAX_EA_SIZE);
|
|---|
| 1708 | _pszComment=_readTrackInfoIntoMem(somSelf, "MMCOMMENT" , pByte, MAX_EA_SIZE);
|
|---|
| 1709 | _pszGenre=_readTrackInfoIntoMem(somSelf, "MMGENRE" , pByte, MAX_EA_SIZE);
|
|---|
| 1710 | _wpFreeMem(somSelf, pByte);
|
|---|
| 1711 | }
|
|---|
| 1712 |
|
|---|
| 1713 | #if 0
|
|---|
| 1714 | cwGetStringFromEA(somSelf, "MMTRACKNAME" , _id3Name, sizeof(_id3Name));
|
|---|
| 1715 | cwGetStringFromEA(somSelf, "MMARTIST" , _id3Artist, sizeof(_id3Artist));
|
|---|
| 1716 | cwGetStringFromEA(somSelf, "MMALBUM" , _id3Album, sizeof(_id3Album));
|
|---|
| 1717 | cwGetStringFromEA(somSelf, "MMYEAR" , _id3Year, sizeof(_id3Year));
|
|---|
| 1718 | cwGetStringFromEA(somSelf, "MMCOMMENT" , _id3Comment, sizeof(_id3Comment));
|
|---|
| 1719 | cwGetStringFromEA(somSelf, "MMGENRE" , _id3Genre, sizeof(_id3Genre));
|
|---|
| 1720 |
|
|---|
| 1721 | sprintf(chrBuffer,"%d",_ulSampleRate);
|
|---|
| 1722 | cwSaveStringToEA(somSelf, "MMSAMPLERATE", chrBuffer);
|
|---|
| 1723 | sprintf(chrBuffer,"%d",_ulChannels);
|
|---|
| 1724 | cwSaveStringToEA(somSelf, "MMCHANNELS", chrBuffer);
|
|---|
| 1725 | sprintf(chrBuffer,"%d",_ulBPS);
|
|---|
| 1726 | cwSaveStringToEA(somSelf, "MMBPS", chrBuffer);
|
|---|
| 1727 | sprintf(chrBuffer,"%d",_ulPlaySecs);
|
|---|
| 1728 | cwSaveStringToEA(somSelf, "MMPLAYTIME", chrBuffer);
|
|---|
| 1729 | sprintf(chrBuffer,"%d",_ulPlayMsecs);
|
|---|
| 1730 | cwSaveStringToEA(somSelf, "MMPLAYTIMEMS", chrBuffer);
|
|---|
| 1731 | #endif
|
|---|
| 1732 |
|
|---|
| 1733 | if(_ulFileSize!=_wpQueryFileSize(somSelf))
|
|---|
| 1734 | bReRead=TRUE; /* The filesize changed, somebody altered the audio file so reread the info */
|
|---|
| 1735 |
|
|---|
| 1736 | if(!_ulFileSize)
|
|---|
| 1737 | bReRead=FALSE;
|
|---|
| 1738 | /* If filesize=0 do nothing because the file was just created and there's no contents yet */
|
|---|
| 1739 |
|
|---|
| 1740 | if(cwObjectIsOnCD(somSelf) && bReRead) {
|
|---|
| 1741 | /* Only get audio info when file isn't on CD. This speeds up opening of folders on CDs filled with
|
|---|
| 1742 | MP3s. Doesn't hurt because folders of CDs open in normal details view as default so the audio info
|
|---|
| 1743 | isn't necessary. When opening the settings notebook the info is reread anyway. */
|
|---|
| 1744 | bReRead=FALSE;
|
|---|
| 1745 | }
|
|---|
| 1746 | bIsMidi=_somIsA(somSelf, somGetSomClass("MMMIDI"));
|
|---|
| 1747 | if(bReRead){
|
|---|
| 1748 | /* Some info changed or isn't present. Reread the audio information */
|
|---|
| 1749 | /* Get data pointer of class object */
|
|---|
| 1750 | // M_CWMMDataFileData *cwmmData = M_CWMMDataFileGetData(_CWMMDataFile);
|
|---|
| 1751 |
|
|---|
| 1752 | /* Send the object pointer to the audio worker thread to read the audio info in the background.
|
|---|
| 1753 | The audio worker thread was started during initialization of CWMMDataFile.
|
|---|
| 1754 | */
|
|---|
| 1755 | //FIXME
|
|---|
| 1756 | // WinPostMsg(cwmmData->hwndAudioWorker , WM_APPTERMINATENOTIFY, somSelf, 0);
|
|---|
| 1757 | WinPostMsg(__get_hwndAudioWorker(_CWMMDataFile) , WM_APPTERMINATENOTIFY, somSelf, 0);
|
|---|
| 1758 |
|
|---|
| 1759 | /* Set default values into instance vars */
|
|---|
| 1760 | if(bIsMidi)
|
|---|
| 1761 | {
|
|---|
| 1762 | /* MIDI files don't have this info. */
|
|---|
| 1763 | strncpy(_chrSampleRate, "---", sizeof(_chrSampleRate));
|
|---|
| 1764 | strncpy(_chrBPS, "---", sizeof(_chrBPS));
|
|---|
| 1765 | }
|
|---|
| 1766 | else
|
|---|
| 1767 | {
|
|---|
| 1768 | strncpy(_chrSampleRate, "??", sizeof(_chrSampleRate));
|
|---|
| 1769 | strncpy(_chrBPS, "??", sizeof(_chrBPS));
|
|---|
| 1770 | }
|
|---|
| 1771 | strncpy(_chrBitRate, "---", sizeof(_chrBitRate));
|
|---|
| 1772 | strncpy(_chrChannels, "??", sizeof(_chrChannels));
|
|---|
| 1773 | strncpy(_chrPlayTime, "??:??", sizeof(_chrPlayTime));
|
|---|
| 1774 |
|
|---|
| 1775 | _ulFileSize=0;
|
|---|
| 1776 | _ulPlaySecs=0;
|
|---|
| 1777 | _ulChannels=0;
|
|---|
| 1778 | _ulSampleRate=0;
|
|---|
| 1779 | _ulBitRate=0;
|
|---|
| 1780 | _ulBPS=0;
|
|---|
| 1781 | _ulPlayMsecs=0;
|
|---|
| 1782 | _ulNumAudioBytes=0;
|
|---|
| 1783 | }/* bReRead */
|
|---|
| 1784 | else {
|
|---|
| 1785 | /* No new reading necessary. Fill in the instance vars with the restored
|
|---|
| 1786 | data. */
|
|---|
| 1787 | sprintf(fName,"%d",_ulChannels);
|
|---|
| 1788 | strncpy(_chrChannels, fName, sizeof(_chrChannels));
|
|---|
| 1789 |
|
|---|
| 1790 | if(bIsMidi)
|
|---|
| 1791 | strncpy(_chrSampleRate, "---", sizeof(_chrSampleRate));
|
|---|
| 1792 | else {
|
|---|
| 1793 | sprintf(fName,"%d", _ulSampleRate);
|
|---|
| 1794 | strncpy(_chrSampleRate, fName, sizeof(_chrSampleRate));
|
|---|
| 1795 | }
|
|---|
| 1796 |
|
|---|
| 1797 | if(bIsMidi)
|
|---|
| 1798 | strncpy(_chrBPS, "---", sizeof(_chrBPS));
|
|---|
| 1799 | else {
|
|---|
| 1800 | sprintf(fName,"%d",_ulBPS);
|
|---|
| 1801 | strncpy(_chrBPS, fName, sizeof(_chrBPS));
|
|---|
| 1802 | }
|
|---|
| 1803 | /* Bitrate of MP3 files */
|
|---|
| 1804 | if(!_ulBitRate)
|
|---|
| 1805 | strncpy(_chrBitRate, "---", sizeof(_chrBitRate));
|
|---|
| 1806 | else {
|
|---|
| 1807 | sprintf(fName,"%d",_ulBitRate);
|
|---|
| 1808 | strncpy(_chrBitRate, fName, sizeof(_chrBitRate));
|
|---|
| 1809 | }
|
|---|
| 1810 |
|
|---|
| 1811 | sprintf(fName,"%02d:%02d",_ulPlaySecs/60, _ulPlaySecs%60);
|
|---|
| 1812 | strncpy(_chrPlayTime, fName, sizeof(_chrPlayTime));
|
|---|
| 1813 | }
|
|---|
| 1814 | _chrChannels[sizeof(_chrChannels)-1]=0;
|
|---|
| 1815 | _chrSampleRate[sizeof(_chrSampleRate)-1]=0;
|
|---|
| 1816 | _chrBPS[sizeof(_chrBPS)-1]=0;
|
|---|
| 1817 | _chrPlayTime[sizeof(_chrPlayTime)-1]=0;
|
|---|
| 1818 |
|
|---|
| 1819 | return bRc;
|
|---|
| 1820 | }
|
|---|
| 1821 |
|
|---|
| 1822 |
|
|---|
| 1823 | /*
|
|---|
| 1824 | * The prototype for cwaudio_wpSaveState was replaced by the following prototype:
|
|---|
| 1825 | */
|
|---|
| 1826 | SOM_Scope BOOL SOMLINK cwaudio_wpSaveState(MMAudio *somSelf)
|
|---|
| 1827 | {
|
|---|
| 1828 | char chrBuffer[10];
|
|---|
| 1829 |
|
|---|
| 1830 | MMAudioData *somThis = MMAudioGetData(somSelf);
|
|---|
| 1831 | MMAudioMethodDebug("MMAudio","cwaudio_wpSaveState");
|
|---|
| 1832 |
|
|---|
| 1833 |
|
|---|
| 1834 | if(_ulFileSize) {
|
|---|
| 1835 | _wpSaveLong(somSelf, "CWAudio", KEY_TIME,_ulPlaySecs);
|
|---|
| 1836 | _wpSaveLong(somSelf, "CWAudio", KEY_SAMPLERATE,_ulSampleRate);
|
|---|
| 1837 | _wpSaveLong(somSelf, "CWAudio", KEY_CHANNELS,_ulChannels);
|
|---|
| 1838 | _wpSaveLong(somSelf, "CWAudio", KEY_BPS,_ulBPS);
|
|---|
| 1839 | _wpSaveLong(somSelf, "CWAudio", KEY_FILESIZE,_ulFileSize);
|
|---|
| 1840 | _wpSaveLong(somSelf, "CWAudio", KEY_TIME_MS,_ulPlayMsecs);
|
|---|
| 1841 | _wpSaveLong(somSelf, "CWAudio", KEY_NUM_AUDIO_BYTES, _ulNumAudioBytes);
|
|---|
| 1842 | }
|
|---|
| 1843 |
|
|---|
| 1844 | /* Save audio info in EA for other programs */
|
|---|
| 1845 | cwSaveStringToEA(somSelf, "MMTRACKNAME", _pszName);
|
|---|
| 1846 | cwSaveStringToEA(somSelf, "MMARTIST", _pszArtist);
|
|---|
| 1847 | cwSaveStringToEA(somSelf, "MMALBUM", _pszAlbum);
|
|---|
| 1848 | cwSaveStringToEA(somSelf, "MMCOMMENT", _pszComment);
|
|---|
| 1849 | cwSaveStringToEA(somSelf, "MMYEAR", _pszYear);
|
|---|
| 1850 | cwSaveStringToEA(somSelf, "MMGENRE", _pszGenre);
|
|---|
| 1851 |
|
|---|
| 1852 |
|
|---|
| 1853 | #if 0
|
|---|
| 1854 | cwSaveStringToEA(somSelf, "MMTRACKNAME", _id3Name);
|
|---|
| 1855 | cwSaveStringToEA(somSelf, "MMARTIST", _id3Artist);
|
|---|
| 1856 | cwSaveStringToEA(somSelf, "MMALBUM", _id3Album);
|
|---|
| 1857 | cwSaveStringToEA(somSelf, "MMCOMMENT", _id3Comment);
|
|---|
| 1858 | cwSaveStringToEA(somSelf, "MMYEAR", _id3Year);
|
|---|
| 1859 | cwSaveStringToEA(somSelf, "MMGENRE", _id3Genre);
|
|---|
| 1860 | #endif
|
|---|
| 1861 |
|
|---|
| 1862 | sprintf(chrBuffer,"%d",_ulSampleRate);
|
|---|
| 1863 | cwSaveStringToEA(somSelf, "MMSAMPLERATE", chrBuffer);
|
|---|
| 1864 | sprintf(chrBuffer,"%d",_ulChannels);
|
|---|
| 1865 | cwSaveStringToEA(somSelf, "MMCHANNELS", chrBuffer);
|
|---|
| 1866 | sprintf(chrBuffer,"%d",_ulBPS);
|
|---|
| 1867 | cwSaveStringToEA(somSelf, "MMBPS", chrBuffer);
|
|---|
| 1868 | sprintf(chrBuffer,"%d",_ulPlaySecs);
|
|---|
| 1869 | cwSaveStringToEA(somSelf, "MMPLAYTIME", chrBuffer);
|
|---|
| 1870 | sprintf(chrBuffer,"%d",_ulPlayMsecs);
|
|---|
| 1871 | cwSaveStringToEA(somSelf, "MMPLAYTIMEMS", chrBuffer);
|
|---|
| 1872 | sprintf(chrBuffer,"%d",_ulNumAudioBytes);
|
|---|
| 1873 | cwSaveStringToEA(somSelf, "MMNUMAUDIOBYTES", chrBuffer);
|
|---|
| 1874 |
|
|---|
| 1875 | /* New with 0.2.7 */
|
|---|
| 1876 | sprintf(chrBuffer,"%d",_ulBitRate);
|
|---|
| 1877 | EASaveString(somSelf, "MMBITRATE", chrBuffer);
|
|---|
| 1878 |
|
|---|
| 1879 | #if 0
|
|---|
| 1880 | cwGetStringFromEA(somSelf, "MMTRACKNAME" , chrBuf, sizeof(chrBuf));
|
|---|
| 1881 | HlpWriteToTrapLog("Value: %s\n", chrBuf);
|
|---|
| 1882 | cwGetStringFromEA(somSelf, "MMARTIST" , chrBuffer, sizeof(chrBuffer));
|
|---|
| 1883 | cwGetStringFromEA(somSelf, "MMALBUM" , chrBuffer, sizeof(chrBuffer));
|
|---|
| 1884 | #endif
|
|---|
| 1885 |
|
|---|
| 1886 | #if 0
|
|---|
| 1887 | /* Set .TYPE EA so the editor and the player are happy. */
|
|---|
| 1888 | strncpy(chrBuf, _wpQueryType(somSelf), sizeof(chrBuf));
|
|---|
| 1889 | chrBuf[sizeof(chrBuf)-1]=0;
|
|---|
| 1890 |
|
|---|
| 1891 | if(!strstr(chrBuf, TYPE_DIGITALAUDIO)) {
|
|---|
| 1892 | ulLength=strlen(chrBuf);
|
|---|
| 1893 | if(ulLength) {
|
|---|
| 1894 | if(ulLength+2+sizeof(TYPE_DIGITALAUDIO) < sizeof(chrBuf)) {
|
|---|
| 1895 | strcat(chrBuf, "\n");
|
|---|
| 1896 | strcat(chrBuf, TYPE_DIGITALAUDIO);
|
|---|
| 1897 | }
|
|---|
| 1898 | }
|
|---|
| 1899 | else
|
|---|
| 1900 | strcpy(chrBuf, TYPE_DIGITALAUDIO);
|
|---|
| 1901 | /* Set .TYPE EA so the editor and the player are happy. */
|
|---|
| 1902 | _wpSetType(somSelf, chrBuf , NULL);
|
|---|
| 1903 | }
|
|---|
| 1904 | #endif
|
|---|
| 1905 | //_wpSetType(somSelf, "Digital Audio" , NULL);
|
|---|
| 1906 | return (MMAudio_parent_CWMMDataFile_wpSaveState(somSelf));
|
|---|
| 1907 | }
|
|---|
| 1908 |
|
|---|
| 1909 | /*
|
|---|
| 1910 | FIXME:
|
|---|
| 1911 |
|
|---|
| 1912 | This function isn't thread safe because of one global memory area. It is supposed to be
|
|---|
| 1913 | called from the wpPopupMenu() method. This method can only be called once at
|
|---|
| 1914 | a time, so that's not a problem. It may become a problem if this function is also
|
|---|
| 1915 | called from somewhere else. The global mem pointer is used by the image class and the
|
|---|
| 1916 | audio class.
|
|---|
| 1917 |
|
|---|
| 1918 | This function inserts only write enabled IO procedures into the menu.
|
|---|
| 1919 | */
|
|---|
| 1920 | static BOOL insertAudioIOProcMenuItems( HWND hwndMenu )
|
|---|
| 1921 | {
|
|---|
| 1922 | CHAR szBuffer[ sizeof( FOURCC ) + CCHMAXPATH + 4 ];
|
|---|
| 1923 | MMFORMATINFO mmFormatInfo;
|
|---|
| 1924 | PMMFORMATINFO pmmFormatInfoArray;
|
|---|
| 1925 | ULONG ulReturnCode;
|
|---|
| 1926 | LONG lFormatsRead;
|
|---|
| 1927 | LONG index;
|
|---|
| 1928 | LONG lBytesRead;
|
|---|
| 1929 | HWND hwndSubMenu;
|
|---|
| 1930 | MENUITEM mi;
|
|---|
| 1931 | LONG lNumIOProcs;
|
|---|
| 1932 |
|
|---|
| 1933 | if(g_pmmFormatInfoArray)
|
|---|
| 1934 | free(g_pmmFormatInfoArray);
|
|---|
| 1935 | g_pmmFormatInfoArray=NULLHANDLE;
|
|---|
| 1936 |
|
|---|
| 1937 | memset( &mmFormatInfo,
|
|---|
| 1938 | '\0',
|
|---|
| 1939 | sizeof(MMFORMATINFO) );
|
|---|
| 1940 |
|
|---|
| 1941 | mmFormatInfo.ulMediaType |= MMIO_MEDIATYPE_AUDIO;
|
|---|
| 1942 | mmFormatInfo.ulFlags|=MMIO_CANWRITETRANSLATED;/* FIXME: CANWRITEUNTRANSLATED???*/
|
|---|
| 1943 | ulReturnCode = mmioQueryFormatCount ( &mmFormatInfo,
|
|---|
| 1944 | &lNumIOProcs,
|
|---|
| 1945 | 0,
|
|---|
| 1946 | 0 );
|
|---|
| 1947 |
|
|---|
| 1948 | if( ulReturnCode != MMIO_SUCCESS )
|
|---|
| 1949 | {
|
|---|
| 1950 | /* Error - mmioQueryFormatCount failed. */
|
|---|
| 1951 | return FALSE;
|
|---|
| 1952 | }
|
|---|
| 1953 |
|
|---|
| 1954 | /*
|
|---|
| 1955 | * Allocate enough memory for n number of FormatInfo blocks
|
|---|
| 1956 | */
|
|---|
| 1957 | g_pmmFormatInfoArray = malloc (lNumIOProcs * sizeof( MMFORMATINFO ) );
|
|---|
| 1958 | if( g_pmmFormatInfoArray == NULL )
|
|---|
| 1959 | {
|
|---|
| 1960 | /* Could not allocate enough memory for mmFormatInfo array. */
|
|---|
| 1961 | return FALSE;
|
|---|
| 1962 | }
|
|---|
| 1963 |
|
|---|
| 1964 | /*
|
|---|
| 1965 | * call mmioGetFormats to get info on the formats supported.
|
|---|
| 1966 | */
|
|---|
| 1967 | ulReturnCode = mmioGetFormats( &mmFormatInfo,
|
|---|
| 1968 | lNumIOProcs,
|
|---|
| 1969 | g_pmmFormatInfoArray,
|
|---|
| 1970 | &lFormatsRead,
|
|---|
| 1971 | 0,
|
|---|
| 1972 | 0 );
|
|---|
| 1973 | if( ulReturnCode != MMIO_SUCCESS )
|
|---|
| 1974 | {
|
|---|
| 1975 | /*
|
|---|
| 1976 | * mmioGetFormats failed.
|
|---|
| 1977 | */
|
|---|
| 1978 | free(g_pmmFormatInfoArray);
|
|---|
| 1979 | g_pmmFormatInfoArray=NULLHANDLE;
|
|---|
| 1980 | return FALSE;
|
|---|
| 1981 | }
|
|---|
| 1982 |
|
|---|
| 1983 | if( lFormatsRead != lNumIOProcs )
|
|---|
| 1984 | {
|
|---|
| 1985 | /*
|
|---|
| 1986 | * Error in MMIO - number of formats read in by
|
|---|
| 1987 | * mmioGetFormats is not equal to number of formats
|
|---|
| 1988 | * found by mmioQueryFormatCount.
|
|---|
| 1989 | */
|
|---|
| 1990 | free(g_pmmFormatInfoArray);
|
|---|
| 1991 | g_pmmFormatInfoArray=NULLHANDLE;
|
|---|
| 1992 | return FALSE;
|
|---|
| 1993 | }
|
|---|
| 1994 |
|
|---|
| 1995 | // Create Empty Submenu //
|
|---|
| 1996 | hwndSubMenu=WinCreateWindow(hwndMenu,WC_MENU,"",0,
|
|---|
| 1997 | 0,0,0,0,
|
|---|
| 1998 | hwndMenu,//Owner. If set, this window
|
|---|
| 1999 | //is destroyed if owner is destroyed
|
|---|
| 2000 | HWND_TOP,
|
|---|
| 2001 | ID_MENU_CONVERT,//menuid
|
|---|
| 2002 | NULL,NULL);
|
|---|
| 2003 |
|
|---|
| 2004 | mi.iPosition=MIT_END;
|
|---|
| 2005 | mi.afStyle=MIS_TEXT;//|MIS_SUBMENU;
|
|---|
| 2006 | mi.id=ID_MENU_CONVERT;
|
|---|
| 2007 | mi.afAttribute=NULLHANDLE;
|
|---|
| 2008 | mi.hwndSubMenu=NULLHANDLE;//hwndSubMenu;
|
|---|
| 2009 | mi.hItem=NULLHANDLE;
|
|---|
| 2010 | mi.hwndSubMenu=hwndSubMenu;
|
|---|
| 2011 |
|
|---|
| 2012 | if(!getMessage(szBuffer, IDSTR_MENU_CONVERT, sizeof(szBuffer), queryResModuleHandle(), HWND_DESKTOP))
|
|---|
| 2013 | sprintf(szBuffer,"~Convert to");
|
|---|
| 2014 | WinSendMsg(hwndMenu,MM_INSERTITEM,(MPARAM)&mi,
|
|---|
| 2015 | (MPARAM)szBuffer);
|
|---|
| 2016 |
|
|---|
| 2017 | pmmFormatInfoArray=g_pmmFormatInfoArray;
|
|---|
| 2018 | for ( index = 0; index <lNumIOProcs; index++ )
|
|---|
| 2019 | {
|
|---|
| 2020 | mmioGetFormatName(pmmFormatInfoArray, szBuffer, &lBytesRead, 0L, 0L);
|
|---|
| 2021 |
|
|---|
| 2022 | /* Insert NULL string terminator */
|
|---|
| 2023 | *( szBuffer + lBytesRead ) = (CHAR)NULL;
|
|---|
| 2024 |
|
|---|
| 2025 | /* Only write enabled IO procs are used in the convert menu.
|
|---|
| 2026 | */
|
|---|
| 2027 | if(pmmFormatInfoArray->ulFlags & MMIO_CANWRITETRANSLATED)
|
|---|
| 2028 | {
|
|---|
| 2029 | // HlpWriteToTrapLog("IO-Proc 2: %s\n\n", szBuffer);
|
|---|
| 2030 | /* Add menu item */
|
|---|
| 2031 | /* Fill the MENUITEM structure */
|
|---|
| 2032 | mi.iPosition=MIT_END;
|
|---|
| 2033 | mi.afStyle=MIS_TEXT|MIS_SUBMENU;
|
|---|
| 2034 | mi.id=ID_ITEM_FIRSTCONVERT+index;/* Create menu id */
|
|---|
| 2035 | mi.afAttribute=NULLHANDLE;
|
|---|
| 2036 | mi.hwndSubMenu=NULLHANDLE;//hwndSubMenu;
|
|---|
| 2037 | mi.hItem=NULLHANDLE;
|
|---|
| 2038 | WinSendMsg(hwndSubMenu, MM_INSERTITEM,(MPARAM)&mi,
|
|---|
| 2039 | (MPARAM)szBuffer);
|
|---|
| 2040 | }
|
|---|
| 2041 | /*
|
|---|
| 2042 | * advance to next entry in mmFormatInfo array
|
|---|
| 2043 | */
|
|---|
| 2044 | pmmFormatInfoArray++;
|
|---|
| 2045 | }
|
|---|
| 2046 | return TRUE;
|
|---|
| 2047 | }
|
|---|
| 2048 |
|
|---|
| 2049 |
|
|---|
| 2050 | /*
|
|---|
| 2051 | * The prototype for cwaudio_wpModifyPopupMenu was replaced by the following prototype:
|
|---|
| 2052 | */
|
|---|
| 2053 | SOM_Scope BOOL SOMLINK cwaudio_wpModifyPopupMenu(MMAudio *somSelf,
|
|---|
| 2054 | HWND hwndMenu,
|
|---|
| 2055 | HWND hwndCnr,
|
|---|
| 2056 | ULONG iPosition)
|
|---|
| 2057 | {
|
|---|
| 2058 | BOOL rc;
|
|---|
| 2059 |
|
|---|
| 2060 | //FIXME
|
|---|
| 2061 | /* CWMMDataFileData *somThis = CWMMDataFileGetData(somSelf);*/
|
|---|
| 2062 | MMAudioMethodDebug("MMAudio","cwaudio_wpModifyPopupMenu");
|
|---|
| 2063 |
|
|---|
| 2064 | /* New Volume item */
|
|---|
| 2065 | _wpInsertPopupMenuItems(somSelf, hwndMenu, 1, queryResModuleHandle(), ID_MENU_VOLUME, 1);
|
|---|
| 2066 | /* Convert menu item */
|
|---|
| 2067 | // _wpInsertPopupMenuItems(somSelf, hwndMenu, -1, queryModuleHandle(), ID_MENU_CONVERT, 0);
|
|---|
| 2068 | //#if 0
|
|---|
| 2069 | /* Insert all known audio I/O procs */
|
|---|
| 2070 | TRY_LOUD(AUDIO_INSERTPOPUPMENU) {
|
|---|
| 2071 | insertAudioIOProcMenuItems( hwndMenu );
|
|---|
| 2072 | }/* TRY_LOUD */
|
|---|
| 2073 | CATCH(AUDIO_INSERTPOPUPMENU)
|
|---|
| 2074 | {
|
|---|
| 2075 | SysWriteToTrapLog("\nTrap occured in %s, file %s, near line %d.\n",
|
|---|
| 2076 | __FUNCTION__, __FILE__, __LINE__);
|
|---|
| 2077 | } END_CATCH;
|
|---|
| 2078 | //#endif
|
|---|
| 2079 |
|
|---|
| 2080 | if(WinIsWindow(WinQueryAnchorBlock(HWND_DESKTOP),__get_hwndObjectPlay(somSelf))) {
|
|---|
| 2081 | if(_cwmmQueryTrackStatus(somSelf)==TRACK_STATUS_PAUSED)
|
|---|
| 2082 | _wpInsertPopupMenuItems(somSelf, hwndMenu, 1, queryResModuleHandle(), ID_MENU_RESUME, 1);
|
|---|
| 2083 | else
|
|---|
| 2084 | _wpInsertPopupMenuItems(somSelf, hwndMenu, 1, queryResModuleHandle(), ID_MENU_PAUSE, 1);
|
|---|
| 2085 | _wpInsertPopupMenuItems(somSelf, hwndMenu, 1, queryResModuleHandle(), ID_MENU_STOP, 1);
|
|---|
| 2086 | }
|
|---|
| 2087 | else
|
|---|
| 2088 | {
|
|---|
| 2089 | _wpInsertPopupMenuItems(somSelf, hwndMenu, 1, queryResModuleHandle(), ID_MENU_EDITOR, 1);
|
|---|
| 2090 | _wpInsertPopupMenuItems(somSelf, hwndMenu, 1, queryResModuleHandle(), ID_MENU_PLAYER, 1);
|
|---|
| 2091 | _wpInsertPopupMenuItems(somSelf, hwndMenu, 1, queryResModuleHandle(), ID_MENU_START, 1);
|
|---|
| 2092 | }
|
|---|
| 2093 | rc= (MMAudio_parent_CWMMDataFile_wpModifyPopupMenu(somSelf,
|
|---|
| 2094 | hwndMenu,
|
|---|
| 2095 | hwndCnr,
|
|---|
| 2096 | iPosition));
|
|---|
| 2097 | return rc;
|
|---|
| 2098 | }
|
|---|
| 2099 |
|
|---|
| 2100 |
|
|---|
| 2101 | /*
|
|---|
| 2102 | * The prototype for cwaudio_wpMenuItemSelected was replaced by the following prototype:
|
|---|
| 2103 | */
|
|---|
| 2104 | SOM_Scope BOOL SOMLINK cwaudio_wpMenuItemSelected(MMAudio *somSelf,
|
|---|
| 2105 | HWND hwndFrame,
|
|---|
| 2106 | ULONG ulMenuId)
|
|---|
| 2107 | {
|
|---|
| 2108 | /* MMAudioData *somThis = MMAudioGetData(somSelf);*/
|
|---|
| 2109 | MMAudioMethodDebug("MMAudio","cwaudio_wpMenuItemSelected");
|
|---|
| 2110 |
|
|---|
| 2111 |
|
|---|
| 2112 | if(ulMenuId>=ID_ITEM_FIRSTCONVERT && ulMenuId<=ID_ITEM_FIRSTCONVERT+lNumIOProcs-1)
|
|---|
| 2113 | {
|
|---|
| 2114 | char chrEditor[CCHMAXPATH]={0};
|
|---|
| 2115 | char chrParams[2*CCHMAXPATH]="\"";
|
|---|
| 2116 | char *chrPtr=chrParams;
|
|---|
| 2117 | ULONG ulSize;
|
|---|
| 2118 | ULONG ulRc;
|
|---|
| 2119 |
|
|---|
| 2120 | PrfQueryProfileString(HINI_USERPROFILE, "CWMM", "audioconverter", "", chrEditor,
|
|---|
| 2121 | sizeof(chrEditor));
|
|---|
| 2122 | chrPtr++;
|
|---|
| 2123 | ulSize=sizeof(chrParams);
|
|---|
| 2124 | _wpQueryRealName(somSelf, chrPtr, &ulSize, TRUE);
|
|---|
| 2125 | strcat(chrPtr,"\" \"");
|
|---|
| 2126 | chrPtr=strrchr(chrPtr, 0);
|
|---|
| 2127 | mmioGetFormatName(&g_pmmFormatInfoArray[ulMenuId-ID_ITEM_FIRSTCONVERT], chrPtr,(LONG*) &ulSize, 0L, 0L);
|
|---|
| 2128 | *( chrPtr + ulSize ) = (CHAR)NULL;
|
|---|
| 2129 | strcat(chrPtr,"\"");
|
|---|
| 2130 |
|
|---|
| 2131 | if((ulRc=launchPMProg("", chrEditor, chrParams, somSelf, ulMenuId-ID_ITEM_FIRSTCONVERT))==NULLHANDLE) {
|
|---|
| 2132 | /* Error */
|
|---|
| 2133 | return TRUE;
|
|---|
| 2134 | }
|
|---|
| 2135 | return TRUE;
|
|---|
| 2136 | }
|
|---|
| 2137 |
|
|---|
| 2138 | switch(ulMenuId)
|
|---|
| 2139 | {
|
|---|
| 2140 | case ID_MENU_VOLUME:
|
|---|
| 2141 | case ID_MENU_START:
|
|---|
| 2142 | case ID_MENU_STOP:
|
|---|
| 2143 | case ID_MENU_PAUSE:
|
|---|
| 2144 | case ID_MENU_RESUME:
|
|---|
| 2145 | case ID_MENU_PLAYER:
|
|---|
| 2146 | case ID_MENU_EDITOR:
|
|---|
| 2147 | case ID_ITEM_CONVERT:
|
|---|
| 2148 | _wpViewObject(somSelf, WinWindowFromID(hwndFrame, FID_CLIENT), ulMenuId,0);
|
|---|
| 2149 | return TRUE;
|
|---|
| 2150 | default:
|
|---|
| 2151 | break;
|
|---|
| 2152 | }
|
|---|
| 2153 | return (MMAudio_parent_CWMMDataFile_wpMenuItemSelected(somSelf,
|
|---|
| 2154 | hwndFrame,
|
|---|
| 2155 | ulMenuId));
|
|---|
| 2156 | }
|
|---|
| 2157 |
|
|---|
| 2158 | /*
|
|---|
| 2159 | * The prototype for cwaudio_wpObjectReady was replaced by the following prototype:
|
|---|
| 2160 | */
|
|---|
| 2161 | SOM_Scope void SOMLINK cwaudio_wpObjectReady(MMAudio *somSelf,
|
|---|
| 2162 | ULONG ulCode, WPObject* refObject)
|
|---|
| 2163 | {
|
|---|
| 2164 | MMAudioData *somThis = MMAudioGetData(somSelf);
|
|---|
| 2165 | MMAudioMethodDebug("MMAudio","cwaudio_wpObjectReady");
|
|---|
| 2166 |
|
|---|
| 2167 | MMAudio_parent_CWMMDataFile_wpObjectReady(somSelf, ulCode, refObject);
|
|---|
| 2168 |
|
|---|
| 2169 | /* Set the type of this object to keep the MM player happy. */
|
|---|
| 2170 | mmclsSetObjectType(somSelf);
|
|---|
| 2171 |
|
|---|
| 2172 | if(_bNeedSaving)
|
|---|
| 2173 | _wpSaveDeferred(somSelf);
|
|---|
| 2174 | }
|
|---|
| 2175 |
|
|---|
| 2176 |
|
|---|
| 2177 | /*
|
|---|
| 2178 | * The prototype for cwaudio_wpSetup was replaced by the following prototype:
|
|---|
| 2179 | */
|
|---|
| 2180 | SOM_Scope BOOL SOMLINK cwaudio_wpSetup(MMAudio *somSelf, PSZ pszSetupString)
|
|---|
| 2181 | {
|
|---|
| 2182 | char buffer[MAX_EA_SIZE];
|
|---|
| 2183 | ULONG bufferSize;
|
|---|
| 2184 |
|
|---|
| 2185 | MMAudioData *somThis = MMAudioGetData(somSelf);
|
|---|
| 2186 | MMAudioMethodDebug("MMAudio","cwaudio_wpSetup");
|
|---|
| 2187 |
|
|---|
| 2188 | /* Setting volume while playing */
|
|---|
| 2189 | bufferSize=sizeof(buffer);
|
|---|
| 2190 | if(_wpScanSetupString(somSelf, pszSetupString, SETUP_MMAUDIOVOLUME, buffer, &bufferSize))
|
|---|
| 2191 | {
|
|---|
| 2192 | LONG l;
|
|---|
| 2193 |
|
|---|
| 2194 | l=atol(buffer);
|
|---|
| 2195 | if(l>100)
|
|---|
| 2196 | l=100;
|
|---|
| 2197 | if(l<0)
|
|---|
| 2198 | l=0;
|
|---|
| 2199 |
|
|---|
| 2200 | globalClassVolume=l;
|
|---|
| 2201 | /* Now tell the running file if any */
|
|---|
| 2202 | WinSendMsg(globalHwndObjectPlay, WM_APPTERMINATENOTIFY, MPFROMLONG(ACKEY_VOLUME), MPFROMP(globalObjectPlay));
|
|---|
| 2203 | }
|
|---|
| 2204 |
|
|---|
| 2205 | /* These are the old setup strings. They will be removed in the future */
|
|---|
| 2206 | bufferSize=sizeof(buffer);
|
|---|
| 2207 | if(_wpScanSetupString(somSelf, pszSetupString, SETUP_AUDIOTRACKNAME, buffer, &bufferSize))
|
|---|
| 2208 | {
|
|---|
| 2209 | _cwmmSetTrackInfo(somSelf, buffer, 0, IDINFO_NAME);
|
|---|
| 2210 | }
|
|---|
| 2211 |
|
|---|
| 2212 | bufferSize=sizeof(buffer);
|
|---|
| 2213 | if(_wpScanSetupString(somSelf, pszSetupString, SETUP_AUDIOARTIST, buffer, &bufferSize))
|
|---|
| 2214 | {
|
|---|
| 2215 | _cwmmSetTrackInfo(somSelf, buffer, 0, IDINFO_ARTIST);
|
|---|
| 2216 | }
|
|---|
| 2217 |
|
|---|
| 2218 | bufferSize=sizeof(buffer);
|
|---|
| 2219 | if(_wpScanSetupString(somSelf, pszSetupString, SETUP_AUDIOALBUM, buffer, &bufferSize))
|
|---|
| 2220 | {
|
|---|
| 2221 | _cwmmSetTrackInfo(somSelf, buffer, 0, IDINFO_ALBUM);
|
|---|
| 2222 | }
|
|---|
| 2223 |
|
|---|
| 2224 | bufferSize=sizeof(buffer);
|
|---|
| 2225 | if(_wpScanSetupString(somSelf, pszSetupString, SETUP_AUDIOCOMMENT, buffer, &bufferSize))
|
|---|
| 2226 | {
|
|---|
| 2227 | _cwmmSetTrackInfo(somSelf, buffer, 0, IDINFO_COMMENT);
|
|---|
| 2228 | }
|
|---|
| 2229 |
|
|---|
| 2230 | bufferSize=sizeof(buffer);
|
|---|
| 2231 | if(_wpScanSetupString(somSelf, pszSetupString, SETUP_AUDIOGENRE, buffer, &bufferSize))
|
|---|
| 2232 | {
|
|---|
| 2233 | _cwmmSetTrackInfo(somSelf, buffer, 0, IDINFO_GENRE);
|
|---|
| 2234 | }
|
|---|
| 2235 |
|
|---|
| 2236 | bufferSize=sizeof(buffer);
|
|---|
| 2237 | if(_wpScanSetupString(somSelf, pszSetupString, SETUP_AUDIOYEAR, buffer, &bufferSize))
|
|---|
| 2238 | {
|
|---|
| 2239 | _cwmmSetTrackInfo(somSelf, buffer, 0, IDINFO_YEAR);
|
|---|
| 2240 | }
|
|---|
| 2241 |
|
|---|
| 2242 | bufferSize=sizeof(buffer);
|
|---|
| 2243 | if(_wpScanSetupString(somSelf, pszSetupString, SETUP_AUDIOPLAYTIME, buffer, &bufferSize))
|
|---|
| 2244 | {
|
|---|
| 2245 | int iPlaytime=atoi(buffer);
|
|---|
| 2246 | if(iPlaytime<0)
|
|---|
| 2247 | iPlaytime=0;
|
|---|
| 2248 | _cwmmSetTrackInfo(somSelf, buffer, iPlaytime, IDINFO_PLAYTIME);
|
|---|
| 2249 | }
|
|---|
| 2250 |
|
|---|
| 2251 | /* Refresh */
|
|---|
| 2252 | bufferSize=sizeof(buffer);
|
|---|
| 2253 | if(_wpScanSetupString(somSelf, pszSetupString, SETUP_REFRESH, buffer,&bufferSize))
|
|---|
| 2254 | {
|
|---|
| 2255 | _ulFileSize=1; /* Set filesize to 1 this will force a reread */
|
|---|
| 2256 | /* Make sure MMIOMP3 doesn't take the time from the EA */
|
|---|
| 2257 | cwSaveStringToEA(somSelf, "MMPLAYTIME", "");
|
|---|
| 2258 | cwSaveStringToEA(somSelf, "MMPLAYTIMEMS", "");
|
|---|
| 2259 |
|
|---|
| 2260 | /* The filesize changed, somebody altered the audio file so reread the info */
|
|---|
| 2261 | if(!cwObjectIsOnCD(somSelf)) {
|
|---|
| 2262 | /* Only get audio info when file isn't on CD. This speeds up opening of folders on CDs filled with
|
|---|
| 2263 | MP3s. Doesn't hurt because folders of CDs open in normal details view as default so the audio info
|
|---|
| 2264 | isn't necessary. When opening the settings notebook the info is reread anyway. */
|
|---|
| 2265 |
|
|---|
| 2266 | //FIXME
|
|---|
| 2267 | /* Get class object */
|
|---|
| 2268 | //M_CWMMDataFile *m_cwmmDataFile=_CWMMDataFile;
|
|---|
| 2269 | /* Get data pointer of class object */
|
|---|
| 2270 | //M_CWMMDataFileData *cwmmData = M_CWMMDataFileGetData(m_cwmmDataFile);
|
|---|
| 2271 | /* Send the object pointer to the audio worker thread to read the audio info in the background. */
|
|---|
| 2272 | // WinPostMsg(cwmmData->hwndAudioWorker , WM_APPTERMINATENOTIFY, somSelf, 0);
|
|---|
| 2273 | WinPostMsg(__get_hwndAudioWorker(_CWMMDataFile) , WM_APPTERMINATENOTIFY, somSelf, 0);
|
|---|
| 2274 | }
|
|---|
| 2275 | _wpCnrRefreshDetails(somSelf);
|
|---|
| 2276 | }
|
|---|
| 2277 |
|
|---|
| 2278 | bufferSize=sizeof(buffer);
|
|---|
| 2279 | if(_wpScanSetupString(somSelf, pszSetupString, SETUP_COPYTAGTO, buffer, &bufferSize))
|
|---|
| 2280 | {
|
|---|
| 2281 | /* The caller requested to copy the tags from this audio file to another */
|
|---|
| 2282 | PBYTE pByte;
|
|---|
| 2283 | ULONG ul;
|
|---|
| 2284 |
|
|---|
| 2285 | /* Length of instance var string can't be longer than MAX_EA_SIZE. See cwmmSetTrackInfo() */
|
|---|
| 2286 | if((pByte=_wpAllocMem(somSelf, MAX_EA_SIZE+100, &ul))!=NULLHANDLE)
|
|---|
| 2287 | {
|
|---|
| 2288 | sprintf(pByte,"%s=%s;",SETUP_AUDIOTRACKNAME, _pszName);
|
|---|
| 2289 | HlpSendCommandToObject( buffer, pByte);
|
|---|
| 2290 |
|
|---|
| 2291 | sprintf(pByte,"%s=%s",SETUP_AUDIOARTIST, _pszArtist);
|
|---|
| 2292 | HlpSendCommandToObject( buffer, pByte);
|
|---|
| 2293 |
|
|---|
| 2294 | sprintf(pByte,"%s=%s",SETUP_AUDIOALBUM, _pszAlbum);
|
|---|
| 2295 | HlpSendCommandToObject( buffer, pByte);
|
|---|
| 2296 |
|
|---|
| 2297 | sprintf(pByte,"%s=%s",SETUP_AUDIOCOMMENT, _pszComment);
|
|---|
| 2298 | HlpSendCommandToObject( buffer, pByte);
|
|---|
| 2299 |
|
|---|
| 2300 | sprintf(pByte,"%s=%s",SETUP_AUDIOYEAR, _pszYear);
|
|---|
| 2301 | HlpSendCommandToObject( buffer, pByte);
|
|---|
| 2302 |
|
|---|
| 2303 | sprintf(pByte,"%s=%s",SETUP_AUDIOGENRE, _pszGenre);
|
|---|
| 2304 | HlpSendCommandToObject( buffer, pByte);
|
|---|
| 2305 | }
|
|---|
| 2306 | }
|
|---|
| 2307 |
|
|---|
| 2308 | #if 0
|
|---|
| 2309 | /* Old code using a static array. To be removed in V.0.2.8 */
|
|---|
| 2310 | bufferSize=sizeof(buffer);
|
|---|
| 2311 | if(_wpScanSetupString(somSelf, pszSetupString, SETUP_COPYTAGTO, buffer, &bufferSize))
|
|---|
| 2312 | {
|
|---|
| 2313 | /* The caller requested to copy the tags from this audio file to another */
|
|---|
| 2314 | char chrCommand[200];
|
|---|
| 2315 |
|
|---|
| 2316 | sprintf(chrCommand,"%s=%s;",SETUP_AUDIOTRACKNAME, _id3Name);
|
|---|
| 2317 | HlpSendCommandToObject( buffer, chrCommand);
|
|---|
| 2318 |
|
|---|
| 2319 | sprintf(chrCommand,"%s=%s",SETUP_AUDIOARTIST, _id3Artist);
|
|---|
| 2320 | HlpSendCommandToObject( buffer, chrCommand);
|
|---|
| 2321 |
|
|---|
| 2322 | sprintf(chrCommand,"%s=%s",SETUP_AUDIOALBUM, _id3Album);
|
|---|
| 2323 | HlpSendCommandToObject( buffer, chrCommand);
|
|---|
| 2324 |
|
|---|
| 2325 | sprintf(chrCommand,"%s=%s",SETUP_AUDIOCOMMENT, _id3Comment);
|
|---|
| 2326 | HlpSendCommandToObject( buffer, chrCommand);
|
|---|
| 2327 |
|
|---|
| 2328 | sprintf(chrCommand,"%s=%s",SETUP_AUDIOYEAR, _id3Year);
|
|---|
| 2329 | HlpSendCommandToObject( buffer, chrCommand);
|
|---|
| 2330 |
|
|---|
| 2331 | sprintf(chrCommand,"%s=%s",SETUP_AUDIOGENRE, _id3Genre);
|
|---|
| 2332 | HlpSendCommandToObject( buffer, chrCommand);
|
|---|
| 2333 | }
|
|---|
| 2334 | #endif
|
|---|
| 2335 |
|
|---|
| 2336 | /* The new MM* setup strings. These have a better naming */
|
|---|
| 2337 | bufferSize=sizeof(buffer);
|
|---|
| 2338 | if(_wpScanSetupString(somSelf, pszSetupString, SETUP_MMAUDIOTRACKNAME, buffer, &bufferSize))
|
|---|
| 2339 | _cwmmSetTrackInfo(somSelf, buffer, 0, IDINFO_NAME);
|
|---|
| 2340 |
|
|---|
| 2341 | bufferSize=sizeof(buffer);
|
|---|
| 2342 | if(_wpScanSetupString(somSelf, pszSetupString, SETUP_MMAUDIOARTIST, buffer, &bufferSize))
|
|---|
| 2343 | _cwmmSetTrackInfo(somSelf, buffer, 0, IDINFO_ARTIST);
|
|---|
| 2344 |
|
|---|
| 2345 | bufferSize=sizeof(buffer);
|
|---|
| 2346 | if(_wpScanSetupString(somSelf, pszSetupString, SETUP_MMAUDIOALBUM, buffer, &bufferSize))
|
|---|
| 2347 | _cwmmSetTrackInfo(somSelf, buffer, 0, IDINFO_ALBUM);
|
|---|
| 2348 |
|
|---|
| 2349 | bufferSize=sizeof(buffer);
|
|---|
| 2350 | if(_wpScanSetupString(somSelf, pszSetupString, SETUP_MMAUDIOCOMMENT, buffer, &bufferSize))
|
|---|
| 2351 | _cwmmSetTrackInfo(somSelf, buffer, 0, IDINFO_COMMENT);
|
|---|
| 2352 |
|
|---|
| 2353 | bufferSize=sizeof(buffer);
|
|---|
| 2354 | if(_wpScanSetupString(somSelf, pszSetupString, SETUP_MMAUDIOGENRE, buffer, &bufferSize))
|
|---|
| 2355 | _cwmmSetTrackInfo(somSelf, buffer, 0, IDINFO_GENRE);
|
|---|
| 2356 |
|
|---|
| 2357 | bufferSize=sizeof(buffer);
|
|---|
| 2358 | if(_wpScanSetupString(somSelf, pszSetupString, SETUP_MMAUDIOYEAR, buffer, &bufferSize))
|
|---|
| 2359 | _cwmmSetTrackInfo(somSelf, buffer, 0, IDINFO_YEAR);
|
|---|
| 2360 |
|
|---|
| 2361 | bufferSize=sizeof(buffer);
|
|---|
| 2362 | if(_wpScanSetupString(somSelf, pszSetupString, SETUP_MMAUDIOPLAYTIME, buffer, &bufferSize))
|
|---|
| 2363 | {
|
|---|
| 2364 | int iPlaytime=atoi(buffer);
|
|---|
| 2365 | if(iPlaytime<0)
|
|---|
| 2366 | iPlaytime=0;
|
|---|
| 2367 | _cwmmSetTrackInfo(somSelf, buffer, iPlaytime, IDINFO_PLAYTIME);
|
|---|
| 2368 | }
|
|---|
| 2369 |
|
|---|
| 2370 | /* Refresh */
|
|---|
| 2371 | bufferSize=sizeof(buffer);
|
|---|
| 2372 | if(_wpScanSetupString(somSelf, pszSetupString, SETUP_MMREFRESH, buffer,&bufferSize))
|
|---|
| 2373 | {
|
|---|
| 2374 | _ulFileSize=1; /* Set filesize to 1 this will force a reread */
|
|---|
| 2375 | /* Make sure MMIOMP3 doesn't take the time from the EA */
|
|---|
| 2376 | cwSaveStringToEA(somSelf, "MMPLAYTIME", "");
|
|---|
| 2377 | cwSaveStringToEA(somSelf, "MMPLAYTIMEMS", "");
|
|---|
| 2378 |
|
|---|
| 2379 | /* The filesize changed, somebody altered the audio file so reread the info */
|
|---|
| 2380 | if(!cwObjectIsOnCD(somSelf)) {
|
|---|
| 2381 | /* Only get audio info when file isn't on CD. This speeds up opening of folders on CDs filled with
|
|---|
| 2382 | MP3s. Doesn't hurt because folders of CDs open in normal details view as default so the audio info
|
|---|
| 2383 | isn't necessary. When opening the settings notebook the info is reread anyway. */
|
|---|
| 2384 |
|
|---|
| 2385 | //FIXME
|
|---|
| 2386 | /* Get class object */
|
|---|
| 2387 | //M_CWMMDataFile *m_cwmmDataFile=_CWMMDataFile;
|
|---|
| 2388 | /* Get data pointer of class object */
|
|---|
| 2389 | //M_CWMMDataFileData *cwmmData = M_CWMMDataFileGetData(m_cwmmDataFile);
|
|---|
| 2390 | /* Send the object pointer to the audio worker thread to read the audio info in the background. */
|
|---|
| 2391 | //WinPostMsg(cwmmData->hwndAudioWorker , WM_APPTERMINATENOTIFY, somSelf, 0);
|
|---|
| 2392 | WinPostMsg(__get_hwndAudioWorker(_CWMMDataFile) , WM_APPTERMINATENOTIFY, somSelf, 0);
|
|---|
| 2393 | }
|
|---|
| 2394 | _wpCnrRefreshDetails(somSelf);
|
|---|
| 2395 | }
|
|---|
| 2396 |
|
|---|
| 2397 | bufferSize=sizeof(buffer);
|
|---|
| 2398 | if(_wpScanSetupString(somSelf, pszSetupString, SETUP_MMCOPYTAGTO, buffer, &bufferSize))
|
|---|
| 2399 | {
|
|---|
| 2400 | /* The caller requested to copy the tags from this audio file to another */
|
|---|
| 2401 | PBYTE pByte;
|
|---|
| 2402 | ULONG ul;
|
|---|
| 2403 |
|
|---|
| 2404 | /* Length of instance var string can't be longer than MAX_EA_SIZE. See cwmmSetTrackInfo() */
|
|---|
| 2405 | if((pByte=_wpAllocMem(somSelf, MAX_EA_SIZE+100, &ul))!=NULLHANDLE)
|
|---|
| 2406 | {
|
|---|
| 2407 |
|
|---|
| 2408 | sprintf(pByte,"%s=%s;",SETUP_MMAUDIOTRACKNAME, _pszName);
|
|---|
| 2409 | HlpSendCommandToObject( buffer, pByte);
|
|---|
| 2410 |
|
|---|
| 2411 | sprintf(pByte,"%s=%s",SETUP_MMAUDIOARTIST, _pszArtist);
|
|---|
| 2412 | HlpSendCommandToObject( buffer, pByte);
|
|---|
| 2413 |
|
|---|
| 2414 | sprintf(pByte,"%s=%s",SETUP_MMAUDIOALBUM, _pszAlbum);
|
|---|
| 2415 | HlpSendCommandToObject( buffer, pByte);
|
|---|
| 2416 |
|
|---|
| 2417 | sprintf(pByte,"%s=%s",SETUP_MMAUDIOCOMMENT, _pszComment);
|
|---|
| 2418 | HlpSendCommandToObject( buffer, pByte);
|
|---|
| 2419 |
|
|---|
| 2420 | sprintf(pByte,"%s=%s",SETUP_MMAUDIOYEAR, _pszYear);
|
|---|
| 2421 | HlpSendCommandToObject( buffer, pByte);
|
|---|
| 2422 |
|
|---|
| 2423 | sprintf(pByte,"%s=%s",SETUP_MMAUDIOGENRE, _pszGenre);
|
|---|
| 2424 | HlpSendCommandToObject( buffer, pByte);
|
|---|
| 2425 | }
|
|---|
| 2426 | }
|
|---|
| 2427 |
|
|---|
| 2428 | #if 0
|
|---|
| 2429 | /* Old code using a static array. To be removed in V0.2.8 */
|
|---|
| 2430 | bufferSize=sizeof(buffer);
|
|---|
| 2431 | if(_wpScanSetupString(somSelf, pszSetupString, SETUP_MMCOPYTAGTO, buffer, &bufferSize))
|
|---|
| 2432 | {
|
|---|
| 2433 | /* The caller requested to copy the tags from this audio file to another */
|
|---|
| 2434 | char chrCommand[200];
|
|---|
| 2435 |
|
|---|
| 2436 | sprintf(chrCommand,"%s=%s;",SETUP_MMAUDIOTRACKNAME, _id3Name);
|
|---|
| 2437 | HlpSendCommandToObject( buffer, chrCommand);
|
|---|
| 2438 |
|
|---|
| 2439 | sprintf(chrCommand,"%s=%s",SETUP_MMAUDIOARTIST, _id3Artist);
|
|---|
| 2440 | HlpSendCommandToObject( buffer, chrCommand);
|
|---|
| 2441 |
|
|---|
| 2442 | sprintf(chrCommand,"%s=%s",SETUP_MMAUDIOALBUM, _id3Album);
|
|---|
| 2443 | HlpSendCommandToObject( buffer, chrCommand);
|
|---|
| 2444 |
|
|---|
| 2445 | sprintf(chrCommand,"%s=%s",SETUP_MMAUDIOCOMMENT, _id3Comment);
|
|---|
| 2446 | HlpSendCommandToObject( buffer, chrCommand);
|
|---|
| 2447 |
|
|---|
| 2448 | sprintf(chrCommand,"%s=%s",SETUP_MMAUDIOYEAR, _id3Year);
|
|---|
| 2449 | HlpSendCommandToObject( buffer, chrCommand);
|
|---|
| 2450 |
|
|---|
| 2451 | sprintf(chrCommand,"%s=%s",SETUP_MMAUDIOGENRE, _id3Genre);
|
|---|
| 2452 | HlpSendCommandToObject( buffer, chrCommand);
|
|---|
| 2453 | }
|
|---|
| 2454 | #endif
|
|---|
| 2455 |
|
|---|
| 2456 | return (MMAudio_parent_CWMMDataFile_wpSetup(somSelf, pszSetupString));
|
|---|
| 2457 | }
|
|---|
| 2458 |
|
|---|
| 2459 | /*
|
|---|
| 2460 |
|
|---|
| 2461 | */
|
|---|
| 2462 | /*
|
|---|
| 2463 | * wpSetTitle : override;
|
|---|
| 2464 | * wpQueryRealName : override;
|
|---|
| 2465 | * wpQueryTitle : override;
|
|---|
| 2466 | * wpRefresh : override;
|
|---|
| 2467 | */
|
|---|
| 2468 |
|
|---|
| 2469 | SOM_Scope HWND SOMLINK cwaudio_wpOpen(MMAudio *somSelf, HWND hwndCnr,
|
|---|
| 2470 | ULONG ulView, ULONG param)
|
|---|
| 2471 | {
|
|---|
| 2472 | ULONG ulRc;
|
|---|
| 2473 |
|
|---|
| 2474 | /* CWAudioData *somThis = CWAudioGetData(somSelf);*/
|
|---|
| 2475 | /* CWMMDataFileData *somThis = CWMMDataFileGetData(somSelf); */
|
|---|
| 2476 | MMAudioMethodDebug("MMAudio","cwaudio_wpOpen");
|
|---|
| 2477 |
|
|---|
| 2478 | switch(ulView)
|
|---|
| 2479 | {
|
|---|
| 2480 | case ID_MENU_START:
|
|---|
| 2481 | {
|
|---|
| 2482 | // HlpWriteToTrapLog("ID_MENU_START selected, iRunningAudioFile: %d hwndCnr: %x %x\n", iRunningAudioFiles, hwndCnr, param);
|
|---|
| 2483 | if(iRunningAudioFiles<MAX_AUDIOFILE_STARTS) {
|
|---|
| 2484 | /* Another audio file running */
|
|---|
| 2485 | iRunningAudioFiles++;
|
|---|
| 2486 | //FIXME
|
|---|
| 2487 | //_ulPreviousView=_wpQueryDefaultView(somSelf);/* Save the view set by the user */
|
|---|
| 2488 | __set_ulPreviousView(somSelf, _wpQueryDefaultView(somSelf));/* Save the view set by the user */
|
|---|
| 2489 | _cwmmPlayTrack(somSelf, hwndCnr, TRUE); /* Start playing */
|
|---|
| 2490 | _wpSetDefaultView(somSelf, ID_MENU_STOP); /* Set new view so doubleclick stops the playing. */
|
|---|
| 2491 | }
|
|---|
| 2492 | return NULLHANDLE;
|
|---|
| 2493 | }
|
|---|
| 2494 | case ID_MENU_STOP:
|
|---|
| 2495 | {
|
|---|
| 2496 | _cwmmPlayTrack(somSelf, hwndCnr, FALSE); /* Stop playing */
|
|---|
| 2497 | //FIXME
|
|---|
| 2498 | // _wpSetDefaultView(somSelf, _ulPreviousView); /* Restore the user view */
|
|---|
| 2499 | _wpSetDefaultView(somSelf, __get_ulPreviousView(somSelf)); /* Restore the user view */
|
|---|
| 2500 | return NULLHANDLE;
|
|---|
| 2501 | }
|
|---|
| 2502 | case ID_MENU_PAUSE:
|
|---|
| 2503 | {
|
|---|
| 2504 | _cwmmPauseTrack(somSelf, hwndCnr, ACKEY_PAUSE);
|
|---|
| 2505 | return NULLHANDLE;
|
|---|
| 2506 | }
|
|---|
| 2507 | case ID_MENU_RESUME:
|
|---|
| 2508 | {
|
|---|
| 2509 | _cwmmPauseTrack(somSelf, hwndCnr, ACKEY_RESUME);
|
|---|
| 2510 | return NULLHANDLE;
|
|---|
| 2511 | }
|
|---|
| 2512 | case ID_MENU_PLAYER:
|
|---|
| 2513 | /*case 0xbbe5: Player */
|
|---|
| 2514 | {
|
|---|
| 2515 | char chrPlayer[CCHMAXPATH]={0};
|
|---|
| 2516 | char chrParams[CCHMAXPATH+2]="\"";
|
|---|
| 2517 | char chrTitle[50];
|
|---|
| 2518 | char *chrPtr=chrParams;
|
|---|
| 2519 | ULONG ulSize;
|
|---|
| 2520 |
|
|---|
| 2521 | /* Build path for the audio player app */
|
|---|
| 2522 | sprintf(chrPlayer, "%s\\bin\\%s", chrInstallDir, "mmplayer.exe");
|
|---|
| 2523 |
|
|---|
| 2524 | /* The user may override the audio player using a setting in the ini. Default is using the
|
|---|
| 2525 | provided one.
|
|---|
| 2526 | */
|
|---|
| 2527 | PrfQueryProfileString(HINI_USERPROFILE, "CWMM", "audioplayer", chrPlayer, chrPlayer,sizeof(chrPlayer));
|
|---|
| 2528 | chrPtr++;
|
|---|
| 2529 | ulSize=sizeof(chrParams)-2;
|
|---|
| 2530 | _wpQueryRealName(somSelf, chrPtr, &ulSize, TRUE); /* Add filename */
|
|---|
| 2531 | strcat(chrPtr,"\"");
|
|---|
| 2532 |
|
|---|
| 2533 | /* Get the Title for the window list */
|
|---|
| 2534 | if(!getMessage(chrTitle, IDSTR_AUDPLAYERTITLE, sizeof(chrTitle), queryResModuleHandle(), HWND_DESKTOP))
|
|---|
| 2535 | strcpy(chrTitle, "Player");
|
|---|
| 2536 |
|
|---|
| 2537 | if((ulRc=launchPMProg(chrTitle, chrPlayer, chrParams, somSelf, ulView))==NULLHANDLE) {
|
|---|
| 2538 | break;
|
|---|
| 2539 | }
|
|---|
| 2540 | return NULLHANDLE;
|
|---|
| 2541 | }
|
|---|
| 2542 | case ID_MENU_VOLUME:
|
|---|
| 2543 | {
|
|---|
| 2544 | char chrVolume[CCHMAXPATH]={0};
|
|---|
| 2545 | char chrTitle[100]={0};
|
|---|
| 2546 | char chrParam[CCHMAXPATH]="\"";
|
|---|
| 2547 | ULONG ulRc;
|
|---|
| 2548 |
|
|---|
| 2549 | sprintf(chrVolume, "%s\\bin\\classvol.exe", queryInstallDir());
|
|---|
| 2550 |
|
|---|
| 2551 | ulRc=sizeof(chrParam);
|
|---|
| 2552 | _wpQueryRealName(somSelf,chrParam+1, &ulRc, TRUE);
|
|---|
| 2553 | strcat(chrParam,"\"");
|
|---|
| 2554 | /* Get the Title for the window list */
|
|---|
| 2555 | if(!getMessage(chrTitle, IDSTR_VOLUMETITLE, sizeof(chrTitle), queryResModuleHandle(), HWND_DESKTOP))
|
|---|
| 2556 | strcpy(chrTitle, "Volume");
|
|---|
| 2557 |
|
|---|
| 2558 | if((ulRc=launchPMProg(chrTitle, chrVolume, chrParam, somSelf, ID_MENU_VOLUME))==0)
|
|---|
| 2559 | return NULLHANDLE;
|
|---|
| 2560 |
|
|---|
| 2561 | #if 0
|
|---|
| 2562 | HOBJECT hObject;
|
|---|
| 2563 | if((hObject=WinQueryObject("<MMPM2_MMVOLUME>"))!=NULLHANDLE)
|
|---|
| 2564 | WinOpenObject(hObject, OPEN_DEFAULT, TRUE);
|
|---|
| 2565 | #endif
|
|---|
| 2566 | return NULLHANDLE;
|
|---|
| 2567 | }
|
|---|
| 2568 | case ID_MENU_EDITOR:
|
|---|
| 2569 | /* case 0xbc0d: Editor */
|
|---|
| 2570 | {
|
|---|
| 2571 | char chrPlayer[CCHMAXPATH]={0};
|
|---|
| 2572 | char chrParams[CCHMAXPATH+10]="-e \"";
|
|---|
| 2573 | char chrTitle[50];
|
|---|
| 2574 | char *chrPtr=chrParams;
|
|---|
| 2575 | ULONG ulSize;
|
|---|
| 2576 |
|
|---|
| 2577 | /*
|
|---|
| 2578 | Check if the user specified another audio editor.
|
|---|
| 2579 | */
|
|---|
| 2580 | if(!PrfQueryProfileString(HINI_USERPROFILE, "CWMM", "audioeditor", NULLHANDLE, chrPlayer,sizeof(chrPlayer)))
|
|---|
| 2581 | {
|
|---|
| 2582 | /* No user setting. Use default ab.exe copied by the installation program to another location */
|
|---|
| 2583 | PrfQueryProfileString(HINI_USERPROFILE, "CWMM", "ab", NULLHANDLE, chrPlayer,sizeof(chrPlayer));
|
|---|
| 2584 | }
|
|---|
| 2585 | chrPtr+=4;
|
|---|
| 2586 | ulSize=sizeof(chrParams)-2;
|
|---|
| 2587 | _wpQueryRealName(somSelf, chrPtr, &ulSize, TRUE);
|
|---|
| 2588 | strcat(chrPtr,"\"");
|
|---|
| 2589 |
|
|---|
| 2590 | if(!getMessage(chrTitle, IDSTR_AUDEDITORTITLE, sizeof(chrTitle), queryResModuleHandle(), HWND_DESKTOP))
|
|---|
| 2591 | strcpy(chrTitle, "Editor");
|
|---|
| 2592 |
|
|---|
| 2593 | if((ulRc=launchPMProg( chrTitle, chrPlayer, chrParams, somSelf, ulView))==NULLHANDLE) {
|
|---|
| 2594 | break;
|
|---|
| 2595 | }
|
|---|
| 2596 |
|
|---|
| 2597 | return NULLHANDLE;
|
|---|
| 2598 | }
|
|---|
| 2599 | #if 0
|
|---|
| 2600 | /*
|
|---|
| 2601 | FIXME:
|
|---|
| 2602 | Moved this to wpMenuItemSelected(). Should be moved back later.
|
|---|
| 2603 | */
|
|---|
| 2604 | case 0xb4dd: /* Convert */
|
|---|
| 2605 | {
|
|---|
| 2606 | char chrPlayer[CCHMAXPATH]={0};
|
|---|
| 2607 | char chrParams[CCHMAXPATH+2]="\"";
|
|---|
| 2608 | char *chrPtr=chrParams;
|
|---|
| 2609 | ULONG ulSize;
|
|---|
| 2610 |
|
|---|
| 2611 | PrfQueryProfileString(HINI_USERPROFILE, "CWMM", "audioconverter", "", chrPlayer,sizeof(chrPlayer));
|
|---|
| 2612 | chrPtr++;
|
|---|
| 2613 | ulSize=sizeof(chrParams)-2;
|
|---|
| 2614 | _wpQueryRealName(somSelf, chrPtr, &ulSize, TRUE);
|
|---|
| 2615 | strcat(chrPtr,"\"");
|
|---|
| 2616 | if((ulRc=launchPMProg("Spieler", chrPlayer, chrParams, somSelf, ulView))==NULLHANDLE) {
|
|---|
| 2617 | break;
|
|---|
| 2618 | }
|
|---|
| 2619 | return NULLHANDLE;
|
|---|
| 2620 | }
|
|---|
| 2621 | #endif
|
|---|
| 2622 | default:
|
|---|
| 2623 | break;
|
|---|
| 2624 | }
|
|---|
| 2625 | return (MMAudio_parent_CWMMDataFile_wpOpen(somSelf, hwndCnr, ulView,
|
|---|
| 2626 | param));
|
|---|
| 2627 | }
|
|---|
| 2628 |
|
|---|
| 2629 |
|
|---|
| 2630 | SOM_Scope void SOMLINK cwaudio_wpInitData(MMAudio *somSelf)
|
|---|
| 2631 | {
|
|---|
| 2632 | MMAudioData *somThis = MMAudioGetData(somSelf);
|
|---|
| 2633 | MMAudioMethodDebug("MMAudio","cwaudio_wpInitData");
|
|---|
| 2634 |
|
|---|
| 2635 | MMAudio_parent_CWMMDataFile_wpInitData(somSelf);
|
|---|
| 2636 | /* Flag to mark we haven't yet the audio size. The size will be read from the
|
|---|
| 2637 | EAs (to circumvent the IO proc file scanning) or by checking the file using
|
|---|
| 2638 | IO procs when the file was altered. */
|
|---|
| 2639 | _ulFileSize=1;
|
|---|
| 2640 |
|
|---|
| 2641 | /* This proc handles the start/stop/resume commands for audio objects.
|
|---|
| 2642 | Playing takes place on a separate thread with an object window and this proc used
|
|---|
| 2643 | for communicating. */
|
|---|
| 2644 | _cwmmSetObjWindowProc(somSelf, &playObjectProc);
|
|---|
| 2645 | }
|
|---|
| 2646 |
|
|---|
| 2647 | /*
|
|---|
| 2648 | This function checks all the installed audio IO procs if one of them can handle the
|
|---|
| 2649 | audio file with the given extension. Only write enabled IO procs are accepted because
|
|---|
| 2650 | we use this function to determine if we should create a template for the audio class.
|
|---|
| 2651 | */
|
|---|
| 2652 | static BOOL checkForWriteEnabledAudioIOProc(char * chrExt)
|
|---|
| 2653 | {
|
|---|
| 2654 | CHAR szBuffer[ sizeof( FOURCC ) + CCHMAXPATH + 4 ];
|
|---|
| 2655 | MMFORMATINFO mmFormatInfo;
|
|---|
| 2656 | PMMFORMATINFO pmmFormatInfoArray;
|
|---|
| 2657 | void * memPtr;
|
|---|
| 2658 | ULONG ulReturnCode;
|
|---|
| 2659 | LONG lFormatsRead;
|
|---|
| 2660 | LONG index;
|
|---|
| 2661 | LONG lBytesRead;
|
|---|
| 2662 | LONG lNumIOProcs;
|
|---|
| 2663 |
|
|---|
| 2664 | memset( &mmFormatInfo,
|
|---|
| 2665 | '\0',
|
|---|
| 2666 | sizeof(MMFORMATINFO) );
|
|---|
| 2667 |
|
|---|
| 2668 | mmFormatInfo.ulMediaType |= MMIO_MEDIATYPE_AUDIO;
|
|---|
| 2669 | mmFormatInfo.ulFlags|=MMIO_CANWRITETRANSLATED;
|
|---|
| 2670 | ulReturnCode = mmioQueryFormatCount ( &mmFormatInfo,
|
|---|
| 2671 | &lNumIOProcs,
|
|---|
| 2672 | 0,
|
|---|
| 2673 | 0 );
|
|---|
| 2674 |
|
|---|
| 2675 | if( ulReturnCode != MMIO_SUCCESS )
|
|---|
| 2676 | {
|
|---|
| 2677 | /*
|
|---|
| 2678 | * Error - mmioQueryFormatCount failed.
|
|---|
| 2679 | */
|
|---|
| 2680 | return FALSE;
|
|---|
| 2681 | }
|
|---|
| 2682 |
|
|---|
| 2683 | /*
|
|---|
| 2684 | * Allocate enough memory for n number of FormatInfo blocks
|
|---|
| 2685 | */
|
|---|
| 2686 | pmmFormatInfoArray = malloc (lNumIOProcs * sizeof( MMFORMATINFO ) );
|
|---|
| 2687 | memPtr=pmmFormatInfoArray;
|
|---|
| 2688 | if( pmmFormatInfoArray == NULL )
|
|---|
| 2689 | {
|
|---|
| 2690 | /*
|
|---|
| 2691 | * Could not allocate enough memory for mmFormatInfo array.
|
|---|
| 2692 | */
|
|---|
| 2693 | return FALSE;
|
|---|
| 2694 | }
|
|---|
| 2695 |
|
|---|
| 2696 | /*
|
|---|
| 2697 | * call mmioGetFormats to get info on the formats supported.
|
|---|
| 2698 | */
|
|---|
| 2699 | ulReturnCode = mmioGetFormats( &mmFormatInfo,
|
|---|
| 2700 | lNumIOProcs,
|
|---|
| 2701 | pmmFormatInfoArray,
|
|---|
| 2702 | &lFormatsRead,
|
|---|
| 2703 | 0,
|
|---|
| 2704 | 0 );
|
|---|
| 2705 | if( ulReturnCode != MMIO_SUCCESS )
|
|---|
| 2706 | {
|
|---|
| 2707 | /*
|
|---|
| 2708 | * mmioGetFormats failed.
|
|---|
| 2709 | */
|
|---|
| 2710 | free(pmmFormatInfoArray);
|
|---|
| 2711 | return FALSE;
|
|---|
| 2712 | }
|
|---|
| 2713 |
|
|---|
| 2714 | if( lFormatsRead != lNumIOProcs )
|
|---|
| 2715 | {
|
|---|
| 2716 | /*
|
|---|
| 2717 | * Error in MMIO - number of formats read in by
|
|---|
| 2718 | * mmioGetFormats is not equal to number of formats
|
|---|
| 2719 | * found by mmioQueryFormatCount.
|
|---|
| 2720 | */
|
|---|
| 2721 | free(pmmFormatInfoArray);
|
|---|
| 2722 | return FALSE;
|
|---|
| 2723 | }
|
|---|
| 2724 |
|
|---|
| 2725 | for ( index = 0; index <lNumIOProcs; index++ )
|
|---|
| 2726 | {
|
|---|
| 2727 | mmioGetFormatName(pmmFormatInfoArray, szBuffer, &lBytesRead, 0L, 0L);
|
|---|
| 2728 |
|
|---|
| 2729 | /* Insert NULL string terminator */
|
|---|
| 2730 | *( szBuffer + lBytesRead ) = (CHAR)NULL;
|
|---|
| 2731 |
|
|---|
| 2732 | if(pmmFormatInfoArray->ulFlags & MMIO_CANWRITETRANSLATED)
|
|---|
| 2733 | {
|
|---|
| 2734 | //if(pmmFormatInfoArray->fccIOProc==mmioStringToFOURCC(chr, MMIO_TOUPPER))
|
|---|
| 2735 | //HlpWriteToTrapLog("%s --- %x %x %s\n",szBuffer, pmmFormatInfoArray->fccIOProc, mmioStringToFOURCC(chrType, MMIO_TOUPPER),
|
|---|
| 2736 | // pmmFormatInfoArray->szDefaultFormatExt);
|
|---|
| 2737 | if(strstr(chrExt, pmmFormatInfoArray->szDefaultFormatExt)) {
|
|---|
| 2738 | // HlpWriteToTrapLog("******* Ext given: %s IO-Proc: %s\n", chrExt, pmmFormatInfoArray->szDefaultFormatExt);
|
|---|
| 2739 | free(memPtr);
|
|---|
| 2740 | return TRUE;
|
|---|
| 2741 | }
|
|---|
| 2742 | }
|
|---|
| 2743 | /*
|
|---|
| 2744 | * advance to next entry in mmFormatInfo array
|
|---|
| 2745 | */
|
|---|
| 2746 | pmmFormatInfoArray++;
|
|---|
| 2747 | }
|
|---|
| 2748 | free(memPtr);
|
|---|
| 2749 | return FALSE;
|
|---|
| 2750 | }
|
|---|
| 2751 |
|
|---|
| 2752 | /*
|
|---|
| 2753 | * wpCreateShadowObject : override;
|
|---|
| 2754 | */
|
|---|
| 2755 |
|
|---|
| 2756 | SOM_Scope void SOMLINK cwaudio_wpUnInitData(MMAudio *somSelf)
|
|---|
| 2757 | {
|
|---|
| 2758 | MMAudioData *somThis = MMAudioGetData(somSelf);
|
|---|
| 2759 | MMAudioMethodDebug("MMAudio","cwaudio_wpUnInitData");
|
|---|
| 2760 |
|
|---|
| 2761 | if(_pszName)
|
|---|
| 2762 | _wpFreeMem(somSelf, _pszName);
|
|---|
| 2763 |
|
|---|
| 2764 | if(_pszArtist)
|
|---|
| 2765 | _wpFreeMem(somSelf, _pszArtist);
|
|---|
| 2766 |
|
|---|
| 2767 | if(_pszAlbum)
|
|---|
| 2768 | _wpFreeMem(somSelf, _pszAlbum);
|
|---|
| 2769 |
|
|---|
| 2770 | if(_pszComment)
|
|---|
| 2771 | _wpFreeMem(somSelf, _pszComment);
|
|---|
| 2772 |
|
|---|
| 2773 | if(_pszYear)
|
|---|
| 2774 | _wpFreeMem(somSelf, _pszYear);
|
|---|
| 2775 |
|
|---|
| 2776 | if(_pszGenre)
|
|---|
| 2777 | _wpFreeMem(somSelf, _pszGenre);
|
|---|
| 2778 |
|
|---|
| 2779 | MMAudio_parent_CWMMDataFile_wpUnInitData(somSelf);
|
|---|
| 2780 | }
|
|---|
| 2781 |
|
|---|
| 2782 |
|
|---|
| 2783 | /*
|
|---|
| 2784 | Only templates for write enabled audio IO procs are created in this method.
|
|---|
| 2785 | */
|
|---|
| 2786 | SOM_Scope BOOL SOMLINK cwaudioM_wpclsCreateDefaultTemplates(M_MMAudio *somSelf,
|
|---|
| 2787 | WPObject* Folder)
|
|---|
| 2788 | {
|
|---|
| 2789 | M_MMAudioMethodDebug("M_MMAudio","cwaudioM_wpclsCreateDefaultTemplates");
|
|---|
| 2790 |
|
|---|
| 2791 | //HlpWriteToTrapLog("Classtitle: %s, Type: %s\n",_wpclsQueryTitle(somSelf), _wpclsQueryInstanceType(somSelf));
|
|---|
| 2792 | if(checkForWriteEnabledAudioIOProc( _wpclsQueryInstanceFilter(somSelf))) {
|
|---|
| 2793 | /* A write enabled IO proc was found, create the template. */
|
|---|
| 2794 | mmclsCreateTheDefaultTemplate(somSelf, Folder);
|
|---|
| 2795 | return TRUE; /* Tell the WPS template created*/
|
|---|
| 2796 | }
|
|---|
| 2797 |
|
|---|
| 2798 | return TRUE; /* We created the template or don't want to have one */
|
|---|
| 2799 | }
|
|---|
| 2800 |
|
|---|
| 2801 |
|
|---|
| 2802 | SOM_Scope PSZ SOMLINK cwaudioM_wpclsQueryInstanceType(M_MMAudio *somSelf)
|
|---|
| 2803 | {
|
|---|
| 2804 | /* M_MMAudioData *somThis = M_MMAudioGetData(somSelf); */
|
|---|
| 2805 | M_MMAudioMethodDebug("M_MMAudio","cwaudioM_wpclsQueryInstanceType");
|
|---|
| 2806 |
|
|---|
| 2807 | return TYPE_DIGITALAUDIO;
|
|---|
| 2808 | }
|
|---|
| 2809 |
|
|---|
| 2810 | SOM_Scope PSZ SOMLINK cwaudioM_wpclsQueryInstanceFilter(M_MMAudio *somSelf)
|
|---|
| 2811 | {
|
|---|
| 2812 | /* M_MMAudioData *somThis = M_MMAudioGetData(somSelf); */
|
|---|
| 2813 | M_MMAudioMethodDebug("M_MMAudio","cwaudioM_wpclsQueryInstanceFilter");
|
|---|
| 2814 |
|
|---|
| 2815 | /* The list of additional extensions is built in wpclsInitData().
|
|---|
| 2816 |
|
|---|
| 2817 | FIXME
|
|---|
| 2818 | This is a static list read in only once during startup.
|
|---|
| 2819 | Should probably be changed later on.
|
|---|
| 2820 | */
|
|---|
| 2821 | return chrMMAudioExt;
|
|---|
| 2822 | /* return (M_MMAudio_parent_M_CWMMDataFile_wpclsQueryInstanceFilter(somSelf)); */
|
|---|
| 2823 | }
|
|---|
| 2824 |
|
|---|
| 2825 | /*
|
|---|
| 2826 | * The prototype for cwaudioM_wpclsQueryDetailsInfo was replaced by the following prototype:
|
|---|
| 2827 | */
|
|---|
| 2828 | SOM_Scope ULONG SOMLINK cwaudioM_wpclsQueryDetailsInfo(M_MMAudio *somSelf,
|
|---|
| 2829 | PCLASSFIELDINFO* ppClassFieldInfo,
|
|---|
| 2830 | PULONG pSize)
|
|---|
| 2831 | {
|
|---|
| 2832 | ULONG cParentColumns;
|
|---|
| 2833 | PCLASSFIELDINFO pCfi;
|
|---|
| 2834 | int i;
|
|---|
| 2835 |
|
|---|
| 2836 | /* M_CWAudioData *somThis = M_CWAudioGetData(somSelf); */
|
|---|
| 2837 | M_MMAudioMethodDebug("M_MMAudio","cwaudioM_wpclsQueryDetailsInfo");
|
|---|
| 2838 |
|
|---|
| 2839 | cParentColumns= (M_MMAudio_parent_M_CWMMDataFile_wpclsQueryDetailsInfo(somSelf,
|
|---|
| 2840 | ppClassFieldInfo,
|
|---|
| 2841 | pSize));
|
|---|
| 2842 | if(pSize)
|
|---|
| 2843 | *pSize+=sizeof(AUDIODETAILS);
|
|---|
| 2844 |
|
|---|
| 2845 | if(ppClassFieldInfo)
|
|---|
| 2846 | {
|
|---|
| 2847 | if(*ppClassFieldInfo)
|
|---|
| 2848 | {
|
|---|
| 2849 | pCfi=*ppClassFieldInfo;
|
|---|
| 2850 | for(i=0; i<cParentColumns;i++)
|
|---|
| 2851 | pCfi=(pCfi->pNextFieldInfo ? pCfi->pNextFieldInfo: pCfi);
|
|---|
| 2852 |
|
|---|
| 2853 | pCfi->pNextFieldInfo=cfiFieldInfo;
|
|---|
| 2854 | }
|
|---|
| 2855 | else
|
|---|
| 2856 | *ppClassFieldInfo=cfiFieldInfo;
|
|---|
| 2857 | }
|
|---|
| 2858 | return (cParentColumns+NUM_AUDIO_FIELDS);
|
|---|
| 2859 | }
|
|---|
| 2860 |
|
|---|
| 2861 |
|
|---|
| 2862 | /*
|
|---|
| 2863 | * The prototype for cwaudioM_wpclsQueryTitle was replaced by the following prototype:
|
|---|
| 2864 | */
|
|---|
| 2865 | SOM_Scope PSZ SOMLINK cwaudioM_wpclsQueryTitle(M_MMAudio *somSelf)
|
|---|
| 2866 | {
|
|---|
| 2867 | static char chrTitle[30]={0};
|
|---|
| 2868 |
|
|---|
| 2869 | M_MMAudioMethodDebug("M_MMAudio","cwaudioM_wpclsQueryTitle");
|
|---|
| 2870 |
|
|---|
| 2871 | if(chrTitle[0]==0)
|
|---|
| 2872 | if(!getMessage(chrTitle, IDSTR_CWAUDIOTITLE, sizeof(chrTitle), queryResModuleHandle(), HWND_DESKTOP))
|
|---|
| 2873 | strcpy(chrTitle, CLSTITLE_DIGITALAUDIO);
|
|---|
| 2874 |
|
|---|
| 2875 | return chrTitle;
|
|---|
| 2876 | }
|
|---|
| 2877 |
|
|---|
| 2878 | /*
|
|---|
| 2879 | Initialize the MMAudio class.
|
|---|
| 2880 | */
|
|---|
| 2881 | SOM_Scope void SOMLINK cwaudioM_wpclsInitData(M_MMAudio *somSelf)
|
|---|
| 2882 | {
|
|---|
| 2883 | PCLASSFIELDINFO pCfi;
|
|---|
| 2884 | USHORT i;
|
|---|
| 2885 | static BOOL bGotAudioExt=FALSE;
|
|---|
| 2886 |
|
|---|
| 2887 | /* M_CWAudioData *somThis = M_CWAudioGetData(somSelf); */
|
|---|
| 2888 | M_MMAudioMethodDebug("M_MMAudio","cwaudioM_wpclsInitData");
|
|---|
| 2889 |
|
|---|
| 2890 | /*
|
|---|
| 2891 | Get extensions of additional audio procs. These extensions may be specified by
|
|---|
| 2892 | newly installed IO procs in MMPM2.INI or by using the Multimedia setup. For
|
|---|
| 2893 | example the MMIOMP3 procedure for reading MP3 files adds the MP3 extension this
|
|---|
| 2894 | way to the system. Extensions already handled by a specialized class will be
|
|---|
| 2895 | filtered in the called REXX script e.g. MP3 so only unknown extensions end up here.
|
|---|
| 2896 |
|
|---|
| 2897 | Strangely enough wpclsQueryInstanceFilter() is called during wpclsInitData() so
|
|---|
| 2898 | we query the extensions here before calling the parent.
|
|---|
| 2899 |
|
|---|
| 2900 | FIXME:
|
|---|
| 2901 | The check is only done once during initialization. This is a little annoyance for
|
|---|
| 2902 | the user because new extension specified in the settings will only be picked up
|
|---|
| 2903 | on next WPS start.
|
|---|
| 2904 | */
|
|---|
| 2905 | if(!bGotAudioExt)
|
|---|
| 2906 | {
|
|---|
| 2907 | getStringFromRexxScript("audioext.rx", chrMMAudioExt, sizeof(chrMMAudioExt));
|
|---|
| 2908 | bGotAudioExt=TRUE;
|
|---|
| 2909 | }
|
|---|
| 2910 |
|
|---|
| 2911 | M_MMAudio_parent_M_CWMMDataFile_wpclsInitData(somSelf);
|
|---|
| 2912 |
|
|---|
| 2913 | /* Get strings for details view titled from the ressource DLL */
|
|---|
| 2914 | if(getMessage(chrPlayTime, IDSTR_PLAYTIME, sizeof(chrPlayTime), queryResModuleHandle(), HWND_DESKTOP))
|
|---|
| 2915 | pszAudioColTitles[0]=chrPlayTime;
|
|---|
| 2916 | /* New with 0.2.7 */
|
|---|
| 2917 | if(getMessage(chrSampleRate, IDSTR_BITRATE, sizeof(chrBitRate), queryResModuleHandle(), HWND_DESKTOP))
|
|---|
| 2918 | pszAudioColTitles[1]=chrBitRate;
|
|---|
| 2919 |
|
|---|
| 2920 | if(getMessage(chrSampleRate, IDSTR_SAMPLERATE, sizeof(chrSampleRate), queryResModuleHandle(), HWND_DESKTOP))
|
|---|
| 2921 | pszAudioColTitles[2]=chrSampleRate;
|
|---|
| 2922 | if(getMessage(chrChannels, IDSTR_CHANNELS, sizeof(chrChannels), queryResModuleHandle(), HWND_DESKTOP))
|
|---|
| 2923 | pszAudioColTitles[3]=chrChannels;
|
|---|
| 2924 | if(getMessage(chrBPS, IDSTR_BPS, sizeof(chrBPS), queryResModuleHandle(), HWND_DESKTOP))
|
|---|
| 2925 | pszAudioColTitles[4]=chrBPS;
|
|---|
| 2926 |
|
|---|
| 2927 | if(getMessage(chrName, IDSTR_TITLE, sizeof(chrName), queryResModuleHandle(), HWND_DESKTOP))
|
|---|
| 2928 | pszAudioColTitles[5]=chrName;
|
|---|
| 2929 | if(getMessage(chrArtist, IDSTR_ARTIST, sizeof(chrArtist), queryResModuleHandle(), HWND_DESKTOP))
|
|---|
| 2930 | pszAudioColTitles[6]=chrArtist;
|
|---|
| 2931 | if(getMessage(chrAlbum, IDSTR_ALBUM, sizeof(chrAlbum), queryResModuleHandle(), HWND_DESKTOP))
|
|---|
| 2932 | pszAudioColTitles[7]=chrAlbum;
|
|---|
| 2933 | if(getMessage(chrYear, IDSTR_YEAR, sizeof(chrYear), queryResModuleHandle(), HWND_DESKTOP))
|
|---|
| 2934 | pszAudioColTitles[8]=chrYear;
|
|---|
| 2935 | if(getMessage(chrComment, IDSTR_COMMENT, sizeof(chrComment), queryResModuleHandle(), HWND_DESKTOP))
|
|---|
| 2936 | pszAudioColTitles[9]=chrComment;
|
|---|
| 2937 | if(getMessage(chrGenre, IDSTR_GENRE, sizeof(chrGenre), queryResModuleHandle(), HWND_DESKTOP))
|
|---|
| 2938 | pszAudioColTitles[10]=chrGenre;
|
|---|
| 2939 |
|
|---|
| 2940 |
|
|---|
| 2941 | /* Setup the static data for the details view */
|
|---|
| 2942 | for(i=0,pCfi=cfiFieldInfo;i<NUM_AUDIO_FIELDS;i++,pCfi++)
|
|---|
| 2943 | {
|
|---|
| 2944 | memset((PCH)pCfi,0,sizeof(CLASSFIELDINFO));
|
|---|
| 2945 |
|
|---|
| 2946 | pCfi->cb=sizeof(CLASSFIELDINFO);
|
|---|
| 2947 | pCfi->flData=CFA_LEFT|CFA_SEPARATOR|CFA_FIREADONLY;
|
|---|
| 2948 | pCfi->flTitle=CFA_CENTER|CFA_SEPARATOR|CFA_HORZSEPARATOR|CFA_STRING|CFA_FITITLEREADONLY;
|
|---|
| 2949 | pCfi->pNextFieldInfo=pCfi+1;
|
|---|
| 2950 | pCfi->pTitleData=(PVOID)pszAudioColTitles[i];
|
|---|
| 2951 | pCfi->flCompare=COMPARE_SUPPORTED|SORTBY_SUPPORTED;
|
|---|
| 2952 |
|
|---|
| 2953 | switch(i)
|
|---|
| 2954 | {
|
|---|
| 2955 | case 0: /* play time */
|
|---|
| 2956 | pCfi->flData|=CFA_STRING;
|
|---|
| 2957 | pCfi->offFieldData=(ULONG)(FIELDOFFSETUL(AUDIODETAILS,pszPlayTime));
|
|---|
| 2958 | pCfi->ulLenFieldData=sizeof(PSZ);
|
|---|
| 2959 | pCfi->DefaultComparison=CMP_EQUAL;
|
|---|
| 2960 | break;
|
|---|
| 2961 | case 1: /* Bitrate */ /* New with 0.2.7 */
|
|---|
| 2962 | pCfi->flData|=CFA_STRING;
|
|---|
| 2963 | pCfi->offFieldData=(ULONG)(FIELDOFFSETUL(AUDIODETAILS,pszBitRate));
|
|---|
| 2964 | pCfi->ulLenFieldData=sizeof(PSZ);
|
|---|
| 2965 | pCfi->DefaultComparison=CMP_EQUAL;
|
|---|
| 2966 | break;
|
|---|
| 2967 | case 2: /* Sample rate */
|
|---|
| 2968 | pCfi->flData|=CFA_STRING;
|
|---|
| 2969 | pCfi->offFieldData=(ULONG)(FIELDOFFSETUL(AUDIODETAILS,pszSampleRate));
|
|---|
| 2970 | pCfi->ulLenFieldData=sizeof(PSZ);
|
|---|
| 2971 | pCfi->DefaultComparison=CMP_EQUAL;
|
|---|
| 2972 | break;
|
|---|
| 2973 | case 3: /* Channels */
|
|---|
| 2974 | pCfi->flData|=CFA_STRING;
|
|---|
| 2975 | pCfi->offFieldData=(ULONG)(FIELDOFFSETUL(AUDIODETAILS,pszChannels));
|
|---|
| 2976 | pCfi->ulLenFieldData=sizeof(PSZ);
|
|---|
| 2977 | pCfi->DefaultComparison=CMP_EQUAL;
|
|---|
| 2978 | break;
|
|---|
| 2979 | case 4: /* BPS */
|
|---|
| 2980 | pCfi->flData|=CFA_STRING;
|
|---|
| 2981 | pCfi->offFieldData=(ULONG)(FIELDOFFSETUL(AUDIODETAILS,pszBPS));
|
|---|
| 2982 | pCfi->ulLenFieldData=sizeof(PSZ);
|
|---|
| 2983 | pCfi->DefaultComparison=CMP_EQUAL;
|
|---|
| 2984 | break;
|
|---|
| 2985 |
|
|---|
| 2986 | case 5:
|
|---|
| 2987 | pCfi->flData|=CFA_STRING;
|
|---|
| 2988 | pCfi->offFieldData=(ULONG)(FIELDOFFSETUL(AUDIODETAILS,pszName));
|
|---|
| 2989 | pCfi->ulLenFieldData=sizeof(PSZ);
|
|---|
| 2990 | pCfi->DefaultComparison=CMP_EQUAL;
|
|---|
| 2991 | break;
|
|---|
| 2992 | case 6:
|
|---|
| 2993 | pCfi->flData|=CFA_STRING;
|
|---|
| 2994 | pCfi->flData|=CFA_STRING;
|
|---|
| 2995 | pCfi->offFieldData=(ULONG)(FIELDOFFSETUL(AUDIODETAILS,pszArtist));
|
|---|
| 2996 | pCfi->ulLenFieldData=sizeof(PSZ);
|
|---|
| 2997 | pCfi->DefaultComparison=CMP_EQUAL;
|
|---|
| 2998 | break;
|
|---|
| 2999 | case 7:
|
|---|
| 3000 | pCfi->flData|=CFA_STRING;
|
|---|
| 3001 | pCfi->offFieldData=(ULONG)(FIELDOFFSETUL(AUDIODETAILS,pszAlbum));
|
|---|
| 3002 | pCfi->ulLenFieldData=sizeof(PSZ);
|
|---|
| 3003 | pCfi->DefaultComparison=CMP_EQUAL;
|
|---|
| 3004 | break;
|
|---|
| 3005 | case 8:
|
|---|
| 3006 | pCfi->flData|=CFA_STRING;
|
|---|
| 3007 | pCfi->offFieldData=(ULONG)(FIELDOFFSETUL(AUDIODETAILS,pszYear));
|
|---|
| 3008 | pCfi->ulLenFieldData=sizeof(PSZ);
|
|---|
| 3009 | pCfi->DefaultComparison=CMP_EQUAL;
|
|---|
| 3010 | break;
|
|---|
| 3011 | case 9:
|
|---|
| 3012 | pCfi->flData|=CFA_STRING;
|
|---|
| 3013 | pCfi->offFieldData=(ULONG)(FIELDOFFSETUL(AUDIODETAILS,pszComment));
|
|---|
| 3014 | pCfi->ulLenFieldData=sizeof(PSZ);
|
|---|
| 3015 | pCfi->DefaultComparison=CMP_EQUAL;
|
|---|
| 3016 | break;
|
|---|
| 3017 | case 10:
|
|---|
| 3018 | pCfi->flData|=CFA_STRING;
|
|---|
| 3019 | pCfi->offFieldData=(ULONG)(FIELDOFFSETUL(AUDIODETAILS,pszGenre));
|
|---|
| 3020 | pCfi->ulLenFieldData=sizeof(PSZ);
|
|---|
| 3021 | pCfi->DefaultComparison=CMP_EQUAL;
|
|---|
| 3022 | break;
|
|---|
| 3023 |
|
|---|
| 3024 | }/* switch(i) */
|
|---|
| 3025 | }/* for() */
|
|---|
| 3026 | cfiFieldInfo[NUM_AUDIO_FIELDS].pNextFieldInfo=NULL;
|
|---|
| 3027 |
|
|---|
| 3028 | /* Get name of help library from resource */
|
|---|
| 3029 | if(!getMessage(chrHelpLibrary, IDSTR_HELPLIBRARY, sizeof(chrHelpLibrary),
|
|---|
| 3030 | queryResModuleHandle(), HWND_DESKTOP))
|
|---|
| 3031 | strcpy(chrHelpLibrary,"MMPARTS.HLP"); /* Fall back to default Warp hel library */
|
|---|
| 3032 | }
|
|---|
| 3033 |
|
|---|
| 3034 |
|
|---|
| 3035 |
|
|---|
| 3036 |
|
|---|
| 3037 |
|
|---|
| 3038 |
|
|---|
| 3039 | SOM_Scope void SOMLINK cwaudioM_wpclsUnInitData(M_MMAudio *somSelf)
|
|---|
| 3040 | {
|
|---|
| 3041 | /* M_MMAudioData *somThis = M_MMAudioGetData(somSelf); */
|
|---|
| 3042 | M_MMAudioMethodDebug("M_MMAudio","cwaudioM_wpclsUnInitData");
|
|---|
| 3043 |
|
|---|
| 3044 | M_MMAudio_parent_M_CWMMDataFile_wpclsUnInitData(somSelf);
|
|---|
| 3045 | }
|
|---|
| 3046 |
|
|---|
| 3047 | /*
|
|---|
| 3048 | * The prototype for cwaudioM_wpclsQueryDefaultView was replaced by the following prototype:
|
|---|
| 3049 | */
|
|---|
| 3050 | SOM_Scope ULONG SOMLINK cwaudioM_wpclsQueryDefaultView(M_MMAudio *somSelf)
|
|---|
| 3051 | {
|
|---|
| 3052 | /* M_CWAudioData *somThis = M_CWAudioGetData(somSelf); */
|
|---|
| 3053 | M_MMAudioMethodDebug("M_MMAudio","cwaudioM_wpclsQueryDefaultView");
|
|---|
| 3054 |
|
|---|
| 3055 | /* Default view for audio objects is 'Start' so on doubleclick the playing starts
|
|---|
| 3056 | immediately. */
|
|---|
| 3057 | return ID_MENU_START;
|
|---|
| 3058 | // return (M_CWAudio_parent_M_MMAudio_wpclsQueryDefaultView(somSelf));
|
|---|
| 3059 | }
|
|---|
| 3060 |
|
|---|
| 3061 | /*
|
|---|
| 3062 | * The prototype for cwaudioM_wpclsQueryIconData was replaced by the following prototype:
|
|---|
| 3063 | */
|
|---|
| 3064 | SOM_Scope ULONG SOMLINK cwaudioM_wpclsQueryIconData(M_MMAudio *somSelf,
|
|---|
| 3065 | PICONINFO pIconInfo)
|
|---|
| 3066 | {
|
|---|
| 3067 | /* M_CWAudioData *somThis = M_CWAudioGetData(somSelf); */
|
|---|
| 3068 | M_MMAudioMethodDebug("M_MMAudio","cwaudioM_wpclsQueryIconData");
|
|---|
| 3069 | /*
|
|---|
| 3070 | We have our own icon.
|
|---|
| 3071 | */
|
|---|
| 3072 | if (pIconInfo) {
|
|---|
| 3073 | pIconInfo->fFormat = ICON_RESOURCE;
|
|---|
| 3074 | pIconInfo->hmod = queryModuleHandle();
|
|---|
| 3075 | pIconInfo->resid = ID_ICONCWAUDIOFILE;
|
|---|
| 3076 | } /* endif */
|
|---|
| 3077 |
|
|---|
| 3078 | return ( sizeof(ICONINFO) );
|
|---|
| 3079 | }
|
|---|
| 3080 |
|
|---|
| 3081 |
|
|---|
| 3082 |
|
|---|
| 3083 | MRESULT EXPENTRY audioWorkerProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|---|
| 3084 | {
|
|---|
| 3085 |
|
|---|
| 3086 | switch (msg)
|
|---|
| 3087 | {
|
|---|
| 3088 | case WM_APPTERMINATENOTIFY:
|
|---|
| 3089 | {
|
|---|
| 3090 | ULONG ulSize;
|
|---|
| 3091 | char fName[CCHMAXPATH];
|
|---|
| 3092 | char text[CCHMAXPATH];
|
|---|
| 3093 | BOOL bContinue=FALSE;
|
|---|
| 3094 | MMAudio *somSelf=(MMAudio*)mp1;
|
|---|
| 3095 | MMAudioData *somThis= MMAudioGetData(somSelf);
|
|---|
| 3096 | ULONG ulLoop;
|
|---|
| 3097 | //FIXME
|
|---|
| 3098 | //M_CWMMDataFileData *m_mmCWMM = M_CWMMDataFileGetData(_CWMMDataFile);
|
|---|
| 3099 |
|
|---|
| 3100 | TRY_LOUD(AUDIO_WORKER) {
|
|---|
| 3101 | for(;;) {
|
|---|
| 3102 | ULONG rc;
|
|---|
| 3103 | MMIOINFO mmio;
|
|---|
| 3104 | HMMIO hmmio;
|
|---|
| 3105 | MMAUDIOHEADER mmAudioHeader={0};
|
|---|
| 3106 | LONG lBytesRead=0;
|
|---|
| 3107 | char* pChar;
|
|---|
| 3108 | ULONG ulFSize;
|
|---|
| 3109 | BOOL bIsMidi=FALSE;
|
|---|
| 3110 |
|
|---|
| 3111 | mmclsSetObjectType(somSelf);
|
|---|
| 3112 |
|
|---|
| 3113 | if(!somIsObj(somSelf))
|
|---|
| 3114 | break;
|
|---|
| 3115 |
|
|---|
| 3116 | ulFSize=_wpQueryFileSize(somSelf);
|
|---|
| 3117 | if(_ulFileSize==ulFSize)
|
|---|
| 3118 | break; /* We already scanned this file */
|
|---|
| 3119 |
|
|---|
| 3120 | ulSize=sizeof(fName);
|
|---|
| 3121 | if(!_wpQueryRealName(somSelf, fName, &ulSize, TRUE))
|
|---|
| 3122 | break;
|
|---|
| 3123 |
|
|---|
| 3124 | /* Show status window */
|
|---|
| 3125 | if((pChar=strrchr(fName, '\\'))!=NULLHANDLE) {
|
|---|
| 3126 | HPS hps;
|
|---|
| 3127 | ULONG ulWinTextLen;
|
|---|
| 3128 | POINTL aptlPoints[TXTBOX_COUNT];
|
|---|
| 3129 | SWP swp;
|
|---|
| 3130 | ULONG ulCy;
|
|---|
| 3131 | WPOINT pwpBorder;
|
|---|
| 3132 | //FIXME
|
|---|
| 3133 | //HWND hwndClient=WinWindowFromID(m_mmCWMM->hwndStatus, FID_CLIENT);
|
|---|
| 3134 | HWND hwndClient=WinWindowFromID(__get_hwndStatus(_CWMMDataFile), FID_CLIENT);
|
|---|
| 3135 |
|
|---|
| 3136 | sprintf(text,"%c:\\...%s",fName[0], pChar);
|
|---|
| 3137 | WinSetWindowText(hwndClient, text);
|
|---|
| 3138 | ulWinTextLen=(ULONG)strlen(text); // Query text length
|
|---|
| 3139 |
|
|---|
| 3140 | /* Calculate text size in pixel */
|
|---|
| 3141 | hps=WinBeginPaint(hwndClient,(HPS)NULL,(PRECTL)NULL);
|
|---|
| 3142 | GpiQueryTextBox(hps,ulWinTextLen,text,TXTBOX_COUNT,aptlPoints);
|
|---|
| 3143 | WinEndPaint(hps);
|
|---|
| 3144 | //FIXME
|
|---|
| 3145 | //if(WinSendMsg(m_mmCWMM->hwndStatus ,WM_QUERYBORDERSIZE, MPFROMP(&pwpBorder), 0L))
|
|---|
| 3146 | if(WinSendMsg(__get_hwndStatus(_CWMMDataFile) ,WM_QUERYBORDERSIZE, MPFROMP(&pwpBorder), 0L))
|
|---|
| 3147 | ulCy=pwpBorder.x*2;
|
|---|
| 3148 | else
|
|---|
| 3149 | ulCy=SV_CYBORDER*2;
|
|---|
| 3150 | //FIXME
|
|---|
| 3151 | // if(WinQueryWindowPos(WinWindowFromID(m_mmCWMM->hwndStatus, FID_TITLEBAR),&swp))
|
|---|
| 3152 | if(WinQueryWindowPos(WinWindowFromID(__get_hwndStatus(_CWMMDataFile), FID_TITLEBAR),&swp))
|
|---|
| 3153 | ulCy+=swp.cy;
|
|---|
| 3154 | else
|
|---|
| 3155 | ulCy+=15;
|
|---|
| 3156 | //FIXME
|
|---|
| 3157 | // WinSetWindowPos(m_mmCWMM->hwndStatus, HWND_TOP, 0,0,
|
|---|
| 3158 | WinSetWindowPos(__get_hwndStatus(_CWMMDataFile), HWND_TOP, 0,0,
|
|---|
| 3159 | aptlPoints[TXTBOX_BOTTOMRIGHT].x-aptlPoints[TXTBOX_BOTTOMLEFT].x+18,
|
|---|
| 3160 | aptlPoints[TXTBOX_TOPRIGHT].y-aptlPoints[TXTBOX_BOTTOMRIGHT].y+ulCy+4,
|
|---|
| 3161 | SWP_SIZE|SWP_SHOW|SWP_ZORDER|SWP_DEACTIVATE);
|
|---|
| 3162 | //FIXME
|
|---|
| 3163 | // WinPostMsg(m_mmCWMM->hwndStatus, WM_APPTERMINATENOTIFY, 0,MPFROMLONG(1L));
|
|---|
| 3164 | WinPostMsg(__get_hwndStatus(_CWMMDataFile), WM_APPTERMINATENOTIFY, 0,MPFROMLONG(1L));
|
|---|
| 3165 | }
|
|---|
| 3166 | //#if 0
|
|---|
| 3167 | /* This part obsolete?? */
|
|---|
| 3168 | /* Get file name */
|
|---|
| 3169 | ulSize=sizeof(fName);
|
|---|
| 3170 | if(!_wpQueryRealName(somSelf, fName, &ulSize, TRUE))
|
|---|
| 3171 | break;
|
|---|
| 3172 | //#endif
|
|---|
| 3173 |
|
|---|
| 3174 | if(!_somIsA(somSelf, somGetSomClass("MMMIDI")))
|
|---|
| 3175 | {
|
|---|
| 3176 | /* Check audio files */
|
|---|
| 3177 | MP3OPTIONS mp3Opt; /* Struct holding MP3 additional info */
|
|---|
| 3178 | VORBISOPTIONS vorbisOpt;
|
|---|
| 3179 |
|
|---|
| 3180 | PMP3OPTIONS returnedMP3Opts;
|
|---|
| 3181 | PVORBISOPTIONS returnedVorbisOpts;
|
|---|
| 3182 |
|
|---|
| 3183 | memset(&mmio,0, sizeof(mmio));
|
|---|
| 3184 | mmio.ulFlags=MMIO_READ;
|
|---|
| 3185 | mmio.ulTranslate=MMIO_TRANSLATEHEADER;
|
|---|
| 3186 |
|
|---|
| 3187 | if(somObjectIsA(somSelf, "MMOGG"))
|
|---|
| 3188 | {
|
|---|
| 3189 | vorbisOpt.cookie = VORBIS_COOKIE;
|
|---|
| 3190 | mmio.pExtraInfoStruct = &vorbisOpt;
|
|---|
| 3191 | }
|
|---|
| 3192 | else
|
|---|
| 3193 | {
|
|---|
| 3194 | /* For bitrate query of MP3 */
|
|---|
| 3195 | mp3Opt.cookie = MP3_COOKIE;
|
|---|
| 3196 | mmio.pExtraInfoStruct = &mp3Opt;
|
|---|
| 3197 | }
|
|---|
| 3198 | hmmio = mmioOpen(fName, &mmio, MMIO_READ);
|
|---|
| 3199 | if(!hmmio)
|
|---|
| 3200 | break;
|
|---|
| 3201 |
|
|---|
| 3202 | memset(&mmAudioHeader,0,sizeof(MMAUDIOHEADER));
|
|---|
| 3203 | rc = mmioGetHeader(hmmio, &mmAudioHeader,sizeof(MMAUDIOHEADER),
|
|---|
| 3204 | &lBytesRead, 0, 0);
|
|---|
| 3205 |
|
|---|
| 3206 | if(rc!=MMIO_SUCCESS) {
|
|---|
| 3207 | mmioClose(hmmio, 0);
|
|---|
| 3208 | break;
|
|---|
| 3209 | }
|
|---|
| 3210 | mmioClose(hmmio, 0);
|
|---|
| 3211 |
|
|---|
| 3212 | /* Check if the object is still living. */
|
|---|
| 3213 | if(!somIsObj(somSelf))
|
|---|
| 3214 | break;
|
|---|
| 3215 |
|
|---|
| 3216 | if(somObjectIsA(somSelf, "MMOGG")) {
|
|---|
| 3217 | returnedVorbisOpts = (PVORBISOPTIONS)mmAudioHeader.mmXWAVHeader.XWAVHeaderInfo.pAdditionalInformation;
|
|---|
| 3218 | if(0 != returnedVorbisOpts && VORBIS_COOKIE == returnedVorbisOpts->cookie && 0 != returnedVorbisOpts->nominal_bitrate)
|
|---|
| 3219 | _ulBitRate=returnedVorbisOpts->nominal_bitrate;
|
|---|
| 3220 | else
|
|---|
| 3221 | _ulBitRate=0;
|
|---|
| 3222 | }
|
|---|
| 3223 | else {
|
|---|
| 3224 | returnedMP3Opts = (PMP3OPTIONS)mmAudioHeader.mmXWAVHeader.XWAVHeaderInfo.pAdditionalInformation;
|
|---|
| 3225 | if(0 != returnedMP3Opts && MP3_COOKIE == returnedMP3Opts->cookie && 0 != returnedMP3Opts->bitrate)
|
|---|
| 3226 | _ulBitRate=returnedMP3Opts->bitrate;
|
|---|
| 3227 | else
|
|---|
| 3228 | _ulBitRate=0;
|
|---|
| 3229 | }
|
|---|
| 3230 |
|
|---|
| 3231 |
|
|---|
| 3232 | _ulChannels=mmAudioHeader.mmXWAVHeader.WAVEHeader.usChannels;
|
|---|
| 3233 | _ulSampleRate=mmAudioHeader.mmXWAVHeader.WAVEHeader.ulSamplesPerSec;
|
|---|
| 3234 | _ulBPS=mmAudioHeader.mmXWAVHeader.WAVEHeader.usBitsPerSample;
|
|---|
| 3235 | _ulNumAudioBytes=mmAudioHeader.mmXWAVHeader.XWAVHeaderInfo.ulAudioLengthInBytes;
|
|---|
| 3236 | /* sprintf(fName,"%02d:%02d",mmAudioHeader.mmXWAVHeader.XWAVHeaderInfo.ulAudioLengthInBytes/
|
|---|
| 3237 | mmAudioHeader.mmXWAVHeader.WAVEHeader.ulAvgBytesPerSec/60,
|
|---|
| 3238 | mmAudioHeader.mmXWAVHeader.XWAVHeaderInfo.ulAudioLengthInBytes/
|
|---|
| 3239 | mmAudioHeader.mmXWAVHeader.WAVEHeader.ulAvgBytesPerSec%60);*/
|
|---|
| 3240 | if(mmAudioHeader.mmXWAVHeader.XWAVHeaderInfo.ulAudioLengthInMS/1000) {
|
|---|
| 3241 | _ulPlaySecs=mmAudioHeader.mmXWAVHeader.XWAVHeaderInfo.ulAudioLengthInMS/1000;
|
|---|
| 3242 | _ulPlayMsecs=mmAudioHeader.mmXWAVHeader.XWAVHeaderInfo.ulAudioLengthInMS;
|
|---|
| 3243 | }
|
|---|
| 3244 | else {
|
|---|
| 3245 | _ulPlaySecs=mmAudioHeader.mmXWAVHeader.XWAVHeaderInfo.ulAudioLengthInBytes/
|
|---|
| 3246 | mmAudioHeader.mmXWAVHeader.WAVEHeader.ulAvgBytesPerSec;
|
|---|
| 3247 | _ulPlayMsecs=_ulPlaySecs*1000;
|
|---|
| 3248 | }
|
|---|
| 3249 | }/* _somIsA()*/
|
|---|
| 3250 | else
|
|---|
| 3251 | {
|
|---|
| 3252 | /* The file is a midi file. Get audio information using MCI commands. */
|
|---|
| 3253 | unsigned char chrCommand[CCHMAXPATH];
|
|---|
| 3254 | char retMsg[20];
|
|---|
| 3255 | APIRET rc;
|
|---|
| 3256 | ULONG ulTime;
|
|---|
| 3257 |
|
|---|
| 3258 | bIsMidi=TRUE;
|
|---|
| 3259 |
|
|---|
| 3260 | // HlpWriteToTrapLog("File: %s\n", fName);
|
|---|
| 3261 | /* open the file */
|
|---|
| 3262 | sprintf(chrCommand,"open \"%s\" type SEQUENCER alias wave%d SHAREABLE wait",fName, somSelf);
|
|---|
| 3263 | rc = mciSendString( chrCommand, retMsg, sizeof(retMsg), NULLHANDLE, 0);
|
|---|
| 3264 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
|---|
| 3265 | break;
|
|---|
| 3266 | }
|
|---|
| 3267 |
|
|---|
| 3268 | /* Set time format */
|
|---|
| 3269 | sprintf(chrCommand,"SET wave%d TIME FORMAT MILLISECONDS wait", somSelf);
|
|---|
| 3270 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
|---|
| 3271 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
|---|
| 3272 | /* close the file */
|
|---|
| 3273 | sprintf(chrCommand,"close wave%d wait", somSelf);
|
|---|
| 3274 | mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
|---|
| 3275 | break;
|
|---|
| 3276 | }
|
|---|
| 3277 |
|
|---|
| 3278 | /* Get midi info */
|
|---|
| 3279 | sprintf(chrCommand,"STATUS wave%d LENGTH WAIT", somSelf);
|
|---|
| 3280 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
|---|
| 3281 | if((rc & 0x0000ffff)!=MCIERR_SUCCESS) {
|
|---|
| 3282 | /* close the file */
|
|---|
| 3283 | sprintf(chrCommand,"close wave%d wait", somSelf);
|
|---|
| 3284 | mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
|---|
| 3285 | break;
|
|---|
| 3286 | }
|
|---|
| 3287 | ulTime=atoi(retMsg);
|
|---|
| 3288 | // HlpWriteToTrapLog("Midi-Time in ms: %d %s\n", ulTime, fName);
|
|---|
| 3289 |
|
|---|
| 3290 | if(ulTime/1000) {
|
|---|
| 3291 | _ulPlaySecs=ulTime/1000;
|
|---|
| 3292 | _ulPlayMsecs=ulTime;
|
|---|
| 3293 | }
|
|---|
| 3294 | else {
|
|---|
| 3295 | _ulPlaySecs=1;
|
|---|
| 3296 | _ulPlayMsecs=_ulPlaySecs*1000;
|
|---|
| 3297 | }
|
|---|
| 3298 |
|
|---|
| 3299 | // HlpWriteToTrapLog("Midi-Time ulPlaySecs: %d\n", _ulPlaySecs);
|
|---|
| 3300 | sprintf(chrCommand,"STATUS wave%d NUMBER OF TRACKS WAIT", somSelf);
|
|---|
| 3301 | rc = mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
|---|
| 3302 | if((rc & 0x0000ffff)==MCIERR_SUCCESS) {
|
|---|
| 3303 | _ulChannels=atoi(retMsg);
|
|---|
| 3304 | // HlpWriteToTrapLog("Midi-Tracks: %d %s %s\n", _ulChannels, fName, retMsg);
|
|---|
| 3305 | }
|
|---|
| 3306 |
|
|---|
| 3307 | /* close the file */
|
|---|
| 3308 | sprintf(chrCommand,"close wave%d wait", somSelf);
|
|---|
| 3309 | mciSendString(chrCommand, retMsg, sizeof(retMsg), 0, 0);
|
|---|
| 3310 | }/* else is MMMIDI */
|
|---|
| 3311 |
|
|---|
| 3312 | _ulFileSize=_wpQueryFileSize(somSelf);
|
|---|
| 3313 | _bNeedSaving=TRUE;/* When the object is initialized the new instance data will be saved in wpObjectReady(). */
|
|---|
| 3314 |
|
|---|
| 3315 | sprintf(fName,"%d",_ulChannels);
|
|---|
| 3316 | strncpy(_chrChannels, fName, sizeof(_chrChannels));
|
|---|
| 3317 | _chrChannels[sizeof(_chrChannels)-1]=0;
|
|---|
| 3318 |
|
|---|
| 3319 | if(bIsMidi)
|
|---|
| 3320 | strncpy(_chrSampleRate, "---", sizeof(_chrSampleRate));
|
|---|
| 3321 | else {
|
|---|
| 3322 | sprintf(fName,"%d", _ulSampleRate);
|
|---|
| 3323 | strncpy(_chrSampleRate, fName, sizeof(_chrSampleRate));
|
|---|
| 3324 | }
|
|---|
| 3325 | _chrSampleRate[sizeof(_chrSampleRate)-1]=0;
|
|---|
| 3326 |
|
|---|
| 3327 | if(!_ulBitRate)
|
|---|
| 3328 | strncpy(_chrBitRate, "---", sizeof(_chrBitRate));
|
|---|
| 3329 | else {
|
|---|
| 3330 | sprintf(fName,"%d",_ulBitRate);
|
|---|
| 3331 | strncpy(_chrBitRate, fName, sizeof(_chrBitRate));
|
|---|
| 3332 | }
|
|---|
| 3333 | _chrBitRate[sizeof(_chrBitRate)-1]=0;
|
|---|
| 3334 |
|
|---|
| 3335 | if(bIsMidi)
|
|---|
| 3336 | strncpy(_chrBPS, "---", sizeof(_chrBPS));
|
|---|
| 3337 | else {
|
|---|
| 3338 | sprintf(fName,"%d",_ulBPS);
|
|---|
| 3339 | strncpy(_chrBPS, fName, sizeof(_chrBPS));
|
|---|
| 3340 | }
|
|---|
| 3341 | _chrBPS[sizeof(_chrBPS)-1]=0;
|
|---|
| 3342 |
|
|---|
| 3343 | sprintf(fName,"%02d:%02d",_ulPlaySecs/60, _ulPlaySecs%60);
|
|---|
| 3344 | strncpy(_chrPlayTime, fName, sizeof(_chrPlayTime));
|
|---|
| 3345 | _chrPlayTime[sizeof(_chrPlayTime)-1]=0;
|
|---|
| 3346 |
|
|---|
| 3347 | bContinue=TRUE;
|
|---|
| 3348 | break;
|
|---|
| 3349 | }/* for */
|
|---|
| 3350 | }
|
|---|
| 3351 | CATCH(AUDIO_WORKER)
|
|---|
| 3352 | {
|
|---|
| 3353 | SysWriteToTrapLog("\nTrap occured in %s, file %s, around line %d.\n",
|
|---|
| 3354 | __FUNCTION__, __FILE__, __LINE__);
|
|---|
| 3355 | SysWriteToTrapLog("Audio file: %s\n\n",
|
|---|
| 3356 | fName);
|
|---|
| 3357 | } END_CATCH;
|
|---|
| 3358 | //FIXME
|
|---|
| 3359 | // WinPostMsg(m_mmCWMM->hwndStatus, WM_APPTERMINATENOTIFY, 0, 0L);
|
|---|
| 3360 | WinPostMsg(__get_hwndStatus(_CWMMDataFile), WM_APPTERMINATENOTIFY, 0, 0L);
|
|---|
| 3361 |
|
|---|
| 3362 | if(!bContinue)
|
|---|
| 3363 | return (MRESULT)FALSE;
|
|---|
| 3364 |
|
|---|
| 3365 | /* This Message was posted from wpRestore(). It's not allowed to call
|
|---|
| 3366 | wpSaveDeferred() from there. The object must be initilized! This is important when
|
|---|
| 3367 | creating objects form templates. So we wait for the object to be initialized.
|
|---|
| 3368 | If it isn't initialized within 2s we quit. */
|
|---|
| 3369 | ulLoop=0;
|
|---|
| 3370 | while(!_wpIsObjectInitialized(somSelf) && ulLoop<40) {
|
|---|
| 3371 | DosSleep(50);
|
|---|
| 3372 | ulLoop++;
|
|---|
| 3373 | }
|
|---|
| 3374 | if(ulLoop<20)
|
|---|
| 3375 | _wpSaveDeferred(somSelf);
|
|---|
| 3376 | _wpCnrRefreshDetails(somSelf);
|
|---|
| 3377 |
|
|---|
| 3378 | return (MRESULT) FALSE;
|
|---|
| 3379 | }
|
|---|
| 3380 | default:
|
|---|
| 3381 | break;
|
|---|
| 3382 | }
|
|---|
| 3383 |
|
|---|
| 3384 | return WinDefWindowProc( hwnd, msg, mp1, mp2);
|
|---|
| 3385 | }
|
|---|
| 3386 |
|
|---|