root/trunk/libffado/src/ffadodevice.cpp

Revision 644, 4.1 kB (checked in by ppalmers, 15 years ago)

- Adapt the phase 88 mixer control application to the new DBUS control interface

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