Okay I am in a really frustrating situation, I have the following problems:
I have to record audio in real-time from a server device, in this scenario an Android Phone but later it could be a laptop or another device. Then transfer the the recorded data from the server over WiFi to multiple receiving client devices, also in this scenario Android phones. However, I am not able to figure out how to configure the data sink on the source properly as to read the data, which I need to transfer, nor am I quiet sure how to configure the data source on the the clients.
My current configuration of the source device is:
// Configure Audio sink
SLDataLocator_AndroidSimpleBufferQueue locate_buffer_queue = {
SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE,
DEVICE_SHADOW_BUFFER_QUEUE_LENGTH};
SLDataSink audio_sink = {&locate_buffer_queue, &format_pcm};
And my process_slcallback method is here:
void opensl_recorder::process_slcallback(
SLAndroidSimpleBufferQueueItf buffer_queue)
{
android_helpers::sample_buffer* data_buffer;
m_device_shadow_queue->front(&data_buffer);
m_device_shadow_queue->pop();
// Device only calls us when it really full
data_buffer->m_size = data_buffer->m_capacity;
m_recorder_queue->push(data_buffer);
m_callback(data_buffer->m_buffer, data_buffer->m_size);
android_helpers::sample_buffer* free_buffer;
while (m_free_queue->front(&free_buffer) &&
m_device_shadow_queue->push(free_buffer))
{
m_free_queue->pop();
SLresult result = (*buffer_queue)->Enqueue(buffer_queue,
free_buffer->m_buffer,
free_buffer->m_capacity);
assert(SL_RESULT_SUCCESS == result);
}
// Device goes to powersafe if the buffers are empty
if (m_device_shadow_queue->size() == 0)
{
(*m_recorder_interface)->SetRecordState(m_recorder_interface,
SL_RECORDSTATE_STOPPED);
}
}
This line
m_callback(data_buffer->m_buffer, data_buffer->m_size);
is calling a callback which “passes” the data from a opens_recorder instance, a class I made to encapsulate OpenSL, and it is expects a uint8_t* which points to the data and a uint32_t value representing the size of the data.
And the receiver data source
// Configure audio source
SLDataLocator_AndroidSimpleBufferQueue locate_buffer_queue =
{SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE,
DEVICE_SHADOW_BUFFER_QUEUE_LENGTH};
SLAndroidDataFormat_PCM_EX format_pcm;
android_helpers::convert_to_sl_sample_format(&format_pcm,
&m_sample_info);
SLDataSource audio_source = {&locate_buffer_queue, &format_pcm};
I am fairly sure that servers audio sink is configured wrong and the same goes for the client audio source. Additional I am also fairly certain I am accessing the data recorded on the server phone wrongly. I am however, not capable of realising what my mistakes are. Can some one help me or point me in the direction of an answer?
Best,
looopTools