@@ -23,17 +23,37 @@ instance Storable ErrorCode where
2323 peek p = ErrorCode <$> peek (castPtr p)
2424 poke p = poke (castPtr p) . unErrorCode
2525
26- -- | A mapping of Haskell definitions of error codes to C counterparts.
27- #{enum ErrorCode, ErrorCode
28- , opus_ok = OPUS_OK
29- , opus_bad_arg = OPUS_BAD_ARG
30- , opus_buffer_too_small = OPUS_BUFFER_TOO_SMALL
31- , opus_internal_error = OPUS_INTERNAL_ERROR
32- , opus_invalid_packet = OPUS_INVALID_PACKET
33- , opus_unimplemented = OPUS_UNIMPLEMENTED
34- , opus_invalid_state = OPUS_INVALID_STATE
35- , opus_alloc_fail = OPUS_ALLOC_FAIL
36- }
26+ -- | libopus error: No error.
27+ opus_ok :: ErrorCode
28+ opus_ok = ErrorCode (# const OPUS_OK )
29+
30+ -- | libopus error: One or more invalid/out of range arguments.
31+ opus_bad_arg :: ErrorCode
32+ opus_bad_arg = ErrorCode (# const OPUS_BAD_ARG )
33+
34+ -- | libopus error: Not enough bytes allocated in the buffer.
35+ opus_buffer_too_small :: ErrorCode
36+ opus_buffer_too_small = ErrorCode (# const OPUS_BUFFER_TOO_SMALL )
37+
38+ -- | libopus error: An internal error was detected.
39+ opus_internal_error :: ErrorCode
40+ opus_internal_error = ErrorCode (# const OPUS_INTERNAL_ERROR )
41+
42+ -- | libopus error: The compressed data passed is corrupted.
43+ opus_invalid_packet :: ErrorCode
44+ opus_invalid_packet = ErrorCode (# const OPUS_INVALID_PACKET )
45+
46+ -- | libopus error: Invalid/unsupported request number.
47+ opus_unimplemented :: ErrorCode
48+ opus_unimplemented = ErrorCode (# const OPUS_UNIMPLEMENTED )
49+
50+ -- | libopus error: An encoder or decoder structure is invalid or already freed.
51+ opus_invalid_state :: ErrorCode
52+ opus_invalid_state = ErrorCode (# const OPUS_INVALID_STATE )
53+
54+ -- | libopus error: Memory allocation has failed.
55+ opus_alloc_fail :: ErrorCode
56+ opus_alloc_fail = ErrorCode (# const OPUS_ALLOC_FAIL )
3757
3858-- | Coding mode for the Opus encoder, represented as an int.
3959newtype CodingMode = CodingMode { unCodingMode :: CInt }
@@ -47,12 +67,19 @@ instance Show CodingMode where
4767 | app_lowdelay == a = " lowdelay coding"
4868 | otherwise = " unknown coding"
4969
50- -- | A mapping of Haskell definitions of coding modes to C counterparts.
51- #{enum CodingMode, CodingMode
52- , app_voip = OPUS_APPLICATION_VOIP
53- , app_audio = OPUS_APPLICATION_AUDIO
54- , app_lowdelay = OPUS_APPLICATION_RESTRICTED_LOWDELAY
55- }
70+ -- | Best for most VoIP/videoconference applications where listening quality and
71+ -- intelligibility matter most.
72+ app_voip :: CodingMode
73+ app_voip = CodingMode (# const OPUS_APPLICATION_VOIP )
74+
75+ -- | Best for broadcast/high-fidelity application where the decoded audio should
76+ -- be as close as possible to the input.
77+ app_audio :: CodingMode
78+ app_audio = CodingMode (# const OPUS_APPLICATION_AUDIO )
79+
80+ -- | Only use when lowest-achievable latency is what matters most.
81+ app_lowdelay :: CodingMode
82+ app_lowdelay = CodingMode (# const OPUS_APPLICATION_RESTRICTED_LOWDELAY )
5683
5784-- | Sampling rate for the Opus encoder, represented as an int.
5885newtype SamplingRate = SamplingRate { unSamplingRate :: Int }
0 commit comments