2
0
mirror of synced 2025-02-22 14:28:14 +00:00

exp/audio: APIs should not use Context pointer type

This CL is a followup of CL/11315 where it is suggested to remove
Context pointer types from the signatures.

Change-Id: Ice68bfabad0e345f7d93102257a99402be8760b5
Reviewed-on: https://go-review.googlesource.com/11560
Reviewed-by: Nigel Tao <nigeltao@golang.org>
This commit is contained in:
Burcu Dogan 2015-06-26 10:31:44 -07:00
parent d06bbc53e4
commit 383ad68fc0
2 changed files with 11 additions and 12 deletions

View File

@ -54,27 +54,25 @@ func OpenDevice() error {
}
// CreateContext creates a new context.
func CreateContext() (*Context, error) {
func CreateContext() (Context, error) {
ctx := alcCreateContext(device, nil)
if ctx == nil {
return nil, errors.New("al: cannot create a new context")
return Context{}, errors.New("al: cannot create a new context")
}
return &Context{ptr: ctx}, nil
return Context{ptr: ctx}, nil
}
// Destroy destroys the context and frees the underlying resources.
// The current context cannot be destroyed. Use MakeContextCurrent
// to make a new context current or use nil.
func (c *Context) Destroy() {
func (c Context) Destroy() {
alcDestroyContext(c.ptr)
}
// MakeContextCurrent makes the given context current. The current
// context can be nil.
func MakeContextCurrent(c *Context) bool {
if c == nil {
return alcMakeContextCurrent(nil)
}
// MakeContextCurrent makes the given context current. Calls to
// MakeContextCurrent can accept a zero value Context to allow
// a program not to have an active current context.
func MakeContextCurrent(c Context) bool {
return alcMakeContextCurrent(c.ptr)
}

View File

@ -104,7 +104,7 @@ var (
mu sync.Mutex // guards ctx
// ctx is the shared al.Context used by multiple Player instances.
ctx *al.Context
ctx al.Context
)
type track struct {
@ -170,9 +170,10 @@ func createContext() error {
mu.Lock()
defer mu.Unlock()
if ctx != nil {
if ctx != (al.Context{}) {
return nil
}
var err error
ctx, err = al.CreateContext()
if err != nil {