[DEBUG] Fix valgrind error on service type management

Change-Id: If7a30d93a7402f44a536d48254abe884c98d5ed6
Reviewed-on: https://gerrit.parrot.biz/12367
Reviewed-by: Marjorie Coulin <e0d0de2845860cf690adee07a4709979cae78d5f@parrot.com>
Reviewed-by: Nicolas Brulez <c7b4d7ddc34318e865922d5ddc9ce680dfb1b14c@parrot.com>

--- Sources/ARDISCOVERY_AvahiDiscovery.c
+++ Sources/ARDISCOVERY_AvahiDiscovery.c
@@ -568,8 +568,7 @@
             browserData->serviceTypes = malloc(sizeof(char*) * serviceTypesNb);
             for (i = 0; i < serviceTypesNb; i++)
             {
-                *(browserData->serviceTypes + i) = malloc(sizeof(uint8_t) * ARDISCOVERY_AVAHIDISCOVERY_SERVICETYPE_SIZE);
-                memcpy(*(browserData->serviceTypes + i), *(serviceTypes + i), ARDISCOVERY_AVAHIDISCOVERY_SERVICETYPE_SIZE);
+                browserData->serviceTypes[i] = strdup(serviceTypes[i]);
             }
             browserData->serviceTypesNb = serviceTypesNb;
         }
@@ -842,7 +841,7 @@

             for (i = 0; i < browserDataPtr->serviceTypesNb; i++)
             {
-                free(browserDataPtr->serviceTypes + i);
+                free(browserDataPtr->serviceTypes[i]);
             }
             free(browserDataPtr->serviceTypes);


small revision in console io

small revision in console io

--- c/console_input/main.c
+++ c/console_input/main.c
@@ -6,8 +6,8 @@
 int main(int argc, char *argv[])
 {

-    /* Single character input works like this. This loop echos any single
-       character input, */
+    /* Old school single character input works like this. This loop
+       echos any char. */
     char c;
     printf("Enter a character and hit 'Return' to mirror it (and a '.' to quit). \n");
     do {
@@ -16,7 +16,7 @@
     } while (c != '.');
     printf("\n");

-    /* More advanced input using 'scanf'. */
+    /* More advanced input using 'scanf': */
     char line[100];
     int a;
     float x;


Fix refcount problems + fix a part of coding style problems

--- modules/access/vcdx/access.c
+++ modules/access/vcdx/access.c
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * vcd.c : VCD input module for vlc using libcdio, libvcd and libvcdinfo.
+ * vcd.c : VCD input module for vlc using libcdio, libvcd and libvcdinfo.
  *         vlc-specific things tend to go here.
  *****************************************************************************
  * Copyright (C) 2000, 2003, 2004 VideoLAN
@@ -7,7 +7,7 @@
  *
  * Authors: Rocky Bernstein <rocky@panix.com>
  *   Some code is based on the non-libcdio VCD plugin (as there really
- *   isn't real developer documentation yet on how to write a
+ *   isn't real developer documentation yet on how to write a
  *   navigable plugin.)
  *
  * This program is free software; you can redistribute it and/or modify
@@ -46,8 +46,8 @@

 #define FREE_AND_NULL(ptr) if (NULL != ptr) free(ptr); ptr = NULL;

-extern void VCDSetOrigin( access_t *p_access, lsn_t i_lsn, track_t i_track,
-			  const vcdinfo_itemid_t *p_itemid );
+extern void VCDSetOrigin( access_t *p_access, lsn_t i_lsn, track_t i_track,
+                          const vcdinfo_itemid_t *p_itemid );

 /*****************************************************************************
  * Local prototypes
@@ -56,8 +56,8 @@
 /* First those which are accessed from outside (via pointers). */
 static block_t *VCDReadBlock    ( access_t * );

-static int      VCDControl      ( access_t *p_access, int i_query,
-				  va_list args );
+static int      VCDControl      ( access_t *p_access, int i_query,
+                                  va_list args );

 /* Now those which are strictly internal */
 static vlc_bool_t  VCDEntryPoints  ( access_t * );
@@ -70,7 +70,7 @@

 static void VCDUpdateVar( access_t *p_access, int i_entry, int i_action,
                           const char *p_varname, char *p_label,
-			  const char *p_debug_label );
+                          const char *p_debug_label );

 static vcdinfo_obj_t *vcd_Open   ( vlc_object_t *p_this, const char *psz_dev );

@@ -150,15 +150,15 @@

     i_read = 0;

-    dbg_print( (INPUT_DBG_LSN), "lsn: %lu",
-	       (long unsigned int) p_vcdplayer->i_lsn );
+    dbg_print( (INPUT_DBG_LSN), "lsn: %lu",
+               (long unsigned int) p_vcdplayer->i_lsn );

     /* Allocate a block for the reading */
     if( !( p_block = block_New( p_access, i_blocks * M2F2_SECTOR_SIZE ) ) )
     {
         msg_Err( p_access, "cannot get a new block of size: %i",
                  i_blocks * M2F2_SECTOR_SIZE );
-	block_Release( p_block );
+        block_Release( p_block );
         return NULL;
     }

@@ -171,85 +171,85 @@

       switch ( read_status ) {
       case READ_END:
-	/* End reached. Return NULL to indicated this. */
-	/* We also set the postion to the end so the higher level
+        /* End reached. Return NULL to indicated this. */
+        /* We also set the postion to the end so the higher level
            (demux?) doesn't try to keep reading. If everything works out
-	   right this shouldn't have to happen.
-	 */
+           right this shouldn't have to happen.
+         */
 #if 0
-	if ( p_access->info.i_pos != p_access->info.i_size ) {
-	  msg_Warn( p_access,
-		    "At end but pos (%llu) is not size (%llu). Adjusting.",
-		    p_access->info.i_pos, p_access->info.i_size );
-	  p_access->info.i_pos = p_access->info.i_size;
-	}
+        if ( p_access->info.i_pos != p_access->info.i_size ) {
+          msg_Warn( p_access,
+                    "At end but pos (%llu) is not size (%llu). Adjusting.",
+                    p_access->info.i_pos, p_access->info.i_size );
+          p_access->info.i_pos = p_access->info.i_size;
+        }
 #endif

 #if 1
-	block_Release( p_block );
-	return NULL;
+        block_Release( p_block );
+        return NULL;
 #else
-	{
-	  memset(p_buf, 0, M2F2_SECTOR_SIZE);
-	  p_buf += 2;
-	  *p_buf = 0x01;
-	  printf("++++hacked\n");
-	  return p_block;
-	}
+        {
+          memset(p_buf, 0, M2F2_SECTOR_SIZE);
+          p_buf += 2;
+          *p_buf = 0x01;
+          printf("++++hacked\n");
+          return p_block;
+        }
 #endif

       case READ_ERROR:
-	/* Some sort of error. Should we increment lsn? to skip block?
-	 */
-	block_Release( p_block );
-	return NULL;
-      case READ_STILL_FRAME:
-	{
-	  /* FIXME The below should be done in an event thread.
-	     Until then...
-	   */
+        /* Some sort of error. Should we increment lsn? to skip block?
+        */
+        block_Release( p_block );
+        return NULL;
+      case READ_STILL_FRAME:
+        {
+          /* FIXME The below should be done in an event thread.
+             Until then...
+           */
 #if 0
-	  msleep( MILLISECONDS_PER_SEC * *p_buf );
-	  p_vcd->in_still = VLC_FALSE;
-	  dbg_print(INPUT_DBG_STILL, "still wait time done");
-#else
-	  vcdIntfStillTime(p_vcdplayer->p_intf, *p_buf);
+          msleep( MILLISECONDS_PER_SEC * *p_buf );
+          p_vcd->in_still = VLC_FALSE;
+          dbg_print(INPUT_DBG_STILL, "still wait time done");
+#else
+          vcdIntfStillTime(p_vcdplayer->p_intf, *p_buf);
 #endif

 #if 1
-	  block_Release( p_block );
-	  return NULL;
+          block_Release( p_block );
+          return NULL;
 #else
-	  memset(p_buf, 0, M2F2_SECTOR_SIZE);
-	  p_buf += 2;
-	  *p_buf = 0x01;
-	  return p_block;
+          memset(p_buf, 0, M2F2_SECTOR_SIZE);
+          p_buf += 2;
+          *p_buf = 0x01;
+          return p_block;
 #endif
-	}
-
+        }
+
       default:
       case READ_BLOCK:
-	/* Read buffer */
-	;
+        /* Read buffer */
+        ;
       }

       p_buf += M2F2_SECTOR_SIZE;
       /* Update seekpoint */
       if ( VCDINFO_ITEM_TYPE_ENTRY == p_vcdplayer->play_item.type )
       {
-	unsigned int i_entry = p_vcdplayer->play_item.num+1;
-	lsn_t        i_lsn   = vcdinfo_get_entry_lsn(p_vcdplayer->vcd, i_entry);
-	if ( p_vcdplayer->i_lsn >= i_lsn && i_lsn != VCDINFO_NULL_LSN )
+        unsigned int i_entry = p_vcdplayer->play_item.num+1;
+        lsn_t        i_lsn   = vcdinfo_get_entry_lsn(p_vcdplayer->vcd, i_entry);
+        if ( p_vcdplayer->i_lsn >= i_lsn && i_lsn != VCDINFO_NULL_LSN )
         {
-	    const track_t i_track = p_vcdplayer->i_track;
-	    p_vcdplayer->play_item.num = i_entry;
-	    dbg_print( (INPUT_DBG_LSN|INPUT_DBG_PBC), "entry change" );
-	    VCDSetOrigin( p_access,  i_lsn, i_track,
-			  &(p_vcdplayer->play_item) );
+            const track_t i_track = p_vcdplayer->i_track;
+            p_vcdplayer->play_item.num = i_entry;
+            dbg_print( (INPUT_DBG_LSN|INPUT_DBG_PBC), "entry change" );
+            VCDSetOrigin( p_access,  i_lsn, i_track,
+                          &(p_vcdplayer->play_item) );
         }
       }
     }
-
+
     return p_block;
 }

@@ -261,54 +261,54 @@
 VCDSeek( access_t * p_access, int64_t i_pos )
 {
     if (!p_access || !p_access->p_sys) return VLC_EGENERIC;
-
+
     {
       vcdplayer_t         *p_vcdplayer = (vcdplayer_t *)p_vcd_access->p_sys;
       const input_title_t *t = p_vcdplayer->p_title[p_access->info.i_title];
-      unsigned int         i_entry = VCDINFO_INVALID_ENTRY;
+      unsigned int         i_entry = VCDINFO_INVALID_ENTRY;
       int i_seekpoint;
-
+
       /* Next sector to read */
       p_access->info.i_pos = i_pos;
       p_vcdplayer->i_lsn = (i_pos / (int64_t)M2F2_SECTOR_SIZE) +
-	p_vcdplayer->track_lsn;
+                                p_vcdplayer->track_lsn;

       switch (p_vcdplayer->play_item.type) {
       case VCDINFO_ITEM_TYPE_TRACK:
       case VCDINFO_ITEM_TYPE_ENTRY:
-	break ;
+        break ;
       default:
-	p_vcdplayer->b_valid_ep = VLC_FALSE;
+        p_vcdplayer->b_valid_ep = VLC_FALSE;
       }
-
+
       /* Find entry */
       if( p_vcdplayer->b_valid_ep )
       {
-	  for( i_entry = 0 ; i_entry < p_vcdplayer->i_entries ; i_entry ++ )
-	  {
-	      if( p_vcdplayer->i_lsn < p_vcdplayer->p_entries[i_entry] )
-	      {
-		  VCDUpdateVar( p_access, i_entry, VLC_VAR_SETVALUE,
-				"chapter", _("Entry"), "Setting entry" );
-		  break;
-	      }
-	  }
-
-	  {
-	      vcdinfo_itemid_t itemid;
-	      itemid.num  = i_entry;
-	      itemid.type = VCDINFO_ITEM_TYPE_ENTRY;
-	      VCDSetOrigin(p_access, p_vcdplayer->i_lsn, p_vcdplayer->i_track,
-			   &itemid);
-	  }
-	}
-
+          for( i_entry = 0 ; i_entry < p_vcdplayer->i_entries ; i_entry ++ )
+          {
+              if( p_vcdplayer->i_lsn < p_vcdplayer->p_entries[i_entry] )
+              {
+                  VCDUpdateVar( p_access, i_entry, VLC_VAR_SETVALUE,
+                                "chapter", _("Entry"), "Setting entry" );
+                  break;
+              }
+          }
+
+          {
+              vcdinfo_itemid_t itemid;
+              itemid.num  = i_entry;
+              itemid.type = VCDINFO_ITEM_TYPE_ENTRY;
+              VCDSetOrigin(p_access, p_vcdplayer->i_lsn, p_vcdplayer->i_track,
+                           &itemid);
+          }
+        }
+
       dbg_print( (INPUT_DBG_CALL|INPUT_DBG_EXT|INPUT_DBG_SEEK),
-		 "orig %lu, cur: %lu, offset: %lld, entry %d",
-		 (long unsigned int) p_vcdplayer->origin_lsn,
-		 (long unsigned int) p_vcdplayer->i_lsn, i_pos,
-		 i_entry );
-
+                 "orig %lu, cur: %lu, offset: %lld, entry %d",
+                 (long unsigned int) p_vcdplayer->origin_lsn,
+                 (long unsigned int) p_vcdplayer->i_lsn, i_pos,
+                 i_entry );
+
       /* Find seekpoint */
       for( i_seekpoint = 0; i_seekpoint < t->i_seekpoint; i_seekpoint++ )
 	{
@@ -384,11 +384,11 @@
 		     "%s, lsn %d,  byte_offset %ld",
 		     s->psz_name, p_vcdplayer->p_entries[i],
 		     (unsigned long int) s->i_byte_offset);
-	  TAB_APPEND( p_vcdplayer->p_title[i_track-1]->i_seekpoint,
-		      p_vcdplayer->p_title[i_track-1]->seekpoint, s );
-
-	} else
-	  msg_Warn( p_access, "wrong track number found in entry points" );
+          TAB_APPEND( p_vcdplayer->p_title[i_track-1]->i_seekpoint,
+                      p_vcdplayer->p_title[i_track-1]->seekpoint, s );
+
+        } else
+          msg_Warn( p_access, "wrong track number found in entry points" );
     }
     p_vcdplayer->b_valid_ep = VLC_TRUE;
     return VLC_TRUE;
@@ -417,11 +417,11 @@

     t->i_size    = 0; /* Not sure Segments have a size associated */
     t->psz_name  = strdup(_("Segments"));
-
+
     /* We have one additional segment allocated so we can get the size
        by subtracting seg[i+1] - seg[i].
      */
-    p_vcdplayer->p_segments =
+    p_vcdplayer->p_segments =
       malloc( sizeof( lsn_t ) * (p_vcdplayer->i_segments+1) );
     if( p_vcdplayer->p_segments == NULL )
     {
@@ -432,21 +432,21 @@
     for( i = 0 ; i < p_vcdplayer->i_segments ; i++ )
     {
         char psz_segment[100];
-	seekpoint_t *s = vlc_seekpoint_New();
-	p_vcdplayer->p_segments[i] = vcdinfo_get_seg_lsn(p_vcdplayer->vcd, i);
-
-	snprintf( psz_segment, sizeof(psz_segment), "%s%02d", _("Segment "),
-		  i );
-
-	s->i_byte_offset = 0; /* Not sure what this would mean here */
-	s->psz_name  = strdup(psz_segment);
-	TAB_APPEND( t->i_seekpoint, t->seekpoint, s );
-    }
-
-    p_vcdplayer->p_segments[p_vcdplayer->i_segments] =
+        seekpoint_t *s = vlc_seekpoint_New();
+        p_vcdplayer->p_segments[i] = vcdinfo_get_seg_lsn(p_vcdplayer->vcd, i);
+
+        snprintf( psz_segment, sizeof(psz_segment), "%s%02d", _("Segment "),
+                  i );
+
+        s->i_byte_offset = 0; /* Not sure what this would mean here */
+        s->psz_name  = strdup(psz_segment);
+        TAB_APPEND( t->i_seekpoint, t->seekpoint, s );
+    }
+
+    p_vcdplayer->p_segments[p_vcdplayer->i_segments] =
       p_vcdplayer->p_segments[p_vcdplayer->i_segments-1]+
-      vcdinfo_get_seg_sector_count(p_vcdplayer->vcd,
-				   p_vcdplayer->i_segments-1);
+      vcdinfo_get_seg_sector_count(p_vcdplayer->vcd,
+                                   p_vcdplayer->i_segments-1);

     return VLC_TRUE;
 }
@@ -470,29 +470,29 @@

     {
         vcdplayer_t *p_vcdplayer = (vcdplayer_t *) p_access->p_sys;
-	track_t      i;
-
-	p_vcdplayer->i_titles = 0;
-	for( i = 1 ; i <= p_vcdplayer->i_tracks ; i++ )
+        track_t      i;
+
+        p_vcdplayer->i_titles = 0;
+        for( i = 1 ; i <= p_vcdplayer->i_tracks ; i++ )
         {
-	    input_title_t *t = p_vcdplayer->p_title[i-1] =
-	      vlc_input_title_New();
-	    char psz_track[100];
-	    uint32_t i_secsize =
-	      vcdinfo_get_track_sect_count( p_vcdplayer->vcd, i );
-
-	    snprintf( psz_track, sizeof(psz_track), "%s%02d", _("Track "),
-		      i );
-
-	    t->i_size    = (i_secsize) * (int64_t) M2F2_SECTOR_SIZE;
-	    t->psz_name  = strdup(psz_track);
-
-	    dbg_print( INPUT_DBG_MRL, "track[%d] i_size: %lld",
-		       i, t->i_size );
-
-	    p_vcdplayer->i_titles++;
-	}
-
+            input_title_t *t = p_vcdplayer->p_title[i-1] =
+              vlc_input_title_New();
+            char psz_track[100];
+            uint32_t i_secsize =
+              vcdinfo_get_track_sect_count( p_vcdplayer->vcd, i );
+
+            snprintf( psz_track, sizeof(psz_track), "%s%02d", _("Track "),
+                                                    i );
+
+            t->i_size    = (i_secsize) * (int64_t) M2F2_SECTOR_SIZE;
+            t->psz_name  = strdup(psz_track);
+
+            dbg_print( INPUT_DBG_MRL, "track[%d] i_size: %lld",
+                       i, t->i_size );
+
+            p_vcdplayer->i_titles++;
+        }
+
       return VLC_SUCCESS;
     }
 }
@@ -514,7 +514,7 @@
                "LIDs: %d", p_vcdplayer->i_lids);

     if ( 0 == p_vcdplayer->i_lids ) return VLC_FALSE;
-
+
     if (vcdinfo_read_psd (p_vcdplayer->vcd)) {

       vcdinfo_visit_lot (p_vcdplayer->vcd, VLC_FALSE);
@@ -539,22 +539,21 @@
     i_title = p_vcdplayer->i_tracks;
     for( i_lid =  1 ; i_lid <=  p_vcdplayer->i_lids ; i_lid++ )
     {
-	char psz_lid[100];
-	seekpoint_t *s = vlc_seekpoint_New();
-
-	snprintf( psz_lid, sizeof(psz_lid), "%s%02d", _("LID "),
-		  i_lid );
-
-	s->i_byte_offset = 0; /*  A lid doesn't have an offset
-				  size associated with it */
-	s->psz_name  = strdup(psz_lid);
-	TAB_APPEND( t->i_seekpoint, t->seekpoint, s );
-
+        char psz_lid[100];
+        seekpoint_t *s = vlc_seekpoint_New();
+
+        snprintf( psz_lid, sizeof(psz_lid), "%s%02d", _("LID "),
+                  i_lid );
+
+        s->i_byte_offset = 0; /*  A lid doesn't have an offset
+                                  size associated with it */
+        s->psz_name  = strdup(psz_lid);
+        TAB_APPEND( t->i_seekpoint, t->seekpoint, s );
     }

 #if DYNAMICALLY_ALLOCATED
     TAB_APPEND( p_vcdplayer->i_titles, p_vcdplayer->p_title, t );
-#else
+#else
     p_vcdplayer->p_title[p_vcdplayer->i_titles] = t;
     p_vcdplayer->i_titles++;
 #endif
@@ -579,7 +578,7 @@
       p_itemid->num = 1;
       *play_single_item = VLC_FALSE;
     }
-    else
+    else
     {
       p_itemid->type = VCDINFO_ITEM_TYPE_ENTRY;
       p_itemid->num = 0;
@@ -666,8 +665,8 @@
                                                      VLC_TRUE );
         if( NULL == cd_drives ) return NULL;
         if( cd_drives[0] == NULL )
-	{
-          cdio_free_device_list( cd_drives );
+        {
+         cdio_free_device_list( cd_drives );
           return NULL;
         }
         psz_source = strdup( cd_drives[0] );
@@ -686,27 +685,27 @@
    Set's start origin subsequent seeks/reads
 */
 void
-VCDSetOrigin( access_t *p_access, lsn_t i_lsn, track_t i_track,
-	      const vcdinfo_itemid_t *p_itemid )
+VCDSetOrigin( access_t *p_access, lsn_t i_lsn, track_t i_track,
+              const vcdinfo_itemid_t *p_itemid )
 {
   vcdplayer_t *p_vcdplayer= (vcdplayer_t *)p_access->p_sys;

   dbg_print( (INPUT_DBG_CALL|INPUT_DBG_LSN),
-             "i_lsn: %lu, track: %d", (long unsigned int) i_lsn,
-	     i_track );
+             "i_lsn: %lu, track: %d", (long unsigned int) i_lsn,
+             i_track );

   vcdplayer_set_origin(p_access, i_lsn, i_track, p_itemid);

-  p_access->info.i_pos     = ( i_lsn - p_vcdplayer->track_lsn )
+  p_access->info.i_pos     = ( i_lsn - p_vcdplayer->track_lsn )
                              * M2F2_SECTOR_SIZE;
   p_access->info.i_update |= INPUT_UPDATE_TITLE|INPUT_UPDATE_SIZE
                           |  INPUT_UPDATE_SEEKPOINT;

-
+
   switch (p_vcdplayer->play_item.type) {
-  case VCDINFO_ITEM_TYPE_ENTRY:
+  case VCDINFO_ITEM_TYPE_ENTRY:
       VCDUpdateVar( p_access, p_itemid->num, VLC_VAR_SETVALUE,
-		    "chapter", _("Entry"), "Setting entry/segment");
+                    "chapter", _("Entry"), "Setting entry/segment");
       p_access->info.i_title     = i_track-1;
       p_access->info.i_size      = p_vcdplayer->p_title[i_track-1]->i_size;
       p_access->info.i_seekpoint = p_itemid->num;
@@ -714,35 +713,35 @@

   case VCDINFO_ITEM_TYPE_SEGMENT:
       VCDUpdateVar( p_access, p_itemid->num, VLC_VAR_SETVALUE,
-		  "chapter", _("Segment"),  "Setting entry/segment");
+                  "chapter", _("Segment"),  "Setting entry/segment");
       /* The last title entry is the for segments (when segments exist
-	 and they must here. The segment seekpoints are stored after
-	 the entry seekpoints and (zeroed) lid seekpoints.
+         and they must here. The segment seekpoints are stored after
+         the entry seekpoints and (zeroed) lid seekpoints.
       */
       p_access->info.i_title     = p_vcdplayer->i_titles - 1;
       p_access->info.i_size      = 150 * M2F2_SECTOR_SIZE;
-      p_access->info.i_seekpoint = p_vcdplayer->i_entries
-	+ p_vcdplayer->i_lids + p_itemid->num;
+      p_access->info.i_seekpoint = p_vcdplayer->i_entries
+        + p_vcdplayer->i_lids + p_itemid->num;
       break;
-
-  case VCDINFO_ITEM_TYPE_TRACK:
+
+  case VCDINFO_ITEM_TYPE_TRACK:
       p_access->info.i_title     = i_track-1;
       p_access->info.i_size      = p_vcdplayer->p_title[i_track-1]->i_size;
-      p_access->info.i_seekpoint = vcdinfo_track_get_entry(p_vcdplayer->vcd,
-							   i_track);
+      p_access->info.i_seekpoint = vcdinfo_track_get_entry(p_vcdplayer->vcd,
+                                                           i_track);
       break;
   default:
-      msg_Warn( p_access, "can't set origin for play type %d",
-		p_vcdplayer->play_item.type );
+      msg_Warn( p_access, "can't set origin for play type %d",
+                p_vcdplayer->play_item.type );
   }
-
+

   VCDUpdateTitle( p_access );
-
-}
-
-/*****************************************************************************
- * vcd_Open: Opens a VCD device or file initializes, a list of
+
+}
+
+/*****************************************************************************
+ * vcd_Open: Opens a VCD device or file initializes, a list of
    tracks, segements and entry lsns and sizes and returns an opaque handle.
  *****************************************************************************/
 static vcdinfo_obj_t *
@@ -766,49 +765,48 @@
     }
     free(actual_dev);

-    /*
-       Save summary info on tracks, segments and entries...
+    /*
+       Save summary info on tracks, segments and entries...
     */
-
+
     if ( 0 < (p_vcdplayer->i_tracks = vcdinfo_get_num_tracks(p_vcdobj)) ) {
-      p_vcdplayer->track = (vcdplayer_play_item_info_t *)
-	calloc(p_vcdplayer->i_tracks, sizeof(vcdplayer_play_item_info_t));
-
-      for (i=0; i<p_vcdplayer->i_tracks; i++) {
-	unsigned int track_num=i+1;
-	p_vcdplayer->track[i].size  =
-	  vcdinfo_get_track_sect_count(p_vcdobj, track_num);
-	p_vcdplayer->track[i].start_LSN =
-	  vcdinfo_get_track_lsn(p_vcdobj, track_num);
+      p_vcdplayer->track = (vcdplayer_play_item_info_t *)
+        calloc(p_vcdplayer->i_tracks, sizeof(vcdplayer_play_item_info_t));
+
+      for (i=0; i<p_vcdplayer->i_tracks; i++) {
+        unsigned int track_num=i+1;
+        p_vcdplayer->track[i].size  =
+          vcdinfo_get_track_sect_count(p_vcdobj, track_num);
+        p_vcdplayer->track[i].start_LSN =
+          vcdinfo_get_track_lsn(p_vcdobj, track_num);
       }
-    } else
+    } else
       p_vcdplayer->track = NULL;
-
+
     if ( 0 < (p_vcdplayer->i_entries = vcdinfo_get_num_entries(p_vcdobj)) ) {
-      p_vcdplayer->entry = (vcdplayer_play_item_info_t *)
-	calloc(p_vcdplayer->i_entries, sizeof(vcdplayer_play_item_info_t));
-
-      for (i=0; i<p_vcdplayer->i_entries; i++) {
-	p_vcdplayer->entry[i].size =
-	  vcdinfo_get_entry_sect_count(p_vcdobj, i);
-	p_vcdplayer->entry[i].start_LSN = vcdinfo_get_entry_lsn(p_vcdobj, i);
+      p_vcdplayer->entry = (vcdplayer_play_item_info_t *)
+        calloc(p_vcdplayer->i_entries, sizeof(vcdplayer_play_item_info_t));
+
+      for (i=0; i<p_vcdplayer->i_entries; i++) {
+        p_vcdplayer->entry[i].size =
+          vcdinfo_get_entry_sect_count(p_vcdobj, i);
+        p_vcdplayer->entry[i].start_LSN = vcdinfo_get_entry_lsn(p_vcdobj, i);
       }
-    } else
+    } else
       p_vcdplayer->entry = NULL;
-
+
     if ( 0 < (p_vcdplayer->i_segments = vcdinfo_get_num_segments(p_vcdobj)) ) {
-      p_vcdplayer->segment = (vcdplayer_play_item_info_t *)
-	calloc(p_vcdplayer->i_segments,  sizeof(vcdplayer_play_item_info_t));
-
-      for (i=0; i<p_vcdplayer->i_segments; i++) {
-	p_vcdplayer->segment[i].size =
-	  vcdinfo_get_seg_sector_count(p_vcdobj, i);
-	p_vcdplayer->segment[i].start_LSN = vcdinfo_get_seg_lsn(p_vcdobj, i);
+      p_vcdplayer->segment = (vcdplayer_play_item_info_t *)
+        calloc(p_vcdplayer->i_segments,  sizeof(vcdplayer_play_item_info_t));
+
+      for (i=0; i<p_vcdplayer->i_segments; i++) {
+        p_vcdplayer->segment[i].size =
+          vcdinfo_get_seg_sector_count(p_vcdobj, i);
+        p_vcdplayer->segment[i].start_LSN = vcdinfo_get_seg_lsn(p_vcdobj, i);
       }
-    } else
+    } else
       p_vcdplayer->segment = NULL;
