Recording data on device, transfer it over wifi, and play it on receiver


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 = {
        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;
        // Device only calls us when it really full
        data_buffer->m_size = data_buffer->m_capacity;

        m_callback(data_buffer->m_buffer, data_buffer->m_size);

        android_helpers::sample_buffer* free_buffer;
        while (m_free_queue->front(&free_buffer) &&
            SLresult result = (*buffer_queue)->Enqueue(buffer_queue,
            assert(SL_RESULT_SUCCESS == result);

        // Device goes to powersafe if the buffers are empty
        if (m_device_shadow_queue->size() == 0)


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 =

        SLAndroidDataFormat_PCM_EX format_pcm;
        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?