root/trunk/libffado/src/ffado.cpp

Revision 554, 3.6 kB (checked in by ppalmers, 13 years ago)

Merge echoaudio branch into trunk.

This adds support for the Echo Audiofire devices to FFADO. Possibly also other devices working with the Apple Class Driver will work with this code. It is not fully complete yet, but the main rework is
done.

First of all the IAvDevice class/interface is renamed to FFADODevice, in order to separate the AV/C code from the FFADO API code. A device supported by FFADO implements a FFADODevice.

The BeBoB device has been split up into three groups:
- libavc/* : all code and commands that are specified by AV/C specs. Note that a lot of the code that used to be in BeBoB::AvDevice? now resides in AVC::Unit
- genericavc/* : a FFADODevice that uses AV/C descriptors & commands for discovery and config
- bebob/* : the bebob FFADODevice that inherits from GenericAVC::AvDevice? but that uses BridgeCo? commands for discovery

Everything has been moved as high as possible in the class hierarchy. If necessary, a subclass that uses device specific commands is introduced (e.g. BeBoB::Plug inherits from AVC::Plug and uses the
BridgeCo? extended plug info command to discover it's properties).

There are some other fixes along the way that have been done too.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
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 "config.h"
26
27 #include "../libffado/ffado.h"
28
29 #include "debugmodule/debugmodule.h"
30 #include "fbtypes.h"
31 #include "devicemanager.h"
32 #include "ffadodevice.h"
33
34 #include <stdio.h>
35 #include <stdlib.h>
36 #include <string.h>
37
38 DECLARE_GLOBAL_DEBUG_MODULE;
39 IMPL_GLOBAL_DEBUG_MODULE( FFADO, DEBUG_LEVEL_VERBOSE );
40
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44
45 // this is very much nescessary, as otherwise the
46 // message buffer thread doesn't get killed when the
47 // library is dlclose()'d
48
49 static void exitfunc(void) __attribute__((destructor));
50
51 static void exitfunc(void)
52 {
53     delete DebugModuleManager::instance();
54
55 }
56 #ifdef __cplusplus
57 }
58 #endif
59
60 const char*
61 ffado_get_version() {
62     return PACKAGE_STRING;
63 }
64
65
66 int
67 ffado_get_api_version() {
68     return FFADO_API_VERSION;
69 }
70
71 ffado_handle_t
72 ffado_new_handle( int port )
73 {
74     ffado_handle_t handle = new struct ffado_handle;
75     if (! handle ) {
76         debugFatal( "Could not allocate memory for new handle\n" );
77         return 0;
78     }
79
80     handle->m_deviceManager = new DeviceManager();
81     if ( !handle->m_deviceManager ) {
82         debugFatal( "Could not allocate device manager\n" );
83         delete handle;
84         return 0;
85     }
86     if ( !handle->m_deviceManager->initialize( port ) ) {
87         debugFatal( "Could not initialize device manager\n" );
88         delete handle->m_deviceManager;
89         delete handle;
90         return 0;
91     }
92     return handle;
93 }
94
95 int
96 ffado_destroy_handle( ffado_handle_t ffado_handle )
97 {
98     delete ffado_handle->m_deviceManager;
99     delete ffado_handle;
100     return 0;
101 }
102
103 int
104 ffado_discover_devices( ffado_handle_t ffado_handle, int verbose )
105 {
106     if (verbose) {
107         ffado_handle->m_deviceManager->setVerboseLevel(DEBUG_LEVEL_VERBOSE);
108    }
109     return ffado_handle->m_deviceManager->discover()? 0 : -1;
110 }
111
112 int
113 ffado_node_is_valid_ffado_device( ffado_handle_t ffado_handle, int node_id )
114 {
115     return ffado_handle->m_deviceManager->isValidNode( node_id );
116 }
117
118 int
119 ffado_get_nb_devices_on_bus( ffado_handle_t ffado_handle )
120 {
121     return ffado_handle->m_deviceManager->getNbDevices();
122 }
123
124 int
125 ffado_get_device_node_id( ffado_handle_t ffado_handle, int device_nr )
126 {
127     return ffado_handle->m_deviceManager->getDeviceNodeId(device_nr);
128 }
129
130 int
131 ffado_set_samplerate( ffado_handle_t ffado_handle, int node_id, int samplerate )
132 {
133     FFADODevice* avDevice = ffado_handle->m_deviceManager->getAvDevice( node_id );
134     if ( avDevice ) {
135         if ( avDevice->setSamplingFrequency( samplerate ) ) {
136             return ffado_handle->m_deviceManager->discover()? 0 : -1;
137         }
138     }
139     return -1;
140 }
141
142 #warning this should be cleaned up
143 #include "libavc/general/avc_generic.h"
144 void ffado_sleep_after_avc_command( int time )
145 {
146     AVC::AVCCommand::setSleepAfterAVCCommand( time );
147 }
Note: See TracBrowser for help on using the browser.