root/trunk/libffado/src/ffado.cpp

Revision 454, 3.5 kB (checked in by ppalmers, 14 years ago)

- fix incorrect referencing of ffado.h

(used the installed version instead of the source tree version).

- fix makefile

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