Esempio n. 1
0
// New creates and initializes a new VLC instance with the given parameters.
// Returns nil and a possible error if no instance could be created.
func New(argv []string) (i *Instance, err error) {
	cstr := make([]*C.char, len(argv))

	for i := range cstr {
		cstr[i] = C.CString(argv[i])
	}

	if c := C.libvlc_new(C.int(len(argv)), *(***C.char)(unsafe.Pointer(&cstr))); c != nil {
		i = &Instance{c}
	} else {
		err = checkError()
	}

	for i := range cstr {
		C.free(unsafe.Pointer(cstr[i]))
	}
	return
}
Esempio n. 2
0
func Init(args ...string) error {
	if instance != nil {
		return nil
	}

	argc := len(args)
	argv := make([]*C.char, argc)

	for i, arg := range args {
		argv[i] = C.CString(arg)
	}
	defer func() {
		for i := range argv {
			C.free(unsafe.Pointer(argv[i]))
		}
	}()

	instance = C.libvlc_new(C.int(argc), *(***C.char)(unsafe.Pointer(&argv)))
	if instance == nil {
		return getError()
	}

	return nil
}
Esempio n. 3
0
// New creates a new instance of libVLC.
func New() (*VLC, error) {
	vlc := &VLC{}
	vlc.instance = C.libvlc_new(0, nil)
	return vlc, LastError()
}