root/trunk/libffado/src/ser.cpp

Revision 445, 2.0 kB (checked in by pieterpalmers, 16 years ago)

* name change from FreeBoB to FFADO
* replaced tabs by 4 spaces
* got rid of end-of-line spaces
* made all license and copyrights conform

library becomes LGPL, apps become GPL
explicitly state LGPL v2.1 and GPL v2 (don't like v3 draft)

copyrights are 2005-2007 Daniel & Pieter
except for the MotU stuff (C) Jonathan, Pieter

Line 
1 /*
2  * Copyright (C) 2005-2007 by Daniel Wagner
3  *
4  * This file is part of FFADO
5  * FFADO = Free Firewire (pro-)audio drivers for linux
6  *
7  * FFADO is based upon FreeBoB.
8  *
9  * This is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License version 2
11  * as published by the Free Software Foundation.
12  *
13  * FFADO is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with FFADO; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21  * MA 02111-1307 USA.
22  */
23
24 #include "devicemanager.h"
25 #include "libutil/serialize.h"
26
27 #include <iostream>
28
29 const char FileName[] = "serialize-test.xml";
30
31 static bool
32 serialize( const char* pFileName, int port )
33 {
34     DeviceManager devMgr;
35     if (!devMgr.initialize( port )) {
36         std::cerr << "could not init DeviceManager" << std::endl;
37         return false;
38     }
39
40 //     devMgr.setVerboseLevel(DEBUG_LEVEL_VERBOSE);
41
42     if (!devMgr.discover( )) {
43         std::cerr << "could not discover devices" << std::endl;
44         return false;
45     }
46     return devMgr.saveCache( pFileName );
47 }
48
49 static bool
50 deserialize( const char* pFileName )
51 {
52     DeviceManager devMgr;
53     if (!devMgr.initialize( 0 )) {
54         std::cerr << "could not init DeviceManager" << std::endl;
55         return false;
56     }
57     return devMgr.loadCache( pFileName );
58 }
59
60 int
61 main(  int argc,  char** argv )
62 {
63     int port=0;
64     if (argc==2) {
65         port=atoi(argv[1]);
66     }
67
68     if ( !serialize( FileName, port ) ) {
69         std::cerr << "serializing failed" << std::endl;
70         return -1;
71     }
72     if ( !deserialize( FileName ) ) {
73         std::cerr << "deserializing failed" << std::endl;
74         return -1;
75     }
76
77     std::cout << "passed" << std::endl;
78     return 0;
79 }
Note: See TracBrowser for help on using the browser.