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
|
|
|
|
|
2015-07-05 19:28:08 +00:00
|
|
|
package opus
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
/*
|
2019-08-13 21:31:57 +00:00
|
|
|
#cgo pkg-config: opus
|
2017-02-28 00:56:11 +00:00
|
|
|
#include <opus.h>
|
2015-07-05 19:28:08 +00:00
|
|
|
*/
|
|
|
|
import "C"
|
|
|
|
|
2016-12-29 11:58:57 +00:00
|
|
|
type Error int
|
2016-10-10 13:18:10 +00:00
|
|
|
|
2016-12-29 11:58:57 +00:00
|
|
|
var _ error = Error(0)
|
2016-10-10 13:18:10 +00:00
|
|
|
|
|
|
|
// Libopus errors
|
2018-03-11 18:45:21 +00:00
|
|
|
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)
|
2016-12-29 11:58:57 +00:00
|
|
|
)
|
|
|
|
|
2016-10-10 13:18:10 +00:00
|
|
|
// Error string (in human readable format) for libopus errors.
|
2016-12-29 11:58:57 +00:00
|
|
|
func (e Error) Error() string {
|
2016-10-10 13:18:10 +00:00
|
|
|
return fmt.Sprintf("opus: %s", C.GoString(C.opus_strerror(C.int(e))))
|
|
|
|
}
|