-
Notifications
You must be signed in to change notification settings - Fork 168
/
samplefmt_go16.go
56 lines (42 loc) · 1.05 KB
/
samplefmt_go16.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// +build go1.6,!go1.12
package gmf
/*
#cgo pkg-config: libavutil
#include "libavutil/samplefmt.h"
*/
import "C"
import (
"errors"
"fmt"
"unsafe"
)
//
// Unfinished.
//
type SampleFormat int
type Sample struct {
data **C.uint8_t
linesize *int
format SampleFormat
CgoMemoryManage
}
func NewSample(nbSamples, nbChannels int, format SampleFormat) error {
panic("This stuff is unfinished.")
this := &Sample{format: format}
if ret := int(C.av_samples_alloc_array_and_samples(
&this.data,
(*_Ctype_int)(unsafe.Pointer(&this.linesize)),
C.int(nbChannels), C.int(nbSamples), int32(format), 0)); ret < 0 {
return errors.New(fmt.Sprintf("Unable to allocate array and samples: %v", AvError(ret)))
}
return nil
}
func (this *Sample) SampleRealloc(nbSamples, nbChannels int) error {
if ret := int(C.av_samples_alloc(
this.data,
(*_Ctype_int)(unsafe.Pointer(&this.linesize)),
C.int(nbChannels), C.int(nbSamples), int32(this.format), 0)); ret < 0 {
return errors.New(fmt.Sprintf("Unable to allocate samples: %v", AvError(ret)))
}
return nil
}