winmm waveOutGetDevCaps channels count

  • Thread starter Thread starter -tE
  • Start date Start date
T

-tE

Guest
Hey guys.

I am working on splitting my devices into single or mono channels. Trouble is I can't get an accurate result from the channels variable in the structure. I was using a preset size of 64 to get the name, but it must not be big enough to get the last components of the structure. However, when I use code (Marshal.Sizeof(my structure)) I get a number that can't be correct. Here is the code snips.

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)>
Public Structure WAVEDEVINFO
''' <summary>Manufacturer identifier for the device driver for the device. Manufacturer identifiers are defined in Manufacturer and Product Identifiers.</summary>
Public wMid As Short
''' <summary>Product identifier for the device. Product identifiers are defined in Manufacturer and Product Identifiers.</summary>
Public wPid As Short
''' <summary>Version number of the device driver for the device. The high-order byte is the major version number, and the low-order byte is the minor version number.</summary>
Public vDriverVersion As Integer
''' <summary>Product name in a null-terminated string.</summary>
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=64)> Public szPname As String
''' <summary>Standard formats that are supported. Can be a combination of the WaveFormats enumeration.</summary>
Public dwFormats As WaveFormats
''' <summary>Number specifying whether the device supports mono (1) or stereo (2) output.</summary>
Public wChannels As Short
''' <summary>Reserved for packing.</summary>
Public wReserved1 As UShort
''' <summary>Optional functionality supported by the device. The following values are defined</summary>
Public dwSupport As WaveCapSupportFlags
End Structure




<DllImport("winmm.dll", EntryPoint:="waveInGetDevCaps")>
Public Shared Function waveInGetDevCaps(ByVal uDeviceID As Integer, ByRef lpWaveInCaps As WAVEDEVINFO, ByVal cbWaveInCaps As Integer) As Integer
End Function




Public Shared wInInfo As WAVEDEVINFO

Public Sub Button_click()

Dim f as integer = 0

retVal = waveInGetDevCaps(f, wInInfo, 64)


' tried '
' retVal = waveInGetDevCaps(f, wInInfo, Marshal.SizeOf(wInInfo)) '

Dim N as String = wInInfo.szPname

' this is not getting the value right '
Dim NumOfCh as Integer = wInInfo.wChannels

End Sub




Any ideas??

Continue reading...
 
Back
Top