Ejemplo n.º 1
0
LRESULT CFirstPageDlg::OnMM_WIM_DATA(UINT wParam, LONG lParam) 
{
	// TODO: Add your message handler code here and/or call default
	// Reallocate save buffer memory
	
	//////////////////////////////////////////////////////////////////////////
	
	pNewBuffer = (PBYTE)realloc (pSaveBuffer, dwDataLength +((PWAVEHDR) lParam)->dwBytesRecorded) ;
	
	if (pNewBuffer == NULL)
	{
		waveInClose (hWaveIn) ;
		MessageBeep (MB_ICONEXCLAMATION) ;
		AfxMessageBox(_T("OnMM_WIM_DATA:memory error"));
		return 0;
	}
	
	pSaveBuffer = pNewBuffer ;
	
	CopyMemory (pSaveBuffer + dwDataLength, ((PWAVEHDR) lParam)->lpData,((PWAVEHDR) lParam)->dwBytesRecorded) ;
	
	dwDataLength += ((PWAVEHDR) lParam)->dwBytesRecorded ;
	
	if (!bRecording)
	{
		waveInClose (hWaveIn) ;
		return 0 ;
	}

	waveInAddBuffer (hWaveIn, (PWAVEHDR) lParam, sizeof (WAVEHDR)) ;
	TRACE("done input data\n");
	return 0;

	
}
Ejemplo n.º 2
0
/**
 * Prepare recording. Initialize and acquire recording resources.
 */
