當前位置: 首頁>>代碼示例>>Golang>>正文


Golang SDL_AudioSpec.channels方法代碼示例

本文整理匯總了Golang中C.SDL_AudioSpec.channels方法的典型用法代碼示例。如果您正苦於以下問題:Golang SDL_AudioSpec.channels方法的具體用法?Golang SDL_AudioSpec.channels怎麽用?Golang SDL_AudioSpec.channels使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在C.SDL_AudioSpec的用法示例。


在下文中一共展示了SDL_AudioSpec.channels方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: OpenAudio

func OpenAudio(desired, obtained_orNil *AudioSpec) int {
	if alreadyOpened {
		panic("more than 1 audio stream currently not supported")
	}

	// copy handle to user-defined callback function, if defined
	// it is perfectly supported to not specify the callback function
	// in that case you will use default SendAudio semantics
	// note that if you specify a callback and use SendAudio, a hangup will instead happen
	// when calling SendAudio

	if nil != desired.UserDefinedCallback {
		userDefinedCallback = desired.UserDefinedCallback
	} else {
		// default playback (16-bit signed)
		userDefinedCallback = DownstreamPlaybackS16
		PlayLoop = make(chan AudioEvent)
	}

	var C_desired, C_obtained *C.SDL_AudioSpec

	C_desired = new(C.SDL_AudioSpec)
	C_desired.freq = C.int(desired.Freq)
	C_desired.format = C.Uint16(desired.Format)
	C_desired.channels = C.Uint8(desired.Channels)
	C_desired.samples = C.Uint16(desired.Samples)
	// there is an unique C callback acting as proxy to the different Go callbacks
	// see streamContext()
	C_desired.callback = C.callback_getCallback()

	if obtained_orNil != nil {
		if desired != obtained_orNil {
			C_obtained = new(C.SDL_AudioSpec)
		} else {
			C_obtained = C_desired
		}
	}

	status := C.SDL_OpenAudio(C_desired, C_obtained)

	if status == 0 {
		alreadyOpened = true
	}

	if obtained_orNil != nil {
		obtained := obtained_orNil

		obtained.Freq = int(C_obtained.freq)
		obtained.Format = uint16(C_obtained.format)
		obtained.Channels = uint8(C_obtained.channels)
		obtained.Samples = uint16(C_obtained.samples)
		obtained.Out_Silence = uint8(C_obtained.silence)
		obtained.Out_Size = uint32(C_obtained.size)
	}

	return int(status)
}
開發者ID:neagix,項目名稱:Go-SDL,代碼行數:57,代碼來源:audio.go

示例2: initAudio

func initAudio() {
	// Init a simple audio setup.
	var spec C.SDL_AudioSpec
	spec.freq = C.int(SamplingRate)
	spec.format = C.AUDIO_S8
	spec.channels = 1
	spec.samples = 512
	spec.userdata = nil
	C.openAudio(&spec)
}
開發者ID:rsaarelm,項目名稱:teratogen,代碼行數:10,代碼來源:audio.go

示例3: Init

func Init() {
	if ok := C.SDL_InitSubSystem(C.SDL_INIT_AUDIO); ok < 0 {
		panic(ok)
	}
	var want C.SDL_AudioSpec
	want.freq = 48000
	want.format = C.AUDIO_S16
	want.channels = 2
	want.callback = (C.SDL_AudioCallback)(unsafe.Pointer(C.audio_callback_go_cgo))
	var have C.SDL_AudioSpec
	if dev = C.SDL_OpenAudioDevice(nil, 0, &want, &have, 0); dev == 0 {
		panic("dev=0")
	}
}
開發者ID:21isgonnabeagoodyear,項目名稱:ggl,代碼行數:14,代碼來源:sdlaudio.go

示例4: OpenAudio

func OpenAudio(desired, obtained *AudioSpec, callback func(*byte, int)) bool {
	var cdesired C.SDL_AudioSpec
	var cobtained C.SDL_AudioSpec
	cdesired.freq = C.int(desired.Freq)
	cdesired.format = C.SDL_AudioFormat(int(desired.Format))
	cdesired.channels = C.Uint8(desired.Channels)
	cdesired.samples = C.Uint16(desired.Samples)
	cdesired.size = C.Uint32(0)
	cdesired.callback = C.go_sdl2_get_callback()
	cdesired.userdata = unsafe.Pointer(&callback)
	ret := C.SDL_OpenAudio(&cdesired, &cobtained)
	if obtained != nil {
		obtained.Freq = int32(cobtained.freq)
		obtained.Format = AudioFormat(int(cobtained.format))
		obtained.Channels = uint8(cobtained.channels)
		obtained.Silence = uint8(cobtained.silence)
		obtained.Samples = uint16(cobtained.samples)
		obtained.Size = uint32(cobtained.size)
	}
	return int(ret) == 0
}
開發者ID:jbondeson,項目名稱:Go-SDL2,代碼行數:21,代碼來源:audio.go

示例5: OpenAudio

func OpenAudio(desired, obtained_orNil *AudioSpec) int {
	var C_desired, C_obtained *C.SDL_AudioSpec

	C_desired = new(C.SDL_AudioSpec)
	C_desired.freq = C.int(desired.Freq)
	C_desired.format = C.Uint16(desired.Format)
	C_desired.channels = C.Uint8(desired.Channels)
	C_desired.samples = C.Uint16(desired.Samples)
	C_desired.callback = C.callback_getCallback()

	if obtained_orNil != nil {
		if desired != obtained_orNil {
			C_obtained = new(C.SDL_AudioSpec)
		} else {
			C_obtained = C_desired
		}
	}

	status := C.SDL_OpenAudio(C_desired, C_obtained)

	if status == 0 {
		mutex.Lock()
		opened++
		mutex.Unlock()
	}

	if obtained_orNil != nil {
		obtained := obtained_orNil

		obtained.Freq = int(C_obtained.freq)
		obtained.Format = uint16(C_obtained.format)
		obtained.Channels = uint8(C_obtained.channels)
		obtained.Samples = uint16(C_obtained.samples)
		obtained.Out_Silence = uint8(C_obtained.silence)
		obtained.Out_Size = uint32(C_obtained.size)
	}

	return int(status)
}
開發者ID:scottferg,項目名稱:Go-SDL,代碼行數:39,代碼來源:audio.go

示例6: OpenAudioDevice

func OpenAudioDevice(device string, iscapture bool, desired, obtained *AudioSpec, allowed_changes bool, callback func(*byte, int)) bool {
	var cdesired C.SDL_AudioSpec
	var cobtained C.SDL_AudioSpec
	cdevice := C.CString(device)
	defer C.free(unsafe.Pointer(cdevice))
	cdesired.freq = C.int(desired.Freq)
	cdesired.format = C.SDL_AudioFormat(int(desired.Format))
	cdesired.channels = C.Uint8(desired.Channels)
	cdesired.samples = C.Uint16(desired.Samples)
	cdesired.size = C.Uint32(0)
	cdesired.callback = C.go_sdl2_get_callback()
	cdesired.userdata = unsafe.Pointer(&callback)
	ret := C.SDL_OpenAudioDevice(cdevice, C.int(bool2int(iscapture)), &cdesired, &cobtained, C.int(bool2int(allowed_changes)))
	if obtained != nil {
		obtained.Freq = int32(cobtained.freq)
		obtained.Format = AudioFormat(int(cobtained.format))
		obtained.Channels = uint8(cobtained.channels)
		obtained.Silence = uint8(cobtained.silence)
		obtained.Samples = uint16(cobtained.samples)
		obtained.Size = uint32(cobtained.size)
	}
	return int(ret) == 0
}
開發者ID:jbondeson,項目名稱:Go-SDL2,代碼行數:23,代碼來源:audio.go


注:本文中的C.SDL_AudioSpec.channels方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。