-
-
Save 0xDiddi/37dfdf0e393740a0b30ba189861f8f98 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <Windows.h> | |
#include <mmsystem.h> | |
int main() { | |
unsigned int numDevices, i; | |
MMRESULT result; | |
LPWAVEOUTCAPSW caps = malloc(sizeof(WAVEOUTCAPSW)); | |
memset(caps, 0, sizeof(WAVEOUTCAPSW)); | |
numDevices = waveOutGetNumDevs(); | |
for (i = 0; i < numDevices; i++) { | |
result = waveOutGetDevCapsW(i, caps, sizeof(WAVEOUTCAPSW)); | |
printf("getCaps() result: %d\n", result); | |
printf("getCaps() name: %S\n", caps->szPname); | |
} | |
printf("Device count: %d\n", numDevices); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dev_count := waveOutDeviceCount() | |
for i := 0; i < dev_count; i++ { | |
caps, err := waveOutGetDeviceCaps(i) | |
_ = caps // just to suppress unused error | |
fmt.Printf("err: %s.\n", err) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... | |
var procWaveOutGetNumDevs = winmm.NewProc("waveOutGetNumDevs") | |
var procWaveOutGetDevCaps = winmm.NewProc("waveOutGetDevCapsW") | |
// ... | |
type waveoutcaps struct { | |
wMid uint16 | |
wPid uint16 | |
vDriverVersion uint32 | |
szPname [32]uint16 | |
dwFormats uint32 | |
wChannels uint16 | |
wReserved1 uint16 | |
dwSupport uint32 | |
} | |
// ... | |
func waveOutDeviceCount() int { | |
r, _, _ := procWaveOutGetNumDevs.Call() | |
return int(r) | |
} | |
func waveOutGetDeviceCaps(id int) (*waveoutcaps, error) { | |
var caps *waveoutcaps | |
r, _, e := procWaveOutGetDevCaps.Call(uintptr(id), uintptr(unsafe.Pointer(caps)), unsafe.Sizeof(waveoutcaps{})) | |
if e.(windows.Errno) != 0 { | |
return nil, &winmmError{ | |
fname: "waveOutGetDeviceCaps", | |
errno: e.(windows.Errno), | |
} | |
} | |
if mmresult(r) != mmsyserrNoerror { | |
return nil, &winmmError{ | |
fname: "waveOutGetDeviceCaps", | |
mmresult: mmresult(r), | |
} | |
} | |
return caps, nil | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment