Beispiel #1
0
// SampleFormat.IsRe returns 1 when the format is reverse endian.
//
// Returns -1 when endianness does not apply to this format.
func (f SampleFormat) IsRe() int {
	// note: C.pa_sample_format_is_re() doesn't seem to work
	if SAMPLE_S16NE == SAMPLE_S16LE {
		return int(C.pa_sample_format_is_be(C.pa_sample_format_t(f)))
	}
	return int(C.pa_sample_format_is_le(C.pa_sample_format_t(f)))
}
Beispiel #2
0
func (self *PulseContext) NewStream(name string, spec *PulseSampleSpec) *PulseStream {
	name_ := C.CString(name)
	st := C.stream_new(self.MainLoop.pa, self.ctx, name_, C.pa_sample_format_t(spec.Format), C.int(spec.Rate), C.int(spec.Channels))
	var retval *PulseStream = nil
	if st != nil {
		retval = &PulseStream{Context: self, st: st}
	}
	C.cfree(unsafe.Pointer(name_))
	return retval
}
Beispiel #3
0
func (spec *SampleSpec) toC() *C.pa_sample_spec {
	if spec == nil {
		return nil
	}
	return &C.pa_sample_spec{
		format:   C.pa_sample_format_t(spec.Format),
		rate:     C.uint32_t(spec.Rate),
		channels: C.uint8_t(spec.Channels),
	}
}
Beispiel #4
0
// SampleFormat.SampleSize returns the size of a single sample in bytes.
func (f SampleFormat) SampleSize() uint {
	return uint(C.pa_sample_size_of_format(C.pa_sample_format_t(f)))
}
Beispiel #5
0
// SampleFormat.IsBe returns 1 when the format is big endian.
//
// Returns -1 when endianness does not apply to this format.
func (f SampleFormat) IsBe() int {
	return int(C.pa_sample_format_is_be(C.pa_sample_format_t(f)))
}
Beispiel #6
0
// SampleFormat.String returns a string describing the format.
func (f SampleFormat) String() string {
	cstr := C.pa_sample_format_to_string(C.pa_sample_format_t(f))
	return C.GoString(cstr)
}