]> git.sesse.net Git - mlt/commitdiff
Convert producer_xml to use mlt_log rather than fprintf.
authorBrian Matherly <pez4brian@yahoo.com>
Thu, 26 Jan 2012 05:38:37 +0000 (23:38 -0600)
committerBrian Matherly <pez4brian@yahoo.com>
Thu, 26 Jan 2012 05:38:37 +0000 (23:38 -0600)
1  2 
src/modules/xml/producer_xml.c

index 9091f0c7eb480da303094f700afec0e306be70b0,516d54950aaf1573117fe220e691084a29fa0a3f..f38c96c882ac48887b71fdac46bd0aa0641bfd04
@@@ -275,7 -274,7 +274,7 @@@ static int add_producer( deserialise_co
                                break;
                        default:
                                result = 0;
-                               fprintf( stderr, "Producer defined inside something that isn't a container\n" );
 -                              mlt_log_warning( container, "Producer defined inside something that isn't a container\n" );
++                              mlt_log_warning( NULL, "[producer_xml] Producer defined inside something that isn't a container\n" );
                                break;
                };
  
@@@ -404,7 -403,7 +403,7 @@@ static void on_end_tractor( deserialise
        }
        else
        {
-               fprintf( stderr, "Invalid state for tractor\n" );
 -              mlt_log_warning( tractor, "Invalid state for tractor\n" );
++              mlt_log_error( NULL, "[producer_xml] Invalid state for tractor\n" );
        }
  }
  
@@@ -447,7 -446,7 +446,7 @@@ static void on_start_multitrack( deseri
        }
        else
        {
-               fprintf( stderr, "Invalid multitrack position\n" );
 -              mlt_log_warning( parent, "Invalid multitrack position\n" );
++              mlt_log_error( NULL, "[producer_xml] Invalid multitrack position\n" );
        }
  }
  
@@@ -458,7 -457,7 +457,7 @@@ static void on_end_multitrack( deserial
        mlt_service service = context_pop_service( context, &type );
  
        if ( service == NULL || type != mlt_multitrack_type )
-               fprintf( stderr, "End multitrack in the wrong state...\n" );
 -              mlt_log_warning( service, "End multitrack in the wrong state...\n" );
++              mlt_log_error( NULL, "[producer_xml] End multitrack in the wrong state...\n" );
  }
  
  static void on_start_playlist( deserialise_context context, const xmlChar *name, const xmlChar **atts)
@@@ -507,7 -506,7 +506,7 @@@ static void on_end_playlist( deserialis
        }
        else
        {
-               fprintf( stderr, "Invalid state of playlist end %d\n", type );
 -              mlt_log_warning( service, "Invalid state of playlist end %d\n", type );
++              mlt_log_error( NULL, "[producer_xml] Invalid state of playlist end %d\n", type );
        }
  }
  
@@@ -606,7 -605,7 +605,7 @@@ static void on_end_producer( deserialis
                if ( !producer && resource )
                        producer = MLT_SERVICE( mlt_factory_producer( context->profile, NULL, resource ) );
                if ( !producer )
-                       fprintf( stderr, "failed to load producer \"%s\"\n", resource );
 -                      mlt_log_warning( service, "failed to load producer \"%s\"\n", resource );
++                      mlt_log_error( NULL, "[producer_xml] failed to load producer \"%s\"\n", resource );
                if ( !producer )
                        producer = MLT_SERVICE( mlt_factory_producer( context->profile, NULL, "+INVALID.txt" ) );
                if ( !producer )
@@@ -747,7 -746,7 +746,7 @@@ static void on_start_blank( deserialise
        }
        else
        {
-               fprintf( stderr, "blank without a playlist - a definite no no\n" );
 -              mlt_log_warning( service, "blank without a playlist - a definite no no\n" );
++              mlt_log_error( NULL, "[producer_xml] blank without a playlist - a definite no no\n" );
        }
  }
  
