Quantcast
Channel: naudio Work Item Rss Feed
Viewing all articles
Browse latest Browse all 738

Commented Issue: BooleanMixerControl doesn't update the value [11648]

$
0
0
When trying to assign new value to the BooleanMixerControl, I get the exception "InvalidParameter calling mixerSetControlDetails".

I had a look into the source of BooleanMixerControl(.cs - 1.3 beta Oct. 10 2009), and it seems that the Set part of Value property actually doesn't pass the new value to the mixerControlDetails - it's commented out:

public bool Value
{
get
{
GetControlDetails(); // make sure we have the latest value
return (boolDetails.fValue == 1);
}
set
{
//GetControlDetails();
//MixerInterop.MIXERCONTROLDETAILS_BOOLEAN boolDetails = (MixerInterop.MIXERCONTROLDETAILS_BOOLEAN) Marshal.PtrToStructure(mixerControlDetails.paDetails,typeof(MixerInterop.MIXERCONTROLDETAILS_BOOLEAN));
//boolDetails.fValue = (value) ? 1 : 0;
// TODO: pin the memory
MmException.Try(MixerInterop.mixerSetControlDetails(mixerHandle, ref mixerControlDetails, MixerFlags.Value | mixerHandleType), "mixerSetControlDetails");
}
}
Anyways, if the value doesn't get passed, where is the invalid paramer exception coming from?
I tried to fix this and marshal the value the same way it is done in the signed mixer control:

set
{
boolDetails.fValue = Convert.ToInt32(value);
Marshal.StructureToPtr(boolDetails, mixerControlDetails.paDetails, false);
MmException.Try(MixerInterop.mixerSetControlDetails(mixerHandle, ref mixerControlDetails, MixerFlags.Value | mixerHandleType), "mixerSetControlDetails");
Marshal.FreeHGlobal(mixerControlDetails.paDetails);
}

But I still get the InvalidParameter exception. I think I'll tinker with this a bit more, but I would like to know if there was something which made you comment the code out in the original version before geetting too deep into the problem (I.e. if there were some underlying problems I can't know about at this level).
Comments: public bool Value { get { GetControlDetails(); // make sure we have the latest value return (boolDetails.fValue == 1); } set { GetControlDetails(); MixerInterop.MIXERCONTROLDETAILS_BOOLEAN m = new MixerInterop.MIXERCONTROLDETAILS_BOOLEAN(); m.fValue = Convert.ToInt32(value); IntPtr buffer = Marshal.AllocCoTaskMem(Marshal.SizeOf(m)); Marshal.StructureToPtr(m, buffer, false); mixerControlDetails.paDetails = buffer; MmException.Try(MixerInterop.mixerSetControlDetails(mixerHandle, ref mixerControlDetails, MixerFlags.Value | mixerHandleType), "mixerSetControlDetails"); } } }

Viewing all articles
Browse latest Browse all 738

Trending Articles