Commit 2dad31885e701d926e5a183de6628bfb6fbf1c8c
1 parent
6dddca6a
优化解码任务结束逻辑,避免可能的泄露
Showing
1 changed file
with
18 additions
and
16 deletions
src/decoder/dvpp/DvppDecoder.cpp
... | ... | @@ -627,27 +627,25 @@ void DvppDecoder::read_thread() { |
627 | 627 | av_packet_free(&pkt); |
628 | 628 | pkt = nullptr; |
629 | 629 | |
630 | - if (vdecChannelDesc) { | |
631 | - sendVdecEos(vdecChannelDesc); | |
632 | - } | |
633 | - | |
634 | - while(m_bRunning && m_decoded_data_queue.size() > 0) { | |
635 | - std::this_thread::sleep_for(std::chrono::milliseconds(5)); | |
636 | - } | |
637 | - | |
638 | 630 | } while (0); |
639 | 631 | |
640 | 632 | if (vdecChannelDesc) { |
633 | + sendVdecEos(vdecChannelDesc); | |
634 | + | |
641 | 635 | CHECK_NOT_RETURN(aclvdecDestroyChannel(vdecChannelDesc), "aclvdecDestroyChannel failed"); |
642 | 636 | CHECK_NOT_RETURN(aclvdecDestroyChannelDesc(vdecChannelDesc), "aclvdecDestroyChannelDesc failed"); |
643 | 637 | vdecChannelDesc = nullptr; |
644 | 638 | } |
645 | 639 | |
646 | - m_bRunning=false; | |
647 | - | |
648 | 640 | m_bExitReportThd = true; |
649 | 641 | CHECK_NOT_RETURN(pthread_join(report_thread, nullptr), "report_thread join failed"); |
650 | 642 | |
643 | + while(m_bRunning && m_decoded_data_queue.size() > 0) { | |
644 | + std::this_thread::sleep_for(std::chrono::milliseconds(5)); | |
645 | + } | |
646 | + | |
647 | + m_bRunning=false; | |
648 | + | |
651 | 649 | m_bExitDisplayThd = true; |
652 | 650 | display_thread.join(); |
653 | 651 | |
... | ... | @@ -774,6 +772,12 @@ void DvppDecoder::doVdppVdecCallBack(acldvppStreamDesc *input, acldvppPicDesc *o |
774 | 772 | // 内部缓存计数减1 |
775 | 773 | m_DvppCacheCounter--; |
776 | 774 | |
775 | + CHECK_AND_RETURN_NOVALUE(aclrtSetCurrentContext(m_context), "aclrtSetCurrentContext failed"); | |
776 | + | |
777 | + void *inputDataDev = acldvppGetStreamDescData(input); | |
778 | + acldvppFree(inputDataDev); | |
779 | + inputDataDev = nullptr; | |
780 | + | |
777 | 781 | if(nullptr == pUserData){ |
778 | 782 | return; |
779 | 783 | } |
... | ... | @@ -783,12 +787,6 @@ void DvppDecoder::doVdppVdecCallBack(acldvppStreamDesc *input, acldvppPicDesc *o |
783 | 787 | |
784 | 788 | m_out_count++; |
785 | 789 | |
786 | - CHECK_AND_RETURN_NOVALUE(aclrtSetCurrentContext(m_context), "aclrtSetCurrentContext failed"); | |
787 | - | |
788 | - void *inputDataDev = acldvppGetStreamDescData(input); | |
789 | - acldvppFree(inputDataDev); | |
790 | - inputDataDev = nullptr; | |
791 | - | |
792 | 790 | void *outputDataDev = acldvppGetPicDescData(output); |
793 | 791 | uint32_t outputSize = acldvppGetPicDescSize(output); |
794 | 792 | uint32_t width = acldvppGetPicDescWidth(output); |
... | ... | @@ -845,6 +843,10 @@ void DvppDecoder::doVdppVdecCallBack(acldvppStreamDesc *input, acldvppPicDesc *o |
845 | 843 | if(mem){ |
846 | 844 | m_decoded_data_queue.push(mem); |
847 | 845 | bCached = true; |
846 | + } else { | |
847 | + // 逻辑完善 | |
848 | + delete mem; | |
849 | + mem = nullptr; | |
848 | 850 | } |
849 | 851 | } |
850 | 852 | ... | ... |