Yes, it seems this is a feature :-) I believe the correct thing to do is in fact to destroy the player inside your callback. I'm not sure why this causes a crash for you, this is what I do in my code (using pjproject svn rev 3087) and it is working fine. See Benny's helpful reply to me on this same topic here: http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/2009-October/009069.html (Did you RTF list archives ;-) ?) Incidentally, I solved your problem a different way (ie. within the callback you need the call id and the player id) but maybe this indicates that having this context is generally useful and could be added to the code base. Ryan Littrell wrote: > I'm using a local build sipek sdk and pjsip trunks. I noticed in the > log the wav player calls the EOF callback twice. In the second call, > the free(args) fails. Any thoughts? > > Log: > > 01:13:36.849 pjsipDll_playW Wav Play, status 0 > 01:13:36.922 strm06B1F80C Start talksprut.. > 01:13:45.029 strm06B1F80C Starting silence > 01:13:45.429 strm06B1F80C Start talksprut.. > 01:13:45.433 strm06B1F80C Starting silence > 01:13:45.629 wav_player.c File port > D:\Projects\WindowsFormsApplication1\bin\Debug\0.wav EOF > 01:13:45.632 pjsipDll_playW on_wavplayerEof_callback, media_port: > 112313596 > 01:13:45.633 pjsipDll_playW End of Wav File, media_port: 112313596 > 01:13:45.671 wav_player.c File port > D:\Projects\WindowsFormsApplication1\bin\Debug\0.wav EOF > 01:13:45.672 pjsipDll_playW on_wavplayerEof_callback, media_port: > 112313596 > > > EOF Code: > > static PJ_DEF(pj_status_t) on_wavplayerEof_callback(pjmedia_port* > media_port, void* args) > { > PJ_LOG(3,(THIS_FILE, "on_wavplayerEof_callback, media_port: > %d", media_port)); > pj_status_t status; > wavplayerEof_Data* WavePlayerData = ((wavplayerEof_Data*) args); > > // Read info from args > pjsua_call_id call_id = WavePlayerData->callId; > pjsua_player_id player_id = WavePlayerData->playerId; > > //Destroy the Wav Player > //status = pjsua_player_destroy(player_id); // ! Problem if > Destroying Here : cash at the end of callback, for most of wavs files > > // Free the memory allocated for the args > free(args); > > PJ_LOG(3,(THIS_FILE, "End of Wav File, media_port: %d", > media_port)); > // Invoke the Callback for C# managed code > if (cb_wavplayerEnded != 0) > (*cb_wavplayerEnded)(call_id, player_id); > > if (status == PJ_SUCCESS) // Player correctly Destroyed > return -1; // Don't return > PJ_SUCCESS, to prevent crash when returning from callback after Player > Destruction > > return PJ_SUCCESS; // Else, return PJ_SUCCESS > > } //// -> goes back to the function wich has invoke the callback > : fill_buffer() in pjmedia\src\pjmedia\wav_player.c > ///// CRASH HERE WITH MOST OF WAV FILES, if player has been > destroyed above //// > ------------------------------------------------------------------------ > > _______________________________________________ > Visit our blog: http://blog.pjsip.org > > pjsip mailing list > pjsip at lists.pjsip.org > http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org > -- Jens B. Jorgensen jbj1 at ultraemail.net