@@@ -801,7 -800,7 +800,7 @@@ static void on_start_entry( deserialise
                }
                else
                {
-                       fprintf( stderr, "Entry not part of a playlist...\n" );
 -                      mlt_log_warning( parent, "Entry not part of a playlist...\n" );
++                      mlt_log_error( NULL, "[producer_xml] Entry not part of a playlist...\n" );
                }
  
                context_push_service( context, parent, parent_type );
@@@ -821,7 -820,7 +820,7 @@@ static void on_end_entry( deserialise_c
  
        if ( entry == NULL && entry_type != mlt_entry_type )
        {
-               fprintf( stderr, "Invalid state at end of entry\n" );
 -              mlt_log_warning( entry, "Invalid state at end of entry\n" );
++              mlt_log_error( NULL, "[producer_xml] Invalid state at end of entry\n" );
        }
  }
  
@@@ -871,7 -870,7 +870,7 @@@ static void on_end_track( deserialise_c
                else if ( parent_type == mlt_multitrack_type )
                        multitrack = MLT_MULTITRACK( parent );
                else
-                       fprintf( stderr, "track contained in an invalid container\n" );
 -                      mlt_log_warning( track, "track contained in an invalid container\n" );
++                      mlt_log_error( NULL, "[producer_xml] track contained in an invalid container\n" );
  
                if ( multitrack != NULL )
                {
        }
        else
        {
-               fprintf( stderr, "Invalid state at end of track\n" );
 -              mlt_log_warning( track, "Invalid state at end of track\n" );
++              mlt_log_error( NULL, "[producer_xml] Invalid state at end of track\n" );
        }
  }
  
@@@ -952,7 -951,7 +951,7 @@@ static void on_end_filter( deserialise_
  
                if ( !filter )
                {
-                       fprintf( stderr, "failed to load filter \"%s\"\n", id );
 -                      mlt_log_warning( service, "failed to load filter \"%s\"\n", id );
++                      mlt_log_error( NULL, "[producer_xml] failed to load filter \"%s\"\n", id );
                        if ( parent )
                                context_push_service( context, parent, parent_type );
                        mlt_service_close( service );
                }
                else
                {
-                       fprintf( stderr, "filter closed with invalid parent...\n" );
 -                      mlt_log_warning( service, "filter closed with invalid parent...\n" );
++                      mlt_log_error( NULL, "[producer_xml] filter closed with invalid parent...\n" );
                }
  
                // Close the dummy filter service
        }
        else
        {
-               fprintf( stderr, "Invalid top of stack on filter close\n" );
 -              mlt_log_warning( service, "Invalid top of stack on filter close\n" );
++              mlt_log_error( NULL, "[producer_xml] Invalid top of stack on filter close\n" );
        }
  }
  
@@@ -1038,7 -1037,7 +1037,7 @@@ static void on_end_transition( deserial
  
                if ( !effect )
                {
-                       fprintf( stderr, "failed to load transition \"%s\"\n", id );
 -                      mlt_log_warning( service, "failed to load transition \"%s\"\n", id );
++                      mlt_log_error( NULL, "[producer_xml] failed to load transition \"%s\"\n", id );
                        if ( parent )
                                context_push_service( context, parent, parent_type );
                        mlt_service_close( service );
                        }
                        else
                        {
-                               fprintf( stderr, "Misplaced transition - ignoring\n" );
 -                              mlt_log_warning( service, "Misplaced transition - ignoring\n" );
++                              mlt_log_warning( NULL, "[producer_xml] Misplaced transition - ignoring\n" );
                        }
  
                        // Put the parent back on the stack
                }
                else
                {
-                       fprintf( stderr, "transition closed with invalid parent...\n" );
 -                      mlt_log_warning( service, "transition closed with invalid parent...\n" );
++                      mlt_log_error( NULL, "[producer_xml] transition closed with invalid parent...\n" );
                }
  
                // Close the dummy filter service
        }
        else
        {
-               fprintf( stderr, "Invalid top of stack on transition close\n" );
 -              mlt_log_warning( service, "Invalid top of stack on transition close\n" );
++              mlt_log_error( NULL, "[producer_xml] Invalid top of stack on transition close\n" );
        }
  }
  