static javacall_result init_recording(recorder_handle* hRecord)
{
    WAVEFORMATEX format;

    /* Setup wave in format */
    format.wFormatTag = WAVE_FORMAT_PCM;
    format.cbSize = 0;
    format.wBitsPerSample = 16;
    format.nSamplesPerSec = 22050;
    format.nChannels = 1;
    format.nAvgBytesPerSec = format.nSamplesPerSec * (format.wBitsPerSample/8);
    format.nBlockAlign = format.nChannels;

    /* Open WAV in H/W */
    if (NULL == hRecord->hWAVEIN) {
        MMRESULT mmReturn = 0;
        
        mmReturn = waveInOpen(&hRecord->hWAVEIN, WAVE_MAPPER, &format, 
            (DWORD)waveInProc, (DWORD)hRecord, CALLBACK_FUNCTION);

        if (MMSYSERR_NOERROR != mmReturn) {
            hRecord->hWAVEIN = NULL;
            return JAVACALL_FAIL;
        }
    }

    /* Create WAV file for (temp) storage */
    if (NULL == hRecord->hFile) {
        HMMIO hFile;

        /* Create temp file? If there is no pre-setted name. */
        if (0x0 == hRecord->fileName[0]) {
            GetTempPath(MAX_PATH, hRecord->fileName);
            GetTempFileName(hRecord->fileName, "record", 0, hRecord->fileName);
        }

        if (JAVACALL_SUCCEEDED(create_wav_file(hRecord->fileName, &format, &hFile))) {
            hRecord->hFile = hFile;
        } else {
            waveInClose(hRecord->hWAVEIN);
            hRecord->hWAVEIN = NULL;
            return JAVACALL_FAIL;
        }
    }

    /* Add input buffer */
    if (!JAVACALL_SUCCEEDED(add_input_buffer(hRecord, &format))) {
        waveInClose(hRecord->hWAVEIN);
        close_wav_file(hRecord);
        hRecord->hWAVEIN = NULL;
        return JAVACALL_FAIL;
    }

    return JAVACALL_OK;
}
Ejemplo n.º 3
0
ad_rec_t *
ad_open_sps_bufsize(int32 sps, int32 bufsize_msec)
{
    ad_rec_t *r;
    int32 i, j;
    HWAVEIN h;

    if ((h = wavein_open(sps, sizeof(int16))) == NULL)
        return NULL;

    if ((r = (ad_rec_t *) malloc(sizeof(ad_rec_t))) == NULL) {
        fprintf(stderr, "malloc(%d) failed\n", sizeof(ad_rec_t));
        waveInClose(h);
        return NULL;
    }

    r->n_buf = ((sps * bufsize_msec) / 1000) / WI_BUFSIZE;
    if (r->n_buf < DEFAULT_N_WI_BUF)
        r->n_buf = DEFAULT_N_WI_BUF;
    printf("Allocating %d buffers of %d samples each\n", r->n_buf,
           WI_BUFSIZE);

    if ((r->wi_buf =
         (ad_wbuf_t *) calloc(r->n_buf, sizeof(ad_wbuf_t))) == NULL) {
        fprintf(stderr, "calloc(%d,%d) failed\n", r->n_buf,
                sizeof(ad_wbuf_t));
        free(r);
        waveInClose(h);

        return NULL;
    }
    for (i = 0; i < r->n_buf; i++) {
        if (wavein_alloc_buf(&(r->wi_buf[i]), WI_BUFSIZE) < 0) {
            for (j = 0; j < i; j++)
                wavein_free_buf(&(r->wi_buf[j]));
            free(r->wi_buf);
            free(r);
            waveInClose(h);

            return NULL;
        }
    }

    r->h_wavein = h;
    r->opened = 1;
    r->recording = 0;
    r->curbuf = r->n_buf - 1;   /* current buffer with data for application */
    r->curlen = 0;              /* #samples in curbuf remaining to be consumed */
    r->lastbuf = r->curbuf;
    r->sps = sps;
    r->bps = sizeof(int16);     /* HACK!! Hardwired value for bytes/sec */

    return r;
}
Ejemplo n.º 4
0
/* destructor */
static tsk_object_t* tdav_producer_waveapi_dtor(tsk_object_t * self)
{ 
	tdav_producer_waveapi_t *producer = self;
	if(producer){
		tsk_size_t i;

		/* stop */
		if(producer->started){
			tdav_producer_waveapi_stop(self);
		}

		/* deinit base */
		tdav_producer_audio_deinit(TDAV_PRODUCER_AUDIO(producer));
		/* deinit self */
		for(i = 0; i< sizeof(producer->hWaveHeaders)/sizeof(LPWAVEHDR); i++){
			free_wavehdr(producer, i);
		}
		if(producer->hWaveIn){
			waveInClose(producer->hWaveIn); 
		}
		if(producer->events[0]){
			CloseHandle(producer->events[0]);
		}
		if(producer->events[1]){
			CloseHandle(producer->events[1]);
		}
		DeleteCriticalSection(&producer->cs);
	}

	return self;
}
Ejemplo n.º 5
0
int RecData(int i)
{
  WORD wResult;

  SendInBuffers--;
  if (!StopRecord)
  {
    InFillBuffer(i);
    wResult = waveInAddBuffer(hWaveIn,WaveInBuf[i].lpWaveHdr,sizeof(WAVEHDR));
    if (wResult != 0)
    {
      WaveInFreeAll();
      return 0;
    }
    SendInBuffers++;
  }
  else
  {
    if (!SendInBuffers)
    {
      WaveInFreeAll();
      StopRecord=FALSE;
	  waveInClose(hWaveIn);
    }
  }
  return 1;
}
Ejemplo n.º 6
0
	void CloseDevice()
	{
		MMRESULT mRes=0;
		
		if(m_hWaveIn)
		{
			UnPrepareBuffers();
			mRes=waveInClose(m_hWaveIn);
		}
		if(m_hOPFile)
		{
			mRes=mmioAscend(m_hOPFile, &m_stckOut, 0);
			if(mRes!=MMSYSERR_NOERROR)
			{
				FAIL_M("bad");
			}
			mRes=mmioAscend(m_hOPFile, &m_stckOutRIFF, 0);
			if(mRes!=MMSYSERR_NOERROR)
			{
				FAIL_M("bad");
			}
			mmioClose(m_hOPFile,0);
			m_hOPFile=NULL;
		}
		m_hWaveIn=NULL;
	}
Ejemplo n.º 7
0
static int32 wavein_close (ad_rec_t *r)
{
    int32 i, st;

    /* Unprepare all buffers; multiple unprepares of the same buffer are benign */
    for (i = 0; i < r->n_buf; i++) {
	st = waveInUnprepareHeader(r->h_wavein, r->wi_buf[i].p_whdr, sizeof(WAVEHDR));
	if (st != 0) {
	    wavein_error("waveInUnprepareHeader", st);
	    return -1;
	}
    }
    
    /* Free buffers */
    for (i = 0; i < r->n_buf; i++)
	wavein_free_buf (&(r->wi_buf[i]));
    free (r->wi_buf);
    
    if ((st = waveInClose (r->h_wavein)) != 0) {
    	wavein_error("waveInClose", st);
	return -1;
    }

    free (r);
    
    return 0;
}
Ejemplo n.º 8
0
/**
 * win32ai_close()
 * Terminate recording.
 * This function discards all data that has been sampled but not read.
 * Return 0 if happy, -1 if error.
 */
