ref: 2c0e6de469bd8345d483399ee52c208f0e3189fe
parent: bc8191a9e7c258f910d8dfed6c682aabdbc40236
parent: 979aca94eb2c5d6bcab6a06c9304b3e1c7521853
author: Jean-Marc Valin <[email protected]>
date: Mon Aug 29 10:22:52 EDT 2011
Merge remote-tracking branch 'jmvalin/master' Conflicts: src/opusdec.c src/opusenc.c
--- a/src/opusdec.c
+++ b/src/opusdec.c
@@ -388,7 +388,7 @@
static OpusMSDecoder *process_header(ogg_packet *op, opus_int32 *rate, int *channels, int *preskip, float *gain, int quiet)
{
- int error;
+ int err;
OpusMSDecoder *st;
OpusHeader header;
unsigned char mapping[256] = {0,1};
@@ -410,7 +410,12 @@
if (!*rate)
*rate = header.input_sample_rate;
*preskip = header.preskip;
- st = opus_multistream_decoder_create(48000, header.channels, 1, header.channels==2 ? 1 : 0, mapping, &error);
+ st = opus_multistream_decoder_create(48000, header.channels, 1, header.channels==2 ? 1 : 0, mapping, &err);
+ if (err != OPUS_OK)
+ {
+ fprintf(stderr, "Cannot create encoder: %s\n", opus_strerror(err));
+ return NULL;
+ }
if (!st)
{
fprintf (stderr, "Decoder initialization failed: %s\n", opus_strerror(error));
--- a/src/opusenc.c
+++ b/src/opusenc.c
@@ -323,6 +323,7 @@
int extra_samples;
int signal = OPUS_SIGNAL_AUTO;
unsigned char mapping[256] = {0, 1};
+ int err;
opus_version = opus_get_version_string();
snprintf(vendor_string, sizeof(vendor_string), "%s\n",opus_version);
@@ -481,7 +482,6 @@
if (rate != 48000)
{
- int err;
fprintf(stderr, "Resampling from %d Hz to %d Hz before encoding\n", rate, 48000);
resampler = speex_resampler_init(chan, rate, 48000, 5, &err);
if (err!=0)
@@ -499,11 +499,11 @@
bytes_per_packet = MAX_FRAME_BYTES;
/*Initialize OPUS encoder*/
- st = opus_multistream_encoder_create(48000, chan, 1, chan==2, mapping, OPUS_APPLICATION_AUDIO, &ret);
- if (!st)
+ st = opus_multistream_encoder_create(48000, chan, 1, chan==2, mapping, OPUS_APPLICATION_AUDIO, &err);
+ if (err != OPUS_OK)
{
- fprintf (stderr, "Failed to create the encoder: %s\n", opus_strerror(ret));
- exit(1);
+ fprintf(stderr, "Cannot create encoder: %s\n", opus_strerror(err));
+ return 1;
}
opus_multistream_encoder_ctl(st, OPUS_SET_SIGNAL(signal));
header.channels = chan;