@@@ -1197,7 -1196,7 +1196,7 @@@ static void on_start_property( deserial
        }
        else
        {
-               fprintf( stderr, "Property without a service '%s'?\n", ( const char * )name );
 -              mlt_log_warning( service, "Property without a service '%s'?\n", ( const char * )name );
++              mlt_log_error( NULL, "[producer_xml] Property without a service '%s'?\n", ( const char * )name );
        }
  }
  
@@@ -1238,7 -1237,7 +1237,7 @@@ static void on_end_property( deserialis
        }
        else
        {
-               fprintf( stderr, "Property without a service '%s'??\n", (const char *)name );
 -              mlt_log_warning( service, "Property without a service '%s'??\n", (const char *)name );
++              mlt_log_error( NULL, "[producer_xml] Property without a service '%s'??\n", (const char *)name );
        }
  }
  
@@@ -1247,7 -1246,7 +1246,6 @@@ static void on_start_element( void *ctx
        struct _xmlParserCtxt *xmlcontext = ( struct _xmlParserCtxt* )ctx;
        deserialise_context context = ( deserialise_context )( xmlcontext->_private );
        
--//printf("on_start_element: %s\n", name );
        if ( context->pass == 0 )
        {
                if ( xmlStrcmp( name, _x("mlt") ) == 0 ||
@@@ -1322,7 -1321,7 +1320,6 @@@ static void on_end_element( void *ctx, 
        struct _xmlParserCtxt *xmlcontext = ( struct _xmlParserCtxt* )ctx;
        deserialise_context context = ( deserialise_context )( xmlcontext->_private );
        
--//printf("on_end_element: %s\n", name );
        if ( context->is_value == 1 && context->pass == 1 && xmlStrcmp( name, _x("property") ) != 0 )
                context_pop_node( context );
        else if ( xmlStrcmp( name, _x("multitrack") ) == 0 )
@@@ -1470,26 -1469,13 +1467,26 @@@ static xmlEntityPtr on_get_entity( voi
        return e;
  }
  
 -/** Handle error messages from the parser.
 -*/
--static void   on_error( void * ctx, const char * msg, ...)
++static void   on_error( void * ctx, const char * msg, ... )
  {
--      struct _xmlError* err_ptr = xmlCtxtGetLastError(ctx);
 -      mlt_log_error( NULL, "XML producer parse error: %s\trow: %d\tcol: %d\n",
 -                             err_ptr->message, err_ptr->line, err_ptr->int2 );
++      struct _xmlError* err_ptr = xmlCtxtGetLastError( ctx );
 +
 +      switch( err_ptr->level )
 +      {
 +      case XML_ERR_WARNING:
-               mlt_log_warning( NULL, "XML parse warning: %s\trow: %d\tcol: %d\n",
-                                        err_ptr->message, err_ptr->line, err_ptr->int2);
++              mlt_log_warning( NULL, "[producer_xml] parse warning: %s\trow: %d\tcol: %d\n",
++                                       err_ptr->message, err_ptr->line, err_ptr->int2 );
 +              break;
 +      case XML_ERR_ERROR:
-               mlt_log_error( NULL, "XML parse error: %s\trow: %d\tcol: %d\n",
-                                      err_ptr->message, err_ptr->line, err_ptr->int2);
++              mlt_log_error( NULL, "[producer_xml] parse error: %s\trow: %d\tcol: %d\n",
++                                     err_ptr->message, err_ptr->line, err_ptr->int2 );
 +              break;
 +      default:
 +      case XML_ERR_FATAL:
-               mlt_log_fatal( NULL, "XML parse fatal: %s\trow: %d\tcol: %d\n",
-                                      err_ptr->message, err_ptr->line, err_ptr->int2);
++              mlt_log_fatal( NULL, "[producer_xml] parse fatal: %s\trow: %d\tcol: %d\n",
++                                     err_ptr->message, err_ptr->line, err_ptr->int2 );
 +              break;
 +      }
  }
  
  /** Convert a hexadecimal character to its value.