Examples of QTFastStartRAF


Examples of com.aelitis.azureus.core.util.QTFastStartRAF

      }
     
      public void
      run()
      {
        QTFastStartRAF  raf = null;
       
        String name = file.getName();
       
        int  dot_pos = name.lastIndexOf('.');
       
        String ext = dot_pos<0?"":name.substring(dot_pos+1);
       
        try{
          raf = new QTFastStartRAF( file, user_agent != null && QTFastStartRAF.isSupportedExtension( ext ));
         
          raf.seek( offset );
     
          byte[] buffer = new byte[max_read_chunk];
         
          long  rem    = length;
          long  pos   = offset;
         
          while( rem > 0 ){
           
            if ( cancelled ){
             
              throw( new Exception( "Cancelled" ));
             
            }else if ( channel_destroyed ){
             
              throw( new Exception( "Destroyed" ));
            }
           
            int  chunk = (int)Math.min( rem, max_read_chunk );
           
            int  len = raf.read( buffer, 0, chunk );
                       
            sendEvent( new event( new PooledByteBufferImpl( buffer, 0, len ), pos, len ));
           
            rem -= len;
            pos  += len;
          }
        }catch( Throwable e ){
         
          sendEvent( new event( e ));
         
        }finally{
         
          if ( raf != null ){
           
            try{
              raf.close();
             
            }catch( Throwable e ){
             
              Debug.out( e );
            }
View Full Code Here

Examples of com.aelitis.azureus.core.util.QTFastStartRAF

          for_stream = QTFastStartRAF.isSupportedExtension( ext );
        }
       
        if ( for_stream ){
         
          QTFastStartRAF  raf = null;
         
          try{
            raf = new QTFastStartRAF( getAccessor( max_read_chunk, user_agent ), true );
           
            raf.seek( offset );
       
            byte[] buffer = new byte[max_read_chunk];
           
            long  rem    = length;
            long  pos   = offset;
           
            while( rem > 0 ){
             
              if ( cancelled ){
               
                throw( new Exception( "Cancelled" ));
               
              }else if ( channel_destroyed ){
               
                throw( new Exception( "Destroyed" ));
              }
             
              int  chunk = (int)Math.min( rem, max_read_chunk );
             
              int  len = raf.read( buffer, 0, chunk );
                         
              sendEvent( new event( new PooledByteBufferImpl( buffer, 0, len ), pos, len ));
             
              rem -= len;
              pos  += len;
             
              position += len;
            }
          }catch( Throwable e ){
           
            sendEvent( new event( e ));
           
          }finally{
           
            if ( raf != null ){
             
              try{
                raf.close();
               
              }catch( Throwable e ){
               
                Debug.out( e );
              }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.