Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.11 KB | None | 0 0
  1. Trying to teach dvblast to use a file as input but having a small problem
  2.  
  3. // these 2 values taken from a seperate include file
  4. #define TS_SIZE 188
  5. const int i_bufsize = TS_SIZE*32;
  6.  
  7. /*****************************************************************************
  8.  * file_Read : read packets from the device
  9.  *****************************************************************************/
  10. block_t *file_Read( mtime_t i_poll_timeout )
  11. {
  12.     i_wallclock = mdate();
  13.  
  14.     {
  15.         block_t *p_ts, **pp_current = &p_ts;
  16.         int i, i_len;
  17.  
  18.         if ( !i_last_packet )
  19.         {
  20.             switch (i_print_type) {
  21.             case PRINT_XML:
  22.                 printf("<STATUS type=\"lock\" status=\"1\"/>\n");
  23.                 break;
  24.             default:
  25.                 printf("frontend has acquired lock\n" );
  26.             }
  27.         }
  28.         i_last_packet = i_wallclock;
  29.  
  30.         i_len = 0;
  31.         for ( i = 0; i < i_bufsize / TS_SIZE; i++ )
  32.         {
  33.             *pp_current = block_New();
  34.             i_len2 = fread( (*pp_current)->p_ts, 1, TS_SIZE, file_input);
  35. // If i remove this code the following if check fails
  36. // But leave the code like this and the warning says i_len2 is 188 bytes
  37.             msg_Warn( NULL, "read from file %s (%s) %d %p",
  38.                        filename, strerror(errno), i_len2, pp_current );
  39.             if ( i_len2 < 188 )
  40.             {
  41.                 msg_Err( NULL, "couldn't read from file %s (%s) %d %p",
  42.                          filename, strerror(errno), i_len2, pp_current );
  43.                 i_len = 0;
  44.                 break;
  45.             }
  46.             i_len++;
  47.             pp_current = &(*pp_current)->p_next;
  48.         }
  49.  
  50.         pp_current = &p_ts;
  51.         while ( i_len && *pp_current )
  52.         {
  53.             pp_current = &(*pp_current)->p_next;
  54.             i_len--;
  55.         }
  56.  
  57.         if ( *pp_current )
  58.             msg_Dbg( NULL, "partial buffer received" );
  59.  
  60.         block_DeleteChain( *pp_current );
  61.         *pp_current = NULL;
  62.  
  63.         return p_ts;
  64.     }
  65.  
  66.     return NULL;
  67. }
  68.  
  69. Whats wrong with this code?
  70.  
  71. Any ideas, got blinked on this one
  72.  
  73. joolz
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement