Support more than 8 channels, set audio application
This commit is contained in:
parent
6cc027f24d
commit
afe0cd7874
|
@ -11,6 +11,7 @@
|
|||
#include <opusfile.h>
|
||||
#include <opusenc.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// Defined in Go. Uses the same signature as Go, no need for proxy function.
|
||||
int go_readcallback(void *p, unsigned char *buf, int nbytes);
|
||||
|
@ -65,6 +66,12 @@ bridge_encoder_set_dtx(OggOpusEnc *st, opus_int32 use_dtx)
|
|||
return ope_encoder_ctl(st, OPUS_SET_DTX(use_dtx));
|
||||
}
|
||||
|
||||
int
|
||||
bridge_encoder_set_application(OggOpusEnc *st, opus_int32 application)
|
||||
{
|
||||
return ope_encoder_ctl(st, OPUS_SET_APPLICATION(application));
|
||||
}
|
||||
|
||||
int
|
||||
bridge_encoder_get_dtx(OggOpusEnc *st, opus_int32 *dtx)
|
||||
{
|
||||
|
|
|
@ -56,6 +56,8 @@ bridge_encoder_set_packet_loss_perc(OggOpusEnc *st, opus_int32 loss_perc);
|
|||
int
|
||||
bridge_encoder_get_packet_loss_perc(OggOpusEnc *st, opus_int32 *loss_perc);
|
||||
|
||||
int
|
||||
bridge_encoder_set_application(OggOpusEnc *st, opus_int32 application);
|
||||
|
||||
OpusEncCallbacks * my_write_callbacks();
|
||||
|
||||
|
@ -131,7 +133,9 @@ func (enc *Encoder) Init(sampleRate int, channels int, application Application,
|
|||
enc.handle = cgo.NewHandle(enc)
|
||||
|
||||
var errno C.int
|
||||
if channels > 2 {
|
||||
if channels > 8 {
|
||||
enc.p = C.ope_encoder_create_callbacks(C.my_write_callbacks(), unsafe.Pointer(&enc.handle), C.my_empty_comment(), C.opus_int32(sampleRate), C.int(channels), C.int(255), &errno)
|
||||
} else if channels > 2 {
|
||||
enc.p = C.ope_encoder_create_callbacks(C.my_write_callbacks(), unsafe.Pointer(&enc.handle), C.my_empty_comment(), C.opus_int32(sampleRate), C.int(channels), C.int(1), &errno)
|
||||
} else {
|
||||
enc.p = C.ope_encoder_create_callbacks(C.my_write_callbacks(), unsafe.Pointer(&enc.handle), C.my_empty_comment(), C.opus_int32(sampleRate), C.int(channels), C.int(0), &errno)
|
||||
|
@ -140,6 +144,7 @@ func (enc *Encoder) Init(sampleRate int, channels int, application Application,
|
|||
if errno != 0 {
|
||||
return Error(int(errno))
|
||||
}
|
||||
C.bridge_encoder_set_application(enc.p, C.int(application))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue