crash - On memcpy application crashes - FFMPEG, C++ -
i have been working ffmpeg, got working good, got memory leak, followed instructions fix (like use av_frame_unref
), needed update ffmpeg version 1.2. weird me, because working good, , then, update, application started crash in memcpy.
honestly, don't know what's happening, tried google no answer. appreciate help, here segment of code failing:
int wbmedia::decodeaudioframe(int16_t *audio_buf){ static avframe *frame; static avpacket pkt; static uint8_t *audio_pkt_data = null; static int audio_pkt_size = 0; static bool first_time = true; if(first_time){ first_time=false; } int len1, data_size = 0; for(;;){ bool do_rt = false; while(audio_pkt_size > 0){ int obt_frame = 0; if (!frame) { if (!(frame = avcodec_alloc_frame())) { messagebox(0,"out of memory error","error: memory",mb_iconwarning | mb_ok); return -1; } } len1 = avcodec_decode_audio4(_audio_ccontext,frame,&obt_frame,&pkt); if(len1 < 0){ audio_pkt_size = 0; break; } if(obt_frame){ data_size = av_samples_get_buffer_size(null,channel_count,sample_fr,_audio_ccontext->sample_fmt,1); memcpy(audio_buf,frame->data[0],data_size); } audio_pkt_data+=len1; audio_pkt_size-=len1; if(data_size < 0){ continue; } return data_size; } if(pkt.data){ //messagebox(0,"hi","hi",mb_ok); // test if app si reaching av_free_packet av_free_packet(&pkt); } if(do_rt){ return data_size; } // try new packet if(!audio_packets.empty()){ waitforsingleobject(queue_audio_mutex,infinite); pkt = *audio_packets.front(); audio_packets.pop(); releasemutex(queue_audio_mutex); audio_pkt_size = pkt.size; audio_pkt_data = pkt.data; }else{ return -1; } } return 0; }
thanks much.
Comments
Post a Comment