VideoCore-Inactive icon indicating copy to clipboard operation
VideoCore-Inactive copied to clipboard

Crash when I remove a watermark image

Open iHandle opened this issue 8 years ago • 1 comments

I use function addPixelBufferSource to add a watermark image, but sometimes I have to update this watermark image. It means that I have to remove the old one and add a new one. To remove the old watermark image, I have added a new function in at VCSimpleSession.mm

-(void) removePixelBufferSource {
    m_videoMixer->unregisterSource(m_pixelBufferSource);
}

It does work. However, sometimes it crash at GLESVideoMixer.h 2017-06-06 16 31 51 Is it means that the "texture" is a wild pointer? I can not fix this problem even thought I have spent half of month, and I hope someone warm-hearted to help me.

iHandle avatar Jun 06 '17 08:06 iHandle

I have solved this problem by myself.The reason why it crashed is I removed PixelBufferSource when the GLESVideoMixer was mixing. So I modified function 'GLESVideoMixer:unregisterSource' .

    GLESVideoMixer::unregisterSource(std::shared_ptr<ISource> source)
    {
        while(1){
    
            if(m_mixing){
                // 
                continue;
            }else {
                DLog("\n GLESVideoMixer::unregisterSource \n");
                releaseBuffer(source);
                
                auto it = m_sources.begin();
                const auto h = std::hash<std::shared_ptr<ISource> >()(source);
                for ( ; it != m_sources.end() ; ++it ) {
                    
                    const auto shash = hash(*it);
                    
                    if(h == shash) {
                        m_sources.erase(it);
                        break;
                    }
                    
                }
                {
                    auto iit = m_sourceBuffers.find(h);
                    if(iit != m_sourceBuffers.end()) {
                        m_sourceBuffers.erase(iit);
                    }
                }
                for ( int i = m_zRange.first ; i <= m_zRange.second ; ++i )
                {
                    for ( auto iit = m_layerMap[i].begin() ; iit!= m_layerMap[i].end() ; ++iit) {
                        if((*iit) == h) {
                            m_layerMap[i].erase(iit);
                            break;
                        }
                    }
                }
            
                break;
            }
        
        
        }
    }

iHandle avatar Jul 28 '17 07:07 iHandle