Einzelnen Beitrag anzeigen

EWeiss
(Gast)

n/a Beiträge
 
#1

Struct übergabe problem

  Alt 16. Okt 2014, 09:43
Was mach ich falsch das meine Daten aus C++ nicht so an meine DLL(Delphi) übergeben werden wie angewiesen?

C++ Anwendung..
Code:
void SetupBassVis()
{
   // TEMP: Temporarily load a plugin

   //////////////////////////////////////////////////////////////////////////
   // ----------------------------------------------------\/
   BASSVIS_KIND_T pluginKind = lastVisParam.Kind = BASSVISKIND_SONIQUE;

   BOOL success = BASSVIS_Init(pluginKind, hWnd);
   RECT wndRect;
   if (success)
   {
      GetWindowRect(hWnd, &wndRect);
      exec.Left = 0;
      exec.Top = 0;
      exec.Width = wndRect.right - wndRect.left;
      exec.Height = wndRect.bottom - wndRect.top;

      switch (pluginKind)
      {
      case BASSVISKIND_WINAMP:
         {
            BASSVIS_WINAMP_SetStateCallback( BASSVIS_StateCallback );

            exec.Pluginfile = "Plugins\vis_milk.dll";
            exec.AMP_Moduleindex = 0;
            exec.AMP_UseOwnW1 = 1;   // 
            exec.AMP_UseOwnW2 = 1;   //
            break;
         }
      case BASSVISKIND_SONIQUE:
         {
            exec.Pluginfile = "Ball.svp";
            exec.SON_ConfigFile = "vis.ini";
            exec.SON_UseOpenGl = true;
            exec.SON_ParentHandle = hWnd;
            exec.SON_ViewportHeight = 600;
            exec.SON_ViewportWidth = 800;
            exec.SON_ShowFPS = true;
            exec.SON_ShowPrgBar = true;
            exec.SON_UseCover = true;
            break;
         }
      case BASSVISKIND_WMP:
         {
            // Call FindPlugins once, otherwise ExecutePlugin doesn't work for WMP
            // Alchemy {0AA02E8D-F851-4CB0-9F64-BBA9BE7A983D}
            char *pluginList = BASSVIS_FindPlugins(pluginKind, "{0AA02E8D-F851-4CB0-9F64-BBA9BE7A983D}", 0, ",");
            exec.WMP_PluginIndex = 0;
            exec.WMP_PresetIndex = 0;
            exec.WMP_SrcVisHandle = hWnd;
            exec.WMP_CoInit = BASSVIS_CoInit::COINIT_NONE;
         }
      }

      BASSVIS_ExecutePlugin(&exec, &lastVisParam);

      switch (pluginKind)
      {
      case BASSVISKIND_WINAMP:
         {
            if (lastVisParam.VisHandle != 0)
            {
               // Get HWND from Winamp Dummy Window
               HVIS visWindowHandle = lastVisParam.VisHandle;

               // Send the last active Playlist index to visplugin
               BASSVIS_SetPlayState(&lastVisParam, psSetPlaylistPos, 0);

               // SendMessage Playing Status
               BASSVIS_SetPlayState(&lastVisParam, psPlay);

               // Check IsPlaying
               BASSVIS_SetPlayState(&lastVisParam, psIsPlaying);

               HWND hWndGen = lastVisParam.VisGenWinHandle;
               if (hWndGen != 0 && (exec.AMP_UseOwnW1 || exec.AMP_UseOwnW2))
                  BASSVIS_SetVisPort(&lastVisParam, hWndGen, hWnd, 0, 0, exec.Width, exec.Height);
            }
            break;
         }

      case BASSVISKIND_WMP:
         {
            if (lastVisParam.VisHandle != 0)
            {
               info.Channels = 2;
               info.SampleRate = 44100;
               info.SongTitle = "test";
               BASSVIS_SetInfo(&lastVisParam, &info);

               BASSVIS_SetPlayState(&lastVisParam, psPlay);
               BASSVIS_SetOption(&lastVisParam, BASS_VIS_CONFIG_FFTAMP, 128);   // TODO
            }

            break;
         }
      case BASSVISKIND_SONIQUE:
         BASSVIS_SetOption(&lastVisParam, BASS_SONIQUEVIS_CONFIG_RENDERTIMING, 25);
         BASSVIS_SetOption(&lastVisParam, BASS_SONIQUEVIS_CONFIG_USESLOWFADE, 1);
         BASSVIS_SetOption(&lastVisParam, BASS_SONIQUEVIS_CONFIG_SLOWFADE, 3);
         break;
      }

      if (hStream != 0)
         BASSVIS_RenderChannel(&lastVisParam, hStream, false);
   }
}
Code:
typedef struct {
    char* Pluginfile;           // path to Plugin kind
    DWORD AMP_UseOwnW1;         // flags for Winamp (ownHDC)
    DWORD AMP_UseOwnW2;         // flags for Winamp (ownHDCW2)
    DWORD AMP_Moduleindex;      // Modul-index for Winamp
    BOOL AMP_UseFakeWindow;    // Create a own Window for WindowMessages
    HWND SON_ParentHandle;     // Parent Windowhandle
    char* SON_ConfigFile;       // path to configfile Sonique
    BOOL SON_UseOpenGl;        // Use OpenGL instead of GDI
    int  SON_ViewportWidth;      // Stretch Width
    int  SON_ViewportHeight;     // Stretch Height  
    bool SON_ShowPrgBar;        // Show Progressbar
    bool SON_ShowFPS;           // ShowFPS
    bool SON_UseCover;          // Show Cover
    int  WMP_PluginIndex;      // Pluginindex für WMP;
    int  WMP_PresetIndex;      // Presetindex für WMP;
    HWND WMP_SrcVisHandle;     // ContainerVisHandle für WMP;
      BASSVIS_CoInit WMP_CoInit;
    HWND BB_ParentHandle;      // Parent Windowhandle
    BOOL BB_ShowFPS;           // Show FPS
    BOOL BB_ShowPrgBar;        // Show Progressbar
    HDC  AIMP_PaintHandle;     // Painthandle für Aimp2
    int  Width;                // SrcWindow width
    int  Height;               // SrcWindow height
    int  Left;                 // SrcWindow left
    int  Top;                  // SrcWindow top
} BASSVIS_EXEC;
Beispiel: Oben im Code das erste..
Code:
case BASSVISKIND_SONIQUE:
Wenn ich hier die Parameter festlege und an meine Delphi DLL übergebe werden diese falsch übergeben.
Es scheint so das die Struct in C++ mit der in Delphi nicht übereinstimmt (Ist aber die gleiche vom Aufbau her).

Delphi-Quellcode:
  PBASSVIS_EXEC = ^TBASSVIS_EXEC;
  TBASSVIS_EXEC = record
    Pluginfile : PAnsiChar; // Dateiname des Plugins
                                       // für Sonique, Winamp, BassBox
    AMP_UseOwnW1 : DWORD; // Flag für Winamp (ownHDC)
    AMP_UseOwnW2 : DWORD; // Flag für Winamp (ownHDCW2)
    AMP_Moduleindex : DWORD; // Modul-index für Winamp
    AMP_UseFakeWindow : BOOL; // Create a own Window for WindowMessages
    SON_ParentHandle : HWND; // Parent Windowhandle
    SON_ConfigFile : PAnsiChar; // Dateiname der Konfiguration für Sonique
    SON_UseOpenGL : BOOL; // Use OpenGL instead of GDI
    SON_ViewportWidth : integer; // Stretch Width
    SON_ViewportHeight : integer; // Stretch Height
    SON_ShowPrgBar : BOOL; // Progressbar anzeigen
    SON_ShowFPS : BOOL; // Frames pro Sekunde anzeigen
    SON_UseCover : BOOL; // Cover anzeigen
    WMP_PluginIndex : integer; // Pluginindex
    WMP_PresetIndex : integer; // Presetindex
    WMP_SrcVisHandle : HWND; // Parent Windowhandle
    WMP_CoInit : TBASSVIS_CoInit;
    BB_ParentHandle : HWND; // Parent Windowhandle
    BB_ShowFPS : BOOL; // Frames pro Sekunde anzeigen
    BB_ShowPrgBar : BOOL; // Progressbar anzeigen
    AIMP_PaintHandle : HDC; // Painthandle für Aimp2
    Width : integer; // Fensterbreite
    Height : integer; // Fensterhöhe
    Left : integer; // Left
    Top : integer; // Top
  end;
Hab es schon mit Packed Record versucht macht aber keinen unterschied.

Code:
BASSVIS_ExecutePlugin(&exec, &lastVisParam);
lastVisParam soll dann die Handles der Plugins enthalten bzw. zurückgeben.

VB, Delphi, C#, VB.NET funktioniert soweit alles.
Es muss also ein Problem bei der Übersetzung des Header File für meine DLL vorliegen.
Hab sie mal angehängt.


gruss

Geändert von EWeiss (11. Jul 2019 um 16:02 Uhr)
  Mit Zitat antworten Zitat