-
-
+
     return p_vcdobj;
 }

@@ -817,8 +815,8 @@
 ****************************************************************************/
 static void
 VCDUpdateVar( access_t *p_access, int i_num, int i_action,
-              const char *p_varname, char *p_label,
-	      const char *p_debug_label)
+              const char *p_varname, char *p_label,
+              const char *p_debug_label)
 {
   vlc_value_t val;
   val.i_int = i_num;
@@ -896,18 +894,18 @@
                psz_source, p_access->psz_path );

     p_vcdplayer->psz_source        = strdup(psz_source);
-    p_vcdplayer->i_debug           = config_GetInt( p_this,
-					      MODULE_STRING "-debug" );
-    p_vcdplayer->i_blocks_per_read = config_GetInt( p_this, MODULE_STRING
-					      "-blocks-per-read" );
+    p_vcdplayer->i_debug           = config_GetInt( p_this,
+                                                  MODULE_STRING "-debug" );
+    p_vcdplayer->i_blocks_per_read = config_GetInt( p_this, MODULE_STRING
+                                                    "-blocks-per-read" );
     p_vcdplayer->in_still          = VLC_FALSE;
     p_vcdplayer->play_item.type    = VCDINFO_ITEM_TYPE_NOTFOUND;
-    p_vcdplayer->p_input           = vlc_object_find( p_access,
-						      VLC_OBJECT_INPUT,
-						      FIND_PARENT );
-    p_vcdplayer->p_demux           = vlc_object_find( p_access,
-						      VLC_OBJECT_DEMUX,
-						      FIND_PARENT );
+    p_vcdplayer->p_input           = vlc_object_find( p_access,
+                                                      VLC_OBJECT_INPUT,
+                                                      FIND_PARENT );
+    p_vcdplayer->p_demux           = vlc_object_find( p_access,
+                                                      VLC_OBJECT_DEMUX,
+                                                      FIND_PARENT );
     p_vcdplayer->p_meta            = vlc_meta_New();
     p_vcdplayer->p_segments        = NULL;
     p_vcdplayer->p_entries         = NULL;
@@ -921,7 +919,7 @@
     }

     p_vcdplayer->b_svd= (vlc_bool_t) vcdinfo_get_tracksSVD(p_vcdplayer->vcd);;
-
+
     /* Get track information. */
     p_vcdplayer->i_tracks = vcdinfo_get_num_tracks(p_vcdplayer->vcd);

@@ -930,7 +928,7 @@
         LOG_ERR ("no movie tracks found" );
         goto err_exit;
     }
-
+
     /* Build Navigation Title table for the tracks. */
     VCDTitles( p_access );

@@ -948,9 +946,9 @@
     }

     /* Do we set PBC (via LID) on? */
-    p_vcdplayer->i_lid =
-      ( VCDINFO_ITEM_TYPE_LID == itemid.type
-	&& p_vcdplayer->i_lids > itemid.num )
+    p_vcdplayer->i_lid =
+      ( VCDINFO_ITEM_TYPE_LID == itemid.type
+        && p_vcdplayer->i_lids > itemid.num )
       ? itemid.num
       :  VCDINFO_INVALID_ENTRY;

@@ -963,10 +961,10 @@

 #if FIXED
     if (play_single_item)
-      VCDFixupPlayList( p_access, p_vcd, psz_source, &itemid,
-			play_single_item );
+      VCDFixupPlayList( p_access, p_vcd, psz_source, &itemid,
+                        play_single_item );
 #endif
-
+
     p_vcdplayer->p_intf = intf_Create( p_access, "vcdx" );
     p_vcdplayer->p_intf->b_block = VLC_FALSE;
     p_vcdplayer->p_access = p_access;
@@ -979,6 +977,8 @@

     return VLC_SUCCESS;
  err_exit:
+    if( p_vcdplayer->p_input ) vlc_object_release( p_vcdplayer->p_input );
+    if( p_vcdplayer->p_demux ) vlc_object_release( p_vcdplayer->p_demux );
     free( psz_source );
     free( p_vcdplayer );
     return VLC_EGENERIC;
@@ -996,13 +996,17 @@
     dbg_print( (INPUT_DBG_CALL|INPUT_DBG_EXT), "VCDClose" );

     vcdinfo_close( p_vcdplayer->vcd );
+
+    if( p_vcdplayer->p_input ) vlc_object_release( p_vcdplayer->p_input );
+    if( p_vcdplayer->p_demux ) vlc_object_release( p_vcdplayer->p_demux );
+

     FREE_AND_NULL( p_vcdplayer->p_entries );
     FREE_AND_NULL( p_vcdplayer->p_segments );
     FREE_AND_NULL( p_vcdplayer->psz_source );
     FREE_AND_NULL( p_vcdplayer->track );
     FREE_AND_NULL( p_vcdplayer->segment );
-    FREE_AND_NULL( p_vcdplayer->entry );
+    FREE_AND_NULL( p_vcdplayer->entry );

     free( p_vcdplayer );
     p_access->p_sys = NULL;
@@ -1026,83 +1030,83 @@
     switch( i_query )
     {
         /* Pass back a copy of meta information that was gathered when we
-	   during the Open/Initialize call.
-	 */
+           during the Open/Initialize call.
+         */
         case ACCESS_GET_META:
-	  {
-	    vlc_meta_t **pp_meta = (vlc_meta_t**)va_arg( args, vlc_meta_t** );
-
-	    dbg_print( INPUT_DBG_EVENT, "get meta info" );
-
-	    if ( p_vcdplayer->p_meta ) {
-	      *pp_meta = vlc_meta_Duplicate( p_vcdplayer->p_meta );
-	      dbg_print( INPUT_DBG_META, "%s", "Meta copied" );
-	    } else
-	      msg_Warn( p_access, "tried to copy NULL meta info" );
-
-	    return VLC_SUCCESS;
-	  }
-	  return VLC_EGENERIC;
+        {
+            vlc_meta_t **pp_meta = (vlc_meta_t**)va_arg( args, vlc_meta_t** );
+
+            dbg_print( INPUT_DBG_EVENT, "get meta info" );
+
+            if ( p_vcdplayer->p_meta ) {
+              *pp_meta = vlc_meta_Duplicate( p_vcdplayer->p_meta );
+              dbg_print( INPUT_DBG_META, "%s", "Meta copied" );
+            } else
+              msg_Warn( p_access, "tried to copy NULL meta info" );
+
+            return VLC_SUCCESS;
+          }
+          return VLC_EGENERIC;

         case ACCESS_CAN_SEEK:
         case ACCESS_CAN_FASTSEEK:
         case ACCESS_CAN_PAUSE:
-        case ACCESS_CAN_CONTROL_PACE:
-	  {
+        case ACCESS_CAN_CONTROL_PACE:
+        {
             vlc_bool_t *pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t* );

-	    dbg_print( INPUT_DBG_EVENT,
-		       "seek/fastseek/pause/can_control_pace" );
+            dbg_print( INPUT_DBG_EVENT,
+                       "seek/fastseek/pause/can_control_pace" );
             *pb_bool = VLC_TRUE;
-	    return VLC_SUCCESS;
+            return VLC_SUCCESS;
             break;
-	  }
+          }

         /* */
         case ACCESS_GET_MTU:
             pi_int = (int*)va_arg( args, int * );
             *pi_int = (p_vcdplayer->i_blocks_per_read * M2F2_SECTOR_SIZE);
-	    dbg_print( INPUT_DBG_EVENT, "GET MTU: %d", *pi_int );
+            dbg_print( INPUT_DBG_EVENT, "GET MTU: %d", *pi_int );
             break;

         case ACCESS_GET_PTS_DELAY:
-	  {
-	    int64_t *pi_64 = (int64_t*)va_arg( args, int64_t * );
+        {
+            int64_t *pi_64 = (int64_t*)va_arg( args, int64_t * );
             *pi_64 = var_GetInteger( p_access, MODULE_STRING "-caching" )
-	      * MILLISECONDS_PER_SEC;
-	    dbg_print( INPUT_DBG_EVENT, "GET PTS DELAY" );
-	    return VLC_SUCCESS;
+              * MILLISECONDS_PER_SEC;
+            dbg_print( INPUT_DBG_EVENT, "GET PTS DELAY" );
+            return VLC_SUCCESS;
             break;
-	  }
+        }

         /* */
         case ACCESS_SET_PAUSE_STATE:
-	    dbg_print( INPUT_DBG_EVENT, "SET PAUSE STATE" );
-	    return VLC_SUCCESS;
+            dbg_print( INPUT_DBG_EVENT, "SET PAUSE STATE" );
+            return VLC_SUCCESS;
             break;

         case ACCESS_GET_TITLE_INFO:
-	  {
-	    unsigned int psz_mrl_max = strlen(VCD_MRL_PREFIX)
-	      + strlen(p_vcdplayer->psz_source) + sizeof("@E999")+3;
-	    input_title_t ***ppp_title
-	      = (input_title_t***)va_arg( args, input_title_t*** );
-	    char *psz_mrl = malloc( psz_mrl_max );
-	    unsigned int i;
+        {
+            unsigned int psz_mrl_max = strlen(VCD_MRL_PREFIX)
+              + strlen(p_vcdplayer->psz_source) + sizeof("@E999")+3;
+            input_title_t ***ppp_title
+              = (input_title_t***)va_arg( args, input_title_t*** );
+            char *psz_mrl = malloc( psz_mrl_max );
+            unsigned int i;

             pi_int    = (int*)va_arg( args, int* );

-	    dbg_print( INPUT_DBG_EVENT, "GET TITLE: i_titles %d",
-		       p_vcdplayer->i_titles );
-
-	    if( psz_mrl == NULL ) {
-	       msg_Warn( p_access, "out of memory" );
-	    } else {
-  	       snprintf(psz_mrl, psz_mrl_max, "%s%s",
-			VCD_MRL_PREFIX, p_vcdplayer->psz_source);
-	       VCDMetaInfo( p_access, psz_mrl );
-	       free(psz_mrl);
-	    }
+            dbg_print( INPUT_DBG_EVENT, "GET TITLE: i_titles %d",
+                       p_vcdplayer->i_titles );
+
+            if( psz_mrl == NULL ) {
+               msg_Warn( p_access, "out of memory" );
+            } else {
+               snprintf(psz_mrl, psz_mrl_max, "%s%s",
+                        VCD_MRL_PREFIX, p_vcdplayer->psz_source);
+               VCDMetaInfo( p_access, psz_mrl );
+               free(psz_mrl);
+            }

             /* Duplicate title info */
             if( p_vcdplayer->i_titles == 0 )
@@ -1111,40 +1115,40 @@
                 return VLC_SUCCESS;
             }
             *pi_int = p_vcdplayer->i_titles;
-            *ppp_title = malloc( sizeof( input_title_t **)
-				 * p_vcdplayer->i_titles );
-
-	    if (!*ppp_title) return VLC_ENOMEM;
-
-	    for( i = 0; i < p_vcdplayer->i_titles; i++ )
-	    {
-		if ( p_vcdplayer->p_title[i] )
-		  (*ppp_title)[i] =
-		    vlc_input_title_Duplicate( p_vcdplayer->p_title[i] );
-	    }
-	  }
-	  break;
+            *ppp_title = malloc( sizeof( input_title_t **)
+                                         * p_vcdplayer->i_titles );
+
+            if (!*ppp_title) return VLC_ENOMEM;
+
+            for( i = 0; i < p_vcdplayer->i_titles; i++ )
+            {
+                if ( p_vcdplayer->p_title[i] )
+                  (*ppp_title)[i] =
+                    vlc_input_title_Duplicate( p_vcdplayer->p_title[i] );
+            }
+          }
+          break;

         case ACCESS_SET_TITLE:
             i = (int)va_arg( args, int );

-	    dbg_print( INPUT_DBG_EVENT, "set title %d" , i);
+            dbg_print( INPUT_DBG_EVENT, "set title %d" , i);
             if( i != p_access->info.i_title )
             {
-	        vcdinfo_itemid_t itemid;
-		track_t          i_track = i+1;
-		unsigned int     i_entry =
-		  vcdinfo_track_get_entry( p_vcdplayer->vcd, i_track);
-
-		/* FIXME! For now we are assuming titles are only
-		 tracks and that track == title+1 */
-		itemid.num = i_track;
-		itemid.type = VCDINFO_ITEM_TYPE_TRACK;
-
-		VCDSetOrigin(p_access,
-			     vcdinfo_get_entry_lsn(p_vcdplayer->vcd, i_entry),
-			     i_track, &itemid );
-	    }
+                vcdinfo_itemid_t itemid;
+                track_t          i_track = i+1;
+                unsigned int     i_entry =
+                  vcdinfo_track_get_entry( p_vcdplayer->vcd, i_track);
+
+                /* FIXME! For now we are assuming titles are only
+                 tracks and that track == title+1 */
+                itemid.num = i_track;
+                itemid.type = VCDINFO_ITEM_TYPE_TRACK;
+
+                VCDSetOrigin(p_access,
+                     vcdinfo_get_entry_lsn(p_vcdplayer->vcd, i_entry),
+                             i_track, &itemid );
+            }
             break;

         case ACCESS_SET_SEEKPOINT:
@@ -1152,50 +1156,50 @@
             input_title_t *t = p_vcdplayer->p_title[p_access->info.i_title];
             unsigned int i = (unsigned int)va_arg( args, unsigned int );

-	    dbg_print( INPUT_DBG_EVENT, "set seekpoint %d", i );
+            dbg_print( INPUT_DBG_EVENT, "set seekpoint %d", i );
             if( t->i_seekpoint > 0 )
             {
-		track_t i_track = p_access->info.i_title+1;
-		lsn_t lsn;
-
-		/* FIXME! For now we are assuming titles are only
-		 tracks and that track == title+1 and we the play
-		 item is entries (not tracks or lids).
-		 We need to generalize all of this.
-		*/
-
-		if (i < p_vcdplayer->i_entries)
-		{
-		    p_vcdplayer->play_item.num  = i;
-		    p_vcdplayer->play_item.type = VCDINFO_ITEM_TYPE_ENTRY;
-		    lsn = vcdinfo_get_entry_lsn(p_vcdplayer->vcd, i);
-		} else if ( i < p_vcdplayer->i_entries + p_vcdplayer->i_lids )
-		{
-		    p_vcdplayer->play_item.num  = i
-		      = i - p_vcdplayer->i_entries;
-		    p_vcdplayer->play_item.type = VCDINFO_ITEM_TYPE_LID;
-		    lsn = 0;
-		} else
-		{
-		    p_vcdplayer->play_item.num  = i
-		      = i - p_vcdplayer->i_entries - p_vcdplayer->i_lids;
-		    p_vcdplayer->play_item.type = VCDINFO_ITEM_TYPE_SEGMENT;
-		    lsn = vcdinfo_get_seg_lsn(p_vcdplayer->vcd, i);
-		}
-
-		VCDSetOrigin( p_access,
-			      vcdinfo_get_entry_lsn(p_vcdplayer->vcd, i),
-			      i_track, &(p_vcdplayer->play_item) );
+                track_t i_track = p_access->info.i_title+1;
+                lsn_t lsn;
+
+                /* FIXME! For now we are assuming titles are only
+                 tracks and that track == title+1 and we the play
+                 item is entries (not tracks or lids).
+                 We need to generalize all of this.
+                */
+
+                if (i < p_vcdplayer->i_entries)
+                {
+                    p_vcdplayer->play_item.num  = i;
+                    p_vcdplayer->play_item.type = VCDINFO_ITEM_TYPE_ENTRY;
+                    lsn = vcdinfo_get_entry_lsn(p_vcdplayer->vcd, i);
+                } else if ( i < p_vcdplayer->i_entries + p_vcdplayer->i_lids )
+                {
+                    p_vcdplayer->play_item.num  = i
+                      = i - p_vcdplayer->i_entries;
+                    p_vcdplayer->play_item.type = VCDINFO_ITEM_TYPE_LID;
+                    lsn = 0;
+                } else
+                {
+                    p_vcdplayer->play_item.num  = i
+                      = i - p_vcdplayer->i_entries - p_vcdplayer->i_lids;
+                    p_vcdplayer->play_item.type = VCDINFO_ITEM_TYPE_SEGMENT;
+                    lsn = vcdinfo_get_seg_lsn(p_vcdplayer->vcd, i);
+                }
+
+                VCDSetOrigin( p_access,
+                              vcdinfo_get_entry_lsn(p_vcdplayer->vcd, i),
+                              i_track, &(p_vcdplayer->play_item) );
             }
             return VLC_SUCCESS;
         }

         case ACCESS_SET_PRIVATE_ID_STATE:
-	    dbg_print( INPUT_DBG_EVENT, "set private id" );
+            dbg_print( INPUT_DBG_EVENT, "set private id" );
             return VLC_EGENERIC;

         default:
-	  msg_Warn( p_access, "unimplemented query in control" );
+          msg_Warn( p_access, "unimplemented query in control" );
             return VLC_EGENERIC;

     }


File output : add a sync option

File output : add a sync option

--- modules/access_output/file.c
+++ modules/access_output/file.c
@@ -63,6 +63,8 @@
 #define APPEND_TEXT N_("Append to file")
 #define APPEND_LONGTEXT N_( "Append to file if it exists instead " \
                             "of replacing it.")
+#define SYNC_TEXT N_("Synchronous writing")
+#define SYNC_LONGTEXT N_( "Open the file with synchronous writing.")

 vlc_module_begin ()
     set_description( N_("File stream output") )
@@ -74,6 +76,8 @@
     add_shortcut( "stream" )
     add_bool( SOUT_CFG_PREFIX "append", false, NULL, APPEND_TEXT,APPEND_LONGTEXT,
               true )
+    add_bool( SOUT_CFG_PREFIX "sync", false, NULL, SYNC_TEXT,SYNC_LONGTEXT,
+              false )
     set_callbacks( Open, Close )
 vlc_module_end ()

@@ -82,7 +86,7 @@
  * Exported prototypes
  *****************************************************************************/
 static const char *const ppsz_sout_options[] = {
-    "append", NULL
+    "append", "sync", NULL
 };

 static ssize_t Write( sout_access_out_t *, block_t * );
@@ -102,6 +106,7 @@
 {
     sout_access_out_t   *p_access = (sout_access_out_t*)p_this;
     int                 fd;
+    bool                sync;

     config_ChainParse( p_access, SOUT_CFG_PREFIX, ppsz_sout_options, p_access->p_cfg );

@@ -112,6 +117,7 @@
     }

     bool append = var_GetBool( p_access, SOUT_CFG_PREFIX "append" );
+    sync = var_GetBool( p_access, SOUT_CFG_PREFIX "sync" );

     if( !strcmp( p_access->psz_path, "-" ) )
     {
@@ -132,6 +138,9 @@
         path_sanitize( psz_tmp );

         fd = vlc_open( psz_tmp, O_RDWR | O_CREAT | O_LARGEFILE |
+#ifdef O_SYNC
+                        (sync ? O_SYNC : 0) |
+#endif
                         (append ? 0 : O_TRUNC), 0666 );
         free( psz_tmp );
     }


Add ITreeNode recurse functions for one, two arguments

--HG--
branch : SceneOverhaul

--- ionCore/ionTreeNode.h
+++ ionCore/ionTreeNode.h
@@ -68,6 +68,20 @@
 			(Child->*Function)();
 	}

+	template <typename Return, typename P1>
+	void RecurseOnChildren(Return (Implementation::* Function)(P1), P1 p1)
+	{
+		for (auto Child : Children)
+			(Child->*Function)(p1);
+	}
+
+	template <typename Return, typename P1, typename P2>
+	void RecurseOnChildren(Return (Implementation::* Function)(P1, P2), P1 p1, P2 p2)
+	{
+		for (auto Child : Children)
+			(Child->*Function)(p1, p2);
+	}
+
 protected:

 	ITreeNode()


fixed macro bug

fixed macro bug

fixed bug in macro

--- c_aacgmv2/src/mlt_v2.c
+++ c_aacgmv2/src/mlt_v2.c
@@ -7,7 +7,7 @@
 #include "astalg.h"

 #ifndef isfinite
-#define isfinite(fpclassify(x) != FP_NAN && fpclassify(x) != FP_INFINITE)
+#define isfinite fpclassify(x) != FP_NAN && fpclassify(x) != FP_INFINITE
 #endif

 /*-----------------------------------------------------------------------------


Code Scrub: Corrected some retvals according to the spec.

git-svn-id: 5648d1bec6962b0a6d1d1b40eba8cf5cdb62da3d@6574 6f19259b-4bc3-4df7-8a09-765794883524

--- MdePkg/Include/Library/UefiScsiLib.h
+++ MdePkg/Include/Library/UefiScsiLib.h
@@ -351,15 +351,16 @@
   @param[in, out] DataLength           The length of data buffer.
   @param[in]      PMI                  Partial medium indicator.

-  @retval  EFI_SUCCESS                Command is executed successfully.
-  @retval  EFI_WARN_BUFFER_TOO_SMALL  The SCSI Request Packet was executed, but the entire DataBuffer could
-                                      not be transferred. The actual number of bytes transferred is returned in DataLength.
-  @retval  EFI_NOT_READY              The SCSI Request Packet could not be sent because there are too many
-                                      SCSI Command Packets already queued.
-  @retval  EFI_DEVICE_ERROR           A device error occurred while attempting to send SCSI Request Packet.
-  @retval  EFI_UNSUPPORTED            The command described by the SCSI Request Packet is not supported by
-                                      the SCSI initiator(i.e., SCSI  Host Controller)
-  @retval  EFI_TIMEOUT                A timeout occurred while waiting for the SCSI Request Packet to execute.
+  @retval  EFI_SUCCESS           Command is executed successfully.
+  @retval  EFI_BAD_BUFFER_SIZE   The SCSI Request Packet was executed, but the entire
+                                 DataBuffer could not be transferred. The actual
+                                 number of bytes transferred is returned in DataLength.
+  @retval  EFI_NOT_READY         The SCSI Request Packet could not be sent because
+                                 there are too many SCSI Command Packets already queued.
+  @retval  EFI_DEVICE_ERROR      A device error occurred while attempting to send SCSI Request Packet.
+  @retval  EFI_UNSUPPORTED       The command described by the SCSI Request Packet
+                                 is not supported by the SCSI initiator(i.e., SCSI  Host Controller)
+  @retval  EFI_TIMEOUT           A timeout occurred while waiting for the SCSI Request Packet to execute.

 **/
 EFI_STATUS
@@ -403,15 +404,15 @@
   @param[in]      StartLba             The start address of LBA.
   @param[in]      SectorSize           The sector size.

-  @retval  EFI_SUCCESS                Command is executed successfully.
-  @retval  EFI_WARN_BUFFER_TOO_SMALL  The SCSI Request Packet was executed, but the entire DataBuffer could
-                                      not be transferred. The actual number of bytes transferred is returned in DataLength.
-  @retval  EFI_NOT_READY              The SCSI Request Packet could not be sent because there are too many
-                                      SCSI Command Packets already queued.
-  @retval  EFI_DEVICE_ERROR           A device error occurred while attempting to send SCSI Request Packet.
-  @retval  EFI_UNSUPPORTED            The command described by the SCSI Request Packet is not supported by
-                                      the SCSI initiator(i.e., SCSI  Host Controller)
-  @retval  EFI_TIMEOUT                A timeout occurred while waiting for the SCSI Request Packet to execute.
+  @retval  EFI_SUCCESS          Command is executed successfully.
+  @retval  EFI_BAD_BUFFER_SIZE  The SCSI Request Packet was executed, but the entire DataBuffer could
+                                not be transferred. The actual number of bytes transferred is returned in DataLength.
+  @retval  EFI_NOT_READY        The SCSI Request Packet could not be sent because there are too many
+                                SCSI Command Packets already queued.
+  @retval  EFI_DEVICE_ERROR     A device error occurred while attempting to send SCSI Request Packet.
+  @retval  EFI_UNSUPPORTED      The command described by the SCSI Request Packet is not supported by
+                                the SCSI initiator(i.e., SCSI  Host Controller)
+  @retval  EFI_TIMEOUT          A timeout occurred while waiting for the SCSI Request Packet to execute.

 **/
 EFI_STATUS
@@ -455,15 +456,15 @@
   @param[in]      StartLba             The start address of LBA.
   @param[in]      SectorSize           The sector size.

-  @retval  EFI_SUCCESS                Command is executed successfully.
-  @retval  EFI_WARN_BUFFER_TOO_SMALL  The SCSI Request Packet was executed, but the entire DataBuffer could
-                                      not be transferred. The actual number of bytes transferred is returned in DataLength.
-  @retval  EFI_NOT_READY              The SCSI Request Packet could not be sent because there are too many
-                                      SCSI Command Packets already queued.
-  @retval  EFI_DEVICE_ERROR           A device error occurred while attempting to send SCSI Request Packet.
-  @retval  EFI_UNSUPPORTED            The command described by the SCSI Request Packet is not supported by
-                                      the SCSI initiator(i.e., SCSI  Host Controller)
-  @retval  EFI_TIMEOUT                A timeout occurred while waiting for the SCSI Request Packet to execute.
+  @retval  EFI_SUCCESS          Command is executed successfully.
+  @retval  EFI_BAD_BUFFER_SIZE  The SCSI Request Packet was executed, but the entire DataBuffer could
+                                not be transferred. The actual number of bytes transferred is returned in DataLength.
+  @retval  EFI_NOT_READY        The SCSI Request Packet could not be sent because there are too many
+                                SCSI Command Packets already queued.
+  @retval  EFI_DEVICE_ERROR     A device error occurred while attempting to send SCSI Request Packet.
+  @retval  EFI_UNSUPPORTED      The command described by the SCSI Request Packet is not supported by
+                                the SCSI initiator(i.e., SCSI  Host Controller)
+  @retval  EFI_TIMEOUT          A timeout occurred while waiting for the SCSI Request Packet to execute.

 **/
 EFI_STATUS


First steps towards integrating coreaudio and auhal module into one. It does not actually render digital audio yet.

--- modules/audio_output/auhal.c
+++ modules/audio_output/auhal.c
@@ -40,6 +40,13 @@
 #include <AudioToolbox/AudioFormat.h>

 #define STREAM_FORMAT_MSG( pre, sfm ) \
+    pre "[%ld][%4.4s][%ld][%ld][%ld][%ld][%ld][%ld]", \
+    (UInt32)sfm.mSampleRate, (char *)&sfm.mFormatID, \
+    sfm.mFormatFlags, sfm.mBytesPerPacket, \
+    sfm.mFramesPerPacket, sfm.mBytesPerFrame, \
+    sfm.mChannelsPerFrame, sfm.mBitsPerChannel
+
+#define STREAM_FORMAT_MSG_FULL( pre, sfm ) \
     pre ":\nsamplerate: [%ld]\nFormatID: [%4.4s]\nFormatFlags: [%ld]\nBypesPerPacket: [%ld]\nFramesPerPacket: [%ld]\nBytesPerFrame: [%ld]\nChannelsPerFrame: [%ld]\nBitsPerChannel[%ld]", \
     (UInt32)sfm.mSampleRate, (char *)&sfm.mFormatID, \
     sfm.mFormatFlags, sfm.mBytesPerPacket, \
@@ -47,6 +54,7 @@
     sfm.mChannelsPerFrame, sfm.mBitsPerChannel

 #define BUFSIZE 0xffffff
+#define AOUT_VAR_SPDIF_FLAG 0xf0000000

 /*****************************************************************************
  * aout_sys_t: private audio output method descriptor
@@ -64,26 +72,24 @@
     Component                   au_component;   /* The Audiocomponent we use */
     AudioUnit                   au_unit;        /* The AudioUnit we use */
     mtime_t                     clock_diff;
-    uint8_t                      p_remainder_buffer[BUFSIZE];
+    uint8_t                     p_remainder_buffer[BUFSIZE];
     uint32_t                    i_read_bytes;
     uint32_t                    i_total_bytes;
-    audio_date_t                end_date_t;
-
-
 };

 /*****************************************************************************
  * Local prototypes.
  *****************************************************************************/
 static int      Open                    ( vlc_object_t * );
+int             OpenAnalog              ( aout_instance_t * );
+int             OpenSPDIF               ( aout_instance_t * );
 static void     Close                   ( vlc_object_t * );

-static void     Play                    ( aout_instance_t *);
-
-static int      Probe                   ( aout_instance_t * );
-static int      DeviceDigitalMode       ( aout_instance_t *, AudioDeviceID );
+static void     Play                    ( aout_instance_t * );
+static void     Probe                   ( aout_instance_t * );
+
+int             AudioDeviceSupportsDigital( aout_instance_t *, AudioDeviceID );
 int             AudioDeviceHasOutput    ( AudioDeviceID );
-static int      DigitalInit             ( aout_instance_t * );

 static OSStatus RenderCallbackAnalog    ( vlc_object_t *, AudioUnitRenderActionFlags *, const AudioTimeStamp *,
                                           unsigned int, unsigned int, AudioBufferList *);
@@ -104,7 +110,7 @@
     set_category( CAT_AUDIO );
     set_subcategory( SUBCAT_AUDIO_AOUT );
     set_callbacks( Open, Close );
-    //add_integer( "coreaudio-dev", -1, NULL, ADEV_TEXT, ADEV_LONGTEXT, VLC_FALSE );
+    //add_integer( "macosx-audio-device", -1, NULL, ADEV_TEXT, ADEV_LONGTEXT, VLC_FALSE );
 vlc_module_end();

 /*****************************************************************************
@@ -113,25 +119,33 @@
 static int Open( vlc_object_t * p_this )
 {
     OSStatus                err = noErr;
-    ComponentDescription    desc;
-    UInt32                  i_param_size,i;
-    struct aout_sys_t       *p_sys;
+    UInt32                  i_param_size = 0, i_hog = 0;
+    struct aout_sys_t       *p_sys = NULL;
+    vlc_bool_t              b_alive = VLC_FALSE;
     vlc_value_t             val;
     aout_instance_t         *p_aout = (aout_instance_t *)p_this;

     /* Allocate structure */
-    p_sys = (struct aout_sys_t *)malloc( sizeof( struct aout_sys_t ) );
-    if( p_sys == NULL )
+    p_aout->output.p_sys = malloc( sizeof( aout_sys_t ) );
+    if( p_aout->output.p_sys == NULL )
     {
         msg_Err( p_aout, "out of memory" );
         return( VLC_ENOMEM );
     }

-    memset( p_sys, 0, sizeof( struct aout_sys_t ) );
-
-    p_sys->b_digital = VLC_FALSE; /* We assume we are not digital */
-
-    p_aout->output.p_sys = p_sys;
+    p_sys = p_aout->output.p_sys;
+    p_sys->i_default_dev = 0;
+    p_sys->i_selected_dev = 0;
+    p_sys->i_devices = 0;
+    p_sys->b_supports_digital = VLC_FALSE;
+    p_sys->b_digital = VLC_FALSE;
+    p_sys->au_component = NULL;
+    p_sys->au_unit = NULL;
+    p_sys->clock_diff = (mtime_t) 0;
+    p_sys->i_read_bytes = 0;
+    p_sys->i_total_bytes = 0;
+    memset( p_sys->p_remainder_buffer, 0, sizeof(uint8_t) * BUFSIZE );
+
     p_aout->output.pf_play = Play;

     aout_FormatPrint( p_aout, "VLC is looking for:\n", (audio_sample_format_t *)&p_aout->output.output );
@@ -140,46 +154,91 @@
     if( var_Type( p_aout, "audio-device" ) == 0 )
     {
         Probe( p_aout );
-        /*if( Probe( p_aout ) != VLC_SUCCESS );
-        {
-            msg_Err( p_aout, "Probe failed" );
-            free( p_sys );
-            return VLC_EGENERIC;
-        }*/
-    }
-
+    }
+
     /* What device do we want? */
     if( var_Get( p_aout, "audio-device", &val ) < 0 )
     {
-        msg_Err( p_aout, "audio-device var does not exist" );
+        msg_Err( p_aout, "audio-device var does not exist. device probe failed." );
         free( p_sys );
         return( VLC_ENOVAR );
     }
-    p_sys->i_selected_dev = val.i_int;
-
-    /* what is vlc format? if digital, take digital route else AUHAL route */
-    DeviceDigitalMode( p_aout, p_sys->i_selected_dev );
-    /*if( DeviceDigitalMode( p_aout, p_sys->i_selected_dev ) != VLC_SUCCESS );
-    {
-        msg_Err( p_aout, "DeviceDigitalMode failed" );
+
+    p_sys->i_selected_dev = val.i_int & ~AOUT_VAR_SPDIF_FLAG;
+    p_sys->b_supports_digital = ( val.i_int & AOUT_VAR_SPDIF_FLAG ) ? VLC_TRUE : VLC_FALSE;
+
+    /* Check if the desired device is alive and usable */
+    i_param_size = sizeof( b_alive );
+    err = AudioDeviceGetProperty( p_sys->i_selected_dev, 0, FALSE,
+                                  kAudioDevicePropertyDeviceIsAlive,
+                                  &i_param_size, &b_alive );
+
+    if( err != noErr )
+    {
+        msg_Err( p_aout, "could not check whether device is alive: %4.4s",
+                 (char *)&err );
+        return VLC_EGENERIC;
+    }
+
+    if( b_alive == VLC_FALSE )
+    {
+        msg_Err( p_aout, "Selected audio device is not alive" );
+        var_Destroy( p_aout, "audio-device" );
         free( p_sys );
         return VLC_EGENERIC;
     }
-    */
-
+
+    i_param_size = sizeof( i_hog );
+    err = AudioDeviceGetProperty( p_sys->i_selected_dev, 0, FALSE,
+                                  kAudioDevicePropertyHogMode,
+                                  &i_param_size, &i_hog );
+
+    if( err != noErr )
+    {
+        msg_Err( p_aout, "could not check whether device is hogged: %4.4s",
+                 (char *)&err );
+        return VLC_EGENERIC;
+    }
+
+    if( i_hog != -1 )
+    {
+        msg_Err( p_aout, "Selected audio device is exclusively in use by another program" );
+        var_Destroy( p_aout, "audio-device" );
+        free( p_sys );
+        return VLC_EGENERIC;
+    }
+
+    /* Check for Digital mode or Analog output mode */
     if( AOUT_FMT_NON_LINEAR( &p_aout->output.output ) && p_sys->b_supports_digital )
     {
-        p_sys->b_digital = VLC_TRUE;
-        p_aout->output.output.i_format = VLC_FOURCC('s','p','d','i');
-        msg_Dbg( p_aout, "we found a digital stream, and we WANT a digital stream" );
-    }
-    else if( AOUT_FMT_NON_LINEAR( &p_aout->output.output ) && !p_sys->b_supports_digital )
+        if( OpenSPDIF( p_aout ) )
+            return VLC_SUCCESS;
+    }
+    else
+    {
+        if( OpenAnalog( p_aout ) )
+            return VLC_SUCCESS;
+    }
+
+    /* If we reach this, the Open* failed */
+    var_Destroy( p_aout, "audio-device" );
+    free( p_sys );
+    return VLC_EGENERIC;
+}
+
+int OpenAnalog( aout_instance_t *p_aout )
+{
+    struct aout_sys_t       *p_sys = p_aout->output.p_sys;
+    OSStatus                err = noErr;
+    UInt32                  i_param_size = 0, i = 0;
+    ComponentDescription    desc;
+
+    if( AOUT_FMT_NON_LINEAR( &p_aout->output.output ) && !p_sys->b_supports_digital )
     {
         msg_Dbg( p_aout, "we had requested a digital stream, but it's not possible for this device" );
     }
-
+
     /* If analog only start setting up AUHAL */
-
     /* Lets go find our Component */
     desc.componentType = kAudioUnitType_Output;
     desc.componentSubType = kAudioUnitSubType_HALOutput;
@@ -191,17 +250,14 @@
     if( p_sys->au_component == NULL )
     {
         msg_Err( p_aout, "we cannot find our HAL component" );
-        free( p_sys );
-        return VLC_EGENERIC;
+        return VLC_FALSE;
     }

     err = OpenAComponent( p_sys->au_component, &p_sys->au_unit );
     if( err )
     {
-
         msg_Err( p_aout, "we cannot find our HAL component" );
-        free( p_sys );
-        return VLC_EGENERIC;
+        return VLC_FALSE;
     }

     /* Enable IO for the component */
@@ -226,7 +282,7 @@
                                    &DeviceFormat,
                                    &i_param_size ));

-    msg_Dbg( p_aout, STREAM_FORMAT_MSG( "current format is " , DeviceFormat ) );
+    msg_Dbg( p_aout, STREAM_FORMAT_MSG( "current format is: " , DeviceFormat ) );

     /* Get the channel layout */
     AudioChannelLayout *layout;
@@ -473,38 +529,14 @@
     verify_noerr( AudioUnitInitialize(p_sys->au_unit) );

     verify_noerr( AudioOutputUnitStart(p_sys->au_unit) );
-    return( VLC_SUCCESS );
+
+    return VLC_TRUE;
 }

 /*****************************************************************************
- * Close: Close HAL AudioUnit
- *****************************************************************************/
-static void Close( vlc_object_t * p_this )
-{
-    aout_instance_t     *p_aout = (aout_instance_t *)p_this;
-    struct aout_sys_t   *p_sys = p_aout->output.p_sys;
-
-    if( p_sys->au_unit )
-    {
-        verify_noerr( AudioOutputUnitStop( p_sys->au_unit ) );
-        verify_noerr( AudioUnitUninitialize( p_sys->au_unit ) );
-        verify_noerr( CloseComponent( p_sys->au_unit ) );
-    }
-    free( p_sys );
-}
-
-/*****************************************************************************
- * Play: nothing to do
- *****************************************************************************/
-static void Play( aout_instance_t * p_aout )
-{
-}
-
-
-/*****************************************************************************
- * Probe
- *****************************************************************************/
-static int Probe( aout_instance_t * p_aout )
+ * Setup a encoded digital stream (SPDIF)
+ *****************************************************************************/
+int OpenSPDIF( aout_instance_t * p_aout )
 {
     OSStatus            err = noErr;
     UInt32              i, i_param_size;
@@ -514,6 +546,56 @@

     struct aout_sys_t   *p_sys = p_aout->output.p_sys;

+    /* Start doing the SPDIF setup proces */
+    p_sys->b_digital = VLC_TRUE;
+    p_aout->output.output.i_format = VLC_FOURCC('s','p','d','i');
+    msg_Dbg( p_aout, "we found a digital stream, and we WANT a digital stream" );
+
+    return VLC_FALSE;
+
+error:
+    return VLC_FALSE;
+}
+
+
+/*****************************************************************************
+ * Close: Close HAL AudioUnit
+ *****************************************************************************/
+static void Close( vlc_object_t * p_this )
+{
+    aout_instance_t     *p_aout = (aout_instance_t *)p_this;
+    struct aout_sys_t   *p_sys = p_aout->output.p_sys;
+
+    if( p_sys->au_unit )
+    {
+        verify_noerr( AudioOutputUnitStop( p_sys->au_unit ) );
+        verify_noerr( AudioUnitUninitialize( p_sys->au_unit ) );
+        verify_noerr( CloseComponent( p_sys->au_unit ) );
+    }
+    free( p_sys );
+}
+
+/*****************************************************************************
+ * Play: nothing to do
+ *****************************************************************************/
+static void Play( aout_instance_t * p_aout )
+{
+}
+
+
+/*****************************************************************************
+ * Probe
+ *****************************************************************************/
+static void Probe( aout_instance_t * p_aout )
+{
+    OSStatus            err = noErr;
+    UInt32              i = 0, i_param_size = 0;
+    AudioDeviceID       devid_def = 0;
+    AudioDeviceID       *p_devices = NULL;
+    vlc_value_t         val, text;
+
+    struct aout_sys_t   *p_sys = p_aout->output.p_sys;
+
     /* Get number of devices */
     err = AudioHardwareGetPropertyInfo( kAudioHardwarePropertyDevices,
                                         &i_param_size, NULL );
@@ -534,7 +616,7 @@
     msg_Dbg( p_aout, "system has [%ld] device(s)", p_sys->i_devices );

     /* Allocate DeviceID array */
-    p_devices = (AudioDeviceID *)malloc( i_param_size );
+    p_devices = (AudioDeviceID*)malloc( sizeof(AudioDeviceID) * p_sys->i_devices );
     if( p_devices == NULL )
     {
         msg_Err( p_aout, "out of memory" );
@@ -543,7 +625,7 @@

     /* Populate DeviceID array */
     err = AudioHardwareGetProperty( kAudioHardwarePropertyDevices,
-                                    &i_param_size, (void *)p_devices );
+                                    &i_param_size, p_devices );
     if( err != noErr )
     {
         msg_Err( p_aout, "could not get the device ID's: [%4.4s]", (char *)&err );
@@ -553,7 +635,7 @@
     /* Find the ID of the default Device */
     i_param_size = sizeof( AudioDeviceID );
     err = AudioHardwareGetProperty( kAudioHardwarePropertyDefaultOutputDevice,
-                                    &i_param_size, (void *)&devid_def );
+                                    &i_param_size, &devid_def );
     if( err != noErr )
     {
         msg_Err( p_aout, "could not get default audio device: [%4.4s]", (char *)&err );
@@ -567,29 +649,25 @@

     for( i = 0; i < p_sys->i_devices; i++ )
     {
-        char psz_devuid[1024];
-        char psz_name[1024];
-        CFStringRef devUID;
-
-        i_param_size = sizeof psz_name;
+        char *psz_name;
+        i_param_size = 0;
+
+        /* Retrieve the length of the device name */
+        err = AudioDeviceGetPropertyInfo(
+                    p_devices[i], 0, VLC_FALSE,
+                    kAudioDevicePropertyDeviceName,
+                    &i_param_size, NULL);
+        if( err ) goto error;
+
+        /* Retrieve the name of the device */
+        psz_name = (char *)malloc( i_param_size );
         err = AudioDeviceGetProperty(
                     p_devices[i], 0, VLC_FALSE,
                     kAudioDevicePropertyDeviceName,
                     &i_param_size, psz_name);
-        if( err )
-            goto error;
-
-        i_param_size = sizeof(CFStringRef);
-        err = AudioDeviceGetProperty(
-                    p_devices[i], 0, VLC_FALSE,
-                    kAudioDevicePropertyDeviceUID,
-                    &i_param_size, &devUID);
-        if( err )
-            goto error;
-
-        CFStringGetCString( devUID, psz_devuid, sizeof psz_devuid, CFStringGetSystemEncoding() );
-        msg_Dbg( p_aout, "DevID: %lu  DevName: %s  DevUID: %s", p_devices[i], psz_name, psz_devuid );
-        CFRelease( devUID );
+        if( err ) goto error;
+
+        msg_Dbg( p_aout, "DevID: %lu  DevName: %s", p_devices[i], psz_name );

         if( !AudioDeviceHasOutput( p_devices[i]) )
         {
@@ -597,87 +675,140 @@
             continue;
         }

-        val.i_int = (int) p_devices[i];
-        text.psz_string = psz_name;
+        val.i_int = (int)p_devices[i];
+        text.psz_string = strdup( psz_name );
         var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val, &text );
-        if( devid_def == p_devices[i] )
+        if( p_sys->i_default_dev == p_devices[i] )
         {
             var_Change( p_aout, "audio-device", VLC_VAR_SETDEFAULT, &val, NULL );
             var_Set( p_aout, "audio-device", val );
         }
+
+        if( AudioDeviceSupportsDigital( p_aout, p_devices[i]) )
+        {
+            val.i_int = (int)p_devices[i] | AOUT_VAR_SPDIF_FLAG;
+            asprintf( &text.psz_string, "%s (Encoded Output)", psz_name );
+            var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val, &text );
+            if( p_sys->i_default_dev == p_devices[i] && config_GetInt( p_aout, "spdif" ) )
+            {
+                var_Change( p_aout, "audio-device", VLC_VAR_SETDEFAULT, &val, NULL );
+                var_Set( p_aout, "audio-device", val );
+            }
+        }
+
+        free( psz_name);
     }
     var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL );

     /* attach a Listener so that we are notified of a change in the Device setup */
-    /* err = AudioHardwareAddPropertyListener( kAudioHardwarePropertyDevices,
+    err = AudioHardwareAddPropertyListener( kAudioHardwarePropertyDevices,
                                             HardwareListener,
                                             (void *)p_aout );
     if( err )
-        goto error;*/
-
+        goto error;
+
     msg_Dbg( p_aout, "succesful finish of deviceslist" );
     if( p_devices ) free( p_devices );
-    return (VLC_SUCCESS);
+    return;

 error:
     var_Destroy( p_aout, "audio-device" );
     if( p_devices ) free( p_devices );
-    return VLC_EGENERIC;
+    return;
 }

 /*****************************************************************************
- * DeviceDigitalMode: Check i_dev_id for digital stream support.
- *****************************************************************************/
-static int DeviceDigitalMode( aout_instance_t *p_aout, AudioDeviceID i_dev_id )
+ * AudioDeviceSupportsDigital: Check i_dev_id for digital stream support.
+ *****************************************************************************/
+int AudioDeviceSupportsDigital( aout_instance_t *p_aout, AudioDeviceID i_dev_id )
 {
     OSStatus                    err = noErr;
-    UInt32                      i_param_size;
-    AudioStreamBasicDescription *p_format_list;
-    int                         i, i_formats;
-    struct aout_sys_t           *p_sys = p_aout->output.p_sys;
-
-    p_sys->b_supports_digital = VLC_FALSE;
-
+    UInt32                      i_param_size = 0;
+    AudioStreamBasicDescription *p_format_list = NULL;
+    AudioStreamID               *p_streams = NULL;
+    int                         i = 0, j = 0;
+    int                         i_formats = 0, i_streams = 0;
+    vlc_bool_t                  b_return = VLC_FALSE;
+
+    /* Retrieve all the output streams */
     err = AudioDeviceGetPropertyInfo( i_dev_id, 0, FALSE,
-                                      kAudioDevicePropertyStreamFormats,
+                                      kAudioDevicePropertyStreams,
                                       &i_param_size, NULL );
     if( err != noErr )
     {
-        msg_Err( p_aout, "could not get number of streamsformats: [%4.4s]", (char *)&err );
-        return( VLC_EGENERIC );
-    }
-
-    i_formats = i_param_size / sizeof( AudioStreamBasicDescription );
-    p_format_list = (AudioStreamBasicDescription *)malloc( i_param_size );
-    if( p_format_list == NULL )
-    {
-        return( VLC_ENOMEM );
+        msg_Err( p_aout, "could not get number of streams: [%4.4s]", (char *)&err );
+        return VLC_FALSE;
+    }
+
+    i_streams = i_param_size / sizeof( AudioStreamID );
+    p_streams = (AudioStreamID *)malloc( i_param_size );
+    if( p_streams == NULL )
+    {
+        msg_Err( p_aout, "Out of memory" );
+        return VLC_ENOMEM;
     }

     err = AudioDeviceGetProperty( i_dev_id, 0, FALSE,
-                                      kAudioDevicePropertyStreamFormats,
-                                      &i_param_size, (void *)p_format_list );
+                                    kAudioDevicePropertyStreams,
+                                    &i_param_size, p_streams );
+
     if( err != noErr )
     {
-        msg_Err( p_aout, "could not get the list of formats: [%4.4s]", (char *)&err );
-        return( VLC_EGENERIC );
-    }
-
-    for( i = 0; i < i_formats; i++ )
-    {
-        msg_Dbg( p_aout, STREAM_FORMAT_MSG( "supported format", p_format_list[i] ) );
+        msg_Err( p_aout, "could not get number of streams: [%4.4s]", (char *)&err );
+        return VLC_FALSE;
+    }
+
+    for( i = 0; i < i_streams; i++ )
+    {
+        p_format_list = NULL;
+        i_formats = 0;
+        msg_Dbg( p_aout, "retrieving formats for stream: %#lx", p_streams[i] );
+
+        /* Retrieve all the stream formats supported by each output stream */
+        err = AudioStreamGetPropertyInfo( p_streams[i], 0,
+                                          kAudioDevicePropertyStreamFormats,
+                                          &i_param_size, NULL );
+        if( err != noErr )
+        {
+            msg_Err( p_aout, "could not get number of streamformats: [%4.4s]", (char *)&err );
+            break;
+        }

-        if( p_format_list[i].mFormatID == 'IAC3' ||
-                  p_format_list[i].mFormatID == kAudioFormat60958AC3 )
-        {
-            p_sys->b_supports_digital = VLC_TRUE;
-            msg_Dbg( p_aout, "this device supports a digital stream" );
-            break;
-        }
-    }
-
-    free( (void *)p_format_list );
-    return VLC_SUCCESS;
+        i_formats = i_param_size / sizeof( AudioStreamBasicDescription );
+        p_format_list = (AudioStreamBasicDescription *)malloc( i_param_size );
+        if( p_format_list == NULL )
+        {
+            break;
+        }
+
+        err = AudioStreamGetProperty( p_streams[i], 0,
+                                          kAudioDevicePropertyStreamFormats,
+                                          &i_param_size, p_format_list );
+        if( err != noErr )
+        {
+            msg_Err( p_aout, "could not get the list of streamformats: [%4.4s]", (char *)&err );
+            free( p_format_list);
+            break;
+        }
+
+        for( j = 0; j < i_formats; j++ )
+        {
+            msg_Dbg( p_aout, STREAM_FORMAT_MSG( "supported format", p_format_list[j] ) );
+
+            if( p_format_list[j].mFormatID == 'IAC3' ||
+                      p_format_list[j].mFormatID == kAudioFormat60958AC3 )
+            {
+                b_return = VLC_TRUE;
+                msg_Dbg( p_aout, "this device supports a digital stream" );
+                break;
+            }
+        }
+
+        if( p_format_list ) free( p_format_list );
+    }
+
+    if( p_streams ) free( p_streams );
+    return b_return;
 }

 /*****************************************************************************
@@ -709,6 +840,7 @@

     current_date = p_sys->clock_diff +
                    AudioConvertHostTimeToNanos( host_time.mHostTime ) / 1000;
+                   //- ((mtime_t) 1000000 / p_aout->output.output.i_rate * 31 ); // 31 = Latency in Frames. retrieve somewhere

     if( ioData == NULL && ioData->mNumberBuffers < 1 )
     {
@@ -766,28 +898,6 @@
     return( noErr );
 }

-
-/*****************************************************************************
- * Setup a digital stream
- *****************************************************************************/
-static int DigitalInit( aout_instance_t * p_aout )
-{
-    OSStatus            err = noErr;
-    UInt32              i, i_param_size;
-    AudioDeviceID       devid_def;
-    AudioDeviceID       *p_devices = NULL;
-    vlc_value_t         val, text;
-
-    struct aout_sys_t   *p_sys = p_aout->output.p_sys;
-
-
-
-    return (VLC_SUCCESS);
-
-error:
-    return VLC_EGENERIC;
-}
-
 int AudioDeviceHasOutput( AudioDeviceID i_dev_id )
 {
     UInt32			dataSize;
@@ -799,7 +909,6 @@
     return TRUE;
 }

-
 /*****************************************************************************
  * HardwareListener: Warns us of changes in the list of registered devices
  *****************************************************************************/
