Skip to content
This repository has been archived by the owner on Mar 26, 2023. It is now read-only.

Crash when I remove a watermark image #368

Open
iHandle opened this issue Jun 6, 2017 · 1 comment
Open

Crash when I remove a watermark image #368

iHandle opened this issue Jun 6, 2017 · 1 comment

Comments

@iHandle
Copy link

iHandle commented Jun 6, 2017

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
Copy link
Author

iHandle commented Jul 28, 2017

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;
            }
        
        
        }
    }

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant