|
|
|
@ -23,40 +23,55 @@ func main() {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
playback_device := infos[0]
|
|
|
|
|
var playback_device *malgo.DeviceInfo = nil
|
|
|
|
|
for _, info := range infos {
|
|
|
|
|
if info.IsDefault != 0 {
|
|
|
|
|
playback_device = info
|
|
|
|
|
break
|
|
|
|
|
full, err := ctx.DeviceInfo(malgo.Playback, info.ID, malgo.Shared)
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
playback_device = &full
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if playback_device == nil {
|
|
|
|
|
panic("No default playback device")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
infos, err = ctx.Devices(malgo.Capture)
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
capture_device := infos[0]
|
|
|
|
|
var capture_device *malgo.DeviceInfo = nil
|
|
|
|
|
for _, info := range infos {
|
|
|
|
|
if info.IsDefault != 0 {
|
|
|
|
|
capture_device = info
|
|
|
|
|
full, err := ctx.DeviceInfo(malgo.Capture, info.ID, malgo.Shared)
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
capture_device = &full
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if capture_device == nil {
|
|
|
|
|
panic("No default capture device")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inDeviceConfig := malgo.DefaultDeviceConfig(malgo.Capture)
|
|
|
|
|
inDeviceConfig.Capture.Format = malgo.FormatF32
|
|
|
|
|
inDeviceConfig.Capture.Format = capture_device.Formats[0].Format
|
|
|
|
|
inDeviceConfig.Capture.Channels = 1
|
|
|
|
|
inDeviceConfig.Capture.DeviceID = capture_device.ID.Pointer()
|
|
|
|
|
inDeviceConfig.SampleRate = 44100
|
|
|
|
|
inDeviceConfig.SampleRate = capture_device.Formats[0].SampleRate
|
|
|
|
|
inDeviceConfig.PeriodSizeInFrames = 100
|
|
|
|
|
inDeviceConfig.Alsa.NoMMap = 1
|
|
|
|
|
inDeviceConfig.Capture.ShareMode = malgo.Shared
|
|
|
|
|
|
|
|
|
|
outDeviceConfig := malgo.DefaultDeviceConfig(malgo.Playback)
|
|
|
|
|
outDeviceConfig.Playback.Format = malgo.FormatF32
|
|
|
|
|
outDeviceConfig.Playback.Format = playback_device.Formats[0].Format
|
|
|
|
|
outDeviceConfig.Playback.Channels = 1
|
|
|
|
|
outDeviceConfig.Playback.DeviceID = playback_device.ID.Pointer()
|
|
|
|
|
outDeviceConfig.SampleRate = 44100
|
|
|
|
|
outDeviceConfig.SampleRate = playback_device.Formats[0].SampleRate
|
|
|
|
|
outDeviceConfig.PeriodSizeInFrames = 100
|
|
|
|
|
outDeviceConfig.Alsa.NoMMap = 1
|
|
|
|
|
outDeviceConfig.Playback.ShareMode = malgo.Shared
|
|
|
|
@ -75,7 +90,7 @@ func main() {
|
|
|
|
|
Data: onSendFrames,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fmt.Printf("Creating playback device %s\n", playback_device)
|
|
|
|
|
fmt.Printf("Creating playback device %+v\n", playback_device)
|
|
|
|
|
outDevice, err := malgo.InitDevice(ctx.Context, outDeviceConfig, playbackCallbacks)
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
@ -104,7 +119,7 @@ func main() {
|
|
|
|
|
Data: onRecvFrames,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fmt.Printf("Creating capture device %s\n", capture_device)
|
|
|
|
|
fmt.Printf("Creating capture device %+v\n", capture_device)
|
|
|
|
|
inDevice, err := malgo.InitDevice(ctx.Context, inDeviceConfig, captureCallbacks)
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|