func (m *ChannelMap) InitExtend(channels uint, mapping ChannelMapDef) {
	cmap := &C.pa_channel_map{}
	C.pa_channel_map_init_extend(cmap, C.unsigned(channels), C.pa_channel_map_def_t(mapping))
	m.fromC(cmap)
}
ChannelMap.InitExtend initializes the ChannelMap using the given mapping
and number of channels.

If there is no default channel map known for the given number of channels
and mapping, then it will synthesize a mapping based on a known mapping
with fewer channels, and fill up the rest with AUX0...AUX31 channels.
package pulse
import (
	"errors"
	"fmt"
	"strings"
	"unsafe"
)
import "C"
type ChannelPosition C.pa_channel_position_t
const (
	CHANNEL_POSITION_INVALID ChannelPosition = C.PA_CHANNEL_POSITION_INVALID
	CHANNEL_POSITION_MONO    ChannelPosition = C.PA_CHANNEL_POSITION_MONO
	CHANNEL_POSITION_FRONT_LEFT   ChannelPosition = C.PA_CHANNEL_POSITION_FRONT_LEFT
	CHANNEL_POSITION_FRONT_RIGHT  ChannelPosition = C.PA_CHANNEL_POSITION_FRONT_RIGHT
	CHANNEL_POSITION_FRONT_CENTER ChannelPosition = C.PA_CHANNEL_POSITION_FRONT_CENTER
	CHANNEL_POSITION_LEFT   ChannelPosition = C.PA_CHANNEL_POSITION_LEFT
	CHANNEL_POSITION_RIGHT  ChannelPosition = C.PA_CHANNEL_POSITION_RIGHT
	CHANNEL_POSITION_CENTER ChannelPosition = C.PA_CHANNEL_POSITION_CENTER
	CHANNEL_POSITION_REAR_CENTER ChannelPosition = C.PA_CHANNEL_POSITION_REAR_CENTER
	CHANNEL_POSITION_REAR_LEFT   ChannelPosition = C.PA_CHANNEL_POSITION_REAR_LEFT
	CHANNEL_POSITION_REAR_RIGHT  ChannelPosition = C.PA_CHANNEL_POSITION_REAR_RIGHT
	CHANNEL_POSITION_LFE       ChannelPosition = C.PA_CHANNEL_POSITION_LFE
	CHANNEL_POSITION_SUBWOOFER ChannelPosition = C.PA_CHANNEL_POSITION_SUBWOOFER
	CHANNEL_POSITION_FRONT_LEFT_OF_CENTER  ChannelPosition = C.PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER
	CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER ChannelPosition = C.PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER
	CHANNEL_POSITION_SIDE_LEFT  ChannelPosition = C.PA_CHANNEL_POSITION_SIDE_LEFT
	CHANNEL_POSITION_SIDE_RIGHT ChannelPosition = C.PA_CHANNEL_POSITION_SIDE_RIGHT
	CHANNEL_POSITION_AUX0  ChannelPosition = C.PA_CHANNEL_POSITION_AUX0
	CHANNEL_POSITION_AUX1  ChannelPosition = C.PA_CHANNEL_POSITION_AUX1
	CHANNEL_POSITION_AUX2  ChannelPosition = C.PA_CHANNEL_POSITION_AUX2
	CHANNEL_POSITION_AUX3  ChannelPosition = C.PA_CHANNEL_POSITION_AUX3
	CHANNEL_POSITION_AUX4  ChannelPosition = C.PA_CHANNEL_POSITION_AUX4
	CHANNEL_POSITION_AUX5  ChannelPosition = C.PA_CHANNEL_POSITION_AUX5
	CHANNEL_POSITION_AUX6  ChannelPosition = C.PA_CHANNEL_POSITION_AUX6
	CHANNEL_POSITION_AUX7  ChannelPosition = C.PA_CHANNEL_POSITION_AUX7
	CHANNEL_POSITION_AUX8  ChannelPosition = C.PA_CHANNEL_POSITION_AUX8
	CHANNEL_POSITION_AUX9  ChannelPosition = C.PA_CHANNEL_POSITION_AUX9
	CHANNEL_POSITION_AUX10 ChannelPosition = C.PA_CHANNEL_POSITION_AUX10
	CHANNEL_POSITION_AUX11 ChannelPosition = C.PA_CHANNEL_POSITION_AUX11
	CHANNEL_POSITION_AUX12 ChannelPosition = C.PA_CHANNEL_POSITION_AUX12
	CHANNEL_POSITION_AUX13 ChannelPosition = C.PA_CHANNEL_POSITION_AUX13
	CHANNEL_POSITION_AUX14 ChannelPosition = C.PA_CHANNEL_POSITION_AUX14
	CHANNEL_POSITION_AUX15 ChannelPosition = C.PA_CHANNEL_POSITION_AUX15
	CHANNEL_POSITION_AUX16 ChannelPosition = C.PA_CHANNEL_POSITION_AUX16
	CHANNEL_POSITION_AUX17 ChannelPosition = C.PA_CHANNEL_POSITION_AUX17
	CHANNEL_POSITION_AUX18 ChannelPosition = C.PA_CHANNEL_POSITION_AUX18
	CHANNEL_POSITION_AUX19 ChannelPosition = C.PA_CHANNEL_POSITION_AUX19
	CHANNEL_POSITION_AUX20 ChannelPosition = C.PA_CHANNEL_POSITION_AUX20
	CHANNEL_POSITION_AUX21 ChannelPosition = C.PA_CHANNEL_POSITION_AUX21
	CHANNEL_POSITION_AUX22 ChannelPosition = C.PA_CHANNEL_POSITION_AUX22
	CHANNEL_POSITION_AUX23 ChannelPosition = C.PA_CHANNEL_POSITION_AUX23
	CHANNEL_POSITION_AUX24 ChannelPosition = C.PA_CHANNEL_POSITION_AUX24
	CHANNEL_POSITION_AUX25 ChannelPosition = C.PA_CHANNEL_POSITION_AUX25
	CHANNEL_POSITION_AUX26 ChannelPosition = C.PA_CHANNEL_POSITION_AUX26
	CHANNEL_POSITION_AUX27 ChannelPosition = C.PA_CHANNEL_POSITION_AUX27
	CHANNEL_POSITION_AUX28 ChannelPosition = C.PA_CHANNEL_POSITION_AUX28
	CHANNEL_POSITION_AUX29 ChannelPosition = C.PA_CHANNEL_POSITION_AUX29
	CHANNEL_POSITION_AUX30 ChannelPosition = C.PA_CHANNEL_POSITION_AUX30
	CHANNEL_POSITION_AUX31 ChannelPosition = C.PA_CHANNEL_POSITION_AUX31
	CHANNEL_POSITION_TOP_CENTER ChannelPosition = C.PA_CHANNEL_POSITION_TOP_CENTER
	CHANNEL_POSITION_TOP_FRONT_LEFT   ChannelPosition = C.PA_CHANNEL_POSITION_TOP_FRONT_LEFT
	CHANNEL_POSITION_TOP_FRONT_RIGHT  ChannelPosition = C.PA_CHANNEL_POSITION_TOP_FRONT_RIGHT
	CHANNEL_POSITION_TOP_FRONT_CENTER ChannelPosition = C.PA_CHANNEL_POSITION_TOP_FRONT_CENTER
	CHANNEL_POSITION_TOP_REAR_LEFT   ChannelPosition = C.PA_CHANNEL_POSITION_TOP_REAR_LEFT
	CHANNEL_POSITION_TOP_REAR_RIGHT  ChannelPosition = C.PA_CHANNEL_POSITION_TOP_REAR_RIGHT
	CHANNEL_POSITION_TOP_REAR_CENTER ChannelPosition = C.PA_CHANNEL_POSITION_TOP_REAR_CENTER
	CHANNEL_POSITION_MAX ChannelPosition = C.PA_CHANNEL_POSITION_MAX
)
type ChannelPositionMask uint64
func (p ChannelPosition) Mask() ChannelPositionMask {
	return 1 << uint(p)
}
type ChannelMapDef C.pa_channel_map_def_t
const (
	CHANNEL_MAP_AIFF    ChannelMapDef = C.PA_CHANNEL_MAP_AIFF
	CHANNEL_MAP_ALSA    ChannelMapDef = C.PA_CHANNEL_MAP_ALSA
	CHANNEL_MAP_AUX     ChannelMapDef = C.PA_CHANNEL_MAP_AUX
	CHANNEL_MAP_WAVEEX  ChannelMapDef = C.PA_CHANNEL_MAP_WAVEEX
	CHANNEL_MAP_OSS     ChannelMapDef = C.PA_CHANNEL_MAP_OSS
	CHANNEL_MAP_DEF_MAX ChannelMapDef = C.PA_CHANNEL_MAP_DEF_MAX
	CHANNEL_MAP_DEFAULT ChannelMapDef = C.PA_CHANNEL_MAP_DEFAULT
)
type ChannelMap struct {
	Channels uint8
	Map      [CHANNELS_MAX]ChannelPosition
}
func (m *ChannelMap) fromC(cmap *C.pa_channel_map) {
	m.Channels = uint8(cmap.channels)
	for i := 0; i < CHANNELS_MAX; i++ {
		m.Map[i] = ChannelPosition(cmap._map[i])
	}
}
func (m *ChannelMap) toC() *C.pa_channel_map {
	if m == nil {
		return nil
	}
	cmap := &C.pa_channel_map{}
	cmap.channels = C.uint8_t(m.Channels)
	for i := 0; i < CHANNELS_MAX; i++ {
		cmap._map[i] = C.pa_channel_position_t(m.Map[i])
	}
	return cmap
}
func (m *ChannelMap) Init() {
	m.fromC(C.pa_channel_map_init(m.toC()))
}
func (m *ChannelMap) InitMono() {
	cmap := &C.pa_channel_map{}
	C.pa_channel_map_init_mono(cmap)
	m.fromC(cmap)
}
func (m *ChannelMap) InitStereo() {
	cmap := &C.pa_channel_map{}
	C.pa_channel_map_init_stereo(cmap)
	m.fromC(cmap)
}
func (m *ChannelMap) InitAuto(channels uint, mapping ChannelMapDef) error {
	cmap := &C.pa_channel_map{}
	mapped := C.pa_channel_map_init_auto(cmap, C.unsigned(channels), C.pa_channel_map_def_t(mapping))
	if mapped == nil {
		return fmt.Errorf("Could not map %d channels with ChannelMapDef %v", channels, mapping)
	}
	m.fromC(cmap)
	return nil
}