root/branches/ppalmers-streaming/src/ffadodevice.cpp

Revision 730, 4.5 kB (checked in by ppalmers, 13 years ago)

- Remove OSC related code
- create DBus server application
- add "scons debian" target that builds a debian package

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_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     return retval;
121 }
122
123 void
124 FFADODevice::handleBusReset()
125 {
126     debugOutput( DEBUG_LEVEL_VERBOSE, "Handle bus reset...\n");
127    
128     // update the config rom node id
129     sleep(1);
130     getConfigRom().setVerboseLevel(getDebugLevel());
131     getConfigRom().updatedNodeId();
132
133 }
134
135 void
136 FFADODevice::setVerboseLevel(int l)
137 {
138     debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l );
139     setDebugLevel(l);
140     getConfigRom().setVerboseLevel(l);
141 }
142
143 void
144 FFADODevice::showDevice()
145 {
146     debugOutput(DEBUG_LEVEL_NORMAL, "Node...........: %d\n", getNodeId());
147     debugOutput(DEBUG_LEVEL_NORMAL, "GUID...........: %s\n", getConfigRom().getGuidString().c_str());
148    
149     std::string id=std::string("dev? [none]");
150     getOption("id", id);
151      
152     debugOutput(DEBUG_LEVEL_NORMAL, "Assigned ID....: %s\n", id.c_str());
153
154     flushDebugOutput();
155 }
156
157
158 bool
159 FFADODevice::enableStreaming() {
160     return true;
161 }
162
163 bool
164 FFADODevice::disableStreaming() {
165     return true;
166 }
167
168 const char *
169 FFADODevice::ClockSourceTypeToString(enum eClockSourceType t)
170 {
171     switch(t) {
172         default:            return "Erratic type      ";
173         case eCT_Invalid:   return "Invalid           ";
174         case eCT_Internal:  return "Internal          ";
175         case eCT_1394Bus:   return "1394 Bus          ";
176         case eCT_SytMatch:  return "Compound Syt Match";
177         case eCT_SytStream: return "Sync Syt Match    ";
178         case eCT_WordClock: return "WordClock         ";
179         case eCT_SPDIF:     return "SPDIF             ";
180         case eCT_ADAT:      return "ADAT              ";
181         case eCT_TDIF:      return "TDIF              ";
182         case eCT_AES:       return "AES               ";
183     }
184 }
Note: See TracBrowser for help on using the browser.