Esempio n. 1
0
void AudioDriverOpenSL::_buffer_callback(
		SLAndroidSimpleBufferQueueItf queueItf
		/*   SLuint32 eventFlags,
    const void * pBuffer,
    SLuint32 bufferSize,
    SLuint32 dataUsed*/) {

	bool mix = true;

	if (pause) {
		mix = false;
	} else if (mutex) {
		mix = mutex->try_lock() == OK;
	}

	if (mix) {
		audio_server_process(buffer_size, mixdown_buffer);
	} else {

		int32_t *src_buff = mixdown_buffer;
		for (int i = 0; i < buffer_size * 2; i++) {
			src_buff[i] = 0;
		}
	}

	if (mutex && mix)
		mutex->unlock();

	const int32_t *src_buff = mixdown_buffer;

	int16_t *ptr = (int16_t *)buffers[last_free];
	last_free = (last_free + 1) % BUFFER_COUNT;

	for (int i = 0; i < buffer_size * 2; i++) {

		ptr[i] = src_buff[i] >> 16;
	}

	(*queueItf)->Enqueue(queueItf, ptr, 4 * buffer_size);

#if 0
	SLresult res;
	CallbackCntxt *pCntxt = (CallbackCntxt*)pContext;
	if(pCntxt->pData < (pCntxt->pDataBase + pCntxt->size))
	{
	    res = (*queueItf)->Enqueue(queueItf, (void*) pCntxt->pData,
				       2 * AUDIO_DATA_BUFFER_SIZE, SL_BOOLEAN_FALSE); /* Size given
    in bytes. */
	    CheckErr(res);
	    /* Increase data pointer by buffer size */
	    pCntxt->pData += AUDIO_DATA_BUFFER_SIZE;
	}
    }
Esempio n. 2
0
void AudioDriverOpenSL::_buffer_callback(
		SLAndroidSimpleBufferQueueItf queueItf
		/*   SLuint32 eventFlags,
    const void * pBuffer,
    SLuint32 bufferSize,
    SLuint32 dataUsed*/
) {

	bool mix = true;

	if (pause) {
		mix = false;
	} else if (mutex) {
		mix = mutex->try_lock() == OK;
	}

	if (mix) {
		audio_server_process(buffer_size, mixdown_buffer);
	} else {

		int32_t *src_buff = mixdown_buffer;
		for (int i = 0; i < buffer_size * 2; i++) {
			src_buff[i] = 0;
		}
	}

	if (mutex && mix)
		mutex->unlock();

	const int32_t *src_buff = mixdown_buffer;

	int16_t *ptr = (int16_t *)buffers[last_free];
	last_free = (last_free + 1) % BUFFER_COUNT;

	for (int i = 0; i < buffer_size * 2; i++) {

		ptr[i] = src_buff[i] >> 16;
	}

	(*queueItf)->Enqueue(queueItf, ptr, 4 * buffer_size);
}