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_VERBOSE ); |
---|
36 |
|
---|
37 |
FFADODevice::FFADODevice( Ieee1394Service& ieee1394Service, |
---|
38 |
std::auto_ptr<ConfigRom>( configRom )) |
---|
39 |
: Control::Container() |
---|
40 |
, m_pConfigRom( configRom ) |
---|
41 |
, m_p1394Service( &ieee1394Service ) |
---|
42 |
{ |
---|
43 |
addOption(Util::OptionContainer::Option("id",std::string("dev?"))); |
---|
44 |
|
---|
45 |
std::ostringstream nodestr; |
---|
46 |
nodestr << "node" << getConfigRom().getNodeId(); |
---|
47 |
|
---|
48 |
if (!addElement(&getConfigRom())) { |
---|
49 |
debugWarning("failed to add ConfigRom to Control::Container\n"); |
---|
50 |
} |
---|
51 |
} |
---|
52 |
|
---|
53 |
FFADODevice::~FFADODevice() |
---|
54 |
{ |
---|
55 |
if (!deleteElement(&getConfigRom())) { |
---|
56 |
debugWarning("failed to remove ConfigRom from Control::Container\n"); |
---|
57 |
} |
---|
58 |
} |
---|
59 |
|
---|
60 |
FFADODevice * |
---|
61 |
FFADODevice::createDevice( Ieee1394Service& , |
---|
62 |
std::auto_ptr<ConfigRom>( x )) |
---|
63 |
{ |
---|
64 |
// re-implement this!! |
---|
65 |
assert(0); |
---|
66 |
return NULL; |
---|
67 |
} |
---|
68 |
|
---|
69 |
std::string |
---|
70 |
FFADODevice::getName() |
---|
71 |
{ |
---|
72 |
return getConfigRom().getGuidString(); |
---|
73 |
} |
---|
74 |
|
---|
75 |
int |
---|
76 |
FFADODevice::getNodeId() |
---|
77 |
{ |
---|
78 |
return getConfigRom().getNodeId(); |
---|
79 |
} |
---|
80 |
|
---|
81 |
bool FFADODevice::compareGUID( FFADODevice *a, FFADODevice *b ) { |
---|
82 |
assert(a); |
---|
83 |
assert(b); |
---|
84 |
return ConfigRom::compareGUID(a->getConfigRom(), b->getConfigRom()); |
---|
85 |
} |
---|
86 |
|
---|
87 |
ConfigRom& |
---|
88 |
FFADODevice::getConfigRom() const |
---|
89 |
{ |
---|
90 |
return *m_pConfigRom; |
---|
91 |
} |
---|
92 |
|
---|
93 |
bool |
---|
94 |
FFADODevice::loadFromCache() |
---|
95 |
{ |
---|
96 |
return false; |
---|
97 |
} |
---|
98 |
|
---|
99 |
bool |
---|
100 |
FFADODevice::saveCache() |
---|
101 |
{ |
---|
102 |
return false; |
---|
103 |
} |
---|
104 |
|
---|
105 |
enum FFADODevice::eSyncState |
---|
106 |
FFADODevice::getSyncState( ) { |
---|
107 |
return eSS_Unknown; |
---|
108 |
} |
---|
109 |
|
---|
110 |
bool |
---|
111 |
FFADODevice::setId( unsigned int id) |
---|
112 |
{ |
---|
113 |
bool retval; |
---|
114 |
// FIXME: decent ID system nescessary |
---|
115 |
std::ostringstream idstr; |
---|
116 |
idstr << "dev" << id; |
---|
117 |
debugOutput( DEBUG_LEVEL_VERBOSE, "Set id to %s...\n", idstr.str().c_str()); |
---|
118 |
|
---|
119 |
retval=setOption("id",idstr.str()); |
---|
120 |
/* if (retval) { |
---|
121 |
setOscBase(idstr.str()); |
---|
122 |
}*/ |
---|
123 |
return retval; |
---|
124 |
} |
---|
125 |
|
---|
126 |
void |
---|
127 |
FFADODevice::setVerboseLevel(int l) |
---|
128 |
{ |
---|
129 |
debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l ); |
---|
130 |
setDebugLevel(l); |
---|
131 |
} |
---|
132 |
|
---|
133 |
void |
---|
134 |
FFADODevice::showDevice() |
---|
135 |
{ |
---|
136 |
debugOutput(DEBUG_LEVEL_NORMAL, "Node...........: %d\n", getNodeId()); |
---|
137 |
debugOutput(DEBUG_LEVEL_NORMAL, "GUID...........: %s\n", getConfigRom().getGuidString().c_str()); |
---|
138 |
|
---|
139 |
std::string id=std::string("dev? [none]"); |
---|
140 |
getOption("id", id); |
---|
141 |
|
---|
142 |
debugOutput(DEBUG_LEVEL_NORMAL, "Assigned ID....: %s\n", id.c_str()); |
---|
143 |
|
---|
144 |
flushDebugOutput(); |
---|
145 |
} |
---|
146 |
|
---|
147 |
|
---|
148 |
bool |
---|
149 |
FFADODevice::enableStreaming() { |
---|
150 |
return true; |
---|
151 |
} |
---|
152 |
|
---|
153 |
bool |
---|
154 |
FFADODevice::disableStreaming() { |
---|
155 |
return true; |
---|
156 |
} |
---|
157 |
|
---|
158 |
const char * |
---|
159 |
FFADODevice::ClockSourceTypeToString(enum eClockSourceType t) |
---|
160 |
{ |
---|
161 |
switch(t) { |
---|
162 |
default: return "Erratic type "; |
---|
163 |
case eCT_Invalid: return "Invalid "; |
---|
164 |
case eCT_Internal: return "Internal "; |
---|
165 |
case eCT_1394Bus: return "1394 Bus "; |
---|
166 |
case eCT_SytMatch: return "Compound Syt Match"; |
---|
167 |
case eCT_SytStream: return "Sync Syt Match "; |
---|
168 |
case eCT_WordClock: return "WordClock "; |
---|
169 |
case eCT_SPDIF: return "SPDIF "; |
---|
170 |
case eCT_ADAT: return "ADAT "; |
---|
171 |
case eCT_TDIF: return "TDIF "; |
---|
172 |
case eCT_AES: return "AES "; |
---|
173 |
} |
---|
174 |
} |
---|