-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathao_test.go
61 lines (50 loc) · 929 Bytes
/
ao_test.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
57
58
59
60
61
// This file is subject to a BSD license.
// Its contents can be found in the enclosed LICENSE file.
package ao
import (
"crypto/rand"
"testing"
)
// null is a special driver for testing.
// It does not generate actual sound.
const driverName = "null"
var (
options = map[string]string{
"debug": "",
"verbose": "",
}
format = &SampleFormat{
ByteOrder: EndianNative,
Bits: 16,
Rate: 44100,
Channels: 2,
}
)
func Test(t *testing.T) {
Init()
defer Shutdown()
driver := DriverByName(driverName)
if driver < 0 {
t.Errorf("No driver named %q", driverName)
return
}
dev, err := OpenLive(driver, format, options)
if err != nil {
t.Error(err)
return
}
defer dev.Close()
var buf [16 * 1024]byte
for i := 0; i < 32; i++ {
n, err := rand.Read(buf[:])
if err != nil {
t.Error(err)
return
}
err = dev.Play(buf[:n])
if err != nil {
t.Error(err)
return
}
}
}