root/trunk/libffado/src/fireworks/fireworks_device.cpp

Revision 607, 3.0 kB (checked in by ppalmers, 14 years ago)

- Fix file-based discovery. The previous code used a pointer to a

vendormodel entry. This pointer however pointed to a VendorModel?
object that was created on the stack of the discover function.
Hence the pointer becomes invalid when the discover function is
exited.

The changes incorporate using a VendorModelEntry? struct instead
of a pointer to it. So now the FFADODevice has it's own copy of
this struct, instead of a pointer to it.

Line 
1 /*
2  * Copyright (C) 2007 by Pieter Palmers
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 library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License version 2.1, as published by the Free Software Foundation;
12  *
13  * This library 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 GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21  * MA 02110-1301 USA
22  */
23
24 #include "fireworks_device.h"
25
26 #include "audiofire/audiofire_device.h"
27
28 #include "libieee1394/configrom.h"
29 #include "libieee1394/ieee1394service.h"
30
31 #include "config.h"
32
33 // FireWorks is the platform used and developed by ECHO AUDIO
34 namespace FireWorks {
35
36 Device::Device( Ieee1394Service& ieee1394Service,
37                             std::auto_ptr<ConfigRom>( configRom ))
38     : GenericAVC::AvDevice( ieee1394Service, configRom)
39 {
40     debugOutput( DEBUG_LEVEL_VERBOSE, "Created FireWorks::Device (NodeID %d)\n",
41                  getConfigRom().getNodeId() );
42 }
43
44 Device::~Device()
45 {
46 }
47
48 void
49 Device::showDevice()
50 {
51     debugOutput(DEBUG_LEVEL_VERBOSE, "This is a FireWorks::Device\n");
52     GenericAVC::AvDevice::showDevice();
53 }
54
55
56 bool
57 Device::probe( ConfigRom& configRom )
58 {
59     unsigned int vendorId = configRom.getNodeVendorId();
60     unsigned int modelId = configRom.getModelId();
61
62     GenericAVC::VendorModel vendorModel( SHAREDIR "/ffado_driver_fireworks.txt" );
63     if ( vendorModel.parse() ) {
64         vendorModel.printTable();
65         return vendorModel.isPresent( vendorId, modelId );
66     }
67
68     return false;
69 }
70
71 bool
72 Device::discover()
73 {
74     unsigned int vendorId = m_pConfigRom->getNodeVendorId();
75     unsigned int modelId = m_pConfigRom->getModelId();
76
77     GenericAVC::VendorModel vendorModel( SHAREDIR "/ffado_driver_fireworks.txt" );
78     if ( vendorModel.parse() ) {
79         m_model = vendorModel.find( vendorId, modelId );
80     }
81
82     if (!GenericAVC::VendorModel::isValid(m_model)) {
83         return false;
84     }
85     debugOutput( DEBUG_LEVEL_VERBOSE, "found %s %s\n",
86             m_model.vendor_name.c_str(), m_model.model_name.c_str());
87
88     if ( !GenericAVC::AvDevice::discover() ) {
89         debugError( "Could not discover GenericAVC::AvDevice\n" );
90         return false;
91     }
92
93     return true;
94 }
95
96 FFADODevice *
97 Device::createDevice( Ieee1394Service& ieee1394Service,
98                       std::auto_ptr<ConfigRom>( configRom ))
99 {
100     unsigned int vendorId = configRom->getNodeVendorId();
101     unsigned int modelId = configRom->getModelId();
102
103     switch(vendorId) {
104         case FW_VENDORID_ECHO: return new ECHO::AudioFire(ieee1394Service, configRom );
105         default: return new Device(ieee1394Service, configRom );
106     }
107 }
108
109
110 } // FireWorks
Note: See TracBrowser for help on using the browser.