AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Projekte TAudioVolume Komponente incl. System Mixer
Thema durchsuchen
Ansicht
Themen-Optionen

TAudioVolume Komponente incl. System Mixer

Ein Thema von EWeiss · begonnen am 6. Mai 2018 · letzter Beitrag vom 24. Jul 2019
 
EWeiss
(Gast)

n/a Beiträge
 
#31

AW: TAudioVolume Komponente incl. System Mixer

  Alt 16. Mai 2018, 16:24
Hälst du denn die Instanz davon irgendwo oder wird die bei jeden Aufruf überschrieben?
Ist das eine der Methoden, der man eine IMMDevice-Instanz hineingibt?
So dass immer wieder neu GetSessionEnumerator aufgerufen wird?

Vergleiche mal mein Beispielprogramm wenn man GetSessionEnumerator auskommentiert.

Wenn auskommentiert: Kein OnSessionCreated. Wenn einkommentiert: OnSessionCreated wird befeuert!
Es ist diese.. und sie wird überschrieben wenn ein neues Control erstellt wird.
Unregistriert und neu registriert für das aktuelle Device.

Delphi-Quellcode:
function TAudioVolume.SetupDefaultAudioEndpoint(Device_Enumerator: IMMDeviceEnumerator): boolean;
var
  HR: HResult;
  MDevice: IMMDevice;
  hnsRequestedDuration: REFERENCE_TIME;
  pwfx: PWAVEFORMATEX;

begin
  Result := false;

  try
    // Get default audio endpoint device with the specified data-flow direction (eRender or eCapture)
    // and device role.
    HR := Device_Enumerator.GetDefaultAudioEndpoint(eRender, eMultimedia, MDevice);
    if HR <> S_OK then
      raise Exception.Create('Error : Unable to get DefaultAudioEndpoint Device');

    FDefaultDevice := GetDeviceInfo(MDevice);
    Device := MDevice;

    // Get the session manager for the endpoint device.
    HR := Device.Activate(IID_IAudioSessionManager, CLSCTX_INPROC_SERVER, nil, IUnknown
        (SessionManager));
    if HR <> S_OK then
      raise Exception.Create('Error : Unable to get AudioSessionManager Interface');

    // **** Get the IChannelAudioVolume interface :
    HR := Device.Activate(IID_IAudioClient, CLSCTX_ALL, nil, IUnknown(AudioClient));
    if HR <> S_OK then
      raise Exception.Create('Error : Unable to get AudioClient Interface');

    hnsRequestedDuration := REFTIMES_PER_SEC;
    HR := AudioClient.GetMixFormat(pwfx);
    if HR <> S_OK then
      raise Exception.Create(
        'Error : Unable to retrieves the stream format that the audio engine uses');

    HR := AudioClient.Initialize(AUDCLNT_SHAREMODE_SHARED, 0, hnsRequestedDuration, 0, pwfx, nil);
    if HR <> S_OK then
      raise Exception.Create('Error : Unable to initialize AudioClient Interface');

    HR := AudioClient.GetService(IID_IChannelAudioVolume, IUnknown(ChannelAudioVolume));
    if HR <> S_OK then
      raise Exception.Create('Error : Unable to get ChannelAudioVolume Interface');

    // get SimpleAudioVolume
    HR := SessionManager.GetSimpleAudioVolume(nil, 0, SimpleAudioVolume);
    if HR <> S_OK then
      raise Exception.Create('Error : Unable to get SimpleAudioVolume Interface');

    // Get the control interface for the process-specific audio session.
    HR := SessionManager.GetAudioSessionControl(nil, false, SessionControl);
    if HR <> S_OK then
      raise Exception.Create('Error : Unable to get AudioSessionControl');

    // Register IAudioSessionEvents interface to receive notifications when session events occur.
    HR := SessionControl.RegisterAudioSessionNotification(self);
    if HR <> S_OK then
      raise Exception.Create('Error : Unable to Register Session Notification Event');

    // We can get session enumerator if we use Windows 7 or newer system.
    if (Win32MajorVersion > 6) or ((Win32MajorVersion = 6) and (Win32MinorVersion >= 1)) then
    begin
      // Get the session manager2 for the endpoint device.
      HR := Device.Activate(IID_IAudioSessionManager2, CLSCTX_ALL, nil, IUnknown(SessionManager2));
      if HR <> S_OK then
        raise Exception.Create('Error : Unable to get AudioSessionManager2 Interface');

      // Register TAudioSessionNotification to receive a notification when a session is created.
      HR := SessionManager2.RegisterSessionNotification(self);
      if HR <> S_OK then
        raise Exception.Create('Error : Unable to Register Session Notification');

      // Get the session enumerator
      HR := SessionManager2.GetSessionEnumerator(SessionEnumerator);
      if HR <> S_OK then
        raise Exception.Create('Error : Unable to get SessionEnumerator Interface');
    end;

    Result := true;
  finally

  end;
end;
Was ich mir vorstellen könnte das es an der falschen Position initialisiert wird.

gruss
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 05:15 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz