示例#1
0
AudioInput::~AudioInput() {
	bRunning = false;
	wait();
	speex_bits_destroy(&sbBits);
	speex_encoder_destroy(esEncState);
	mumble_drft_clear(&fftTable);
	jitter_buffer_destroy(jb);

	if (sppPreprocess)
		speex_preprocess_state_destroy(sppPreprocess);
	if (sesEcho)
		speex_echo_state_destroy(sesEcho);

	if (srsMic)
		speex_resampler_destroy(srsMic);
	if (srsEcho)
		speex_resampler_destroy(srsEcho);

	delete [] psMic;
	delete [] psSpeaker;
	delete [] psClean;

	if (pfMicInput)
		delete [] pfMicInput;
	if (pfEchoInput)
		delete [] pfEchoInput;
	if (pfOutput)
		delete [] pfOutput;
}
示例#2
0
AudioInput::~AudioInput() {
	bRunning = false;
	wait();

	if (ceEncoder) {
		cCodec->celt_encoder_destroy(ceEncoder);
	} else if (esSpeex) {
		speex_bits_destroy(&sbBits);
		speex_encoder_destroy(esSpeex);
	}

	foreach(short *buf, qlEchoFrames)
		delete [] buf;

	if (sppPreprocess)
		speex_preprocess_state_destroy(sppPreprocess);
	if (sesEcho)
		speex_echo_state_destroy(sesEcho);

	if (srsMic)
		speex_resampler_destroy(srsMic);
	if (srsEcho)
		speex_resampler_destroy(srsEcho);

	delete [] psMic;
	delete [] psClean;
	delete [] psSpeaker;

	delete [] pfMicInput;
	delete [] pfEchoInput;
	delete [] pfOutput;
}
示例#3
0
AudioInput::~AudioInput() {
	bRunning = false;
	wait();

#ifdef USE_OPUS
	if (opusState)
		opus_encoder_destroy(opusState);
#endif

	if (ceEncoder) {
		cCodec->celt_encoder_destroy(ceEncoder);
	}

	foreach(short *buf, qlEchoFrames)
		delete [] buf;

	if (sppPreprocess)
		speex_preprocess_state_destroy(sppPreprocess);
	if (sesEcho)
		speex_echo_state_destroy(sesEcho);

	if (srsMic)
		speex_resampler_destroy(srsMic);
	if (srsEcho)
		speex_resampler_destroy(srsEcho);

	delete [] psMic;
	delete [] psClean;
	delete [] psSpeaker;

	delete [] pfMicInput;
	delete [] pfEchoInput;
	delete [] pfOutput;
}
示例#4
0
COggVorbisFileHelper::~COggVorbisFileHelper()
{
	stop();
	bStopDecoding = true;
	while(mDecThread.thread_status == CThread::TRUNNING) 
	{
		s3eDebugTracePrintf("waiting decoding thread terminating\n");
		s3eDeviceYield(10);
	}

	if(mDecBuffer != NULL)
	{
		delete mDecBuffer;
		mDecBuffer = NULL;
	}
	//cleanup();

	if(res_contR)	speex_resampler_destroy(res_contR);
	if(res_contL)	speex_resampler_destroy(res_contL);

	delete [] iFilterBufferL;
	delete [] iFilterBufferR;
	delete [] dFilterCoefficients;

	delete [] m_outL;
	delete [] m_outR;

	/*if(nStatus != OH_NAN) ov_clear(&vf);*/
	
}
示例#5
0
RtpAudioStream::~RtpAudioStream()
{
    for (int i = 0; i < rtp_packets_.size(); i++) {
        rtp_packet_t *rtp_packet = rtp_packets_[i];
        g_free(rtp_packet->info);
        g_free(rtp_packet->payload_data);
        g_free(rtp_packet);
    }
    g_hash_table_destroy(decoders_hash_);
    if (audio_resampler_) speex_resampler_destroy (audio_resampler_);
    speex_resampler_destroy (visual_resampler_);
}
示例#6
0
void kill_filter_audio(Filter_Audio *f_a)
{
    if (!f_a) {
        return;
    }

    WebRtcNsx_Free(f_a->noise_sup_x);
    WebRtcAgc_Free(f_a->gain_control);
    WebRtcAec_Free(f_a->echo_cancellation);
    WebRtcVad_Free(f_a->Vad_handle);
    speex_resampler_destroy(f_a->upsampler);
    speex_resampler_destroy(f_a->downsampler);
    speex_resampler_destroy(f_a->downsampler_echo);
    free(f_a);
}
示例#7
0
文件: Resampler.cpp 项目: taqu/opus
 void Resampler::destroyResampler()
 {
     if(NULL != resampler_){
         speex_resampler_destroy(resampler_);
         resampler_ = NULL;
     }
 }
static void
AudioQualityImprovement_free(AudioQualityImprovement *aqi)
{
    /* mutex */
    Mutex_free(aqi->mutex);
    /* preprocess */
    if (aqi->preprocess)
        speex_preprocess_state_destroy(aqi->preprocess);
    /* echo */
    if (aqi->echo)
        speex_echo_state_destroy(aqi->echo);
    /* out */
    if (aqi->out)
        free(aqi->out);
    /* play */
    if (aqi->play)
        free(aqi->play);
    /* resampler */
    if (aqi->resampler)
        speex_resampler_destroy(aqi->resampler);
    /* stringID */
    free(aqi->stringID);

    free(aqi);
}
示例#9
0
Channel::~Channel()
{
	if (resampler) {
		speex_resampler_destroy(resampler);
		resampler = 0;
	}
}
示例#10
0
static void Close (vlc_object_t *obj)
{
    filter_t *filter = (filter_t *)obj;
    SpeexResamplerState *st = (SpeexResamplerState *)filter->p_sys;

    speex_resampler_destroy (st);
}
示例#11
0
AudioOutputSample::~AudioOutputSample() {
	if (srs)
		speex_resampler_destroy(srs);

	delete sfHandle;
	sfHandle = NULL;
}
示例#12
0
JNIEXPORT void JNICALL Native_NATIVE(speex_1resampler_1destroy)
	(JNIEnv *env, jclass that, jlong arg0)
{
	Native_NATIVE_ENTER(env, that, Native_speex_1resampler_1destroy_FUNC);
	speex_resampler_destroy((SpeexResamplerState *)(intptr_t)arg0);
	Native_NATIVE_EXIT(env, that, Native_speex_1resampler_1destroy_FUNC);
}
示例#13
0
void rl_resampler_destroy( rl_resampler_t* resampler )
{
  if ( resampler != (rl_resampler_t*)&passthrough )
  {
    speex_resampler_destroy( (SpeexResamplerState*)resampler );
  }
}
示例#14
0
static void ebur128_destroy_resampler(ebur128_state* st) {
  free(st->d->resampler_buffer_input);
  st->d->resampler_buffer_input = NULL;
  free(st->d->resampler_buffer_output);
  st->d->resampler_buffer_output = NULL;
  speex_resampler_destroy(st->d->resampler);
  st->d->resampler = NULL;
}
示例#15
0
	bool ResamplePCM(uint32 NumChannels, const TArray<uint8>& InBuffer, uint32 InSampleRate, TArray<uint8>& OutBuffer, uint32 OutSampleRate) const
	{
		// Initialize resampler to convert to desired rate for Opus
		int32 err = 0;
		SpeexResamplerState* resampler = speex_resampler_init(NumChannels, InSampleRate, OutSampleRate, SPEEX_RESAMPLER_QUALITY_DESKTOP, &err);
		if (err != RESAMPLER_ERR_SUCCESS)
		{
			speex_resampler_destroy(resampler);
			return false;
		}

		// Calculate extra space required for sample rate
		const uint32 SampleStride = SAMPLE_SIZE * NumChannels;
		const float Duration = (float)InBuffer.Num() / (InSampleRate * SampleStride);
		const int32 SafeCopySize = (Duration + 1) * OutSampleRate * SampleStride;
		OutBuffer.Empty(SafeCopySize);
		OutBuffer.AddUninitialized(SafeCopySize);
		uint32 InSamples = InBuffer.Num() / SampleStride;
		uint32 OutSamples = OutBuffer.Num() / SampleStride;

		// Do resampling and check results
		if (NumChannels == 1)
		{
			err = speex_resampler_process_int(resampler, 0, (const short*)(InBuffer.GetData()), &InSamples, (short*)(OutBuffer.GetData()), &OutSamples);
		}
		else
		{
			err = speex_resampler_process_interleaved_int(resampler, (const short*)(InBuffer.GetData()), &InSamples, (short*)(OutBuffer.GetData()), &OutSamples);
		}

		speex_resampler_destroy(resampler);
		if (err != RESAMPLER_ERR_SUCCESS)
		{
			return false;
		}

		// reduce the size of Out Buffer if more space than necessary was allocated
		const int32 WrittenBytes = (int32)(OutSamples * SampleStride);
		if (WrittenBytes < OutBuffer.Num())
		{
			OutBuffer.SetNum(WrittenBytes, true);
		}

		return true;
	}
示例#16
0
void AudioInput::initializeMixer() {
	int err;

	if (srsMic)
		speex_resampler_destroy(srsMic);
	if (srsEcho)
		speex_resampler_destroy(srsEcho);
	if (pfMicInput)
		delete [] pfMicInput;
	if (pfEchoInput)
		delete [] pfEchoInput;
	if (pfOutput)
		delete [] pfOutput;

	if (iMicFreq != iSampleRate)
		srsMic = speex_resampler_init(1, iMicFreq, iSampleRate, 3, &err);

	iMicLength = (iFrameSize * iMicFreq) / iSampleRate;

	pfMicInput = new float[iMicLength];
	pfOutput = new float[iFrameSize * max(1U,iEchoChannels)];

	if (iEchoChannels > 0) {
		bEchoMulti = g_struct.s.bEchoMulti;
		if (iEchoFreq != iSampleRate)
			srsEcho = speex_resampler_init(bEchoMulti ? iEchoChannels : 1, iEchoFreq, iSampleRate, 3, &err);
		iEchoLength = (iFrameSize * iEchoFreq) / iSampleRate;
		iEchoMCLength = bEchoMulti ? iEchoLength * iEchoChannels : iEchoLength;
		iEchoFrameSize = bEchoMulti ? iFrameSize * iEchoChannels : iFrameSize;
		pfEchoInput = new float[iEchoMCLength];
	} else {
		srsEcho = NULL;
		pfEchoInput = NULL;
	}

	imfMic = chooseMixer(iMicChannels, eMicFormat);
	imfEcho = chooseMixer(iEchoChannels, eEchoFormat);

	iMicSampleSize = static_cast<int>(iMicChannels * ((eMicFormat == SampleFloat) ? sizeof(float) : sizeof(short)));
	iEchoSampleSize = static_cast<int>(iEchoChannels * ((eEchoFormat == SampleFloat) ? sizeof(float) : sizeof(short)));

	bResetProcessor = true;

	Trace("AudioInput: Initialized mixer for %d channel %d hz mic and %d channel %d hz echo", iMicChannels, iMicFreq, iEchoChannels, iEchoFreq);
}
示例#17
0
/*
 * close resampler.
 * @param resampler
 */
void ttLibC_SpeexdspResampler_close(ttLibC_SpeexdspResampler **resampler) {
	ttLibC_SpeexdspResampler_ *target = (ttLibC_SpeexdspResampler_ *)*resampler;
	if(target == NULL) {
		return;
	}
	speex_resampler_destroy(target->resampler);
	ttLibC_free(target);
	*resampler = NULL;
}
示例#18
0
AudioResampler::~AudioResampler() {
	if (conversion_state) {
	#if defined(HAVE_LIBSPEEXDSP)
			speex_resampler_destroy(conversion_state);
	#elif defined(HAVE_LIBSAMPLERATE)
			src_delete(conversion_state);
	#endif
	}
}
示例#19
0
AudioInput::~AudioInput() {

	g_pWaveFile.Close();

	bRunning = false;

	if (ceEncoder) {
		cCodec->encoder_destroy(ceEncoder);
	} else if (esSpeex) {
		speex_bits_destroy(&sbBits);
		speex_encoder_destroy(esSpeex);
	}

//	mumble_drft_clear(&fftTable);

	std::deque<short*>::iterator dit;
	for (dit = qlEchoFrames.begin(); dit != qlEchoFrames.end();)
	{
		delete [] *dit;
		dit = qlEchoFrames.erase(dit);
	}

	if (sppPreprocess)
		speex_preprocess_state_destroy(sppPreprocess);
	if (sesEcho)
		speex_echo_state_destroy(sesEcho);

	if (srsMic)
		speex_resampler_destroy(srsMic);
	if (srsEcho)
		speex_resampler_destroy(srsEcho);

	delete [] psMic;
	delete [] psClean;
	if (psSpeaker)
		delete [] psSpeaker;

	if (pfMicInput)
		delete [] pfMicInput;
	if (pfEchoInput)
		delete [] pfEchoInput;
	if (pfOutput)
		delete [] pfOutput;
}
示例#20
0
static void resample_process_ms2(MSFilter *obj) {
    ResampleData *dt=(ResampleData*)obj->data;
    mblk_t *m;

    if (dt->output_rate==dt->input_rate) {
        while((m=ms_queue_get(obj->inputs[0]))!=NULL) {
            ms_queue_put(obj->outputs[0],m);
        }
        return;
    }
    ms_filter_lock(obj);
    if (dt->handle!=NULL) {
        unsigned int inrate=0, outrate=0;
        speex_resampler_get_rate(dt->handle,&inrate,&outrate);
        if (inrate!=dt->input_rate || outrate!=dt->output_rate) {
            speex_resampler_destroy(dt->handle);
            dt->handle=0;
        }
    }
    if (dt->handle==NULL) {
        int err=0;
        dt->handle=speex_resampler_init(dt->nchannels, dt->input_rate, dt->output_rate, SPEEX_RESAMPLER_QUALITY_VOIP, &err);
    }


    while((m=ms_queue_get(obj->inputs[0]))!=NULL) {
        unsigned int inlen=(m->b_wptr-m->b_rptr)/(2*dt->nchannels);
        unsigned int outlen=((inlen*dt->output_rate)/dt->input_rate)+1;
        unsigned int inlen_orig=inlen;
        mblk_t *om=allocb(outlen*2*dt->nchannels,0);
        if (dt->nchannels==1) {
            speex_resampler_process_int(dt->handle,
                                        0,
                                        (int16_t*)m->b_rptr,
                                        &inlen,
                                        (int16_t*)om->b_wptr,
                                        &outlen);
        } else {
            speex_resampler_process_interleaved_int(dt->handle,
                                                    (int16_t*)m->b_rptr,
                                                    &inlen,
                                                    (int16_t*)om->b_wptr,
                                                    &outlen);
        }
        if (inlen_orig!=inlen) {
            ms_error("Bug in resampler ! only %u samples consumed instead of %u, out=%u",
                     inlen,inlen_orig,outlen);
        }
        om->b_wptr+=outlen*2*dt->nchannels;
        mblk_set_timestamp_info(om,dt->ts);
        dt->ts+=outlen;
        ms_queue_put(obj->outputs[0],om);
        freemsg(m);
    }
    ms_filter_unlock(obj);
}
示例#21
0
AudioDecoderSpeex::~AudioDecoderSpeex()
{
    speex_bits_destroy(&_speex_bits);

    speex_decoder_destroy(_speex_dec_state);

#ifdef RESAMPLING_SPEEX
    speex_resampler_destroy(_resampler);
#endif
}
示例#22
0
OpusTrackEncoder::~OpusTrackEncoder()
{
  if (mEncoder) {
    opus_encoder_destroy(mEncoder);
  }
  if (mResampler) {
    speex_resampler_destroy(mResampler);
    mResampler = nullptr;
  }
}
示例#23
0
Channel::~Channel()
{
	if (resampler) {
		speex_resampler_destroy(resampler);
		resampler = 0;
	}
	if (deletesourceondone) {
		delete source;
	}
}
示例#24
0
void AudioInput::initializeMixer() {
	int err;

	if (srsMic)
		speex_resampler_destroy(srsMic);
	if (srsEcho)
		speex_resampler_destroy(srsEcho);
	if (pfMicInput)
		delete [] pfMicInput;
	if (pfEchoInput)
		delete [] pfEchoInput;
	if (pfOutput)
		delete [] pfOutput;

	if (iMicFreq != SAMPLE_RATE)
		srsMic = speex_resampler_init(1, iMicFreq, SAMPLE_RATE, 3, &err);

	iMicLength = (iFrameSize * iMicFreq) / SAMPLE_RATE;

	pfMicInput = new float[iMicLength];
	pfOutput = new float[iFrameSize];

	if (iEchoChannels > 0) {
		if (iEchoFreq != SAMPLE_RATE)
			srsEcho = speex_resampler_init(1, iEchoFreq, SAMPLE_RATE, 3, &err);
		iEchoLength = (iFrameSize * iEchoFreq) / SAMPLE_RATE;
		pfEchoInput = new float[iEchoLength];
	} else {
		srsEcho = NULL;
		pfEchoInput = NULL;
	}

	imfMic = chooseMixer(iMicChannels, eMicFormat);
	imfEcho = chooseMixer(iEchoChannels, eEchoFormat);

	iMicSampleSize = iMicChannels * ((eMicFormat == SampleFloat) ? sizeof(float) : sizeof(short));
	iEchoSampleSize = iEchoChannels * ((eEchoFormat == SampleFloat) ? sizeof(float) : sizeof(short));

	bResetProcessor = true;

	qWarning("AudioInput: Initialized mixer for %d channel %d hz mic and %d channel %d hz echo", iMicChannels, iMicFreq, iEchoChannels, iEchoFreq);
}
示例#25
0
 ~AudioChannelImpl() override
 {
     if (_resampler != nullptr)
     {
         speex_resampler_destroy(_resampler);
         _resampler = nullptr;
     }
     if (_deletesourceondone)
     {
         delete _source;
     }
 }
