public MixerLine(IntPtr mixerHandle, int destinationIndex, int sourceIndex, MixerFlags mixerHandleType) { this.mixerHandle = mixerHandle; this.mixerHandleType = mixerHandleType; this.mixerLine = default(MixerInterop.MIXERLINE); this.mixerLine.cbStruct = Marshal.SizeOf(this.mixerLine); this.mixerLine.dwDestination = destinationIndex; this.mixerLine.dwSource = sourceIndex; MmException.Try(MixerInterop.mixerGetLineInfo(mixerHandle, ref this.mixerLine, mixerHandleType | MixerFlags.ListText), "mixerGetLineInfo"); }
public Mixer(int mixerIndex) { if (mixerIndex < 0 || mixerIndex >= Mixer.NumberOfDevices) { throw new ArgumentOutOfRangeException("mixerID"); } this.caps = default(MixerInterop.MIXERCAPS); MmException.Try(MixerInterop.mixerGetDevCaps((IntPtr)mixerIndex, ref this.caps, Marshal.SizeOf(this.caps)), "mixerGetDevCaps"); this.mixerHandle = (IntPtr)mixerIndex; this.mixerHandleType = MixerFlags.Mixer; }
public static MixerControl GetMixerControl(IntPtr mixerHandle, int nLineID, int controlId, int nChannels, MixerFlags mixerFlags) { MixerInterop.MIXERLINECONTROLS mIXERLINECONTROLS = default(MixerInterop.MIXERLINECONTROLS); MixerInterop.MIXERCONTROL mIXERCONTROL = default(MixerInterop.MIXERCONTROL); IntPtr intPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf(mIXERCONTROL)); mIXERLINECONTROLS.cbStruct = Marshal.SizeOf(mIXERLINECONTROLS); mIXERLINECONTROLS.cControls = 1; mIXERLINECONTROLS.dwControlID = controlId; mIXERLINECONTROLS.cbmxctrl = Marshal.SizeOf(mIXERCONTROL); mIXERLINECONTROLS.pamxctrl = intPtr; mIXERLINECONTROLS.dwLineID = nLineID; MmResult mmResult = MixerInterop.mixerGetLineControls(mixerHandle, ref mIXERLINECONTROLS, MixerFlags.ListText | mixerFlags); if (mmResult != MmResult.NoError) { Marshal.FreeCoTaskMem(intPtr); throw new MmException(mmResult, "mixerGetLineControls"); } mIXERCONTROL = (MixerInterop.MIXERCONTROL)Marshal.PtrToStructure(mIXERLINECONTROLS.pamxctrl, typeof(MixerInterop.MIXERCONTROL)); Marshal.FreeCoTaskMem(intPtr); if (MixerControl.IsControlBoolean(mIXERCONTROL.dwControlType)) { return(new BooleanMixerControl(mIXERCONTROL, mixerHandle, mixerFlags, nChannels)); } if (MixerControl.IsControlSigned(mIXERCONTROL.dwControlType)) { return(new SignedMixerControl(mIXERCONTROL, mixerHandle, mixerFlags, nChannels)); } if (MixerControl.IsControlUnsigned(mIXERCONTROL.dwControlType)) { return(new UnsignedMixerControl(mIXERCONTROL, mixerHandle, mixerFlags, nChannels)); } if (MixerControl.IsControlListText(mIXERCONTROL.dwControlType)) { return(new ListTextMixerControl(mIXERCONTROL, mixerHandle, mixerFlags, nChannels)); } if (MixerControl.IsControlCustom(mIXERCONTROL.dwControlType)) { return(new CustomMixerControl(mIXERCONTROL, mixerHandle, mixerFlags, nChannels)); } throw new InvalidOperationException(string.Format("Unknown mixer control type {0}", mIXERCONTROL.dwControlType)); }
protected void GetControlDetails() { this.mixerControlDetails.cbStruct = Marshal.SizeOf(this.mixerControlDetails); this.mixerControlDetails.dwControlID = this.mixerControl.dwControlID; if (this.IsCustom) { this.mixerControlDetails.cChannels = 0; } else if ((this.mixerControl.fdwControl & 1u) != 0u) { this.mixerControlDetails.cChannels = 1; } else { this.mixerControlDetails.cChannels = this.nChannels; } if ((this.mixerControl.fdwControl & 2u) != 0u) { this.mixerControlDetails.hwndOwner = (IntPtr)((long)((ulong)this.mixerControl.cMultipleItems)); } else if (this.IsCustom) { this.mixerControlDetails.hwndOwner = IntPtr.Zero; } else { this.mixerControlDetails.hwndOwner = IntPtr.Zero; } if (this.IsBoolean) { this.mixerControlDetails.cbDetails = Marshal.SizeOf(default(MixerInterop.MIXERCONTROLDETAILS_BOOLEAN)); } else if (this.IsListText) { this.mixerControlDetails.cbDetails = Marshal.SizeOf(default(MixerInterop.MIXERCONTROLDETAILS_LISTTEXT)); } else if (this.IsSigned) { this.mixerControlDetails.cbDetails = Marshal.SizeOf(default(MixerInterop.MIXERCONTROLDETAILS_SIGNED)); } else if (this.IsUnsigned) { this.mixerControlDetails.cbDetails = Marshal.SizeOf(default(MixerInterop.MIXERCONTROLDETAILS_UNSIGNED)); } else { this.mixerControlDetails.cbDetails = this.mixerControl.Metrics.customData; } int num = this.mixerControlDetails.cbDetails * this.mixerControlDetails.cChannels; if ((this.mixerControl.fdwControl & 2u) != 0u) { num *= (int)this.mixerControl.cMultipleItems; } IntPtr intPtr = Marshal.AllocCoTaskMem(num); this.mixerControlDetails.paDetails = intPtr; MmResult mmResult = MixerInterop.mixerGetControlDetails(this.mixerHandle, ref this.mixerControlDetails, MixerFlags.Mixer | this.mixerHandleType); if (mmResult == MmResult.NoError) { this.GetDetails(this.mixerControlDetails.paDetails); } Marshal.FreeCoTaskMem(intPtr); if (mmResult != MmResult.NoError) { throw new MmException(mmResult, "mixerGetControlDetails"); } }