go-pus/errors.go

37 lines
824 B
Go
Raw Permalink Normal View History

2020-07-09 16:22:12 +00:00
// Copyright © Go Opus Authors (see AUTHORS file)
2016-08-14 22:33:23 +00:00
//
// License for use of this code is detailed in the LICENSE file
package opus
import (
"fmt"
)
/*
#cgo pkg-config: opus
#include <opus.h>
*/
import "C"
type Error int
var _ error = Error(0)
// Libopus errors
const (
ErrOK = Error(C.OPUS_OK)
ErrBadArg = Error(C.OPUS_BAD_ARG)
ErrBufferTooSmall = Error(C.OPUS_BUFFER_TOO_SMALL)
ErrInternalError = Error(C.OPUS_INTERNAL_ERROR)
ErrInvalidPacket = Error(C.OPUS_INVALID_PACKET)
ErrUnimplemented = Error(C.OPUS_UNIMPLEMENTED)
ErrInvalidState = Error(C.OPUS_INVALID_STATE)
ErrAllocFail = Error(C.OPUS_ALLOC_FAIL)
)
// Error string (in human readable format) for libopus errors.
func (e Error) Error() string {
return fmt.Sprintf("opus: %s", C.GoString(C.opus_strerror(C.int(e))))
}