root/branches/streaming-rework/src/freebob.cpp

Revision 435, 3.5 kB (checked in by pieterpalmers, 17 years ago)

src/devicemanager:
- start OSC server for the device manager

src/devicemanager,
src/iavdevice,
src/libieee1394/configrom:
- inherit from OscNode? to become Osc'able

src/bounce,
src/libstreaming/AmdtpStreamProcessor,
src/libstreaming/AmdtpSlaveStreamProcessor:
- fixed bounce device implementation, now working

src/bebob:
- fixed midi bug

General:
- removed 'intermediate XML'
- removed obsolete tests
- removed obsolete files
- removed obsolete API calls

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 /* freebob.cpp
2  * Copyright (C) 2005 Pieter Palmers, Daniel Wagner
3  *
4  * This file is part of FreeBoB
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19  * MA 02110-1301 USA
20  */
21
22 #include "config.h"
23
24 #include "libfreebob/freebob.h"
25
26 #include "debugmodule/debugmodule.h"
27 #include "fbtypes.h"
28 #include "devicemanager.h"
29 #include "iavdevice.h"
30
31 #include "libavc/avc_generic.h"
32
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <string.h>
36
37 DECLARE_GLOBAL_DEBUG_MODULE;
38 IMPL_GLOBAL_DEBUG_MODULE( FreeBoB, DEBUG_LEVEL_VERBOSE );
39
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43
44 // this is very much nescessary, as otherwise the
45 // message buffer thread doesn't get killed when the
46 // library is dlclose()'d
47
48 static void exitfunc(void) __attribute__((destructor));
49
50 static void exitfunc(void)
51 {
52     delete DebugModuleManager::instance();
53
54 }
55 #ifdef __cplusplus
56 }
57 #endif
58
59 const char*
60 freebob_get_version() {
61     return PACKAGE_STRING;
62 }
63
64
65 int
66 freebob_get_api_version() {
67     return FREEBOB_API_VERSION;
68 }
69
70 freebob_handle_t
71 freebob_new_handle( int port )
72 {
73     freebob_handle_t handle = new struct freebob_handle;
74     if (! handle ) {
75         debugFatal( "Could not allocate memory for new handle\n" );
76         return 0;
77     }
78
79     handle->m_deviceManager = new DeviceManager();
80     if ( !handle->m_deviceManager ) {
81         debugFatal( "Could not allocate device manager\n" );
82         delete handle;
83         return 0;
84     }
85     if ( !handle->m_deviceManager->initialize( port ) ) {
86         debugFatal( "Could not initialize device manager\n" );
87         delete handle->m_deviceManager;
88         delete handle;
89         return 0;
90     }
91     return handle;
92 }
93
94 int
95 freebob_destroy_handle( freebob_handle_t freebob_handle )
96 {
97     delete freebob_handle->m_deviceManager;
98     delete freebob_handle;
99     return 0;
100 }
101
102 int
103 freebob_discover_devices( freebob_handle_t freebob_handle, int verbose )
104 {
105     return freebob_handle->m_deviceManager->discover(verbose)? 0 : -1;
106 }
107
108 int
109 freebob_node_is_valid_freebob_device( freebob_handle_t freebob_handle, int node_id )
110 {
111     return freebob_handle->m_deviceManager->isValidNode( node_id );
112 }
113
114 int
115 freebob_get_nb_devices_on_bus( freebob_handle_t freebob_handle )
116 {
117     return freebob_handle->m_deviceManager->getNbDevices();
118 }
119
120 int
121 freebob_get_device_node_id( freebob_handle_t freebob_handle, int device_nr )
122 {
123     return freebob_handle->m_deviceManager->getDeviceNodeId(device_nr);
124 }
125
126 int
127 freebob_set_samplerate( freebob_handle_t freebob_handle, int node_id, int samplerate )
128 {
129     IAvDevice* avDevice = freebob_handle->m_deviceManager->getAvDevice( node_id );
130     if ( avDevice ) {
131         if ( avDevice->setSamplingFrequency( parseSampleRate( samplerate ) ) ) {
132             return freebob_handle->m_deviceManager->discover(0)? 0 : -1;
133         }
134     }
135     return -1;
136 }
137
138 void freebob_sleep_after_avc_command( int time )
139 {
140     AVCCommand::setSleepAfterAVCCommand( time );
141 }
Note: See TracBrowser for help on using the browser.