@@ -807,9 +916,7 @@
                                   void * inClientData )
 {
     OSStatus err = noErr;
-
     aout_instance_t     *p_aout = (aout_instance_t *)inClientData;
-    /* struct aout_sys_t   *p_sys = p_aout->output.p_sys; */

     switch( inPropertyID )
     {


[PGO] Test update for revision 253484.

[PGO] Test update for revision 253484.

git-svn-id: ffe668792ed300d6c2daa1f6eba2e0aa28d7ec6c@253485 91177308-0d34-0410-b5e6-96231b3b80d8

--- test/Profile/c-linkage-available_externally.c
+++ test/Profile/c-linkage-available_externally.c
@@ -5,7 +5,7 @@
 // CHECK: @__llvm_profile_name_foo = linkonce_odr hidden constant [3 x i8] c"foo", section "__DATA,__llvm_prf_names", align 1

 // CHECK: @__llvm_profile_counters_foo = linkonce_odr hidden global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8
-// CHECK: @__llvm_profile_data_foo = linkonce_odr hidden constant { i32, i32, i64, i8*, i64* } { i32 3, i32 1, i64 {{[0-9]+}}, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__llvm_profile_name_foo, i32 0, i32 0), i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__llvm_profile_counters_foo, i32 0, i32 0) }, section "__DATA,__llvm_prf_data", align 8
+// CHECK: @__llvm_profile_data_foo = linkonce_odr hidden global { i32, i32, i64, i8*, i64*, i8*, i8*, [1 x i16] } { i32 3, i32 1, i64 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__llvm_profile_name_foo, i32 0, i32 0), i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__llvm_profile_counters_foo, i32 0, i32 0), i8* null, i8* null, [1 x i16] zeroinitializer }, section "__DATA,__llvm_prf_data", align 8
 inline int foo(void) { return 1; }

 int main(void) {


[vterm] restart_video_output: don't redraw static elems in panic

--- modules/console/video_term.c
+++ modules/console/video_term.c
@@ -185,7 +185,7 @@
 static void term_redraw2(term *_t, u16 s, u16 e)
 {
    struct vterm *const t = _t;
-   const bool fpu_allowed = !in_irq();
+   const bool fpu_allowed = !in_irq() && !in_panic();

    if (!t->buffer)
       return;
@@ -821,11 +821,13 @@
    term_redraw(t);
    term_action_enable_cursor(t, t->cursor_enabled);

-   if (t->vi->redraw_static_elements)
-      t->vi->redraw_static_elements();
-
-   if (t->vi->enable_static_elems_refresh)
-      t->vi->enable_static_elems_refresh();
+   if (!in_panic()) {
+      if (t->vi->redraw_static_elements)
+         t->vi->redraw_static_elements();
+
+      if (t->vi->enable_static_elems_refresh)
+         t->vi->enable_static_elems_refresh();
+   }
 }

 static int


Document WrongJacobianDiffusion kernel (#4182)

--- test/include/kernels/WrongJacobianDiffusion.h
+++ test/include/kernels/WrongJacobianDiffusion.h
@@ -1,3 +1,6 @@
+#ifndef WRONGJACOBIANDIFFUSION_H
+#define WRONGJACOBIANDIFFUSION_H
+
 #include "Kernel.h"
 #include "Material.h"

@@ -7,6 +10,10 @@
 template<>
 InputParameters validParams<WrongJacobianDiffusion>();

+/**
+ * Kernel that allows to construct wrong jacobians, by multiplying a diffusion
+ * kernel jacobian and/or residual with an arbitrary prefactor
+ */
 class WrongJacobianDiffusion : public Kernel
 {
 public:
@@ -17,6 +24,11 @@
   virtual Real computeQpJacobian();

 private:
+  /// prefactor of the Residual
   Real _rfactor;
+
+  /// prefactor of teh Jacobian
   Real _jfactor;
 };
+
+#endif //WRONGJACOBIANDIFFUSION_H


Remove extra debug introduced accidentally in 9925a34ee

(cherry picked from commit cd7b29a55ccbc613eb53873f0946bb525e84c4e4)
Signed-off-by: Jean-Baptiste Kempf <7b85a41a628204b76aba4326273a3ccc74bd009a@videolan.org>

--- modules/demux/avformat/mux.c
+++ modules/demux/avformat/mux.c
@@ -40,7 +40,7 @@
 #include "../../codec/avcodec/avcommon.h"

-#define AVFORMAT_DEBUG 1
+//#define AVFORMAT_DEBUG 1

 static const char *const ppsz_mux_options[] = {
     "mux", "options", NULL


Revert "avformat audio mux: set frame size"

This reverts commit 61426dcb1ec7497cd6413a174cc6687d7cd46df7.

This was a repeat of 077f47ff59b9e5e1a523d924a0307105dcdee4bc

--- modules/demux/avformat/mux.c
+++ modules/demux/avformat/mux.c
@@ -221,7 +221,6 @@
     case AUDIO_ES:
         codec->codec_type = AVMEDIA_TYPE_AUDIO;
         codec->channels = fmt->audio.i_channels;
-        codec->frame_size = fmt->audio.i_frame_length;
         codec->sample_rate = fmt->audio.i_rate;
         codec->time_base = (AVRational){1, codec->sample_rate};
         codec->frame_size = fmt->audio.i_frame_length;


termios does not seem to be requried

termios does not seem to be requried

git-svn-id: 40dd595c6684d839db675001a64203a1457e7319@14770 67ed7778-7388-44ab-90cf-0a291f65f57c

--- camlibs/canon/serial.c
+++ camlibs/canon/serial.c
@@ -18,7 +18,6 @@

 #include <stdio.h>
 #include <unistd.h>
-#include <termios.h>
 #include <fcntl.h>
 #include <string.h>
 #include <sys/time.h>


demux: wpl: fix leak on repeated attributes (cid #1313808)

--- modules/demux/playlist/wpl.c
+++ modules/demux/playlist/wpl.c
@@ -56,9 +56,9 @@
                 psz_attr = xml_ReaderNextAttr( p_sys->p_reader, &psz_val );
                 if ( !psz_attr || !psz_val )
                     break;
-                if ( !strcasecmp( psz_attr, "name" ) )
+                if ( !strcasecmp( psz_attr, "name" ) && !psz_attribute_name )
                     psz_attribute_name = strdup( psz_val );
-                else if ( !strcasecmp( psz_attr, "content" ) )
+                else if ( !strcasecmp( psz_attr, "content" ) && !psz_attribute_value )
                     psz_attribute_value = strdup( psz_val );
             }
             if ( psz_attribute_name && psz_attribute_value )


error 3 might mean

error 3 might mean

--- camlibs/ptp2/library.c
+++ camlibs/ptp2/library.c
@@ -2440,6 +2440,10 @@
 		gp_context_error (context, _("Canon EOS Capture failed to release: Perhaps no focus?"));
 		return GP_ERROR;
 	}
+	if (result == 3) {
+		gp_context_error (context, _("Canon EOS Capture failed to release: Perhaps mirror up?"));
+		return GP_ERROR;
+	}
 	if (result == 7) {
 		gp_context_error (context, _("Canon EOS Capture failed to release: Perhaps no more memory on card?"));
 		return GP_ERROR_NO_MEMORY;


Used VLC_TS_INVALID/0 in subtitle_asa demuxer.

--- modules/demux/subtitle_asa.c
+++ modules/demux/subtitle_asa.c
@@ -247,7 +247,7 @@
         p_sys->i_length = p_sys->subtitle[p_sys->i_subtitles-1].i_stop;
         /* +1 to avoid 0 */
         if( p_sys->i_length <= 0 )
-            p_sys->i_length = p_sys->subtitle[p_sys->i_subtitles-1].i_start+1;
+            p_sys->i_length = p_sys->subtitle[p_sys->i_subtitles-1].i_start + VLC_TS_0;
     }

     /* *** add subtitle ES *** */
@@ -447,9 +447,9 @@
             continue;
         }

-        p_block->i_pts = p_sys->subtitle[p_sys->i_subtitle].i_start;
-        p_block->i_dts = p_block->i_pts;
-        if( p_sys->subtitle[p_sys->i_subtitle].i_stop > 0 )
+        p_block->i_pts = VLC_TS_0 + p_sys->subtitle[p_sys->i_subtitle].i_start;
+        p_block->i_dts = VLC_TS_0 + p_block->i_pts;
+        if( p_sys->subtitle[p_sys->i_subtitle].i_stop >= 0 )
         {
             p_block->i_length =
                 p_sys->subtitle[p_sys->i_subtitle].i_stop - p_block->i_pts;
@@ -457,7 +457,7 @@

         memcpy( p_block->p_buffer,
                 p_sys->subtitle[p_sys->i_subtitle].psz_text, i_len );
-        if( p_block->i_pts > 0 )
+        if( p_block->i_pts > VLC_TS_INVALID )
         {
             es_out_Send( p_demux->out, p_sys->es, p_block );
         }


make build again.
longer timeout for capture

git-svn-id: 40dd595c6684d839db675001a64203a1457e7319@13304 67ed7778-7388-44ab-90cf-0a291f65f57c

--- camlibs/ptp2/library.c
+++ camlibs/ptp2/library.c
@@ -64,7 +64,7 @@
 #define USB_START_TIMEOUT 8000
 #define USB_CANON_START_TIMEOUT 1500	/* 1.5 seconds (0.5 was too low) */
 #define USB_NORMAL_TIMEOUT 20000
-#define USB_TIMEOUT_CAPTURE 20000
+#define USB_TIMEOUT_CAPTURE 100000

 #define	SET_CONTEXT(camera, ctx) ((PTPData *) camera->pl->params.data)->context = ctx
 #define	SET_CONTEXT_P(p, ctx) ((PTPData *) p->data)->context = ctx
@@ -1458,8 +1458,8 @@
                         if (camera->pl->checkevents) {
                                 PTPCanon_changes_entry entry;

-                                _ptp_check_eos_events (params);
-                                while (_ptp_get_one_eos_event (params, &entry)) {
+                                ptp_check_eos_events (params);
+                                while (ptp_get_one_eos_event (params, &entry)) {
                                         gp_log (GP_LOG_DEBUG, "camera_exit", "missed EOS ptp type %d", entry.type);
                                         if (entry.type == PTP_CANON_EOS_CHANGES_TYPE_UNKNOWN)
                                                 free (entry.u.info);
@@ -2164,7 +2164,8 @@
 	gettimeofday (&event_start, NULL);
 	found = FALSE;

-	while (!_timeout_passed(&event_start, timeout)) {
+	CR (gp_port_set_timeout (camera->port, USB_TIMEOUT_CAPTURE));
+	while (!_timeout_passed(&event_start, USB_TIMEOUT_CAPTURE)) {
 		gp_context_idle (context);
 		if (PTP_RC_OK == params->event_check (params, &event)) {
 			if (event.Code == PTP_EC_CaptureComplete) {
@@ -2200,6 +2201,7 @@
 			break;
 		}
 	}
+	CR (gp_port_set_timeout (camera->port, timeout));
 	/* Catch event, attempt  2 */
 	if (!sawcapturecomplete) {
 		if (PTP_RC_OK==params->event_wait (params, &event)) {


added object adding event loop

added object adding event loop

--- camlibs/ptp2/library.c
+++ camlibs/ptp2/library.c
@@ -4950,10 +4950,38 @@
 		if (newobject)
 			break;
 		while (ptp_get_one_event(params, &event)) {
+			PTPObject	*ob;
+			PTPContainer	newevent;
+
 			switch (event.Code) {
 				case PTP_EC_ObjectAdded:
 				case PTP_EC_FUJI_ObjectAdded:
+					ret = ptp_object_want (params, event.Param1, PTPOBJECT_OBJECTINFO_LOADED, &ob);
+					if (ret != PTP_RC_OK) {
+						GP_LOG_E ("object added, but not found?");
+						continue;
+					}
+					/* A directory was added, like initial DCIM/100NIKON or so. */
+					if (ob->oi.ObjectFormat == PTP_OFC_Association) {
+						GP_LOG_D ("new object 0x%08x is a directory, continuing", handles.Handler[i]);
+						break;
+					}
+					if (newobject) {
+						/* we already got one image ... means a secondary image in RAW+JPG. Push this to the event queue. */
+						newevent.Code = PTP_EC_ObjectAdded;
+						newevent.Param1 = newobject;
+						ptp_add_event (params, &newevent);
+					}
 					newobject = event.Param1;
+					GP_LOG_D ("newobject 0x%08x", newobject);
+					/* we found a new file */
+					strcpy  (path->name,  ob->oi.Filename);
+					sprintf (path->folder,"/"STORAGE_FOLDER_PREFIX"%08lx/",(unsigned long)ob->oi.StorageID);
+					get_folder_from_handle (camera, ob->oi.StorageID, ob->oi.ParentObject, path->folder);
+					/* delete last / or we get confused later. */
+					path->folder[ strlen(path->folder)-1 ] = '\0';
+					add_objectid_and_upload (camera, path, context, newobject, &ob->oi);
+					/* we need to proceed to download all images, in cases of RAW+JPG capture */
 					break;
 				default:
 					GP_LOG_D ("unexpected unhandled event Code %04x, Param 1 %08x", event.Code, event.Param1);


fix directory listign

fix directory listign

--- camlibs/ptp2/library.c
+++ camlibs/ptp2/library.c
@@ -5600,7 +5600,6 @@
 ptp_list_folder_eos (PTPParams *params, uint32_t storage, uint32_t handle) {
 	unsigned int	k, i, j, last, changed;
 	PTPCANONFolderEntry *tmp = NULL;
-	PTPCANONFolderEntry *entries = NULL;
 	unsigned int	nroftmp = 0;
 	uint16_t	ret;
 	PTPStorageIDs	storageids;
@@ -5634,38 +5633,38 @@
 			PTPObject	*newobs;

 			for (j=0;j<params->nrofobjects;j++) {
-				if (params->objects[(last+j)%params->nrofobjects].oid == entries[i].ObjectHandle)  {
+				if (params->objects[(last+j)%params->nrofobjects].oid == tmp[i].ObjectHandle)  {
 					ob = &params->objects[(last+j)%params->nrofobjects];
 					break;
 				}
 			}
 			if (j == params->nrofobjects) {
-				gp_log (GP_LOG_DEBUG, "ptp_list_folder_eos", "adding new objectid 0x%08x (nrofobs=%d,j=%d)", entries[i].ObjectHandle, params->nrofobjects,j);
+				gp_log (GP_LOG_DEBUG, "ptp_list_folder_eos", "adding new objectid 0x%08x (nrofobs=%d,j=%d)", tmp[i].ObjectHandle, params->nrofobjects,j);
 				newobs = realloc (params->objects,sizeof(PTPObject)*(params->nrofobjects+1));
 				if (!newobs) return PTP_RC_GeneralError;
 				params->objects = newobs;
 				memset (&params->objects[params->nrofobjects],0,sizeof(params->objects[params->nrofobjects]));
-				params->objects[params->nrofobjects].oid   = entries[i].ObjectHandle;
+				params->objects[params->nrofobjects].oid   = tmp[i].ObjectHandle;
 				params->objects[params->nrofobjects].flags = 0;

 				params->objects[params->nrofobjects].oi.StorageID = storageids.Storage[k];
 				params->objects[params->nrofobjects].flags |= PTPOBJECT_STORAGEID_LOADED;
 				params->objects[params->nrofobjects].oi.ParentObject = handle;
 				params->objects[params->nrofobjects].flags |= PTPOBJECT_PARENTOBJECT_LOADED;
-				params->objects[params->nrofobjects].oi.Filename = strdup(entries[i].Filename);
-				params->objects[params->nrofobjects].oi.ObjectFormat = entries[i].ObjectFormatCode;
+				params->objects[params->nrofobjects].oi.Filename = strdup(tmp[i].Filename);
+				params->objects[params->nrofobjects].oi.ObjectFormat = tmp[i].ObjectFormatCode;
 				params->objects[params->nrofobjects].oi.ProtectionStatus = PTP_DPGS_Get; /* FIXME: check if ok */
-				params->objects[params->nrofobjects].oi.ObjectCompressedSize = entries[i].ObjectSize;
-				params->objects[params->nrofobjects].oi.CaptureDate = entries[i].Time;
-				params->objects[params->nrofobjects].oi.ModificationDate = entries[i].Time;
+				params->objects[params->nrofobjects].oi.ObjectCompressedSize = tmp[i].ObjectSize;
+				params->objects[params->nrofobjects].oi.CaptureDate = tmp[i].Time;
+				params->objects[params->nrofobjects].oi.ModificationDate = tmp[i].Time;
 				params->objects[params->nrofobjects].flags |= PTPOBJECT_OBJECTINFO_LOADED;

-				debug_objectinfo(params, entries[i].ObjectHandle, &params->objects[params->nrofobjects].oi);
+				debug_objectinfo(params, tmp[i].ObjectHandle, &params->objects[params->nrofobjects].oi);
 				last = params->nrofobjects;
 				params->nrofobjects++;
 				changed = 1;
 			} else {
-				gp_log (GP_LOG_DEBUG, "ptp_list_folder_eos", "adding old objectid 0x%08x (nrofobs=%d,j=%d)", entries[i].ObjectHandle, params->nrofobjects,j);
+				gp_log (GP_LOG_DEBUG, "ptp_list_folder_eos", "adding old objectid 0x%08x (nrofobs=%d,j=%d)", tmp[i].ObjectHandle, params->nrofobjects,j);
 				ob = &params->objects[(last+j)%params->nrofobjects];
 				/* for speeding up search */
 				last = (last+j)%params->nrofobjects;


added d800

added d800

git-svn-id: 40dd595c6684d839db675001a64203a1457e7319@14193 67ed7778-7388-44ab-90cf-0a291f65f57c

--- camlibs/ptp2/library.c
+++ camlibs/ptp2/library.c
@@ -831,6 +831,8 @@
 	/* IRC Reporter popolon */
 	{"Nikon:DSC D5100 (PTP mode)",    0x04b0, 0x0429, PTP_CAP|PTP_CAP_PREVIEW},

+	/* "François G." <francois@webcampak.com> */
+	{"Nikon:DSC D800",	          0x04b0, 0x042a, PTP_CAP|PTP_CAP_PREVIEW},
 	/* t.ludewig@gmail.com */
 	{"Nikon:DSC D600",	          0x04b0, 0x042d, PTP_CAP|PTP_CAP_PREVIEW},
 	/* Roderick Stewart <roderick.stewart@gmail.com> */


From: David Fries <David@Fries.net>

From: David Fries <David@Fries.net>

event handling on the P100 is even worse, do not
rely on it (switch to NIKON_BROKEN_CAP)

git-svn-id: 40dd595c6684d839db675001a64203a1457e7319@14577 67ed7778-7388-44ab-90cf-0a291f65f57c

--- camlibs/ptp2/library.c
+++ camlibs/ptp2/library.c
@@ -843,7 +843,7 @@
 	{"Nikon:Coolpix S225 (PTP mode)", 0x04b0, 0x0178, PTP_CAP|PTP_NIKON_BROKEN_CAP},

 	/* Ryan Nestor <ryan@monadnock.org> */
-	{"Nikon:Coolpix P100 (PTP mode)", 0x04b0, 0x017d, PTP_CAP|PTP_NO_CAPTURE_COMPLETE},
+	{"Nikon:Coolpix P100 (PTP mode)", 0x04b0, 0x017d, PTP_CAP|PTP_NIKON_BROKEN_CAP},
 	/* Štěpán Němec <stepnem@gmail.com> */
 	{"Nikon:Coolpix P7000 (PTP mode)",0x04b0, 0x017f, PTP_CAP|PTP_NO_CAPTURE_COMPLETE},

@@ -2023,7 +2023,7 @@
 		if (ptp_operation_issupported(params, PTP_OC_CANON_EOS_GetViewFinderData)) {
 			PTPPropertyValue	val;
 			/* FIXME: this might cause a focusing pass and take seconds. 20 was not
-			 * enough. */
+			 * enough (would be 0.2 seconds, too short for the mirror up operation.). */
 			int 			tries = 100;
 			PTPDevicePropDesc       dpd;


- handle directories being created also in nikon_capture
- fix up nikon broken capture code with new on-deman-object model
- Nikon Coolpix P2 TIFF -> JPEG hack
- use ptp_check_event generic function in the generic capture case

git-svn-id: 40dd595c6684d839db675001a64203a1457e7319@15000 67ed7778-7388-44ab-90cf-0a291f65f57c

--- camlibs/ptp2/library.c
+++ camlibs/ptp2/library.c
@@ -2695,16 +2695,21 @@
 				if (newobject != 0xffff0001) {
 					ptp_add_event (params, &event);
 					checkevt = 1; /* avoid endless loop */
-				} else {
-					newobject = event.Param1;
 				}
+				/* we register the object in the internal storage, and we also need to
+				 * to find out if it is just a new directory (/DCIM/NEWENTRY/) created
+				 * during capture or the actual image. */
 				ret = ptp_object_want (params, event.Param1, PTPOBJECT_OBJECTINFO_LOADED, &ob);
 				if (ret != PTP_RC_OK)
 					break;
 				/* if a new directory was added, not a file ... just continue.
 				 * happens when the camera starts with an empty card. */
-				if (ob->oi.ObjectFormat == PTP_OFC_Association)
+				if (ob->oi.ObjectFormat == PTP_OFC_Association) {
+					/* libgphoto2 vfs does not notice otherwise */
+					gp_filesystem_reset (camera->fs);
 					break;
+				}
+				newobject = event.Param1;
 				done |= 2;
 				break;
 			}
@@ -2766,6 +2771,14 @@
 			} else {
 				sprintf (path->folder,"/"STORAGE_FOLDER_PREFIX"%08lx",(unsigned long)oi.StorageID);
 			}
+			if (oi.ObjectFormat != PTP_OFC_EXIF_JPEG) {
+				/* the Nikon Coolpix P2 says "TIFF" and gives us "JPG". weird. */
+				if (oi.Filename && strstr(oi.Filename,".JPG")) {
+					gp_log (GP_LOG_DEBUG,"nikon_capture", "rewriting %04x to JPEG %04x for %s", oi.ObjectFormat,PTP_OFC_EXIF_JPEG,oi.Filename);
+					oi.ObjectFormat = PTP_OFC_EXIF_JPEG;
+				}
+			}
+
 			if (oi.ObjectFormat != PTP_OFC_EXIF_JPEG) {
 				gp_log (GP_LOG_DEBUG,"nikon_capture", "raw? ofc is 0x%04x, name is %s", oi.ObjectFormat,oi.Filename);
 				sprintf (path->name, "capt%04d.nef", capcnt++);
@@ -3384,6 +3397,7 @@
 	PTPParams *params = &camera->pl->params;
 	uint32_t newobject = 0x0;
 	int done,tries;
+	PTPObjectHandles	beforehandles;

 	/* adjust if we ever do sound or movie capture */
 	if (type != GP_CAPTURE_IMAGE)
@@ -3445,6 +3459,14 @@
 		gp_context_error(context,
                	_("Sorry, your camera does not support generic capture"));
 		return GP_ERROR_NOT_SUPPORTED;
+	}
+
+	/* broken capture ... we detect what was captured using added objects
+	 * via the getobjecthandles array. here get the before state */
+	if ((params->deviceinfo.VendorExtensionID==PTP_VENDOR_NIKON) && NIKON_BROKEN_CAP(params)) {
+		uint16_t ret = ptp_getobjecthandles (params, PTP_HANDLER_SPECIAL, 0x000000, 0x000000, &beforehandles);
+		if (ret != PTP_RC_OK)
+			return translate_ptp_result (ret);
 	}

 	/* A capture may take longer than the standard 8 seconds.
@@ -3475,7 +3497,8 @@
 	 * the camera.
 	 */

-	/* The Nikon way: Does not send AddObject event ... so try else */
+	/* The Nikon way: Does not send AddObject event ... so try to detect it by checking what objects
+	 * were added. */
 	if ((params->deviceinfo.VendorExtensionID==PTP_VENDOR_NIKON) && NIKON_BROKEN_CAP(params)) {
 		PTPObjectHandles	handles;
 		int tries = 5;
@@ -3493,19 +3516,21 @@
 			 */
 			newobject = 0;
 			for (i=0;i<handles.n;i++) {
+				unsigned int 	j;
 				PTPObject	*ob;

-				ret = ptp_object_find (params, handles.Handler[i], &ob);
-				if (ret == PTP_RC_OK)
+				/* look if we saw the objecthandle before capture */
+				for (j=0;j<beforehandles.n;j++)
+					if (beforehandles.Handler[j] == handles.Handler[i])
+						break;
+				if (j != beforehandles.n)
 					continue;

 				ret = ptp_object_want (params, handles.Handler[i], PTPOBJECT_OBJECTINFO_LOADED, &ob);
-
 				if (ret != PTP_RC_OK) {
 					gp_log (GP_LOG_ERROR, "nikon_broken_capture", "object added, but not found?");
 					continue;
 				}
-
 				/* A directory was added, like initial DCIM/100NIKON or so. */
 				if (ob->oi.ObjectFormat == PTP_OFC_Association)
 					continue;
@@ -3516,8 +3541,10 @@
 			free (handles.Handler);
 			if (newobject)
 				break;
+			CPR (context, ptp_check_event (params));
 			sleep(1);
 		}
+		free (beforehandles.Handler);
 		if (!newobject)
             		GP_DEBUG("PTPBUG_NIKON_BROKEN_CAPTURE no new file found after 5 seconds?!?");
 		goto out;
@@ -3526,6 +3553,9 @@
 	CR (gp_port_set_timeout (camera->port, normal_timeout));

 	/* The standard defined way ... wait for some capture related events. */
+	/* The Nikon 1 series emits ObjectAdded occasionaly after
+	 * the CaptureComplete event, while others do it the other way
+	 * round. Handle that case with some bitmask. */
 	done = 0; tries = 20;
 	while (done != 3) {
 		uint16_t ret;


added C533

added C533

git-svn-id: 40dd595c6684d839db675001a64203a1457e7319@9120 67ed7778-7388-44ab-90cf-0a291f65f57c

--- camlibs/ptp2/library.c
+++ camlibs/ptp2/library.c
@@ -311,6 +311,8 @@
 	/* v550 Jon Burgess <jburgess@uklinux.net> */
 	{"Kodak:V550",   0x040a, 0x058f, 0},
 	{"Kodak:P850",   0x040a, 0x0592, 0},
+	/* http://sourceforge.net/tracker/index.php?func=detail&aid=1547142&group_id=8874&atid=358874 */
+	{"Kodak:C533",   0x040a, 0x05a2, 0},
 	/* David D. Huff Jr. <David.Huff@computer-critters.com> */
 	{"Kodak:Z650",   0x040a, 0x059e, 0},


sony a6000 does not support liveview, untag

--- camlibs/ptp2/library.c
+++ camlibs/ptp2/library.c
@@ -943,7 +943,8 @@
 	/* https://sourceforge.net/p/gphoto/feature-requests/442/ */
 	{"Sony:Alpha-A7r (Control)",  0x054c, 0x094d, PTP_CAP|PTP_CAP_PREVIEW},

-	{"Sony:Alpha-A6000 (Control)",0x054c, 0x094e, PTP_CAP|PTP_CAP_PREVIEW},
+	/* preview was confirmed not to work. */
+	{"Sony:Alpha-A6000 (Control)",0x054c, 0x094e, PTP_CAP},

 	/* Nick Clarke <nick.clarke@gmail.com> */
 	{"Sony:Alpha-A77 M2 (Control)",0x054c, 0x0953, PTP_CAP|PTP_CAP_PREVIEW},


Initial commit

Initial commit

error: pathspec 'recursion/towerOfHanoi.c' did not match any file(s) known to git

--- recursion/towerOfHanoi.c
+++ recursion/towerOfHanoi.c
@@ -0,0 +1,22 @@
+/*tower of hanoi			author: yusuf shakeel	date: 20-12-2012
+*/
+
+#include <stdio.h>
+
+void t(int n, char beg, char aux, char end);
+
+int main(){
+	printf("Moves\n");
+	t(3, 'a', 'b', 'c');	//N = 3 (no. of disks)  a, b, c are the three pegs
+	return 0;
+}//main() ends here
+
+void t(int n, char beg, char aux, char end){
+	if(n == 1){
+		printf("%c --> %c\n", beg, end);
+	}else{
+		t(n-1, beg, end, aux);
+		t(1, beg, aux, end);
+		t(n-1, aux, beg, end);
+	}
+}//t() ends here


nic_uio: add i40e device ids

nic_uio: add i40e device ids

The FreeBSD nic_uio driver was missing the #defines to include the device ids
for devices using the i40e driver. This change adds in the missing defines.

Signed-off-by: Bruce Richardson <66b9e8e8fbd5e9f41f91b0af050876182ce9d0e4@intel.com>
Acked-by: Helin Zhang <aba9dfdb1a6ec8bf1ff66b95272c029f8dfde1b1@intel.com>

--- lib/librte_eal/bsdapp/nic_uio/nic_uio.c
+++ lib/librte_eal/bsdapp/nic_uio/nic_uio.c
@@ -109,6 +109,8 @@
 #define RTE_PCI_DEV_ID_DECL_IGBVF(vend, dev)   {vend, dev},
 #define RTE_PCI_DEV_ID_DECL_IXGBE(vend, dev)   {vend, dev},
 #define RTE_PCI_DEV_ID_DECL_IXGBEVF(vend, dev) {vend, dev},
+#define RTE_PCI_DEV_ID_DECL_I40E(vend, dev)    {vend, dev},
+#define RTE_PCI_DEV_ID_DECL_I40EVF(vend, dev)  {vend, dev},
 #define RTE_PCI_DEV_ID_DECL_VIRTIO(vend, dev)  {vend, dev},

 const struct device devices[] = {


ipc: fix access after async request failure

Previous fix for rte_panic has moved setting of alarm before
sending the message. This means that whether we send a message,
the alarm would still trigger. The comment noted that cleanup
would happen in the alarm handler, but that's not what actually
happened - instead, in the event of failed send we freed the
memory in-place, before putting the request on the queue.

This works OK when the message is sent, but when sending the
message fails, the alarm would still trigger with a pointer
argument that points to non-existent memory, and cause
memory corruption.

There probably is a "proper" fix for this issue, with correct
handling of sent vs. unsent requests, however it would be
simpler just to sacrifice the sent request in the (extremely
unlikely) event of alarm set failing. The other process would
still send a response, but it will be ignored by the sender.

Fixes: 45e5f49e87fb ("ipc: remove panic in async request")

Signed-off-by: Anatoly Burakov <814e00d8f6e4e81b7ccc7e3e5a0bfec0078f0203@intel.com>

--- lib/librte_eal/common/eal_common_proc.c
+++ lib/librte_eal/common/eal_common_proc.c
@@ -827,28 +827,6 @@
 		goto fail;
 	}

-	/*
-	 * set the alarm before sending message. there are two possible error
-	 * scenarios to consider here:
-	 *
-	 * - if the alarm set fails, we free the memory right there
-	 * - if the alarm set succeeds but sending message fails, then the alarm
-	 *   will trigger and clean up the memory
-	 *
-	 * Even if the alarm triggers too early (i.e. immediately), we're still
-	 * holding the lock to pending requests queue, so the interrupt thread
-	 * will just spin until we release the lock, and either release the
-	 * memory, or doesn't find any pending requests in the queue because we
-	 * never added any due to send message failure.
-	 */
-	if (rte_eal_alarm_set(ts->tv_sec * 1000000 + ts->tv_nsec / 1000,
-			      async_reply_handle, pending_req) < 0) {
-		RTE_LOG(ERR, EAL, "Fail to set alarm for request %s:%s\n",
-			dst, req->name);
-		ret = -1;
-		goto fail;
-	}
-
 	ret = send_msg(dst, req, MP_REQ);
 	if (ret < 0) {
 		RTE_LOG(ERR, EAL, "Fail to send request %s:%s\n",
@@ -859,9 +837,17 @@
 		ret = 0;
 		goto fail;
 	}
+	param->user_reply.nb_sent++;
+
+	/* if alarm set fails, we simply ignore the reply */
+	if (rte_eal_alarm_set(ts->tv_sec * 1000000 + ts->tv_nsec / 1000,
+			      async_reply_handle, pending_req) < 0) {
+		RTE_LOG(ERR, EAL, "Fail to set alarm for request %s:%s\n",
+			dst, req->name);
+		ret = -1;
+		goto fail;
+	}
 	TAILQ_INSERT_TAIL(&pending_requests.requests, pending_req, next);
-
-	param->user_reply.nb_sent++;

 	return 0;
 fail:


Fixes for AXIS2C-1247.

Fixes for AXIS2C-1247.

git-svn-id: fbb392d5347ebc45c06187f72dfd8bab02595dbf@681623 13f79535-47bb-0310-9956-ffa450edef68

--- axiom/src/attachments/mime_parser.c
+++ axiom/src/attachments/mime_parser.c
@@ -583,6 +583,23 @@
     mime_parser->soap_body_str = soap_str;
     mime_parser->soap_body_len = soap_len;

+    /* There are multipart/related messages which does not contain attachments
+     * The only mime_part is the soap envelope. So for those messages the mime
+     * boundary after the soap will end up with --
+     * So we will check that here and if we found then the logic inside the
+     * while loop will not be executed */
+
+    if(len_array[buf_num] == 2)
+    {
+        end_of_mime = (AXIOM_MIME_BOUNDARY_BYTE == *(buf_array[buf_num])) &&
+                            (AXIOM_MIME_BOUNDARY_BYTE == *(buf_array[buf_num] + 1));
+        if(end_of_mime)
+        {
+            AXIS2_FREE(env->allocator, buf_array[buf_num]);
+            buf_array[buf_num] = NULL;
+        }
+    }
+
     /*<SOAP></SOAP>--MIMEBOUNDARY
       mime_headr1:.......
       mime_headr2:....