Einzelnen Beitrag anzeigen

EWeiss
(Gast)

n/a Beiträge
 
#53

AW: TAudioVolume Komponente incl. System Mixer

  Alt 10. Mai 2018, 04:53
@Tigü

Habe deinen Vorschlag umgesetzt aber sehe im Moment nicht wirklich irgendeinen Vorteil.
Es geht jetzt mal nur um die Events.

Beispiel:
Vorher!

Delphi-Quellcode:
TAudioEndpointEvents = class(TInterfacedObject, IAudioEndpointVolumeCallback)
  private
    MsgHandle: HWND;
    VolMute: TVolMute;
    EventContext: TGUID;
  public
    function OnNotify(pNotify: PAUDIO_VOLUME_NOTIFICATION_DATA): HResult; stdcall;
    procedure SetMsgHandle(WinHandle: HWND);
  end;

function TAudioEndpointEvents.OnNotify(pNotify: PAUDIO_VOLUME_NOTIFICATION_DATA): HResult; stdcall;
var
  VolumeData: AUDIO_VOLUME_NOTIFICATION_DATA;
begin
  VolumeData := pNotify^;
  VolMute.Volume := VolumeData.fMasterVolume;
  VolMute.Muted := VolumeData.bMuted;
  EventContext := VolumeData.guidEventContext;

  PostMessage(MsgHandle, WM_EndpointVolume, integer(@VolMute), integer(@EventContext));

  Result := S_OK;
end;
Nachher!
Delphi-Quellcode:
  TAudioVolume = class(TWinControl, IAudioSessionEvents, IMMNotificationClient,
    IAudioSessionNotification, IAudioEndpointVolumeCallback)
//...
  public
    function OnNotify(pNotify: PAUDIO_VOLUME_NOTIFICATION_DATA): HResult; stdcall;
Delphi-Quellcode:
function TAudioVolume.OnNotify(pNotify: PAUDIO_VOLUME_NOTIFICATION_DATA): HResult;
var
  VolumeData: AUDIO_VOLUME_NOTIFICATION_DATA;
begin
  VolumeData := pNotify^;
  VolMute.Volume := VolumeData.fMasterVolume;
  VolMute.Muted := VolumeData.bMuted;
  EventContext := VolumeData.guidEventContext;

  PostMessage(MsgHandle, WM_EndpointVolume, integer(@VolMute), integer(@EventContext));

  Result := S_OK;

end;
Wo ist jetzt der Vorteil von deiner <> meiner Auslegung?
Das erschließt sich mir nicht. Sorry

PS:
Hab Foobar 2000 mal installiert.
Und nein wie vorher schon gesagt es wird nie ein Event ausgelöst vom System.

Kein OnSessionCreated
Kein OnSessionDisconnected

gruss

Geändert von EWeiss (10. Mai 2018 um 05:32 Uhr)
  Mit Zitat antworten Zitat