The normal behaviour should be :
1. The prerender callback allocates a buffer with the right size
2. Smem uses memcpy to fill the buffer
3. The postrender callback uses the buffer (and deletes it, if needed)
My code is :
Code: Select all
void StreamPlayer::prepareRender( void* p_audio_data, uint8_t** pp_pcm_buffer , unsigned int size )
{
cout << "Prerender" << endl;
cout << " pp_pcm_buffer = ";
cout << pp_pcm_buffer << endl;
cout << " *pp_pcm_buffer = " << flush;
cout << *pp_pcm_buffer << endl; // Here I get a segfault. Why ?
// This pointer has been passed from another thread, from SendAudio in smem.
// I should be able to access to it since I'm supposed to modify it !
(*pp_pcm_buffer) = new uint8_t[size]; // Dummy behaviour : each time, we delete and reallocate, which should take a while
cout << "Prerender ended." << endl << endl;
}
void StreamPlayer::handleStream(void* p_audio_data, uint8_t* p_pcm_buffer, unsigned int channels, unsigned int rate, unsigned int nb_samples, unsigned int bits_per_sample, unsigned int size, int64_t pts )
{
cout << "Postrender" << endl;
delete p_pcm_buffer;
cout << "Postrender ended." << endl << endl;
}
Thanks