示例#26
0
static int set_nchannels(MSFilter *f, void *arg) {
    ResampleData *dt=(ResampleData*)f->data;
    int chans=*(int*)arg;
    ms_filter_lock(f);
    if (dt->nchannels!=chans && dt->handle!=NULL) {
        speex_resampler_destroy(dt->handle);
        dt->handle=NULL;
    }
    dt->nchannels=*(int*)arg;
    ms_filter_unlock(f);
    return 0;
}
示例#27
0
static void destructor(void *arg)
{
	struct audec_state *ads = arg;

	if (ads->resampler)
		speex_resampler_destroy(ads->resampler);

	mpg123_close(ads->dec);
	mpg123_delete(ads->dec);
#ifdef DEBUG
	debug("MPA dec destroyed\n");
#endif
}
示例#28
0
void cras_fmt_conv_destroy(struct cras_fmt_conv *conv)
{
    unsigned i;
    if (conv->ch_conv_mtx)
        cras_channel_conv_matrix_destroy(conv->ch_conv_mtx,
                                         conv->out_fmt.num_channels);
    if (conv->speex_state)
        speex_resampler_destroy(conv->speex_state);
    if (conv->resampler)
        linear_resampler_destroy(conv->resampler);
    for (i = 0; i < MAX_NUM_CONVERTERS - 1; i++)
        free(conv->tmp_bufs[i]);
    free(conv);
}
void release_resampler(struct resampler_itfe *resampler)
{
    struct resampler *rsmp = (struct resampler *)resampler;

    if (rsmp == NULL) {
        return;
    }

    free(rsmp->in_buf);

    if (rsmp->speex_resampler != NULL) {
        speex_resampler_destroy(rsmp->speex_resampler);
    }
    free(rsmp);
}
示例#30
0
AudioOutputSpeech::~AudioOutputSpeech() {
	if (cdDecoder) {
		cCodec->celt_decoder_destroy(cdDecoder);
	} else if (dsSpeex) {
		speex_bits_destroy(&sbBits);
		speex_decoder_destroy(dsSpeex);
	}

	if (srs)
		speex_resampler_destroy(srs);

	jitter_buffer_destroy(jbJitter);

	delete [] fFadeIn;
	delete [] fFadeOut;
}