root/trunk/libffado/src/ffadodevice.cpp

Revision 560, 2.9 kB (checked in by ppalmers, 15 years ago)

- Sort the FFADODevice vector on GUID before assigning device id's

This results in the same device id for identical device setups,
independent of the way they are connected or the node numbers they
have been assigned.

- Sanitized debug message reporting a bit
- Cosmetic changes

Line 
1 /*
2  * Copyright (C) 2005-2007 by Daniel Wagner
3  * Copyright (C) 2005-2007 by Pieter Palmers
4  *
5  * This file is part of FFADO
6  * FFADO = Free Firewire (pro-)audio drivers for linux
7  *
8  * FFADO is based upon FreeBoB
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License version 2.1, as published by the Free Software Foundation;
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22  * MA 02110-1301 USA
23  */
24
25 #include "ffadodevice.h"
26
27 #include "libieee1394/configrom.h"
28 #include "libieee1394/ieee1394service.h"
29
30 #include <iostream>
31 #include <sstream>
32
33 #include <assert.h>
34
35 IMPL_DEBUG_MODULE( FFADODevice, FFADODevice, DEBUG_LEVEL_NORMAL );
36
37 FFADODevice::FFADODevice( std::auto_ptr< ConfigRom >( configRom ),
38                     Ieee1394Service& ieee1394service,
39                     int nodeId )
40     : OscNode()
41     , m_pConfigRom( configRom )
42     , m_p1394Service( &ieee1394service )
43     , m_nodeId ( nodeId )
44 {
45     addOption(Util::OptionContainer::Option("id",std::string("dev?")));
46
47     std::ostringstream nodestr;
48     nodestr << "node" << nodeId;
49     setOscBase(nodestr.str());
50     ConfigRom& c = getConfigRom();
51
52     addChildOscNode(&c);
53 }
54
55 bool FFADODevice::compareGUID( FFADODevice *a, FFADODevice *b ) {
56     assert(a);
57     assert(b);
58     return ConfigRom::compareGUID(a->getConfigRom(), b->getConfigRom());
59 }
60
61 ConfigRom&
62 FFADODevice::getConfigRom() const
63 {
64     return *m_pConfigRom;
65 }
66
67 bool
68 FFADODevice::loadFromCache()
69 {
70     return false;
71 }
72
73 bool
74 FFADODevice::saveCache()
75 {
76     return false;
77 }
78
79 bool
80 FFADODevice::setId( unsigned int id)
81 {
82     bool retval;
83     // FIXME: decent ID system nescessary
84     std::ostringstream idstr;
85     idstr << "dev" << id;
86     debugOutput( DEBUG_LEVEL_VERBOSE, "Set id to %s...\n", idstr.str().c_str());
87
88     retval=setOption("id",idstr.str());
89     if (retval) {
90         setOscBase(idstr.str());
91     }
92     return retval;
93 }
94
95 void
96 FFADODevice::setVerboseLevel(int l)
97 {
98     debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l );
99     setDebugLevel(l);
100 }
101
102 void
103 FFADODevice::showDevice()
104 {
105     debugOutput(DEBUG_LEVEL_NORMAL, "Node...........: %d\n", getNodeId());
106     debugOutput(DEBUG_LEVEL_NORMAL, "GUID...........: %s\n", getConfigRom().getGuidString().c_str());
107    
108     std::string id=std::string("dev? [none]");
109     getOption("id", id);
110      
111     debugOutput(DEBUG_LEVEL_NORMAL, "Assigned ID....: %s\n", id.c_str());
112
113     flushDebugOutput();
114 }
115
116
117 bool
118 FFADODevice::enableStreaming() {
119     return true;
120 }
121
122 bool
123 FFADODevice::disableStreaming() {
124     return true;
125 }
Note: See TracBrowser for help on using the browser.