Einzelnen Beitrag anzeigen

EWeiss
(Gast)

n/a Beiträge
 
#3

Re: Dynamisches Array oder Klasse als Array auslegen

  Alt 22. Sep 2006, 20:37
Danke marabu.

Werde mir das mal zu gemüte führen..
Anbei nochmal die ganze klasse (Delphi style angepasst)

Delphi-Quellcode:
Type
  //WinampDSPInfo Klasse
  PWinampDSPInfo = ^TWinampDSPInfo;
  TWinampDSPInfo = record
     csH : TRTLCriticalSection; // CRITICAL_SECTION
     handle : DWORD;                      // DSP handle
     NumberOfModules : UINT;                      // number of modules in the dsp
     hDll : HWND;                // the dll instance
     pModule : PWinampDSPHeader;       // module header
     pDSP :   PWinampDSPModule;       // current selected dsp module
     hchannel : DWORD;                      // channel associated to dsp
    module : DWORD;                      // curent selected dsp module
     hdsp : HDSP;                         // optional dsp handle
     DSP_Window_Emu : HWND;             // related fake window handle
     DSP_Atom_Emu : ATOM;                   // related fake window atom
     songTitle : array[0..MAX_PATH-1] of char; // the playing song title
     fileName : array[0..MAX_PATH-1] of char; // the playing file name
     info : BASS_CHANNELINFO;       // channel info
  end;
Delphi-Quellcode:
implementation

var
 winampDSP : PWinampDSPInfo = nil;
Der sinn des arrays liegt darin das bei jeden aufruf eines neuen DSP Plugins
eine neue Instanz von winampDSP gebildet werden soll das geschieht hier.

Original
Code:
void AddDSP(WINAMPPLUGINPROPDSP *winampDsp)
{
   DWORD a;
   for (a=0;a<winampDSPcounter;a++)
        if (!winampDSP[a]) break;

   if (a==winampDSPcounter)
   { 
      // no empty slot, so add a new one
      winampDSP = (WINAMPPLUGINPROPDSP**)realloc(winampDSP, (winampDSPcounter+1)*sizeof(WINAMPPLUGINPROPDSP*));
      winampDSPcounter++;
   }
   winampDsp->handle = ++winampDSPhandle;
   // insert the new Winamp DSP
   winampDSP[a] = winampDsp;
}
Übersetzt
Delphi-Quellcode:
procedure AddDSP(winampDsp: PWinampDSPInfo);
var
  a: DWORD;

begin
   for a := 0 to winampDSPcounter do
        if (not winampDSP[a]) then break;

   if a = winampDSPcounter then
   Begin
      // no empty slot, so add a new one
// winampDSP := ReallocMem(winampDSP, (winampDSPcounter + 1) SizeOf(PWinampDSPInfo);
      winampDSPcounter;
   end;
   winampDsp^.handle := winampDSPhandle;
   // insert the new Winamp DSP
// winampDSP[a] := winampDsp;
end;
Hier sind meine beiden Probleme.
ReallocMem ärger bei 'SizeOf'
und halt das berüchtigte array winampDSP[a] := winampDsp;

Vielleicht kannst ja mal drüberfliegen was da nicht in Ordnung ist.

gruß
  Mit Zitat antworten Zitat