Logo Search packages:      
Sourcecode: djvulibre version File versions

void DjVuFile::start_decode ( void   ) 

Starts decode. If threads are enabled, the decoding will be done in another thread. Be sure to use {wait_for_finish}() or listen for notifications sent through the {DjVuPortcaster} to remain in sync.

Definition at line 1325 of file DjVuFile.cpp.

References GThread::create(), DataPool::create(), GMonitor::enter(), DjVuPort::get_portcaster(), is_decoding(), GMonitor::leave(), DjVuPortcaster::notify_file_flags_changed(), and reset().

Referenced by resume_decode().

{
  check();
  DEBUG_MSG("DjVuFile::start_decode(), url='" << url << "'\n");
  DEBUG_MAKE_INDENT(3);
  
  GThread * thread_to_delete=0;
  flags.enter();
  G_TRY {
    if (!(flags & DONT_START_DECODE) && !is_decoding())
    {
      if (flags & DECODE_STOPPED) reset();
      flags&=~(DECODE_OK | DECODE_STOPPED | DECODE_FAILED);
      flags|=DECODING;
      
      // Don't delete the thread while you're owning the flags lock
      // Beware of deadlock!
      thread_to_delete=decode_thread; decode_thread=0;
      
      // We want to create it right here to be able to stop the
      // decoding thread even before its function is called (it starts)
      decode_data_pool=DataPool::create(data_pool);
      decode_life_saver=this;
      
      decode_thread=new GThread();
      decode_thread->create(static_decode_func, this);
    }
  }
  G_CATCH_ALL
  {
    flags&=~DECODING;
    flags|=DECODE_FAILED;
    flags.leave();
    get_portcaster()->notify_file_flags_changed(this, DECODE_FAILED, DECODING);
    delete thread_to_delete;
    G_RETHROW;
  }
  G_ENDCATCH;
  flags.leave();
  delete thread_to_delete;
}


Generated by  Doxygen 1.6.0   Back to index