int win32ai_close(void) {
	MMRESULT res;
	int i;

	// stop device
	res = waveInReset(wavein);
	if (checkWaveInResult(wavein, res, "waveInReset"))
		return -1;

	// wait for buffers to finish and unprepare them all
	for (i = 0; i < WaveBuf_N; ++i) {
		while ((whin[i]->dwFlags & WHDR_DONE) == 0) {
			// buffer not ready, wait, try again
			WaitForSingleObject(whinEvent, INFINITE);
		}
		// unprepare the buffer
		res = waveInUnprepareHeader(wavein, whin[i], sizeof(WAVEHDR));
		if (checkWaveInResult(wavein, res, "waveInUnprepareHeader"))
			return -1;
		// free memory
		free(whin[i]->lpData);
		free(whin[i]);
	}

	// close device
	res = waveInClose(wavein);
	if (checkWaveInResult(wavein, res, "waveInClose"))
		return -1;
			
	return 0;
}
Ejemplo n.º 9
0
static void ALCwinmmCapture_Destruct(ALCwinmmCapture *self)
{
    void *buffer = NULL;
    int i;

    /* Tell the processing thread to quit and wait for it to do so. */
    if(!ATOMIC_EXCHANGE(&self->killNow, AL_TRUE, almemory_order_acq_rel))
    {
        PostThreadMessage(self->thread, WM_QUIT, 0, 0);

        althrd_join(self->thread, &i);

        /* Make sure capture is stopped and all pending buffers are flushed. */
        waveInReset(self->InHdl);

        // Release the wave buffers
        for(i = 0;i < 4;i++)
        {
            waveInUnprepareHeader(self->InHdl, &self->WaveBuffer[i], sizeof(WAVEHDR));
            if(i == 0) buffer = self->WaveBuffer[i].lpData;
            self->WaveBuffer[i].lpData = NULL;
        }
        free(buffer);
    }

    ll_ringbuffer_free(self->Ring);
    self->Ring = NULL;

    // Close the Wave device
    if(self->InHdl)
        waveInClose(self->InHdl);
    self->InHdl = 0;

    ALCbackend_Destruct(STATIC_CAST(ALCbackend, self));
}
Ejemplo n.º 10
0
void RUIAudio::RecordClose()
{
	Stop();
	HWAVEIN hTemp = m_hWaveIn;
	m_hWaveIn = NULL;
	if (hTemp == NULL)
		return;

	RUIBuffer*	pRUIBuffer = m_RecBufferList.GetFirst();
	while (pRUIBuffer != NULL)
	{
		RecRemoveBuffer(pRUIBuffer);

		pRUIBuffer = m_RecBufferList.GetNext(pRUIBuffer);
	}

	if( hTemp == NULL )
		return;

	if (waveInReset(hTemp) != MMSYSERR_NOERROR)
		ASSERT(FALSE);

	if (waveInClose(hTemp) != MMSYSERR_NOERROR)
		ASSERT(FALSE);
}
Ejemplo n.º 11
0
bool CSoundChannel::m_bCloseAudio()
{
	if(m_bClose)
		return m_bClose;
	
	m_bAbort();

	if(m_hWaveOut != NULL)
	{
		while(waveOutClose(m_hWaveOut) == WAVERR_STILLPLAYING)	//关闭WAVEOUT设备
			waveOutReset(m_hWaveOut);
		m_hWaveOut = NULL;
	}

	if(m_hWaveIn != NULL)
	{
		while(waveInClose(m_hWaveIn) == WAVERR_STILLPLAYING)	//关闭WAVEIN设备
			waveInReset(m_hWaveIn);
		m_hWaveIn = NULL;
	}

	m_bAbort();

	m_uOldHandle = -1;
	m_bClose = true;
	return true;
}
Ejemplo n.º 12
0
void mmio_close_audio( void)
{
    int errcode;
    int nda, nad;
    if (sys_verbose)
    	post("closing audio...");

    for (nda=0; nda < nt_nwaveout; nda++) /*if (nt_nwaveout) wini */
    {
       errcode = waveOutReset(ntsnd_outdev[nda]);
       if (errcode != MMSYSERR_NOERROR)
	   printf("error resetting output %d: %d\n", nda, errcode);
       errcode = waveOutClose(ntsnd_outdev[nda]);
       if (errcode != MMSYSERR_NOERROR)
	   printf("error closing output %d: %d\n",nda , errcode);	   
    }
    nt_nwaveout = 0;

    for(nad=0; nad < nt_nwavein;nad++) /* if (nt_nwavein) wini */
    {
	errcode = waveInReset(ntsnd_indev[nad]);
	if (errcode != MMSYSERR_NOERROR)
	    printf("error resetting input: %d\n", errcode);
	errcode = waveInClose(ntsnd_indev[nad]);
	if (errcode != MMSYSERR_NOERROR)
	    printf("error closing input: %d\n", errcode);
    }
    nt_nwavein = 0;
}
Ejemplo n.º 13
0
static void WinMMCloseCapture(ALCdevice *Device)
{
    WinMMData *data = (WinMMData*)Device->ExtraData;
    void *buffer = NULL;
    int i;

    /* Tell the processing thread to quit and wait for it to do so. */
    data->killNow = AL_TRUE;
    PostThreadMessage(data->thread, WM_QUIT, 0, 0);

    althrd_join(data->thread, &i);

    /* Make sure capture is stopped and all pending buffers are flushed. */
    waveInReset(data->WaveHandle.In);

    // Release the wave buffers
    for(i = 0; i < 4; i++)
    {
        waveInUnprepareHeader(data->WaveHandle.In, &data->WaveBuffer[i], sizeof(WAVEHDR));
        if(i == 0) buffer = data->WaveBuffer[i].lpData;
        data->WaveBuffer[i].lpData = NULL;
    }
    free(buffer);

    DestroyRingBuffer(data->Ring);
    data->Ring = NULL;

    // Close the Wave device
    waveInClose(data->WaveHandle.In);
    data->WaveHandle.In = 0;

    free(data);
    Device->ExtraData = NULL;
}
Ejemplo n.º 14
0
bool_t gaudio_record_lld_init(uint16_t channel, uint32_t frequency, ArrayDataFormat format) {
	WAVEFORMATEX	wfx;

	if (format != ARRAY_DATA_8BITUNSIGNED && format != ARRAY_DATA_16BITSIGNED)
		return FALSE;

	if (!waveThread) {
		if (!(waveThread = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)waveProc, 0, 0, &threadID))) {
			fprintf(stderr, "GAUDIO: Can't create WAVE recording thread\n");
			exit(-1);
		}
		CloseHandle(waveThread);
	}

	wfx.wFormatTag = WAVE_FORMAT_PCM;
	wfx.nChannels = channel == GAUDIO_RECORD_STEREO ? 2 : 1;
	wfx.nSamplesPerSec = frequency;
	wfx.nBlockAlign = wfx.nChannels * (format == ARRAY_DATA_8BITUNSIGNED ? 1 : 2);
	wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
	wfx.wBitsPerSample = (format == ARRAY_DATA_8BITUNSIGNED ? 8 : 16);
	wfx.cbSize = 0;

	if (ah) {
		waveInClose(ah);
		ah = 0;
	}
	if (waveInOpen(&ah, WAVE_MAPPER, &wfx, (DWORD_PTR)threadID, 0, CALLBACK_THREAD)) {
		fprintf(stderr, "GAUDIN: Can't open WAVE recording device\n");
		exit(-1);
	}

	return TRUE;
}
Ejemplo n.º 15
0
BMID_API int BGBMID_SoundDev_RecDeInit()
{
	int i;

	waveInStop(hWaveIn);

	waveInReset(hWaveIn);

	if(lpInWaveHdr)
	{
		for(i=0; i<WAV_BUFFERS; i++)
			waveInUnprepareHeader(hWaveIn, lpInWaveHdr+i, sizeof(WAVEHDR));
	}

	waveInClose(hWaveIn);

	if(hInWaveHdr)
	{
		GlobalUnlock(hInWaveHdr); 
		GlobalFree(hInWaveHdr);
	}

	if(hInData)
	{
		GlobalUnlock(hInData);
		GlobalFree(hInData);
	}

	return(0);
}
Ejemplo n.º 16
0
audioStreamer_waveOut::~audioStreamer_waveOut()
{
   int x;
   if (m_hwo) waveOutReset(m_hwo);
   if (m_hwi) waveInReset(m_hwi);
   for (x = 0; x < m_bufs.GetSize(); x ++)
   {
	   WAVEHDR *p = (WAVEHDR *)m_bufs.Get(x)->Get();
	   if (m_hwi && p)
		   if (p->dwFlags & WHDR_PREPARED) waveInUnprepareHeader(m_hwi,p,sizeof(WAVEHDR));

	   if (m_hwo && p)
     {
		   if (p->dwFlags & WHDR_PREPARED) waveOutUnprepareHeader(m_hwo,p,sizeof(WAVEHDR));
     }
	   delete m_bufs.Get(x);
   }
   m_bufs.Empty();

   if (m_hwo)
   {
	   waveOutClose(m_hwo);
	   m_hwo=0;
   }
   if (m_hwi)
   {
	   waveInClose(m_hwi);
	   m_hwi=0;
   }

}
Ejemplo n.º 17
0
CAudio::~CAudio()
{
	if (m_bIsWaveInUsed)
	{
		waveInStop(m_hWaveIn);
		waveInReset(m_hWaveIn);
		for (int i = 0; i < 2; i++)
			waveInUnprepareHeader(m_hWaveIn, m_lpInAudioHdr[i], sizeof(WAVEHDR));
		waveInClose(m_hWaveIn);
		TerminateThread(m_hThreadCallBack, -1);
	}

	if (m_bIsWaveOutUsed)
	{
		waveOutReset(m_hWaveOut);
		for (int i = 0; i < 2; i++)
			waveOutUnprepareHeader(m_hWaveOut, m_lpInAudioHdr[i], sizeof(WAVEHDR));
		waveOutClose(m_hWaveOut);
	}		


	for (int i = 0; i < 2; i++)
	{
		delete [] m_lpInAudioData[i];
		delete m_lpInAudioHdr[i];
		
		delete [] m_lpOutAudioData[i];
		delete m_lpOutAudioHdr[i];
	}

	CloseHandle(m_hEventWaveIn);
	CloseHandle(m_hStartRecord);
	CloseHandle(m_hThreadCallBack);
}
Ejemplo n.º 18
0
static void
winaudio_in_fini (HWVoiceIn *hw)
{
    WinAudioIn*  s = (WinAudioIn*) hw;
    int           i;

    if (s->wavein) {
        waveInReset(s->wavein);
            s->wavein = 0;
    }

    for ( i=0; i<NUM_OUT_BUFFERS; ++i ) {
        if ( s->buffers[i].dwUser != 0xFFFF ) {
            waveInUnprepareHeader(
                s->wavein, &s->buffers[i], sizeof(s->buffers[i]) );
                s->buffers[i].dwUser = 0xFFFF;
        }
    }

    if (s->buffer_bytes != NULL) {
        qemu_free(s->buffer_bytes);
        s->buffer_bytes = NULL;
    }

    if (s->wavein) {
        waveInClose(s->wavein);
        s->wavein = NULL;
    }
}
Ejemplo n.º 19
0
/*
 * Class:     com_ibm_media_protocol_device_DataSource
 * Method:    disconnectDevice
 * Signature: ()V
 */
JNIEXPORT void JNICALL Java_com_ibm_media_protocol_device_DataSource_disconnectDevice
(JNIEnv* env, jobject obj) {

	MMRESULT result;

	/* first mark all pending buffers as done */
	result = waveInReset(hwi); 
	
	/* DEBUG */
	if (result == MMSYSERR_NOERROR)
		printf("Device reset\n");
	else
		printf("ERROR reseting device !\n");
	/* end DEBUG */

	result = waveInClose(hwi);

	/* DEBUG */
	if (result == MMSYSERR_NOERROR)
		printf("Device closed\n");
	else
		printf("ERROR closing device !\n");
	/* end DEBUG */

}
Ejemplo n.º 20
0
int audio_close(snd_type snd)
{
    int i;
    MMRESULT er;
    buffer_state *bs = (buffer_state *) snd->u.audio.descriptor;
    if (snd->write_flag == SND_READ) {
        if (er = waveInReset(bs->u.h_in)) {
            mm_error_handler(snd, er, snd_fail);
            return !SND_SUCCESS;
        }
        if (er = waveInClose(bs->u.h_in)) {
            mm_error_handler(snd, er, snd_fail);
            return !SND_SUCCESS;
        }
    } else { // SND_WRITE
        if (er = waveOutReset(bs->u.h_out)) {
            mm_error_handler(snd, er, snd_fail);
            return !SND_SUCCESS;
        }
        if (er = waveOutClose(bs->u.h_out)) {
            mm_error_handler(snd, er, snd_fail);
            return !SND_SUCCESS;
        }
    }
    for (i = 0; i < bs->numofbuffers; i++) {
        snd_free(bs->whdr[i].lpData);
    }
    snd_free(bs->whdr);
    snd_free(bs);
    if (rt_devices_open) {
        timeEndPeriod(1);
        rt_devices_open--;
    }
    return SND_SUCCESS;
}
Ejemplo n.º 21
0
static int32
wavein_close(ad_rec_t * r)
{
    int32 i, st;

    /* Unprepare all buffers; multiple unprepares of the same buffer are benign */
    for (i = 0; i < r->n_buf; i++) {
        /* Unpreparing an unprepared buffer, on the other hand, fails
           on Win98/WinME, though this is not documented - dhuggins@cs,
           2004-07-14 */
        if (!(r->wi_buf[i].p_whdr->dwFlags & WHDR_PREPARED))
            continue;
        st = waveInUnprepareHeader(r->h_wavein,
                                   r->wi_buf[i].p_whdr, sizeof(WAVEHDR));
        if (st != 0) {
            wavein_error("waveInUnprepareHeader", st);
            return -1;
        }
    }

    /* Free buffers */
    for (i = 0; i < r->n_buf; i++)
        wavein_free_buf(&(r->wi_buf[i]));
    free(r->wi_buf);

    if ((st = waveInClose(r->h_wavein)) != 0) {
        wavein_error("waveInClose", st);
        return -1;
    }

    free(r);

    return 0;
}
Ejemplo n.º 22
0
/*
 * Destroy stream.
 */
PJ_DEF(pj_status_t) pjmedia_snd_stream_close(pjmedia_snd_stream *stream)
{
    unsigned i;

    PJ_ASSERT_RETURN(stream != NULL, PJ_EINVAL);

    pjmedia_snd_stream_stop(stream);

    if (stream->thread)
    {
	SetEvent(stream->thread_quit_event);
	pj_thread_join(stream->thread);
	pj_thread_destroy(stream->thread);
	stream->thread = NULL;
    }

    /* Unprepare the headers and close the play device */
    if (stream->play_strm.hWave.Out)
    {
	waveOutReset(stream->play_strm.hWave.Out);
	for (i = 0; i < stream->play_strm.dwMaxBufIdx; ++i)
	    waveOutUnprepareHeader(stream->play_strm.hWave.Out, 
				   &(stream->play_strm.WaveHdr[i]),
				   sizeof(WAVEHDR));
	waveOutClose(stream->play_strm.hWave.Out);
	stream->play_strm.hWave.Out = NULL;
    }

    /* Close the play event */
    if (stream->play_strm.hEvent)
    {
	CloseHandle(stream->play_strm.hEvent);
	stream->play_strm.hEvent = NULL;
    }

    /* Unprepare the headers and close the record device */
    if (stream->rec_strm.hWave.In)
    {
	waveInReset(stream->rec_strm.hWave.In);
	for (i = 0; i < stream->play_strm.dwMaxBufIdx; ++i)
	    waveInUnprepareHeader(stream->rec_strm.hWave.In, 
				  &(stream->rec_strm.WaveHdr[i]),
				  sizeof(WAVEHDR));
	waveInClose(stream->rec_strm.hWave.In);
	stream->rec_strm.hWave.In = NULL;
    }

    /* Close the record event */
    if (stream->rec_strm.hEvent)
    {
	CloseHandle(stream->rec_strm.hEvent);
	stream->rec_strm.hEvent = NULL;
    }

    pj_pool_release(stream->pool);

    return PJ_SUCCESS;
}
Ejemplo n.º 23
0
void ph_media_stop(phcall_t *ca)
{
  phmstream_t *stream = (phmstream_t *) ca->phstream;


  ca->hasaudio = 0;
  ca->phstream = 0;

  stream->running = 0;

  osip_thread_join(stream->audio_in_thread);
  osip_thread_join(stream->audio_out_thread);
  osip_free(stream->audio_in_thread);
  osip_free(stream->audio_out_thread);

  
  rtp_session_signal_disconnect_by_callback(stream->rtp_session, "telephone-event",
					    (RtpCallback)ph_telephone_event);
  ortp_set_debug_file("oRTP", stdout);
  ortp_global_stats_display();
  ortp_set_debug_file("oRTP", NULL);
  rtp_session_destroy(stream->rtp_session);

#if USE_CODECS
  if (stream->codec->encoder_cleanup)
	  stream->codec->encoder_cleanup(stream->encoder_ctx);
  if (stream->codec->decoder_cleanup)
	  stream->codec->decoder_cleanup(stream->decoder_ctx);
#endif /* !USE_CODECS */

  waveInReset(stream->hWaveIn);
  waveInClose(stream->hWaveIn);
  waveOutReset(stream->hWaveOut);
  waveOutClose(stream->hWaveOut);

#if DO_ECHO_CAN
   printf("\nbytes echoed %d %d\n", stream->sent_cnt, stream->recv_cnt);

  free(stream->pcm_sent);

# if !AEC_BIS
  if(stream->ec)
    echo_can_free(stream->ec);
# else /* AEC_BIS */
  kill_AEC();
# endif /* AEC_BIS */

  g_mutex_free(stream->synclock);
  g_cond_free(stream->sync_cond);
  g_mutex_free(stream->aec_mutex);


#endif /* !DO_ECHO_CAN */

  g_mutex_free(stream->dtmfg_lock);

  osip_free(stream);
}
Ejemplo n.º 24
0
void CAudioCollect::Stop()
{
	bStart = false;
	bReset = true;
	waveOutReset(m_hWaveOut);
	waveOutClose(m_hWaveOut);
	waveInReset(m_hWaveIn);
	waveInClose(m_hWaveIn);
}
Ejemplo n.º 25
0
static void winwave_anal_close_in (WaveVoiceIn *wave)
{
    MMRESULT mr;

    mr = waveInClose (wave->hwi);
    if (mr != MMSYSERR_NOERROR) {
        winwave_logerr (mr, "waveInClose");
    }
    wave->hwi = NULL;
}
Ejemplo n.º 26
0
void CAudioInput::CloseMic()
{
    Sleep(50);  // wait for the thread to terminate
	if(h_input){
		waveInStop(h_input);
		//waveInReset(h_input);
   		waveInClose(h_input);
	}
	fclose(fpBufferData);
	fclose(fpTempoData);
}
Ejemplo n.º 27
0
			~inAudioCapture()
			{
				#if WRITEWAVE
				finishWaveFile();
				#endif
				waveInStop(hWaveIn);
				std::cout << "Stop Recording.\n" << std::endl;
				waveInClose(hWaveIn);
				if(!dataIn) delete [] dataIn;
				
			}
Ejemplo n.º 28
0
static void close_sound(void)
{ if (sound_recording)
    stop_sound();
  if (!opened)
    return;
  close_Mixer_data();
  error_code = waveInClose(hwavein);
  if( error_code != MMSYSERR_NOERROR)
     errormsg("Unable to close sound recording.",error_code);
  opened=0;
}
Ejemplo n.º 29
0
Archivo: wave.cpp Proyecto: harite/im-1
int WaveIn::Close()
{
    //int nRet;
    Clean();
    if(m_hWaveIn!=NULL){
                        
          m_nRet=waveInClose(m_hWaveIn);
          if(m_nRet!=MMSYSERR_NOERROR){
               return 0;
               }
          }
    return 1;
}
Ejemplo n.º 30
0
void CALLBACK waveInProc(HWAVEIN hwi,      
						 UINT uMsg,         
						 DWORD_PTR dwInstance,  
						 DWORD_PTR dwParam1,  
						 DWORD_PTR dwParam2     )
{
	LPWAVEHDR pwh = (LPWAVEHDR)dwParam1;

	if ((WIM_DATA==uMsg) && (buf_count<BUFFER_SIZE))
	{

		int size = pwh->dwBytesRecorded;

		//relocated memory location
		pNewBuffer = (PBYTE)realloc (pSaveBuffer, dwDataLength+ size) ; 

		if(pNewBuffer ==NULL)
		{
			waveInClose(hwi);
			printf("memory error");
			return;
		}

		//copy data into memory and refresh memory address
		pSaveBuffer = pNewBuffer;
		buf_count ++;
		CopyMemory(pSaveBuffer + dwDataLength, pwh->lpData,size);
		dwDataLength += size;

		if(!m_record)
		{
			waveInClose(hwi);
			printf("stop recording");
			return;
		}		
		waveInAddBuffer(hwi, pwh, sizeof(WAVEHDR));
	}
}