Changeset 445
- Timestamp:
- 04/02/07 12:35:17 (5 years ago)
- Files:
-
- trunk/libffado/autogen.sh (modified) (1 diff)
- trunk/libffado/ChangeLog (modified) (5 diffs)
- trunk/libffado/configure.ac (modified) (8 diffs)
- trunk/libffado/doc/adding_devices.dox (modified) (10 diffs)
- trunk/libffado/doc/amdtpstreamprocessor.dox (modified) (1 diff)
- trunk/libffado/doc/mainpage.dox (modified) (2 diffs)
- trunk/libffado/doc/reference.doxygen.in (modified) (2 diffs)
- trunk/libffado/doc/streaming.xmi (modified) (15 diffs)
- trunk/libffado/libffado.pc.in (modified) (1 diff)
- trunk/libffado/Makefile.am (modified) (2 diffs)
- trunk/libffado/src/bebob-sync.cpp (modified) (5 diffs)
- trunk/libffado/src/bebob/bebob_avdevice.cpp (modified) (31 diffs)
- trunk/libffado/src/bebob/bebob_avdevice.h (modified) (4 diffs)
- trunk/libffado/src/bebob/bebob_avdevice_subunit.cpp (modified) (1 diff)
- trunk/libffado/src/bebob/bebob_avdevice_subunit.h (modified) (6 diffs)
- trunk/libffado/src/bebob/bebob_avplug.cpp (modified) (1 diff)
- trunk/libffado/src/bebob/bebob_avplug.h (modified) (12 diffs)
- trunk/libffado/src/bebob/bebob_dl_bcd.cpp (modified) (1 diff)
- trunk/libffado/src/bebob/bebob_dl_bcd.h (modified) (5 diffs)
- trunk/libffado/src/bebob/bebob_dl_codes.cpp (modified) (1 diff)
- trunk/libffado/src/bebob/bebob_dl_codes.h (modified) (8 diffs)
- trunk/libffado/src/bebob/bebob_dl_mgr.cpp (modified) (1 diff)
- trunk/libffado/src/bebob/bebob_dl_mgr.h (modified) (3 diffs)
- trunk/libffado/src/bebob/bebob_functionblock.cpp (modified) (1 diff)
- trunk/libffado/src/bebob/bebob_functionblock.h (modified) (3 diffs)
- trunk/libffado/src/bounce/bounce_avdevice.cpp (modified) (31 diffs)
- trunk/libffado/src/bounce/bounce_avdevice.h (modified) (6 diffs)
- trunk/libffado/src/bounce/bounce_slave_avdevice.cpp (modified) (27 diffs)
- trunk/libffado/src/bounce/bounce_slave_avdevice.h (modified) (7 diffs)
- trunk/libffado/src/bridgeco-downloader.cpp (modified) (5 diffs)
- trunk/libffado/src/debugmodule/debugmodule.cpp (modified) (15 diffs)
- trunk/libffado/src/debugmodule/debugmodule.h (modified) (9 diffs)
- trunk/libffado/src/debugmodule/test_debugmodule.cpp (modified) (1 diff)
- trunk/libffado/src/devicemanager.cpp (modified) (24 diffs)
- trunk/libffado/src/devicemanager.h (modified) (3 diffs)
- trunk/libffado/src/dice/dice_avdevice.cpp (modified) (84 diffs)
- trunk/libffado/src/dice/dice_avdevice.h (modified) (11 diffs)
- trunk/libffado/src/dice/dice_defines.h (modified) (4 diffs)
- trunk/libffado/src/fbtypes.h (modified) (2 diffs)
- trunk/libffado/src/ffado.cpp (modified) (8 diffs)
- trunk/libffado/src/ffado_streaming.cpp (modified) (30 diffs)
- trunk/libffado/src/iavdevice.cpp (modified) (3 diffs)
- trunk/libffado/src/iavdevice.h (modified) (6 diffs)
- trunk/libffado/src/libavc/avc_connect.cpp (modified) (1 diff)
- trunk/libffado/src/libavc/avc_connect.h (modified) (2 diffs)
- trunk/libffado/src/libavc/avc_definitions.cpp (modified) (1 diff)
- trunk/libffado/src/libavc/avc_definitions.h (modified) (4 diffs)
- trunk/libffado/src/libavc/avc_extended_cmd_generic.cpp (modified) (4 diffs)
- trunk/libffado/src/libavc/avc_extended_cmd_generic.h (modified) (5 diffs)
- trunk/libffado/src/libavc/avc_extended_plug_info.cpp (modified) (1 diff)
- trunk/libffado/src/libavc/avc_extended_plug_info.h (modified) (3 diffs)
- trunk/libffado/src/libavc/avc_extended_stream_format.cpp (modified) (3 diffs)
- trunk/libffado/src/libavc/avc_extended_stream_format.h (modified) (3 diffs)
- trunk/libffado/src/libavc/avc_extended_subunit_info.cpp (modified) (1 diff)
- trunk/libffado/src/libavc/avc_extended_subunit_info.h (modified) (3 diffs)
- trunk/libffado/src/libavc/avc_function_block.cpp (modified) (6 diffs)
- trunk/libffado/src/libavc/avc_function_block.h (modified) (3 diffs)
- trunk/libffado/src/libavc/avc_generic.cpp (modified) (3 diffs)
- trunk/libffado/src/libavc/avc_generic.h (modified) (6 diffs)
- trunk/libffado/src/libavc/avc_plug_info.cpp (modified) (1 diff)
- trunk/libffado/src/libavc/avc_plug_info.h (modified) (4 diffs)
- trunk/libffado/src/libavc/avc_serialize.cpp (modified) (3 diffs)
- trunk/libffado/src/libavc/avc_serialize.h (modified) (4 diffs)
- trunk/libffado/src/libavc/avc_signal_source.cpp (modified) (1 diff)
- trunk/libffado/src/libavc/avc_signal_source.h (modified) (3 diffs)
- trunk/libffado/src/libavc/avc_subunit_info.cpp (modified) (1 diff)
- trunk/libffado/src/libavc/avc_subunit_info.h (modified) (4 diffs)
- trunk/libffado/src/libavc/avc_unit_info.cpp (modified) (1 diff)
- trunk/libffado/src/libavc/avc_unit_info.h (modified) (3 diffs)
- trunk/libffado/src/libieee1394/ARMHandler.cpp (modified) (5 diffs)
- trunk/libffado/src/libieee1394/ARMHandler.h (modified) (6 diffs)
- trunk/libffado/src/libieee1394/configrom.cpp (modified) (10 diffs)
- trunk/libffado/src/libieee1394/configrom.h (modified) (4 diffs)
- trunk/libffado/src/libieee1394/IEC61883.cpp (modified) (1 diff)
- trunk/libffado/src/libieee1394/IEC61883.h (modified) (5 diffs)
- trunk/libffado/src/libieee1394/ieee1394service.cpp (modified) (32 diffs)
- trunk/libffado/src/libieee1394/ieee1394service.h (modified) (14 diffs)
- trunk/libffado/src/libosc/OscArgument.cpp (modified) (5 diffs)
- trunk/libffado/src/libosc/OscArgument.h (modified) (4 diffs)
- trunk/libffado/src/libosc/OscMessage.cpp (modified) (3 diffs)
- trunk/libffado/src/libosc/OscMessage.h (modified) (3 diffs)
- trunk/libffado/src/libosc/OscNode.cpp (modified) (13 diffs)
- trunk/libffado/src/libosc/OscNode.h (modified) (4 diffs)
- trunk/libffado/src/libosc/OscResponse.cpp (modified) (1 diff)
- trunk/libffado/src/libosc/OscResponse.h (modified) (4 diffs)
- trunk/libffado/src/libosc/OscServer.cpp (modified) (6 diffs)
- trunk/libffado/src/libosc/OscServer.h (modified) (3 diffs)
- trunk/libffado/src/libosc/unittests.cpp (modified) (13 diffs)
- trunk/libffado/src/libstreaming/AmdtpPort.cpp (modified) (1 diff)
- trunk/libffado/src/libstreaming/AmdtpPort.h (modified) (3 diffs)
- trunk/libffado/src/libstreaming/AmdtpPortInfo.cpp (modified) (1 diff)
- trunk/libffado/src/libstreaming/AmdtpPortInfo.h (modified) (4 diffs)
- trunk/libffado/src/libstreaming/AmdtpSlaveStreamProcessor.cpp (modified) (24 diffs)
- trunk/libffado/src/libstreaming/AmdtpSlaveStreamProcessor.h (modified) (7 diffs)
- trunk/libffado/src/libstreaming/AmdtpStreamProcessor.cpp (modified) (61 diffs)
- trunk/libffado/src/libstreaming/AmdtpStreamProcessor.h (modified) (13 diffs)
- trunk/libffado/src/libstreaming/cip.h (modified) (6 diffs)
- trunk/libffado/src/libstreaming/cycletimer.h (modified) (25 diffs)
- trunk/libffado/src/libstreaming/IsoHandler.cpp (modified) (41 diffs)
- trunk/libffado/src/libstreaming/IsoHandler.h (modified) (12 diffs)
- trunk/libffado/src/libstreaming/IsoHandlerManager.cpp (modified) (22 diffs)
- trunk/libffado/src/libstreaming/IsoHandlerManager.h (modified) (7 diffs)
- trunk/libffado/src/libstreaming/IsoStream.cpp (modified) (3 diffs)
- trunk/libffado/src/libstreaming/IsoStream.h (modified) (6 diffs)
- trunk/libffado/src/libstreaming/MotuPort.cpp (modified) (1 diff)
- trunk/libffado/src/libstreaming/MotuPort.h (modified) (4 diffs)
- trunk/libffado/src/libstreaming/MotuPortInfo.cpp (modified) (1 diff)
- trunk/libffado/src/libstreaming/MotuPortInfo.h (modified) (4 diffs)
- trunk/libffado/src/libstreaming/MotuStreamProcessor.cpp (modified) (42 diffs)
- trunk/libffado/src/libstreaming/MotuStreamProcessor.h (modified) (4 diffs)
- trunk/libffado/src/libstreaming/Port.cpp (modified) (5 diffs)
- trunk/libffado/src/libstreaming/Port.h (modified) (7 diffs)
- trunk/libffado/src/libstreaming/PortManager.cpp (modified) (5 diffs)
- trunk/libffado/src/libstreaming/PortManager.h (modified) (4 diffs)
- trunk/libffado/src/libstreaming/StreamProcessor.cpp (modified) (19 diffs)
- trunk/libffado/src/libstreaming/StreamProcessor.h (modified) (15 diffs)
- trunk/libffado/src/libstreaming/StreamProcessorManager.cpp (modified) (47 diffs)
- trunk/libffado/src/libstreaming/StreamProcessorManager.h (modified) (9 diffs)
- trunk/libffado/src/libutil/Atomic.h (modified) (10 diffs)
- trunk/libffado/src/libutil/cycles.h (modified) (7 diffs)
- trunk/libffado/src/libutil/DelayLockedLoop.cpp (modified) (20 diffs)
- trunk/libffado/src/libutil/DelayLockedLoop.h (modified) (3 diffs)
- trunk/libffado/src/libutil/OptionContainer.cpp (modified) (11 diffs)
- trunk/libffado/src/libutil/OptionContainer.h (modified) (14 diffs)
- trunk/libffado/src/libutil/PacketBuffer.cpp (modified) (4 diffs)
- trunk/libffado/src/libutil/PacketBuffer.h (modified) (3 diffs)
- trunk/libffado/src/libutil/PosixThread.cpp (modified) (6 diffs)
- trunk/libffado/src/libutil/PosixThread.h (modified) (6 diffs)
- trunk/libffado/src/libutil/ringbuffer.c (modified) (17 diffs)
- trunk/libffado/src/libutil/ringbuffer.h (modified) (16 diffs)
- trunk/libffado/src/libutil/serialize.cpp (modified) (3 diffs)
- trunk/libffado/src/libutil/serialize.h (modified) (1 diff)
- trunk/libffado/src/libutil/StreamStatistics.cpp (modified) (1 diff)
- trunk/libffado/src/libutil/StreamStatistics.h (modified) (3 diffs)
- trunk/libffado/src/libutil/SystemTimeSource.cpp (modified) (2 diffs)
- trunk/libffado/src/libutil/SystemTimeSource.h (modified) (4 diffs)
- trunk/libffado/src/libutil/test-dll.cpp (modified) (4 diffs)
- trunk/libffado/src/libutil/Thread.h (modified) (3 diffs)
- trunk/libffado/src/libutil/Time.c (modified) (2 diffs)
- trunk/libffado/src/libutil/Time.h (modified) (3 diffs)
- trunk/libffado/src/libutil/TimeSource.cpp (modified) (15 diffs)
- trunk/libffado/src/libutil/TimeSource.h (modified) (6 diffs)
- trunk/libffado/src/libutil/TimestampedBuffer.cpp (modified) (59 diffs)
- trunk/libffado/src/libutil/TimestampedBuffer.h (modified) (11 diffs)
- trunk/libffado/src/libutil/unittests.cpp (modified) (10 diffs)
- trunk/libffado/src/Makefile.am (modified) (11 diffs)
- trunk/libffado/src/maudio/fw410.xml (modified) (2 diffs)
- trunk/libffado/src/maudio/fwap.xml (modified) (2 diffs)
- trunk/libffado/src/maudio/maudio_avdevice.cpp (modified) (3 diffs)
- trunk/libffado/src/maudio/maudio_avdevice.h (modified) (4 diffs)
- trunk/libffado/src/maudio/refdesign.xml (modified) (2 diffs)
- trunk/libffado/src/metrichalo/mh_avdevice.cpp (modified) (6 diffs)
- trunk/libffado/src/metrichalo/mh_avdevice.h (modified) (3 diffs)
- trunk/libffado/src/motu/motu_avdevice.cpp (modified) (19 diffs)
- trunk/libffado/src/motu/motu_avdevice.h (modified) (6 diffs)
- trunk/libffado/src/rme/rme_avdevice.cpp (modified) (1 diff)
- trunk/libffado/src/rme/rme_avdevice.h (modified) (1 diff)
- trunk/libffado/src/ser.cpp (modified) (3 diffs)
- trunk/libffado/src/threads.h (modified) (7 diffs)
- trunk/libffado/support/jack/ffado_driver.c (modified) (68 diffs)
- trunk/libffado/support/jack/ffado_driver.h (modified) (12 diffs)
- trunk/libffado/tests/Makefile.am (modified) (2 diffs)
- trunk/libffado/tests/streaming/debugtools.c (modified) (1 diff)
- trunk/libffado/tests/streaming/debugtools.h (modified) (1 diff)
- trunk/libffado/tests/streaming/Makefile.am (modified) (2 diffs)
- trunk/libffado/tests/streaming/test-isohandling.cpp (modified) (3 diffs)
- trunk/libffado/tests/streaming/testmidistreaming1.c (modified) (1 diff)
- trunk/libffado/tests/streaming/teststreaming.c (modified) (1 diff)
- trunk/libffado/tests/streaming/teststreaming2.c (modified) (1 diff)
- trunk/libffado/tests/streaming/teststreaming3.c (modified) (1 diff)
- trunk/libffado/tests/SytMonitor.cpp (modified) (5 diffs)
- trunk/libffado/tests/SytMonitor.h (modified) (3 diffs)
- trunk/libffado/tests/test-cycletimer.cpp (modified) (12 diffs)
- trunk/libffado/tests/test-extplugcmd.cpp (modified) (4 diffs)
- trunk/libffado/tests/test-ffado.cpp (modified) (24 diffs)
- trunk/libffado/tests/test-freebob.cpp (deleted)
- trunk/libffado/tests/test-fw410.cpp (modified) (5 diffs)
- trunk/libffado/tests/test-ieee1394service.cpp (modified) (5 diffs)
- trunk/libffado/tests/test-mixer.cpp (modified) (2 diffs)
- trunk/libffado/tests/test-sytmonitor.cpp (modified) (21 diffs)
- trunk/libffado/tests/test-timestampedbuffer.cpp (modified) (27 diffs)
- trunk/libffado/tests/test-volume.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/autogen.sh
r125 r445 2 2 # Run this to generate all the initial makefiles, etc. 3 3 4 5 4 autoreconf -f -i -s 6 ./configure --enable-maintainer-mode7 maketrunk/libffado/ChangeLog
r336 r445 1 REMARK: Please use the SVN commit messages as replacement for ChangeLog 2 3 2007-03-20 Pieter Palmers 4 * name change from FreeBoB to FFADO 5 * replaced tabs by 4 spaces 6 * got rid of end-of-line spaces 7 * made all license and copyrights conform 8 library becomes LGPL, apps become GPL 9 explicitly state LGPL v2.1 and GPL v2 (don't like v3 draft) 10 copyrights are 2005-2007 Daniel & Pieter 11 except for the MotU stuff (C) Jonathan, Pieter 12 1 13 2006-11-20 Daniel Wagner <wagi@monom.org> 2 14 3 * freebob_set_samplerate: return value consitency fix. On success4 it return 0 else -1. Reported by Jamie Gennis jgennis at gmail dot com5 6 * freebob_streaming_start: Reset the playback ringbuffer before calling7 freebob_streaming_start.8 15 * freebob_set_samplerate: return value consitency fix. On success 16 it return 0 else -1. Reported by Jamie Gennis jgennis at gmail dot com 17 18 * freebob_streaming_start: Reset the playback ringbuffer before calling 19 freebob_streaming_start. 20 9 21 2006-11-12 Daniel Wagner <wagi@monom.org> 10 22 11 * test mixer programm added.12 13 * basic function block AV/C commands added.14 test program for setting the volume added.23 * test mixer programm added. 24 25 * basic function block AV/C commands added. 26 test program for setting the volume added. 15 27 16 28 2006-11-11 Daniel Wagner <wagi@monom.org> 17 29 18 * src/bebob/bebob_avdevice.cpp (setSamplingFrequencyPlug): copy past19 error fixed. Reported by Jamie Gennis jgennis at gmail dot com30 * src/bebob/bebob_avdevice.cpp (setSamplingFrequencyPlug): copy past 31 error fixed. Reported by Jamie Gennis jgennis at gmail dot com 20 32 21 33 2006-08-27 Daniel Wagner <wagi@monom.org> 22 34 23 * configure.ac: Version set to 1.4.024 * maudio device support infrastructure added. Implements25 IAvDevice interface, discover reads the information from26 an xml file.35 * configure.ac: Version set to 1.4.0 36 * maudio device support infrastructure added. Implements 37 IAvDevice interface, discover reads the information from 38 an xml file. 27 39 28 40 2006-08-22 Daniel Wagner <wagi@monom.org> 29 41 30 * configure.ac: Version bump to 1.3.031 * freebob_sync allows now to set the sync mode. It does not32 check yet if it really could set the mode.42 * configure.ac: Version bump to 1.3.0 43 * freebob_sync allows now to set the sync mode. It does not 44 check yet if it really could set the mode. 33 45 34 46 2006-07-17 Daniel Wagner <wagi@monom.org> 35 47 36 * configure.ac: Version bump to 1.2.037 * freebob_sync program added38 * Basic interface added for sync info48 * configure.ac: Version bump to 1.2.0 49 * freebob_sync program added 50 * Basic interface added for sync info 39 51 40 52 2006-07-02 Daniel Wagner <wagi@monom.org> 41 53 42 * firmware downloader: check device firmware compatibility54 * firmware downloader: check device firmware compatibility 43 55 44 56 2006-06-27 Daniel Wagner <wagi@monom.org> 45 57 46 * configure.ac: Version bump to 1.1.047 * remove bebob_light code48 * downloader various improvements49 * ConfigRom::isAvcDevice() removed. Device probe code added.50 Each device driver class can check if it supports a device.58 * configure.ac: Version bump to 1.1.0 59 * remove bebob_light code 60 * downloader various improvements 61 * ConfigRom::isAvcDevice() removed. Device probe code added. 62 Each device driver class can check if it supports a device. 51 63 52 64 2006-06-24 Daniel Wagner <wagi@monom.org> 53 65 54 * tests/streaming/Makefile.am: Fixed build problem with missing '/'.66 * tests/streaming/Makefile.am: Fixed build problem with missing '/'. 55 67 56 68 2006-06-21 Daniel Wagner <wagi@monom.org> 57 69 58 * freebob-downloader first version added70 * freebob-downloader first version added 59 71 60 72 2006-06-10 Daniel Wagner <wagi@monom.org> 61 73 62 * Changed building rules: No static sub libraries63 are build anymore.74 * Changed building rules: No static sub libraries 75 are build anymore. 64 76 65 77 2006-06-01 Daniel Wagner <wagi@monom.org> 66 78 67 * configure.ac: Version bump to 1.0.068 69 * Changed all FreeBob to FreeBoB70 * Removed all .cvsignore71 * Added Pieter to AUTHORS72 * Updated NEWS and README (release canditate date added)79 * configure.ac: Version bump to 1.0.0 80 81 * Changed all FreeBob to FreeBoB 82 * Removed all .cvsignore 83 * Added Pieter to AUTHORS 84 * Updated NEWS and README (release canditate date added) 73 85 74 86 2006-05-31 Daniel Wagner <wagi@monom.org> 75 87 76 * Free all allocated asprintf buffers after xmlNewChild.77 Compiler warning removed88 * Free all allocated asprintf buffers after xmlNewChild. 89 Compiler warning removed 78 90 79 91 2006-05-31 Pieter Palmers <pieterpalmers@users.sourceforge.net> … … 110 122 111 123 2006-05-26 Pieter Palmers <pieterpalmers@users.sourceforge.net> 112 * src/libfreebobstreaming/*:124 * src/libfreebobstreaming/*: 113 125 - added a 'verbose' option to disable/enable message output 114 126 - removed some residual messages … … 131 143 132 144 2006-05-12 Pieter Palmers <pieterpalmers@users.sourceforge.net> 133 * src/libfreebobstreaming/*:134 - Code cleanup135 - Improved SSE code136 - ISO connection parameters are calculated instead of being user137 specified. Note: you need a new jackd backend version due to this.138 139 * configure.ac: Version bumped to 0.8.2145 * src/libfreebobstreaming/*: 146 - Code cleanup 147 - Improved SSE code 148 - ISO connection parameters are calculated instead of being user 149 specified. Note: you need a new jackd backend version due to this. 150 151 * configure.ac: Version bumped to 0.8.2 140 152 141 153 2006-05-06 Daniel Wagner <wagi@monom.org> 142 154 143 * This patch fixes two issues when building:144 - libfreebob include files aren't found when build dir != source dir145 - some libraries aren't found when they're not in a system install dir146 147 Jeremy Kerr155 * This patch fixes two issues when building: 156 - libfreebob include files aren't found when build dir != source dir 157 - some libraries aren't found when they're not in a system install dir 158 159 Jeremy Kerr 148 160 149 161 2006-05-04 Pieter Palmers <pieterpalmers@users.sourceforge.net> 150 162 151 * configure.ac: Version bumped to 0.8.1152 153 * Introduced SSE-accellerated packet encoders/decoders163 * configure.ac: Version bumped to 0.8.1 164 165 * Introduced SSE-accellerated packet encoders/decoders 154 166 155 167 2006-05-04 Daniel Wagner <wagi@monom.org> 156 168 157 * configure.ac: Version bumped to 0.8.0158 159 * Discovering code ported stable 0.2.0 version160 to head and activated for default discovering.169 * configure.ac: Version bumped to 0.8.0 170 171 * Discovering code ported stable 0.2.0 version 172 to head and activated for default discovering. 161 173 162 174 2006-05-04 Daniel Wagner <wagi@monom.org> 163 175 164 * configure.ac: Version bumped to 0.7.2165 166 * src/bebob: Some cleanup on naming and167 namespaces.176 * configure.ac: Version bumped to 0.7.2 177 178 * src/bebob: Some cleanup on naming and 179 namespaces. 168 180 169 181 2006-05-03 Daniel Wagner <wagi@monom.org> 170 182 171 * configure.ac: Version bumped to 0.7.1172 173 * Fixed bug in SignalSource command which174 prevented one to set the samplerate.183 * configure.ac: Version bumped to 0.7.1 184 185 * Fixed bug in SignalSource command which 186 prevented one to set the samplerate. 175 187 176 188 2006-04-23 Daniel Wagner <wagi@monom.org> 177 189 178 * configure.ac: Version bumped to 0.7.0179 180 * Abstract interface IAvDevice introduced.181 * BeBoB device discovering code moved into bebob directory.182 * Bounce device added.190 * configure.ac: Version bumped to 0.7.0 191 192 * Abstract interface IAvDevice introduced. 193 * BeBoB device discovering code moved into bebob directory. 194 * Bounce device added. 183 195 184 196 2006-04-17 Daniel Wagner <wagi@monom.org> 185 197 186 * configure.ac: Version bumped to 0.6.4187 188 * src/libfreebobavc/avc_generic.cpp (serialize): Decode subunit_type189 and subunit_id field.190 (fire): avc1394_transaction_block2 inteface change update.191 * src/libfreebobavc/ieee1394service.cpp (transactionBlock): Likewise.192 * src/libfreebobavc/ieee1394service.h: Likewise.198 * configure.ac: Version bumped to 0.6.4 199 200 * src/libfreebobavc/avc_generic.cpp (serialize): Decode subunit_type 201 and subunit_id field. 202 (fire): avc1394_transaction_block2 inteface change update. 203 * src/libfreebobavc/ieee1394service.cpp (transactionBlock): Likewise. 204 * src/libfreebobavc/ieee1394service.h: Likewise. 193 205 194 206 2006-04-11 Daniel Wagner <wagi@monom.org> 195 207 196 * configure.ac: Version bumped to 0.6.3197 198 * src/avdevicesubunit.cpp (discoverFunctionBlocks): reformating.199 (discoverFunctionBlocksDo): Really added a correct200 bugfix for the reuse of ExtendedSubunitInfoCmd.208 * configure.ac: Version bumped to 0.6.3 209 210 * src/avdevicesubunit.cpp (discoverFunctionBlocks): reformating. 211 (discoverFunctionBlocksDo): Really added a correct 212 bugfix for the reuse of ExtendedSubunitInfoCmd. 201 213 202 214 2006-04-07 Pieter Palmers <pieterpalmers@users.sourceforge.net> 203 215 204 * src/avdevice.h src/avdevice.cpp: moved the include of stdint.h205 from the implementation to the header, to fix certain compilation206 problems wrt uint64_t. This datatype is also used in the class207 definition in avdevice.h.216 * src/avdevice.h src/avdevice.cpp: moved the include of stdint.h 217 from the implementation to the header, to fix certain compilation 218 problems wrt uint64_t. This datatype is also used in the class 219 definition in avdevice.h. 208 220 209 221 2006-04-05 Pieter Palmers <pieterpalmers@users.sourceforge.net> 210 222 211 * configure.ac: Version bump to 0.6.2212 213 * src/freebob.cpp: Retry setting the sample rate if it fails the214 first time.215 216 * src/libfreebobstreaming/*: Added an way to choose for playback217 or capture only (for ALSA plugin), using the options passed when218 creating the freebob device. * src/libfreebobstreaming/*: fixed219 the bug that prevented playback only operation.223 * configure.ac: Version bump to 0.6.2 224 225 * src/freebob.cpp: Retry setting the sample rate if it fails the 226 first time. 227 228 * src/libfreebobstreaming/*: Added an way to choose for playback 229 or capture only (for ALSA plugin), using the options passed when 230 creating the freebob device. * src/libfreebobstreaming/*: fixed 231 the bug that prevented playback only operation. 220 232 221 233 2006-04-04 Daniel Wagner <wagi@monom.org> 222 234 223 * configure.ac: Version bump to 0.6.1224 225 * src/avdevicesubunit.cpp (discoverFunctionBlocksDo):226 ExtendedSubunitInfoCmd is not reusable at this point.227 Moved into its own block so that's initatilialized correctly.235 * configure.ac: Version bump to 0.6.1 236 237 * src/avdevicesubunit.cpp (discoverFunctionBlocksDo): 238 ExtendedSubunitInfoCmd is not reusable at this point. 239 Moved into its own block so that's initatilialized correctly. 228 240 229 241 2006-03-30 Daniel Wagner <wagi@monom.org> 230 242 231 * configure.ac: Version bump to 0.6.0232 233 * src/*: Verbose bool turned int verbose level.234 235 * src/libfreebobavc/*: Moved fire implementation to236 base class (AVCCommand).237 238 * libfreebob/freebob.h: freebob_sleep_after_avc_command239 workaround added.240 241 * tests/test-freebob.c: Verbose bool turned into verbose level.242 Workaround: sleep after avc command added.243 244 * tests/streaming/Makefile.am (*_SOURCES): Added libavc1394 to LDADD.245 * tests/Makefile.am (*_SOURCES): Likewise.246 247 * tests/streaming/teststreaming2.c (fid_in): compiler warning fixed.243 * configure.ac: Version bump to 0.6.0 244 245 * src/*: Verbose bool turned int verbose level. 246 247 * src/libfreebobavc/*: Moved fire implementation to 248 base class (AVCCommand). 249 250 * libfreebob/freebob.h: freebob_sleep_after_avc_command 251 workaround added. 252 253 * tests/test-freebob.c: Verbose bool turned into verbose level. 254 Workaround: sleep after avc command added. 255 256 * tests/streaming/Makefile.am (*_SOURCES): Added libavc1394 to LDADD. 257 * tests/Makefile.am (*_SOURCES): Likewise. 258 259 * tests/streaming/teststreaming2.c (fid_in): compiler warning fixed. 248 260 249 261 2006-03-20 Daniel Wagner <wagi@monom.org> 250 262 251 * configure.ac: Version bump to 0.5.2252 253 * src/avplug.cpp (discoverStreamFormat): If no stream format information254 is available or format hierarchy root is not Audio&Music skip plug.255 (discoverSupportedStreamFormats): Added 'support' for IEC60968-3 (SPDIF transparent)263 * configure.ac: Version bump to 0.5.2 264 265 * src/avplug.cpp (discoverStreamFormat): If no stream format information 266 is available or format hierarchy root is not Audio&Music skip plug. 267 (discoverSupportedStreamFormats): Added 'support' for IEC60968-3 (SPDIF transparent) 256 268 257 269 2006-03-15 Daniel Wagner <wagi@monom.org> 258 270 259 * configure.ac: Version bump to 0.5.1260 261 * src/libfreebobavc/avc_extended_plug_info.cpp (fire):262 Handle NOT_IMPLEMENTED.263 264 * src/avplug.h: Input and output plug discovering part265 fixed. Now connection are correctly handled.266 * src/avplug.cpp: Likewise.267 * src/avdevicesubunit.cpp: Likewise.271 * configure.ac: Version bump to 0.5.1 272 273 * src/libfreebobavc/avc_extended_plug_info.cpp (fire): 274 Handle NOT_IMPLEMENTED. 275 276 * src/avplug.h: Input and output plug discovering part 277 fixed. Now connection are correctly handled. 278 * src/avplug.cpp: Likewise. 279 * src/avdevicesubunit.cpp: Likewise. 268 280 269 281 2006-03-12 Daniel Wagner <wagi@monom.org> 270 282 271 * src/libfreebobavc/ieee1394service.cpp (transactionBlock): Set retry272 value to 10.283 * src/libfreebobavc/ieee1394service.cpp (transactionBlock): Set retry 284 value to 10. 273 285 274 286 2006-03-10 Daniel Wagner <wagi@monom.org> 275 287 276 * configure.ac: Version bump to 0.5.0277 278 * src/avdevice.cpp: Plug connection discovering279 finished.280 * src/avdevicesubunit.cpp: Likewise.281 * src/avdevicesubunit.h: Likewise.282 * src/avplug.cpp: Likewise.283 * src/avplug.h: Likewise.284 * src/functionblock.cpp: Likewise.285 * src/functionblock.h: Likewise.286 287 * src/libfreebobavc/Makefile.am: New files added.288 * src/libfreebobavc/avc_extended_subunit_info.cpp: Likewise.289 * src/libfreebobavc/avc_extended_subunit_info.h: Likewise290 291 * src/libfreebobavc/avc_definitions.h: Several small improvements.292 * src/libfreebobavc/avc_extended_cmd_generic.cpp: Likewise.293 * src/libfreebobavc/avc_extended_cmd_generic.h: Likewise.294 * src/libfreebobavc/avc_extended_plug_info.cpp: Likewise.295 * src/libfreebobavc/avc_generic.cpp: Likewise.288 * configure.ac: Version bump to 0.5.0 289 290 * src/avdevice.cpp: Plug connection discovering 291 finished. 292 * src/avdevicesubunit.cpp: Likewise. 293 * src/avdevicesubunit.h: Likewise. 294 * src/avplug.cpp: Likewise. 295 * src/avplug.h: Likewise. 296 * src/functionblock.cpp: Likewise. 297 * src/functionblock.h: Likewise. 298 299 * src/libfreebobavc/Makefile.am: New files added. 300 * src/libfreebobavc/avc_extended_subunit_info.cpp: Likewise. 301 * src/libfreebobavc/avc_extended_subunit_info.h: Likewise 302 303 * src/libfreebobavc/avc_definitions.h: Several small improvements. 304 * src/libfreebobavc/avc_extended_cmd_generic.cpp: Likewise. 305 * src/libfreebobavc/avc_extended_cmd_generic.h: Likewise. 306 * src/libfreebobavc/avc_extended_plug_info.cpp: Likewise. 307 * src/libfreebobavc/avc_generic.cpp: Likewise. 296 308 297 309 2006-03-05 Daniel Wagner <wagi@monom.org> 298 310 299 * src/avdevice.cpp: Plug connection discovering also on300 subunits (disabled because missing funciton blocks).301 Sync connections code cleanup.302 * src/avdevice.h: Likewise.303 * src/avdevicesubunit.cpp: Likewise.304 * src/avdevicesubunit.h: Likewise.305 * src/avplug.cpp: Likewise.306 * src/avplug.h: Likewise.307 308 * src/Makefile.am: Added functionblock.cpp and309 functionblock.h310 * src/functionblock.cpp: New file311 * src/functionblock.h: Likewise.311 * src/avdevice.cpp: Plug connection discovering also on 312 subunits (disabled because missing funciton blocks). 313 Sync connections code cleanup. 314 * src/avdevice.h: Likewise. 315 * src/avdevicesubunit.cpp: Likewise. 316 * src/avdevicesubunit.h: Likewise. 317 * src/avplug.cpp: Likewise. 318 * src/avplug.h: Likewise. 319 320 * src/Makefile.am: Added functionblock.cpp and 321 functionblock.h 322 * src/functionblock.cpp: New file 323 * src/functionblock.h: Likewise. 312 324 313 325 2006-03-04 Daniel Wagner <wagi@monom.org> 314 326 315 * src/avdevice.cpp: Sync mode discovering improved.316 * src/avdevice.h: Likewise.317 * src/avplug.cpp: Likewise.318 * src/avplug.h: Likewise.319 320 * tests/test-freebob.c: Added 'odiscover' command which321 does not print the xml stuff.322 323 * src/avdevice.cpp: Added 'verbose' argument to constructor324 and set debug level to DEBUG_LEVEL_VERBOSE if 'verbose'325 is true, e.g enables verbose mode with '-v' argument passed326 to test-freebob.327 * src/avdevice.h: Likewsise.328 * src/avdevicesubunit.cpp: Likewsise.329 * src/avdevicesubunit.h: Likewsise.330 * src/avplug.cpp: Likewsise.331 * src/avplug.h: Likewsise.332 * src/devicemanager.cpp: Likewsise.333 * src/debugmodule/debugmodule.cpp: Likewsise.334 * src/debugmodule/debugmodule.h: Likewsise.335 * src/debugmodule/test_debugmodule.cpp: Likewsise.336 337 * src/avdevice.cpp: eAP_* renamed into eAPA_*.338 EAvPlugDirection and EAvPlugType introduced. All PlugAddress:ePD_ and339 ExtendedPlugInfoPlugTypeSpecificData::eEPIPT_* exchanged with corresponding340 AvPlug definitions.341 * src/avdevice.h: Likewise.342 * src/avdevicesubunit.cpp: Likewise.343 * src/avdevicesubunit.h: Likewise.344 * src/avdevicexml.cpp: Likewise.345 * src/avplug.cpp: Likewise.346 * src/avplug.h: Likewise.327 * src/avdevice.cpp: Sync mode discovering improved. 328 * src/avdevice.h: Likewise. 329 * src/avplug.cpp: Likewise. 330 * src/avplug.h: Likewise. 331 332 * tests/test-freebob.c: Added 'odiscover' command which 333 does not print the xml stuff. 334 335 * src/avdevice.cpp: Added 'verbose' argument to constructor 336 and set debug level to DEBUG_LEVEL_VERBOSE if 'verbose' 337 is true, e.g enables verbose mode with '-v' argument passed 338 to test-freebob. 339 * src/avdevice.h: Likewsise. 340 * src/avdevicesubunit.cpp: Likewsise. 341 * src/avdevicesubunit.h: Likewsise. 342 * src/avplug.cpp: Likewsise. 343 * src/avplug.h: Likewsise. 344 * src/devicemanager.cpp: Likewsise. 345 * src/debugmodule/debugmodule.cpp: Likewsise. 346 * src/debugmodule/debugmodule.h: Likewsise. 347 * src/debugmodule/test_debugmodule.cpp: Likewsise. 348 349 * src/avdevice.cpp: eAP_* renamed into eAPA_*. 350 EAvPlugDirection and EAvPlugType introduced. All PlugAddress:ePD_ and 351 ExtendedPlugInfoPlugTypeSpecificData::eEPIPT_* exchanged with corresponding 352 AvPlug definitions. 353 * src/avdevice.h: Likewise. 354 * src/avdevicesubunit.cpp: Likewise. 355 * src/avdevicesubunit.h: Likewise. 356 * src/avdevicexml.cpp: Likewise. 357 * src/avplug.cpp: Likewise. 358 * src/avplug.h: Likewise. 347 359 348 360 2006-03-02 Daniel Wagner <wagi@monom.org> 349 361 350 * src/avplug.cpp (discoverStreamFormat): Sanity check turned351 into warning.352 353 * configure.ac: bumb minor version to 0.4354 355 * src/libfreebobavc/avc_extended_cmd_generic.h: plugAddressPlugDirectionToString356 and plugAddressAddressModeToString added.357 * src/libfreebobavc/avc_extended_cmd_generic.cpp: Likewise.358 359 * src/avplug.h: Enum EAvPlugType renamed to EAvPlugAddressType.360 getPlugAddressType added. getPlugType returns now real plug type.361 (class AvPlugManager): getPlugByType added.362 363 * src/avdevice.h: getPlugByType added.364 * src/avdevice.cpp: Likewise.365 (discoverSyncModes): Use getPlugByType instead366 of hardcoded id to find sync plugs.367 368 * src/devicemanager.h: Verbose argument not in constructor369 instead in discover method.370 * src/devicemanager.cpp: Likewise.371 372 * libfreebob/freebob.h (freebob_discover_devices): Verbose argument373 added.374 * src/libfreebobstreaming/freebob_streaming.c: Likewise.375 * src/freebob.cpp: Likewise.376 * tests/test-freebob.c: Likewise.362 * src/avplug.cpp (discoverStreamFormat): Sanity check turned 363 into warning. 364 365 * configure.ac: bumb minor version to 0.4 366 367 * src/libfreebobavc/avc_extended_cmd_generic.h: plugAddressPlugDirectionToString 368 and plugAddressAddressModeToString added. 369 * src/libfreebobavc/avc_extended_cmd_generic.cpp: Likewise. 370 371 * src/avplug.h: Enum EAvPlugType renamed to EAvPlugAddressType. 372 getPlugAddressType added. getPlugType returns now real plug type. 373 (class AvPlugManager): getPlugByType added. 374 375 * src/avdevice.h: getPlugByType added. 376 * src/avdevice.cpp: Likewise. 377 (discoverSyncModes): Use getPlugByType instead 378 of hardcoded id to find sync plugs. 379 380 * src/devicemanager.h: Verbose argument not in constructor 381 instead in discover method. 382 * src/devicemanager.cpp: Likewise. 383 384 * libfreebob/freebob.h (freebob_discover_devices): Verbose argument 385 added. 386 * src/libfreebobstreaming/freebob_streaming.c: Likewise. 387 * src/freebob.cpp: Likewise. 388 * tests/test-freebob.c: Likewise. 377 389 378 390 2006-03-01 Daniel Wagner <wagi@monom.org> 379 391 380 * configure.ac: bumb minor version to 0.3381 382 * src/avdevice.cpp: Discover connections between plugs.383 * src/avdevice.h: Likewise.384 * src/avdevicesubunit.cpp: Likewise.385 * src/avdevicesubunit.h: Likewise.386 * src/avdevicexml.cpp: Likewise.387 * src/avplug.cpp: Likewise.388 * src/avplug.h: Likewise.389 * src/devicemanager.cpp: Likewise.390 * src/devicemanager.h: Likewise.391 * src/freebob.cpp: Likewise.392 393 * src/libfreebobavc/avc_extended_cmd_generic.cpp: Give394 return value to caller. New undefined plug address395 introduced. Handling of response message is more rebust now.396 * src/libfreebobavc/avc_extended_cmd_generic.h: Likewise.397 * src/libfreebobavc/avc_extended_plug_info.cpp: Likewise.398 * src/libfreebobavc/avc_extended_stream_format.cpp: Likewise.399 * src/libfreebobavc/avc_extended_stream_format.h: Likewise.400 * src/libfreebobavc/avc_plug_info.cpp: Likewise.401 * src/libfreebobavc/avc_signal_source.cpp: Likewise.402 * src/libfreebobavc/avc_signal_source.h: Likewise.403 * src/libfreebobavc/avc_subunit_info.cpp: Likewise.404 * src/libfreebobavc/avc_unit_info.cpp: Likewise.405 * src/libfreebobavc/avc_extended_plug_info.cpp: Likewise.406 * src/libfreebobavc/avc_extended_stream_format.cpp: Likewise.407 * src/libfreebobavc/avc_extended_cmd_generic.cpp:408 * src/libfreebobavc/avc_extended_cmd_generic.h: Likewise.409 410 * src/libfreebobstreaming/freebob_debug.h: DEBUG is defined through --enable-debug411 switch.412 413 * src/libfreebobstreaming/freebob_connections.h: Removed double defined variable414 if DEBUG is defined.392 * configure.ac: bumb minor version to 0.3 393 394 * src/avdevice.cpp: Discover connections between plugs. 395 * src/avdevice.h: Likewise. 396 * src/avdevicesubunit.cpp: Likewise. 397 * src/avdevicesubunit.h: Likewise. 398 * src/avdevicexml.cpp: Likewise. 399 * src/avplug.cpp: Likewise. 400 * src/avplug.h: Likewise. 401 * src/devicemanager.cpp: Likewise. 402 * src/devicemanager.h: Likewise. 403 * src/freebob.cpp: Likewise. 404 405 * src/libfreebobavc/avc_extended_cmd_generic.cpp: Give 406 return value to caller. New undefined plug address 407 introduced. Handling of response message is more rebust now. 408 * src/libfreebobavc/avc_extended_cmd_generic.h: Likewise. 409 * src/libfreebobavc/avc_extended_plug_info.cpp: Likewise. 410 * src/libfreebobavc/avc_extended_stream_format.cpp: Likewise. 411 * src/libfreebobavc/avc_extended_stream_format.h: Likewise. 412 * src/libfreebobavc/avc_plug_info.cpp: Likewise. 413 * src/libfreebobavc/avc_signal_source.cpp: Likewise. 414 * src/libfreebobavc/avc_signal_source.h: Likewise. 415 * src/libfreebobavc/avc_subunit_info.cpp: Likewise. 416 * src/libfreebobavc/avc_unit_info.cpp: Likewise. 417 * src/libfreebobavc/avc_extended_plug_info.cpp: Likewise. 418 * src/libfreebobavc/avc_extended_stream_format.cpp: Likewise. 419 * src/libfreebobavc/avc_extended_cmd_generic.cpp: 420 * src/libfreebobavc/avc_extended_cmd_generic.h: Likewise. 421 422 * src/libfreebobstreaming/freebob_debug.h: DEBUG is defined through --enable-debug 423 switch. 424 425 * src/libfreebobstreaming/freebob_connections.h: Removed double defined variable 426 if DEBUG is defined. 415 427 416 428 2006-02-28 Pieter Palmers <pieterpalmers@users.sourceforge.net> 417 * Added the streaming API that was previously hardcoded into the jackd backend418 to the library as src/libfreebobstreaming.419 * Added test programs for the streaming API in tests/streaming429 * Added the streaming API that was previously hardcoded into the jackd backend 430 to the library as src/libfreebobstreaming. 431 * Added test programs for the streaming API in tests/streaming 420 432 421 433 2006-02-26 Daniel Wagner <wagi@monom.org> 422 434 423 * src/avdevice.cpp: Some more refactoring (m_isoInputPlugs and m_isoOutputPlugs424 unified into m_isoPlugs). Discovering of unit external plugs.425 * src/avdevice.h: Likewise.426 * src/avdevicexml.cpp: Likewise.427 * src/avdevicesubunit.cpp: Likewise.428 * src/avdevicesubunit.h: Likewise.429 * src/avplug.cpp: Likewise.430 * src/avplug.h: Likewise.431 432 * src/libfreebobavc/avc_extended_cmd_generic.h (class UnitPlugAddress):433 ePT_Unknown enum added.435 * src/avdevice.cpp: Some more refactoring (m_isoInputPlugs and m_isoOutputPlugs 436 unified into m_isoPlugs). Discovering of unit external plugs. 437 * src/avdevice.h: Likewise. 438 * src/avdevicexml.cpp: Likewise. 439 * src/avdevicesubunit.cpp: Likewise. 440 * src/avdevicesubunit.h: Likewise. 441 * src/avplug.cpp: Likewise. 442 * src/avplug.h: Likewise. 443 444 * src/libfreebobavc/avc_extended_cmd_generic.h (class UnitPlugAddress): 445 ePT_Unknown enum added. 434 446 435 447 2006-02-22 Daniel Wagner <wagi@monom.org> 436 448 437 * configure.ac438 src/Makefile.am449 * configure.ac 450 src/Makefile.am 439 451 src/avdevice.cpp 440 452 src/avdevice.h … … 443 455 src/avdevicexml.cpp 444 456 src/avplug.cpp 445 src/avplug.h457 src/avplug.h 446 458 src/avplugxml.cpp 447 459 src/libfreebobavc/avc_extended_plug_info.cpp … … 451 463 src/libfreebobavc/avc_plug_info.cpp 452 464 src/libfreebobavc/avc_plug_info.h: 453 Refactoring: plug discovering is now part of AvPlug454 instead of AvDevice.455 All plugs of music and audio subunit are now also456 discovered.457 libfreebobavc: Copy constructor added.458 459 The overhaul is not finished. This is the first460 version which works again.465 Refactoring: plug discovering is now part of AvPlug 466 instead of AvDevice. 467 All plugs of music and audio subunit are now also 468 discovered. 469 libfreebobavc: Copy constructor added. 470 471 The overhaul is not finished. This is the first 472 version which works again. 461 473 462 474 2006-01-19 Daniel Wagner <wagi@monom.org> 463 475 464 476 * This patch cleans up the external dependency detection for 465 libfreebob. At present, building libfreebob is not possible466 if libraries are outside the system include/library paths467 (ie /usr/ and /usr/local). Use the results of pkg-config to468 specify the correct paths to the automake system.469 470 Becuase we're using pkgconfig, there's no real need to use471 AC_CHECK_LIB or AC_CHECK_HEADERS. However, these could472 potentially be reinstated, but need to be fixed to check in473 the locations specified by pkgconfig.474 475 * It is not currently possible to build freebob in a directory476 outside the source dir (ie, builddir != srcdir). This patch477 fixes the include paths to allow this. (it's handy for keeping478 the source tree clean, or when building on multiple architectures479 - I use a build dir of $srcdir/obj-$arch-$os)480 481 Both patches are written by Jeremy Kerr jk at ozlabs dot org477 libfreebob. At present, building libfreebob is not possible 478 if libraries are outside the system include/library paths 479 (ie /usr/ and /usr/local). Use the results of pkg-config to 480 specify the correct paths to the automake system. 481 482 Becuase we're using pkgconfig, there's no real need to use 483 AC_CHECK_LIB or AC_CHECK_HEADERS. However, these could 484 potentially be reinstated, but need to be fixed to check in 485 the locations specified by pkgconfig. 486 487 * It is not currently possible to build freebob in a directory 488 outside the source dir (ie, builddir != srcdir). This patch 489 fixes the include paths to allow this. (it's handy for keeping 490 the source tree clean, or when building on multiple architectures 491 - I use a build dir of $srcdir/obj-$arch-$os) 492 493 Both patches are written by Jeremy Kerr jk at ozlabs dot org 482 494 483 495 2006-01-12 Daniel Wagner <wagi@monom.org> 484 496 485 * src/avdevice.cpp: Include stdint.h.486 Some compilers seem to need the definitions.497 * src/avdevice.cpp: Include stdint.h. 498 Some compilers seem to need the definitions. 487 499 488 500 2006-01-08 Daniel Wagner <wagi@monom.org> 489 501 490 * libfreebob/freebob.h491 libfreebob/xmlparser.h492 src/avdevice.cpp493 src/xmlparser.c494 tests/test-freebob.c:495 Add stream format info support.502 * libfreebob/freebob.h 503 libfreebob/xmlparser.h 504 src/avdevice.cpp 505 src/xmlparser.c 506 tests/test-freebob.c: 507 Add stream format info support. 496 508 497 509 * src/avdevice.h 498 src/avdevice.cpp:499 Refactoring and code duplication removal.500 501 * src/avdevice.cpp (getModelName):502 Return model name and not vendor name.503 (getVendorName):504 Return vendor name and not model name.505 (discoverStep10Plug): Implementation added.506 (enumerateSubUnits): max_subunit_id removed.507 (addXmlDescription): Add stream format infos.508 509 * src/avdevice.h: discoverStep10 added.510 Renaming of addPlugToXmlDescription to addXmlDescriptionPlug.511 ESampleRate to ESamplingFrequency changes.512 513 * src/avplug.cpp (getSampleRate):514 Use convertESamplingFrequency instead of515 local implementation.516 517 * src/avplug.h:518 ESampleRate to ESamplingFrequency changes.519 Added FormatInfo struct.520 521 * src/devicemanager.cpp (getXmlDescription):522 Print GUID correctly.523 524 * src/freebob.cpp (parseSampleRate):525 Moved to avc_definitions.cpp526 527 * src/libfreebobavc/avc_definitions.h528 src/libfreebobavc/avc_definitions.cpp:529 Renamed ESampleRate back to ESamlingFrequency.530 Added connvert functions for ESamplingFrequency.531 532 * configure.ac: New micro version.510 src/avdevice.cpp: 511 Refactoring and code duplication removal. 512 513 * src/avdevice.cpp (getModelName): 514 Return model name and not vendor name. 515 (getVendorName): 516 Return vendor name and not model name. 517 (discoverStep10Plug): Implementation added. 518 (enumerateSubUnits): max_subunit_id removed. 519 (addXmlDescription): Add stream format infos. 520 521 * src/avdevice.h: discoverStep10 added. 522 Renaming of addPlugToXmlDescription to addXmlDescriptionPlug. 523 ESampleRate to ESamplingFrequency changes. 524 525 * src/avplug.cpp (getSampleRate): 526 Use convertESamplingFrequency instead of 527 local implementation. 528 529 * src/avplug.h: 530 ESampleRate to ESamplingFrequency changes. 531 Added FormatInfo struct. 532 533 * src/devicemanager.cpp (getXmlDescription): 534 Print GUID correctly. 535 536 * src/freebob.cpp (parseSampleRate): 537 Moved to avc_definitions.cpp 538 539 * src/libfreebobavc/avc_definitions.h 540 src/libfreebobavc/avc_definitions.cpp: 541 Renamed ESampleRate back to ESamlingFrequency. 542 Added connvert functions for ESamplingFrequency. 543 544 * configure.ac: New micro version. 533 545 534 546 2006-01-06 Daniel Wagner <wagi@monom.org> 535 547 536 * tests/test-freebob.c (main): setsamplerate on all537 devices takes now the samplerate argument.538 539 * src/freebob.cpp (freebob_set_samplerate): After setting540 sampling rate rediscover devices.541 542 * src/devicemanager.cpp (discover): Clear vector as well after543 delete all elements. Cout and cerr replaced with debugModule.544 545 * src/avdevice.cpp (discoverStep8): Skip sync plug.546 (discoverStep9): Sanity check fixed and reenabled.547 548 * configure.ac: New micro version.549 550 * src/avdevice.h551 src/avdevice.cpp (setSampleRate): Implementation added.552 553 * src/devicemanager.cpp554 src/devicemanager.h (getAvDevice): New functions555 (setNodeSampleFrequency): removed.556 557 * src/freebob.cpp (parseSampleRate): New function.558 (freebob_set_samplerate): Use AvDevice directly559 for setting samplerate.560 561 * src/libfreebobavc/avc_definitions.h562 src/libfreebobavc/avc_definitions.cpp: Changed ESampleFrequency563 to ESampleRate.564 565 * tests/test-freebob.c: Info added about OPERATION arguments.566 Parse sample rate for setsamplerate command.567 Let emacs reindent code. Sorry Pieter :)548 * tests/test-freebob.c (main): setsamplerate on all 549 devices takes now the samplerate argument. 550 551 * src/freebob.cpp (freebob_set_samplerate): After setting 552 sampling rate rediscover devices. 553 554 * src/devicemanager.cpp (discover): Clear vector as well after 555 delete all elements. Cout and cerr replaced with debugModule. 556 557 * src/avdevice.cpp (discoverStep8): Skip sync plug. 558 (discoverStep9): Sanity check fixed and reenabled. 559 560 * configure.ac: New micro version. 561 562 * src/avdevice.h 563 src/avdevice.cpp (setSampleRate): Implementation added. 564 565 * src/devicemanager.cpp 566 src/devicemanager.h (getAvDevice): New functions 567 (setNodeSampleFrequency): removed. 568 569 * src/freebob.cpp (parseSampleRate): New function. 570 (freebob_set_samplerate): Use AvDevice directly 571 for setting samplerate. 572 573 * src/libfreebobavc/avc_definitions.h 574 src/libfreebobavc/avc_definitions.cpp: Changed ESampleFrequency 575 to ESampleRate. 576 577 * tests/test-freebob.c: Info added about OPERATION arguments. 578 Parse sample rate for setsamplerate command. 579 Let emacs reindent code. Sorry Pieter :) 568 580 569 581 2006-01-04 Daniel Wagner <wagi@monom.org> 570 582 571 * tests/test-extplugcmd.cpp: Changed test application572 to use PlugType and PlugName command for testing.573 574 * src/libfreebobavc/avc_extended_plug_info.cpp (serialize):575 The string.length() thing did not work as expected. A workaround576 added which converts the C++ string into a C string before strlen577 is used.583 * tests/test-extplugcmd.cpp: Changed test application 584 to use PlugType and PlugName command for testing. 585 586 * src/libfreebobavc/avc_extended_plug_info.cpp (serialize): 587 The string.length() thing did not work as expected. A workaround 588 added which converts the C++ string into a C string before strlen 589 is used. 578 590 579 591 2006-01-03 Daniel Wagner <wagi@monom.org> 580 592 581 * src/devicemanager.cpp (discover): If config rom initializing582 failes just skip this device. The PHY might be in power safe583 mode and then there is no config rom to be discovered.593 * src/devicemanager.cpp (discover): If config rom initializing 594 failes just skip this device. The PHY might be in power safe 595 mode and then there is no config rom to be discovered. 584 596 585 597 2006-01-02 Pieter Palmer <pieterpalmers@users.sourceforge.net> 586 598 587 * tests/test-freebob.c: Added support for scanning the whole bus.588 Added xmldump operation to dump an XML description of the FW bus.589 590 * src/freebob.cpp src/freebob.h: Added freebob_print_xml_description591 to print an XML description of the bus.592 Added freebob_node_is_valid_freebob_device().593 Added freebob_get_nb_devices_on_bus().594 Added freebob_get_device_node_id().595 Added freebob_set_samplerate() as a dummy (unimplemented)596 597 * src/libfreebobavc/avc_connect.cpp598 src/libfreebobavc/avc_extended_stream_format.cpp599 src/libfreebobavc/avc_extended_stream_format.h600 src/libfreebobavc/avc_plug_info.cpp601 src/libfreebobavc/avc_signal_source.cpp602 src/avcdevice.cpp603 src/avdevice.h604 src/avplug.cpp605 src/avplug.h606 src/devicemanager.cpp607 src/devicemanager.h:608 Fixed NodeId bug.609 Commented out sanity check that failed for midi channels.610 Fixed Dimension bug.611 Increased all "XXX random length" requests.612 Made a mess of clean code ;)613 614 * configure.ac: Bumped library verson615 616 * src/xmlparser.c617 tests/test-freeebob.c: Added support to detect & use618 multiple devices on the bus.619 620 * src/libfreebobavc/avc_extendec_plug_info.cpp621 src/configrom.cpp:622 Some small memory access bugfixes.623 599 * tests/test-freebob.c: Added support for scanning the whole bus. 600 Added xmldump operation to dump an XML description of the FW bus. 601 602 * src/freebob.cpp src/freebob.h: Added freebob_print_xml_description 603 to print an XML description of the bus. 604 Added freebob_node_is_valid_freebob_device(). 605 Added freebob_get_nb_devices_on_bus(). 606 Added freebob_get_device_node_id(). 607 Added freebob_set_samplerate() as a dummy (unimplemented) 608 609 * src/libfreebobavc/avc_connect.cpp 610 src/libfreebobavc/avc_extended_stream_format.cpp 611 src/libfreebobavc/avc_extended_stream_format.h 612 src/libfreebobavc/avc_plug_info.cpp 613 src/libfreebobavc/avc_signal_source.cpp 614 src/avcdevice.cpp 615 src/avdevice.h 616 src/avplug.cpp 617 src/avplug.h 618 src/devicemanager.cpp 619 src/devicemanager.h: 620 Fixed NodeId bug. 621 Commented out sanity check that failed for midi channels. 622 Fixed Dimension bug. 623 Increased all "XXX random length" requests. 624 Made a mess of clean code ;) 625 626 * configure.ac: Bumped library verson 627 628 * src/xmlparser.c 629 tests/test-freeebob.c: Added support to detect & use 630 multiple devices on the bus. 631 632 * src/libfreebobavc/avc_extendec_plug_info.cpp 633 src/configrom.cpp: 634 Some small memory access bugfixes. 635 624 636 2006-01-02 Daniel Wagner <wagi@monom.org> 625 637 626 * src/avdevice.cpp (discoverStep9): Sanity check: 8 logical627 midi channel fit into 1 channel.638 * src/avdevice.cpp (discoverStep9): Sanity check: 8 logical 639 midi channel fit into 1 channel. 628 640 629 641 2005-12-31 Daniel Wagner <wagi@monom.org> 630 642 631 * src/debugmodule/debugmodule.h: debugFatal, debugError632 and debugWarning declaration always declared.633 634 * src/xmlparser.c (freebob_xmlparse_connection): Parse IsoChannel635 node.636 637 * src/freebob.cpp (freebob_print_connection_info): Print all638 members from connection_spec (IsoChannel and IsMaster).639 640 * src/avdevice.cpp (addPlugToXmlDescription): Set direction641 according library interface definition and not according642 avc model.643 Add IsoChannel node.644 645 * configure.ac: Version set to 0.0.2643 * src/debugmodule/debugmodule.h: debugFatal, debugError 644 and debugWarning declaration always declared. 645 646 * src/xmlparser.c (freebob_xmlparse_connection): Parse IsoChannel 647 node. 648 649 * src/freebob.cpp (freebob_print_connection_info): Print all 650 members from connection_spec (IsoChannel and IsMaster). 651 652 * src/avdevice.cpp (addPlugToXmlDescription): Set direction 653 according library interface definition and not according 654 avc model. 655 Add IsoChannel node. 656 657 * configure.ac: Version set to 0.0.2 646 658 647 659 2005-12-30 Daniel Wagner <wagi@monom.org> 648 660 649 * src/libfreebobavc/avc_extended_stream_format.cpp (fire): Buffer650 length increased.651 652 * src/avdevice.cpp (discoverStep9): Error message extended.653 More debug info added.654 655 * src/debugmodule/debugmodule.h: Enable debugFatal, debugError and656 also in the release case.661 * src/libfreebobavc/avc_extended_stream_format.cpp (fire): Buffer 662 length increased. 663 664 * src/avdevice.cpp (discoverStep9): Error message extended. 665 More debug info added. 666 667 * src/debugmodule/debugmodule.h: Enable debugFatal, debugError and 668 also in the release case. 657 669 658 670 2005-12-28 Daniel Wagner <wagi@monom.org> 659 671 660 * tests/test-freebob.c (main): Debug info added.661 662 * src/libfreebobavc/ieee1394service.cpp (initialize): Use663 raw1394_new_handle_on_port instead of raw1394_new_handle and664 raw1394_set_port.665 666 * src/devicemanager.cpp (initialize): After deleteing 1394 service667 clear also pointer.668 669 * libfreebob/freebob.h: freebob_direction enum names changed670 members which jack backed freebob needs to freebob_connection added671 672 * configure.ac: Update library version depency.672 * tests/test-freebob.c (main): Debug info added. 673 674 * src/libfreebobavc/ieee1394service.cpp (initialize): Use 675 raw1394_new_handle_on_port instead of raw1394_new_handle and 676 raw1394_set_port. 677 678 * src/devicemanager.cpp (initialize): After deleteing 1394 service 679 clear also pointer. 680 681 * libfreebob/freebob.h: freebob_direction enum names changed 682 members which jack backed freebob needs to freebob_connection added 683 684 * configure.ac: Update library version depency. 673 685 674 686 2005-12-27 Daniel Wagner <wagi@monom.org> 675 687 676 * src/libfreebobavc/avc_extended_plug_info.cpp (serialize):677 Do cast of the length field to let the compiler know which version678 of the serializing code it has to take.688 * src/libfreebobavc/avc_extended_plug_info.cpp (serialize): 689 Do cast of the length field to let the compiler know which version 690 of the serializing code it has to take. 679 691 680 692 2005-12-26 Daniel Wagner <wagi@monom.org> 681 693 682 * Initial check-in and first beta relase 'late x-mass gift'.683 684 694 * Initial check-in and first beta relase 'late x-mass gift'. 695 696 trunk/libffado/configure.ac
r435 r445 1 # configure.ac - Configure script for F reeBoB.1 # configure.ac - Configure script for FFADO. 2 2 # Copyright (C) 2005,06 by Daniel Wagner. 3 3 # Copyright (C) 2006,07 by Pieter Palmers. 4 4 # 5 # This file is part of FreeBoB. 5 # This file is part of FFADO. 6 # FFADO is based upon FreeBoB. 6 7 # 7 # F reeBoBis free software; you can redistribute it and/or modify8 # FFADO is free software; you can redistribute it and/or modify 8 9 # it under the terms of the GNU General Public License as published by 9 10 # the Free Software Foundation; either version 2 of the License, or 10 11 # (at your option) any later version. 11 # F reeBoBis distributed in the hope that it will be useful,12 # FFADO is distributed in the hope that it will be useful, 12 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 15 # GNU General Public License for more details. 15 16 # You should have received a copy of the GNU General Public License 16 # along with F reeBoB; if not, write to the Free Software17 # along with FFADO; if not, write to the Free Software 17 18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 19 # … … 23 24 24 25 25 m4_define(f reebob_major_version, 1)26 m4_define(f reebob_minor_version, 999)27 m4_define(f reebob_micro_version, 4)28 29 m4_define(f reebob_version, freebob_major_version.freebob_minor_version.freebob_micro_version)30 31 AC_INIT(libf reebob, freebob_version, <freebob-devel@lists.sf.net>)26 m4_define(ffado_major_version, 1) 27 m4_define(ffado_minor_version, 999) 28 m4_define(ffado_micro_version, 4) 29 30 m4_define(ffado_version, ffado_major_version.ffado_minor_version.ffado_micro_version) 31 32 AC_INIT(libffado, ffado_version, <ffado-devel@lists.sf.net>) 32 33 33 34 # Before making a release, the LT_VERSION string should be modified. … … 39 40 # - If the interface is the same as the previous version, change to C:R+1:A 40 41 41 LT_VERSION= 2:0:042 LT_VERSION=1:0:0 42 43 AC_SUBST(LT_VERSION) 43 44 44 AC_DEFINE(F REEBOB_MAJOR_VERSION, freebob_major_version,[Freebobmajor version])45 AC_DEFINE(F REEBOB_MINOR_VERSION, freebob_minor_version,[Freebobminor version])46 AC_DEFINE(F REEBOB_MICRO_VERSION, freebob_micro_version,[Freebobmicro version])47 AC_SUBST(F REEBOB_MINOR_VERSION, freebob_minor_version)48 AC_SUBST(F REEBOB_MAJOR_VERSION, freebob_major_version)49 AC_SUBST(F REEBOB_MICRO_VERSION, freebob_micro_version)45 AC_DEFINE(FFADO_MAJOR_VERSION, ffado_major_version,[FFADO major version]) 46 AC_DEFINE(FFADO_MINOR_VERSION, ffado_minor_version,[FFADO minor version]) 47 AC_DEFINE(FFADO_MICRO_VERSION, ffado_micro_version,[FFADO micro version]) 48 AC_SUBST(FFADO_MINOR_VERSION, ffado_minor_version) 49 AC_SUBST(FFADO_MAJOR_VERSION, ffado_major_version) 50 AC_SUBST(FFADO_MICRO_VERSION, ffado_micro_version) 50 51 51 52 AM_INIT_AUTOMAKE([subdir-objects]) 52 53 AM_MAINTAINER_MODE 53 AC_CONFIG_SRCDIR([src/f reebob.cpp])54 AC_CONFIG_SRCDIR([src/ffado.cpp]) 54 55 AC_CONFIG_HEADER([config.h]) 55 56 AC_GNU_SOURCE … … 109 110 AC_CHECK_LIB(pthread, pthread_create,, 110 111 [ 111 AC_ERROR(You need the pthread library to compile f reebob)112 AC_ERROR(You need the pthread library to compile ffado) 112 113 ]) 113 114 … … 181 182 182 183 if test "$target_cpu" = "i586"; then 183 F REEBOB_OPT_CFLAGS="-march=i586 "184 FFADO_OPT_CFLAGS="-march=i586 " 184 185 elif test "$target_cpu" = "i686"; then 185 F REEBOB_OPT_CFLAGS="-march=i686"186 FFADO_OPT_CFLAGS="-march=i686" 186 187 else 187 188 : 188 189 fi 189 190 190 F REEBOB_OPT_CFLAGS="$COMMON_X86_OPT_FLAGS $FREEBOB_OPT_CFLAGS $MMX_FLAGS $SSE_FLAGS"191 FFADO_OPT_CFLAGS="$COMMON_X86_OPT_FLAGS $FFADO_OPT_CFLAGS $MMX_FLAGS $SSE_FLAGS" 191 192 192 193 … … 195 196 [ask the compiler for its best optimizations]), 196 197 [ if test x$enable_optimize != xno ; then 197 CFLAGS="$CFLAGS $F REEBOB_OPT_CFLAGS" ;198 CXXFLAGS="$CXXFLAGS $F REEBOB_OPT_CFLAGS"198 CFLAGS="$CFLAGS $FFADO_OPT_CFLAGS" ; 199 CXXFLAGS="$CXXFLAGS $FFADO_OPT_CFLAGS" 199 200 fi 200 201 ] … … 399 400 doc/Makefile 400 401 doc/reference.doxygen 401 libf reebob/Makefile402 libffado/Makefile 402 403 src/Makefile 403 404 tests/Makefile 404 405 tests/streaming/Makefile 405 libf reebob.pc])406 libffado.pc]) 406 407 407 408 AC_OUTPUT … … 410 411 AC_MSG_RESULT([ 411 412 412 F reeBoB$VERSION is now configured for $canonical_host_type413 FFADO $VERSION is now configured for $canonical_host_type 413 414 414 415 Building support for: $supported_devices trunk/libffado/doc/adding_devices.dox
r249 r445 1 /*2 * This is the main page of the FreeBoB reference manual, built using3 * doxygen.4 */5 6 1 /** 7 @page adding_devices Adding support for new devices to LibFreeBoB2 @page adding_devices Adding support for new devices to libffado 8 3 9 4 @author Pieter Palmers <pieterpalmers@users.sourceforge.net> … … 21 16 Layer 2 is implemented by subclassing the StreamProcessor class in src/libstreaming/ 22 17 23 Basic operation of libf reebobis:18 Basic operation of libffado is: 24 19 - Create a DeviceManager that iterates over all nodes connected to the 1394 bus. 25 20 For every node present, it tries the probeFunctions (probeBeBoB, probeMotu, ...). … … 54 49 the start/stop mechanism differ. 55 50 56 In order to add support for a device to freebob, two things should be implemented:51 In order to add support for a device to libffado, two things should be implemented: 57 52 - an IAvDevice descendant that takes care of the device discovery & configuration 58 53 - a StreamProcessor descendant that takes care of the device specific stream translation … … 65 60 @section streamingbaseclasses Streaming base class hierarchy and operation 66 61 67 This section explains the implementation details of the streaming part of LibFreeBoB.62 This section explains the implementation details of the streaming part of libffado. 68 63 69 64 The following figure shows the base class diagram, and the derrived classed that implement … … 89 84 - an IsoHandlerManager instance 90 85 91 Related classes: FreebobStreaming::StreamProcessorManager86 Related classes: Streaming::StreamProcessorManager 92 87 93 88 @subsection isoside The ISO side: 1394 isochronous traffic management … … 103 98 \note This abstraction is completely device independent, it only provides a mechanism to transmit or receive a certain isochronous stream. It could as well be used for video streams... 104 99 105 Related classes: FreebobStreaming::IsoStream, FreebobStreaming::IsoHandlerManager, FreebobStreaming::IsoHandler100 Related classes: Streaming::IsoStream, Streaming::IsoHandlerManager, Streaming::IsoHandler 106 101 107 102 @subsection audioapiside The Audio API side: port management … … 137 132 The idea is that we present a collection of ports to the Audio API side which from which it can read or to which it can write. 138 133 139 Related classes: FreebobStreaming::Port, FreebobStreaming::PortManager134 Related classes: Streaming::Port, Streaming::PortManager 140 135 141 136 @subsection connectingisoandaudio Connecting the ISO side with the Audio API side … … 161 156 A StreamProcessor also has the init(), prepare() and reset() calls, which are still to be documented (see later). 162 157 163 Related classes: FreebobStreaming::StreamProcessor, FreebobStreaming::ReceiveStreamProcessor, FreebobStreaming::TransmitStreamProcessor, FreebobStreaming::PortManager158 Related classes: Streaming::StreamProcessor, Streaming::ReceiveStreamProcessor, Streaming::TransmitStreamProcessor, Streaming::PortManager 164 159 165 160 @subsection mappingports Mapping Ports to IsoStreams … … 167 162 168 163 @subsection puttingtogether Putting it all together 164 165 @note this is outdated 166 169 167 The framework is completed by introducing the StreamProcessorManager. As indicated before, this class implements a 'collection of StreamProcessors' and an IsoHandlerManager. 170 168 171 169 First of all, the StreamProcessorManager is a collection of StreamProcessors, hence it implements the registerStreamProcessor and unregisterStreamProcessor methods. It maintains the list of StreamProcessors under it's control. When StreamProcessors are (un)registered, they are automatically (un)registered to the IsoHandlerManager too, creating IsoHandlers to handle them. Remember that StreamProcessor is a descendant of IsoStream, and can therefore be registered to an IsoHandlerManager. This results in the fact that the ISO stream the StreamProcessor is supposed to handle, will be attached to an IsoHandler. 172 170 173 Furthermore StreamProcessorManager is a child of the FreebobRunnable interface, and can therefore be used as the worker class for a FreebobThread. A complicated sentence to say that the StreamProcessorManager will start up a thread that calls its Execute() function, which in its turn calls the IsoHandlerManager Exectute() method (hence iterating the IsoHandlers managed by the IsoHandlerManager). This thread also performs the synchronisation as described in the next paragraph.171 Furthermore StreamProcessorManager is a child of the Runnable interface, and can therefore be used as the worker class for a Thread. A complicated sentence to say that the StreamProcessorManager will start up a thread that calls its Execute() function, which in its turn calls the IsoHandlerManager Exectute() method (hence iterating the IsoHandlers managed by the IsoHandlerManager). This thread also performs the synchronisation as described in the next paragraph. 174 172 175 173 The third function of the StreamProcessorManager is the synchronisation between the ISO side and the Audio API side. To implement this, the class provides a wait() method that waits on a synchronisation primitive. This primitive is signalled by the thread that iterates the IsoHandlerManager. This thread will signal the primitive when all StreamProcessors indicate that they have one period ready. … … 181 179 \note A blocking-read/nonblocking write (and the other way around) version of access to PacketBuffered Ports is planned. 182 180 183 Related classes: FreebobStreaming::StreamProcessorManager, FreebobStreaming::IsoHandlerManager, FreebobStreaming::Port181 Related classes: Streaming::StreamProcessorManager, Streaming::IsoHandlerManager, Streaming::Port 184 182 185 183 @subsection callingorder Some notes on when which method is called trunk/libffado/doc/amdtpstreamprocessor.dox
r249 r445 1 /*2 * This is the main page of the FreeBoB reference manual, built using3 * doxygen.4 */5 6 1 /** 7 2 @page amdtpdescription The AMDTP StreamProcessor trunk/libffado/doc/mainpage.dox
r249 r445 1 1 /* 2 * This is the main page of the F reeBoBreference manual, built using2 * This is the main page of the FFADO reference manual, built using 3 3 * doxygen. 4 4 */ 5 5 6 6 /** 7 @mainpage F reeBoB - Firewire (pro-)audiofor Linux7 @mainpage FFADO - Free Firewire (pro-)Audio Drivers for Linux 8 8 9 9 @author Pieter Palmers <pieterpalmers@users.sourceforge.net> … … 11 11 @section intro Introduction 12 12 13 F reeBoBis intended as an intermediate layer between the Linux1394 kernel/userspace layer, and the various audio API's (ALSA, jack, ...) present.13 FFADO is intended as an intermediate layer between the Linux1394 kernel/userspace layer, and the various audio API's (ALSA, jack, ...) present. 14 14 15 15 \note this is a SVN version, therefore it is highly volatile. Certain parts of the documentation can be outdated. This documentation is also auto-generated, and it can occur that unused classes and interfaces appear in the documentation. This pollution will be cleaned up as we go along. 16 16 17 @see <http://f reebob.sourceforge.net>17 @see <http://ffado.sourceforge.net> 18 18 19 19 @section library Client side library 20 20 21 F reeBoBpresents an interface that can be used to implement backends for various audio21 FFADO presents an interface that can be used to implement backends for various audio 22 22 API's. Currently the best support is for the JACK backend. It is also intended to implement configuration applications like mixer controls etc.. 23 23 24 The library API is split in two parts: 25 - @ref freebob.h "<libfreebob/freebob.h>" is the discovery & configuration interface 26 - @ref freebob_streaming.h "<libfreebob/freebob_streaming.h>" is the streaming interface 27 24 The library API's external C interface is defined in: 25 - @ref ffado.h "<libffado/ffado.h>" 28 26 29 27 @section devicesupport Adding support for unsupported devices 30 28 31 Initial support is/was for BeBoB devices only, however theframework32 is usable for all firewire audio devices.29 Initial support by FreeBoB was for BeBoB devices only, however the FFADO framework 30 is usable for all FireWire audio devices. 33 31 34 32 Take a look at the @ref adding_devices page for a detailed description. trunk/libffado/doc/reference.doxygen.in
r250 r445 18 18 # by quotes) that should identify the project. 19 19 20 PROJECT_NAME = LIBF REEBOB20 PROJECT_NAME = LIBFFADO 21 21 22 22 # The PROJECT_NUMBER tag can be used to enter a project or revision number. … … 366 366 @top_srcdir@/src/ \ 367 367 @top_srcdir@/src/debugmodule \ 368 @top_srcdir@/src/libavc \ 369 @top_srcdir@/src/libieee1394 \ 370 @top_srcdir@/src/libosc \ 368 371 @top_srcdir@/src/libstreaming \ 369 372 @top_srcdir@/src/libutil \ 370 @top_srcdir@/src/libfreebobavc \ 371 @top_srcdir@/libfreebob/ 373 @top_srcdir@/src/bebob \ 374 @top_srcdir@/src/bounce \ 375 @top_srcdir@/src/dice \ 376 @top_srcdir@/src/maudio \ 377 @top_srcdir@/src/metrichalo \ 378 @top_srcdir@/src/motu \ 379 @top_srcdir@/src/rme \ 380 @top_srcdir@/libffado/ 381 372 382 373 383 # If the value of the INPUT tag contains directories, you can use the trunk/libffado/doc/streaming.xmi
r403 r445 85 85 <UML:DataType stereotype="12706" isSpecification="false" isLeaf="false" visibility="public" namespace="88018" xmi.id="13397" isRoot="false" isAbstract="false" name="PortVectorIterator" elementReference="13396" /> 86 86 <UML:DataType stereotype="12706" isSpecification="false" isLeaf="false" visibility="public" namespace="88018" xmi.id="13401" isRoot="false" isAbstract="false" name="Port*" elementReference="12717" /> 87 <UML:DataType stereotype="12706" isSpecification="false" isLeaf="false" visibility="public" namespace="88018" xmi.id="14009" isRoot="false" isAbstract="false" name="F reebobRunnableInterface*" elementReference="14008" />87 <UML:DataType stereotype="12706" isSpecification="false" isLeaf="false" visibility="public" namespace="88018" xmi.id="14009" isRoot="false" isAbstract="false" name="FFADORunnableInterface*" elementReference="14008" /> 88 88 <UML:DataType stereotype="12706" isSpecification="false" isLeaf="false" visibility="public" namespace="88018" xmi.id="14530" isRoot="false" isAbstract="false" name="unsigned char*" elementReference="14529" /> 89 89 <UML:DataType stereotype="12706" isSpecification="false" isLeaf="false" visibility="public" namespace="88018" xmi.id="14540" isRoot="false" isAbstract="false" name="unsigned int*" elementReference="12734" /> … … 96 96 <UML:DataType stereotype="12706" isSpecification="false" isLeaf="false" visibility="public" namespace="88018" xmi.id="14665" isRoot="false" isAbstract="false" name="IsoHandlerManager*" elementReference="14659" /> 97 97 <UML:DataType stereotype="12706" isSpecification="false" isLeaf="false" visibility="public" namespace="88018" xmi.id="15179" isRoot="false" isAbstract="false" name="quadlet_t*" elementReference="15178" /> 98 <UML:DataType stereotype="12706" isSpecification="false" isLeaf="false" visibility="public" namespace="88018" xmi.id="15190" isRoot="false" isAbstract="false" name="f reebob_ringbuffer_t*" elementReference="15166" />98 <UML:DataType stereotype="12706" isSpecification="false" isLeaf="false" visibility="public" namespace="88018" xmi.id="15190" isRoot="false" isAbstract="false" name="ffado_ringbuffer_t*" elementReference="15166" /> 99 99 <UML:DataType stereotype="12706" isSpecification="false" isLeaf="false" visibility="public" namespace="88018" xmi.id="15236" isRoot="false" isAbstract="false" name="IsoHandler*" elementReference="15194" /> 100 100 <UML:DataType stereotype="12706" isSpecification="false" isLeaf="false" visibility="public" namespace="88018" xmi.id="15278" isRoot="false" isAbstract="false" name="PacketBuffer*" elementReference="15167" /> … … 109 109 </UML:Package> 110 110 <UML:Class comment="Id$ *//* 111 F reeBobStreaming API112 F reeBob= Firewire (pro-)audio for linux111 FFADO Streaming API 112 FFADO = Firewire (pro-)audio for linux 113 113 114 http://f reebob.sf.net114 http://ffado.sf.net 115 115 116 116 Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> … … 958 958 </UML:Class> 959 959 <UML:Class comment="Id$ *//* 960 F reeBobStreaming API961 F reeBob= Firewire (pro-)audio for linux960 FFADO Streaming API 961 FFADO = Firewire (pro-)audio for linux 962 962 963 http://f reebob.sf.net963 http://ffado.sf.net 964 964 965 965 Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> … … 1034 1034 <UML:Class isSpecification="false" isLeaf="false" visibility="public" namespace="1" xmi.id="13000" isRoot="false" isAbstract="false" name="enum E_Formats" /> 1035 1035 <UML:Class comment="Id$ *//* 1036 F reeBobStreaming API1037 F reeBob= Firewire (pro-)audio for linux1036 FFADO Streaming API 1037 FFADO = Firewire (pro-)audio for linux 1038 1038 1039 http://f reebob.sf.net1039 http://ffado.sf.net 1040 1040 1041 1041 Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> … … 1531 1531 <UML:Class stereotype="13989" isSpecification="false" isLeaf="false" visibility="public" namespace="1" xmi.id="13991" isRoot="false" isAbstract="false" name="SInt32" /> 1532 1532 <UML:Class stereotype="13989" isSpecification="false" isLeaf="false" visibility="public" namespace="1" xmi.id="13992" isRoot="false" isAbstract="false" name="UInt64" /> 1533 <UML:Class comment="Modifications for F reebob(C) 2006, Pieter Palmers1533 <UML:Class comment="Modifications for FFADO (C) 2006, Pieter Palmers 1534 1534 Copied from the jackd/jackdmp sources 1535 1535 function names changed in order to avoid naming problems when using this in … … 1549 1549 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 1550 1550 //*! 1551 \brief The POSIX thread base class." isSpecification="false" isLeaf="false" visibility="public" namespace="1" xmi.id="13993" isRoot="false" isAbstract="false" name="F reebobPosixThread" >1551 \brief The POSIX thread base class." isSpecification="false" isLeaf="false" visibility="public" namespace="1" xmi.id="13993" isRoot="false" isAbstract="false" name="FFADOPosixThread" > 1552 1552 <UML:GeneralizableElement.generalization> 1553 1553 <UML:Generalization xmi.idref="13995" /> … … 1660 1660 </UML:BehavioralFeature.parameter> 1661 1661 </UML:Operation> 1662 <UML:Operation stereotype="12714" isSpecification="false" isLeaf="false" visibility="public" xmi.id="14007" isRoot="false" isAbstract="false" isQuery="false" name="F reebobPosixThread" >1662 <UML:Operation stereotype="12714" isSpecification="false" isLeaf="false" visibility="public" xmi.id="14007" isRoot="false" isAbstract="false" isQuery="false" name="FFADOPosixThread" > 1663 1663 <UML:BehavioralFeature.parameter> 1664 1664 <UML:Parameter isSpecification="false" visibility="private" xmi.id="14010" value="" type="14009" name="runnable" /> … … 1668 1668 </UML:BehavioralFeature.parameter> 1669 1669 </UML:Operation> 1670 <UML:Operation stereotype="12714" isSpecification="false" isLeaf="false" visibility="public" xmi.id="14014" isRoot="false" isAbstract="false" isQuery="false" name="F reebobPosixThread" >1670 <UML:Operation stereotype="12714" isSpecification="false" isLeaf="false" visibility="public" xmi.id="14014" isRoot="false" isAbstract="false" isQuery="false" name="FFADOPosixThread" > 1671 1671 <UML:BehavioralFeature.parameter> 1672 1672 <UML:Parameter isSpecification="false" visibility="private" xmi.id="14015" value="" type="14009" name="runnable" /> 1673 1673 </UML:BehavioralFeature.parameter> 1674 1674 </UML:Operation> 1675 <UML:Operation stereotype="12714" isSpecification="false" isLeaf="false" visibility="public" xmi.id="14016" isRoot="false" isAbstract="false" isQuery="false" name="F reebobPosixThread" >1675 <UML:Operation stereotype="12714" isSpecification="false" isLeaf="false" visibility="public" xmi.id="14016" isRoot="false" isAbstract="false" isQuery="false" name="FFADOPosixThread" > 1676 1676 <UML:BehavioralFeature.parameter> 1677 1677 <UML:Parameter isSpecification="false" visibility="private" xmi.id="14017" value="" type="14009" name="runnable" /> … … 1679 1679 </UML:BehavioralFeature.parameter> 1680 1680 </UML:Operation> 1681 <UML:Operation isSpecification="false" isLeaf="false" visibility="public" xmi.id="14019" isRoot="false" isAbstract="false" isQuery="false" name="~ F reebobPosixThread" />1681 <UML:Operation isSpecification="false" isLeaf="false" visibility="public" xmi.id="14019" isRoot="false" isAbstract="false" isQuery="false" name="~ FFADOPosixThread" /> 1682 1682 <UML:Operation isSpecification="false" isLeaf="false" visibility="public" xmi.id="14020" isRoot="false" isAbstract="false" isQuery="false" name="Start" > 1683 1683 <UML:BehavioralFeature.parameter> … … 1718 1718 </UML:Classifier.feature> 1719 1719 </UML:Class> 1720 <UML:Class isSpecification="false" isLeaf="false" visibility="public" namespace="1" xmi.id="13994" isRoot="false" isAbstract="false" name="F reebobThread" />1720 <UML:Class isSpecification="false" isLeaf="false" visibility="public" namespace="1" xmi.id="13994" isRoot="false" isAbstract="false" name="FFADOThread" /> 1721 1721 <UML:Class isSpecification="false" isLeaf="false" visibility="public" namespace="1" xmi.id="13998" isRoot="false" isAbstract="false" name="pthread_t" /> 1722 1722 <UML:Class isSpecification="false" isLeaf="false" visibility="public" namespace="1" xmi.id="14002" isRoot="false" isAbstract="false" name="volatile bool" /> 1723 <UML:Class isSpecification="false" isLeaf="false" visibility="public" namespace="1" xmi.id="14008" isRoot="false" isAbstract="false" name="F reebobRunnableInterface" />1723 <UML:Class isSpecification="false" isLeaf="false" visibility="public" namespace="1" xmi.id="14008" isRoot="false" isAbstract="false" name="FFADORunnableInterface" /> 1724 1724 <UML:Class comment="Id$ *//* 1725 F reeBobStreaming API1726 F reeBob= Firewire (pro-)audio for linux1725 FFADO Streaming API 1726 FFADO = Firewire (pro-)audio for linux 1727 1727 1728 http://f reebob.sf.net1728 http://ffado.sf.net 1729 1729 1730 1730 Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> … … 2554 2554 </UML:Class> 2555 2555 <UML:Class comment="Id$ *//* 2556 F reeBobStreaming API2557 F reeBob= Firewire (pro-)audio for linux2556 FFADO Streaming API 2557 FFADO = Firewire (pro-)audio for linux 2558 2558 2559 http://f reebob.sf.net2559 http://ffado.sf.net 2560 2560 2561 2561 Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> … … 3556 3556 </UML:BehavioralFeature.parameter> 3557 3557 </UML:Operation> 3558 <UML:Operation comment="// F reebobRunnableInterface interface// note that this is called in we while(running) loop" isSpecification="false" isLeaf="false" visibility="protected" xmi.id="14649" isRoot="false" isAbstract="false" isQuery="false" name="Execute" >3558 <UML:Operation comment="// FFADORunnableInterface interface// note that this is called in we while(running) loop" isSpecification="false" isLeaf="false" visibility="protected" xmi.id="14649" isRoot="false" isAbstract="false" isQuery="false" name="Execute" > 3559 3559 <UML:BehavioralFeature.parameter> 3560 3560 <UML:Parameter kind="return" xmi.id="LlXy8i6aXj2o" type="12708" /> … … 3686 3686 </UML:Operation> 3687 3687 <UML:Operation isSpecification="false" isLeaf="false" visibility="public" xmi.id="14668" isRoot="false" isAbstract="false" isQuery="false" name="~ StreamRunner" /> 3688 <UML:Operation comment="// F reebobRunnableInterface interface// note that this is called in we while(running) loop" isSpecification="false" isLeaf="false" visibility="public" xmi.id="14669" isRoot="false" isAbstract="false" isQuery="false" name="Execute" >3688 <UML:Operation comment="// FFADORunnableInterface interface// note that this is called in we while(running) loop" isSpecification="false" isLeaf="false" visibility="public" xmi.id="14669" isRoot="false" isAbstract="false" isQuery="false" name="Execute" > 3689 3689 <UML:BehavioralFeature.parameter> 3690 3690 <UML:Parameter kind="return" xmi.id="9wZVdbzyKUvQ" type="12708" /> … … 3698 3698 </UML:Classifier.feature> 3699 3699 </UML:Class> 3700 <UML:Class stereotype="13989" isSpecification="false" isLeaf="false" visibility="public" namespace="1" xmi.id="15165" isRoot="false" isAbstract="false" name="f reebob_ringbuffer_data_t" />3701 <UML:Class stereotype="13989" isSpecification="false" isLeaf="false" visibility="public" namespace="1" xmi.id="15166" isRoot="false" isAbstract="false" name="f reebob_ringbuffer_t" />3700 <UML:Class stereotype="13989" isSpecification="false" isLeaf="false" visibility="public" namespace="1" xmi.id="15165" isRoot="false" isAbstract="false" name="ffado_ringbuffer_data_t" /> 3701 <UML:Class stereotype="13989" isSpecification="false" isLeaf="false" visibility="public" namespace="1" xmi.id="15166" isRoot="false" isAbstract="false" name="ffado_ringbuffer_t" /> 3702 3702 <UML:Class comment="Id$ *//* 3703 F reeBobStreaming API3704 F reeBob= Firewire (pro-)audio for linux3703 FFADO Streaming API 3704 FFADO = Firewire (pro-)audio for linux 3705 3705 3706 http://f reebob.sf.net3706 http://ffado.sf.net 3707 3707 3708 3708 Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> trunk/libffado/libffado.pc.in
r442 r445 4 4 includedir=@includedir@ 5 5 6 Name: libf reebob7 Description: F reeBoB6 Name: libffado 7 Description: FFADO 8 8 Version: @VERSION@ 9 Libs: -L${libdir} -lf reebob9 Libs: -L${libdir} -lffado 10 10 Cflags: -I${includedir} trunk/libffado/Makefile.am
r336 r445 1 # Makefile.am - Makefile template 2 # Copyright (C) 2005 by Daniel Wagner. 1 # Makefile.am - toplevel Makefile for FFADO 3 2 # 4 # This file is part of FreeBoB. 3 # Copyright (C) 2005-2007 by Daniel Wagner. 4 # Copyright (C) 2005-2007 by Pieter Palmers. 5 5 # 6 # FreeBoB is free software; you can redistribute it and/or modify 7 # it under the terms of the GNU General Public License as published by 8 # the Free Software Foundation; either version 2 of the License, or 9 # (at your option) any later version. 10 # FreeBoB is distributed in the hope that it will be useful, 6 # This file is part of FFADO. 7 # FFADO = Free Firewire (pro-)audio drivers for linux 8 # 9 # FFADO is based upon FreeBoB. 10 # 11 # FFADO is free software. 12 # 13 # you can redistribute and/or modify the library code 14 # under the terms of the GNU Lesser General Public License 15 # version 2.1, as published by the Free Software Foundation 16 # 17 # you can redistribute and/or modify the applications 18 # under the terms of the GNU General Public License 19 # version 2, as published by the Free Software Foundation 20 # 21 # FFADO is distributed in the hope that it will be useful, 11 22 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU General Public License for more details. 14 # You should have received a copy of the GNU General Public License 15 # along with FreeBoB; if not, write to the Free Software 24 # GNU (Lesser) General Public License for more details. 25 # 26 # You should have received a copy of the GNU (Lesser) General Public License 27 # along with FFADO; if not, write to the Free Software 16 28 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 29 18 SUBDIRS = libf reebobsrc tests doc30 SUBDIRS = libffado src tests doc 19 31 20 32 pkgconfigdir = $(libdir)/pkgconfig 21 pkgconfig_DATA = libf reebob.pc33 pkgconfig_DATA = libffado.pc 22 34 23 35 $(srcdir)/configure: configure.ac aclocal.m4 … … 39 51 config.status: configure 40 52 ./config.status --recheck 41 42 trunk/libffado/src/bebob-sync.cpp
r442 r445 1 /* freebob-sync.cpp 2 * Copyright (C) 2006 by Daniel Wagner 3 * 4 * This file is part of FreeBoB. 5 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 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 is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License version 2 11 * as published by the Free Software Foundation. 12 * 13 * FFADO is distributed in the hope that it will be useful, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the … … 14 17 * 15 18 * You should have received a copy of the GNU General Public License 16 * along with F reeBoB; if not, write to the Free Software19 * along with FFADO; if not, write to the Free Software 17 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 18 21 * MA 02111-1307 USA. … … 30 33 // arg parsing 31 34 //////////////////////////////////////////////// 32 const char *argp_program_version = " freebob_sync 0.1";33 const char *argp_program_bug_address = "<f reebob-devel@lists.sf.net>";34 static char doc[] = " freebob_sync -- select sync mode\n\n"35 const char *argp_program_version = "bebob-sync 0.1"; 36 const char *argp_program_bug_address = "<ffado-devel@lists.sf.net>"; 37 static char doc[] = "bebob-sync -- select sync mode on a BeBoB device\n\n" 35 38 "OPERATION: set <nr>\n"; 36 39 static char args_doc[] = "NODE_ID OPERATION"; … … 41 44 }; 42 45 43 IMPL_GLOBAL_DEBUG_MODULE( freebob-sync, DebugModule::eDL_Normal ); 46 // IMPL_GLOBAL_DEBUG_MODULE( bebob-sync, DebugModule::eDL_Normal ); 47 DECLARE_GLOBAL_DEBUG_MODULE; 44 48 45 49 struct arguments … … 118 122 int node_id = strtol(arguments.args[0], &tail, 0); 119 123 if (errno) { 120 perror("argument parsng failed:");121 return -1;124 perror("argument parsng failed:"); 125 return -1; 122 126 } 123 127 trunk/libffado/src/bebob/bebob_avdevice.cpp
r436 r445 1 /* bebob_avdevice.cpp2 * Copyright (C) 2005 ,06,07 by Daniel Wagner1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 3 * 4 * This file is part of FreeBoB. 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 5 6 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 14 17 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 … … 42 45 { 43 46 {0x00000f, 0x00010065, "Mackie", "Onyx Firewire"}, 44 47 45 48 {0x0003db, 0x00010048, "Apogee Electronics", "Rosetta 200"}, 46 49 … … 105 108 106 109 void 107 AvDevice::setVerboseLevel(int l) 110 AvDevice::setVerboseLevel(int l) 108 111 { 109 112 // m_pPlugManager->setVerboseLevel(l); 110 113 111 114 IAvDevice::setVerboseLevel(l); 112 115 } … … 143 146 { 144 147 if ( ( supportedDeviceList[i].vendor_id == vendorId ) 145 && ( supportedDeviceList[i].model_id == modelId ) 148 && ( supportedDeviceList[i].model_id == modelId ) 146 149 ) 147 150 { … … 155 158 m_model->vendor_name, m_model->model_name); 156 159 } else return false; 157 160 158 161 if ( !enumerateSubUnits() ) { 159 162 debugError( "Could not enumarate sub units\n" ); … … 709 712 debugWarning("Could not retrieve snoopMode parameter, defauling to false\n"); 710 713 } 711 714 712 715 if(snoopMode) { 713 716 int current_sr=getSamplingFrequency(); … … 724 727 return false; 725 728 } 726 729 727 730 if ( !setSamplingFrequencyPlug( *plug, 728 731 AvPlug::eAPD_Input, … … 732 735 return false; 733 736 } 734 737 735 738 plug = getPlugById( m_pcrPlugs, AvPlug::eAPD_Output, 0 ); 736 739 if ( !plug ) { … … 738 741 return false; 739 742 } 740 743 741 744 if ( !setSamplingFrequencyPlug( *plug, 742 745 AvPlug::eAPD_Output, … … 746 749 return false; 747 750 } 748 751 749 752 debugOutput( DEBUG_LEVEL_VERBOSE, 750 753 "setSampleRate: Set sample rate to %d\n", … … 886 889 "%s %s at node %d\n", m_model->vendor_name, m_model->model_name, 887 890 m_nodeId); 888 891 889 892 m_pPlugManager->showPlugs(); 890 893 } … … 946 949 // don't lock 947 950 } else { 948 951 949 952 } 950 953 … … 962 965 // don't unlock 963 966 } else { 964 967 965 968 } 966 969 return true; … … 973 976 debugWarning("Could not retrieve snoopMode parameter, defauling to false\n"); 974 977 } 975 978 976 979 /////////// 977 980 // get plugs … … 989 992 990 993 int samplerate=outputPlug->getSampleRate(); 991 994 992 995 debugOutput( DEBUG_LEVEL_VERBOSE, "Initializing receive processor...\n"); 993 996 // create & add streamprocessors 994 997 Streaming::StreamProcessor *p; 995 998 996 999 p=new Streaming::AmdtpReceiveStreamProcessor( 997 1000 m_p1394Service->getPort(), … … 1011 1014 return false; 1012 1015 } 1013 1016 1014 1017 m_receiveProcessors.push_back(p); 1015 1018 … … 1029 1032 inputPlug->getNrOfChannels()); 1030 1033 } 1031 1034 1032 1035 if(!p->init()) { 1033 1036 debugFatal("Could not initialize transmit processor %s!\n", … … 1050 1053 } 1051 1054 } 1052 1055 1053 1056 // we put this SP into the transmit SP vector, 1054 1057 // no matter if we are in snoop mode or not … … 1065 1068 Streaming::StreamProcessor *processor, 1066 1069 Streaming::AmdtpAudioPort::E_Direction direction) { 1067 1070 1068 1071 std::string id=std::string("dev?"); 1069 1072 if(!getOption("id", id)) { 1070 1073 debugWarning("Could not retrieve id parameter, defauling to 'dev?'\n"); 1071 1074 } 1072 1075 1073 1076 AvPlug::ClusterInfoVector& clusterInfos = plug.getClusterInfos(); 1074 1077 for ( AvPlug::ClusterInfoVector::const_iterator it = clusterInfos.begin(); … … 1173 1176 int n=i; 1174 1177 Streaming::StreamProcessor *p=m_receiveProcessors.at(n); 1175 1178 1176 1179 if(snoopMode) { // a stream from the device to another host 1177 1180 // FIXME: put this into a decent framework! … … 1179 1182 struct iec61883_oPCR opcr; 1180 1183 if (iec61883_get_oPCRX( 1181 m_p1394Service->getHandle(), 1184 m_p1394Service->getHandle(), 1182 1185 m_pConfigRom->getNodeId() | 0xffc0, 1183 1186 (quadlet_t *)&opcr, 1184 1187 n)) { 1185 1188 1186 1189 debugWarning("Error getting the channel for SP %d\n",i); 1187 1190 return false; 1188 1191 } 1189 1192 1190 1193 iso_channel=opcr.channel; 1191 1194 } else { 1192 1195 iso_channel=m_p1394Service->allocateIsoChannelCMP( 1193 m_pConfigRom->getNodeId() | 0xffc0, n, 1196 m_pConfigRom->getNodeId() | 0xffc0, n, 1194 1197 m_p1394Service->getLocalNodeId()| 0xffc0, -1); 1195 1198 } … … 1198 1201 return false; 1199 1202 } 1200 1203 1201 1204 debugOutput(DEBUG_LEVEL_VERBOSE, "Started SP %d on channel %d\n",i,iso_channel); 1202 1205 1203 1206 p->setChannel(iso_channel); 1204 1207 return true; 1205 1208 1206 1209 } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) { 1207 1210 int n=i-m_receiveProcessors.size(); 1208 1211 Streaming::StreamProcessor *p=m_transmitProcessors.at(n); 1209 1210 if(snoopMode) { // a stream from another host to the device 1212 1213 if(snoopMode) { // a stream from another host to the device 1211 1214 // FIXME: put this into a decent framework! 1212 1215 // we should check the iPCR[n] on the device 1213 1216 struct iec61883_iPCR ipcr; 1214 1217 if (iec61883_get_iPCRX( 1215 m_p1394Service->getHandle(), 1218 m_p1394Service->getHandle(), 1216 1219 m_pConfigRom->getNodeId() | 0xffc0, 1217 1220 (quadlet_t *)&ipcr, 1218 1221 n)) { 1219 1222 1220 1223 debugWarning("Error getting the channel for SP %d\n",i); 1221 1224 return false; 1222 1225 } 1223 1226 1224 1227 iso_channel=ipcr.channel; 1225 1228 1226 1229 } else { 1227 1230 iso_channel=m_p1394Service->allocateIsoChannelCMP( … … 1229 1232 m_pConfigRom->getNodeId() | 0xffc0, n); 1230 1233 } 1231 1234 1232 1235 if (iso_channel<0) { 1233 1236 debugError("Could not allocate ISO channel for SP %d\n",i); 1234 1237 return false; 1235 1238 } 1236 1239 1237 1240 debugOutput(DEBUG_LEVEL_VERBOSE, "Started SP %d on channel %d\n",i,iso_channel); 1238 1241 1239 1242 p->setChannel(iso_channel); 1240 1243 return true; 1241 1244 } 1242 1245 1243 1246 debugError("SP index %d out of range!\n",i); 1244 1247 return false; … … 1266 1269 } 1267 1270 p->setChannel(-1); 1268 1271 1269 1272 return true; 1270 1273 1271 1274 } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) { 1272 1275 int n=i-m_receiveProcessors.size(); 1273 1276 Streaming::StreamProcessor *p=m_transmitProcessors.at(n); 1274 1277 1275 1278 if(snoopMode) { 1276 1279 … … 1283 1286 } 1284 1287 p->setChannel(-1); 1285 1288 1286 1289 return true; 1287 1290 } 1288 1291 1289 1292 debugError("SP index %d out of range!\n",i); 1290 1293 return false; … … 1414 1417 Util::IOSerialize& ser ) const 1415 1418 { 1416 1419 1417 1420 bool result; 1418 1421 result = m_pConfigRom->serialize( basePath + "m_pConfigRom/", ser ); … … 1435 1438 i++; 1436 1439 } 1437 1440 1438 1441 result &= serializeOptions( basePath + "Options", ser ); 1439 1442 … … 1451 1454 ConfigRom *configRom = 1452 1455 ConfigRom::deserialize( basePath + "m_pConfigRom/", deser, ieee1394Service ); 1453 1456 1454 1457 if ( !configRom ) { 1455 1458 return NULL; … … 1457 1460 1458 1461 AvDevice* pDev = new AvDevice( 1459 std::auto_ptr<ConfigRom>(configRom), 1462 std::auto_ptr<ConfigRom>(configRom), 1460 1463 ieee1394Service, configRom->getNodeId()); 1461 1464 … … 1463 1466 bool result; 1464 1467 result = deser.read( basePath + "m_verboseLevel", pDev->m_verboseLevel ); 1465 1468 1466 1469 if (pDev->m_pPlugManager) delete pDev->m_pPlugManager; 1467 1470 pDev->m_pPlugManager = AvPlugManager::deserialize( basePath + "AvPlug", deser, *pDev ); … … 1484 1487 } 1485 1488 } 1486 1489 1487 1490 result &= deserializeOptions( basePath + "Options", deser, *pDev ); 1488 1491 } trunk/libffado/src/bebob/bebob_avdevice.h
r436 r445 1 /* bebob_avdevice.h2 * Copyright (C) 2005 ,06,07 by Daniel Wagner1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 3 * 4 * This file is part of FreeBoB. 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 5 6 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 14 17 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 23 20 24 #ifndef BEBOB_AVDEVICE_H 21 25 #define BEBOB_AVDEVICE_H … … 51 55 unsigned int model_id; 52 56 char *vendor_name; 53 char *model_name; 57 char *model_name; 54 58 }; 55 59 … … 60 64 int nodeId ); 61 65 virtual ~AvDevice(); 62 66 63 67 void setVerboseLevel(int l); 64 68 … … 115 119 static AvDevice* deserialize( Glib::ustring basePath, 116 120 Util::IODeserialize& deser, 117 Ieee1394Service& ieee1394Service );121 Ieee1394Service& ieee1394Service ); 118 122 protected: 119 123 trunk/libffado/src/bebob/bebob_avdevice_subunit.cpp
r420 r445 1 /* bebob_avdevice_subunit.cpp2 * Copyright (C) 2005 ,06,07 by Daniel Wagner1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 3 * 4 * This file is part of FreeBoB. 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 5 6 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 14 17 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 trunk/libffado/src/bebob/bebob_avdevice_subunit.h
r420 r445 1 /* bebob_avdevice_subunit.h2 * Copyright (C) 2005 ,06,07 by Daniel Wagner1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 3 * 4 * This file is part of FreeBoB. 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 5 6 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 14 17 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 23 20 24 #ifndef BEBOB_AVDEVICESUBUNIT_H 21 25 #define BEBOB_AVDEVICESUBUNIT_H … … 38 42 public: 39 43 AvDeviceSubunit( AvDevice& avDevice, 40 AVCCommand::ESubunitType type,41 subunit_t id,42 int verboseLevel );44 AVCCommand::ESubunitType type, 45 subunit_t id, 46 int verboseLevel ); 43 47 virtual ~AvDeviceSubunit(); 44 48 … … 50 54 51 55 subunit_t getSubunitId() 52 { return m_sbId; }56 { return m_sbId; } 53 57 AVCCommand::ESubunitType getSubunitType() 54 { return m_sbType; }58 { return m_sbType; } 55 59 56 60 AvPlugVector& getPlugs() 57 { return m_plugs; }61 { return m_plugs; } 58 62 AvPlug* getPlug(AvPlug::EAvPlugDirection direction, plug_id_t plugId); 59 63 … … 65 69 bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; 66 70 static AvDeviceSubunit* deserialize( Glib::ustring basePath, 67 Util::IODeserialize& deser,71 Util::IODeserialize& deser, 68 72 AvDevice& avDevice ); 69 73 protected: … … 98 102 public: 99 103 AvDeviceSubunitAudio( AvDevice& avDevice, 100 subunit_t id,101 int verboseLevel );104 subunit_t id, 105 int verboseLevel ); 102 106 AvDeviceSubunitAudio(); 103 107 virtual ~AvDeviceSubunitAudio(); … … 135 139 public: 136 140 AvDeviceSubunitMusic( AvDevice& avDevice, 137 subunit_t id,138 int verboseLevel );141 subunit_t id, 142 int verboseLevel ); 139 143 AvDeviceSubunitMusic(); 140 144 virtual ~AvDeviceSubunitMusic(); trunk/libffado/src/bebob/bebob_avplug.cpp
r420 r445 1 /* bebob_avplug.cpp2 * Copyright (C) 2005 ,06,07 by Daniel Wagner1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 3 * 4 * This file is part of FreeBoB. 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 5 6 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 14 17 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 trunk/libffado/src/bebob/bebob_avplug.h
r435 r445 1 /* bebob_avplug.h 2 * Copyright (C) 2005,06,07 by Daniel Wagner 3 * 4 * This file is part of FreeBoB. 5 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.14 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 … … 50 53 51 54 enum EAvPlugAddressType { 52 eAPA_PCR,53 eAPA_ExternalPlug,54 eAPA_AsynchronousPlug,55 eAPA_SubunitPlug,56 eAPA_FunctionBlockPlug,57 eAPA_Undefined,55 eAPA_PCR, 56 eAPA_ExternalPlug, 57 eAPA_AsynchronousPlug, 58 eAPA_SubunitPlug, 59 eAPA_FunctionBlockPlug, 60 eAPA_Undefined, 58 61 }; 59 62 … … 69 72 70 73 enum EAvPlugDirection { 71 eAPD_Input,72 eAPD_Output,73 eAPD_Unknown,74 eAPD_Input, 75 eAPD_Output, 76 eAPD_Unknown, 74 77 }; 75 78 76 79 // \todo This constructors sucks. too many parameters. fix it. 77 80 AvPlug( Ieee1394Service& ieee1394Service, 78 ConfigRom& configRom,81 ConfigRom& configRom, 79 82 AvPlugManager& plugManager, 80 AVCCommand::ESubunitType subunitType,81 subunit_id_t subunitId,82 function_block_type_t functionBlockType,83 function_block_type_t functionBlockId,84 EAvPlugAddressType plugAddressType,85 EAvPlugDirection plugDirection,86 plug_id_t plugId,87 int verboseLevel );83 AVCCommand::ESubunitType subunitType, 84 subunit_id_t subunitId, 85 function_block_type_t functionBlockType, 86 function_block_type_t functionBlockId, 87 EAvPlugAddressType plugAddressType, 88 EAvPlugDirection plugDirection, 89 plug_id_t plugId, 90 int verboseLevel ); 88 91 AvPlug( const AvPlug& rhs ); 89 92 virtual ~AvPlug(); … … 96 99 97 100 int getGlobalId() const 98 { return m_globalId; }101 { return m_globalId; } 99 102 plug_id_t getPlugId() const 100 { return m_id; }103 { return m_id; } 101 104 AVCCommand::ESubunitType getSubunitType() const 102 { return m_subunitType; }105 { return m_subunitType; } 103 106 subunit_id_t getSubunitId() const 104 { return m_subunitId; }107 { return m_subunitId; } 105 108 const char* getName() const 106 { return m_name.c_str(); }109 { return m_name.c_str(); } 107 110 EAvPlugDirection getPlugDirection() const 108 { return m_direction; }111 { return m_direction; } 109 112 sampling_frequency_t getSamplingFrequency() const 110 { return m_samplingFrequency; }113 { return m_samplingFrequency; } 111 114 int getSampleRate() const; // 22050, 24000, 32000, ... 112 115 int getNrOfChannels() const; … … 118 121 { return m_addressType; } 119 122 EAvPlugType getPlugType() const 120 { return m_infoPlugType; }123 { return m_infoPlugType; } 121 124 122 125 function_block_type_t getFunctionBlockType() const 123 { return m_functionBlockType; }126 { return m_functionBlockType; } 124 127 function_block_id_t getFunctionBlockId() const 125 128 { return m_functionBlockId; } … … 131 134 132 135 static PlugAddress::EPlugDirection convertPlugDirection( 133 EAvPlugDirection direction);136 EAvPlugDirection direction); 134 137 135 138 void showPlug() const; … … 148 151 stream_position_t m_streamPosition; 149 152 stream_position_location_t m_location; 150 Glib::ustring m_name;153 Glib::ustring m_name; 151 154 }; 152 155 typedef std::vector<ChannelInfo> ChannelInfoVector; 153 156 154 157 struct ClusterInfo { 155 int m_index;156 port_type_t m_portType;157 Glib::ustring m_name;158 int m_index; 159 port_type_t m_portType; 160 Glib::ustring m_name; 158 161 159 162 nr_of_channels_t m_nrOfChannels; 160 163 ChannelInfoVector m_channelInfos; 161 stream_format_t m_streamFormat;164 stream_format_t m_streamFormat; 162 165 }; 163 166 typedef std::vector<ClusterInfo> ClusterInfoVector; … … 183 186 184 187 ExtendedStreamFormatCmd setPlugAddrToStreamFormatCmd( 185 ExtendedStreamFormatCmd::ESubFunction subFunction);188 ExtendedStreamFormatCmd::ESubFunction subFunction); 186 189 187 190 SignalSourceCmd setSrcPlugAddrToSignalCmd(); 188 191 189 192 void setDestPlugAddrToSignalCmd( 190 SignalSourceCmd& signalSourceCmd, AvPlug& plug );193 SignalSourceCmd& signalSourceCmd, AvPlug& plug ); 191 194 192 195 void debugOutputClusterInfos( int debugLevel ); … … 245 248 , m_index( 0xff ) 246 249 {} 247 sampling_frequency_t m_samplingFrequency;248 bool m_isSyncStream;249 number_of_channels_t m_audioChannels;250 number_of_channels_t m_midiChannels;251 byte_t m_index;250 sampling_frequency_t m_samplingFrequency; 251 bool m_isSyncStream; 252 number_of_channels_t m_audioChannels; 253 number_of_channels_t m_midiChannels; 254 byte_t m_index; 252 255 }; 253 256 typedef std::vector<FormatInfo> FormatInfoVector; … … 297 300 AvPlug* getPlug( AVCCommand::ESubunitType subunitType, 298 301 subunit_id_t subunitId, 299 function_block_type_t functionBlockType,300 function_block_id_t functionBlockId,302 function_block_type_t functionBlockType, 303 function_block_id_t functionBlockId, 301 304 AvPlug::EAvPlugAddressType plugAddressType, 302 305 AvPlug::EAvPlugDirection plugDirection, … … 304 307 AvPlug* getPlug( int iGlobalId ) const; 305 308 AvPlugVector getPlugsByType( AVCCommand::ESubunitType subunitType, 306 subunit_id_t subunitId,307 function_block_type_t functionBlockType,308 function_block_id_t functionBlockId,309 AvPlug::EAvPlugAddressType plugAddressType,310 AvPlug::EAvPlugDirection plugDirection,311 AvPlug::EAvPlugType type) const;309 subunit_id_t subunitId, 310 function_block_type_t functionBlockType, 311 function_block_id_t functionBlockId, 312 AvPlug::EAvPlugAddressType plugAddressType, 313 AvPlug::EAvPlugDirection plugDirection, 314 AvPlug::EAvPlugType type) const; 312 315 313 316 bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; … … 351 354 } 352 355 353 #endif 356 #endif // BEBOB_AVPLUG_H trunk/libffado/src/bebob/bebob_dl_bcd.cpp
r407 r445 1 /* bebob_dl_bcd.cpp 2 * Copyright (C) 2006 by Daniel Wagner 3 * 4 * This file is part of FreeBoB. 5 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.14 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 trunk/libffado/src/bebob/bebob_dl_bcd.h
r407 r445 1 /* bebob_dl_bcd.h2 * Copyright (C) 200 6by Daniel Wagner1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 3 * 4 * This file is part of FreeBoB. 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 5 6 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 14 17 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 23 20 24 #ifndef BEBOB_DL_BCD_H 21 25 #define BEBOB_DL_BCD_H … … 45 49 fb_quadlet_t getSoftwareVersion() const 46 50 { return m_softwareVersion; } 47 fb_quadlet_t getHardwareId() const48 { return m_hardwareId; }49 fb_quadlet_t getVendorOUI() const50 { return m_vendorOUI; }51 51 fb_quadlet_t getHardwareId() const 52 { return m_hardwareId; } 53 fb_quadlet_t getVendorOUI() const 54 { return m_vendorOUI; } 55 52 56 fb_quadlet_t getImageBaseAddress() const 53 57 { return m_imageBaseAddress; } … … 59 63 { return m_imageCRC; } 60 64 61 fb_quadlet_t getCnEOffset() const62 { return m_cneOffset; }65 fb_quadlet_t getCnEOffset() const 66 { return m_cneOffset; } 63 67 fb_quadlet_t getCnELength() const 64 68 { return m_cneLength; } 65 fb_quadlet_t getCnECRC() const66 { return m_cneCRC; }69 fb_quadlet_t getCnECRC() const 70 { return m_cneCRC; } 67 71 68 72 bool read( int addr, fb_quadlet_t* q ); 69 73 bool read( int addr, fb_octlet_t* o ); 70 bool read( int addr, unsigned char* b, size_t len );74 bool read( int addr, unsigned char* b, size_t len ); 71 75 72 void displayInfo();76 void displayInfo(); 73 77 74 78 protected: 75 79 unsigned long crc32_table[256]; 76 void initCRC32Table();77 unsigned long reflect(unsigned long ref, char ch);78 unsigned int getCRC(unsigned char* text, size_t len);80 void initCRC32Table(); 81 unsigned long reflect(unsigned long ref, char ch); 82 unsigned int getCRC(unsigned char* text, size_t len); 79 83 bool checkHeaderCRC( unsigned int crcOffset, 80 84 unsigned int headerSize ); … … 89 93 fb_quadlet_t m_softwareId; 90 94 fb_quadlet_t m_softwareVersion; 91 fb_quadlet_t m_hardwareId;92 fb_quadlet_t m_vendorOUI;93 95 fb_quadlet_t m_hardwareId; 96 fb_quadlet_t m_vendorOUI; 97 94 98 95 99 fb_quadlet_t m_imageBaseAddress; … … 99 103 100 104 fb_quadlet_t m_cneLength; 101 fb_quadlet_t m_cneOffset;102 fb_quadlet_t m_cneCRC;105 fb_quadlet_t m_cneOffset; 106 fb_quadlet_t m_cneCRC; 103 107 104 108 105 109 106 DECLARE_DEBUG_MODULE;110 DECLARE_DEBUG_MODULE; 107 111 }; 108 112 trunk/libffado/src/bebob/bebob_dl_codes.cpp
r407 r445 1 /* bebob_dl_codes.cpp 2 * Copyright (C) 2006 by Daniel Wagner 3 * 4 * This file is part of FreeBoB. 5 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.14 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 23 20 24 #include "bebob/bebob_dl_codes.h" 21 25 #include "bebob/bebob_dl_bcd.h" trunk/libffado/src/bebob/bebob_dl_codes.h
r420 r445 1 /* bebob_dl_codes.h 2 * Copyright (C) 2006 by Daniel Wagner 3 * 4 * This file is part of FreeBoB. 5 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.14 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 … … 64 67 fb_byte_t operandSizeRequestField, 65 68 fb_byte_t operandSizeResponseField ); 66 virtual ~CommandCodes();69 virtual ~CommandCodes(); 67 70 68 71 virtual bool serialize( IOSSerialize& se ); … … 74 77 { return static_cast<EBootloaderCommandCodes>( m_commandCode ); } 75 78 76 fb_byte_t getProtocolVersion() const77 { return m_protocolVersion; }79 fb_byte_t getProtocolVersion() const 80 { return m_protocolVersion; } 78 81 size_t getMsgSize() const 79 82 { return m_msgSize; } … … 163 166 enum EObject { 164 167 eO_Application = 0, 165 eO_Config = 1,166 eO_Debugger = 2,168 eO_Config = 1, 169 eO_Debugger = 2, 167 170 eO_Bootloader = 3, 168 eO_WarpImage = 4,169 eO_SerialBootCode = 5,171 eO_WarpImage = 4, 172 eO_SerialBootCode = 5, 170 173 }; 171 174 172 175 CommandCodesDownloadStart( fb_quadlet_t protocolVersion, 173 EObject object );176 EObject object ); 174 177 virtual ~CommandCodesDownloadStart(); 175 178 … … 218 221 virtual bool deserialize( IISDeserialize& de ); 219 222 220 bool setSeqNumber( fb_quadlet_t seqNumber )221 { m_seqNumber = seqNumber; return true; }222 bool setAddress( fb_quadlet_t address )223 bool setSeqNumber( fb_quadlet_t seqNumber ) 224 { m_seqNumber = seqNumber; return true; } 225 bool setAddress( fb_quadlet_t address ) 223 226 { m_address = address; return true; } 224 227 bool setNumberBytes( fb_quadlet_t numByte ) … … 233 236 fb_quadlet_t m_numBytes; 234 237 235 fb_quadlet_t m_resp_seqNumber;236 fb_quadlet_t m_resp_errorCode;238 fb_quadlet_t m_resp_seqNumber; 239 fb_quadlet_t m_resp_errorCode; 237 240 }; 238 241 … … 287 290 enum EStartMode { 288 291 eSM_Application = 0, 289 eSM_Debugger = 2,292 eSM_Debugger = 2, 290 293 }; 291 294 … … 306 309 private: 307 310 fb_quadlet_t m_startMode; 308 fb_quadlet_t m_resp_validCRC;311 fb_quadlet_t m_resp_validCRC; 309 312 }; 310 313 trunk/libffado/src/bebob/bebob_dl_mgr.cpp
r420 r445 1 /* bebob_dl_mgr.cpp2 * Copyright (C) 200 6by Daniel Wagner1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 3 * 4 * This file is part of FreeBoB. 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 5 6 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 14 17 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 23 20 24 #include "bebob_dl_mgr.h" 21 25 #include "bebob_dl_codes.h" trunk/libffado/src/bebob/bebob_dl_mgr.h
r407 r445 1 /* bebob_dl_mgr.h2 * Copyright (C) 200 6by Daniel Wagner1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 3 * 4 * This file is part of FreeBoB. 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 5 6 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 14 17 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 23 20 24 #ifndef BEBOB_DL_MGR_H 21 25 #define BEBOB_DL_MGR_H … … 51 55 bool programGUID( octlet_t guid ); 52 56 53 void busresetHandler();57 void busresetHandler(); 54 58 55 Ieee1394Service* get1394Serivce() const59 Ieee1394Service* get1394Serivce() const 56 60 { return m_ieee1394service; } 57 61 58 bool setForceOperations( bool enabled )62 bool setForceOperations( bool enabled ) 59 63 { m_forceEnabled = enabled; return true; } 60 64 61 bool setStartBootloader( bool bStartBootloader )62 { m_bStartBootloader = bStartBootloader; return true; }65 bool setStartBootloader( bool bStartBootloader ) 66 { m_bStartBootloader = bStartBootloader; return true; } 63 67 protected: 64 enum EObjectType {65 eOT_Application,66 eOT_CnE67 };68 enum EObjectType { 69 eOT_Application, 70 eOT_CnE 71 }; 68 72 69 void waitForBusReset();73 void waitForBusReset(); 70 74 bool writeRequest( CommandCodes& cmd ); 71 bool readResponse( CommandCodes& writeRequestCmd );72 bool downloadObject( BCD& bcd, EObjectType eObject );75 bool readResponse( CommandCodes& writeRequestCmd ); 76 bool downloadObject( BCD& bcd, EObjectType eObject ); 73 77 74 78 bool programGUIDCmd( octlet_t guid ); 75 bool startBootloaderCmd();79 bool startBootloaderCmd(); 76 80 bool startApplicationCmd(); 77 81 bool initializePersParamCmd(); … … 111 115 info_register_t m_cachedInfoRegs; 112 116 113 pthread_mutex_t m_mutex;114 pthread_cond_t m_cond;117 pthread_mutex_t m_mutex; 118 pthread_cond_t m_cond; 115 119 116 Functor* m_functor;120 Functor* m_functor; 117 121 118 122 bool m_forceEnabled; 119 bool m_bStartBootloader;123 bool m_bStartBootloader; 120 124 121 DECLARE_DEBUG_MODULE;125 DECLARE_DEBUG_MODULE; 122 126 }; 123 127 } trunk/libffado/src/bebob/bebob_functionblock.cpp
r413 r445 1 /* bebob_functionblock.cpp2 * Copyright (C) 200 6,07 by Daniel Wagner1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 3 * 4 * This file is part of FreeBoB. 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 5 6 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 14 17 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 23 20 24 #include "bebob/bebob_functionblock.h" 21 25 #include "bebob/bebob_avdevice_subunit.h" trunk/libffado/src/bebob/bebob_functionblock.h
r420 r445 1 /* bebob_functionblock.h 2 * Copyright (C) 2006,07 by Daniel Wagner 3 * 4 * This file is part of FreeBoB. 5 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.14 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 23 20 24 #ifndef BEBOB_FUNCTION_BLOCK_H 21 25 #define BEBOB_FUNCTION_BLOCK_H … … 47 51 48 52 FunctionBlock( AvDeviceSubunit& subunit, 49 function_block_type_t type,53 function_block_type_t type, 50 54 function_block_type_t subtype, 51 55 function_block_id_t id, … … 65 69 bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; 66 70 static FunctionBlock* deserialize( Glib::ustring basePath, 67 Util::IODeserialize& deser,68 AvDevice& avDevice,71 Util::IODeserialize& deser, 72 AvDevice& avDevice, 69 73 AvDeviceSubunit& subunit); 70 74 protected: trunk/libffado/src/bounce/bounce_avdevice.cpp
r436 r445 1 /* bounce_avdevice.cpp2 * Copyright (C) 200 6by Pieter Palmers3 * Copyright (C) 200 6by Daniel Wagner1 /* 2 * Copyright (C) 2005-2007 by Pieter Palmers 3 * Copyright (C) 2005-2007 by Daniel Wagner 4 4 * 5 * This file is part of FreeBoB. 5 * This file is part of FFADO 6 * FFADO = Free Firewire (pro-)audio drivers for linux 6 7 * 7 * FreeBoB is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * FreeBoB is distributed in the hope that it will be useful, 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, 12 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNUGeneral Public License for more details.16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * Lesser General Public License for more details. 15 18 * 16 * You should have received a copy of the GNU General Public License17 * along with FreeBoB; if not, write to the Free Software18 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,19 * MA 0211 1-1307 USA.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 20 23 */ 24 21 25 #include "bounce/bounce_avdevice.h" 22 26 … … 45 49 static VendorModelEntry supportedDeviceList[] = 46 50 { 47 {0x0B0001LU, 0x0B0001LU, 0x0B0001LU, "F reeBoB", "Bounce"},51 {0x0B0001LU, 0x0B0001LU, 0x0B0001LU, "FFADO", "Bounce"}, 48 52 }; 49 53 … … 80 84 ++i ) 81 85 { 82 if ( 86 if ( 83 87 // ( supportedDeviceList[i].vendor_id == vendorId ) 84 88 ( supportedDeviceList[i].model_id == modelId ) 85 && ( supportedDeviceList[i].unit_specifier_id == unitSpecifierId ) 89 && ( supportedDeviceList[i].unit_specifier_id == unitSpecifierId ) 86 90 ) 87 91 { … … 98 102 debugOutput( DEBUG_LEVEL_VERBOSE, "discovering BounceDevice (NodeID %d)\n", 99 103 m_nodeId ); 100 104 101 105 // unsigned int vendorId = m_pConfigRom->getNodeVendorId(); 102 106 unsigned int modelId = m_pConfigRom->getModelId(); … … 108 112 { 109 113 if ( //( supportedDeviceList[i].vendor_id == vendorId ) 110 ( supportedDeviceList[i].model_id == modelId ) 111 && ( supportedDeviceList[i].unit_specifier_id == unitSpecifierId ) 114 ( supportedDeviceList[i].model_id == modelId ) 115 && ( supportedDeviceList[i].unit_specifier_id == unitSpecifierId ) 112 116 ) 113 117 { … … 168 172 169 173 debugOutput(DEBUG_LEVEL_VERBOSE,"Adding ports to processor\n"); 170 174 171 175 std::string id=std::string("dev?"); 172 176 if(!getOption("id", id)) { 173 177 debugWarning("Could not retrieve id parameter, defauling to 'dev?'\n"); 174 178 } 175 179 176 180 int i=0; 177 181 for (i=0;i<BOUNCE_NB_AUDIO_CHANNELS;i++) { … … 205 209 free(buff); 206 210 } 207 211 208 212 for (i=0;i<BOUNCE_NB_MIDI_CHANNELS;i++) { 209 213 char *buff; … … 237 241 } 238 242 239 return true;243 return true; 240 244 } 241 245 … … 243 247 BounceDevice::prepare() { 244 248 debugOutput(DEBUG_LEVEL_NORMAL, "Preparing BounceDevice...\n" ); 245 249 246 250 bool snoopMode=false; 247 251 if(!getOption("snoopMode", snoopMode)) { … … 251 255 // create & add streamprocessors 252 256 Streaming::StreamProcessor *p; 253 257 254 258 p=new Streaming::AmdtpReceiveStreamProcessor( 255 259 m_p1394Service->getPort(), … … 285 289 BOUNCE_NB_AUDIO_CHANNELS+(BOUNCE_NB_MIDI_CHANNELS?1:0)); 286 290 } 287 291 288 292 if(!p->init()) { 289 293 debugFatal("Could not initialize transmit processor %s!\n", … … 335 339 int n=i; 336 340 Streaming::StreamProcessor *p=m_receiveProcessors.at(n); 337 341 338 342 // allocate ISO channel 339 343 int isochannel=allocateIsoChannel(p->getMaxPacketSize()); … … 343 347 } 344 348 p->setChannel(isochannel); 345 349 346 350 fb_quadlet_t reg_isoch; 347 351 // check value of ISO_CHANNEL register … … 358 362 return false; 359 363 } 360 364 361 365 // write value of ISO_CHANNEL register 362 366 reg_isoch=isochannel; … … 367 371 return false; 368 372 } 369 373 370 374 return true; 371 375 372 376 } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) { 373 377 int n=i-m_receiveProcessors.size(); 374 378 Streaming::StreamProcessor *p=m_transmitProcessors.at(n); 375 379 376 380 // allocate ISO channel 377 381 int isochannel=allocateIsoChannel(p->getMaxPacketSize()); … … 381 385 } 382 386 p->setChannel(isochannel); 383 387 384 388 fb_quadlet_t reg_isoch; 385 389 // check value of ISO_CHANNEL register … … 396 400 return false; 397 401 } 398 402 399 403 // write value of ISO_CHANNEL register 400 404 reg_isoch=isochannel; … … 405 409 return false; 406 410 } 407 411 408 412 return true; 409 413 } 410 414 411 415 debugError("SP index %d out of range!\n",i); 412 416 413 417 return false; 414 418 } … … 420 424 Streaming::StreamProcessor *p=m_receiveProcessors.at(n); 421 425 unsigned int isochannel=p->getChannel(); 422 426 423 427 fb_quadlet_t reg_isoch; 424 428 // check value of ISO_CHANNEL register … … 431 435 return false; 432 436 } 433 437 434 438 // write value of ISO_CHANNEL register 435 439 reg_isoch=0xFFFFFFFFUL; … … 438 442 return false; 439 443 } 440 444 441 445 // deallocate ISO channel 442 446 if(!deallocateIsoChannel(isochannel)) { … … 444 448 return false; 445 449 } 446 450 447 451 p->setChannel(-1); 448 452 return true; 449 453 450 454 } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) { 451 455 int n=i-m_receiveProcessors.size(); 452 456 Streaming::StreamProcessor *p=m_transmitProcessors.at(n); 453 457 454 458 unsigned int isochannel=p->getChannel(); 455 459 456 460 fb_quadlet_t reg_isoch; 457 461 // check value of ISO_CHANNEL register … … 464 468 return false; 465 469 } 466 470 467 471 // write value of ISO_CHANNEL register 468 472 reg_isoch=0xFFFFFFFFUL; … … 471 475 return false; 472 476 } 473 477 474 478 // deallocate ISO channel 475 479 if(!deallocateIsoChannel(isochannel)) { … … 477 481 return false; 478 482 } 479 483 480 484 p->setChannel(-1); 481 485 return true; 482 486 } 483 487 484 488 debugError("SP index %d out of range!\n",i); 485 489 return false; … … 491 495 int BounceDevice::allocateIsoChannel(unsigned int packet_size) { 492 496 unsigned int bandwidth=8+packet_size; 493 497 494 498 int ch=m_p1394Service->allocateIsoChannelGeneric(bandwidth); 495 499 496 500 debugOutput(DEBUG_LEVEL_VERBOSE, "allocated channel %d, bandwidth %d\n", 497 501 ch, bandwidth); 498 502 499 503 return ch; 500 504 } … … 510 514 BounceDevice::readReg(fb_nodeaddr_t offset, fb_quadlet_t *result) { 511 515 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading base register offset 0x%08llX\n", offset); 512 516 513 517 if(offset >= BOUNCE_INVALID_OFFSET) { 514 518 debugError("invalid offset: 0x%016llX\n", offset); 515 519 return false; 516 520 } 517 521 518 522 fb_nodeaddr_t addr=BOUNCE_REGISTER_BASE + offset; 519 523 fb_nodeid_t nodeId=m_nodeId | 0xFFC0; 520 524 521 525 if(!m_p1394Service->read_quadlet( nodeId, addr, result ) ) { 522 526 debugError("Could not read from node 0x%04X addr 0x%012X\n", nodeId, addr); … … 524 528 } 525 529 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Read result: 0x%08X\n", *result); 526 530 527 531 return true; 528 532 } … … 530 534 bool 531 535 BounceDevice::writeReg(fb_nodeaddr_t offset, fb_quadlet_t data) { 532 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing base register offset 0x%08llX, data: 0x%08X\n", 536 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing base register offset 0x%08llX, data: 0x%08X\n", 533 537 offset, data); 534 538 535 539 if(offset >= BOUNCE_INVALID_OFFSET) { 536 540 debugError("invalid offset: 0x%016llX\n", offset); 537 541 return false; 538 542 } 539 543 540 544 fb_nodeaddr_t addr=BOUNCE_REGISTER_BASE + offset; 541 545 fb_nodeid_t nodeId=m_nodeId | 0xFFC0; 542 546 543 547 if(!m_p1394Service->write_quadlet( nodeId, addr, data ) ) { 544 548 debugError("Could not write to node 0x%04X addr 0x%012X\n", nodeId, addr); … … 548 552 } 549 553 550 bool 554 bool 551 555 BounceDevice::readRegBlock(fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { 552 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading base register offset 0x%08llX, length %u\n", 556 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading base register offset 0x%08llX, length %u\n", 553 557 offset, length); 554 558 555 559 if(offset >= BOUNCE_INVALID_OFFSET) { 556 560 debugError("invalid offset: 0x%016llX\n", offset); 557 561 return false; 558 562 } 559 563 560 564 fb_nodeaddr_t addr=BOUNCE_REGISTER_BASE + offset; 561 565 fb_nodeid_t nodeId=m_nodeId | 0xFFC0; 562 566 563 567 if(!m_p1394Service->read( nodeId, addr, length, data ) ) { 564 568 debugError("Could not read from node 0x%04X addr 0x%012llX\n", nodeId, addr); … … 568 572 } 569 573 570 bool 574 bool 571 575 BounceDevice::writeRegBlock(fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { 572 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing base register offset 0x%08llX, length: %u\n", 576 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing base register offset 0x%08llX, length: %u\n", 573 577 offset, length); 574 578 575 579 if(offset >= BOUNCE_INVALID_OFFSET) { 576 580 debugError("invalid offset: 0x%016llX\n", offset); 577 581 return false; 578 582 } 579 583 580 584 fb_nodeaddr_t addr=BOUNCE_REGISTER_BASE + offset; 581 585 fb_nodeid_t nodeId=m_nodeId | 0xFFC0; trunk/libffado/src/bounce/bounce_avdevice.h
r436 r445 1 /* bounce_avdevice.h2 * Copyright (C) 200 6by Pieter Palmers3 * Copyright (C) 200 6by Daniel Wagner1 /* 2 * Copyright (C) 2005-2007 by Pieter Palmers 3 * Copyright (C) 2005-2007 by Daniel Wagner 4 4 * 5 * This file is part of FreeBoB. 5 * This file is part of FFADO 6 * FFADO = Free Firewire (pro-)audio drivers for linux 6 7 * 7 * FreeBoB is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * FreeBoB is distributed in the hope that it will be useful, 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, 12 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNUGeneral Public License for more details.16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * Lesser General Public License for more details. 15 18 * 16 * You should have received a copy of the GNU General Public License17 * along with FreeBoB; if not, write to the Free Software18 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,19 * MA 0211 1-1307 USA.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 20 23 */ 24 21 25 #ifndef BOUNCEDEVICE_H 22 26 #define BOUNCEDEVICE_H … … 66 70 public: 67 71 BounceDevice( std::auto_ptr<ConfigRom>( configRom ), 68 Ieee1394Service& ieee1394Service,69 int nodeId );72 Ieee1394Service& ieee1394Service, 73 int nodeId ); 70 74 virtual ~BounceDevice(); 71 75 72 76 static bool probe( ConfigRom& configRom ); 73 77 bool discover(); 74 78 75 79 bool setSamplingFrequency( ESamplingFrequency samplingFrequency ); 76 80 int getSamplingFrequency( ); 77 81 78 82 bool prepare(); 79 83 bool lock(); … … 86 90 bool startStreamByIndex(int i); 87 91 bool stopStreamByIndex(int i); 88 92 89 93 void showDevice(); 90 94 … … 99 103 100 104 bool addPortsToProcessor( 101 Streaming::StreamProcessor *processor, 105 Streaming::StreamProcessor *processor, 102 106 Streaming::Port::E_Direction direction); 103 107 104 108 private: // generic helpers 105 109 int allocateIsoChannel(unsigned int packet_size); … … 112 116 bool readRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t); 113 117 bool writeRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t); 114 118 115 119 private: 116 120 BounceNotifier *m_Notifier; 117 121 /** 118 * this class reacts on the other side writing to the 122 * this class reacts on the other side writing to the 119 123 * hosts address space 120 124 */ … … 126 130 BounceNotifier(BounceDevice *, nodeaddr_t start); 127 131 virtual ~BounceNotifier(); 128 132 129 133 private: 130 134 BounceDevice *m_bouncedevice; trunk/libffado/src/bounce/bounce_slave_avdevice.cpp
r435 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob Streaming API5 * FreeBob = Firewire (pro-)audio for linux2 * Copyright (C) 2005-2007 by Pieter Palmers 3 * Copyright (C) 2005-2007 by Daniel Wagner 6 4 * 7 * http://freebob.sf.net 5 * This file is part of FFADO 6 * FFADO = Free Firewire (pro-)audio drivers for linux 8 7 * 9 * Copyright (C) 2007 Pieter Palmers <pieterpalmers@users.sourceforge.net>8 * FFADO is based upon FreeBoB 10 9 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 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; 15 13 * 16 * This programis distributed in the hope that it will be useful,17 * but WITHOUT ANY WARRANTY {}without even the implied warranty of18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the19 * GNUGeneral Public License for more details.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. 20 18 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 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 27 23 */ 28 24 … … 42 38 { 43 39 //{vendor_id, model_id, unit_specifier_id, vendor_name, model_name}, 44 {0x0B0001, 0x0B0001, 0x0B0001, "F reeBoB", "Bounce Slave"},40 {0x0B0001, 0x0B0001, 0x0B0001, "FFADO", "Bounce Slave"}, 45 41 }; 46 42 … … 80 76 debugOutput(DEBUG_LEVEL_VERBOSE, "Initializing memory space...\n"); 81 77 fb_quadlet_t result=0xFFFFFFFFLU; 82 78 83 79 // initialize the ISO channel registers 84 80 // this will write to our own registers … … 91 87 return false; 92 88 } 93 89 94 90 // set everything such that we can be discovered 95 91 m_original_config_rom=save_config_rom( m_p1394Service->getHandle() ); 96 92 97 93 if ( init_config_rom( m_p1394Service->getHandle() ) < 0 ) { 98 94 debugError("Could not initalize local config rom\n"); 99 95 return false; 100 96 } 101 97 102 98 // refresh our config rom cache 103 99 if ( !m_pConfigRom->initialize() ) { … … 122 118 bool 123 119 BounceSlaveDevice::lock() { 124 debugOutput(DEBUG_LEVEL_VERBOSE, "Locking %s %s at node %d\n", 120 debugOutput(DEBUG_LEVEL_VERBOSE, "Locking %s %s at node %d\n", 125 121 m_model->vendor_name, m_model->model_name, m_nodeId); 126 122 127 123 // get a notifier to handle device notifications 128 124 nodeaddr_t notify_address; … … 131 127 BOUNCE_REGISTER_LENGTH, 132 128 BOUNCE_REGISTER_LENGTH); 133 129 134 130 if (notify_address == 0xFFFFFFFFFFFFFFFFLLU) { 135 131 debugError("Could not find free ARM block for notification\n"); 136 132 return false; 137 133 } 138 134 139 135 m_Notifier=new BounceSlaveDevice::BounceSlaveNotifier(this, notify_address); 140 136 141 137 if(!m_Notifier) { 142 138 debugError("Could not allocate notifier\n"); 143 139 return false; 144 140 } 145 141 146 142 if (!m_p1394Service->registerARMHandler(m_Notifier)) { 147 143 debugError("Could not register notifier\n"); … … 150 146 return false; 151 147 } 152 148 153 149 // (re)initialize the memory space 154 150 if (!initMemSpace()) { … … 156 152 return false; 157 153 } 158 154 159 155 return true; 160 156 } … … 177 173 BounceSlaveDevice::prepare() { 178 174 debugOutput(DEBUG_LEVEL_NORMAL, "Preparing BounceSlaveDevice...\n" ); 179 175 180 176 // create & add streamprocessors 181 177 Streaming::StreamProcessor *p; 182 178 183 179 p=new Streaming::AmdtpSlaveReceiveStreamProcessor( 184 180 m_p1394Service->getPort(), … … 206 202 m_samplerate, 207 203 BOUNCE_NB_AUDIO_CHANNELS); 208 204 209 205 if(!p->init()) { 210 206 debugFatal("Could not initialize transmit processor!\n"); … … 227 223 bool 228 224 BounceSlaveDevice::startStreamByIndex(int i) { 229 225 230 226 if (i<(int)m_receiveProcessors.size()) { 231 227 int n=i; 232 228 Streaming::StreamProcessor *p=m_receiveProcessors.at(n); 233 229 234 230 // the other side sends on this channel 235 231 nodeaddr_t iso_channel_offset = BOUNCE_REGISTER_RX_ISOCHANNEL; 236 232 iso_channel_offset += ((unsigned)n)*4; 237 233 238 234 if (!waitForRegisterNotEqualTo(iso_channel_offset, 0xFFFFFFFFLU)) { 239 235 debugError("Timeout waiting for stream %d to get an ISO channel\n",i); 240 236 return false; 241 237 } 242 238 243 239 fb_quadlet_t result; 244 240 // this will read from our own registers … … 247 243 return false; 248 244 } 249 245 250 246 // set ISO channel 251 247 p->setChannel(result); 252 248 253 249 return true; 254 250 255 251 } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) { 256 252 int n=i-m_receiveProcessors.size(); 257 253 Streaming::StreamProcessor *p=m_transmitProcessors.at(n); 258 254 259 255 // the other side sends on this channel 260 256 nodeaddr_t iso_channel_offset = BOUNCE_REGISTER_TX_ISOCHANNEL; 261 257 iso_channel_offset += ((unsigned)n)*4; 262 258 263 259 if (!waitForRegisterNotEqualTo(iso_channel_offset, 0xFFFFFFFF)) { 264 260 debugError("Timeout waiting for stream %d to get an ISO channel\n",i); 265 261 return false; 266 262 } 267 263 268 264 fb_quadlet_t result; 269 265 // this will read from our own registers … … 272 268 return false; 273 269 } 274 270 275 271 // set ISO channel 276 272 p->setChannel(result); … … 279 275 280 276 } 281 277 282 278 debugError("SP index %d out of range!\n",i); 283 279 284 280 return false; 285 281 } … … 301 297 debugWarning("Could not retrieve isoTimeoutSecs parameter, defauling to 120secs\n"); 302 298 } 303 299 304 300 int wait_cycles=timeoutSecs*10; // two seconds 305 301 306 302 fb_quadlet_t reg=v; 307 303 308 304 while ((v == reg) && wait_cycles) { 309 305 wait_cycles--; … … 318 314 return false; 319 315 } 320 316 321 317 return true; 322 318 } … … 326 322 327 323 328 struct BounceSlaveDevice::configrom_backup 324 struct BounceSlaveDevice::configrom_backup 329 325 BounceSlaveDevice::save_config_rom(raw1394handle_t handle) 330 326 { … … 333 329 /* get the current rom image */ 334 330 retval=raw1394_get_config_rom(handle, tmp.rom, 0x100, &tmp.rom_size, &tmp.rom_version); 335 // tmp.rom_size=rom1394_get_size(tmp.rom);331 // tmp.rom_size=rom1394_get_size(tmp.rom); 336 332 // printf("save_config_rom get_config_rom returned %d, romsize %d, rom_version %d:\n",retval,tmp.rom_size,tmp.rom_version); 337 333 … … 339 335 } 340 336 341 int 337 int 342 338 BounceSlaveDevice::restore_config_rom(raw1394handle_t handle, struct BounceSlaveDevice::configrom_backup old) 343 339 { 344 340 int retval; 345 341 // int i; 346 342 347 343 quadlet_t current_rom[0x100]; 348 344 size_t current_rom_size; … … 371 367 } 372 368 373 int 369 int 374 370 BounceSlaveDevice::init_config_rom(raw1394handle_t handle) 375 371 { … … 380 376 rom1394_directory dir; 381 377 char *leaf; 382 378 383 379 /* get the current rom image */ 384 380 retval=raw1394_get_config_rom(handle, rom, 0x100, &rom_size, &rom_version); … … 391 387 // } 392 388 // printf("\n"); 393 389 394 390 /* get the local directory */ 395 391 rom1394_get_directory( handle, raw1394_get_local_id(handle) & 0x3f, &dir); 396 392 397 393 /* change the vendor description for kicks */ 398 394 i = strlen(dir.textual_leafs[0]); 399 strncpy(dir.textual_leafs[0], F REEBOB_BOUNCE_SERVER_VENDORNAME " ", i);400 401 dir.vendor_id=F REEBOB_BOUNCE_SERVER_VENDORID;402 dir.model_id=F REEBOB_BOUNCE_SERVER_MODELID;403 395 strncpy(dir.textual_leafs[0], FFADO_BOUNCE_SERVER_VENDORNAME " ", i); 396 397 dir.vendor_id=FFADO_BOUNCE_SERVER_VENDORID; 398 dir.model_id=FFADO_BOUNCE_SERVER_MODELID; 399 404 400 /* update the rom */ 405 401 retval = rom1394_set_directory(rom, &dir); … … 411 407 // } 412 408 // printf("\n"); 413 409 414 410 /* free the allocated mem for the textual leaves */ 415 411 rom1394_free_directory( &dir); 416 412 417 413 /* add an AV/C unit directory */ 418 dir.unit_spec_id = F REEBOB_BOUNCE_SERVER_SPECID;414 dir.unit_spec_id = FFADO_BOUNCE_SERVER_SPECID; 419 415 dir.unit_sw_version = 0x00010001; 420 leaf = F REEBOB_BOUNCE_SERVER_MODELNAME;416 leaf = FFADO_BOUNCE_SERVER_MODELNAME; 421 417 dir.nr_textual_leafs = 1; 422 418 dir.textual_leafs = &leaf; 423 419 424 420 /* manipulate the rom */ 425 421 retval = rom1394_add_unit( rom, &dir); 426 422 427 423 /* get the computed size of the rom image */ 428 424 rom_size = rom1394_get_size(rom); 429 425 430 426 // printf("rom1394_add_unit_directory returned %d, romsize %d:",retval,rom_size); 431 427 // for (i = 0; i < rom_size; i++) … … 435 431 // } 436 432 // printf("\n"); 437 // 433 // 438 434 /* convert computed rom size from quadlets to bytes before update */ 439 435 rom_size *= sizeof(quadlet_t); 440 436 retval = raw1394_update_config_rom(handle, rom, rom_size, rom_version); 441 437 // printf("update_config_rom returned %d\n",retval); 442 438 443 439 retval=raw1394_get_config_rom(handle, rom, 0x100, &rom_size, &rom_version); 444 440 // printf("get_config_rom returned %d, romsize %d, rom_version %d:",retval,rom_size,rom_version); … … 449 445 // } 450 446 // printf("\n"); 451 452 // printf("You need to reload your ieee1394 modules to reset the rom.\n");453 447 448 // printf("You need to reload your ieee1394 modules to reset the rom.\n"); 449 454 450 return 0; 455 451 } … … 459 455 460 456 BounceSlaveDevice::BounceSlaveNotifier::BounceSlaveNotifier(BounceSlaveDevice *d, nodeaddr_t start) 461 : ARMHandler(start, BOUNCE_REGISTER_LENGTH, 457 : ARMHandler(start, BOUNCE_REGISTER_LENGTH, 462 458 RAW1394_ARM_READ | RAW1394_ARM_WRITE, // allowed operations 463 459 0, //RAW1394_ARM_READ | RAW1394_ARM_WRITE, // operations to be notified of … … 468 464 } 469 465 470 BounceSlaveDevice::BounceSlaveNotifier::~BounceSlaveNotifier() 466 BounceSlaveDevice::BounceSlaveNotifier::~BounceSlaveNotifier() 471 467 { 472 468 trunk/libffado/src/bounce/bounce_slave_avdevice.h
r435 r445 1 /* $Id$ */ 1 /* 2 * Copyright (C) 2005-2007 by Pieter Palmers 3 * Copyright (C) 2005-2007 by Daniel Wagner 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 */ 2 24 3 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2007 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 27 */ 28 #ifndef __FREEBOB_BOUNCESLAVEDEVICE__ 29 #define __FREEBOB_BOUNCESLAVEDEVICE__ 25 #ifndef __FFADO_BOUNCESLAVEDEVICE__ 26 #define __FFADO_BOUNCESLAVEDEVICE__ 30 27 31 28 #include "debugmodule/debugmodule.h" 32 29 #include "bounce_avdevice.h" 33 30 34 #define F REEBOB_MAX_NAME_LEN 25631 #define FFADO_MAX_NAME_LEN 256 35 32 36 #define F REEBOB_BOUNCE_SERVER_VENDORNAME "FreeBoBServer"37 #define F REEBOB_BOUNCE_SERVER_MODELNAME "freebob-server"33 #define FFADO_BOUNCE_SERVER_VENDORNAME "FFADO Server" 34 #define FFADO_BOUNCE_SERVER_MODELNAME "ffado-server" 38 35 39 36 // NOTE: this is currently free, but it is not really allowed to use 40 #define F REEBOB_BOUNCE_SERVER_VENDORID 0x000B000141 #define F REEBOB_BOUNCE_SERVER_MODELID 0x000B000142 #define F REEBOB_BOUNCE_SERVER_SPECID 0x000B000137 #define FFADO_BOUNCE_SERVER_VENDORID 0x000B0001 38 #define FFADO_BOUNCE_SERVER_MODELID 0x000B0001 39 #define FFADO_BOUNCE_SERVER_SPECID 0x000B0001 43 40 44 41 namespace Bounce { … … 51 48 Ieee1394Service& ieee1394Service ); 52 49 virtual ~BounceSlaveDevice(); 53 50 54 51 static bool probe( ConfigRom& configRom ); 55 52 bool discover(); … … 57 54 bool lock(); 58 55 bool unlock(); 59 56 60 57 bool startStreamByIndex(int i); 61 58 bool stopStreamByIndex(int i); … … 65 62 bool initMemSpace(); 66 63 bool restoreMemSpace(); 67 64 68 65 private: // configrom shit 69 66 … … 74 71 }; 75 72 struct configrom_backup m_original_config_rom; 76 77 struct configrom_backup 73 74 struct configrom_backup 78 75 save_config_rom(raw1394handle_t handle); 79 76 int restore_config_rom(raw1394handle_t handle, struct configrom_backup old); 80 77 int init_config_rom(raw1394handle_t handle); 81 78 82 79 private: 83 80 BounceSlaveNotifier *m_Notifier; 84 81 /** 85 * this class reacts on the ohter side writing to the 82 * this class reacts on the ohter side writing to the 86 83 * hosts address space 87 84 */ … … 91 88 BounceSlaveNotifier(BounceSlaveDevice *, nodeaddr_t start); 92 89 virtual ~BounceSlaveNotifier(); 93 90 94 91 private: 95 92 BounceSlaveDevice *m_bounceslavedevice; … … 99 96 } // end of namespace Bounce 100 97 101 #endif /* __F REEBOB_BOUNCESLAVEDEVICE__ */98 #endif /* __FFADO_BOUNCESLAVEDEVICE__ */ 102 99 103 100 trunk/libffado/src/bridgeco-downloader.cpp
r442 r445 1 /* freebob-downloader.cpp 2 * Copyright (C) 2006 by Daniel Wagner 3 * 4 * This file is part of FreeBoB. 5 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 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 is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License version 2 11 * as published by the Free Software Foundation. 12 * 13 * FFADO is distributed in the hope that it will be useful, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the … … 14 17 * 15 18 * You should have received a copy of the GNU General Public License 16 * along with F reeBoB; if not, write to the Free Software19 * along with FFADO; if not, write to the Free Software 17 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 18 21 * MA 02111-1307 USA. … … 32 35 // arg parsing 33 36 //////////////////////////////////////////////// 34 const char *argp_program_version = " freebob_downloader 0.1";35 const char *argp_program_bug_address = "<f reebob-devel@lists.sf.net>";36 static char doc[] = " freebob_downloader -- firmware downloader application\n\n"37 const char *argp_program_version = "bridgeco-downloader 0.1"; 38 const char *argp_program_bug_address = "<ffado-devel@lists.sf.net>"; 39 static char doc[] = "bridgeco-downloader -- firmware downloader application for BridgeCo devices\n\n" 37 40 "OPERATION: display\n" 38 41 " setguid GUID\n" … … 135 138 int node_id = strtol(arguments.args[0], &tail, 0); 136 139 if (errno) { 137 perror("argument parsing failed:");138 return -1;140 perror("argument parsing failed:"); 141 return -1; 139 142 } 140 143 … … 220 223 return 0; 221 224 } 222 223 trunk/libffado/src/debugmodule/debugmodule.cpp
r406 r445 1 /* debugmodule.cpp 2 * Copyright (C) 2005 by Daniel Wagner 1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 * Copyright (C) 2005-2007 by Pieter Palmers 3 4 * 4 * This file is part of FreeBoB. 5 * This file is part of FFADO 6 * FFADO = Free Firewire (pro-)audio drivers for linux 5 7 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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, 11 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * Lesser General Public License for more details. 14 18 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 23 */ 20 24 … … 54 58 DebugModule::~DebugModule() 55 59 { 56 if ( m_level >= eDL_VeryVerbose ) {57 cout << "Unregistering "58 << this->getName()59 << " at DebugModuleManager"60 << endl;61 }60 // if ( m_level >= eDL_VeryVerbose ) { 61 // cout << "Unregistering " 62 // << this->getName() 63 // << " at DebugModuleManager" 64 // << endl; 65 // } 62 66 if ( !DebugModuleManager::instance()->unregisterModule( *this ) ) { 63 67 cerr << "Could not unregister DebugModule at DebugModuleManager" … … 99 103 va_list arg; 100 104 va_start( arg, format ); 101 105 102 106 // remove the path info from the filename 103 107 const char *f = file; … … 107 111 fname=f; 108 112 } 109 113 110 114 DebugModuleManager::instance()->print( "%s (%s)[%4d] %s: ", getPreSequence( level ), 111 115 fname, line, function ); … … 149 153 DebugModuleManager::~DebugModuleManager() 150 154 { 151 // cleanin up leftover modules155 // cleanin up leftover modules 152 156 for ( DebugModuleVectorIterator it = m_debugModules.begin(); 153 157 it != m_debugModules.end(); … … 159 163 } 160 164 161 if (!mb_initialized)162 return;163 164 pthread_mutex_lock(&mb_write_lock);165 mb_initialized = 0;166 pthread_cond_signal(&mb_ready_cond);167 pthread_mutex_unlock(&mb_write_lock);168 169 pthread_join(mb_writer_thread, NULL);170 mb_flush();171 172 if (mb_overruns)173 fprintf(stderr, "WARNING: %d message buffer overruns!\n",174 mb_overruns);175 else176 fprintf(stderr, "no message buffer overruns\n");177 178 pthread_mutex_destroy(&mb_write_lock);179 pthread_cond_destroy(&mb_ready_cond);165 if (!mb_initialized) 166 return; 167 168 pthread_mutex_lock(&mb_write_lock); 169 mb_initialized = 0; 170 pthread_cond_signal(&mb_ready_cond); 171 pthread_mutex_unlock(&mb_write_lock); 172 173 pthread_join(mb_writer_thread, NULL); 174 mb_flush(); 175 176 if (mb_overruns) 177 fprintf(stderr, "WARNING: %d message buffer overruns!\n", 178 mb_overruns); 179 else 180 fprintf(stderr, "no message buffer overruns\n"); 181 182 pthread_mutex_destroy(&mb_write_lock); 183 pthread_cond_destroy(&mb_ready_cond); 180 184 181 185 } … … 184 188 DebugModuleManager::init() 185 189 { 186 if (mb_initialized)187 return true;190 if (mb_initialized) 191 return true; 188 192 189 193 // if ( m_level >= eDL_VeryVerbose ) 190 194 // cout << "DebugModuleManager init..." << endl; 191 195 192 pthread_mutex_init(&mb_write_lock, NULL);193 pthread_cond_init(&mb_ready_cond, NULL);194 195 mb_overruns = 0;196 mb_initialized = 1;197 198 if (pthread_create(&mb_writer_thread, NULL, &mb_thread_func, (void *)this) != 0)199 mb_initialized = 0;196 pthread_mutex_init(&mb_write_lock, NULL); 197 pthread_cond_init(&mb_ready_cond, NULL); 198 199 mb_overruns = 0; 200 mb_initialized = 1; 201 202 if (pthread_create(&mb_writer_thread, NULL, &mb_thread_func, (void *)this) != 0) 203 mb_initialized = 0; 200 204 201 205 return true; … … 223 227 { 224 228 bool already_present=false; 225 229 226 230 for ( DebugModuleVectorIterator it = m_debugModules.begin(); 227 231 it != m_debugModules.end(); … … 233 237 } 234 238 } 235 239 236 240 if (already_present) { 237 241 cerr << "DebugModuleManager::registerModule: Module already registered: " … … 246 250 DebugModuleManager::unregisterModule( DebugModule& debugModule ) 247 251 { 248 252 249 253 for ( DebugModuleVectorIterator it = m_debugModules.begin(); 250 254 it != m_debugModules.end(); … … 256 260 } 257 261 } 258 262 259 263 cerr << "DebugModuleManager::unregisterModule: Could not unregister " 260 264 << "DebugModule (" << debugModule.getName() << ")" << endl; … … 288 292 DebugModuleManager::mb_flush() 289 293 { 290 /* called WITHOUT the mb_write_lock */291 while (mb_outbuffer != mb_inbuffer) {292 fputs(mb_buffers[mb_outbuffer], stderr);293 mb_outbuffer = MB_NEXT(mb_outbuffer);294 }294 /* called WITHOUT the mb_write_lock */ 295 while (mb_outbuffer != mb_inbuffer) { 296 fputs(mb_buffers[mb_outbuffer], stderr); 297 mb_outbuffer = MB_NEXT(mb_outbuffer); 298 } 295 299 } 296 300 … … 301 305 DebugModuleManager *m=static_cast<DebugModuleManager *>(arg); 302 306 303 /* The mutex is only to eliminate collisions between multiple304 * writer threads and protect the condition variable. */305 pthread_mutex_lock(&m->mb_write_lock);306 307 while (m->mb_initialized) {308 pthread_cond_wait(&m->mb_ready_cond, &m->mb_write_lock);309 310 /* releasing the mutex reduces contention */311 pthread_mutex_unlock(&m->mb_write_lock);312 m->mb_flush();313 pthread_mutex_lock(&m->mb_write_lock);314 }315 316 pthread_mutex_unlock(&m->mb_write_lock);317 318 return NULL;307 /* The mutex is only to eliminate collisions between multiple 308 * writer threads and protect the condition variable. */ 309 pthread_mutex_lock(&m->mb_write_lock); 310 311 while (m->mb_initialized) { 312 pthread_cond_wait(&m->mb_ready_cond, &m->mb_write_lock); 313 314 /* releasing the mutex reduces contention */ 315 pthread_mutex_unlock(&m->mb_write_lock); 316 m->mb_flush(); 317 pthread_mutex_lock(&m->mb_write_lock); 318 } 319 320 pthread_mutex_unlock(&m->mb_write_lock); 321 322 return NULL; 319 323 } 320 324 … … 322 326 DebugModuleManager::print(const char *fmt, ...) 323 327 { 324 char msg[MB_BUFFERSIZE];325 va_list ap;326 327 /* format the message first, to reduce lock contention */328 va_start(ap, fmt);329 vsnprintf(msg, MB_BUFFERSIZE, fmt, ap);330 va_end(ap);331 332 if (!mb_initialized) {333 /* Unable to print message with realtime safety.334 * Complain and print it anyway. */335 fprintf(stderr, "ERROR: messagebuffer not initialized: %s",336 msg);337 return;338 }339 if (pthread_mutex_trylock(&mb_write_lock) == 0) {340 strncpy(mb_buffers[mb_inbuffer], msg, MB_BUFFERSIZE);341 mb_inbuffer = MB_NEXT(mb_inbuffer);342 pthread_cond_signal(&mb_ready_cond);343 pthread_mutex_unlock(&mb_write_lock);344 } else {/* lock collision */345 // atomic_add(&mb_overruns, 1);346 // FIXME: atomicity347 mb_overruns++; // skip the atomicness for now348 }328 char msg[MB_BUFFERSIZE]; 329 va_list ap; 330 331 /* format the message first, to reduce lock contention */ 332 va_start(ap, fmt); 333 vsnprintf(msg, MB_BUFFERSIZE, fmt, ap); 334 va_end(ap); 335 336 if (!mb_initialized) { 337 /* Unable to print message with realtime safety. 338 * Complain and print it anyway. */ 339 fprintf(stderr, "ERROR: messagebuffer not initialized: %s", 340 msg); 341 return; 342 } 343 if (pthread_mutex_trylock(&mb_write_lock) == 0) { 344 strncpy(mb_buffers[mb_inbuffer], msg, MB_BUFFERSIZE); 345 mb_inbuffer = MB_NEXT(mb_inbuffer); 346 pthread_cond_signal(&mb_ready_cond); 347 pthread_mutex_unlock(&mb_write_lock); 348 } else { /* lock collision */ 349 // atomic_add(&mb_overruns, 1); 350 // FIXME: atomicity 351 mb_overruns++; // skip the atomicness for now 352 } 349 353 } 350 354 … … 353 357 DebugModuleManager::va_print (const char *fmt, va_list ap) 354 358 { 355 char msg[MB_BUFFERSIZE];356 357 /* format the message first, to reduce lock contention */358 vsnprintf(msg, MB_BUFFERSIZE, fmt, ap);359 360 if (!mb_initialized) {361 /* Unable to print message with realtime safety.362 * Complain and print it anyway. */363 fprintf(stderr, "ERROR: messagebuffer not initialized: %s",364 msg);365 return;366 }367 368 if (pthread_mutex_trylock(&mb_write_lock) == 0) {369 strncpy(mb_buffers[mb_inbuffer], msg, MB_BUFFERSIZE);370 mb_inbuffer = MB_NEXT(mb_inbuffer);371 pthread_cond_signal(&mb_ready_cond);372 pthread_mutex_unlock(&mb_write_lock);373 } else {/* lock collision */374 // atomic_add(&mb_overruns, 1);375 // FIXME: atomicity376 mb_overruns++; // skip the atomicness for now377 }359 char msg[MB_BUFFERSIZE]; 360 361 /* format the message first, to reduce lock contention */ 362 vsnprintf(msg, MB_BUFFERSIZE, fmt, ap); 363 364 if (!mb_initialized) { 365 /* Unable to print message with realtime safety. 366 * Complain and print it anyway. */ 367 fprintf(stderr, "ERROR: messagebuffer not initialized: %s", 368 msg); 369 return; 370 } 371 372 if (pthread_mutex_trylock(&mb_write_lock) == 0) { 373 strncpy(mb_buffers[mb_inbuffer], msg, MB_BUFFERSIZE); 374 mb_inbuffer = MB_NEXT(mb_inbuffer); 375 pthread_cond_signal(&mb_ready_cond); 376 pthread_mutex_unlock(&mb_write_lock); 377 } else { /* lock collision */ 378 // atomic_add(&mb_overruns, 1); 379 // FIXME: atomicity 380 mb_overruns++; // skip the atomicness for now 381 } 378 382 } 379 383 trunk/libffado/src/debugmodule/debugmodule.h
r392 r445 1 /* debugmodule.h 2 * Copyright (C) 2005 by Daniel Wagner 3 * 4 * This file is part of FreeBoB. 5 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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, 11 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.14 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 23 */ 20 24 … … 31 35 32 36 /* MB_NEXT() relies on the fact that MB_BUFFERS is a power of two */ 33 #define MB_BUFFERS 819237 #define MB_BUFFERS 8192 34 38 #define MB_NEXT(index) ((index+1) & (MB_BUFFERS-1)) 35 #define MB_BUFFERSIZE 256/* message length limit */39 #define MB_BUFFERSIZE 256 /* message length limit */ 36 40 37 41 #define debugFatal( format, args... ) \ … … 78 82 #define IMPL_GLOBAL_DEBUG_MODULE( RegisterName, Level ) \ 79 83 DebugModule m_debugModule = \ 80 DebugModule( #RegisterName, Level )84 DebugModule( #RegisterName, Level ) 81 85 82 86 #define setDebugLevel( Level ) { \ 83 87 m_debugModule.setLevel( Level ); \ 84 }88 } 85 89 86 90 /* m_debugModule.print( eDL_Normal, \ … … 90 94 "Setting debug level to %d\n", \ 91 95 Level ); \ 92 }*/96 }*/ 93 97 94 98 #define getDebugLevel( ) \ … … 97 101 98 102 #ifdef DEBUG 99 103 100 104 #define debugOutput( level, format, args... ) \ 101 105 m_debugModule.print( level, \ … … 129 133 130 134 #include <sys/time.h> 131 135 132 136 #ifdef DO_PREEMPTION_CHECKING 133 137 #define CHECK_PREEMPTION(onoff) \ 134 gettimeofday((struct timeval *)1, (struct timezone *)onoff)138 gettimeofday((struct timeval *)1, (struct timezone *)onoff) 135 139 #else 136 140 #define CHECK_PREEMPTION(onoff) … … 196 200 static DebugModuleManager* instance(); 197 201 ~DebugModuleManager(); 198 202 199 203 bool setMgrDebugLevel( std::string name, debug_level_t level ); 200 204 … … 206 210 207 211 bool init(); 208 212 209 213 void print(const char *fmt, ...); 210 214 void va_print(const char *fmt, va_list); 211 215 212 216 private: 213 217 DebugModuleManager(); … … 227 231 static void *mb_thread_func(void *arg); 228 232 void mb_flush(); 229 233 230 234 static DebugModuleManager* m_instance; 231 235 DebugModuleVector m_debugModules; trunk/libffado/src/debugmodule/test_debugmodule.cpp
r168 r445 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 is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU General Public License version 2 12 * as published by the Free Software Foundation. 13 * 14 * FFADO 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 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with FFADO; if not, write to the Free Software 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 22 * MA 02111-1307 USA. 23 */ 24 1 25 #include "debugmodule.h" 2 26 trunk/libffado/src/devicemanager.cpp
r436 r445 1 /* devicemanager.cpp 2 * Copyright (C) 2005,06,07 by Daniel Wagner 3 * 4 * This file is part of FreeBoB. 5 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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, 11 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.14 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 23 */ 20 24 … … 94 98 95 99 void 96 DeviceManager::setVerboseLevel(int l) 100 DeviceManager::setVerboseLevel(int l) 97 101 { 98 102 m_verboseLevel=l; 99 103 setDebugLevel(l); 100 104 101 105 if (m_1394Service) m_1394Service->setVerboseLevel(l); 102 106 if (m_oscServer) m_oscServer->setVerboseLevel(l); 103 107 OscNode::setVerboseLevel(l); 104 108 105 109 for ( IAvDeviceVectorIterator it = m_avDevices.begin(); 106 110 it != m_avDevices.end(); … … 126 130 return false; 127 131 } 128 132 129 133 m_oscServer = new OSC::OscServer("17820"); 130 134 131 135 if (!m_oscServer) { 132 136 debugFatal("failed to create osc server\n"); … … 135 139 return false; 136 140 } 137 141 138 142 if (!m_oscServer->init()) { 139 143 debugFatal("failed to init osc server\n"); … … 144 148 return false; 145 149 } 146 150 147 151 if (!m_oscServer->registerAtRootNode(this)) { 148 152 debugFatal("failed to register devicemanager at server\n"); … … 153 157 return false; 154 158 } 155 159 156 160 if (!m_oscServer->start()) { 157 161 debugFatal("failed to start osc server\n"); … … 162 166 return false; 163 167 } 164 168 165 169 setVerboseLevel(m_verboseLevel); 166 170 return true; … … 198 202 { 199 203 debugOutput( DEBUG_LEVEL_VERBOSE, "Probing node %d...\n", nodeId ); 200 204 201 205 if (nodeId == m_1394Service->getLocalNodeId()) { 202 206 debugOutput( DEBUG_LEVEL_VERBOSE, "Skipping local node (%d)...\n", nodeId ); 203 207 continue; 204 208 } 205 209 206 210 std::auto_ptr<ConfigRom> configRom = 207 211 std::auto_ptr<ConfigRom>( new ConfigRom( *m_1394Service, … … 219 223 continue; 220 224 } 221 225 222 226 IAvDevice* avDevice = getDriverForDevice( configRom, 223 227 nodeId ); … … 228 232 229 233 avDevice->setVerboseLevel( m_verboseLevel ); 230 234 231 235 if ( !avDevice->discover() ) { 232 236 debugError( "discover: could not discover device\n" ); … … 238 242 debugError( "setting Id failed\n" ); 239 243 } 240 244 241 245 if (snoopMode) { 242 246 debugOutput( DEBUG_LEVEL_VERBOSE, … … 249 253 } 250 254 } 251 255 252 256 if ( m_verboseLevel >= DEBUG_LEVEL_VERBOSE ) { 253 257 avDevice->showDevice(); … … 255 259 256 260 m_avDevices.push_back( avDevice ); 257 261 258 262 if (!addChildOscNode(avDevice)) { 259 263 debugWarning("failed to register AvDevice at OSC server\n"); … … 263 267 } 264 268 return true; 265 269 266 270 } else { // slave mode 267 271 fb_nodeid_t nodeId = m_1394Service->getLocalNodeId(); … … 289 293 "discover: driver found for device %d\n", 290 294 nodeId ); 291 295 292 296 avDevice->setVerboseLevel( m_verboseLevel ); 293 297 … … 307 311 m_avDevices.push_back( avDevice ); 308 312 } 309 313 310 314 return true; 311 315 } … … 392 396 393 397 if (avDevice->getConfigRom().getNodeId() == node) { 394 return true;395 }398 return true; 399 } 396 400 } 397 401 return false; … … 440 444 DeviceManager::getAvDeviceByIndex( int idx ) 441 445 { 442 return m_avDevices.at(idx);446 return m_avDevices.at(idx); 443 447 } 444 448 … … 446 450 DeviceManager::getAvDeviceCount( ) 447 451 { 448 return m_avDevices.size();452 return m_avDevices.size(); 449 453 } 450 454 … … 465 469 debugWarning("Could not retrieve slaveMode parameter, defauling to false\n"); 466 470 } 467 471 468 472 #warning TEST CODE FOR BOUNCE DEVICE !! 469 473 // this makes the bounce slave use the xmit SP as sync source … … 473 477 return device->getStreamProcessorByIndex(0); 474 478 } 475 476 479 } 477 480 … … 487 490 int i; 488 491 i=0; // avoids unused warning 489 492 490 493 for ( IAvDeviceVectorIterator it = m_avDevices.begin(); 491 494 it != m_avDevices.end(); … … 494 497 IAvDevice* pAvDevice; 495 498 pAvDevice = *it; // avoids unused warning 496 499 497 500 #ifdef ENABLE_BEBOB 498 501 BeBoB::AvDevice* pBeBoBDevice = reinterpret_cast< BeBoB::AvDevice* >( pAvDevice ); … … 577 580 } while ( pBeBoBDevice ); 578 581 #endif 579 582 580 583 return true; 581 584 } trunk/libffado/src/devicemanager.h
r436 r445 1 /* devicemanager.h 2 * Copyright (C) 2005 by Daniel Wagner 1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 * Copyright (C) 2005-2007 by Pieter Palmers 3 4 * 4 * This file is part of FreeBoB. 5 * This file is part of FFADO 6 * FFADO = Free Firewire (pro-)audio drivers for linux 5 7 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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, 11 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * Lesser General Public License for more details. 14 18 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 23 */ 20 24 21 #ifndef F REEBOBDEVICEMANAGER_H22 #define F REEBOBDEVICEMANAGER_H25 #ifndef FFADODEVICEMANAGER_H 26 #define FFADODEVICEMANAGER_H 23 27 24 28 #include "debugmodule/debugmodule.h" … … 44 48 typedef std::vector< IAvDevice* >::iterator IAvDeviceVectorIterator; 45 49 46 class DeviceManager 50 class DeviceManager 47 51 : public Util::OptionContainer, 48 52 public OSC::OscNode … … 78 82 Ieee1394Service* m_1394Service; 79 83 IAvDeviceVector m_avDevices; 80 84 81 85 OSC::OscServer* m_oscServer; 82 86 83 87 // debug stuff 84 88 public: trunk/libffado/src/dice/dice_avdevice.cpp
r436 r445 1 /* dice_avdevice.cpp2 * Copyright (C) 200 7 by Pieter Palmers1 /* 2 * Copyright (C) 2005-2007 by Pieter Palmers 3 3 * 4 * This file is part of FreeBob. 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 5 6 * 6 * FreeBob is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBob is distributed in the hope that it will be useful, 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 14 17 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBob; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 … … 94 97 { 95 98 if ( ( supportedDeviceList[i].vendor_id == vendorId ) 96 && ( supportedDeviceList[i].model_id == modelId ) 99 && ( supportedDeviceList[i].model_id == modelId ) 97 100 ) 98 101 { … … 115 118 { 116 119 if ( ( supportedDeviceList[i].vendor_id == vendorId ) 117 && ( supportedDeviceList[i].model_id == modelId ) 120 && ( supportedDeviceList[i].model_id == modelId ) 118 121 ) 119 122 { … … 126 129 return false; 127 130 } 128 131 129 132 if ( !initIoFunctions() ) { 130 133 debugError("Could not initialize I/O functions\n"); … … 138 141 } 139 142 140 int 143 int 141 144 DiceAvDevice::getSamplingFrequency( ) { 142 145 ESamplingFrequency samplingFrequency; 143 146 144 147 fb_quadlet_t clockreg; 145 148 if (!readGlobalReg(DICE_REGISTER_GLOBAL_CLOCK_SELECT, &clockreg)) { … … 147 150 return false; 148 151 } 149 152 150 153 clockreg = DICE_GET_RATE(clockreg); 151 154 … … 164 167 default: samplingFrequency = eSF_DontCare; break; 165 168 } 166 169 167 170 return convertESamplingFrequency(samplingFrequency); 168 171 } … … 171 174 DiceAvDevice::setSamplingFrequency( ESamplingFrequency samplingFrequency ) 172 175 { 173 debugOutput(DEBUG_LEVEL_VERBOSE, "Setting sample rate: %d\n", 176 debugOutput(DEBUG_LEVEL_VERBOSE, "Setting sample rate: %d\n", 174 177 convertESamplingFrequency(samplingFrequency)); 175 178 176 179 bool supported=false; 177 180 fb_quadlet_t select=0x0; 178 181 179 182 switch ( samplingFrequency ) { 180 183 default: … … 236 239 return false; 237 240 } 238 241 239 242 fb_quadlet_t clockreg; 240 243 if (!readGlobalReg(DICE_REGISTER_GLOBAL_CLOCK_SELECT, &clockreg)) { … … 256 259 return false; 257 260 } 258 261 259 262 if(clockreg != clockreg_verify) { 260 263 debugError("Samplerate register write failed\n"); 261 264 return false; 262 265 } 263 266 264 267 return true; 265 268 } … … 270 273 fb_quadlet_t tmp_quadlet; 271 274 fb_octlet_t tmp_octlet; 272 275 273 276 debugOutput(DEBUG_LEVEL_VERBOSE, 274 277 "%s %s at node %d\n", m_model->vendor_name, m_model->model_name, … … 285 288 286 289 debugOutput(DEBUG_LEVEL_VERBOSE," Global param space:\n"); 287 290 288 291 readGlobalRegBlock(DICE_REGISTER_GLOBAL_OWNER, (fb_quadlet_t *)&tmp_octlet,sizeof(fb_octlet_t)); 289 292 debugOutput(DEBUG_LEVEL_VERBOSE," Owner : 0x%016X\n",tmp_octlet); 290 293 291 294 readGlobalReg(DICE_REGISTER_GLOBAL_NOTIFICATION, &tmp_quadlet); 292 295 debugOutput(DEBUG_LEVEL_VERBOSE," Notification : 0x%08X\n",tmp_quadlet); 293 296 294 297 readGlobalReg(DICE_REGISTER_GLOBAL_NOTIFICATION, &tmp_quadlet); 295 298 debugOutput(DEBUG_LEVEL_VERBOSE," Nick name : %s\n",getDeviceNickName().c_str()); 296 299 297 300 readGlobalReg(DICE_REGISTER_GLOBAL_CLOCK_SELECT, &tmp_quadlet); 298 301 debugOutput(DEBUG_LEVEL_VERBOSE," Clock Select : 0x%02X 0x%02X\n", 299 302 (tmp_quadlet>>8) & 0xFF, tmp_quadlet & 0xFF); 300 303 301 304 readGlobalReg(DICE_REGISTER_GLOBAL_ENABLE, &tmp_quadlet); 302 305 debugOutput(DEBUG_LEVEL_VERBOSE," Enable : %s\n", 303 306 (tmp_quadlet&0x1?"true":"false")); 304 307 305 308 readGlobalReg(DICE_REGISTER_GLOBAL_STATUS, &tmp_quadlet); 306 309 debugOutput(DEBUG_LEVEL_VERBOSE," Clock Status : %s 0x%02X\n", 307 310 (tmp_quadlet&0x1?"locked":"not locked"), (tmp_quadlet>>8) & 0xFF); 308 311 309 312 readGlobalReg(DICE_REGISTER_GLOBAL_EXTENDED_STATUS, &tmp_quadlet); 310 313 debugOutput(DEBUG_LEVEL_VERBOSE," Extended Status : 0x%08X\n",tmp_quadlet); 311 314 312 315 readGlobalReg(DICE_REGISTER_GLOBAL_SAMPLE_RATE, &tmp_quadlet); 313 316 debugOutput(DEBUG_LEVEL_VERBOSE," Samplerate : 0x%08X (%lu)\n",tmp_quadlet,tmp_quadlet); 314 317 315 318 readGlobalReg(DICE_REGISTER_GLOBAL_VERSION, &tmp_quadlet); 316 319 debugOutput(DEBUG_LEVEL_VERBOSE," Version : 0x%08X (%u.%u.%u.%u)\n", … … 321 324 DICE_DRIVER_SPEC_VERSION_NUMBER_GET_D(tmp_quadlet) 322 325 ); 323 326 324 327 readGlobalReg(DICE_REGISTER_GLOBAL_CLOCKCAPABILITIES, &tmp_quadlet); 325 328 debugOutput(DEBUG_LEVEL_VERBOSE," Clock caps : 0x%08X\n",tmp_quadlet & 0x1FFF007F); … … 327 330 diceNameVector names=getClockSourceNameString(); 328 331 debugOutput(DEBUG_LEVEL_VERBOSE," Clock sources :\n"); 329 332 330 333 for ( diceNameVectorIterator it = names.begin(); 331 334 it != names.end(); … … 334 337 debugOutput(DEBUG_LEVEL_VERBOSE," %s\n", (*it).c_str()); 335 338 } 336 339 337 340 debugOutput(DEBUG_LEVEL_VERBOSE," TX param space:\n"); 338 341 debugOutput(DEBUG_LEVEL_VERBOSE," Nb of xmit : %1d\n", m_nb_tx); 339 342 for (unsigned int i=0;i<m_nb_tx;i++) { 340 343 debugOutput(DEBUG_LEVEL_VERBOSE," Transmitter %d:\n",i); 341 344 342 345 readTxReg(i, DICE_REGISTER_TX_ISOC_BASE, &tmp_quadlet); 343 346 debugOutput(DEBUG_LEVEL_VERBOSE," ISO channel : %3d\n", tmp_quadlet); 344 347 readTxReg(i, DICE_REGISTER_TX_SPEED_BASE, &tmp_quadlet); 345 348 debugOutput(DEBUG_LEVEL_VERBOSE," ISO speed : %3d\n", tmp_quadlet); 346 349 347 350 readTxReg(i, DICE_REGISTER_TX_NB_AUDIO_BASE, &tmp_quadlet); 348 351 debugOutput(DEBUG_LEVEL_VERBOSE," Nb audio channels : %3d\n", tmp_quadlet); 349 352 readTxReg(i, DICE_REGISTER_TX_MIDI_BASE, &tmp_quadlet); 350 353 debugOutput(DEBUG_LEVEL_VERBOSE," Nb midi channels : %3d\n", tmp_quadlet); 351 354 352 355 readTxReg(i, DICE_REGISTER_TX_AC3_CAPABILITIES_BASE, &tmp_quadlet); 353 356 debugOutput(DEBUG_LEVEL_VERBOSE," AC3 caps : 0x%08X\n", tmp_quadlet); 354 357 readTxReg(i, DICE_REGISTER_TX_AC3_ENABLE_BASE, &tmp_quadlet); 355 358 debugOutput(DEBUG_LEVEL_VERBOSE," AC3 enable : 0x%08X\n", tmp_quadlet); 356 359 357 360 diceNameVector channel_names=getTxNameString(i); 358 361 debugOutput(DEBUG_LEVEL_VERBOSE," Channel names :\n"); … … 364 367 } 365 368 } 366 369 367 370 debugOutput(DEBUG_LEVEL_VERBOSE," RX param space:\n"); 368 371 debugOutput(DEBUG_LEVEL_VERBOSE," Nb of recv : %1d\n", m_nb_tx); 369 372 for (unsigned int i=0;i<m_nb_rx;i++) { 370 373 debugOutput(DEBUG_LEVEL_VERBOSE," Receiver %d:\n",i); 371 374 372 375 readTxReg(i, DICE_REGISTER_RX_ISOC_BASE, &tmp_quadlet); 373 376 debugOutput(DEBUG_LEVEL_VERBOSE," ISO channel : %3d\n", tmp_quadlet); 374 377 readTxReg(i, DICE_REGISTER_RX_SEQ_START_BASE, &tmp_quadlet); 375 378 debugOutput(DEBUG_LEVEL_VERBOSE," Sequence start : %3d\n", tmp_quadlet); 376 379 377 380 readTxReg(i, DICE_REGISTER_RX_NB_AUDIO_BASE, &tmp_quadlet); 378 381 debugOutput(DEBUG_LEVEL_VERBOSE," Nb audio channels : %3d\n", tmp_quadlet); 379 382 readTxReg(i, DICE_REGISTER_RX_MIDI_BASE, &tmp_quadlet); 380 383 debugOutput(DEBUG_LEVEL_VERBOSE," Nb midi channels : %3d\n", tmp_quadlet); 381 384 382 385 readTxReg(i, DICE_REGISTER_RX_AC3_CAPABILITIES_BASE, &tmp_quadlet); 383 386 debugOutput(DEBUG_LEVEL_VERBOSE," AC3 caps : 0x%08X\n", tmp_quadlet); 384 387 readTxReg(i, DICE_REGISTER_RX_AC3_ENABLE_BASE, &tmp_quadlet); 385 388 debugOutput(DEBUG_LEVEL_VERBOSE," AC3 enable : 0x%08X\n", tmp_quadlet); 386 389 387 390 diceNameVector channel_names=getRxNameString(i); 388 391 debugOutput(DEBUG_LEVEL_VERBOSE," Channel names :\n"); … … 421 424 fb_quadlet_t nb_midi; 422 425 unsigned int nb_channels=0; 423 426 424 427 if(!readTxReg(i, DICE_REGISTER_TX_NB_AUDIO_BASE, &nb_audio)) { 425 428 debugError("Could not read DICE_REGISTER_TX_NB_AUDIO_BASE register for ATX%u",i); … … 430 433 continue; 431 434 } 432 435 433 436 // request the channel names 434 437 diceNameVector names_audio=getTxNameString(i); 435 438 436 439 if (names_audio.size() != nb_audio) { 437 440 debugWarning("The audio channel name vector is incorrect, using default names\n"); 438 441 names_audio.clear(); 439 442 440 443 for (unsigned int j=0;j<nb_audio;j++) { 441 444 std::ostringstream newname; … … 444 447 } 445 448 } 446 449 447 450 nb_channels=nb_audio; 448 451 if(nb_midi) nb_channels += 1; // midi-muxed counts as one 449 452 450 453 // construct the MIDI names 451 454 diceNameVector names_midi; … … 455 458 names_midi.push_back(newname.str()); 456 459 } 457 460 458 461 // construct the streamprocessor 459 462 Streaming::AmdtpReceiveStreamProcessor *p; … … 478 481 479 482 if (!addChannelToProcessor(&channelInfo, p, Streaming::Port::E_Capture)) { 480 debugError("Could not add channel %s to StreamProcessor\n", 483 debugError("Could not add channel %s to StreamProcessor\n", 481 484 channelInfo.name.c_str()); 482 485 continue; 483 486 } 484 487 } 485 488 486 489 // add midi ports to the processor 487 490 for (unsigned int j=0;j<nb_midi;j++) { … … 493 496 494 497 if (!addChannelToProcessor(&channelInfo, p, Streaming::Port::E_Capture)) { 495 debugError("Could not add channel %s to StreamProcessor\n", 498 debugError("Could not add channel %s to StreamProcessor\n", 496 499 channelInfo.name.c_str()); 497 500 continue; 498 501 } 499 502 } 500 503 501 504 // add the SP to the vector 502 505 m_receiveProcessors.push_back(p); 503 506 } 504 507 505 508 // prepare transmit SP's 506 509 for (unsigned int i=0;i<m_nb_rx;i++) { … … 508 511 fb_quadlet_t nb_midi; 509 512 unsigned int nb_channels=0; 510 513 511 514 if(!readTxReg(i, DICE_REGISTER_RX_NB_AUDIO_BASE, &nb_audio)) { 512 515 debugError("Could not read DICE_REGISTER_RX_NB_AUDIO_BASE register for ARX%u",i); … … 517 520 continue; 518 521 } 519 522 520 523 // request the channel names 521 524 diceNameVector names_audio=getRxNameString(i); 522 525 523 526 if (names_audio.size() != nb_audio) { 524 527 debugWarning("The audio channel name vector is incorrect, using default names\n"); 525 528 names_audio.clear(); 526 529 527 530 for (unsigned int j=0;j<nb_audio;j++) { 528 531 std::ostringstream newname; … … 531 534 } 532 535 } 533 536 534 537 nb_channels=nb_audio; 535 538 if(nb_midi) nb_channels += 1; // midi-muxed counts as one 536 539 537 540 // construct the MIDI names 538 541 diceNameVector names_midi; … … 542 545 names_midi.push_back(newname.str()); 543 546 } 544 547 545 548 // construct the streamprocessor 546 549 Streaming::AmdtpTransmitStreamProcessor *p; … … 565 568 566 569 if (!addChannelToProcessor(&channelInfo, p, Streaming::Port::E_Playback)) { 567 debugError("Could not add channel %s to StreamProcessor\n", 570 debugError("Could not add channel %s to StreamProcessor\n", 568 571 channelInfo.name.c_str()); 569 572 continue; 570 573 } 571 574 } 572 575 573 576 // add midi ports to the processor 574 577 for (unsigned int j=0;j<nb_midi;j++) { … … 580 583 581 584 if (!addChannelToProcessor(&channelInfo, p, Streaming::Port::E_Playback)) { 582 debugError("Could not add channel %s to StreamProcessor\n", 585 debugError("Could not add channel %s to StreamProcessor\n", 583 586 channelInfo.name.c_str()); 584 587 continue; 585 588 } 586 589 } 587 590 588 591 m_transmitProcessors.push_back(p); 589 592 } … … 596 599 Streaming::StreamProcessor *processor, 597 600 Streaming::Port::E_Direction direction) { 598 601 599 602 std::string id=std::string("dev?"); 600 603 if(!getOption("id", id)) { … … 609 612 portname << "c"; 610 613 } 611 614 612 615 portname << "_" << channelInfo->name; 613 616 … … 655 658 DiceAvDevice::lock() { 656 659 fb_octlet_t result; 657 658 debugOutput(DEBUG_LEVEL_VERBOSE, "Locking %s %s at node %d\n", 660 661 debugOutput(DEBUG_LEVEL_VERBOSE, "Locking %s %s at node %d\n", 659 662 m_model->vendor_name, m_model->model_name, m_nodeId); 660 663 661 664 // get a notifier to handle device notifications 662 665 nodeaddr_t notify_address; … … 665 668 DICE_NOTIFIER_BLOCK_LENGTH, 666 669 DICE_NOTIFIER_BLOCK_LENGTH); 667 670 668 671 if (notify_address == 0xFFFFFFFFFFFFFFFFLLU) { 669 672 debugError("Could not find free ARM block for notification\n"); 670 673 return false; 671 674 } 672 675 673 676 m_notifier=new DiceAvDevice::DiceNotifier(this, notify_address); 674 677 675 678 if(!m_notifier) { 676 679 debugError("Could not allocate notifier\n"); 677 680 return false; 678 681 } 679 682 680 683 if (!m_p1394Service->registerARMHandler(m_notifier)) { 681 684 debugError("Could not register notifier\n"); … … 686 689 687 690 // register this notifier 688 fb_nodeaddr_t addr = DICE_REGISTER_BASE 691 fb_nodeaddr_t addr = DICE_REGISTER_BASE 689 692 + m_global_reg_offset 690 693 + DICE_REGISTER_GLOBAL_OWNER; … … 696 699 return false; 697 700 } 698 701 699 702 fb_nodeaddr_t swap_value = ((0xFFC0) | m_p1394Service->getLocalNodeId()); 700 703 swap_value = swap_value << 48; 701 704 swap_value |= m_notifier->getStart(); 702 703 if (!m_p1394Service->lockCompareSwap64( m_nodeId | 0xFFC0, addr, DICE_OWNER_NO_OWNER, 705 706 if (!m_p1394Service->lockCompareSwap64( m_nodeId | 0xFFC0, addr, DICE_OWNER_NO_OWNER, 704 707 swap_value, &result )) { 705 708 debugWarning("Could not register ourselves as device owner\n"); 706 709 } 707 710 708 711 if (result != DICE_OWNER_NO_OWNER) { 709 712 debugWarning("Could not register ourselves as device owner, unexpected register value: 0x%016llX\n", result); … … 717 720 DiceAvDevice::unlock() { 718 721 fb_octlet_t result; 719 722 720 723 if(!m_notifier) { 721 724 debugWarning("Request to unlock, but no notifier present!\n"); 722 725 return false; 723 726 } 724 725 fb_nodeaddr_t addr = DICE_REGISTER_BASE 727 728 fb_nodeaddr_t addr = DICE_REGISTER_BASE 726 729 + m_global_reg_offset 727 730 + DICE_REGISTER_GLOBAL_OWNER; … … 733 736 return false; 734 737 } 735 738 736 739 fb_nodeaddr_t compare_value = ((0xFFC0) | m_p1394Service->getLocalNodeId()); 737 compare_value <<= 48; 740 compare_value <<= 48; 738 741 compare_value |= m_notifier->getStart(); 739 740 if (!m_p1394Service->lockCompareSwap64( m_nodeId | 0xFFC0, addr, compare_value, 742 743 if (!m_p1394Service->lockCompareSwap64( m_nodeId | 0xFFC0, addr, compare_value, 741 744 DICE_OWNER_NO_OWNER, &result )) { 742 745 debugWarning("Could not unregister ourselves as device owner\n"); 743 746 } 744 747 745 748 m_p1394Service->unregisterARMHandler(m_notifier); 746 749 delete m_notifier; … … 788 791 int n=i; 789 792 Streaming::StreamProcessor *p=m_receiveProcessors.at(n); 790 793 791 794 // allocate ISO channel 792 795 int isochannel=allocateIsoChannel(p->getMaxPacketSize()); … … 796 799 } 797 800 p->setChannel(isochannel); 798 801 799 802 fb_quadlet_t reg_isoch; 800 803 // check value of ISO_CHANNEL register … … 811 814 return false; 812 815 } 813 816 814 817 // write value of ISO_CHANNEL register 815 818 reg_isoch=isochannel; … … 820 823 return false; 821 824 } 822 825 823 826 return true; 824 827 825 828 } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) { 826 829 int n=i-m_receiveProcessors.size(); 827 830 Streaming::StreamProcessor *p=m_transmitProcessors.at(n); 828 831 829 832 // allocate ISO channel 830 833 int isochannel=allocateIsoChannel(p->getMaxPacketSize()); … … 834 837 } 835 838 p->setChannel(isochannel); 836 839 837 840 fb_quadlet_t reg_isoch; 838 841 // check value of ISO_CHANNEL register … … 849 852 return false; 850 853 } 851 854 852 855 // write value of ISO_CHANNEL register 853 856 reg_isoch=isochannel; … … 858 861 return false; 859 862 } 860 863 861 864 return true; 862 865 } 863 866 864 867 debugError("SP index %d out of range!\n",i); 865 868 866 869 return false; 867 870 } … … 879 882 Streaming::StreamProcessor *p=m_receiveProcessors.at(n); 880 883 unsigned int isochannel=p->getChannel(); 881 884 882 885 fb_quadlet_t reg_isoch; 883 886 // check value of ISO_CHANNEL register … … 890 893 return false; 891 894 } 892 895 893 896 // write value of ISO_CHANNEL register 894 897 reg_isoch=0xFFFFFFFFUL; … … 897 900 return false; 898 901 } 899 902 900 903 // deallocate ISO channel 901 904 if(!deallocateIsoChannel(isochannel)) { … … 903 906 return false; 904 907 } 905 908 906 909 p->setChannel(-1); 907 910 return true; 908 911 909 912 } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) { 910 913 int n=i-m_receiveProcessors.size(); 911 914 Streaming::StreamProcessor *p=m_transmitProcessors.at(n); 912 915 913 916 unsigned int isochannel=p->getChannel(); 914 917 915 918 fb_quadlet_t reg_isoch; 916 919 // check value of ISO_CHANNEL register … … 923 926 return false; 924 927 } 925 928 926 929 // write value of ISO_CHANNEL register 927 930 reg_isoch=0xFFFFFFFFUL; … … 930 933 return false; 931 934 } 932 935 933 936 // deallocate ISO channel 934 937 if(!deallocateIsoChannel(isochannel)) { … … 936 939 return false; 937 940 } 938 941 939 942 p->setChannel(-1); 940 943 return true; 941 944 } 942 945 943 946 debugError("SP index %d out of range!\n",i); 944 947 945 948 return false; 946 949 } … … 951 954 int DiceAvDevice::allocateIsoChannel(unsigned int packet_size) { 952 955 unsigned int bandwidth=8+packet_size; 953 956 954 957 int ch=m_p1394Service->allocateIsoChannelGeneric(bandwidth); 955 958 956 959 debugOutput(DEBUG_LEVEL_VERBOSE, "allocated channel %d, bandwidth %d\n", 957 960 ch, bandwidth); 958 961 959 962 return ch; 960 963 } … … 979 982 fb_quadlet_t result; 980 983 readGlobalReg(DICE_REGISTER_GLOBAL_ENABLE, &result); 981 // I don't know what exactly is 'enable', 984 // I don't know what exactly is 'enable', 982 985 // but disable is definately == 0 983 986 return (result != DICE_ISOSTREAMING_DISABLE); … … 1007 1010 diceNameVector names; 1008 1011 char namestring[DICE_TX_NAMES_SIZE+1]; 1009 1010 if (!readTxRegBlock(i, DICE_REGISTER_TX_NAMES_BASE, 1012 1013 if (!readTxRegBlock(i, DICE_REGISTER_TX_NAMES_BASE, 1011 1014 (fb_quadlet_t *)namestring, DICE_TX_NAMES_SIZE)) { 1012 1015 debugError("Could not read TX name string \n"); 1013 1016 return names; 1014 1017 } 1015 1018 1016 1019 namestring[DICE_TX_NAMES_SIZE]='\0'; 1017 1020 return splitNameString(std::string(namestring)); … … 1022 1025 diceNameVector names; 1023 1026 char namestring[DICE_RX_NAMES_SIZE+1]; 1024 1025 if (!readRxRegBlock(i, DICE_REGISTER_RX_NAMES_BASE, 1027 1028 if (!readRxRegBlock(i, DICE_REGISTER_RX_NAMES_BASE, 1026 1029 (fb_quadlet_t *)namestring, DICE_RX_NAMES_SIZE)) { 1027 1030 debugError("Could not read RX name string \n"); 1028 1031 return names; 1029 1032 } 1030 1033 1031 1034 namestring[DICE_RX_NAMES_SIZE]='\0'; 1032 1035 return splitNameString(std::string(namestring)); … … 1037 1040 diceNameVector names; 1038 1041 char namestring[DICE_CLOCKSOURCENAMES_SIZE+1]; 1039 1040 if (!readGlobalRegBlock(DICE_REGISTER_GLOBAL_CLOCKSOURCENAMES, 1042 1043 if (!readGlobalRegBlock(DICE_REGISTER_GLOBAL_CLOCKSOURCENAMES, 1041 1044 (fb_quadlet_t *)namestring, DICE_CLOCKSOURCENAMES_SIZE)) { 1042 1045 debugError("Could not read CLOCKSOURCE name string \n"); 1043 1046 return names; 1044 1047 } 1045 1048 1046 1049 namestring[DICE_CLOCKSOURCENAMES_SIZE]='\0'; 1047 1050 return splitNameString(std::string(namestring)); … … 1051 1054 DiceAvDevice::getDeviceNickName() { 1052 1055 char namestring[DICE_NICK_NAME_SIZE+1]; 1053 1054 if (!readGlobalRegBlock(DICE_REGISTER_GLOBAL_NICK_NAME, 1056 1057 if (!readGlobalRegBlock(DICE_REGISTER_GLOBAL_NICK_NAME, 1055 1058 (fb_quadlet_t *)namestring, DICE_NICK_NAME_SIZE)) { 1056 1059 debugError("Could not read nickname string \n"); 1057 1060 return std::string("(unknown)"); 1058 1061 } 1059 1062 1060 1063 namestring[DICE_NICK_NAME_SIZE]='\0'; 1061 1064 return std::string(namestring); … … 1096 1099 } 1097 1100 m_global_reg_offset*=4; 1098 1101 1099 1102 if(!readReg(DICE_REGISTER_GLOBAL_PAR_SPACE_SZ, &m_global_reg_size)) { 1100 1103 debugError("Could not initialize m_global_reg_size\n"); … … 1102 1105 } 1103 1106 m_global_reg_size*=4; 1104 1107 1105 1108 if(!readReg(DICE_REGISTER_TX_PAR_SPACE_OFF, &m_tx_reg_offset)) { 1106 1109 debugError("Could not initialize m_tx_reg_offset\n"); … … 1108 1111 } 1109 1112 m_tx_reg_offset*=4; 1110 1113 1111 1114 if(!readReg(DICE_REGISTER_TX_PAR_SPACE_SZ, &m_tx_reg_size)) { 1112 1115 debugError("Could not initialize m_tx_reg_size\n"); … … 1114 1117 } 1115 1118 m_tx_reg_size*=4; 1116 1119 1117 1120 if(!readReg(DICE_REGISTER_RX_PAR_SPACE_OFF, &m_rx_reg_offset)) { 1118 1121 debugError("Could not initialize m_rx_reg_offset\n"); … … 1120 1123 } 1121 1124 m_rx_reg_offset*=4; 1122 1125 1123 1126 if(!readReg(DICE_REGISTER_RX_PAR_SPACE_SZ, &m_rx_reg_size)) { 1124 1127 debugError("Could not initialize m_rx_reg_size\n"); … … 1126 1129 } 1127 1130 m_rx_reg_size*=4; 1128 1131 1129 1132 if(!readReg(DICE_REGISTER_UNUSED1_SPACE_OFF, &m_unused1_reg_offset)) { 1130 1133 debugError("Could not initialize m_unused1_reg_offset\n"); … … 1132 1135 } 1133 1136 m_unused1_reg_offset*=4; 1134 1137 1135 1138 if(!readReg(DICE_REGISTER_UNUSED1_SPACE_SZ, &m_unused1_reg_size)) { 1136 1139 debugError("Could not initialize m_unused1_reg_size\n"); … … 1138 1141 } 1139 1142 m_unused1_reg_size*=4; 1140 1143 1141 1144 if(!readReg(DICE_REGISTER_UNUSED2_SPACE_OFF, &m_unused2_reg_offset)) { 1142 1145 debugError("Could not initialize m_unused2_reg_offset\n"); … … 1144 1147 } 1145 1148 m_unused2_reg_offset*=4; 1146 1149 1147 1150 if(!readReg(DICE_REGISTER_UNUSED2_SPACE_SZ, &m_unused2_reg_size)) { 1148 1151 debugError("Could not initialize m_unused2_reg_size\n"); … … 1160 1163 } 1161 1164 m_tx_size*=4; 1162 1165 1163 1166 if(!readReg(m_tx_reg_offset + DICE_REGISTER_RX_NB_RX, &m_nb_rx)) { 1164 1167 debugError("Could not initialize m_nb_rx\n"); … … 1170 1173 } 1171 1174 m_rx_size*=4; 1172 1175 1173 1176 debugOutput(DEBUG_LEVEL_VERBOSE,"DICE Parameter Space info:\n"); 1174 1177 debugOutput(DEBUG_LEVEL_VERBOSE," Global : offset=%04X size=%04d\n", m_global_reg_offset, m_global_reg_size); … … 1179 1182 debugOutput(DEBUG_LEVEL_VERBOSE," UNUSED1 : offset=%04X size=%04d\n", m_unused1_reg_offset, m_unused1_reg_size); 1180 1183 debugOutput(DEBUG_LEVEL_VERBOSE," UNUSED2 : offset=%04X size=%04d\n", m_unused2_reg_offset, m_unused2_reg_size); 1181 1184 1182 1185 return true; 1183 1186 } … … 1186 1189 DiceAvDevice::readReg(fb_nodeaddr_t offset, fb_quadlet_t *result) { 1187 1190 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading base register offset 0x%08llX\n", offset); 1188 1191 1189 1192 if(offset >= DICE_INVALID_OFFSET) { 1190 1193 debugError("invalid offset: 0x%016llX\n", offset); 1191 1194 return false; 1192 1195 } 1193 1196 1194 1197 fb_nodeaddr_t addr=DICE_REGISTER_BASE + offset; 1195 1198 fb_nodeid_t nodeId=m_nodeId | 0xFFC0; 1196 1199 1197 1200 if(!m_p1394Service->read_quadlet( nodeId, addr, result ) ) { 1198 1201 debugError("Could not read from node 0x%04X addr 0x%012X\n", nodeId, addr); 1199 1202 return false; 1200 1203 } 1201 1204 1202 1205 *result=ntohl(*result); 1203 1206 1204 1207 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Read result: 0x%08X\n", *result); 1205 1208 1206 1209 return true; 1207 1210 } … … 1209 1212 bool 1210 1213 DiceAvDevice::writeReg(fb_nodeaddr_t offset, fb_quadlet_t data) { 1211 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing base register offset 0x%08llX, data: 0x%08X\n", 1214 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing base register offset 0x%08llX, data: 0x%08X\n", 1212 1215 offset, data); 1213 1216 1214 1217 if(offset >= DICE_INVALID_OFFSET) { 1215 1218 debugError("invalid offset: 0x%016llX\n", offset); 1216 1219 return false; 1217 1220 } 1218 1221 1219 1222 fb_nodeaddr_t addr=DICE_REGISTER_BASE + offset; 1220 1223 fb_nodeid_t nodeId=m_nodeId | 0xFFC0; 1221 1224 1222 1225 if(!m_p1394Service->write_quadlet( nodeId, addr, htonl(data) ) ) { 1223 1226 debugError("Could not write to node 0x%04X addr 0x%012X\n", nodeId, addr); … … 1227 1230 } 1228 1231 1229 bool 1232 bool 1230 1233 DiceAvDevice::readRegBlock(fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { 1231 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading base register offset 0x%08llX, length %u\n", 1234 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading base register offset 0x%08llX, length %u\n", 1232 1235 offset, length); 1233 1236 1234 1237 if(offset >= DICE_INVALID_OFFSET) { 1235 1238 debugError("invalid offset: 0x%016llX\n", offset); 1236 1239 return false; 1237 1240 } 1238 1241 1239 1242 fb_nodeaddr_t addr=DICE_REGISTER_BASE + offset; 1240 1243 fb_nodeid_t nodeId=m_nodeId | 0xFFC0; 1241 1244 1242 1245 if(!m_p1394Service->read( nodeId, addr, length/4, data ) ) { 1243 1246 debugError("Could not read from node 0x%04X addr 0x%012llX\n", nodeId, addr); 1244 1247 return false; 1245 1248 } 1246 1249 1247 1250 for(unsigned int i=0;i<length/4;i++) { 1248 1251 *(data+i)=ntohl(*(data+i)); 1249 1252 } 1250 1253 1251 1254 return true; 1252 1255 } 1253 1256 1254 bool 1257 bool 1255 1258 DiceAvDevice::writeRegBlock(fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { 1256 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing base register offset 0x%08llX, length: %u\n", 1259 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing base register offset 0x%08llX, length: %u\n", 1257 1260 offset, length); 1258 1261 1259 1262 if(offset >= DICE_INVALID_OFFSET) { 1260 1263 debugError("invalid offset: 0x%016llX\n", offset); 1261 1264 return false; 1262 1265 } 1263 1266 1264 1267 fb_nodeaddr_t addr=DICE_REGISTER_BASE + offset; 1265 1268 fb_nodeid_t nodeId=m_nodeId | 0xFFC0; 1266 1269 1267 1270 fb_quadlet_t data_out[length/4]; 1268 1271 1269 1272 for(unsigned int i=0;i<length/4;i++) { 1270 1273 data_out[i]=ntohl(*(data+i)); 1271 1274 } 1272 1275 1273 1276 if(!m_p1394Service->write( nodeId, addr, length/4, data_out ) ) { 1274 1277 debugError("Could not write to node 0x%04X addr 0x%012llX\n", nodeId, addr); 1275 1278 return false; 1276 1279 } 1277 1280 1278 1281 return true; 1279 1282 } … … 1289 1292 bool 1290 1293 DiceAvDevice::writeGlobalReg(fb_nodeaddr_t offset, fb_quadlet_t data) { 1291 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing global register offset 0x%08llX, data: 0x%08X\n", 1294 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing global register offset 0x%08llX, data: 0x%08X\n", 1292 1295 offset, data); 1293 1296 … … 1296 1299 } 1297 1300 1298 bool 1301 bool 1299 1302 DiceAvDevice::readGlobalRegBlock(fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { 1300 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading global register block offset 0x%04llX, length %u bytes\n", 1303 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading global register block offset 0x%04llX, length %u bytes\n", 1301 1304 offset, length); 1302 1305 … … 1305 1308 } 1306 1309 1307 bool 1310 bool 1308 1311 DiceAvDevice::writeGlobalRegBlock(fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { 1309 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing global register block offset 0x%04llX, length %u bytes\n", 1312 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing global register block offset 0x%04llX, length %u bytes\n", 1310 1313 offset, length); 1311 1314 … … 1314 1317 } 1315 1318 1316 fb_nodeaddr_t 1319 fb_nodeaddr_t 1317 1320 DiceAvDevice::globalOffsetGen(fb_nodeaddr_t offset, size_t length) { 1318 1321 … … 1328 1331 return DICE_INVALID_OFFSET; 1329 1332 } 1330 1333 1331 1334 return offset; 1332 1335 } … … 1335 1338 DiceAvDevice::readTxReg(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *result) { 1336 1339 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading tx %d register offset 0x%04llX\n", i, offset); 1337 1340 1338 1341 fb_nodeaddr_t offset_tx=txOffsetGen(i, offset, sizeof(fb_quadlet_t)); 1339 1342 return readReg(m_tx_reg_offset + offset_tx, result); … … 1349 1352 } 1350 1353 1351 bool 1354 bool 1352 1355 DiceAvDevice::readTxRegBlock(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { 1353 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading rx register block offset 0x%04llX, length %u bytes\n", 1356 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading rx register block offset 0x%04llX, length %u bytes\n", 1354 1357 offset, length); 1355 1358 1356 1359 fb_nodeaddr_t offset_tx=txOffsetGen(i, offset, length); 1357 1360 return readRegBlock(m_tx_reg_offset + offset_tx, data, length); 1358 1361 } 1359 1362 1360 bool 1363 bool 1361 1364 DiceAvDevice::writeTxRegBlock(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { 1362 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing rx register block offset 0x%04llX, length %u bytes\n", 1365 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing rx register block offset 0x%04llX, length %u bytes\n", 1363 1366 offset, length); 1364 1367 … … 1367 1370 } 1368 1371 1369 fb_nodeaddr_t 1372 fb_nodeaddr_t 1370 1373 DiceAvDevice::txOffsetGen(unsigned int i, fb_nodeaddr_t offset, size_t length) { 1371 1374 // registry offsets should always be smaller than 0x7FFFFFFF … … 1402 1405 DiceAvDevice::readRxReg(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *result) { 1403 1406 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading rx %d register offset 0x%04llX\n", i, offset); 1404 1407 1405 1408 fb_nodeaddr_t offset_rx=rxOffsetGen(i, offset, sizeof(fb_quadlet_t)); 1406 1409 return readReg(m_rx_reg_offset + offset_rx, result); … … 1409 1412 bool 1410 1413 DiceAvDevice::writeRxReg(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t data) { 1411 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing rx register offset 0x%08llX, data: 0x%08X\n", 1414 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing rx register offset 0x%08llX, data: 0x%08X\n", 1412 1415 offset, data); 1413 1416 1414 1417 fb_nodeaddr_t offset_rx=rxOffsetGen(i, offset, sizeof(fb_quadlet_t)); 1415 1418 return writeReg(m_rx_reg_offset + offset_rx, data); 1416 1419 } 1417 1420 1418 bool 1421 bool 1419 1422 DiceAvDevice::readRxRegBlock(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { 1420 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading rx register block offset 0x%04llX, length %u bytes\n", 1423 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading rx register block offset 0x%04llX, length %u bytes\n", 1421 1424 offset, length); 1422 1425 1423 1426 fb_nodeaddr_t offset_rx=rxOffsetGen(i, offset, length); 1424 1427 return readRegBlock(m_rx_reg_offset + offset_rx, data, length); 1425 1428 } 1426 1429 1427 bool 1430 bool 1428 1431 DiceAvDevice::writeRxRegBlock(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length) { 1429 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing rx register block offset 0x%04llX, length %u bytes\n", 1432 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Writing rx register block offset 0x%04llX, length %u bytes\n", 1430 1433 offset, length); 1431 1434 … … 1434 1437 } 1435 1438 1436 fb_nodeaddr_t 1439 fb_nodeaddr_t 1437 1440 DiceAvDevice::rxOffsetGen(unsigned int i, fb_nodeaddr_t offset, size_t length) { 1438 1441 // registry offsets should always be smaller than 0x7FFFFFFF … … 1469 1472 1470 1473 DiceAvDevice::DiceNotifier::DiceNotifier(DiceAvDevice *d, nodeaddr_t start) 1471 : ARMHandler(start, DICE_NOTIFIER_BLOCK_LENGTH, 1474 : ARMHandler(start, DICE_NOTIFIER_BLOCK_LENGTH, 1472 1475 RAW1394_ARM_READ | RAW1394_ARM_WRITE | RAW1394_ARM_LOCK, 1473 1476 RAW1394_ARM_WRITE, 0) … … 1477 1480 } 1478 1481 1479 DiceAvDevice::DiceNotifier::~DiceNotifier() 1482 DiceAvDevice::DiceNotifier::~DiceNotifier() 1480 1483 { 1481 1484 trunk/libffado/src/dice/dice_avdevice.h
r436 r445 1 /* dice_avdevice.h2 * Copyright (C) 200 7 by Pieter Palmers1 /* 2 * Copyright (C) 2005-2007 by Pieter Palmers 3 3 * 4 * This file is part of FreeBob. 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 5 6 * 6 * FreeBob is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBob is distributed in the hope that it will be useful, 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 14 17 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBob; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 23 20 24 #ifndef DICEDEVICE_H 21 25 #define DICEDEVICE_H … … 69 73 70 74 bool prepare(); 71 75 72 76 bool lock(); 73 77 bool unlock(); 74 78 75 79 bool startStreamByIndex(int i); 76 80 bool stopStreamByIndex(int i); 77 81 78 82 bool enableStreaming(); 79 83 bool disableStreaming(); 80 84 81 85 protected: 82 86 struct VendorModelEntry *m_model; 83 87 84 88 // streaming stuff 85 89 typedef std::vector< Streaming::StreamProcessor * > StreamProcessorVector; 86 90 StreamProcessorVector m_receiveProcessors; 87 91 StreamProcessorVector m_transmitProcessors; 88 92 89 93 private: // streaming & port helpers 90 94 enum EPortTypes { … … 92 96 ePT_MIDI, 93 97 }; 94 98 95 99 typedef struct { 96 100 std::string name; … … 98 102 unsigned int streamPosition; 99 103 unsigned int streamLocation; 100 } diceChannelInfo; 101 102 bool addChannelToProcessor( diceChannelInfo *, 103 Streaming::StreamProcessor *, 104 } diceChannelInfo; 105 106 bool addChannelToProcessor( diceChannelInfo *, 107 Streaming::StreamProcessor *, 104 108 Streaming::Port::E_Direction direction); 105 109 106 110 int allocateIsoChannel(unsigned int packet_size); 107 111 bool deallocateIsoChannel(int channel); 108 112 109 113 private: // helper functions 110 114 bool enableIsoStreaming(); 111 115 bool disableIsoStreaming(); 112 116 bool isIsoStreamingEnabled(); 113 117 114 118 bool maskedCheckZeroGlobalReg(fb_nodeaddr_t offset, fb_quadlet_t mask); 115 119 bool maskedCheckNotZeroGlobalReg(fb_nodeaddr_t offset, fb_quadlet_t mask); 116 120 117 121 typedef std::vector< std::string > diceNameVector; 118 122 typedef std::vector< std::string >::iterator diceNameVectorIterator; … … 122 126 diceNameVector getClockSourceNameString(); 123 127 std::string getDeviceNickName(); 124 128 125 129 private: // register I/O routines 126 130 bool initIoFunctions(); … … 130 134 bool readRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t); 131 135 bool writeRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t); 132 136 133 137 bool readGlobalReg(fb_nodeaddr_t, fb_quadlet_t *); 134 138 bool writeGlobalReg(fb_nodeaddr_t, fb_quadlet_t); … … 136 140 bool writeGlobalRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t); 137 141 fb_nodeaddr_t globalOffsetGen(fb_nodeaddr_t, size_t); 138 142 139 143 bool readTxReg(unsigned int i, fb_nodeaddr_t, fb_quadlet_t *); 140 144 bool writeTxReg(unsigned int i, fb_nodeaddr_t, fb_quadlet_t); … … 142 146 bool writeTxRegBlock(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length); 143 147 fb_nodeaddr_t txOffsetGen(unsigned int, fb_nodeaddr_t, size_t); 144 148 145 149 bool readRxReg(unsigned int i, fb_nodeaddr_t, fb_quadlet_t *); 146 150 bool writeRxReg(unsigned int i, fb_nodeaddr_t, fb_quadlet_t); … … 148 152 bool writeRxRegBlock(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length); 149 153 fb_nodeaddr_t rxOffsetGen(unsigned int, fb_nodeaddr_t, size_t); 150 154 151 155 fb_quadlet_t m_global_reg_offset; 152 156 fb_quadlet_t m_global_reg_size; … … 159 163 fb_quadlet_t m_unused2_reg_offset; 160 164 fb_quadlet_t m_unused2_reg_size; 161 165 162 166 fb_quadlet_t m_nb_tx; 163 167 fb_quadlet_t m_tx_size; 164 168 fb_quadlet_t m_nb_rx; 165 169 fb_quadlet_t m_rx_size; 166 170 167 171 private: 168 172 // notification 169 173 DiceNotifier *m_notifier; 170 174 171 175 /** 172 * this class reacts on the DICE device writing to the 176 * this class reacts on the DICE device writing to the 173 177 * hosts notify address 174 178 */ … … 180 184 DiceNotifier(DiceAvDevice *, nodeaddr_t start); 181 185 virtual ~DiceNotifier(); 182 186 183 187 private: 184 188 DiceAvDevice *m_dicedevice; trunk/libffado/src/dice/dice_defines.h
r436 r445 1 /* dice_defines.h 2 * Copyright (C) 2007 by Pieter Palmers 3 * 4 * This file is part of FreeBob. 5 * 6 * FreeBob is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBob is distributed in the hope that it will be useful, 1 /* 2 * Copyright (C) 2005-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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.14 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBob; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 23 20 24 #ifndef DICEDEFINES_H 21 25 #define DICEDEFINES_H … … 23 27 #define DICE_VER_1_0_4_0 24 28 // #define DICE_VER_1_0_7_0 25 26 29 27 30 #define DICE_INVALID_OFFSET 0xFFFFF00000000000ULL … … 138 141 // the format of the user messages 139 142 // however diceDriverInterface.h indicates: 140 // "When DD_NOTIFY_MESSAGE is set DD_NOTIFY_USER4 through 141 // DD_NOTIFY_USER11 are defined as an 8 bit message so 142 // you can have 256 seperate messages (like gray encoder 143 // "When DD_NOTIFY_MESSAGE is set DD_NOTIFY_USER4 through 144 // DD_NOTIFY_USER11 are defined as an 8 bit message so 145 // you can have 256 seperate messages (like gray encoder 143 146 // movements)." 144 147 … … 161 164 #define DICE_NOTIFY_USER_GET_MESSAGE(x) \ 162 165 ( ((x) >> 24 ) & 0xFF ) 163 166 164 167 // NICK_NAME register 165 168 trunk/libffado/src/fbtypes.h
r336 r445 1 1 /* fbtypes.h 2 * Copyright (C) 2005 by Daniel Wagner2 * Copyright (C) 2005-2007 by by Daniel Wagner 3 3 * 4 * This file is part of FreeBoB. 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 5 6 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 14 17 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 21 24 #ifndef FBTYPES_H 22 25 #define FBTYPES_H 23 26 24 27 #include <libraw1394/raw1394.h> 25 28 26 29 typedef quadlet_t fb_quadlet_t; 27 30 typedef byte_t fb_byte_t; … … 32 35 class DeviceManager; 33 36 34 struct f reebob_handle {37 struct ffado_handle { 35 38 DeviceManager* m_deviceManager; 36 39 }; trunk/libffado/src/ffado.cpp
r442 r445 1 /* freebob.cpp 2 * Copyright (C) 2005 Pieter Palmers, Daniel Wagner 1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 * Copyright (C) 2005-2007 by Pieter Palmers 3 4 * 4 * This file is part of FreeBoB 5 * This file is part of FFADO 6 * FFADO = Free Firewire (pro-)audio drivers for linux 7 * 8 * FFADO is based upon FreeBoB 5 9 * 6 10 * This library is free software; you can redistribute it and/or 7 11 * 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. 12 * License version 2.1, as published by the Free Software Foundation; 10 13 * 11 14 * This library is distributed in the hope that it will be useful, … … 22 25 #include "config.h" 23 26 24 #include "libf reebob/freebob.h"27 #include "libffado/ffado.h" 25 28 26 29 #include "debugmodule/debugmodule.h" … … 36 39 37 40 DECLARE_GLOBAL_DEBUG_MODULE; 38 IMPL_GLOBAL_DEBUG_MODULE( F reeBoB, DEBUG_LEVEL_VERBOSE );41 IMPL_GLOBAL_DEBUG_MODULE( FFADO, DEBUG_LEVEL_VERBOSE ); 39 42 40 43 #ifdef __cplusplus … … 42 45 #endif 43 46 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 // this is very much nescessary, as otherwise the 48 // message buffer thread doesn't get killed when the 49 // library is dlclose()'d 47 50 48 51 static void exitfunc(void) __attribute__((destructor)); … … 58 61 59 62 const char* 60 f reebob_get_version() {63 ffado_get_version() { 61 64 return PACKAGE_STRING; 62 65 } … … 64 67 65 68 int 66 f reebob_get_api_version() {67 return F REEBOB_API_VERSION;69 ffado_get_api_version() { 70 return FFADO_API_VERSION; 68 71 } 69 72 70 f reebob_handle_t71 f reebob_new_handle( int port )73 ffado_handle_t 74 ffado_new_handle( int port ) 72 75 { 73 f reebob_handle_t handle = new struct freebob_handle;76 ffado_handle_t handle = new struct ffado_handle; 74 77 if (! handle ) { 75 78 debugFatal( "Could not allocate memory for new handle\n" ); … … 93 96 94 97 int 95 f reebob_destroy_handle( freebob_handle_t freebob_handle )98 ffado_destroy_handle( ffado_handle_t ffado_handle ) 96 99 { 97 delete f reebob_handle->m_deviceManager;98 delete f reebob_handle;100 delete ffado_handle->m_deviceManager; 101 delete ffado_handle; 99 102 return 0; 100 103 } 101 104 102 105 int 103 f reebob_discover_devices( freebob_handle_t freebob_handle, int verbose )106 ffado_discover_devices( ffado_handle_t ffado_handle, int verbose ) 104 107 { 105 108 if (verbose) { 106 f reebob_handle->m_deviceManager->setVerboseLevel(DEBUG_LEVEL_VERBOSE);109 ffado_handle->m_deviceManager->setVerboseLevel(DEBUG_LEVEL_VERBOSE); 107 110 } 108 return f reebob_handle->m_deviceManager->discover()? 0 : -1;111 return ffado_handle->m_deviceManager->discover()? 0 : -1; 109 112 } 110 113 111 114 int 112 f reebob_node_is_valid_freebob_device( freebob_handle_t freebob_handle, int node_id )115 ffado_node_is_valid_ffado_device( ffado_handle_t ffado_handle, int node_id ) 113 116 { 114 return f reebob_handle->m_deviceManager->isValidNode( node_id );117 return ffado_handle->m_deviceManager->isValidNode( node_id ); 115 118 } 116 119 117 120 int 118 f reebob_get_nb_devices_on_bus( freebob_handle_t freebob_handle )121 ffado_get_nb_devices_on_bus( ffado_handle_t ffado_handle ) 119 122 { 120 return f reebob_handle->m_deviceManager->getNbDevices();123 return ffado_handle->m_deviceManager->getNbDevices(); 121 124 } 122 125 123 126 int 124 f reebob_get_device_node_id( freebob_handle_t freebob_handle, int device_nr )127 ffado_get_device_node_id( ffado_handle_t ffado_handle, int device_nr ) 125 128 { 126 return f reebob_handle->m_deviceManager->getDeviceNodeId(device_nr);129 return ffado_handle->m_deviceManager->getDeviceNodeId(device_nr); 127 130 } 128 131 129 132 int 130 f reebob_set_samplerate( freebob_handle_t freebob_handle, int node_id, int samplerate )133 ffado_set_samplerate( ffado_handle_t ffado_handle, int node_id, int samplerate ) 131 134 { 132 IAvDevice* avDevice = f reebob_handle->m_deviceManager->getAvDevice( node_id );135 IAvDevice* avDevice = ffado_handle->m_deviceManager->getAvDevice( node_id ); 133 136 if ( avDevice ) { 134 137 if ( avDevice->setSamplingFrequency( parseSampleRate( samplerate ) ) ) { 135 return f reebob_handle->m_deviceManager->discover()? 0 : -1;138 return ffado_handle->m_deviceManager->discover()? 0 : -1; 136 139 } 137 140 } … … 139 142 } 140 143 141 void f reebob_sleep_after_avc_command( int time )144 void ffado_sleep_after_avc_command( int time ) 142 145 { 143 146 AVCCommand::setSleepAfterAVCCommand( time ); trunk/libffado/src/ffado_streaming.cpp
r442 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 27 */ 28 29 /* freebob_streaming.c 30 * 31 * Implementation of the FreeBob Streaming API 32 * 33 */ 34 35 #include "libfreebob/freebob.h" 36 #include "libfreebob/freebob_streaming.h" 2 * Copyright (C) 2005-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 /* 25 * Implementation of the FFADO Streaming API 26 */ 27 28 #include "libffado/ffado.h" 37 29 #include "devicemanager.h" 38 30 #include "iavdevice.h" … … 53 45 using namespace Streaming; 54 46 55 struct _f reebob_device47 struct _ffado_device 56 48 { 57 49 DeviceManager * m_deviceManager; 58 50 StreamProcessorManager *processorManager; 59 51 60 f reebob_options_t options;61 f reebob_device_info_t device_info;62 }; 63 64 f reebob_device_t *freebob_streaming_init (freebob_device_info_t *device_info, freebob_options_t options) {52 ffado_options_t options; 53 ffado_device_info_t device_info; 54 }; 55 56 ffado_device_t *ffado_streaming_init (ffado_device_info_t *device_info, ffado_options_t options) { 65 57 unsigned int i=0; 66 58 67 struct _f reebob_device *dev = new struct _freebob_device;68 69 debugFatal("%s built %s %s\n", f reebob_get_version(), __DATE__, __TIME__);59 struct _ffado_device *dev = new struct _ffado_device; 60 61 debugFatal("%s built %s %s\n", ffado_get_version(), __DATE__, __TIME__); 70 62 71 63 if(!dev) { … … 83 75 return 0; 84 76 } 85 77 86 78 dev->m_deviceManager->setVerboseLevel(DEBUG_LEVEL_VERBOSE); 87 79 if ( !dev->m_deviceManager->initialize( dev->options.port ) ) { … … 93 85 94 86 // create a processor manager to manage the actual stream 95 // processors 87 // processors 96 88 dev->processorManager = new StreamProcessorManager(dev->options.period_size,dev->options.nb_buffers); 97 89 if(!dev->processorManager) { … … 101 93 return 0; 102 94 } 103 95 104 96 dev->processorManager->setThreadParameters(dev->options.realtime, dev->options.packetizer_priority); 105 97 106 98 dev->processorManager->setVerboseLevel(DEBUG_LEVEL_VERBOSE); 107 99 if(!dev->processorManager->init()) { … … 112 104 return 0; 113 105 } 114 106 115 107 // set slave mode option 116 108 bool slaveMode=(dev->options.slave_mode != 0); … … 125 117 debugWarning("Failed to set snoop mode option\n"); 126 118 } 127 119 128 120 // discover the devices on the bus 129 121 if(!dev->m_deviceManager->discover()) { … … 134 126 return 0; 135 127 } 136 128 137 129 // are there devices on the bus? 138 130 if(dev->m_deviceManager->getAvDeviceCount()==0) { … … 143 135 return 0; 144 136 } 145 137 146 138 // iterate over the found devices 147 139 // add the stream processors of the devices to the managers … … 151 143 152 144 debugOutput(DEBUG_LEVEL_VERBOSE, "Locking device (%p)\n", device); 153 145 154 146 if (!device->lock()) { 155 147 debugWarning("Could not lock device, skipping device (%p)!\n", device); 156 148 continue; 157 149 } 158 159 debugOutput(DEBUG_LEVEL_VERBOSE, "Setting samplerate to %d for (%p)\n", 150 151 debugOutput(DEBUG_LEVEL_VERBOSE, "Setting samplerate to %d for (%p)\n", 160 152 dev->options.sample_rate, device); 161 153 162 154 // Set the device's sampling rate to that requested 163 155 // FIXME: does this really belong here? If so we need to handle errors. 164 156 if (!device->setSamplingFrequency(parseSampleRate(dev->options.sample_rate))) { 165 debugOutput(DEBUG_LEVEL_VERBOSE, " => Retry setting samplerate to %d for (%p)\n", 157 debugOutput(DEBUG_LEVEL_VERBOSE, " => Retry setting samplerate to %d for (%p)\n", 166 158 dev->options.sample_rate, device); 167 159 168 160 // try again: 169 161 if (!device->setSamplingFrequency(parseSampleRate(dev->options.sample_rate))) { … … 188 180 } 189 181 } 190 182 191 183 // set the sync source 192 184 if (!dev->processorManager->setSyncSource(dev->m_deviceManager->getSyncSource())) { … … 201 193 } 202 194 203 int f reebob_streaming_prepare(freebob_device_t *dev) {195 int ffado_streaming_prepare(ffado_device_t *dev) { 204 196 debugOutput(DEBUG_LEVEL_VERBOSE, "Preparing...\n"); 205 197 206 198 if (!dev->processorManager->prepare()) { 207 199 debugFatal("Could not prepare streaming...\n"); … … 212 204 } 213 205 214 void f reebob_streaming_finish(freebob_device_t *dev) {206 void ffado_streaming_finish(ffado_device_t *dev) { 215 207 unsigned int i=0; 216 208 217 209 assert(dev); 218 210 219 211 // iterate over the found devices 220 212 for(i=0;i<dev->m_deviceManager->getAvDeviceCount();i++) { … … 228 220 } 229 221 } 230 222 231 223 delete dev->processorManager; 232 224 delete dev->m_deviceManager; … … 236 228 } 237 229 238 int f reebob_streaming_start(freebob_device_t *dev) {230 int ffado_streaming_start(ffado_device_t *dev) { 239 231 unsigned int i=0; 240 232 debugOutput(DEBUG_LEVEL_VERBOSE,"------------- Start -------------\n"); 241 233 242 234 // create the connections for all devices 243 235 // iterate over the found devices … … 246 238 IAvDevice *device=dev->m_deviceManager->getAvDeviceByIndex(i); 247 239 assert(device); 248 240 249 241 int j=0; 250 242 for(j=0; j<device->getStreamCount();j++) { … … 265 257 return 0; 266 258 } else { 267 f reebob_streaming_stop(dev);268 return -1; 269 } 270 } 271 272 int f reebob_streaming_stop(freebob_device_t *dev) {259 ffado_streaming_stop(dev); 260 return -1; 261 } 262 } 263 264 int ffado_streaming_stop(ffado_device_t *dev) { 273 265 unsigned int i; 274 266 debugOutput(DEBUG_LEVEL_VERBOSE,"------------- Stop -------------\n"); … … 286 278 debugWarning("Could not disable streaming on device %d!\n",i); 287 279 } 288 280 289 281 int j=0; 290 282 for(j=0; j<device->getStreamCount();j++) { … … 302 294 } 303 295 304 int f reebob_streaming_reset(freebob_device_t *dev) {296 int ffado_streaming_reset(ffado_device_t *dev) { 305 297 debugOutput(DEBUG_LEVEL_VERBOSE,"------------- Reset -------------\n"); 306 298 … … 310 302 } 311 303 312 int f reebob_streaming_wait(freebob_device_t *dev) {304 int ffado_streaming_wait(ffado_device_t *dev) { 313 305 static int periods=0; 314 306 static int periods_print=0; 315 307 static int xruns=0; 316 308 317 309 periods++; 318 310 if(periods>periods_print) { 319 debugOutputShort(DEBUG_LEVEL_VERBOSE, "\nf reebob_streaming_wait\n");311 debugOutputShort(DEBUG_LEVEL_VERBOSE, "\nffado_streaming_wait\n"); 320 312 debugOutputShort(DEBUG_LEVEL_VERBOSE, "============================================\n"); 321 313 debugOutputShort(DEBUG_LEVEL_VERBOSE, "Xruns: %d\n",xruns); … … 325 317 periods_print+=100; 326 318 } 327 319 328 320 if(dev->processorManager->waitForPeriod()) { 329 321 return dev->options.period_size; 330 322 } else { 331 323 debugWarning("XRUN detected\n"); 332 324 333 325 // do xrun recovery 334 326 dev->processorManager->handleXrun(); … … 338 330 } 339 331 340 int f reebob_streaming_transfer_capture_buffers(freebob_device_t *dev) {332 int ffado_streaming_transfer_capture_buffers(ffado_device_t *dev) { 341 333 return dev->processorManager->transfer(StreamProcessor::E_Receive); 342 334 } 343 335 344 int f reebob_streaming_transfer_playback_buffers(freebob_device_t *dev) {336 int ffado_streaming_transfer_playback_buffers(ffado_device_t *dev) { 345 337 return dev->processorManager->transfer(StreamProcessor::E_Transmit); 346 338 } 347 339 348 int f reebob_streaming_transfer_buffers(freebob_device_t *dev) {340 int ffado_streaming_transfer_buffers(ffado_device_t *dev) { 349 341 return dev->processorManager->transfer(); 350 342 } 351 343 352 344 353 int f reebob_streaming_write(freebob_device_t *dev, int i, freebob_sample_t *buffer, int nsamples) {345 int ffado_streaming_write(ffado_device_t *dev, int i, ffado_sample_t *buffer, int nsamples) { 354 346 Port *p=dev->processorManager->getPortByIndex(i, Port::E_Playback); 355 // use an assert here performancewise, 347 // use an assert here performancewise, 356 348 // it should already have failed before, if not correct 357 assert(p); 358 349 assert(p); 350 359 351 return p->writeEvents((void *)buffer, nsamples); 360 352 } 361 353 362 int f reebob_streaming_read(freebob_device_t *dev, int i, freebob_sample_t *buffer, int nsamples) {354 int ffado_streaming_read(ffado_device_t *dev, int i, ffado_sample_t *buffer, int nsamples) { 363 355 Port *p=dev->processorManager->getPortByIndex(i, Port::E_Capture); 364 // use an assert here performancewise, 356 // use an assert here performancewise, 365 357 // it should already have failed before, if not correct 366 assert(p); 367 358 assert(p); 359 368 360 return p->readEvents((void *)buffer, nsamples); 369 361 } 370 362 371 int f reebob_streaming_get_nb_capture_streams(freebob_device_t *dev) {363 int ffado_streaming_get_nb_capture_streams(ffado_device_t *dev) { 372 364 return dev->processorManager->getPortCount(Port::E_Capture); 373 365 } 374 366 375 int f reebob_streaming_get_nb_playback_streams(freebob_device_t *dev) {367 int ffado_streaming_get_nb_playback_streams(ffado_device_t *dev) { 376 368 return dev->processorManager->getPortCount(Port::E_Playback); 377 369 } 378 370 379 int f reebob_streaming_get_capture_stream_name(freebob_device_t *dev, int i, char* buffer, size_t buffersize) {371 int ffado_streaming_get_capture_stream_name(ffado_device_t *dev, int i, char* buffer, size_t buffersize) { 380 372 Port *p=dev->processorManager->getPortByIndex(i, Port::E_Capture); 381 373 if(!p) { … … 391 383 } 392 384 393 int f reebob_streaming_get_playback_stream_name(freebob_device_t *dev, int i, char* buffer, size_t buffersize) {385 int ffado_streaming_get_playback_stream_name(ffado_device_t *dev, int i, char* buffer, size_t buffersize) { 394 386 Port *p=dev->processorManager->getPortByIndex(i, Port::E_Playback); 395 387 if(!p) { … … 405 397 } 406 398 407 f reebob_streaming_stream_type freebob_streaming_get_capture_stream_type(freebob_device_t *dev, int i) {399 ffado_streaming_stream_type ffado_streaming_get_capture_stream_type(ffado_device_t *dev, int i) { 408 400 Port *p=dev->processorManager->getPortByIndex(i, Port::E_Capture); 409 401 if(!p) { 410 402 debugWarning("Could not get capture port at index %d\n",i); 411 return f reebob_stream_type_invalid;403 return ffado_stream_type_invalid; 412 404 } 413 405 switch(p->getPortType()) { 414 406 case Port::E_Audio: 415 return f reebob_stream_type_audio;407 return ffado_stream_type_audio; 416 408 case Port::E_Midi: 417 return f reebob_stream_type_midi;409 return ffado_stream_type_midi; 418 410 case Port::E_Control: 419 return f reebob_stream_type_control;411 return ffado_stream_type_control; 420 412 default: 421 return f reebob_stream_type_unknown;422 } 423 } 424 425 f reebob_streaming_stream_type freebob_streaming_get_playback_stream_type(freebob_device_t *dev, int i) {413 return ffado_stream_type_unknown; 414 } 415 } 416 417 ffado_streaming_stream_type ffado_streaming_get_playback_stream_type(ffado_device_t *dev, int i) { 426 418 Port *p=dev->processorManager->getPortByIndex(i, Port::E_Playback); 427 419 if(!p) { 428 420 debugWarning("Could not get playback port at index %d\n",i); 429 return f reebob_stream_type_invalid;421 return ffado_stream_type_invalid; 430 422 } 431 423 switch(p->getPortType()) { 432 424 case Port::E_Audio: 433 return f reebob_stream_type_audio;425 return ffado_stream_type_audio; 434 426 case Port::E_Midi: 435 return f reebob_stream_type_midi;427 return ffado_stream_type_midi; 436 428 case Port::E_Control: 437 return f reebob_stream_type_control;429 return ffado_stream_type_control; 438 430 default: 439 return f reebob_stream_type_unknown;440 } 441 } 442 443 int f reebob_streaming_set_stream_buffer_type(freebob_device_t *dev, int i,444 f reebob_streaming_buffer_type t, enum Port::E_Direction direction) {431 return ffado_stream_type_unknown; 432 } 433 } 434 435 int ffado_streaming_set_stream_buffer_type(ffado_device_t *dev, int i, 436 ffado_streaming_buffer_type t, enum Port::E_Direction direction) { 445 437 446 438 Port *p=dev->processorManager->getPortByIndex(i, direction); … … 450 442 return -1; 451 443 } 452 444 453 445 switch(t) { 454 case f reebob_buffer_type_int24:446 case ffado_buffer_type_int24: 455 447 if (!p->setDataType(Port::E_Int24)) { 456 448 debugWarning("%s: Could not set data type to Int24\n",p->getName().c_str()); … … 462 454 } 463 455 break; 464 case f reebob_buffer_type_float:456 case ffado_buffer_type_float: 465 457 if (!p->setDataType(Port::E_Float)) { 466 458 debugWarning("%s: Could not set data type to Float\n",p->getName().c_str()); … … 472 464 } 473 465 break; 474 case f reebob_buffer_type_midi:466 case ffado_buffer_type_midi: 475 467 if (!p->setDataType(Port::E_MidiEvent)) { 476 468 debugWarning("%s: Could not set data type to MidiEvent\n",p->getName().c_str()); … … 490 482 } 491 483 492 int f reebob_streaming_set_playback_buffer_type(freebob_device_t *dev, int i, freebob_streaming_buffer_type t) {493 return f reebob_streaming_set_stream_buffer_type(dev, i, t, Port::E_Playback);494 } 495 496 int f reebob_streaming_set_capture_buffer_type(freebob_device_t *dev, int i, freebob_streaming_buffer_type t) {497 return f reebob_streaming_set_stream_buffer_type(dev, i, t, Port::E_Capture);498 } 499 500 int f reebob_streaming_stream_onoff(freebob_device_t *dev, int i,484 int ffado_streaming_set_playback_buffer_type(ffado_device_t *dev, int i, ffado_streaming_buffer_type t) { 485 return ffado_streaming_set_stream_buffer_type(dev, i, t, Port::E_Playback); 486 } 487 488 int ffado_streaming_set_capture_buffer_type(ffado_device_t *dev, int i, ffado_streaming_buffer_type t) { 489 return ffado_streaming_set_stream_buffer_type(dev, i, t, Port::E_Capture); 490 } 491 492 int ffado_streaming_stream_onoff(ffado_device_t *dev, int i, 501 493 int on, enum Port::E_Direction direction) { 502 494 Port *p=dev->processorManager->getPortByIndex(i, direction); … … 514 506 } 515 507 516 int f reebob_streaming_playback_stream_onoff(freebob_device_t *dev, int number, int on) {517 return f reebob_streaming_stream_onoff(dev, number, on, Port::E_Playback);518 } 519 520 int f reebob_streaming_capture_stream_onoff(freebob_device_t *dev, int number, int on) {521 return f reebob_streaming_stream_onoff(dev, number, on, Port::E_Capture);508 int ffado_streaming_playback_stream_onoff(ffado_device_t *dev, int number, int on) { 509 return ffado_streaming_stream_onoff(dev, number, on, Port::E_Playback); 510 } 511 512 int ffado_streaming_capture_stream_onoff(ffado_device_t *dev, int number, int on) { 513 return ffado_streaming_stream_onoff(dev, number, on, Port::E_Capture); 522 514 } 523 515 524 516 // TODO: the way port buffers are set in the C api doesn't satisfy me 525 int f reebob_streaming_set_capture_stream_buffer(freebob_device_t *dev, int i, char *buff) {517 int ffado_streaming_set_capture_stream_buffer(ffado_device_t *dev, int i, char *buff) { 526 518 Port *p=dev->processorManager->getPortByIndex(i, Port::E_Capture); 527 528 // use an assert here performancewise, 519 520 // use an assert here performancewise, 529 521 // it should already have failed before, if not correct 530 assert(p); 531 522 assert(p); 523 532 524 p->useExternalBuffer(true); 533 525 p->setExternalBufferAddress((void *)buff); … … 537 529 } 538 530 539 int f reebob_streaming_set_playback_stream_buffer(freebob_device_t *dev, int i, char *buff) {531 int ffado_streaming_set_playback_stream_buffer(ffado_device_t *dev, int i, char *buff) { 540 532 Port *p=dev->processorManager->getPortByIndex(i, Port::E_Playback); 541 // use an assert here performancewise, 533 // use an assert here performancewise, 542 534 // it should already have failed before, if not correct 543 assert(p); 544 535 assert(p); 536 545 537 p->useExternalBuffer(true); 546 538 p->setExternalBufferAddress((void *)buff); trunk/libffado/src/iavdevice.cpp
r436 r445 1 /* iavdevice.h2 * Copyright (C) 200 6by Daniel Wagner3 * Copyright (C) 200 7 by Pieter Palmers1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 * Copyright (C) 2005-2007 by Pieter Palmers 4 4 * 5 * This file is part of FreeBoB. 5 * This file is part of FFADO 6 * FFADO = Free Firewire (pro-)audio drivers for linux 6 7 * 7 * FreeBoB is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * FreeBoB is distributed in the hope that it will be useful, 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, 12 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNUGeneral Public License for more details.16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * Lesser General Public License for more details. 15 18 * 16 * You should have received a copy of the GNU General Public License17 * along with FreeBoB; if not, write to the Free Software18 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,19 * MA 0211 1-1307 USA.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 20 23 */ 21 24 … … 40 43 { 41 44 addOption(Util::OptionContainer::Option("id",std::string("dev?"))); 42 45 43 46 std::ostringstream nodestr; 44 47 nodestr << "node" << nodeId; 45 48 setOscBase(nodestr.str()); 46 49 ConfigRom& c = getConfigRom(); 47 50 48 51 addChildOscNode(&c); 49 52 } … … 68 71 69 72 void 70 IAvDevice::setVerboseLevel(int l) 73 IAvDevice::setVerboseLevel(int l) 71 74 { 72 75 m_verboseLevel=l; trunk/libffado/src/iavdevice.h
r436 r445 1 /* iavdevice.h 2 * Copyright (C) 2006 by Daniel Wagner 3 * 4 * This file is part of FreeBoB. 5 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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, 11 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.14 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 23 */ 20 24 … … 35 39 @brief Base class for device support 36 40 37 This class should be subclassed to implement f reebob support41 This class should be subclassed to implement ffado support 38 42 for a specific device. 39 43 40 44 */ 41 class IAvDevice 45 class IAvDevice 42 46 : public Util::OptionContainer, 43 47 public OSC::OscNode 44 48 { 45 49 public: 46 IAvDevice( std::auto_ptr< ConfigRom >( configRom ),50 IAvDevice( std::auto_ptr< ConfigRom >( configRom ), 47 51 Ieee1394Service& ieee1394service, 48 52 int nodeId ); 49 50 virtual ~IAvDevice() {};51 52 /// Returns the ConfigRom object of the device node.53 ConfigRom& getConfigRom() const;54 55 /**56 * @brief This is called by the DeviceManager to discover & configure the device57 * 58 * @return true if the device was discovered successfuly59 */60 virtual bool discover() = 0;61 62 /**63 * @brief Set the samping frequency64 * @param samplingFrequency 65 * @return true if successful66 */67 virtual bool setSamplingFrequency( ESamplingFrequency samplingFrequency ) = 0;68 /**69 * @brief get the samplingfrequency as an integer70 * @return the sampling frequency as integer71 */72 virtual int getSamplingFrequency( ) = 0;73 53 54 virtual ~IAvDevice() {}; 55 56 /// Returns the ConfigRom object of the device node. 57 ConfigRom& getConfigRom() const; 58 59 /** 60 * @brief This is called by the DeviceManager to discover & configure the device 61 * 62 * @return true if the device was discovered successfuly 63 */ 64 virtual bool discover() = 0; 65 66 /** 67 * @brief Set the samping frequency 68 * @param samplingFrequency 69 * @return true if successful 70 */ 71 virtual bool setSamplingFrequency( ESamplingFrequency samplingFrequency ) = 0; 72 /** 73 * @brief get the samplingfrequency as an integer 74 * @return the sampling frequency as integer 75 */ 76 virtual int getSamplingFrequency( ) = 0; 77 74 78 /** 75 79 * @brief This is called by the device manager to give the device a unique ID. … … 87 91 * 88 92 * @note Currently this is a simple integer that is equal to 89 * the position of the device in the devicemanager's 93 * the position of the device in the devicemanager's 90 94 * device list. Therefore it is dependant on the order 91 95 * in which the devices are detected. The side-effect … … 93 97 * and history (e.g. busresets etc). This makes that 94 98 * these ID's are not fixed to a specific physical device. 95 * At some point, we will replaced this with a GUID based 99 * At some point, we will replaced this with a GUID based 96 100 * approach, which is tied to a physiscal device and is 97 * bus & time independant. 98 * 99 * @param id 101 * bus & time independant. 102 * 103 * @param id 100 104 * @return true if successful 101 105 */ 102 106 bool setId(unsigned int id); 103 104 /**105 * @brief Outputs the device configuration to stderr/stdout [debug helper]106 *107 * This function prints out a (detailed) description of the 108 * device detected, and its configuration.109 */110 virtual void showDevice() = 0;111 112 /** 113 * @brief Lock the device114 *115 * This is called by the streaming layer before we start manipulating116 * and/or using the device.117 *118 * It should implement the mechanisms provided by the device to 119 * make sure that no other controller claims control of the device.120 *121 * @return true if successful, false if not122 */123 virtual bool lock() = 0;124 125 /** 126 * @brief Unlock the device127 *128 * This is called by the streaming layer after we finish manipulating129 * and/or using the device.130 *131 * It should implement the mechanisms provided by the device to 132 * give up exclusive control of the device.133 *134 * @return true if successful, false if not135 */136 virtual bool unlock() = 0;137 138 /** 107 108 /** 109 * @brief Outputs the device configuration to stderr/stdout [debug helper] 110 * 111 * This function prints out a (detailed) description of the 112 * device detected, and its configuration. 113 */ 114 virtual void showDevice() = 0; 115 116 /** 117 * @brief Lock the device 118 * 119 * This is called by the streaming layer before we start manipulating 120 * and/or using the device. 121 * 122 * It should implement the mechanisms provided by the device to 123 * make sure that no other controller claims control of the device. 124 * 125 * @return true if successful, false if not 126 */ 127 virtual bool lock() = 0; 128 129 /** 130 * @brief Unlock the device 131 * 132 * This is called by the streaming layer after we finish manipulating 133 * and/or using the device. 134 * 135 * It should implement the mechanisms provided by the device to 136 * give up exclusive control of the device. 137 * 138 * @return true if successful, false if not 139 */ 140 virtual bool unlock() = 0; 141 142 /** 139 143 * @brief Enable streaming on all 'started' streams 140 144 * … … 146 150 */ 147 151 virtual bool enableStreaming(); 148 149 /** 152 153 /** 150 154 * @brief Disable streaming on all streams 151 155 * … … 158 162 virtual bool disableStreaming(); 159 163 160 /** 161 * @brief Prepare the device162 *163 * This is called by the streaming layer after the configuration 164 * parameters (e.g. sample rate) are set, and before 165 * getStreamProcessor[*] functions are called.166 *167 * It should be used to prepare the device's streamprocessors168 * based upon the device's current configuration. Normally169 * the streaming layer will not change the device's configuration170 * after calling this function.171 *172 * @return true if successful, false if not173 */174 virtual bool prepare() = 0;175 176 /**177 * @brief Returns the number of ISO streams implemented/used by this device178 *179 * Most likely this is 2 streams, i.e. one transmit stream and one180 * receive stream. However there are devices that implement more, for 181 * example BeBoB's implement 4 streams: 182 * - 2 audio streams (1 xmit/1 recv)183 * - 2 sync streams (1 xmit/1 recv), which are an optional sync source184 * for the device.185 *186 * @note you have to have a StreamProcessor for every stream. I.e.187 * getStreamProcessorByIndex(i) should return a valid StreamProcessor188 * for i=0 to i=getStreamCount()-1189 *190 * @return number of streams available (both transmit and receive)191 */192 virtual int getStreamCount() = 0;193 194 /** 195 * @brief Returns the StreamProcessor object for the stream with index i196 *197 * @note a streamprocessor returned by getStreamProcessorByIndex(i)198 * cannot be the same object as one returned by199 * getStreamProcessorByIndex(j) if i isn't equal to j200 * @note you cannot have two streamprocessors handling the same ISO201 * channel (on the same port)202 *203 * @param i : Stream index204 * @pre @ref i smaller than getStreamCount()205 * @return a StreamProcessor object if successful, NULL otherwise206 */207 virtual Streaming::StreamProcessor *getStreamProcessorByIndex(int i) = 0;208 209 /** 210 * @brief starts the stream with index i211 *212 * This function is called by the streaming layer when this stream should213 * be started, i.e. the device should start sending data or should be prepared to 214 * be ready to receive data.215 *216 * It returns the channel number that was assigned for this stream.217 * Channel allocation should be done using the allocation functions provided by the218 * Ieee1394Service object that is passed in the constructor.219 *220 * @param i : Stream index221 * @pre @ref i smaller than getStreamCount()222 * @return true if successful, false if not223 */224 virtual bool startStreamByIndex(int i) = 0;225 226 /** 227 * @brief stops the stream with index @ref i228 *229 * @param i : Stream index230 * @pre @ref i smaller than getStreamCount()231 * @return true if successful, false if not232 */233 virtual bool stopStreamByIndex(int i) = 0;164 /** 165 * @brief Prepare the device 166 * 167 * This is called by the streaming layer after the configuration 168 * parameters (e.g. sample rate) are set, and before 169 * getStreamProcessor[*] functions are called. 170 * 171 * It should be used to prepare the device's streamprocessors 172 * based upon the device's current configuration. Normally 173 * the streaming layer will not change the device's configuration 174 * after calling this function. 175 * 176 * @return true if successful, false if not 177 */ 178 virtual bool prepare() = 0; 179 180 /** 181 * @brief Returns the number of ISO streams implemented/used by this device 182 * 183 * Most likely this is 2 streams, i.e. one transmit stream and one 184 * receive stream. However there are devices that implement more, for 185 * example BeBoB's implement 4 streams: 186 * - 2 audio streams (1 xmit/1 recv) 187 * - 2 sync streams (1 xmit/1 recv), which are an optional sync source 188 * for the device. 189 * 190 * @note you have to have a StreamProcessor for every stream. I.e. 191 * getStreamProcessorByIndex(i) should return a valid StreamProcessor 192 * for i=0 to i=getStreamCount()-1 193 * 194 * @return number of streams available (both transmit and receive) 195 */ 196 virtual int getStreamCount() = 0; 197 198 /** 199 * @brief Returns the StreamProcessor object for the stream with index i 200 * 201 * @note a streamprocessor returned by getStreamProcessorByIndex(i) 202 * cannot be the same object as one returned by 203 * getStreamProcessorByIndex(j) if i isn't equal to j 204 * @note you cannot have two streamprocessors handling the same ISO 205 * channel (on the same port) 206 * 207 * @param i : Stream index 208 * @pre @ref i smaller than getStreamCount() 209 * @return a StreamProcessor object if successful, NULL otherwise 210 */ 211 virtual Streaming::StreamProcessor *getStreamProcessorByIndex(int i) = 0; 212 213 /** 214 * @brief starts the stream with index i 215 * 216 * This function is called by the streaming layer when this stream should 217 * be started, i.e. the device should start sending data or should be prepared to 218 * be ready to receive data. 219 * 220 * It returns the channel number that was assigned for this stream. 221 * Channel allocation should be done using the allocation functions provided by the 222 * Ieee1394Service object that is passed in the constructor. 223 * 224 * @param i : Stream index 225 * @pre @ref i smaller than getStreamCount() 226 * @return true if successful, false if not 227 */ 228 virtual bool startStreamByIndex(int i) = 0; 229 230 /** 231 * @brief stops the stream with index @ref i 232 * 233 * @param i : Stream index 234 * @pre @ref i smaller than getStreamCount() 235 * @return true if successful, false if not 236 */ 237 virtual bool stopStreamByIndex(int i) = 0; 234 238 235 239 /** trunk/libffado/src/libavc/avc_connect.cpp
r413 r445 1 /* avc_connect.cpp2 * Copyright (C) 2005 by Daniel Wagner1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 3 * 4 * This file is part of FreeBoB. 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 5 6 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 14 17 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 trunk/libffado/src/libavc/avc_connect.h
r375 r445 1 /* avc_connect.h2 * Copyright (C) 2005 by Daniel Wagner1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 3 * 4 * This file is part of FreeBoB. 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 5 6 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 14 17 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 21 #ifndef AVCC onnect_h22 #define AVCC onnect_h24 #ifndef AVCCONNECT_H 25 #define AVCCONNECT_H 23 26 24 27 #include "avc_generic.h" … … 36 39 37 40 virtual const char* getCmdName() const 38 { return "ConnectCmd"; }41 { return "ConnectCmd"; } 39 42 }; 40 43 41 44 42 #endif // AVCC onnect_h45 #endif // AVCCONNECT_H trunk/libffado/src/libavc/avc_definitions.cpp
r415 r445 1 /* avc_defintions.cpp2 * Copyright (C) 2005 by Daniel Wagner1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 3 * 4 * This file is part of FreeBoB. 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 5 6 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 14 17 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 trunk/libffado/src/libavc/avc_definitions.h
r415 r445 1 /* avc_definitions.h2 * Copyright (C) 2005 by Daniel Wagner1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 3 * 4 * This file is part of FreeBoB. 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 5 6 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 14 17 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 21 #ifndef AV CDefinitions_h22 #define AV CDefinitions_h24 #ifndef AVDDEFINITIONS_H 25 #define AVDDEFINITIONS_H 23 26 24 27 #include <libavc1394/avc1394.h> … … 70 73 typedef byte_t control_selector_t; 71 74 typedef byte_t control_data_length_t; 75 typedef uint16_t control_data_ext_length_t; 76 typedef uint16_t mixer_level_t; 77 typedef byte_t mixer_programmable_state_t; 72 78 typedef byte_t input_fb_plug_number_t; 73 79 typedef byte_t input_audio_channel_number_t; … … 99 105 /** 100 106 * \brief Convert from ESamplingFrequency to an integer 101 * @param freq 102 * @return 107 * @param freq 108 * @return 103 109 */ 104 110 int convertESamplingFrequency(ESamplingFrequency freq); 105 111 /** 106 112 * \brief Convert from integer to ESamplingFrequency 107 * @param sampleRate 108 * @return 113 * @param sampleRate 114 * @return 109 115 */ 110 116 ESamplingFrequency parseSampleRate( int sampleRate ); … … 123 129 #define AVC1394_SUBUNIT_ID_RESERVED 0x06 124 130 125 #endif // AV CDefinitions_h131 #endif // AVDDEFINITIONS_H trunk/libffado/src/libavc/avc_extended_cmd_generic.cpp
r413 r445 1 /* avc_extended_cmd_generic.cpp2 * Copyright (C) 2005 by Daniel Wagner1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 3 * 4 * This file is part of FreeBoB. 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 5 6 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 14 17 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 … … 461 464 462 465 PlugAddressSpecificData::PlugAddressSpecificData( EPlugDirection plugDirection, 463 EPlugAddressMode plugAddressMode,464 UnitPlugSpecificDataPlugAddress& unitPlugAddress )466 EPlugAddressMode plugAddressMode, 467 UnitPlugSpecificDataPlugAddress& unitPlugAddress ) 465 468 : m_plugDirection( plugDirection ) 466 469 , m_addressMode( plugAddressMode ) … … 470 473 471 474 PlugAddressSpecificData::PlugAddressSpecificData( EPlugDirection plugDirection, 472 EPlugAddressMode plugAddressMode,473 SubunitPlugSpecificDataPlugAddress& subUnitPlugAddress )475 EPlugAddressMode plugAddressMode, 476 SubunitPlugSpecificDataPlugAddress& subUnitPlugAddress ) 474 477 : m_plugDirection( plugDirection ) 475 478 , m_addressMode( plugAddressMode ) … … 479 482 480 483 PlugAddressSpecificData::PlugAddressSpecificData( EPlugDirection plugDirection, 481 EPlugAddressMode plugAddressMode,482 FunctionBlockPlugSpecificDataPlugAddress& functionBlockPlugAddress )484 EPlugAddressMode plugAddressMode, 485 FunctionBlockPlugSpecificDataPlugAddress& functionBlockPlugAddress ) 483 486 : m_plugDirection( plugDirection ) 484 487 , m_addressMode( plugAddressMode ) trunk/libffado/src/libavc/avc_extended_cmd_generic.h
r336 r445 1 /* avc_extended_cmd_generic.h 2 * Copyright (C) 2005 by Daniel Wagner 3 * 4 * This file is part of FreeBoB. 5 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.14 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 … … 38 41 ePT_ExternalPlug = 0x01, 39 42 ePT_AsynchronousPlug = 0x02, 40 ePT_Unknown = 0xff,43 ePT_Unknown = 0xff, 41 44 }; 42 45 … … 205 208 ePD_Input = 0x00, 206 209 ePD_Output = 0x01, 207 ePD_Undefined = 0xff,210 ePD_Undefined = 0xff, 208 211 }; 209 212 … … 212 215 ePAM_Subunit = 0x01, 213 216 ePAM_FunctionBlock = 0x02, 214 ePAM_Undefined = 0xff,217 ePAM_Undefined = 0xff, 215 218 }; 216 219 … … 259 262 260 263 PlugAddressSpecificData( EPlugDirection plugDirection, 261 EPlugAddressMode plugAddressMode,262 UnitPlugSpecificDataPlugAddress& unitPlugAddress );263 PlugAddressSpecificData( EPlugDirection plugDirection, 264 EPlugAddressMode plugAddressMode,265 SubunitPlugSpecificDataPlugAddress& subUnitPlugAddress );266 PlugAddressSpecificData( EPlugDirection plugDirection, 267 EPlugAddressMode plugAddressMode,268 FunctionBlockPlugSpecificDataPlugAddress& functionBlockPlugAddress );269 PlugAddressSpecificData( EPlugDirection plugDirection, 270 EPlugAddressMode plugAddressMode );264 EPlugAddressMode plugAddressMode, 265 UnitPlugSpecificDataPlugAddress& unitPlugAddress ); 266 PlugAddressSpecificData( EPlugDirection plugDirection, 267 EPlugAddressMode plugAddressMode, 268 SubunitPlugSpecificDataPlugAddress& subUnitPlugAddress ); 269 PlugAddressSpecificData( EPlugDirection plugDirection, 270 EPlugAddressMode plugAddressMode, 271 FunctionBlockPlugSpecificDataPlugAddress& functionBlockPlugAddress ); 272 PlugAddressSpecificData( EPlugDirection plugDirection, 273 EPlugAddressMode plugAddressMode ); 271 274 PlugAddressSpecificData( const PlugAddressSpecificData& pa ); 272 275 trunk/libffado/src/libavc/avc_extended_plug_info.cpp
r413 r445 1 /* avc_extended_plug_info.cpp2 * Copyright (C) 2005 by Daniel Wagner1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 3 * 4 * This file is part of FreeBoB. 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 5 6 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 14 17 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 trunk/libffado/src/libavc/avc_extended_plug_info.h
r375 r445 1 /* avc_extended_plug_info.h 2 * Copyright (C) 2005 by Daniel Wagner 3 * 4 * This file is part of FreeBoB. 5 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.14 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 … … 285 288 public: 286 289 enum ESubFunction { 287 eSF_ExtendedPlugInfoCmd = AVC1394_PLUG_INFO_SUBFUNCTION_EXTENDED_PLUG_INFO_CMD,290 eSF_ExtendedPlugInfoCmd = AVC1394_PLUG_INFO_SUBFUNCTION_EXTENDED_PLUG_INFO_CMD, 288 291 eSF_NotUsed = AVC1394_PLUG_INFO_SUBFUNCTION_SERIAL_BUS_NOT_USED, 289 292 }; … … 301 304 bool setInfoType( const ExtendedPlugInfoInfoType& infoType ); 302 305 ExtendedPlugInfoInfoType* getInfoType() 303 { return m_infoType; }306 { return m_infoType; } 304 307 305 308 virtual const char* getCmdName() const 306 { return "ExtendedPlugInfoCmd"; }309 { return "ExtendedPlugInfoCmd"; } 307 310 308 311 protected: trunk/libffado/src/libavc/avc_extended_stream_format.cpp
r413 r445 1 /* avc_extended_stream_format.cpp 2 * Copyright (C) 2005 by Daniel Wagner 3 * 4 * This file is part of FreeBoB. 5 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.14 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 … … 38 41 << ", midi channels: " << info.m_midiChannels << ")"; 39 42 */ 40 stream << " NbChannels " << (int)info.m_numberOfChannels << ", Format " << (int)info.m_streamFormat;43 stream << " NbChannels " << (int)info.m_numberOfChannels << ", Format " << (int)info.m_streamFormat; 41 44 return stream; 42 45 } … … 120 123 { 121 124 stream << (int)info.m_samplingFrequency << " Hz (rate control: "; 122 stream << (int)info.m_rateControl << ")" << std::endl;123 124 for ( FormatInformationStreamsCompound::StreamFormatInfoVector::iterator it = info.m_streamFormatInfos.begin();125 it != info.m_streamFormatInfos.end();126 ++it )127 {128 StreamFormatInfo* sfi=*it;129 stream << " > " << *sfi << std::endl;130 }125 stream << (int)info.m_rateControl << ")" << std::endl; 126 127 for ( FormatInformationStreamsCompound::StreamFormatInfoVector::iterator it = info.m_streamFormatInfos.begin(); 128 it != info.m_streamFormatInfos.end(); 129 ++it ) 130 { 131 StreamFormatInfo* sfi=*it; 132 stream << " > " << *sfi << std::endl; 133 } 131 134 132 135 return stream; trunk/libffado/src/libavc/avc_extended_stream_format.h
r375 r445 1 /* avc_extended_stream_format.h 2 * Copyright (C) 2005 by Daniel Wagner 3 * 4 * This file is part of FreeBoB. 5 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.14 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 21 #ifndef AVCE xtendedStreamFormat_h22 #define AVCE xtendedStreamFormat_h24 #ifndef AVCEXTENDEDSTREAMFROMAT_H 25 #define AVCEXTENDEDSTREAMFROMAT_H 23 26 24 27 #include "avc_generic.h" … … 274 277 275 278 virtual const char* getCmdName() const 276 { return "ExtendedStreamFormatCmd"; }279 { return "ExtendedStreamFormatCmd"; } 277 280 278 281 protected: … … 284 287 }; 285 288 286 #endif // AVCE xtendedStreamFormat_h289 #endif // AVCEXTENDEDSTREAMFROMAT_H trunk/libffado/src/libavc/avc_extended_subunit_info.cpp
r413 r445 1 /* avc_extended_subunit_info.cpp2 * Copyright (C) 200 6by Daniel Wagner1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 3 * 4 * This file is part of FreeBoB. 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 5 6 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 14 17 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 trunk/libffado/src/libavc/avc_extended_subunit_info.h
r378 r445 1 /* avc_extended_subunit_info.h2 * Copyright (C) 200 6by Daniel Wagner1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 3 * 4 * This file is part of FreeBoB. 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 5 6 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 14 17 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 … … 66 69 67 70 enum EProcessingType { 68 ePT_Unknown = 0x00,71 ePT_Unknown = 0x00, 69 72 ePT_Mixer = 0x01, 70 73 ePT_Generic = 0x02, … … 95 98 96 99 virtual const char* getCmdName() const 97 { return "ExtendedSubunitInfoCmd"; }100 { return "ExtendedSubunitInfoCmd"; } 98 101 99 102 page_t m_page; trunk/libffado/src/libavc/avc_function_block.cpp
r413 r445 1 /* avc_function_block.cpp2 * Copyright (C) 200 6by Daniel Wagner1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 3 * 4 * This file is part of FreeBoB. 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 5 6 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 14 17 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 … … 144 147 FunctionBlockProcessingEnhancedMixer::serialize( IOSSerialize& se ) 145 148 { 146 bool bStatus; 149 int todo,done; 150 bool bStatus; 151 byte_t data_length_hi, data_length_lo; 152 147 153 bStatus = se.write( m_controlSelector, "FunctionBlockProcessingEnhancedMixer controlSelector" ); 148 154 bStatus &= se.write( m_statusSelector, "FunctionBlockProcessingEnhancedMixer statusSelector" ); 149 155 156 switch (m_statusSelector) { 157 case eSS_ProgramableState: 158 m_controlDataLength=m_LevelData.size(); 159 data_length_hi=(m_controlDataLength >> 8); 160 data_length_lo=(m_controlDataLength & 0xFF); 161 bStatus &= se.write( data_length_hi, "FunctionBlockProcessingEnhancedMixer controlDataLengthHi" ); 162 bStatus &= se.write( data_length_lo, "FunctionBlockProcessingEnhancedMixer controlDataLengthLo" ); 163 164 for (int i=0;i<m_controlDataLength/8;i++) { 165 byte_t value=0; 166 167 for (int j=0;j<8;j++) { 168 control_data_ext_length_t bit_value=m_ProgramableStateData.at(i*8+j); 169 value |= bit_value << (7-j); 170 } 171 172 bStatus &= se.write( value, "FunctionBlockProcessingEnhancedMixer data" ); 173 } 174 175 todo=m_controlDataLength%8; 176 done=m_controlDataLength-todo; 177 if (todo) { 178 byte_t value=0; 179 for (int j=0;j<todo;j++) { 180 control_data_ext_length_t bit_value=m_ProgramableStateData.at(done*8+j); 181 value |= bit_value << (7-j); 182 } 183 bStatus &= se.write( value, "FunctionBlockProcessingEnhancedMixer data" ); 184 } 185 break; 186 case eSS_Level: 187 m_controlDataLength=m_LevelData.size()/2; 188 data_length_hi=(m_controlDataLength >> 8); 189 data_length_lo=(m_controlDataLength & 0xFF); 190 bStatus &= se.write( data_length_hi, "FunctionBlockProcessingEnhancedMixer controlDataLengthHi" ); 191 bStatus &= se.write( data_length_lo, "FunctionBlockProcessingEnhancedMixer controlDataLengthLo" ); 192 193 for (int i=0;i<m_controlDataLength/2;i++) { 194 mixer_level_t value=m_LevelData.at(i); 195 byte_t value_hi=value >> 8; 196 byte_t value_lo=value & 0xFF; 197 198 bStatus &= se.write( value_hi, "FunctionBlockProcessingEnhancedMixer data" ); 199 bStatus &= se.write( value_lo, "FunctionBlockProcessingEnhancedMixer data" ); 200 } 201 break; 202 } 150 203 return bStatus; 151 204 } … … 154 207 FunctionBlockProcessingEnhancedMixer::deserialize( IISDeserialize& de ) 155 208 { 156 bool bStatus; 209 int todo; 210 bool bStatus=true; 157 211 bStatus = de.read( &m_controlSelector ); 212 213 // NOTE: the returned value is currently bogus, so overwrite it 214 m_controlSelector=FunctionBlockProcessing::eCSE_Processing_EnhancedMixer; 215 158 216 bStatus &= de.read( &m_statusSelector ); 217 218 byte_t data_length_hi; 219 byte_t data_length_lo; 220 bStatus &= de.read( &data_length_hi ); 221 bStatus &= de.read( &data_length_lo ); 222 223 m_controlDataLength = (data_length_hi << 8) + data_length_lo; 224 switch (m_statusSelector) { 225 case eSS_ProgramableState: 226 m_ProgramableStateData.clear(); 227 for (int i=0;i<m_controlDataLength/8;i++) { 228 byte_t value; 229 bStatus &= de.read( &value); 230 231 for (int j=7;j>=0;j--) { 232 byte_t bit_value; 233 bit_value=(((1<<j) & value) ? 1 : 0); 234 m_ProgramableStateData.push_back(bit_value); 235 } 236 } 237 238 todo=m_controlDataLength%8; 239 if (todo) { 240 byte_t value; 241 bStatus &= de.read( &value); 242 243 for (int j=7;j>7-todo;j--) { 244 byte_t bit_value; 245 bit_value=(((1<<j) & value) ? 1 : 0); 246 m_ProgramableStateData.push_back(bit_value); 247 } 248 } 249 break; 250 case eSS_Level: 251 m_LevelData.clear(); 252 for (int i=0;i<m_controlDataLength/2;i++) { 253 byte_t mixer_value_hi=0, mixer_value_lo=0; 254 bStatus &= de.read( &mixer_value_hi); 255 bStatus &= de.read( &mixer_value_lo); 256 mixer_level_t value = (mixer_value_hi << 8) + mixer_value_lo; 257 m_LevelData.push_back(value); 258 } 259 break; 260 } 159 261 160 262 return bStatus; … … 358 460 FunctionBlockProcessing::deserialize( IISDeserialize& de ) 359 461 { 462 // NOTE: apparently the fbCmd of the STATUS type, 463 // with EnhancedMixer controlSelector returns with this 464 // controlSelector type changed to Mixer, making it 465 // impossible to choose the correct response handler 466 // based upon the response only. 467 468 // HACK: we assume that it is the same as the sent one 469 // we also look at our data structure to figure out what we sent 470 byte_t controlSelector=eCSE_Processing_Unknown; 471 if(m_pMixer) { 472 controlSelector=eCSE_Processing_Mixer; 473 } else if(m_pEnhancedMixer) { 474 controlSelector=eCSE_Processing_EnhancedMixer; 475 } 476 360 477 bool bStatus; 361 478 bStatus = de.read( &m_selectorLength ); … … 364 481 bStatus &= de.read( &m_outputAudioChannelNumber ); 365 482 366 byte_t controlSelector; 367 bStatus &= de.peek( &controlSelector ); 483 byte_t controlSelector_response; 484 bStatus &= de.peek( &controlSelector_response ); 485 /* debugOutput(DEBUG_LEVEL_VERBOSE,"ctrlsel: orig = %02X, resp = %02X\n", 486 controlSelector, controlSelector_response);*/ 487 368 488 switch( controlSelector ) { 369 489 case eCSE_Processing_Mixer: … … 385 505 } 386 506 507 byte_t tmp; 508 if (de.peek(&tmp)) { 509 debugOutput(DEBUG_LEVEL_VERBOSE,"Unprocessed bytes:\n"); 510 while (de.read(&tmp)) { 511 debugOutput(DEBUG_LEVEL_VERBOSE," %02X\n",tmp); 512 } 513 } 514 387 515 return bStatus; 388 516 } trunk/libffado/src/libavc/avc_function_block.h
r379 r445 1 /* avc_function_block.h 2 * Copyright (C) 2006,07 by Daniel Wagner 3 * 4 * This file is part of FreeBoB. 5 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.14 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 … … 26 29 27 30 #include <libavc1394/avc1394.h> 31 #include <vector> 32 using namespace std; 28 33 29 34 class FunctionBlockFeatureVolume: public IBusData … … 78 83 virtual FunctionBlockProcessingEnhancedMixer* clone() const; 79 84 80 control_selector_t m_controlSelector; 81 status_selector_t m_statusSelector; 85 control_selector_t m_controlSelector; 86 status_selector_t m_statusSelector; 87 control_data_ext_length_t m_controlDataLength; 88 vector<mixer_programmable_state_t> m_ProgramableStateData; 89 vector<mixer_level_t> m_LevelData; 82 90 }; 83 91 trunk/libffado/src/libavc/avc_generic.cpp
r413 r445 1 /* avc_generic.cpp 2 * Copyright (C) 2005 by Daniel Wagner 3 * 4 * This file is part of FreeBoB. 5 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.14 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 … … 30 33 31 34 IMPL_DEBUG_MODULE( AVCCommand, AVCCommand, DEBUG_LEVEL_NORMAL ); 35 IMPL_DEBUG_MODULE( IBusData, IBusData, DEBUG_LEVEL_VERBOSE ); 32 36 33 37 int AVCCommand::m_time = 0; … … 227 231 } 228 232 } else { 229 debugWarning( "no response\n" );233 debugWarning( "no response\n" ); 230 234 } 231 235 trunk/libffado/src/libavc/avc_generic.h
r375 r445 1 /* avc_generic.h2 * Copyright (C) 2005 by Daniel Wagner1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 3 * 4 * This file is part of FreeBoB. 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 5 6 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 14 17 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 21 #ifndef AVCG eneric_h22 #define AVCG eneric_h24 #ifndef AVCGENERIC_H 25 #define AVCGENERIC_H 23 26 24 27 #include "avc_definitions.h" … … 45 48 46 49 virtual IBusData* clone() const = 0; 50 51 protected: 52 DECLARE_DEBUG_MODULE; 47 53 }; 48 54 … … 106 112 bool setVerbose( int verboseLevel ); 107 113 int getVerboseLevel(); 108 114 109 115 virtual const char* getCmdName() const = 0; 110 116 … … 113 119 protected: 114 120 void showFcpFrame( const unsigned char* buf, 115 unsigned short frameSize ) const;121 unsigned short frameSize ) const; 116 122 117 123 protected: … … 133 139 ECommandType m_commandType; 134 140 static int m_time; 135 141 136 142 DECLARE_DEBUG_MODULE; 137 143 }; … … 141 147 const char* responseToString( AVCCommand::EResponse eResponse ); 142 148 143 #endif // AVCG eneric_h149 #endif // AVCGENERIC_H trunk/libffado/src/libavc/avc_plug_info.cpp
r413 r445 1 /* avc_plug_info.cpp2 * Copyright (C) 2005 by Daniel Wagner1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 3 * 4 * This file is part of FreeBoB. 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 5 6 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 14 17 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 trunk/libffado/src/libavc/avc_plug_info.h
r375 r445 1 /* avc_plug_info.h2 * Copyright (C) 2005 by Daniel Wagner1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 3 * 4 * This file is part of FreeBoB. 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 5 6 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 14 17 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 21 #ifndef AVCP lugInfo_h22 #define AVCP lugInfo_h24 #ifndef AVCPLUGINFO_H 25 #define AVCPLUGINFO_H 23 26 24 27 #include "avc_generic.h" … … 43 46 44 47 PlugInfoCmd( Ieee1394Service& ieee1394service, 45 ESubFunction eSubFunction = eSF_SerialBusIsochronousAndExternalPlug );48 ESubFunction eSubFunction = eSF_SerialBusIsochronousAndExternalPlug ); 46 49 PlugInfoCmd( const PlugInfoCmd& rhs ); 47 50 virtual ~PlugInfoCmd(); … … 51 54 52 55 virtual const char* getCmdName() const 53 { return "PlugInfoCmd"; }56 { return "PlugInfoCmd"; } 54 57 55 58 nr_of_plugs_t m_serialBusIsochronousInputPlugs; … … 70 73 71 74 72 #endif // AVCP lugInfo_h75 #endif // AVCPLUGINFO_H trunk/libffado/src/libavc/avc_serialize.cpp
r365 r445 1 /* avc_serialize.cpp2 * Copyright (C) 2005 ,07 by Daniel Wagner1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 3 * 4 * This file is part of FreeBoB. 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 5 6 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 14 17 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 … … 26 29 #include <netinet/in.h> 27 30 31 IMPL_DEBUG_MODULE( CoutSerializer, CoutSerializer, DEBUG_LEVEL_NORMAL ); 32 28 33 bool 29 34 CoutSerializer::write( byte_t d, const char* name ) 30 35 { 31 printf(" %3d:\t0x%02x\t%s\n", m_cnt, d, name );36 debugOutput( DEBUG_LEVEL_NORMAL, " %3d:\t0x%02x\t%s\n", m_cnt, d, name ); 32 37 m_cnt += sizeof( byte_t ); 33 38 … … 38 43 CoutSerializer::write( quadlet_t d, const char* name ) 39 44 { 40 printf(" %3d:\t0x%08x\t%s\n", m_cnt, d, name );45 debugOutput( DEBUG_LEVEL_NORMAL, " %3d:\t0x%08x\t%s\n", m_cnt, d, name ); 41 46 m_cnt += sizeof( quadlet_t ); 42 47 return true; trunk/libffado/src/libavc/avc_serialize.h
r365 r445 1 /* avc_serialize.h2 * Copyright (C) 2005 ,07 by Daniel Wagner1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 3 * 4 * This file is part of FreeBoB. 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 5 6 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 14 17 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 21 #ifndef Serialize_h 22 #define Serialize_h 24 #ifndef SERIALIZE_H 25 #define SERIALIZE_H 26 27 #include "debugmodule/debugmodule.h" 23 28 24 29 #include <libraw1394/raw1394.h> // byte_t and quadlet_t declaration … … 62 67 private: 63 68 unsigned int m_cnt; 69 DECLARE_DEBUG_MODULE; 64 70 65 71 }; … … 97 103 98 104 int getNrOfProducesBytes() const 99 { return m_curPos - m_buffer; }105 { return m_curPos - m_buffer; } 100 106 101 107 protected: … … 135 141 }; 136 142 137 #endif // S erialize_h143 #endif // SERIALIZE_H 138 144 trunk/libffado/src/libavc/avc_signal_source.cpp
r413 r445 1 /* avc_signal_source.cpp 2 * Copyright (C) 2005 by Daniel Wagner 3 * 4 * This file is part of FreeBoB. 5 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.14 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 trunk/libffado/src/libavc/avc_signal_source.h
r375 r445 1 /* avc_signal_source.h2 * Copyright (C) 2005 by Daniel Wagner1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 3 * 4 * This file is part of FreeBoB. 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 5 6 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 14 17 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 21 #ifndef AVCS ignalSource_h22 #define AVCS ignalSource_h24 #ifndef AVCSIGNALSOURCE_H 25 #define AVCSIGNALSOURCE_H 23 26 24 27 #include "avc_generic.h" … … 73 76 74 77 virtual const char* getCmdName() const 75 { return "SignalSourceCmd"; }78 { return "SignalSourceCmd"; } 76 79 77 80 bool setSignalSource( SignalUnitAddress& signalAddress ); … … 96 99 97 100 98 #endif // AVCS ignalSource_h101 #endif // AVCSIGNALSOURCE_H trunk/libffado/src/libavc/avc_subunit_info.cpp
r413 r445 1 /* avc_subunit_info.cpp2 * Copyright (C) 2005 by Daniel Wagner1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 3 * 4 * This file is part of FreeBoB. 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 5 6 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 14 17 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 trunk/libffado/src/libavc/avc_subunit_info.h
r375 r445 1 /* avc_subunit_info.h2 * Copyright (C) 2005 by Daniel Wagner1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 3 * 4 * This file is part of FreeBoB. 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 5 6 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 14 17 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 21 #ifndef AVCS ubUnitInfo_h22 #define AVCS ubUnitInfo_h24 #ifndef AVCSUBUNITINFO_H 25 #define AVCSUBUNITINFO_H 23 26 24 27 #include "avc_generic.h" … … 39 42 40 43 virtual const char* getCmdName() const 41 { return "SubUnitInfoCmd"; }44 { return "SubUnitInfoCmd"; } 42 45 43 46 bool clear(); … … 49 52 50 53 enum { 51 eMaxSubunitsPerPage = 4,52 eMaxSubunitsPerUnit = 32,54 eMaxSubunitsPerPage = 4, 55 eMaxSubunitsPerUnit = 32, 53 56 }; 54 57 55 58 struct TableEntry { 56 subunit_type_t m_subunit_type;57 max_subunit_id_t m_max_subunit_id;59 subunit_type_t m_subunit_type; 60 max_subunit_id_t m_max_subunit_id; 58 61 }; 59 62 … … 61 64 62 65 short getMaxNoOfPages() 63 { return eMaxSubunitsPerUnit / eMaxSubunitsPerPage; }66 { return eMaxSubunitsPerUnit / eMaxSubunitsPerPage; } 64 67 65 68 66 69 short m_nrOfValidEntries; 67 70 short getNrOfValidEntries() 68 { return m_nrOfValidEntries; }71 { return m_nrOfValidEntries; } 69 72 70 73 }; 71 74 72 75 73 #endif // AVCS ubUnitInfo_h76 #endif // AVCSUBUNITINFO_H trunk/libffado/src/libavc/avc_unit_info.cpp
r413 r445 1 /* avc_unit_info.cpp2 * Copyright (C) 2005 by Daniel Wagner1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 3 * 4 * This file is part of FreeBoB. 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 5 6 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 14 17 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 trunk/libffado/src/libavc/avc_unit_info.h
r375 r445 1 /* avc_unit_info.h2 * Copyright (C) 2005 by Daniel Wagner1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 3 * 4 * This file is part of FreeBoB. 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 5 6 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 14 17 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 21 #ifndef AVCU nitInfo_h22 #define AVCU nitInfo_h24 #ifndef AVCUNITINFO_H 25 #define AVCUNITINFO_H 23 26 24 27 #include "avc_generic.h" … … 56 59 57 60 virtual const char* getCmdName() const 58 { return "UnitInfoCmd"; }61 { return "UnitInfoCmd"; } 59 62 60 63 reserved_t m_reserved; … … 66 69 67 70 68 #endif // AVCU nitInfo_h71 #endif // AVCUNITINFO_H trunk/libffado/src/libieee1394/ARMHandler.cpp
r414 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 2 * Copyright (C) 2005-2007 by Pieter Palmers 6 3 * 7 * http://freebob.sf.net 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 8 6 * 9 * Copyright (C) 2007 Pieter Palmers <pieterpalmers@users.sourceforge.net>7 * FFADO is based upon FreeBoB 10 8 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 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; 15 12 * 16 * This programis distributed in the hope that it will be useful,17 * but WITHOUT ANY WARRANTY {}without even the implied warranty of18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the19 * GNUGeneral Public License for more details.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. 20 17 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 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 27 22 */ 28 23 … … 35 30 * @param initial_value pointer to buffer containing (if necessary) initial value 36 31 * NULL means undefined 37 * @param access_rights access-rights for registered addressrange handled 38 * by kernel-part. Value is one or more binary or of the 32 * @param access_rights access-rights for registered addressrange handled 33 * by kernel-part. Value is one or more binary or of the 39 34 * following flags - ARM_READ, ARM_WRITE, ARM_LOCK 40 35 * @param notification_options identifies for which type of request you want 41 * to be notified. Value is one or more binary or of the 36 * to be notified. Value is one or more binary or of the 42 37 * following flags - ARM_READ, ARM_WRITE, ARM_LOCK 43 38 * @param client_transactions identifies for which type of request you want … … 45 40 * for those requests no response will be generated, but 46 41 * has to be generated by the application. 47 * Value is one or more binary or of the 42 * Value is one or more binary or of the 48 43 * following flags - ARM_READ, ARM_WRITE, ARM_LOCK 49 44 * For each bit set here, notification_options and … … 101 96 // byte_t *buffer; 102 97 // } *raw1394_arm_request_t; 103 // 98 // 104 99 // typedef struct raw1394_arm_response { 105 100 // int response_code; … … 107 102 // byte_t *buffer; 108 103 // } *raw1394_arm_response_t; 109 // 104 // 110 105 // typedef struct raw1394_arm_request_response { 111 106 // struct raw1394_arm_request *request; trunk/libffado/src/libieee1394/ARMHandler.h
r414 r445 1 /* $Id$ */ 1 /* 2 * Copyright (C) 2005-2007 by Pieter Palmers 3 * Copyright (C) 2005-2007 by Daniel Wagner 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 */ 2 24 3 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 27 */ 28 #ifndef __FREEBOB_ARMHANDLER__ 29 #define __FREEBOB_ARMHANDLER__ 25 #ifndef __FFADO_ARMHANDLER__ 26 #define __FFADO_ARMHANDLER__ 30 27 31 28 #include "../debugmodule/debugmodule.h" … … 37 34 /** 38 35 * @brief Class to handle AddressRangeMappings 39 * 40 * This class is intended to help with implementing 36 * 37 * This class is intended to help with implementing 41 38 * address range mapping, i.e. implementing handlers 42 39 * that react to reads/writes of certain addresses 43 40 * in 1394 memory space 44 * 41 * 45 42 * see the _arm_ functions in raw1394.h for more insight 46 * 43 * 47 44 */ 48 45 49 46 class ARMHandler { 50 47 friend class Ieee1394Service; … … 57 54 unsigned int client_transactions 58 55 ); 59 56 60 57 virtual ~ARMHandler(); 61 58 … … 65 62 66 63 struct raw1394_arm_response *getResponse() {return &m_response;}; 67 64 68 65 nodeaddr_t getStart() {return m_start;}; 69 66 nodeaddr_t getLength() {return m_length;}; … … 71 68 unsigned int getNotificationOptions() {return m_notification_options;}; 72 69 unsigned int getClientTransactions() {return m_client_transactions;}; 73 70 74 71 byte_t *getBuffer() {return m_buffer;}; 75 72 76 73 private: 77 74 nodeaddr_t m_start; … … 82 79 83 80 byte_t *m_buffer; 84 81 85 82 struct raw1394_arm_response m_response; 86 83 87 84 void printBufferBytes( unsigned int level, size_t length, byte_t* buffer ) const; 88 85 void printRequest(struct raw1394_arm_request *arm_req); 89 86 90 87 protected: 91 88 92 89 93 90 DECLARE_DEBUG_MODULE; 94 91 95 92 }; 96 93 97 #endif /* __F REEBOB_ARMHANDLER__ */94 #endif /* __FFADO_ARMHANDLER__ */ 98 95 99 96 trunk/libffado/src/libieee1394/configrom.cpp
r435 r445 1 /* configrom.cpp 2 * Copyright (C) 2005 by Daniel Wagner 1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 * Copyright (C) 2005-2007 by Jonathan Woithe 4 * Copyright (C) 2005-2007 by Pieter Palmers 3 5 * 4 * This file is part of FreeBoB. 6 * This file is part of FFADO 7 * FFADO = Free Firewire (pro-)audio drivers for linux 5 8 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 9 * FFADO is based upon FreeBoB 10 * 11 * This library is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU Lesser General Public 13 * License version 2.1, as published by the Free Software Foundation; 14 * 15 * This library is distributed in the hope that it will be useful, 11 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * Lesser General Public License for more details. 14 19 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.20 * You should have received a copy of the GNU Lesser General Public 21 * License along with this library; if not, write to the Free Software 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 23 * MA 02110-1301 USA 19 24 */ 20 25 … … 159 164 len ); 160 165 161 while ((buf + len - 1) == '\0') {166 while ((buf + len - 1) == '\0') { 162 167 len--; 163 168 } 164 169 // \todo XXX seems a bit strage to do this but the nodemgr.c code does 165 170 // it. try to figure out why this is needed (or not) 166 buf[len++] = ' ';167 buf[len] = '\0';171 buf[len++] = ' '; 172 buf[len] = '\0'; 168 173 169 174 … … 178 183 ( void* )CSR1212_TEXTUAL_DESCRIPTOR_LEAF_DATA( m_modelNameKv ), 179 184 len ); 180 while ((buf + len - 1) == '\0') {185 while ((buf + len - 1) == '\0') { 181 186 len--; 182 187 } 183 188 // \todo XXX for edirol fa-66 it seems somehow broken. see above 184 189 // todo as well. 185 buf[len++] = ' ';186 buf[len] = '\0';190 buf[len++] = ' '; 191 buf[len] = '\0'; 187 192 188 193 debugOutput( DEBUG_LEVEL_VERBOSE, "Model name: '%s'\n", buf); … … 217 222 { 218 223 struct config_csr_info* csr_info = (struct config_csr_info*) private_data; 219 224 220 225 if ( !csr_info->service->read( csr_info->nodeId, 221 226 addr, … … 249 254 debugOutput( DEBUG_LEVEL_VERBOSE, "process unit directory:\n" ); 250 255 csr1212_for_each_dir_entry(csr, kv, ud_kv, dentry) { 251 switch (kv->key.id) {252 case CSR1212_KV_ID_VENDOR:253 if (kv->key.type == CSR1212_KV_TYPE_IMMEDIATE) {256 switch (kv->key.id) { 257 case CSR1212_KV_ID_VENDOR: 258 if (kv->key.type == CSR1212_KV_TYPE_IMMEDIATE) { 254 259 debugOutput( DEBUG_LEVEL_VERBOSE, 255 260 "\tvendor_id = 0x%08x\n", 256 261 kv->value.immediate); 257 262 m_vendorId = kv->value.immediate; 258 }259 break;260 261 case CSR1212_KV_ID_MODEL:263 } 264 break; 265 266 case CSR1212_KV_ID_MODEL: 262 267 debugOutput( DEBUG_LEVEL_VERBOSE, 263 268 "\tmodel_id = 0x%08x\n", 264 269 kv->value.immediate); 265 270 m_modelId = kv->value.immediate; 266 break;267 268 case CSR1212_KV_ID_SPECIFIER_ID:271 break; 272 273 case CSR1212_KV_ID_SPECIFIER_ID: 269 274 debugOutput( DEBUG_LEVEL_VERBOSE, 270 275 "\tspecifier_id = 0x%08x\n", 271 276 kv->value.immediate); 272 277 m_unit_specifier_id = kv->value.immediate; 273 break;274 275 case CSR1212_KV_ID_VERSION:278 break; 279 280 case CSR1212_KV_ID_VERSION: 276 281 debugOutput( DEBUG_LEVEL_VERBOSE, 277 282 "\tversion = 0x%08x\n", … … 284 289 } 285 290 } 286 break;287 288 case CSR1212_KV_ID_DESCRIPTOR:289 if (kv->key.type == CSR1212_KV_TYPE_LEAF &&290 CSR1212_DESCRIPTOR_LEAF_TYPE(kv) == 0 &&291 CSR1212_DESCRIPTOR_LEAF_SPECIFIER_ID(kv) == 0 &&292 CSR1212_TEXTUAL_DESCRIPTOR_LEAF_WIDTH(kv) == 0 &&293 CSR1212_TEXTUAL_DESCRIPTOR_LEAF_CHAR_SET(kv) == 0 &&294 CSR1212_TEXTUAL_DESCRIPTOR_LEAF_LANGUAGE(kv) == 0)295 {296 switch (last_key_id) {297 case CSR1212_KV_ID_VENDOR:298 csr1212_keep_keyval(kv);291 break; 292 293 case CSR1212_KV_ID_DESCRIPTOR: 294 if (kv->key.type == CSR1212_KV_TYPE_LEAF && 295 CSR1212_DESCRIPTOR_LEAF_TYPE(kv) == 0 && 296 CSR1212_DESCRIPTOR_LEAF_SPECIFIER_ID(kv) == 0 && 297 CSR1212_TEXTUAL_DESCRIPTOR_LEAF_WIDTH(kv) == 0 && 298 CSR1212_TEXTUAL_DESCRIPTOR_LEAF_CHAR_SET(kv) == 0 && 299 CSR1212_TEXTUAL_DESCRIPTOR_LEAF_LANGUAGE(kv) == 0) 300 { 301 switch (last_key_id) { 302 case CSR1212_KV_ID_VENDOR: 303 csr1212_keep_keyval(kv); 299 304 m_vendorNameKv = kv; 300 break;301 302 case CSR1212_KV_ID_MODEL:305 break; 306 307 case CSR1212_KV_ID_MODEL: 303 308 m_modelNameKv = kv; 304 csr1212_keep_keyval(kv);305 break;306 307 }308 } /* else if (kv->key.type == CSR1212_KV_TYPE_DIRECTORY) ... */309 break;310 311 case CSR1212_KV_ID_DEPENDENT_INFO:312 if (kv->key.type == CSR1212_KV_TYPE_DIRECTORY) {313 /* This should really be done in SBP2 as this is314 * doing SBP2 specific parsing. */315 processUnitDirectory(csr, kv, id);316 }317 318 break;319 320 default:321 break;322 }323 last_key_id = kv->key.id;309 csr1212_keep_keyval(kv); 310 break; 311 312 } 313 } /* else if (kv->key.type == CSR1212_KV_TYPE_DIRECTORY) ... */ 314 break; 315 316 case CSR1212_KV_ID_DEPENDENT_INFO: 317 if (kv->key.type == CSR1212_KV_TYPE_DIRECTORY) { 318 /* This should really be done in SBP2 as this is 319 * doing SBP2 specific parsing. */ 320 processUnitDirectory(csr, kv, id); 321 } 322 323 break; 324 325 default: 326 break; 327 } 328 last_key_id = kv->key.id; 324 329 } 325 330 } … … 334 339 335 340 csr1212_for_each_dir_entry(csr, kv, csr->root_kv, dentry) { 336 switch (kv->key.id) {337 case CSR1212_KV_ID_VENDOR:341 switch (kv->key.id) { 342 case CSR1212_KV_ID_VENDOR: 338 343 debugOutput( DEBUG_LEVEL_VERBOSE, 339 344 "vendor id = 0x%08x\n", kv->value.immediate); 340 break;341 342 case CSR1212_KV_ID_NODE_CAPABILITIES:345 break; 346 347 case CSR1212_KV_ID_NODE_CAPABILITIES: 343 348 debugOutput( DEBUG_LEVEL_VERBOSE, 344 349 "capabilities = 0x%08x\n", kv->value.immediate); 345 break;346 347 case CSR1212_KV_ID_UNIT:348 processUnitDirectory(csr, kv, &ud_id);349 break;350 351 case CSR1212_KV_ID_DESCRIPTOR:352 if (last_key_id == CSR1212_KV_ID_VENDOR) {353 if (kv->key.type == CSR1212_KV_TYPE_LEAF &&354 CSR1212_DESCRIPTOR_LEAF_TYPE(kv) == 0 &&355 CSR1212_DESCRIPTOR_LEAF_SPECIFIER_ID(kv) == 0 &&356 CSR1212_TEXTUAL_DESCRIPTOR_LEAF_WIDTH(kv) == 0 &&357 CSR1212_TEXTUAL_DESCRIPTOR_LEAF_CHAR_SET(kv) == 0 &&358 CSR1212_TEXTUAL_DESCRIPTOR_LEAF_LANGUAGE(kv) == 0)350 break; 351 352 case CSR1212_KV_ID_UNIT: 353 processUnitDirectory(csr, kv, &ud_id); 354 break; 355 356 case CSR1212_KV_ID_DESCRIPTOR: 357 if (last_key_id == CSR1212_KV_ID_VENDOR) { 358 if (kv->key.type == CSR1212_KV_TYPE_LEAF && 359 CSR1212_DESCRIPTOR_LEAF_TYPE(kv) == 0 && 360 CSR1212_DESCRIPTOR_LEAF_SPECIFIER_ID(kv) == 0 && 361 CSR1212_TEXTUAL_DESCRIPTOR_LEAF_WIDTH(kv) == 0 && 362 CSR1212_TEXTUAL_DESCRIPTOR_LEAF_CHAR_SET(kv) == 0 && 363 CSR1212_TEXTUAL_DESCRIPTOR_LEAF_LANGUAGE(kv) == 0) 359 364 { 360 365 m_vendorNameKv = kv; 361 csr1212_keep_keyval(kv);362 }363 }364 break;365 }366 last_key_id = kv->key.id;366 csr1212_keep_keyval(kv); 367 } 368 } 369 break; 370 } 371 last_key_id = kv->key.id; 367 372 } 368 373 … … 578 583 ConfigRom::processOscMessage(OSC::OscMessage *m) { 579 584 OSC::OscResponse r=OSC::OscResponse(OSC::OscResponse::eUnhandled); 580 585 581 586 unsigned int nbArgs=m->nbArguments(); 582 587 if (nbArgs>=1) { … … 584 589 if(arg0.isString()) { // commands 585 590 string cmd=arg0.getString(); 586 591 587 592 debugOutput( DEBUG_LEVEL_VERBOSE, "(%p) CMD? %s\n", this, cmd.c_str()); 588 593 if(cmd == "params") { … … 623 628 } 624 629 } 625 630 626 631 return r; 627 632 trunk/libffado/src/libieee1394/configrom.h
r435 r445 1 /* configrom.h 2 * Copyright (C) 2005,06 by Daniel Wagner 1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 * Copyright (C) 2005-2007 by Jonathan Woithe 4 * Copyright (C) 2005-2007 by Pieter Palmers 3 5 * 4 * This file is part of FreeBoB. 6 * This file is part of FFADO 7 * FFADO = Free Firewire (pro-)audio drivers for linux 5 8 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 9 * FFADO is based upon FreeBoB 10 * 11 * This library is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU Lesser General Public 13 * License version 2.1, as published by the Free Software Foundation; 14 * 15 * This library is distributed in the hope that it will be useful, 11 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * Lesser General Public License for more details. 14 19 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.20 * You should have received a copy of the GNU Lesser General Public 21 * License along with this library; if not, write to the Free Software 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 23 * MA 02110-1301 USA 19 24 */ 20 25 … … 56 61 57 62 bool isIsoResourseManager() const 58 { return m_isIsoResourceManager; }63 { return m_isIsoResourceManager; } 59 64 bool isCycleMasterCapable() const 60 65 { return m_isCycleMasterCapable; } … … 70 75 71 76 fb_quadlet_t getNodeVendorId() const 72 { return m_nodeVendorId; }77 { return m_nodeVendorId; } 73 78 74 79 bool updatedNodeId(); … … 78 83 79 84 bool serialize( Glib::ustring path, Util::IOSerialize& ser ); 80 static ConfigRom* deserialize( Glib::ustring path, 81 Util::IODeserialize& deser,82 Ieee1394Service& ieee1394Service );85 static ConfigRom* deserialize( Glib::ustring path, 86 Util::IODeserialize& deser, 87 Ieee1394Service& ieee1394Service ); 83 88 84 89 protected: trunk/libffado/src/libieee1394/IEC61883.cpp
r424 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 2 * Copyright (C) 2005-2007 by Pieter Palmers 6 3 * 7 * http://freebob.sf.net 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 8 6 * 9 * Copyright (C) 2007 Pieter Palmers <pieterpalmers@users.sourceforge.net>7 * FFADO is based upon FreeBoB 10 8 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 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; 15 12 * 16 * This programis distributed in the hope that it will be useful,17 * but WITHOUT ANY WARRANTY {}without even the implied warranty of18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the19 * GNUGeneral Public License for more details.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. 20 17 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 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 26 22 */ 27 23 trunk/libffado/src/libieee1394/IEC61883.h
r424 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2007 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 27 */ 28 #ifndef __FREEBOB_IEC61883__ 29 #define __FREEBOB_IEC61883__ 2 * Copyright (C) 2005-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 #ifndef __FFADO_IEC61883__ 25 #define __FFADO_IEC61883__ 30 26 31 27 #include "../debugmodule/debugmodule.h" 32 28 33 29 /* 34 * This is shamelessly stolen from iec61883-private, 30 * This is shamelessly stolen from iec61883-private, 35 31 * but I need these functions! 36 32 * FIXME: this will only work until somebody decides to change … … 45 41 **/ 46 42 47 /* maximum number of PCRs allowed within the standard 43 /* maximum number of PCRs allowed within the standard 48 44 * MPR/PCR addresses defined in IEC-61883. 49 45 * This refers to the number of output or input PCRs-- … … 147 143 * @a: The CSR offset address (relative to base) of the register to read. 148 144 * @value: A pointer to a quadlet where the plug register's value will be stored. 149 * 150 * This function handles bus to host endian conversion. It returns 0 for 145 * 146 * This function handles bus to host endian conversion. It returns 0 for 151 147 * suceess or -1 for error (errno available). 152 148 **/ … … 155 151 156 152 157 /** 153 /** 158 154 * iec61883_plug_set - Write a node's plug register. 159 155 * @h: A raw1394 handle. … … 204 200 }; 205 201 206 #endif /* __F REEBOB_IEC61883__ */207 208 202 #endif /* __FFADO_IEC61883__ */ 203 204 trunk/libffado/src/libieee1394/ieee1394service.cpp
r436 r445 1 /* ieee1394service.cpp 2 * Copyright (C) 2005,07 by Daniel Wagner 3 * Copyright (C) 2007 by Pieter Palmers 4 * 5 * This file is part of FreeBoB. 6 * 7 * FreeBoB is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * FreeBoB is distributed in the hope that it will be useful, 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, 12 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNUGeneral Public License for more details.15 * 16 * You should have received a copy of the GNU General Public License17 * along with FreeBoB; if not, write to the Free Software18 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,19 * MA 0211 1-1307 USA.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 20 23 */ 24 21 25 #include "ieee1394service.h" 22 26 #include "ARMHandler.h" … … 42 46 { 43 47 pthread_mutex_init( &m_mutex, 0 ); 44 48 45 49 for (unsigned int i=0; i<64; i++) { 46 50 m_channels[i].channel=-1; … … 73 77 raw1394_destroy_handle( m_handle ); 74 78 } 75 79 76 80 if ( m_resetHandle ) { 77 81 raw1394_destroy_handle( m_resetHandle ); … … 117 121 m_default_arm_handler = raw1394_set_arm_tag_handler( m_resetHandle, 118 122 this->armHandlerLowLevel ); 119 123 120 124 startRHThread(); 121 125 … … 230 234 } 231 235 232 bool 236 bool 233 237 Ieee1394Service::lockCompareSwap64( fb_nodeid_t nodeId, 234 238 fb_nodeaddr_t addr, … … 244 248 fb_octlet_t buffer; 245 249 if(!read_octlet( nodeId, addr,&buffer )) { 246 debug Output(DEBUG_LEVEL_VERBOSE,"Could not read ownerregister\n");250 debugWarning("Could not read register\n"); 247 251 } else { 248 debugOutput(DEBUG_LEVEL_VERBOSE,"Owner register before = 0x%016llX\n", buffer); 249 } 250 251 buffer=0x123456789ABCDEF0LL; 252 debugOutput(DEBUG_LEVEL_VERBOSE,"before byteswap = 0x%016llX\n", buffer); 253 buffer=byteSwap_octlet(buffer); 254 debugOutput(DEBUG_LEVEL_VERBOSE,"after byteswap = 0x%016llX\n", buffer); 255 256 252 debugOutput(DEBUG_LEVEL_VERBOSE,"before = 0x%016llX\n", buffer); 253 } 254 257 255 #endif 258 256 259 257 // do endiannes swapping 260 258 compare_value=byteSwap_octlet(compare_value); 261 259 swap_value=byteSwap_octlet(swap_value); 262 260 263 261 int retval=raw1394_lock64(m_handle, nodeId, addr, RAW1394_EXTCODE_COMPARE_SWAP, 264 262 swap_value, compare_value, result); 265 263 266 264 #ifdef DEBUG 267 265 if(!read_octlet( nodeId, addr,&buffer )) { 268 debug Output(DEBUG_LEVEL_VERBOSE,"Could not read ownerregister\n");266 debugWarning("Could not read register\n"); 269 267 } else { 270 debugOutput(DEBUG_LEVEL_VERBOSE," Owner registerafter = 0x%016llX\n", buffer);268 debugOutput(DEBUG_LEVEL_VERBOSE,"after = 0x%016llX\n", buffer); 271 269 } 272 270 #endif 273 271 274 272 *result=byteSwap_octlet(*result); 275 273 276 274 return (retval == 0); 277 275 } … … 286 284 buf[i] = ntohl( buf[i] ); 287 285 } 288 289 #ifdef DEBUG290 debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, " pre avc1394_transaction_block2\n" );291 printBuffer( DEBUG_LEVEL_VERY_VERBOSE, len, buf );292 #endif293 286 294 287 fb_quadlet_t* result = … … 300 293 10 ); 301 294 302 #ifdef DEBUG303 debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, " post avc1394_transaction_block2\n" );304 printBuffer( DEBUG_LEVEL_VERY_VERBOSE, *resp_len, result );305 #endif306 307 295 for ( unsigned int i = 0; i < *resp_len; ++i ) { 308 296 result[i] = htonl( result[i] ); … … 389 377 h, h->getStart(), h->getLength()); 390 378 391 int err=raw1394_arm_register(m_resetHandle, h->getStart(), 379 int err=raw1394_arm_register(m_resetHandle, h->getStart(), 392 380 h->getLength(), h->getBuffer(), (octlet_t)h, 393 381 h->getAccessRights(), … … 399 387 return false; 400 388 } 401 389 402 390 m_armHandlers.push_back( h ); 403 391 … … 406 394 407 395 bool Ieee1394Service::unregisterARMHandler( ARMHandler *h ) { 408 debugOutput(DEBUG_LEVEL_VERBOSE, "Unregistering ARM handler (%p) for 0x%016llX\n", 396 debugOutput(DEBUG_LEVEL_VERBOSE, "Unregistering ARM handler (%p) for 0x%016llX\n", 409 397 h, h->getStart()); 410 398 411 399 for ( arm_handler_vec_t::iterator it = m_armHandlers.begin(); 412 400 it != m_armHandlers.end(); … … 439 427 debugOutput(DEBUG_LEVEL_VERBOSE, "Finding free ARM block of %d bytes, from 0x%016llX in steps of %d bytes\n", 440 428 length, start, step); 441 429 442 430 int cnt=0; 443 431 const int maxcnt=10; … … 446 434 // try to register 447 435 err=raw1394_arm_register(m_resetHandle, start, length, 0, 0, 0, 0, 0); 448 436 449 437 if (err) { 450 438 debugOutput(DEBUG_LEVEL_VERBOSE, " -> cannot use 0x%016llX\n", start); … … 466 454 } 467 455 468 int 469 Ieee1394Service::armHandlerLowLevel(raw1394handle_t handle, 456 int 457 Ieee1394Service::armHandlerLowLevel(raw1394handle_t handle, 470 458 unsigned long arm_tag, 471 459 byte_t request_type, unsigned int requested_length, … … 493 481 raw1394_arm_request_t arm_req=arm_req_resp->request; 494 482 raw1394_arm_response_t arm_resp=arm_req_resp->response; 495 483 496 484 debugOutput(DEBUG_LEVEL_VERBOSE,"ARM handler for address 0x%016llX called\n", 497 485 (*it)->getStart()); 498 486 debugOutput(DEBUG_LEVEL_VERBOSE," request type : 0x%02X\n",request_type); 499 487 debugOutput(DEBUG_LEVEL_VERBOSE," request length : %04d\n",requested_length); 500 488 501 489 switch(request_type) { 502 490 case RAW1394_ARM_READ: … … 583 571 { 584 572 debugOutput(DEBUG_LEVEL_VERBOSE, "Removing busreset handler (%p)\n", functor); 585 573 586 574 for ( reset_handler_vec_t::iterator it = m_busResetHandlers.begin(); 587 575 it != m_busResetHandlers.end(); … … 603 591 * or an allocated channel number. 604 592 * 605 * Does not perform anything other than registering the channel and the 593 * Does not perform anything other than registering the channel and the 606 594 * bandwidth at the IRM 607 595 * 608 596 * Also allocates the necessary bandwidth (in ISO allocation units). 609 * 597 * 610 598 * FIXME: As in libiec61883, channel 63 is not requested; this is either a 611 599 * bug or it's omitted since that's the channel preferred by video devices. … … 616 604 signed int Ieee1394Service::allocateIsoChannelGeneric(unsigned int bandwidth) { 617 605 debugOutput(DEBUG_LEVEL_VERBOSE, "Allocating ISO channel using generic method...\n" ); 618 606 619 607 struct ChannelInfo cinfo; 620 608 … … 627 615 if (raw1394_bandwidth_modify(m_handle, bandwidth, RAW1394_MODIFY_ALLOC) < 0) { 628 616 debugFatal("Could not allocate bandwidth of %d\n", bandwidth); 629 617 630 618 raw1394_channel_modify (m_handle, c, RAW1394_MODIFY_FREE); 631 619 return -1; … … 634 622 cinfo.bandwidth=bandwidth; 635 623 cinfo.alloctype=AllocGeneric; 636 624 625 cinfo.xmit_node=-1; 626 cinfo.xmit_plug=-1; 627 cinfo.recv_node=-1; 628 cinfo.recv_plug=-1; 629 637 630 if (registerIsoChannel(c, cinfo)) { 638 631 return c; … … 667 660 668 661 signed int Ieee1394Service::allocateIsoChannelCMP( 669 nodeid_t xmit_node, int xmit_plug, 662 nodeid_t xmit_node, int xmit_plug, 670 663 nodeid_t recv_node, int recv_plug 671 664 ) { 672 665 673 666 debugOutput(DEBUG_LEVEL_VERBOSE, "Allocating ISO channel using IEC61883 CMP...\n" ); 674 667 675 668 struct ChannelInfo cinfo; 676 669 677 670 int c = -1; 678 671 int bandwidth=1; 679 672 680 673 // do connection management: make connection 681 674 c = iec61883_cmp_connect( … … 697 690 cinfo.bandwidth=bandwidth; 698 691 cinfo.alloctype=AllocCMP; 699 692 700 693 cinfo.xmit_node=xmit_node; 701 694 cinfo.xmit_plug=xmit_plug; 702 695 cinfo.recv_node=recv_node; 703 696 cinfo.recv_plug=recv_plug; 704 697 705 698 if (registerIsoChannel(c, cinfo)) { 706 699 return c; … … 711 704 712 705 /** 713 * Deallocates an iso channel. Silently ignores a request to deallocate 706 * Deallocates an iso channel. Silently ignores a request to deallocate 714 707 * a negative channel number. 715 708 * … … 717 710 * and uses the appropriate method to deallocate. Also frees the bandwidth 718 711 * that was reserved along with this channel. 719 * 712 * 720 713 * @param c channel number 721 714 * @return true if successful … … 723 716 bool Ieee1394Service::freeIsoChannel(signed int c) { 724 717 debugOutput(DEBUG_LEVEL_VERBOSE, "Freeing ISO channel %d...\n", c ); 725 718 726 719 if (c < 0 || c > 63) { 727 720 debugWarning("Invalid channel number: %d\n", c); 728 721 return false; 729 722 } 730 723 731 724 switch (m_channels[c].alloctype) { 732 725 default: 733 726 debugError(" BUG: invalid allocation type!\n"); 734 727 return false; 735 736 case AllocFree: 728 729 case AllocFree: 737 730 debugWarning(" Channel %d not registered\n", c); 738 731 return false; 739 732 740 733 case AllocGeneric: 741 734 debugOutput(DEBUG_LEVEL_VERBOSE, " allocated using generic routine...\n" ); … … 751 744 return false; 752 745 return true; 753 746 754 747 case AllocCMP: 755 748 debugOutput(DEBUG_LEVEL_VERBOSE, " allocated using IEC61883 CMP...\n" ); 756 749 debugOutput(DEBUG_LEVEL_VERBOSE, " performing IEC61883 CMP disconnect...\n" ); 757 750 if(iec61883_cmp_disconnect( 758 m_handle, 751 m_handle, 759 752 m_channels[c].xmit_node | 0xffc0, 760 753 m_channels[c].xmit_plug, … … 769 762 return true; 770 763 } 771 764 772 765 // unreachable 773 766 debugError("BUG: unreachable code reached!\n"); 774 767 775 768 return false; 776 769 } … … 788 781 m_channels[c].channel, m_channels[c].bandwidth); 789 782 } 790 783 791 784 memcpy(&m_channels[c], &cinfo, sizeof(struct ChannelInfo)); 792 785 793 786 } else return false; 794 787 return true; … … 806 799 return false; 807 800 } 808 801 809 802 m_channels[c].channel=-1; 810 803 m_channels[c].bandwidth=-1; … … 814 807 m_channels[c].recv_node=0xFFFF; 815 808 m_channels[c].recv_plug=-1; 816 809 817 810 } else return false; 818 811 return true; … … 822 815 * Returns the current value of the `bandwidth available' register on 823 816 * the IRM, or -1 on error. 824 * @return 817 * @return 825 818 */ 826 819 signed int Ieee1394Service::getAvailableBandwidth() { … … 836 829 837 830 void 838 Ieee1394Service::setVerboseLevel(int l) 831 Ieee1394Service::setVerboseLevel(int l) 839 832 { 840 833 setDebugLevel(l); trunk/libffado/src/libieee1394/ieee1394service.h
r436 r445 1 /* Ieee1394Service.cpp 2 * Copyright (C) 2005,06 by Daniel Wagner 3 * Copyright (C) 2007 by Pieter Palmers 4 * 5 * This file is part of FreeBoB. 6 * 7 * FreeBoB is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * FreeBoB is distributed in the hope that it will be useful, 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, 12 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNUGeneral Public License for more details.15 * 16 * You should have received a copy of the GNU General Public License17 * along with FreeBoB; if not, write to the Free Software18 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,19 * MA 0211 1-1307 USA.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 20 23 */ 21 24 22 #ifndef F REEBOBIEEE1394SERVICE_H23 #define F REEBOBIEEE1394SERVICE_H25 #ifndef FFADO_IEEE1394SERVICE_H 26 #define FFADO_IEEE1394SERVICE_H 24 27 25 28 #include "fbtypes.h" … … 45 48 46 49 int getPort() 47 { return m_port; }50 { return m_port; } 48 51 /** 49 52 * @brief get number of nodes on the bus … … 57 60 */ 58 61 int getNodeCount(); 59 62 60 63 /** 61 64 * @brief get the node id of the local node … … 67 70 */ 68 71 nodeid_t getLocalNodeId(); 69 72 70 73 /** 71 74 * @brief send async read request to a node and wait for response. … … 77 80 * @param length amount of data to read in quadlets 78 81 * @param buffer pointer to buffer where data will be saved 79 82 80 83 * @return true on success or false on failure (sets errno) 81 84 */ 82 85 bool read( fb_nodeid_t nodeId, 83 fb_nodeaddr_t addr,84 size_t length,85 fb_quadlet_t* buffer );86 fb_nodeaddr_t addr, 87 size_t length, 88 fb_quadlet_t* buffer ); 86 89 87 90 bool read_quadlet( fb_nodeid_t nodeId, … … 106 109 */ 107 110 bool write( fb_nodeid_t nodeId, 108 fb_nodeaddr_t addr,109 size_t length,110 fb_quadlet_t* data );111 fb_nodeaddr_t addr, 112 size_t length, 113 fb_quadlet_t* data ); 111 114 112 115 bool write_quadlet( fb_nodeid_t nodeId, … … 143 146 fb_quadlet_t* buf, 144 147 int len, 145 unsigned int* resp_len );148 unsigned int* resp_len ); 146 149 147 150 bool transactionBlockClose(); … … 153 156 bool addBusResetHandler( Functor* functor ); 154 157 bool remBusResetHandler( Functor* functor ); 155 158 156 159 /** 157 160 * @brief register an AddressRangeMapping Handler … … 169 172 */ 170 173 bool unregisterARMHandler( ARMHandler *h ); 171 174 172 175 nodeaddr_t findFreeARMBlock( nodeaddr_t start, size_t length, size_t step ); 173 176 … … 176 179 signed int getAvailableBandwidth(); 177 180 signed int allocateIsoChannelGeneric(unsigned int bandwidth); 178 signed int allocateIsoChannelCMP(nodeid_t xmit_node, int xmit_plug, 181 signed int allocateIsoChannelCMP(nodeid_t xmit_node, int xmit_plug, 179 182 nodeid_t recv_node, int recv_plug); 180 183 bool freeIsoChannel(signed int channel); 181 184 182 185 private: 183 186 enum EAllocType { … … 196 199 int recv_plug; 197 200 }; 198 201 199 202 // the info for the channels we manage 200 203 struct ChannelInfo m_channels[64]; 201 204 202 205 bool unregisterIsoChannel(unsigned int c); 203 206 bool registerIsoChannel(unsigned int c, struct ChannelInfo cinfo); … … 211 214 void printBuffer( unsigned int level, size_t length, fb_quadlet_t* buffer ) const; 212 215 void printBufferBytes( unsigned int level, size_t length, byte_t* buffer ) const; 213 216 214 217 static int resetHandlerLowLevel( raw1394handle_t handle, 215 218 unsigned int generation ); 216 219 bool resetHandler( unsigned int generation ); 217 220 218 221 static int armHandlerLowLevel(raw1394handle_t handle, unsigned long arm_tag, 219 222 byte_t request_type, unsigned int requested_length, 220 void *data); 223 void *data); 221 224 bool armHandler( unsigned long arm_tag, 222 225 byte_t request_type, unsigned int requested_length, … … 234 237 typedef std::vector< Functor* > reset_handler_vec_t; 235 238 reset_handler_vec_t m_busResetHandlers; 236 239 237 240 // ARM stuff 238 241 arm_tag_handler_t m_default_arm_handler; 239 242 240 243 typedef std::vector< ARMHandler * > arm_handler_vec_t; 241 244 arm_handler_vec_t m_armHandlers; 242 245 243 246 fb_octlet_t byteSwap_octlet(fb_octlet_t value); 244 247 245 248 public: 246 249 void setVerboseLevel(int l); … … 249 252 }; 250 253 251 #endif 254 #endif // FFADO_IEEE1394SERVICE_H trunk/libffado/src/libosc/OscArgument.cpp
r432 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 2 * Copyright (C) 2005-2007 by Pieter Palmers 6 3 * 7 * http://freebob.sf.net 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 8 6 * 9 * Copyright (C) 2007 Pieter Palmers <pieterpalmers@users.sourceforge.net>7 * FFADO is based upon FreeBoB 10 8 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 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; 15 12 * 16 * This programis distributed in the hope that it will be useful,17 * but WITHOUT ANY WARRANTY {}without even the implied warranty of18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the19 * GNUGeneral Public License for more details.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. 20 17 * 21 * You should have received a copy of the GNU General Public License22 * along with this program {}if not, write to the Free Software23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.24 * 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 25 22 */ 26 23 … … 31 28 IMPL_DEBUG_MODULE( OscArgument, OscArgument, DEBUG_LEVEL_VERBOSE ); 32 29 33 OscArgument::OscArgument(int32_t i) 30 OscArgument::OscArgument(int32_t i) 34 31 : m_isInt(true) 35 32 , m_intVal(i) … … 42 39 {} 43 40 44 OscArgument::OscArgument(int64_t i) 41 OscArgument::OscArgument(int64_t i) 45 42 : m_isInt(false) 46 43 , m_intVal(0) … … 53 50 {} 54 51 55 OscArgument::OscArgument(float f) 52 OscArgument::OscArgument(float f) 56 53 : m_isInt(false) 57 54 , m_intVal(0) … … 64 61 {} 65 62 66 OscArgument::OscArgument(string s) 63 OscArgument::OscArgument(string s) 67 64 : m_isInt(false) 68 65 , m_intVal(0) trunk/libffado/src/libosc/OscArgument.h
r432 r445 1 /* $Id$ */ 1 /* 2 * Copyright (C) 2005-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 */ 2 23 3 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2007 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 */ 26 #ifndef __FREEBOB_OSCARGUMENT__ 27 #define __FREEBOB_OSCARGUMENT__ 24 #ifndef __FFADO_OSCARGUMENT__ 25 #define __FFADO_OSCARGUMENT__ 28 26 29 27 #include "../debugmodule/debugmodule.h" … … 44 42 OscArgument(string); 45 43 virtual ~OscArgument(); 46 44 47 45 bool operator == ( const OscArgument& rhs ); 48 46 49 47 int32_t getInt() { return m_intVal;}; 50 48 bool isInt() { return m_isInt;}; … … 55 53 string& getString() { return m_stringVal;}; 56 54 bool isString() { return m_isString;}; 57 55 58 56 void print(); 59 57 60 58 protected: 61 59 bool m_isInt; 62 60 int32_t m_intVal; 63 61 64 62 bool m_isInt64; 65 63 int64_t m_int64Val; 66 64 67 65 bool m_isFloat; 68 66 float m_floatVal; 69 67 70 68 bool m_isString; 71 69 string m_stringVal; … … 78 76 } // end of namespace OSC 79 77 80 #endif /* __F REEBOB_OSCARGUMENT__ */78 #endif /* __FFADO_OSCARGUMENT__ */ 81 79 82 80 trunk/libffado/src/libosc/OscMessage.cpp
r432 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 2 * Copyright (C) 2005-2007 by Pieter Palmers 6 3 * 7 * http://freebob.sf.net 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 8 6 * 9 * Copyright (C) 2007 Pieter Palmers <pieterpalmers@users.sourceforge.net>7 * FFADO is based upon FreeBoB 10 8 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 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; 15 12 * 16 * This programis distributed in the hope that it will be useful,17 * but WITHOUT ANY WARRANTY {}without even the implied warranty of18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the19 * GNUGeneral Public License for more details.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. 20 17 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 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 27 22 */ 28 23 … … 62 57 addArgument((int64_t)(argv[i]->h)); 63 58 break; 64 59 65 60 /* unsupported types */ 66 61 /** OSC binary blob type. Accessed using the lo_blob_*() functions. */ … … 86 81 case LO_INFINITUM: 87 82 default: 88 debugOutput(DEBUG_LEVEL_NORMAL, 83 debugOutput(DEBUG_LEVEL_NORMAL, 89 84 "unsupported osc type: %c\n", lo_type(types[i])); 90 85 } trunk/libffado/src/libosc/OscMessage.h
r432 r445 1 /* $Id$ */ 1 /* 2 * Copyright (C) 2005-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 */ 2 23 3 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2007 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 27 */ 28 #ifndef __FREEBOB_OSCMESSAGE__ 29 #define __FREEBOB_OSCMESSAGE__ 24 #ifndef __FFADO_OSCMESSAGE__ 25 #define __FFADO_OSCMESSAGE__ 30 26 31 27 #include <string> … … 47 43 OscMessage(string path, const char* types, lo_arg** argv, int argc); 48 44 virtual ~OscMessage(); 49 45 50 46 lo_message makeLoMessage(); 51 47 52 48 void addArgument(int32_t v); 53 49 void addArgument(int64_t v); 54 50 void addArgument(float v); 55 51 void addArgument(string v); 56 52 57 53 OscArgument& getArgument(unsigned int idx); 58 54 unsigned int nbArguments(); 59 55 60 56 void setPath(string v); 61 57 string getPath() {return m_Path;}; 62 58 void print(); 63 59 64 60 protected: 65 61 typedef std::vector< OscArgument > OscArgumentVector; … … 75 71 } // end of namespace OSC 76 72 77 #endif /* __F REEBOB_OSCMESSAGE__ */73 #endif /* __FFADO_OSCMESSAGE__ */ 78 74 79 75 trunk/libffado/src/libosc/OscNode.cpp
r436 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2007 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 2 * Copyright (C) 2005-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 25 22 */ 26 23 … … 80 77 { 81 78 debugOutput( DEBUG_LEVEL_VERBOSE, "(%p) MSG: %s\n",this, path.c_str()); 82 79 83 80 // delete leading slash 84 81 if(path.find_first_of('/')==0) path=path.substr(1,path.size()); 85 82 86 83 // delete trailing slash 87 84 if(path.find_last_of('/')==path.size()-1) path=path.substr(0,path.size()-1); 88 85 89 86 // continue processing 90 87 int firstsep=path.find_first_of('/'); … … 92 89 if (firstsep == -1) { 93 90 OscResponse retVal; 94 91 95 92 // process the message 96 93 retVal=processOscMessage(m); 97 94 98 95 if(retVal.isHandled()) { 99 96 return retVal; // completely handled … … 121 118 } 122 119 debugOutput( DEBUG_LEVEL_VERBOSE, "Child node %s not found \n",newbase.c_str()); 123 120 124 121 return OscResponse(OscResponse::eError); 125 122 } … … 160 157 } 161 158 162 OscMessage 159 OscMessage 163 160 OscNode::oscListChildren(OscMessage m) { 164 161 165 162 for ( OscNodeVectorIterator it = m_ChildNodes.begin(); 166 163 it != m_ChildNodes.end(); … … 179 176 { 180 177 assert(n); 181 178 182 179 debugOutput( DEBUG_LEVEL_VERBOSE, "Adding child node %s\n",n->getOscBase().c_str()); 183 180 for ( OscNodeVectorIterator it = m_ChildNodes.begin(); … … 186 183 { 187 184 if(*it == n) { 188 debugOutput( DEBUG_LEVEL_VERBOSE, 185 debugOutput( DEBUG_LEVEL_VERBOSE, 189 186 "Child node %s already registered\n", 190 187 n->getOscBase().c_str()); … … 202 199 * you would add it using this function, by 203 200 * addChildOscNode(n, "/base/level1/level2") 204 * 205 * @param n 206 * @param 207 * @return 201 * 202 * @param n 203 * @param 204 * @return 208 205 */ 209 206 bool … … 211 208 { 212 209 debugOutput( DEBUG_LEVEL_VERBOSE, "add node to: %s\n",path.c_str()); 213 210 214 211 // delete leading slashes 215 212 if(path.find_first_of('/')==0) path=path.substr(1,path.size()); 216 213 217 214 // delete trailing slashes 218 215 if(path.find_last_of('/')==path.size()-1) path=path.substr(0,path.size()-1); 219 216 220 217 // continue processing 221 218 int firstsep=path.find_first_of('/'); … … 243 240 } 244 241 debugOutput( DEBUG_LEVEL_VERBOSE, "node %s not found, creating auto-node\n",newbase.c_str()); 245 242 246 243 OscNode *autoNode=new OscNode(newbase,true); 247 244 248 245 // add the auto-node to this node 249 246 m_ChildNodes.push_back(autoNode); 250 247 251 248 // add the child to the node 252 249 return autoNode->addChildOscNode(n,newpath); … … 255 252 } 256 253 257 bool 254 bool 258 255 OscNode::removeChildOscNode(OscNode *n) 259 256 { … … 276 273 277 274 debugOutput( DEBUG_LEVEL_VERBOSE, "Child node %s not found \n",n->getOscBase().c_str()); 278 275 279 276 return false; //not found 280 277 } 281 278 282 void 279 void 283 280 OscNode::printOscNode() 284 281 { … … 286 283 } 287 284 288 void 285 void 289 286 OscNode::printOscNode(string path) 290 287 { trunk/libffado/src/libosc/OscNode.h
r436 r445 1 /* $Id$ */ 1 /* 2 * Copyright (C) 2005-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 */ 2 23 3 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2007 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 */ 26 #ifndef __FREEBOB_OSCNODE__ 27 #define __FREEBOB_OSCNODE__ 24 #ifndef __FFADO_OSCNODE__ 25 #define __FFADO_OSCNODE__ 28 26 29 27 #include "../debugmodule/debugmodule.h" … … 55 53 56 54 string getOscBase() {return m_oscBase;}; 57 55 58 56 void setOscNodeAutoDelete(bool b) {m_oscAutoDelete=b;}; 59 57 bool doOscNodeAutoDelete() {return m_oscAutoDelete;}; 60 58 61 59 void printOscNode(string path); 62 60 void printOscNode(); 63 61 64 62 virtual OscResponse processOscMessage(OscMessage *m); 65 63 virtual OscResponse processOscMessage(string path, OscMessage *m); 66 64 67 65 protected: 68 66 void setOscBase(string s) {m_oscBase=s;}; … … 71 69 OscResponse processOscMessageDefault(OscMessage *m, OscResponse); 72 70 OscMessage oscListChildren(OscMessage); 73 71 74 72 string m_oscBase; 75 73 bool m_oscAutoDelete; 76 74 77 75 typedef vector< OscNode * > OscNodeVector; 78 76 typedef vector< OscNode * >::iterator OscNodeVectorIterator; … … 88 86 } // end of namespace OSC 89 87 90 #endif /* __F REEBOB_OSCNODE__ */88 #endif /* __FFADO_OSCNODE__ */ 91 89 92 90 trunk/libffado/src/libosc/OscResponse.cpp
r432 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 2 * Copyright (C) 2005-2007 by Pieter Palmers 6 3 * 7 * http://freebob.sf.net 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 8 6 * 9 * Copyright (C) 2007 Pieter Palmers <pieterpalmers@users.sourceforge.net>7 * FFADO is based upon FreeBoB 10 8 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 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; 15 12 * 16 * This programis distributed in the hope that it will be useful,17 * but WITHOUT ANY WARRANTY {}without even the implied warranty of18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the19 * GNUGeneral Public License for more details.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. 20 17 * 21 * You should have received a copy of the GNU General Public License22 * along with this program {}if not, write to the Free Software23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.24 * 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 25 22 */ 26 23 trunk/libffado/src/libosc/OscResponse.h
r432 r445 1 /* $Id$ */ 1 /* 2 * Copyright (C) 2005-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 */ 2 23 3 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2007 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 */ 26 #ifndef __FREEBOB_OSCRESPONSE__ 27 #define __FREEBOB_OSCRESPONSE__ 24 #ifndef __FFADO_OSCRESPONSE__ 25 #define __FFADO_OSCRESPONSE__ 28 26 29 27 #include "OscMessage.h" … … 47 45 OscResponse(OscMessage); 48 46 virtual ~OscResponse(); 49 47 50 48 OscMessage& getMessage() {return m_message;}; 51 49 52 50 bool isError() {return m_type==eError;}; 53 51 bool isHandled() {return (m_type != eError) && (m_type != eUnhandled);}; … … 58 56 enum EType m_type; 59 57 OscMessage m_message; 60 58 61 59 protected: 62 60 DECLARE_DEBUG_MODULE; … … 66 64 } // end of namespace OSC 67 65 68 #endif /* __F REEBOB_OSCRESPONSE__ */66 #endif /* __FFADO_OSCRESPONSE__ */ 69 67 70 68 trunk/libffado/src/libosc/OscServer.cpp
r436 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 2 * Copyright (C) 2005-2007 by Pieter Palmers 6 3 * 7 * http://freebob.sf.net 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 8 6 * 9 * Copyright (C) 2007 Pieter Palmers <pieterpalmers@users.sourceforge.net>7 * FFADO is based upon FreeBoB 10 8 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 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; 15 12 * 16 * This programis distributed in the hope that it will be useful,17 * but WITHOUT ANY WARRANTY {}without even the implied warranty of18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the19 * GNUGeneral Public License for more details.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. 20 17 * 21 * You should have received a copy of the GNU General Public License22 * along with this program {}if not, write to the Free Software23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.24 * 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 25 22 */ 26 23 … … 86 83 return false; 87 84 } 88 85 89 86 m_server = lo_server_thread_new(m_port.c_str(), error_cb); 90 87 91 88 if (m_server == NULL) { 92 89 debugWarning("Could not start OSC server on port %s, trying other port...\n", m_port.c_str()); … … 96 93 return false; 97 94 } 98 debugWarning("Started OSC server at %s\n", 95 debugWarning("Started OSC server at %s\n", 99 96 lo_server_get_url(lo_server_thread_get_server(m_server))); 100 97 } else { 101 98 debugOutput(DEBUG_LEVEL_VERBOSE, 102 "Started OSC server at %s\n", 99 "Started OSC server at %s\n", 103 100 lo_server_get_url(lo_server_thread_get_server(m_server))); 104 101 } 105 102 106 103 // For debugging, print all incoming OSC messages 107 104 lo_server_thread_add_method(m_server, NULL, NULL, generic_cb, this); … … 134 131 OscServer *server=reinterpret_cast<OscServer *>(user_data); 135 132 assert(server); 136 133 137 134 debugOutput(DEBUG_LEVEL_VERBOSE, "Message on: %s\n", path); 138 135 … … 144 141 // construct the message 145 142 OscMessage m = OscMessage(path, types, argv, argc); 146 143 147 144 #ifdef DEBUG 148 145 if (getDebugLevel()>=DEBUG_LEVEL_VERY_VERBOSE) { … … 162 159 // send response 163 160 lo_address addr = lo_message_get_source(msg); 164 161 165 162 lo_message lo_msg; 166 163 lo_msg=r.getMessage().makeLoMessage(); 167 164 168 165 debugOutput(DEBUG_LEVEL_VERBOSE, " Sending response to %s\n",lo_address_get_url(addr)); 169 166 170 167 #ifdef DEBUG 171 168 if(getDebugLevel()>=DEBUG_LEVEL_VERY_VERBOSE) r.getMessage().print(); 172 169 #endif 173 170 174 171 if (lo_send_message(addr, "/response", lo_msg) < 0) { 175 172 debugError("Failed to send response\n"); trunk/libffado/src/libosc/OscServer.h
r436 r445 1 /* $Id$ */ 1 /* 2 * Copyright (C) 2005-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 */ 2 23 3 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2007 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 27 */ 28 #ifndef __FREEBOB_OSCSERVER__ 29 #define __FREEBOB_OSCSERVER__ 24 #ifndef __FFADO_OSCSERVER__ 25 #define __FFADO_OSCSERVER__ 30 26 31 27 #include <lo/lo.h> … … 46 42 OscServer(string port); 47 43 virtual ~OscServer(); 48 44 49 45 bool init(); 50 46 bool start(); 51 47 bool stop(); 52 48 53 49 bool registerAtRootNode(OscNode *); 54 50 bool unregisterAtRootNode(OscNode *); 55 51 56 52 private: 57 static void error_cb(int num, const char* msg, const char* path); 53 static void error_cb(int num, const char* msg, const char* path); 58 54 static int generic_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg, void* user_data); 59 55 60 56 protected: 61 57 string m_port; 62 58 lo_server_thread m_server; 63 59 64 60 OscNode * m_rootNode; 65 61 … … 73 69 } // end of namespace OSC 74 70 75 #endif /* __F REEBOB_OSCSERVER__ */71 #endif /* __FFADO_OSCSERVER__ */ 76 72 77 73 trunk/libffado/src/libosc/unittests.cpp
r432 r445 1 /* unittests.cpp 2 * Copyright (C) 2006,07 by Daniel Wagner 3 * 4 * This file is part of FreeBoB. 5 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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 is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU General Public License version 2 12 * as published by the Free Software Foundation. 13 * 14 * FFADO is distributed in the hope that it will be useful, 11 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the … … 14 18 * 15 19 * You should have received a copy of the GNU General Public License 16 * along with F reeBoB; if not, write to the Free Software20 * along with FFADO; if not, write to the Free Software 17 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 18 22 * MA 02111-1307 USA. 19 23 */ 20 21 24 22 25 #include "OscServer.h" … … 36 39 #define TEST_SHOULD_RETURN_FALSE(test) \ 37 40 (test ? printf( "'" #test "' should return true\n") && false : true ) 38 41 39 42 static int run=0; 40 43 … … 50 53 bool result=true; 51 54 OscMessage m=OscMessage(); 52 55 53 56 m.addArgument((float)1.1); 54 57 m.addArgument("teststring"); 55 58 m.addArgument(1); 56 59 m.print(); 57 60 58 61 result &= TEST_SHOULD_RETURN_TRUE(m.nbArguments()==3); 59 62 result &= TEST_SHOULD_RETURN_TRUE(m.getArgument(0).getFloat()==(float)1.1); 60 63 result &= TEST_SHOULD_RETURN_TRUE(m.getArgument(1).getString()==string("teststring")); 61 64 result &= TEST_SHOULD_RETURN_TRUE(m.getArgument(2).getInt()==1); 62 65 63 66 return result; 64 67 } … … 69 72 bool result=true; 70 73 OscMessage m=OscMessage(); 71 74 72 75 OscNode n1=OscNode("base1"); 73 76 OscNode n2=OscNode("child1"); … … 75 78 OscNode n4=OscNode("subchild1"); 76 79 OscNode n5=OscNode("subchild2"); 77 80 78 81 OscNode n6=OscNode("subsubchild1"); 79 82 OscNode n7=OscNode("subsubchild2"); 80 83 81 84 OscNode n8=OscNode("auto1"); 82 85 OscNode n9=OscNode("auto2"); 83 86 84 87 n1.addChildOscNode(&n2); 85 88 n1.addChildOscNode(&n3); 86 89 n2.addChildOscNode(&n4); 87 90 n2.addChildOscNode(&n5); 88 91 89 92 n1.addChildOscNode(&n6,"base1/child1/"); 90 93 n1.addChildOscNode(&n7,"base1/child1/"); 91 94 92 95 n1.addChildOscNode(&n8,"auto1/test/"); 93 96 n1.addChildOscNode(&n9,"auto1/test2/"); 94 97 95 98 n1.printOscNode(); 96 99 97 100 result &= TEST_SHOULD_RETURN_FALSE(n1.processOscMessage("base1",&m).isError()); 98 101 result &= TEST_SHOULD_RETURN_FALSE(n1.processOscMessage("base1/child1",&m).isError()); … … 102 105 result &= TEST_SHOULD_RETURN_FALSE(n1.processOscMessage("base1/child2",&m).isError()); 103 106 result &= TEST_SHOULD_RETURN_TRUE(n1.processOscMessage("base1/child2/subchild1",&m).isError()); 104 107 105 108 return result; 106 109 } … … 108 111 //////////////////////////////// 109 112 110 class OscTestNode 113 class OscTestNode 111 114 : public OscNode 112 115 { … … 124 127 test_OscServer_T1() { 125 128 bool result=true; 126 129 127 130 OscServer s=OscServer("17820"); 128 131 129 132 if (!s.init()) { 130 133 printf("failed to init server"); 131 134 return false; 132 135 } 133 136 134 137 OscNode n1=OscNode("base1"); 135 138 OscNode n2=OscNode("child1"); … … 137 140 OscNode n4=OscNode("subchild1"); 138 141 OscNode n5=OscNode("subchild2"); 139 142 140 143 OscNode n6=OscNode("subsubchild1"); 141 144 OscNode n7=OscNode("subsubchild2"); 142 145 143 146 OscNode n8=OscNode("auto1"); 144 147 OscNode n9=OscNode("auto2"); 145 148 146 149 n1.addChildOscNode(&n2); 147 150 n1.addChildOscNode(&n3); 148 151 n2.addChildOscNode(&n4); 149 152 n2.addChildOscNode(&n5); 150 153 151 154 n1.addChildOscNode(&n6,"base1/child1/"); 152 155 n1.addChildOscNode(&n7,"base1/child1/"); 153 156 154 157 n1.addChildOscNode(&n8,"auto1/test/"); 155 158 n1.addChildOscNode(&n9,"auto1/test2/"); 156 159 157 160 OscTestNode n10=OscTestNode("base2"); 158 161 159 162 if (!s.registerAtRootNode(&n1)) { 160 163 printf("failed to register base1 at server"); … … 165 168 return false; 166 169 } 167 170 168 171 if (!s.start()) { 169 172 printf("failed to start server"); 170 173 return false; 171 174 } 172 175 173 176 printf("server started\n"); 174 177 printf("press ctrl-c to stop it & continue\n"); 175 178 176 179 signal (SIGINT, sighandler); 177 180 178 181 run=1; 179 182 while(run) { … … 183 186 } 184 187 signal (SIGINT, SIG_DFL); 185 188 186 189 if (!s.stop()) { 187 190 printf("failed to stop server"); 188 191 return false; 189 192 } 190 193 191 194 if (!s.unregisterAtRootNode(&n1)) { 192 195 printf("failed to unregister base1 at server"); … … 197 200 return false; 198 201 } 199 202 200 203 return result; 201 204 } trunk/libffado/src/libstreaming/AmdtpPort.cpp
r419 r445 1 /* $Id$ */ 1 /* 2 * Copyright (C) 2005-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 */ 2 23 3 /*4 * FreeBob Streaming API5 * FreeBob = Firewire (pro-)audio for linux6 *7 * http://freebob.sf.net8 *9 * Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net>10 *11 * This program is free software {} you can redistribute it and/or modify12 * it under the terms of the GNU General Public License as published by13 * the Free Software Foundation {} either version 2 of the License, or14 * (at your option) any later version.15 *16 * This program is distributed in the hope that it will be useful,17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the19 * GNU General Public License for more details.20 *21 * You should have received a copy of the GNU General Public License22 * along with this program {} if not, write to the Free Software23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.24 *25 *26 *27 */28 24 #include "AmdtpPort.h" 29 25 #include <assert.h> trunk/libffado/src/libstreaming/AmdtpPort.h
r419 r445 1 /* $Id$ */ 1 /* 2 * Copyright (C) 2005-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 */ 2 23 3 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 27 */ 28 #ifndef __FREEBOB_AMDTPPORT__ 29 #define __FREEBOB_AMDTPPORT__ 24 #ifndef __FFADO_AMDTPPORT__ 25 #define __FFADO_AMDTPPORT__ 30 26 31 27 /** … … 43 39 44 40 The AMDTP/AM824/IEC61883-6 port that represents audio. 45 41 46 42 */ 47 class AmdtpAudioPort 48 : public AudioPort, public AmdtpPortInfo43 class AmdtpAudioPort 44 : public AudioPort, public AmdtpPortInfo 49 45 { 50 46 51 47 public: 52 48 53 AmdtpAudioPort(std::string name, 54 enum E_Direction direction,55 int position, 56 int location, 57 enum E_Formats format)58 : AudioPort(name, direction),59 AmdtpPortInfo(name, position, location, format)60 {};49 AmdtpAudioPort(std::string name, 50 enum E_Direction direction, 51 int position, 52 int location, 53 enum E_Formats format) 54 : AudioPort(name, direction), 55 AmdtpPortInfo(name, position, location, format) 56 {}; 61 57 62 virtual ~AmdtpAudioPort() {};63 58 virtual ~AmdtpAudioPort() {}; 59 64 60 protected: 65 61 … … 70 66 71 67 The AMDTP/AM824/IEC61883-6 port that represents midi. 72 68 73 69 */ 74 class AmdtpMidiPort 75 : public MidiPort, public AmdtpPortInfo70 class AmdtpMidiPort 71 : public MidiPort, public AmdtpPortInfo 76 72 { 77 73 78 74 public: 79 75 80 AmdtpMidiPort(std::string name, 81 enum E_Direction direction,82 int position, 83 int location, 84 enum E_Formats format)85 : MidiPort(name, direction),86 AmdtpPortInfo(name, position, location, format) 87 {};76 AmdtpMidiPort(std::string name, 77 enum E_Direction direction, 78 int position, 79 int location, 80 enum E_Formats format) 81 : MidiPort(name, direction), 82 AmdtpPortInfo(name, position, location, format) 83 {}; 88 84 89 85 90 virtual ~AmdtpMidiPort() {};86 virtual ~AmdtpMidiPort() {}; 91 87 92 88 protected: 93 89 94 90 }; 95 91 96 92 } // end of namespace Streaming 97 93 98 #endif /* __F REEBOB_AMDTPPORT__ */94 #endif /* __FFADO_AMDTPPORT__ */ trunk/libffado/src/libstreaming/AmdtpPortInfo.cpp
r419 r445 1 /* $Id$ */ 1 /* 2 * Copyright (C) 2005-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 */ 2 23 3 /*4 * FreeBob Streaming API5 * FreeBob = Firewire (pro-)audio for linux6 *7 * http://freebob.sf.net8 *9 * Copyright (C) 2005,2006,2007 Pieter Palmers <pieterpalmers@users.sourceforge.net>10 *11 * This program is free software {} you can redistribute it and/or modify12 * it under the terms of the GNU General Public License as published by13 * the Free Software Foundation {} either version 2 of the License, or14 * (at your option) any later version.15 *16 * This program is distributed in the hope that it will be useful,17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the19 * GNU General Public License for more details.20 *21 * You should have received a copy of the GNU General Public License22 * along with this program {} if not, write to the Free Software23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.24 *25 *26 *27 */28 24 #include "AmdtpPortInfo.h" 29 25 #include <assert.h> trunk/libffado/src/libstreaming/AmdtpPortInfo.h
r419 r445 1 /* $Id$ */ 1 /* 2 * Copyright (C) 2005-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 */ 2 23 3 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2005,2006,2007 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 27 */ 28 #ifndef __FREEBOB_AMDTPPORTINFO__ 29 #define __FREEBOB_AMDTPPORTINFO__ 24 #ifndef __FFADO_AMDTPPORTINFO__ 25 #define __FFADO_AMDTPPORTINFO__ 30 26 31 27 #include "../debugmodule/debugmodule.h" … … 37 33 38 34 Contains the information that maps the port to an AMDTP stream position (i.e. channel) 39 this allows the AMDTP stream demultiplexer to find the channel associated 35 this allows the AMDTP stream demultiplexer to find the channel associated 40 36 to this port. 41 37 42 38 */ 43 39 class AmdtpPortInfo { … … 45 41 public: 46 42 /** 47 * Sometimes a channel can have multiple formats, depending on the 43 * Sometimes a channel can have multiple formats, depending on the 48 44 * device configuration (e.g. an SPDIF port could be plain audio in 24bit integer 49 * or AC3 passthrough in IEC compliant frames.) 45 * or AC3 passthrough in IEC compliant frames.) 50 46 * 51 47 * This kind of enum allows to discriminate these formats when decoding 52 48 * If all channels always have the same format, you won't be needing this 53 49 */ 54 enum E_Formats {55 E_MBLA, ///< multibit linear audio56 E_Midi, ///< midi57 E_SPDIF,///< IEC.... format58 };50 enum E_Formats { 51 E_MBLA, ///< multibit linear audio 52 E_Midi, ///< midi 53 E_SPDIF,///< IEC.... format 54 }; 59 55 60 AmdtpPortInfo(std::string name, int position, int location, enum E_Formats format)61 : m_name(name), m_position(position), m_location(location), m_format(format)62 {};63 virtual ~AmdtpPortInfo() {};56 AmdtpPortInfo(std::string name, int position, int location, enum E_Formats format) 57 : m_name(name), m_position(position), m_location(location), m_format(format) 58 {}; 59 virtual ~AmdtpPortInfo() {}; 64 60 65 61 66 std::string getName() {return m_name;};67 int getLocation() {return m_location;};68 int getPosition() {return m_position;};69 enum E_Formats getFormat() {return m_format;};62 std::string getName() {return m_name;}; 63 int getLocation() {return m_location;}; 64 int getPosition() {return m_position;}; 65 enum E_Formats getFormat() {return m_format;}; 70 66 71 67 protected: … … 80 76 } // end of namespace Streaming 81 77 82 #endif /* __F REEBOB_AMDTPPORTINFO__ */78 #endif /* __FFADO_AMDTPPORTINFO__ */ trunk/libffado/src/libstreaming/AmdtpSlaveStreamProcessor.cpp
r435 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 2 * Copyright (C) 2005-2007 by Pieter Palmers 6 3 * 7 * http://freebob.sf.net 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 8 6 * 9 * Copyright (C) 2005,2006,2007 Pieter Palmers <pieterpalmers@users.sourceforge.net>7 * FFADO is based upon FreeBoB. 10 8 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 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; 15 12 * 16 * This programis distributed in the hope that it will be useful,17 * but WITHOUT ANY WARRANTY {}without even the implied warranty of18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the19 * GNUGeneral Public License for more details.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. 20 17 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 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 27 22 */ 23 28 24 #include "AmdtpSlaveStreamProcessor.h" 29 25 … … 53 49 enum raw1394_iso_disposition 54 50 AmdtpSlaveTransmitStreamProcessor::getPacket(unsigned char *data, unsigned int *length, 55 unsigned char *tag, unsigned char *sy,56 int cycle, unsigned int dropped, unsigned int max_length) {57 51 unsigned char *tag, unsigned char *sy, 52 int cycle, unsigned int dropped, unsigned int max_length) { 53 58 54 struct iec61883_packet *packet = (struct iec61883_packet *) data; 59 55 if (cycle<0) return RAW1394_ISO_OK; 60 56 61 57 m_last_cycle=cycle; 62 58 63 59 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Xmit handler for cycle %d, (running=%d, enabled=%d,%d)\n", 64 60 cycle, m_running, m_disabled, m_is_disabled); 65 61 66 62 #ifdef DEBUG 67 63 if(dropped>0) { … … 69 65 } 70 66 #endif 71 67 72 68 // calculate & preset common values 73 69 74 70 /* Our node ID can change after a bus reset, so it is best to fetch 75 71 * our node ID for each packet. */ … … 84 80 packet->eoh1 = 2; 85 81 packet->fmt = IEC61883_FMT_AMDTP; 86 82 87 83 *tag = IEC61883_TAG_WITH_CIP; 88 84 *sy = 0; 89 85 90 86 // determine if we want to send a packet or not 91 87 // note that we can't use getCycleTimer directly here, 92 88 // because packets are queued in advance. This means that 93 // we the packet we are constructing will be sent out 89 // we the packet we are constructing will be sent out 94 90 // on 'cycle', not 'now'. 95 91 unsigned int ctr=m_handler->getCycleTimer(); 96 92 int now_cycles = (int)CYCLE_TIMER_GET_CYCLES(ctr); 97 93 98 94 // the difference between the cycle this 99 95 // packet is intended for and 'now' 100 96 int cycle_diff = diffCycles(cycle, now_cycles); 101 97 102 98 #ifdef DEBUG 103 99 if(m_running && (cycle_diff < 0)) { … … 114 110 debugOutput(DEBUG_LEVEL_VERBOSE, "Xmit StreamProcessor %p started running at cycle %d\n",this, cycle); 115 111 m_running=true; 116 112 117 113 uint32_t ticks_to_advance = TICKS_PER_CYCLE * TRANSMIT_ADVANCE_CYCLES; 118 114 119 115 // if cycle lies cycle_diff cycles in the future, the 120 116 // timestamp for it corresponds to 121 117 // now+cycle_diff * TICKS_PER_CYCLE 122 118 ticks_to_advance += cycle_diff * TICKS_PER_CYCLE; 123 119 124 120 // determine the 'now' time in ticks 125 121 uint32_t cycle_timer=CYCLE_TIMER_TO_TICKS(ctr); 126 122 127 123 cycle_timer = addTicks(cycle_timer, ticks_to_advance); 128 124 m_data_buffer->setBufferHeadTimestamp(cycle_timer); 129 125 } 130 126 131 127 uint64_t ts_head, fc; 132 128 if (!m_disabled && m_is_disabled) { // this means that we are trying to enable 133 129 // check if we are on or past the enable point 134 130 int cycles_past_enable=diffCycles(cycle, m_cycle_to_enable_at); 135 131 136 132 if (cycles_past_enable >= 0) { 137 133 m_is_disabled=false; 138 134 139 135 debugOutput(DEBUG_LEVEL_VERBOSE,"Enabling StreamProcessor %p at %u\n", this, cycle); 140 136 141 137 // initialize the buffer head & tail 142 138 m_SyncSource->m_data_buffer->getBufferHeadTimestamp(&ts_head, &fc); // thread safe 143 139 144 140 // the number of cycles the sync source lags (> 0) 145 141 // or leads (< 0) 146 142 int sync_lag_cycles=diffCycles(cycle, m_SyncSource->getLastCycle()); 147 143 148 144 // account for the cycle lag between sync SP and this SP 149 145 // the last update of the sync source's timestamps was sync_lag_cycles 150 146 // cycles before the cycle we are calculating the timestamp for. 151 // if we were to use one-frame buffers, you would expect the 147 // if we were to use one-frame buffers, you would expect the 152 148 // frame that is sent on cycle CT to have a timestamp T1. 153 149 // ts_head however is for cycle CT-sync_lag_cycles, and lies … … 155 151 // T1. 156 152 ts_head = addTicks(ts_head, (sync_lag_cycles) * TICKS_PER_CYCLE); 157 153 158 154 ts_head = substractTicks(ts_head, TICKS_PER_CYCLE); 159 155 160 156 // account for the number of cycles we are too late to enable 161 157 ts_head = addTicks(ts_head, cycles_past_enable * TICKS_PER_CYCLE); 162 158 163 159 // account for one extra packet of frames 164 ts_head = substractTicks(ts_head, 160 ts_head = substractTicks(ts_head, 165 161 (uint32_t)((float)m_syt_interval * m_SyncSource->m_data_buffer->getRate())); 166 162 … … 181 177 } else if (m_disabled && !m_is_disabled) { 182 178 // trying to disable 183 debugOutput(DEBUG_LEVEL_VERBOSE,"disabling StreamProcessor %p at %u\n", 179 debugOutput(DEBUG_LEVEL_VERBOSE,"disabling StreamProcessor %p at %u\n", 184 180 this, cycle); 185 181 m_is_disabled=true; 186 182 } 187 183 188 184 // the base timestamp is the one of the next sample in the buffer 189 185 m_data_buffer->getBufferHeadTimestamp(&ts_head, &fc); // thread safe … … 191 187 // we send a packet some cycles in advance, to avoid the 192 188 // following situation: 193 // suppose we are only a few ticks away from 189 // suppose we are only a few ticks away from 194 190 // the moment to send this packet. therefore we decide 195 191 // not to send the packet, but send it in the next cycle. 196 192 // This means that the next time point will be 3072 ticks 197 // later, making that the timestamp will be expired when the 193 // later, making that the timestamp will be expired when the 198 194 // packet is sent, unless TRANSFER_DELAY > 3072. 199 195 // this means that we need at least one cycle of extra buffering. 200 196 uint32_t ticks_to_advance = TICKS_PER_CYCLE * TRANSMIT_ADVANCE_CYCLES; 201 197 202 198 // if cycle lies cycle_diff cycles in the future, we should 203 199 // queue this packet cycle_diff * TICKS_PER_CYCLE earlier than … … 207 203 // determine the 'now' time in ticks 208 204 uint32_t cycle_timer=CYCLE_TIMER_TO_TICKS(ctr); 209 205 210 206 cycle_timer = addTicks(cycle_timer, ticks_to_advance); 211 207 212 208 // time until the packet is to be sent (if > 0: send packet) 213 209 int32_t until_next=diffTicks(ts_head, cycle_timer); … … 218 214 // add the transmit transfer delay to construct the playout time (=SYT timestamp) 219 215 uint32_t ts_packet=addTicks(ts_head, TRANSMIT_TRANSFER_DELAY); 220 216 221 217 // if we are disabled, send a silent packet 222 218 // and advance the buffer head timestamp 223 219 if(m_is_disabled) { 224 220 225 221 transmitSilenceBlock((char *)(data+8), m_syt_interval, 0); 226 222 m_dbc += fillDataPacketHeader(packet, length, ts_packet); 227 223 228 224 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "XMIT SYNC: CY=%04u TSH=%011llu TSP=%011lu\n", 229 225 cycle, ts_head, ts_packet); … … 232 228 uint32_t ts_step=(uint32_t)((float)(m_syt_interval) 233 229 *m_SyncSource->m_data_buffer->getRate()); 234 230 235 231 // the next buffer head timestamp 236 232 ts_head=addTicks(ts_head,ts_step); 237 233 m_data_buffer->setBufferHeadTimestamp(ts_head); 238 234 239 235 // defer to make sure we get to be enabled asap 240 236 return RAW1394_ISO_DEFER; 241 237 242 238 } else { // enabled & packet due, read from the buffer 243 239 if (m_data_buffer->readFrames(m_syt_interval, (char *)(data + 8))) { 244 240 m_dbc += fillDataPacketHeader(packet, length, ts_packet); 245 241 246 242 // process all ports that should be handled on a per-packet base 247 243 // this is MIDI for AMDTP (due to the need of DBC) … … 249 245 debugWarning("Problem encoding Packet Ports\n"); 250 246 } 251 247 252 248 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "XMIT DATA: CY=%04u TSH=%011llu TSP=%011lu\n", 253 249 cycle, ts_head, ts_packet); 254 250 255 251 return RAW1394_ISO_OK; 256 252 257 253 } else if (now_cycles<cycle) { 258 254 // we can still postpone the queueing of the packets 259 255 // because the ISO transmit packet buffer is not empty yet 260 256 return RAW1394_ISO_AGAIN; 261 257 262 258 } else { // there is no more data in the ringbuffer 263 259 // compose a silent packet, we should always … … 265 261 transmitSilenceBlock((char *)(data+8), m_syt_interval, 0); 266 262 m_dbc += fillDataPacketHeader(packet, length, ts_packet); 267 268 debugWarning("Transmit buffer underrun (now %d, queue %d, target %d)\n", 263 264 debugWarning("Transmit buffer underrun (now %d, queue %d, target %d)\n", 269 265 now_cycles, cycle, TICKS_TO_CYCLES(ts_packet)); 270 266 // signal underrun … … 274 270 m_disabled=true; 275 271 m_is_disabled=true; 276 272 277 273 return RAW1394_ISO_DEFER; 278 274 } 279 275 } 280 276 281 277 } else { // no packet due, send no-data packet 282 278 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "XMIT NONE: CY=%04u TSH=%011llu\n", 283 279 cycle, ts_head); 284 280 285 281 m_dbc += fillNoDataPacketHeader(packet, length); 286 282 return RAW1394_ISO_DEFER; 287 283 } 288 284 289 285 // we shouldn't get here 290 286 return RAW1394_ISO_ERROR; … … 298 294 {} 299 295 300 AmdtpSlaveReceiveStreamProcessor::~AmdtpSlaveReceiveStreamProcessor() 296 AmdtpSlaveReceiveStreamProcessor::~AmdtpSlaveReceiveStreamProcessor() 301 297 {} 302 298 303 enum raw1394_iso_disposition 304 AmdtpSlaveReceiveStreamProcessor::putPacket(unsigned char *data, unsigned int length, 305 unsigned char channel, unsigned char tag, unsigned char sy, 299 enum raw1394_iso_disposition 300 AmdtpSlaveReceiveStreamProcessor::putPacket(unsigned char *data, unsigned int length, 301 unsigned char channel, unsigned char tag, unsigned char sy, 306 302 unsigned int cycle, unsigned int dropped) { 307 303 308 304 enum raw1394_iso_disposition retval=RAW1394_ISO_OK; 309 305 m_last_cycle=cycle; 310 306 311 307 struct iec61883_packet *packet = (struct iec61883_packet *) data; 312 308 assert(packet); … … 318 314 319 315 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"ch%2u: CY=%4u, SYT=%08X (%4ucy + %04uticks) (running=%d, disabled=%d,%d)\n", 320 channel, cycle,ntohs(packet->syt), 316 channel, cycle,ntohs(packet->syt), 321 317 CYCLE_TIMER_GET_CYCLES(ntohs(packet->syt)), CYCLE_TIMER_GET_OFFSET(ntohs(packet->syt)), 322 318 m_running,m_disabled,m_is_disabled); 323 319 324 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, 325 "RCV: CH = %d, FDF = %X. SYT = %6d, DBS = %3d, DBC = %3d, FMT = %3d, LEN = %4d\n", 320 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, 321 "RCV: CH = %d, FDF = %X. SYT = %6d, DBS = %3d, DBC = %3d, FMT = %3d, LEN = %4d\n", 326 322 channel, packet->fdf, 327 323 packet->syt, 328 324 packet->dbs, 329 325 packet->dbc, 330 packet->fmt, 326 packet->fmt, 331 327 length); 332 328 … … 336 332 // check if we are on or past the enable point 337 333 int cycles_past_enable=diffCycles(cycle, m_cycle_to_enable_at); 338 334 339 335 if (cycles_past_enable >= 0) { 340 336 m_is_disabled=false; 341 debugOutput(DEBUG_LEVEL_VERBOSE,"Enabling StreamProcessor %p at %d (SYT=%04X)\n", 337 debugOutput(DEBUG_LEVEL_VERBOSE,"Enabling StreamProcessor %p at %d (SYT=%04X)\n", 342 338 this, cycle, ntohs(packet->syt)); 343 339 // the previous timestamp is the one we need to start with … … 358 354 359 355 // check if this is a valid packet 360 if((packet->syt != 0xFFFF) 361 && (packet->fdf != 0xFF) 356 if((packet->syt != 0xFFFF) 357 && (packet->fdf != 0xFF) 362 358 && (packet->fmt == 0x10) 363 && (packet->dbs>0) 359 && (packet->dbs>0) 364 360 && (length>=2*sizeof(quadlet_t))) { 365 361 366 362 unsigned int nevents=((length / sizeof (quadlet_t)) - 2)/packet->dbs; 367 363 … … 370 366 371 367 //=> convert the SYT to a full timestamp in ticks 372 m_last_timestamp=sytRecvToFullTicks((uint32_t)ntohs(packet->syt), 368 m_last_timestamp=sytRecvToFullTicks((uint32_t)ntohs(packet->syt), 373 369 cycle, m_handler->getCycleTimer()); 374 370 375 371 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "RECV: CY=%04u TS=%011llu\n", 376 372 cycle, m_last_timestamp); 377 373 378 374 // we have to keep in mind that there are also 379 375 // some packets buffered by the ISO layer, … … 385 381 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"STMP: %lluticks | buff=%d, syt_interval=%d, tpf=%f\n", 386 382 m_last_timestamp, m_handler->getWakeupInterval(),m_syt_interval,m_ticks_per_frame); 387 383 388 384 //=> signal that we're running (if we are) 389 385 if(!m_running && nevents && m_last_timestamp2 && m_last_timestamp) { … … 399 395 // estimate as to when a period might be ready. i.e. it will not 400 396 // be ready earlier than this timestamp + period time 401 402 // the next (possible) sample is not this one, but lies 397 398 // the next (possible) sample is not this one, but lies 403 399 // SYT_INTERVAL * rate later 404 400 uint64_t ts=addTicks(m_last_timestamp, … … 408 404 // the buffer by the next packet. 409 405 m_data_buffer->setBufferTailTimestamp(ts); 410 406 411 407 return RAW1394_ISO_DEFER; 412 408 } 413 409 414 410 #ifdef DEBUG_OFF 415 if((cycle % 1000) == 0) 411 if((cycle % 1000) == 0) 416 412 { 417 413 uint32_t syt = (uint32_t)ntohs(packet->syt); 418 414 uint32_t now=m_handler->getCycleTimer(); 419 415 uint32_t now_ticks=CYCLE_TIMER_TO_TICKS(now); 420 416 421 417 uint32_t test_ts=sytRecvToFullTicks(syt, cycle, now); 422 418 … … 432 428 } 433 429 #endif 434 430 435 431 //=> process the packet 436 432 // add the data payload to the ringbuffer 437 if(m_data_buffer->writeFrames(nevents, (char *)(data+8), m_last_timestamp)) { 433 if(m_data_buffer->writeFrames(nevents, (char *)(data+8), m_last_timestamp)) { 438 434 retval=RAW1394_ISO_OK; 439 435 440 436 // process all ports that should be handled on a per-packet base 441 437 // this is MIDI for AMDTP (due to the need of DBC) … … 444 440 retval=RAW1394_ISO_DEFER; 445 441 } 446 442 447 443 } else { 448 449 debugWarning("Receive buffer overrun (cycle %d, FC=%d, PC=%d)\n", 444 445 debugWarning("Receive buffer overrun (cycle %d, FC=%d, PC=%d)\n", 450 446 cycle, m_data_buffer->getFrameCounter(), m_handler->getPacketCount()); 451 447 452 448 m_xruns++; 453 449 454 450 // disable the processing, will be re-enabled when 455 451 // the xrun is handled trunk/libffado/src/libstreaming/AmdtpSlaveStreamProcessor.h
r435 r445 1 /* $Id$ */ 1 /* 2 * Copyright (C) 2005-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 */ 2 23 3 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2005,2006,2007 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 27 */ 28 #ifndef __FREEBOB_AMDTPSLAVESTREAMPROCESSOR__ 29 #define __FREEBOB_AMDTPSLAVESTREAMPROCESSOR__ 24 #ifndef __FFADO_AMDTPSLAVESTREAMPROCESSOR__ 25 #define __FFADO_AMDTPSLAVESTREAMPROCESSOR__ 30 26 31 27 /** … … 46 42 #define IEC61883_STREAM_TYPE_MBLA 0x06 47 43 48 #define IEC61883_AM824_LABEL_MASK 0xFF00000049 #define IEC61883_AM824_GET_LABEL(x) (((x) & 0xFF000000) >> 24)50 #define IEC61883_AM824_SET_LABEL(x,y) ((x) | ((y)<<24))44 #define IEC61883_AM824_LABEL_MASK 0xFF000000 45 #define IEC61883_AM824_GET_LABEL(x) (((x) & 0xFF000000) >> 24) 46 #define IEC61883_AM824_SET_LABEL(x,y) ((x) | ((y)<<24)) 51 47 52 #define IEC61883_AM824_LABEL_MIDI_NO_DATA 0x8053 #define IEC61883_AM824_LABEL_MIDI_1X 0x8154 #define IEC61883_AM824_LABEL_MIDI_2X 0x8255 #define IEC61883_AM824_LABEL_MIDI_3X 0x8348 #define IEC61883_AM824_LABEL_MIDI_NO_DATA 0x80 49 #define IEC61883_AM824_LABEL_MIDI_1X 0x81 50 #define IEC61883_AM824_LABEL_MIDI_2X 0x82 51 #define IEC61883_AM824_LABEL_MIDI_3X 0x83 56 52 57 53 namespace Streaming { … … 59 55 class AmdtpSlaveReceiveStreamProcessor; 60 56 61 class AmdtpSlaveTransmitStreamProcessor 57 class AmdtpSlaveTransmitStreamProcessor 62 58 : public AmdtpTransmitStreamProcessor 63 59 { … … 68 64 virtual ~AmdtpSlaveTransmitStreamProcessor(); 69 65 70 enum raw1394_iso_disposition 66 enum raw1394_iso_disposition 71 67 getPacket(unsigned char *data, unsigned int *length, 72 68 unsigned char *tag, unsigned char *sy, … … 75 71 }; 76 72 77 class AmdtpSlaveReceiveStreamProcessor 73 class AmdtpSlaveReceiveStreamProcessor 78 74 : public AmdtpReceiveStreamProcessor 79 75 { … … 84 80 virtual ~AmdtpSlaveReceiveStreamProcessor(); 85 81 86 enum raw1394_iso_disposition putPacket(unsigned char *data, unsigned int length, 87 unsigned char channel, unsigned char tag, unsigned char sy, 82 enum raw1394_iso_disposition putPacket(unsigned char *data, unsigned int length, 83 unsigned char channel, unsigned char tag, unsigned char sy, 88 84 unsigned int cycle, unsigned int dropped); 89 85 … … 93 89 } // end of namespace Streaming 94 90 95 #endif /* __F REEBOB_AMDTPSLAVESTREAMPROCESSOR__ */91 #endif /* __FFADO_AMDTPSLAVESTREAMPROCESSOR__ */ 96 92 trunk/libffado/src/libstreaming/AmdtpStreamProcessor.cpp
r435 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 2 * Copyright (C) 2005-2007 by Pieter Palmers 6 3 * 7 * http://freebob.sf.net 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 8 6 * 9 * Copyright (C) 2005,2006,2007 Pieter Palmers <pieterpalmers@users.sourceforge.net>7 * FFADO is based upon FreeBoB. 10 8 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 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; 15 12 * 16 * This programis distributed in the hope that it will be useful,17 * but WITHOUT ANY WARRANTY {}without even the implied warranty of18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the19 * GNUGeneral Public License for more details.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. 20 17 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 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 27 22 */ 23 28 24 #include "AmdtpStreamProcessor.h" 29 25 #include "Port.h" … … 59 55 60 56 /** 61 * @return 57 * @return 62 58 */ 63 59 bool AmdtpTransmitStreamProcessor::init() { 64 60 65 debugOutput( DEBUG_LEVEL_VERBOSE, "Initializing (%p)...\n");66 // call the parent init67 // this has to be done before allocating the buffers, 68 // because this sets the buffersizes from the processormanager69 if(!TransmitStreamProcessor::init()) {70 debugFatal("Could not do base class init (%p)\n",this);71 return false;72 }73 74 return true;61 debugOutput( DEBUG_LEVEL_VERBOSE, "Initializing (%p)...\n"); 62 // call the parent init 63 // this has to be done before allocating the buffers, 64 // because this sets the buffersizes from the processormanager 65 if(!TransmitStreamProcessor::init()) { 66 debugFatal("Could not do base class init (%p)\n",this); 67 return false; 68 } 69 70 return true; 75 71 } 76 72 77 73 void AmdtpTransmitStreamProcessor::setVerboseLevel(int l) { 78 setDebugLevel(l);79 TransmitStreamProcessor::setVerboseLevel(l);74 setDebugLevel(l); 75 TransmitStreamProcessor::setVerboseLevel(l); 80 76 } 81 77 82 78 enum raw1394_iso_disposition 83 79 AmdtpTransmitStreamProcessor::getPacket(unsigned char *data, unsigned int *length, 84 unsigned char *tag, unsigned char *sy,85 int cycle, unsigned int dropped, unsigned int max_length) {86 80 unsigned char *tag, unsigned char *sy, 81 int cycle, unsigned int dropped, unsigned int max_length) { 82 87 83 struct iec61883_packet *packet = (struct iec61883_packet *) data; 88 84 if (cycle<0) return RAW1394_ISO_OK; 89 85 90 86 m_last_cycle=cycle; 91 87 92 88 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Xmit handler for cycle %d, (running=%d, enabled=%d,%d)\n", 93 89 cycle, m_running, m_disabled, m_is_disabled); 94 90 95 91 #ifdef DEBUG 96 92 if(dropped>0) { … … 98 94 } 99 95 #endif 100 96 101 97 // calculate & preset common values 102 98 103 99 /* Our node ID can change after a bus reset, so it is best to fetch 104 100 * our node ID for each packet. */ … … 113 109 packet->eoh1 = 2; 114 110 packet->fmt = IEC61883_FMT_AMDTP; 115 111 116 112 *tag = IEC61883_TAG_WITH_CIP; 117 113 *sy = 0; 118 114 119 115 // determine if we want to send a packet or not 120 116 // note that we can't use getCycleTimer directly here, 121 117 // because packets are queued in advance. This means that 122 // we the packet we are constructing will be sent out 118 // we the packet we are constructing will be sent out 123 119 // on 'cycle', not 'now'. 124 120 unsigned int ctr=m_handler->getCycleTimer(); 125 121 int now_cycles = (int)CYCLE_TIMER_GET_CYCLES(ctr); 126 122 127 123 // the difference between the cycle this 128 124 // packet is intended for and 'now' 129 125 int cycle_diff = diffCycles(cycle, now_cycles); 130 126 131 127 #ifdef DEBUG 132 128 if(m_running && (cycle_diff < 0)) { … … 144 140 m_running=true; 145 141 } 146 142 147 143 uint64_t ts_head, fc; 148 144 if (!m_disabled && m_is_disabled) { // this means that we are trying to enable 149 145 // check if we are on or past the enable point 150 146 int cycles_past_enable=diffCycles(cycle, m_cycle_to_enable_at); 151 147 152 148 if (cycles_past_enable >= 0) { 153 149 m_is_disabled=false; 154 150 155 151 debugOutput(DEBUG_LEVEL_VERBOSE,"Enabling StreamProcessor %p at %u\n", this, cycle); 156 152 157 153 // initialize the buffer head & tail 158 154 m_SyncSource->m_data_buffer->getBufferHeadTimestamp(&ts_head, &fc); // thread safe 159 155 160 156 // the number of cycles the sync source lags (> 0) 161 157 // or leads (< 0) 162 158 int sync_lag_cycles=diffCycles(cycle, m_SyncSource->getLastCycle()); 163 159 164 160 // account for the cycle lag between sync SP and this SP 165 161 // the last update of the sync source's timestamps was sync_lag_cycles 166 162 // cycles before the cycle we are calculating the timestamp for. 167 // if we were to use one-frame buffers, you would expect the 163 // if we were to use one-frame buffers, you would expect the 168 164 // frame that is sent on cycle CT to have a timestamp T1. 169 165 // ts_head however is for cycle CT-sync_lag_cycles, and lies … … 171 167 // T1. 172 168 ts_head = addTicks(ts_head, (sync_lag_cycles) * TICKS_PER_CYCLE); 173 169 174 170 ts_head = substractTicks(ts_head, TICKS_PER_CYCLE); 175 171 176 172 // account for the number of cycles we are too late to enable 177 173 ts_head = addTicks(ts_head, cycles_past_enable * TICKS_PER_CYCLE); 178 174 179 175 // account for one extra packet of frames 180 ts_head = substractTicks(ts_head, 176 ts_head = substractTicks(ts_head, 181 177 (uint32_t)((float)m_syt_interval * m_SyncSource->m_data_buffer->getRate())); 182 178 … … 197 193 } else if (m_disabled && !m_is_disabled) { 198 194 // trying to disable 199 debugOutput(DEBUG_LEVEL_VERBOSE,"disabling StreamProcessor %p at %u\n", 195 debugOutput(DEBUG_LEVEL_VERBOSE,"disabling StreamProcessor %p at %u\n", 200 196 this, cycle); 201 197 m_is_disabled=true; 202 198 } 203 199 204 200 // the base timestamp is the one of the next sample in the buffer 205 201 m_data_buffer->getBufferHeadTimestamp(&ts_head, &fc); // thread safe … … 207 203 // we send a packet some cycles in advance, to avoid the 208 204 // following situation: 209 // suppose we are only a few ticks away from 205 // suppose we are only a few ticks away from 210 206 // the moment to send this packet. therefore we decide 211 207 // not to send the packet, but send it in the next cycle. 212 208 // This means that the next time point will be 3072 ticks 213 // later, making that the timestamp will be expired when the 209 // later, making that the timestamp will be expired when the 214 210 // packet is sent, unless TRANSFER_DELAY > 3072. 215 211 // this means that we need at least one cycle of extra buffering. 216 212 uint32_t ticks_to_advance = TICKS_PER_CYCLE * TRANSMIT_ADVANCE_CYCLES; 217 213 218 214 // if cycle lies cycle_diff cycles in the future, we should 219 215 // queue this packet cycle_diff * TICKS_PER_CYCLE earlier than … … 223 219 // determine the 'now' time in ticks 224 220 uint32_t cycle_timer=CYCLE_TIMER_TO_TICKS(ctr); 225 221 226 222 cycle_timer = addTicks(cycle_timer, ticks_to_advance); 227 223 228 224 // time until the packet is to be sent (if > 0: send packet) 229 225 int32_t until_next=diffTicks(ts_head, cycle_timer); … … 234 230 // add the transmit transfer delay to construct the playout time (=SYT timestamp) 235 231 uint32_t ts_packet=addTicks(ts_head, TRANSMIT_TRANSFER_DELAY); 236 232 237 233 // if we are disabled, send a silent packet 238 234 // and advance the buffer head timestamp 239 235 if(m_is_disabled) { 240 236 241 237 // transmitSilenceBlock((char *)(data+8), m_syt_interval, 0); 242 238 // m_dbc += fillDataPacketHeader(packet, length, ts_packet); 243 // 239 // 244 240 // debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "XMIT SYNC: CY=%04u TSH=%011llu TSP=%011lu\n", 245 241 // cycle, ts_head, ts_packet); 246 // 242 // 247 243 // // update the base timestamp 248 244 // uint32_t ts_step=(uint32_t)((float)(m_syt_interval) 249 245 // *m_SyncSource->m_data_buffer->getRate()); 250 // 246 // 251 247 // // the next buffer head timestamp 252 248 // ts_head=addTicks(ts_head,ts_step); 253 249 // m_data_buffer->setBufferHeadTimestamp(ts_head); 254 // 250 // 255 251 // no-data 256 252 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "XMIT SYNC: CY=%04u NONE\n", cycle); … … 258 254 // defer to make sure we get to be enabled asap 259 255 return RAW1394_ISO_DEFER; 260 256 261 257 } else { // enabled & packet due, read from the buffer 262 258 if (m_data_buffer->readFrames(m_syt_interval, (char *)(data + 8))) { 263 259 m_dbc += fillDataPacketHeader(packet, length, ts_packet); 264 260 265 261 // process all ports that should be handled on a per-packet base 266 262 // this is MIDI for AMDTP (due to the need of DBC) … … 268 264 debugWarning("Problem encoding Packet Ports\n"); 269 265 } 270 266 271 267 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "XMIT DATA: CY=%04u TSH=%011llu TSP=%011lu\n", 272 268 cycle, ts_head, ts_packet); 273 269 274 270 return RAW1394_ISO_OK; 275 271 276 272 } else if (now_cycles<cycle) { 277 273 // we can still postpone the queueing of the packets 278 274 // because the ISO transmit packet buffer is not empty yet 279 275 return RAW1394_ISO_AGAIN; 280 276 281 277 } else { // there is no more data in the ringbuffer 282 278 // compose a silent packet, we should always … … 284 280 transmitSilenceBlock((char *)(data+8), m_syt_interval, 0); 285 281 m_dbc += fillDataPacketHeader(packet, length, ts_packet); 286 287 debugWarning("Transmit buffer underrun (now %d, queue %d, target %d)\n", 282 283 debugWarning("Transmit buffer underrun (now %d, queue %d, target %d)\n", 288 284 now_cycles, cycle, TICKS_TO_CYCLES(ts_packet)); 289 285 // signal underrun … … 293 289 m_disabled=true; 294 290 m_is_disabled=true; 295 291 296 292 return RAW1394_ISO_DEFER; 297 293 } 298 294 } 299 295 300 296 } else { // no packet due, send no-data packet 301 297 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "XMIT NONE: CY=%04u TSH=%011llu\n", 302 298 cycle, ts_head); 303 299 304 300 m_dbc += fillNoDataPacketHeader(packet, length); 305 301 return RAW1394_ISO_DEFER; 306 302 } 307 303 308 304 // we shouldn't get here 309 305 return RAW1394_ISO_ERROR; … … 314 310 struct iec61883_packet *packet, unsigned int* length, 315 311 uint32_t ts) { 316 312 317 313 packet->fdf = m_fdf; 318 314 … … 320 316 uint16_t timestamp_SYT = TICKS_TO_SYT(ts); 321 317 packet->syt = ntohs(timestamp_SYT); 322 318 323 319 *length = m_syt_interval*sizeof(quadlet_t)*m_dimension + 8; 324 320 … … 328 324 unsigned int AmdtpTransmitStreamProcessor::fillNoDataPacketHeader( 329 325 struct iec61883_packet *packet, unsigned int* length) { 330 326 331 327 // no-data packets have syt=0xFFFF 332 328 // and have the usual amount of events as dummy data (?) 333 329 packet->fdf = IEC61883_FDF_NODATA; 334 330 packet->syt = 0xffff; 335 336 // FIXME: either make this a setting or choose 331 332 // FIXME: either make this a setting or choose 337 333 bool send_payload=true; 338 334 if(send_payload) { … … 355 351 356 352 debugOutput( DEBUG_LEVEL_VERBOSE, "Prefill transmit buffers...\n"); 357 353 358 354 if(!transferSilence(m_ringbuffer_size_frames)) { 359 355 debugFatal("Could not prefill transmit stream\n"); … … 372 368 m_PacketStat.reset(); 373 369 m_WakeupStat.reset(); 374 370 375 371 // we have to make sure that the buffer HEAD timestamp 376 372 // lies in the future for every possible buffer fill case. 377 373 int offset=(int)(m_ringbuffer_size_frames*m_ticks_per_frame); 378 374 379 375 m_data_buffer->setTickOffset(offset); 380 376 381 377 // reset all non-device specific stuff 382 378 // i.e. the iso stream and the associated ports … … 385 381 return false; 386 382 } 387 383 388 384 // we should prefill the event buffer 389 385 if (!prefill()) { 390 386 debugFatal("Could not prefill buffers\n"); 391 return false; 392 } 393 387 return false; 388 } 389 394 390 return true; 395 391 } … … 401 397 402 398 debugOutput( DEBUG_LEVEL_VERBOSE, "Preparing (%p)...\n", this); 403 399 404 400 // prepare all non-device specific stuff 405 401 // i.e. the iso stream and the associated ports … … 408 404 return false; 409 405 } 410 406 411 407 switch (m_framerate) { 412 408 case 32000: … … 440 436 break; 441 437 } 442 438 443 439 iec61883_cip_init ( 444 &m_cip_status, 445 IEC61883_FMT_AMDTP, 440 &m_cip_status, 441 IEC61883_FMT_AMDTP, 446 442 m_fdf, 447 m_framerate, 448 m_dimension, 443 m_framerate, 444 m_dimension, 449 445 m_syt_interval); 450 446 451 447 // prepare the framerate estimate 452 448 m_ticks_per_frame = (TICKS_PER_SECOND*1.0) / ((float)m_framerate); 453 454 // initialize internal buffer449 450 // initialize internal buffer 455 451 m_ringbuffer_size_frames=m_nb_buffers * m_period; 456 452 457 assert(m_data_buffer); 453 assert(m_data_buffer); 458 454 m_data_buffer->setBufferSize(m_ringbuffer_size_frames); 459 455 m_data_buffer->setEventSize(sizeof(quadlet_t)); 460 456 m_data_buffer->setEventsPerFrame(m_dimension); 461 457 462 458 m_data_buffer->setUpdatePeriod(m_period); 463 459 m_data_buffer->setNominalRate(m_ticks_per_frame); 464 460 465 461 m_data_buffer->setWrapValue(128L*TICKS_PER_SECOND); 466 462 467 463 m_data_buffer->prepare(); 468 464 … … 479 475 return false; 480 476 } 481 482 477 478 483 479 switch ((*it)->getPortType()) { 484 480 case Port::E_Audio: … … 497 493 return false; 498 494 } 499 495 500 496 if(!(*it)->setDataType(Port::E_Float)) { 501 497 debugFatal("Could not set data type"); 502 498 return false; 503 499 } 504 505 500 501 506 502 break; 507 503 case Port::E_Midi: … … 510 506 return false; 511 507 } 512 508 513 509 // we use a timing unit of 10ns 514 510 // this makes sure that for the max syt interval … … 527 523 return false; 528 524 } 529 525 530 526 // buffertype and datatype are dependant on the API 531 527 debugWarning("---------------- ! Doing hardcoded test setup ! --------------\n"); … … 546 542 } 547 543 548 // the API specific settings of the ports should already be set, 544 // the API specific settings of the ports should already be set, 549 545 // as this is called from the processorManager->prepare() 550 546 // so we can init the ports … … 585 581 debugOutput(DEBUG_LEVEL_VERBOSE,"Preparing to enable...\n"); 586 582 587 // for the transmit SP, we have to initialize the 583 // for the transmit SP, we have to initialize the 588 584 // buffer timestamp to something sane, because this timestamp 589 585 // is used when it is SyncSource 590 586 591 587 // the time we initialize to will determine the time at which 592 588 // the first sample in the buffer will be sent, so we should 593 589 // make it at least 'time_to_enable_at' 594 590 595 591 uint64_t now=m_handler->getCycleTimer(); 596 592 unsigned int now_secs=CYCLE_TIMER_GET_SECS(now); 597 593 598 594 // check if a wraparound on the secs will happen between 599 595 // now and the time we start 600 596 int until_enable=(int)time_to_enable_at - (int)CYCLE_TIMER_GET_CYCLES(now); 601 597 602 598 if(until_enable>4000) { 603 599 // wraparound on CYCLE_TIMER_GET_CYCLES(now) … … 616 612 uint64_t ts_head= now_secs*TICKS_PER_SECOND; 617 613 ts_head+=time_to_enable_at*TICKS_PER_CYCLE; 618 614 619 615 // we also add the nb of cycles we transmit in advance 620 616 ts_head=addTicks(ts_head, TRANSMIT_ADVANCE_CYCLES*TICKS_PER_CYCLE); 621 617 622 618 m_data_buffer->setBufferTailTimestamp(ts_head); 623 619 … … 633 629 bool AmdtpTransmitStreamProcessor::transferSilence(unsigned int nframes) { 634 630 bool retval; 635 631 636 632 char *dummybuffer=(char *)calloc(sizeof(quadlet_t),nframes*m_dimension); 637 633 638 634 transmitSilenceBlock(dummybuffer, nframes, 0); 639 635 640 636 // add the silence data to the ringbuffer 641 if(m_data_buffer->writeFrames(nframes, dummybuffer, 0)) { 637 if(m_data_buffer->writeFrames(nframes, dummybuffer, 0)) { 642 638 retval=true; 643 639 } else { … … 647 643 648 644 free(dummybuffer); 649 645 650 646 return retval; 651 647 } … … 653 649 bool AmdtpTransmitStreamProcessor::putFrames(unsigned int nbframes, int64_t ts) { 654 650 m_PeriodStat.mark(m_data_buffer->getBufferFill()); 655 651 656 652 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "AmdtpTransmitStreamProcessor::putFrames(%d, %llu)\n", nbframes, ts); 657 653 658 654 // transfer the data 659 655 m_data_buffer->blockProcessWriteFrames(nbframes, ts); … … 663 659 return true; 664 660 } 665 /* 661 /* 666 662 * write received events to the stream ringbuffers. 667 663 */ 668 664 669 bool AmdtpTransmitStreamProcessor::processWriteBlock(char *data, 665 bool AmdtpTransmitStreamProcessor::processWriteBlock(char *data, 670 666 unsigned int nevents, unsigned int offset) 671 667 { … … 678 674 679 675 if((*it)->isDisabled()) {continue;}; 680 676 681 677 //FIXME: make this into a static_cast when not DEBUG? 682 678 … … 701 697 } 702 698 703 int AmdtpTransmitStreamProcessor::transmitSilenceBlock(char *data, 699 int AmdtpTransmitStreamProcessor::transmitSilenceBlock(char *data, 704 700 unsigned int nevents, unsigned int offset) 705 701 { … … 745 741 bool ok=true; 746 742 char byte; 747 743 748 744 quadlet_t *target_event=NULL; 749 745 unsigned int j; 750 746 751 747 for ( PortVectorIterator it = m_PacketPorts.begin(); 752 748 it != m_PacketPorts.end(); … … 761 757 assert(pinfo->getFormat()==AmdtpPortInfo::E_Midi); 762 758 #endif 763 759 764 760 AmdtpMidiPort *mp=static_cast<AmdtpMidiPort *>(*it); 765 761 766 762 // we encode this directly (no function call) due to the high frequency 767 763 /* idea: 768 764 spec says: current_midi_port=(dbc+j)%8; 769 => if we start at (dbc+stream->location-1)%8, 765 => if we start at (dbc+stream->location-1)%8, 770 766 we'll start at the right event for the midi port. 771 767 => if we increment j with 8, we stay at the right event. 772 768 */ 773 // FIXME: as we know in advance how big a packet is (syt_interval) we can 769 // FIXME: as we know in advance how big a packet is (syt_interval) we can 774 770 // predict how much loops will be present here 775 771 // first prefill the buffer with NO_DATA's on all time muxed channels 776 772 777 773 for(j = (dbc & 0x07)+mp->getLocation(); j < nevents; j += 8) { 778 774 779 775 target_event=(quadlet_t *)(data + ((j * m_dimension) + mp->getPosition())); 780 776 781 777 if(mp->canRead()) { // we can send a byte 782 778 mp->readEvent(&byte); … … 784 780 IEC61883_AM824_SET_LABEL((byte)<<16, 785 781 IEC61883_AM824_LABEL_MIDI_1X)); 786 } else { 782 } else { 787 783 // can't send a byte, either because there is no byte, 788 784 // or because this would exceed the maximum rate … … 793 789 794 790 } 795 791 796 792 return ok; 797 793 } 798 794 799 795 800 int AmdtpTransmitStreamProcessor::encodePortToMBLAEvents(AmdtpAudioPort *p, quadlet_t *data, 796 int AmdtpTransmitStreamProcessor::encodePortToMBLAEvents(AmdtpAudioPort *p, quadlet_t *data, 801 797 unsigned int offset, unsigned int nevents) 802 798 { … … 833 829 buffer+=offset; 834 830 835 for(j = 0; j < nevents; j += 1) { // decode max nsamples 836 831 for(j = 0; j < nevents; j += 1) { // decode max nsamples 832 837 833 // don't care for overflow 838 834 float v = *buffer * multiplier; // v: -231 .. 231 839 835 unsigned int tmp = ((int)v); 840 836 *target_event = htonl((tmp >> 8) | 0x40000000); 841 837 842 838 buffer++; 843 839 target_event += m_dimension; … … 849 845 return 0; 850 846 } 851 int AmdtpTransmitStreamProcessor::encodeSilencePortToMBLAEvents(AmdtpAudioPort *p, quadlet_t *data, 847 int AmdtpTransmitStreamProcessor::encodeSilencePortToMBLAEvents(AmdtpAudioPort *p, quadlet_t *data, 852 848 unsigned int offset, unsigned int nevents) 853 849 { … … 888 884 889 885 // call the parent init 890 // this has to be done before allocating the buffers, 886 // this has to be done before allocating the buffers, 891 887 // because this sets the buffersizes from the processormanager 892 888 if(!ReceiveStreamProcessor::init()) { … … 898 894 } 899 895 900 enum raw1394_iso_disposition 901 AmdtpReceiveStreamProcessor::putPacket(unsigned char *data, unsigned int length, 902 unsigned char channel, unsigned char tag, unsigned char sy, 896 enum raw1394_iso_disposition 897 AmdtpReceiveStreamProcessor::putPacket(unsigned char *data, unsigned int length, 898 unsigned char channel, unsigned char tag, unsigned char sy, 903 899 unsigned int cycle, unsigned int dropped) { 904 900 905 901 enum raw1394_iso_disposition retval=RAW1394_ISO_OK; 906 902 m_last_cycle=cycle; 907 903 908 904 struct iec61883_packet *packet = (struct iec61883_packet *) data; 909 905 assert(packet); … … 915 911 916 912 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"ch%2u: CY=%4u, SYT=%08X (%4ucy + %04uticks) (running=%d, disabled=%d,%d)\n", 917 channel, cycle,ntohs(packet->syt), 913 channel, cycle,ntohs(packet->syt), 918 914 CYCLE_TIMER_GET_CYCLES(ntohs(packet->syt)), CYCLE_TIMER_GET_OFFSET(ntohs(packet->syt)), 919 915 m_running,m_disabled,m_is_disabled); 920 916 921 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, 922 "RCV: CH = %d, FDF = %X. SYT = %6d, DBS = %3d, DBC = %3d, FMT = %3d, LEN = %4d\n", 917 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, 918 "RCV: CH = %d, FDF = %X. SYT = %6d, DBS = %3d, DBC = %3d, FMT = %3d, LEN = %4d\n", 923 919 channel, packet->fdf, 924 920 packet->syt, 925 921 packet->dbs, 926 922 packet->dbc, 927 packet->fmt, 923 packet->fmt, 928 924 length); 929 925 … … 932 928 // check if we are on or past the enable point 933 929 int cycles_past_enable=diffCycles(cycle, m_cycle_to_enable_at); 934 930 935 931 if (cycles_past_enable >= 0) { 936 932 m_is_disabled=false; 937 debugOutput(DEBUG_LEVEL_VERBOSE,"Enabling StreamProcessor %p at %d (SYT=%04X)\n", 933 debugOutput(DEBUG_LEVEL_VERBOSE,"Enabling StreamProcessor %p at %d (SYT=%04X)\n", 938 934 this, cycle, ntohs(packet->syt)); 939 935 // the previous timestamp is the one we need to start with … … 954 950 955 951 // check if this is a valid packet 956 if((packet->syt != 0xFFFF) 957 && (packet->fdf != 0xFF) 952 if((packet->syt != 0xFFFF) 953 && (packet->fdf != 0xFF) 958 954 && (packet->fmt == 0x10) 959 && (packet->dbs>0) 955 && (packet->dbs>0) 960 956 && (length>=2*sizeof(quadlet_t))) { 961 957 962 958 unsigned int nevents=((length / sizeof (quadlet_t)) - 2)/packet->dbs; 963 959 … … 966 962 967 963 //=> convert the SYT to a full timestamp in ticks 968 m_last_timestamp=sytRecvToFullTicks((uint32_t)ntohs(packet->syt), 964 m_last_timestamp=sytRecvToFullTicks((uint32_t)ntohs(packet->syt), 969 965 cycle, m_handler->getCycleTimer()); 970 966 971 967 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "RECV: CY=%04u TS=%011llu\n", 972 968 cycle, m_last_timestamp); 973 969 974 970 // we have to keep in mind that there are also 975 971 // some packets buffered by the ISO layer, … … 981 977 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"STMP: %lluticks | buff=%d, syt_interval=%d, tpf=%f\n", 982 978 m_last_timestamp, m_handler->getWakeupInterval(),m_syt_interval,m_ticks_per_frame); 983 979 984 980 //=> signal that we're running (if we are) 985 981 if(!m_running && nevents && m_last_timestamp2 && m_last_timestamp) { … … 995 991 // estimate as to when a period might be ready. i.e. it will not 996 992 // be ready earlier than this timestamp + period time 997 998 // the next (possible) sample is not this one, but lies 993 994 // the next (possible) sample is not this one, but lies 999 995 // SYT_INTERVAL * rate later 1000 996 uint64_t ts=addTicks(m_last_timestamp, … … 1004 1000 // the buffer by the next packet. 1005 1001 m_data_buffer->setBufferTailTimestamp(ts); 1006 1002 1007 1003 return RAW1394_ISO_DEFER; 1008 1004 } 1009 1005 1010 1006 #ifdef DEBUG_OFF 1011 1007 if((cycle % 1000) == 0) { … … 1013 1009 uint32_t now=m_handler->getCycleTimer(); 1014 1010 uint32_t now_ticks=CYCLE_TIMER_TO_TICKS(now); 1015 1011 1016 1012 uint32_t test_ts=sytRecvToFullTicks(syt, cycle, now); 1017 1013 … … 1027 1023 } 1028 1024 #endif 1029 1025 1030 1026 //=> process the packet 1031 1027 // add the data payload to the ringbuffer 1032 if(m_data_buffer->writeFrames(nevents, (char *)(data+8), m_last_timestamp)) { 1028 if(m_data_buffer->writeFrames(nevents, (char *)(data+8), m_last_timestamp)) { 1033 1029 retval=RAW1394_ISO_OK; 1034 1030 1035 1031 // process all ports that should be handled on a per-packet base 1036 1032 // this is MIDI for AMDTP (due to the need of DBC) … … 1039 1035 retval=RAW1394_ISO_DEFER; 1040 1036 } 1041 1037 1042 1038 } else { 1043 1044 debugWarning("Receive buffer overrun (cycle %d, FC=%d, PC=%d)\n", 1039 1040 debugWarning("Receive buffer overrun (cycle %d, FC=%d, PC=%d)\n", 1045 1041 cycle, m_data_buffer->getFrameCounter(), m_handler->getPacketCount()); 1046 1042 1047 1043 m_xruns++; 1048 1044 1049 1045 // disable the processing, will be re-enabled when 1050 1046 // the xrun is handled … … 1071 1067 1072 1068 void AmdtpReceiveStreamProcessor::setVerboseLevel(int l) { 1073 setDebugLevel(l);1074 ReceiveStreamProcessor::setVerboseLevel(l);1069 setDebugLevel(l); 1070 ReceiveStreamProcessor::setVerboseLevel(l); 1075 1071 } 1076 1072 … … 1101 1097 1102 1098 debugOutput( DEBUG_LEVEL_VERBOSE, "Preparing (%p)...\n", this); 1103 1104 // prepare all non-device specific stuff1105 // i.e. the iso stream and the associated ports1106 if(!ReceiveStreamProcessor::prepare()) {1107 debugFatal("Could not prepare base class\n");1108 return false;1109 }1110 1111 switch (m_framerate) {1112 case 32000:1113 m_syt_interval = 8;1114 break;1115 case 44100:1116 m_syt_interval = 8;1117 break;1118 default:1119 case 48000:1120 m_syt_interval = 8;1121 break;1122 case 88200:1123 m_syt_interval = 16;1124 break;1125 case 96000:1126 m_syt_interval = 16;1127 break;1128 case 176400:1129 m_syt_interval = 32;1130 break;1131 case 192000:1132 m_syt_interval = 32;1133 break;1134 }1099 1100 // prepare all non-device specific stuff 1101 // i.e. the iso stream and the associated ports 1102 if(!ReceiveStreamProcessor::prepare()) { 1103 debugFatal("Could not prepare base class\n"); 1104 return false; 1105 } 1106 1107 switch (m_framerate) { 1108 case 32000: 1109 m_syt_interval = 8; 1110 break; 1111 case 44100: 1112 m_syt_interval = 8; 1113 break; 1114 default: 1115 case 48000: 1116 m_syt_interval = 8; 1117 break; 1118 case 88200: 1119 m_syt_interval = 16; 1120 break; 1121 case 96000: 1122 m_syt_interval = 16; 1123 break; 1124 case 176400: 1125 m_syt_interval = 32; 1126 break; 1127 case 192000: 1128 m_syt_interval = 32; 1129 break; 1130 } 1135 1131 1136 1132 // prepare the framerate estimate … … 1139 1135 debugOutput(DEBUG_LEVEL_VERBOSE,"Initializing remote ticks/frame to %f\n",m_ticks_per_frame); 1140 1136 1141 // initialize internal buffer1137 // initialize internal buffer 1142 1138 unsigned int ringbuffer_size_frames=m_nb_buffers * m_period; 1143 1144 assert(m_data_buffer); 1139 1140 assert(m_data_buffer); 1145 1141 m_data_buffer->setBufferSize(ringbuffer_size_frames); 1146 1142 m_data_buffer->setEventSize(sizeof(quadlet_t)); 1147 1143 m_data_buffer->setEventsPerFrame(m_dimension); 1148 1144 1149 1145 // the buffer is written every syt_interval 1150 1146 m_data_buffer->setUpdatePeriod(m_syt_interval); 1151 1147 m_data_buffer->setNominalRate(m_ticks_per_frame); 1152 1148 1153 1149 m_data_buffer->setWrapValue(128L*TICKS_PER_SECOND); 1154 1150 1155 1151 m_data_buffer->prepare(); 1156 1152 1157 // set the parameters of ports we can:1158 // we want the audio ports to be period buffered,1159 // and the midi ports to be packet buffered1160 for ( PortVectorIterator it = m_Ports.begin();1161 it != m_Ports.end();1162 ++it )1163 {1164 debugOutput(DEBUG_LEVEL_VERBOSE, "Setting up port %s\n",(*it)->getName().c_str());1165 if(!(*it)->setBufferSize(m_period)) {1166 debugFatal("Could not set buffer size to %d\n",m_period);1167 return false;1168 }1169 1170 switch ((*it)->getPortType()) {1171 case Port::E_Audio:1172 if(!(*it)->setSignalType(Port::E_PeriodSignalled)) {1173 debugFatal("Could not set signal type to PeriodSignalling");1174 return false;1175 }1176 // buffertype and datatype are dependant on the API1177 debugWarning("---------------- ! Doing hardcoded dummy setup ! --------------\n");1178 // buffertype and datatype are dependant on the API1179 if(!(*it)->setBufferType(Port::E_PointerBuffer)) {1180 debugFatal("Could not set buffer type");1181 return false;1182 }1183 if(!(*it)->useExternalBuffer(true)) {1184 debugFatal("Could not set external buffer usage");1185 return false;1186 }1187 if(!(*it)->setDataType(Port::E_Float)) {1188 debugFatal("Could not set data type");1189 return false;1190 }1191 break;1192 case Port::E_Midi:1193 if(!(*it)->setSignalType(Port::E_PacketSignalled)) {1194 debugFatal("Could not set signal type to PacketSignalling");1195 return false;1196 }1197 // buffertype and datatype are dependant on the API1198 // buffertype and datatype are dependant on the API1199 debugWarning("---------------- ! Doing hardcoded test setup ! --------------\n");1200 // buffertype and datatype are dependant on the API1201 if(!(*it)->setBufferType(Port::E_RingBuffer)) {1202 debugFatal("Could not set buffer type");1203 return false;1204 }1205 if(!(*it)->setDataType(Port::E_MidiEvent)) {1206 debugFatal("Could not set data type");1207 return false;1208 }1209 break;1210 default:1211 debugWarning("Unsupported port type specified\n");1212 break;1213 }1214 }1215 1216 // the API specific settings of the ports should already be set, 1217 // as this is called from the processorManager->prepare()1218 // so we can init the ports1219 if(!initPorts()) {1220 debugFatal("Could not initialize ports!\n");1221 return false;1222 }1223 1224 if(!preparePorts()) {1225 debugFatal("Could not initialize ports!\n");1226 return false;1227 }1153 // set the parameters of ports we can: 1154 // we want the audio ports to be period buffered, 1155 // and the midi ports to be packet buffered 1156 for ( PortVectorIterator it = m_Ports.begin(); 1157 it != m_Ports.end(); 1158 ++it ) 1159 { 1160 debugOutput(DEBUG_LEVEL_VERBOSE, "Setting up port %s\n",(*it)->getName().c_str()); 1161 if(!(*it)->setBufferSize(m_period)) { 1162 debugFatal("Could not set buffer size to %d\n",m_period); 1163 return false; 1164 } 1165 1166 switch ((*it)->getPortType()) { 1167 case Port::E_Audio: 1168 if(!(*it)->setSignalType(Port::E_PeriodSignalled)) { 1169 debugFatal("Could not set signal type to PeriodSignalling"); 1170 return false; 1171 } 1172 // buffertype and datatype are dependant on the API 1173 debugWarning("---------------- ! Doing hardcoded dummy setup ! --------------\n"); 1174 // buffertype and datatype are dependant on the API 1175 if(!(*it)->setBufferType(Port::E_PointerBuffer)) { 1176 debugFatal("Could not set buffer type"); 1177 return false; 1178 } 1179 if(!(*it)->useExternalBuffer(true)) { 1180 debugFatal("Could not set external buffer usage"); 1181 return false; 1182 } 1183 if(!(*it)->setDataType(Port::E_Float)) { 1184 debugFatal("Could not set data type"); 1185 return false; 1186 } 1187 break; 1188 case Port::E_Midi: 1189 if(!(*it)->setSignalType(Port::E_PacketSignalled)) { 1190 debugFatal("Could not set signal type to PacketSignalling"); 1191 return false; 1192 } 1193 // buffertype and datatype are dependant on the API 1194 // buffertype and datatype are dependant on the API 1195 debugWarning("---------------- ! Doing hardcoded test setup ! --------------\n"); 1196 // buffertype and datatype are dependant on the API 1197 if(!(*it)->setBufferType(Port::E_RingBuffer)) { 1198 debugFatal("Could not set buffer type"); 1199 return false; 1200 } 1201 if(!(*it)->setDataType(Port::E_MidiEvent)) { 1202 debugFatal("Could not set data type"); 1203 return false; 1204 } 1205 break; 1206 default: 1207 debugWarning("Unsupported port type specified\n"); 1208 break; 1209 } 1210 } 1211 1212 // the API specific settings of the ports should already be set, 1213 // as this is called from the processorManager->prepare() 1214 // so we can init the ports 1215 if(!initPorts()) { 1216 debugFatal("Could not initialize ports!\n"); 1217 return false; 1218 } 1219 1220 if(!preparePorts()) { 1221 debugFatal("Could not initialize ports!\n"); 1222 return false; 1223 } 1228 1224 1229 1225 debugOutput( DEBUG_LEVEL_VERBOSE, "Prepared for:\n"); … … 1234 1230 debugOutput( DEBUG_LEVEL_VERBOSE, " Port: %d, Channel: %d\n", 1235 1231 m_port,m_channel); 1236 1232 1237 1233 return true; 1238 1234 … … 1264 1260 * \brief write received events to the stream ringbuffers. 1265 1261 */ 1266 bool AmdtpReceiveStreamProcessor::processReadBlock(char *data, 1267 unsigned int nevents, unsigned int offset)1262 bool AmdtpReceiveStreamProcessor::processReadBlock(char *data, 1263 unsigned int nevents, unsigned int offset) 1268 1264 { 1269 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "(%p)->processReadBlock(%u, %u)\n",this,nevents,offset);1270 1271 bool no_problem=true;1272 1273 for ( PortVectorIterator it = m_PeriodPorts.begin();1265 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "(%p)->processReadBlock(%u, %u)\n",this,nevents,offset); 1266 1267 bool no_problem=true; 1268 1269 for ( PortVectorIterator it = m_PeriodPorts.begin(); 1274 1270 it != m_PeriodPorts.end(); 1275 1271 ++it ) … … 1278 1274 if((*it)->isDisabled()) {continue;}; 1279 1275 1280 //FIXME: make this into a static_cast when not DEBUG?1281 1282 AmdtpPortInfo *pinfo=dynamic_cast<AmdtpPortInfo *>(*it);1283 assert(pinfo); // this should not fail!!1284 1285 switch(pinfo->getFormat()) {1286 case AmdtpPortInfo::E_MBLA:1287 if(decodeMBLAEventsToPort(static_cast<AmdtpAudioPort *>(*it), (quadlet_t *)data, offset, nevents)) {1288 debugWarning("Could not decode packet MBLA to port %s",(*it)->getName().c_str());1289 no_problem=false;1290 }1291 break;1292 case AmdtpPortInfo::E_SPDIF: // still unimplemented1293 break;1294 /* for this processor, midi is a packet based port 1295 case AmdtpPortInfo::E_Midi:1296 break;*/1297 default: // ignore1298 break;1299 }1276 //FIXME: make this into a static_cast when not DEBUG? 1277 1278 AmdtpPortInfo *pinfo=dynamic_cast<AmdtpPortInfo *>(*it); 1279 assert(pinfo); // this should not fail!! 1280 1281 switch(pinfo->getFormat()) { 1282 case AmdtpPortInfo::E_MBLA: 1283 if(decodeMBLAEventsToPort(static_cast<AmdtpAudioPort *>(*it), (quadlet_t *)data, offset, nevents)) { 1284 debugWarning("Could not decode packet MBLA to port %s",(*it)->getName().c_str()); 1285 no_problem=false; 1286 } 1287 break; 1288 case AmdtpPortInfo::E_SPDIF: // still unimplemented 1289 break; 1290 /* for this processor, midi is a packet based port 1291 case AmdtpPortInfo::E_Midi: 1292 break;*/ 1293 default: // ignore 1294 break; 1295 } 1300 1296 } 1301 1297 return no_problem; … … 1313 1309 bool AmdtpReceiveStreamProcessor::decodePacketPorts(quadlet_t *data, unsigned int nevents, unsigned int dbc) 1314 1310 { 1315 bool ok=true;1316 1317 quadlet_t *target_event=NULL;1318 unsigned int j;1319 1320 for ( PortVectorIterator it = m_PacketPorts.begin();1311 bool ok=true; 1312 1313 quadlet_t *target_event=NULL; 1314 unsigned int j; 1315 1316 for ( PortVectorIterator it = m_PacketPorts.begin(); 1321 1317 it != m_PacketPorts.end(); 1322 1318 ++it ) 1323 {1319 { 1324 1320 1325 1321 #ifdef DEBUG 1326 AmdtpPortInfo *pinfo=dynamic_cast<AmdtpPortInfo *>(*it);1327 assert(pinfo); // this should not fail!!1328 1329 // the only packet type of events for AMDTP is MIDI in mbla1330 assert(pinfo->getFormat()==AmdtpPortInfo::E_Midi);1322 AmdtpPortInfo *pinfo=dynamic_cast<AmdtpPortInfo *>(*it); 1323 assert(pinfo); // this should not fail!! 1324 1325 // the only packet type of events for AMDTP is MIDI in mbla 1326 assert(pinfo->getFormat()==AmdtpPortInfo::E_Midi); 1331 1327 #endif 1332 AmdtpMidiPort *mp=static_cast<AmdtpMidiPort *>(*it);1333 1334 // we decode this directly (no function call) due to the high frequency1335 /* idea:1336 spec says: current_midi_port=(dbc+j)%8;1337 => if we start at (dbc+stream->location-1)%8, 1338 we'll start at the right event for the midi port.1339 => if we increment j with 8, we stay at the right event.1340 */1341 // FIXME: as we know in advance how big a packet is (syt_interval) we can 1342 // predict how much loops will be present here1343 for(j = (dbc & 0x07)+mp->getLocation(); j < nevents; j += 8) {1344 target_event=(quadlet_t *)(data + ((j * m_dimension) + mp->getPosition()));1345 quadlet_t sample_int=ntohl(*target_event);1346 // FIXME: this assumes that 2X and 3X speed isn't used, 1347 // because only the 1X slot is put into the ringbuffer1348 if(IEC61883_AM824_GET_LABEL(sample_int) != IEC61883_AM824_LABEL_MIDI_NO_DATA) {1349 sample_int=(sample_int >> 16) & 0x000000FF;1350 if(!mp->writeEvent(&sample_int)) {1351 debugWarning("Packet port events lost\n");1352 ok=false;1353 }1354 }1355 }1356 1357 }1358 1359 return ok;1360 } 1361 1362 int AmdtpReceiveStreamProcessor::decodeMBLAEventsToPort(AmdtpAudioPort *p, quadlet_t *data, 1363 unsigned int offset, unsigned int nevents)1328 AmdtpMidiPort *mp=static_cast<AmdtpMidiPort *>(*it); 1329 1330 // we decode this directly (no function call) due to the high frequency 1331 /* idea: 1332 spec says: current_midi_port=(dbc+j)%8; 1333 => if we start at (dbc+stream->location-1)%8, 1334 we'll start at the right event for the midi port. 1335 => if we increment j with 8, we stay at the right event. 1336 */ 1337 // FIXME: as we know in advance how big a packet is (syt_interval) we can 1338 // predict how much loops will be present here 1339 for(j = (dbc & 0x07)+mp->getLocation(); j < nevents; j += 8) { 1340 target_event=(quadlet_t *)(data + ((j * m_dimension) + mp->getPosition())); 1341 quadlet_t sample_int=ntohl(*target_event); 1342 // FIXME: this assumes that 2X and 3X speed isn't used, 1343 // because only the 1X slot is put into the ringbuffer 1344 if(IEC61883_AM824_GET_LABEL(sample_int) != IEC61883_AM824_LABEL_MIDI_NO_DATA) { 1345 sample_int=(sample_int >> 16) & 0x000000FF; 1346 if(!mp->writeEvent(&sample_int)) { 1347 debugWarning("Packet port events lost\n"); 1348 ok=false; 1349 } 1350 } 1351 } 1352 1353 } 1354 1355 return ok; 1356 } 1357 1358 int AmdtpReceiveStreamProcessor::decodeMBLAEventsToPort(AmdtpAudioPort *p, quadlet_t *data, 1359 unsigned int offset, unsigned int nevents) 1364 1360 { 1365 unsigned int j=0;1366 1367 // printf("****************\n");1368 // hexDumpQuadlets(data,m_dimension*4);1369 // printf("****************\n");1370 1371 quadlet_t *target_event;1372 1373 target_event=(quadlet_t *)(data + p->getPosition());1374 1375 switch(p->getDataType()) {1376 default:1377 case Port::E_Int24:1378 {1379 quadlet_t *buffer=(quadlet_t *)(p->getBufferAddress());1380 1381 assert(nevents + offset <= p->getBufferSize());1382 1383 buffer+=offset;1384 1385 for(j = 0; j < nevents; j += 1) { // decode max nsamples1386 *(buffer)=(ntohl((*target_event) ) & 0x00FFFFFF);1387 buffer++;1388 target_event+=m_dimension;1389 }1390 }1391 break;1392 case Port::E_Float:1393 {1394 const float multiplier = 1.0f / (float)(0x7FFFFF);1395 float *buffer=(float *)(p->getBufferAddress());1396 1397 assert(nevents + offset <= p->getBufferSize());1398 1399 buffer+=offset;1400 1401 for(j = 0; j < nevents; j += 1) { // decode max nsamples 1402 1403 unsigned int v = ntohl(*target_event) & 0x00FFFFFF;1404 // sign-extend highest bit of 24-bit int1405 int tmp = (int)(v << 8) / 256;1406 1407 *buffer = tmp * multiplier;1408 1409 buffer++;1410 target_event+=m_dimension;1411 }1412 }1413 break;1414 }1415 1416 return 0;1361 unsigned int j=0; 1362 1363 // printf("****************\n"); 1364 // hexDumpQuadlets(data,m_dimension*4); 1365 // printf("****************\n"); 1366 1367 quadlet_t *target_event; 1368 1369 target_event=(quadlet_t *)(data + p->getPosition()); 1370 1371 switch(p->getDataType()) { 1372 default: 1373 case Port::E_Int24: 1374 { 1375 quadlet_t *buffer=(quadlet_t *)(p->getBufferAddress()); 1376 1377 assert(nevents + offset <= p->getBufferSize()); 1378 1379 buffer+=offset; 1380 1381 for(j = 0; j < nevents; j += 1) { // decode max nsamples 1382 *(buffer)=(ntohl((*target_event) ) & 0x00FFFFFF); 1383 buffer++; 1384 target_event+=m_dimension; 1385 } 1386 } 1387 break; 1388 case Port::E_Float: 1389 { 1390 const float multiplier = 1.0f / (float)(0x7FFFFF); 1391 float *buffer=(float *)(p->getBufferAddress()); 1392 1393 assert(nevents + offset <= p->getBufferSize()); 1394 1395 buffer+=offset; 1396 1397 for(j = 0; j < nevents; j += 1) { // decode max nsamples 1398 1399 unsigned int v = ntohl(*target_event) & 0x00FFFFFF; 1400 // sign-extend highest bit of 24-bit int 1401 int tmp = (int)(v << 8) / 256; 1402 1403 *buffer = tmp * multiplier; 1404 1405 buffer++; 1406 target_event+=m_dimension; 1407 } 1408 } 1409 break; 1410 } 1411 1412 return 0; 1417 1413 } 1418 1414 trunk/libffado/src/libstreaming/AmdtpStreamProcessor.h
r424 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2005,2006,2007 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 2 * Copyright (C) 2005-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 27 22 */ 28 #ifndef __FREEBOB_AMDTPSTREAMPROCESSOR__ 29 #define __FREEBOB_AMDTPSTREAMPROCESSOR__ 23 24 #ifndef __FFADO_AMDTPSTREAMPROCESSOR__ 25 #define __FFADO_AMDTPSTREAMPROCESSOR__ 30 26 31 27 /** … … 46 42 #define IEC61883_STREAM_TYPE_MBLA 0x06 47 43 48 #define IEC61883_AM824_LABEL_MASK 0xFF00000049 #define IEC61883_AM824_GET_LABEL(x) (((x) & 0xFF000000) >> 24)50 #define IEC61883_AM824_SET_LABEL(x,y) ((x) | ((y)<<24))51 52 #define IEC61883_AM824_LABEL_MIDI_NO_DATA 0x8053 #define IEC61883_AM824_LABEL_MIDI_1X 0x8154 #define IEC61883_AM824_LABEL_MIDI_2X 0x8255 #define IEC61883_AM824_LABEL_MIDI_3X 0x8344 #define IEC61883_AM824_LABEL_MASK 0xFF000000 45 #define IEC61883_AM824_GET_LABEL(x) (((x) & 0xFF000000) >> 24) 46 #define IEC61883_AM824_SET_LABEL(x,y) ((x) | ((y)<<24)) 47 48 #define IEC61883_AM824_LABEL_MIDI_NO_DATA 0x80 49 #define IEC61883_AM824_LABEL_MIDI_1X 0x81 50 #define IEC61883_AM824_LABEL_MIDI_2X 0x82 51 #define IEC61883_AM824_LABEL_MIDI_3X 0x83 56 52 57 53 namespace Streaming { … … 65 61 \brief The Base Class for an AMDTP transmit stream processor 66 62 67 This class implements a TransmitStreamProcessor that multiplexes Ports 63 This class implements a TransmitStreamProcessor that multiplexes Ports 68 64 into AMDTP streams. 69 65 70 66 */ 71 class AmdtpTransmitStreamProcessor 72 : public TransmitStreamProcessor67 class AmdtpTransmitStreamProcessor 68 : public TransmitStreamProcessor 73 69 { 74 70 … … 78 74 * @param port 1394 port 79 75 * @param framerate frame rate 80 * @param dimension number of substreams in the ISO stream 76 * @param dimension number of substreams in the ISO stream 81 77 * (midi-muxed is only one stream) 82 78 */ … … 85 81 virtual ~AmdtpTransmitStreamProcessor(); 86 82 87 enum raw1394_iso_disposition 83 enum raw1394_iso_disposition 88 84 getPacket(unsigned char *data, unsigned int *length, 89 85 unsigned char *tag, unsigned char *sy, … … 93 89 bool reset(); 94 90 bool prepare(); 95 91 96 92 bool prepareForStop(); 97 93 bool prepareForStart(); 98 94 99 95 bool prepareForEnable(uint64_t time_to_enable_at); 100 96 101 97 bool putFrames(unsigned int nbframes, int64_t ts); ///< transfer the buffer contents from the client 102 98 … … 104 100 // this period takes m_period/m_framerate seconds of time 105 101 // during this time, 8000 packets are sent 106 // unsigned int getPacketsPerPeriod() {return (m_period*8000)/m_framerate;};107 102 // unsigned int getPacketsPerPeriod() {return (m_period*8000)/m_framerate;}; 103 108 104 // however, if we only count the number of used packets 109 105 // it is m_period / m_syt_interval 110 106 unsigned int getPacketsPerPeriod() {return (m_period)/m_syt_interval;}; 111 112 unsigned int getMaxPacketSize() {return 4 * (2 + m_syt_interval * m_dimension);}; 113 107 108 unsigned int getMaxPacketSize() {return 4 * (2 + m_syt_interval * m_dimension);}; 109 114 110 int getMinimalSyncDelay(); 115 111 116 112 void setVerboseLevel(int l); 117 113 118 114 protected: 119 115 bool processWriteBlock(char *data, unsigned int nevents, unsigned int offset); 120 116 121 117 struct iec61883_cip m_cip_status; 122 118 123 119 int m_dimension; 124 120 unsigned int m_syt_interval; 125 121 126 122 int m_fdf; 127 123 128 124 bool prefill(); 129 125 130 126 unsigned int fillNoDataPacketHeader(struct iec61883_packet *packet, unsigned int* length); 131 127 unsigned int fillDataPacketHeader(struct iec61883_packet *packet, unsigned int* length, uint32_t ts); 132 133 128 129 134 130 bool transferSilence(unsigned int size); 135 131 136 int transmitBlock(char *data, unsigned int nevents, 132 int transmitBlock(char *data, unsigned int nevents, 137 133 unsigned int offset); 138 134 139 135 bool encodePacketPorts(quadlet_t *data, unsigned int nevents, unsigned int dbc); 140 136 int encodePortToMBLAEvents(AmdtpAudioPort *, quadlet_t *data, 141 137 unsigned int offset, unsigned int nevents); 142 143 int transmitSilenceBlock(char *data, unsigned int nevents, 138 139 int transmitSilenceBlock(char *data, unsigned int nevents, 144 140 unsigned int offset); 145 141 int encodeSilencePortToMBLAEvents(AmdtpAudioPort *, quadlet_t *data, 146 142 unsigned int offset, unsigned int nevents); 147 143 void updatePreparedState(); 148 144 149 145 unsigned long m_last_timestamp; 150 146 151 147 unsigned int m_dbc; 152 148 153 149 unsigned int m_ringbuffer_size_frames; 154 150 … … 159 155 \brief The Base Class for an AMDTP receive stream processor 160 156 161 This class implements a ReceiveStreamProcessor that demultiplexes 157 This class implements a ReceiveStreamProcessor that demultiplexes 162 158 AMDTP streams into Ports. 163 159 164 160 */ 165 class AmdtpReceiveStreamProcessor 166 : public ReceiveStreamProcessor161 class AmdtpReceiveStreamProcessor 162 : public ReceiveStreamProcessor 167 163 { 168 164 … … 172 168 * @param port 1394 port 173 169 * @param framerate frame rate 174 * @param dimension number of substreams in the ISO stream 170 * @param dimension number of substreams in the ISO stream 175 171 * (midi-muxed is only one stream) 176 172 */ 177 AmdtpReceiveStreamProcessor(int port, int framerate, int dimension);178 179 virtual ~AmdtpReceiveStreamProcessor();180 181 enum raw1394_iso_disposition putPacket(unsigned char *data, unsigned int length, 182 unsigned char channel, unsigned char tag, unsigned char sy, 183 unsigned int cycle, unsigned int dropped);184 185 186 bool init();187 bool reset();188 bool prepare();189 173 AmdtpReceiveStreamProcessor(int port, int framerate, int dimension); 174 175 virtual ~AmdtpReceiveStreamProcessor(); 176 177 enum raw1394_iso_disposition putPacket(unsigned char *data, unsigned int length, 178 unsigned char channel, unsigned char tag, unsigned char sy, 179 unsigned int cycle, unsigned int dropped); 180 181 182 bool init(); 183 bool reset(); 184 bool prepare(); 185 190 186 bool prepareForStop(); 191 187 bool prepareForStart(); 192 188 193 189 bool getFrames(unsigned int nbframes); ///< transfer the buffer contents to the client 194 190 … … 196 192 // this period takes m_period/m_framerate seconds of time 197 193 // during this time, 8000 packets are sent 198 // unsigned int getPacketsPerPeriod() {return (m_period*8000)/m_framerate;};199 194 // unsigned int getPacketsPerPeriod() {return (m_period*8000)/m_framerate;}; 195 200 196 // however, if we only count the number of used packets 201 197 // it is m_period / m_syt_interval 202 unsigned int getPacketsPerPeriod() {return (m_period)/m_syt_interval;};203 204 unsigned int getMaxPacketSize() {return 4 * (2 + m_syt_interval * m_dimension);}; 198 unsigned int getPacketsPerPeriod() {return (m_period)/m_syt_interval;}; 199 200 unsigned int getMaxPacketSize() {return 4 * (2 + m_syt_interval * m_dimension);}; 205 201 206 202 void dumpInfo(); 207 203 208 204 int getMinimalSyncDelay(); 209 205 210 206 void setVerboseLevel(int l); 211 207 212 208 protected: 213 209 … … 215 211 216 212 bool decodePacketPorts(quadlet_t *data, unsigned int nevents, unsigned int dbc); 217 213 218 214 int decodeMBLAEventsToPort(AmdtpAudioPort *, quadlet_t *data, unsigned int offset, unsigned int nevents); 219 215 void updatePreparedState(); … … 221 217 int m_dimension; 222 218 unsigned int m_syt_interval; 223 219 224 220 uint64_t m_last_timestamp; /// last timestamp (in ticks) 225 221 uint64_t m_last_timestamp2; /// last timestamp (in ticks) 226 222 uint64_t m_last_timestamp_at_period_ticks; 227 223 228 224 DECLARE_DEBUG_MODULE; 229 225 … … 233 229 } // end of namespace Streaming 234 230 235 #endif /* __F REEBOB_AMDTPSTREAMPROCESSOR__ */236 231 #endif /* __FFADO_AMDTPSTREAMPROCESSOR__ */ 232 trunk/libffado/src/libstreaming/cip.h
r435 r445 1 /* 2 * libiec61883 - Linux IEEE 1394 streaming media library. 3 * Copyright (C) 2004 Kristian Hogsberg, Dan Dennedy, and Dan Maas. 4 * This file written by Kristian Hogsberg. 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 */ 20 1 21 #ifndef _IEC61883_CIP_PRIVATE_H 2 22 #define _IEC61883_CIP_PRIVATE_H … … 21 41 22 42 struct iec61883_packet { 23 /* First quadlet */24 uint8_t dbs : 8;25 uint8_t eoh0 : 2;26 uint8_t sid : 6;43 /* First quadlet */ 44 uint8_t dbs : 8; 45 uint8_t eoh0 : 2; 46 uint8_t sid : 6; 27 47 28 uint8_t dbc : 8;29 uint8_t fn : 2;30 uint8_t qpc : 3;31 uint8_t sph : 1;32 uint8_t reserved : 2;48 uint8_t dbc : 8; 49 uint8_t fn : 2; 50 uint8_t qpc : 3; 51 uint8_t sph : 1; 52 uint8_t reserved : 2; 33 53 34 /* Second quadlet */35 uint8_t fdf : 8;36 uint8_t eoh1 : 2;37 uint8_t fmt : 6;54 /* Second quadlet */ 55 uint8_t fdf : 8; 56 uint8_t eoh1 : 2; 57 uint8_t fmt : 6; 38 58 39 uint16_t syt : 16;59 uint16_t syt : 16; 40 60 41 unsigned char data[0];61 unsigned char data[0]; 42 62 }; 43 63 … … 45 65 46 66 struct iec61883_packet { 47 /* First quadlet */48 uint8_t sid : 6;49 uint8_t eoh0 : 2;50 uint8_t dbs : 8;67 /* First quadlet */ 68 uint8_t sid : 6; 69 uint8_t eoh0 : 2; 70 uint8_t dbs : 8; 51 71 52 uint8_t reserved : 2;53 uint8_t sph : 1;54 uint8_t qpc : 3;55 uint8_t fn : 2;56 uint8_t dbc : 8;72 uint8_t reserved : 2; 73 uint8_t sph : 1; 74 uint8_t qpc : 3; 75 uint8_t fn : 2; 76 uint8_t dbc : 8; 57 77 58 /* Second quadlet */59 uint8_t fmt : 6;60 uint8_t eoh1 : 2;61 uint8_t fdf : 8;78 /* Second quadlet */ 79 uint8_t fmt : 6; 80 uint8_t eoh1 : 2; 81 uint8_t fdf : 8; 62 82 63 uint16_t syt : 16;83 uint16_t syt : 16; 64 84 65 unsigned char data[0];85 unsigned char data[0]; 66 86 }; 67 87 … … 84 104 85 105 #define IEC61883_FDF_NODATA 0xFF 86 106 87 107 /* AM824 format definitions. */ 88 108 #define IEC61883_FDF_AM824 0x00 … … 104 124 #define IEC60958_LABEL 0x0 105 125 #define IEC60958_PAC_B 0x3 /* Preamble Code 'B': Start of channel 1, at 106 * the start of a data block. */126 * the start of a data block. */ 107 127 #define IEC60958_PAC_RSV 0x2 /* Preamble Code 'RESERVED' */ 108 128 #define IEC60958_PAC_M 0x1 /* Preamble Code 'M': Start of channel 1 that 109 *is not at the start of a data block. */129 * is not at the start of a data block. */ 110 130 #define IEC60958_PAC_W 0x0 /* Preamble Code 'W': start of channel 2. */ 111 131 #define IEC60958_DATA_VALID 0 /* When cleared means data is valid. */ … … 113 133 114 134 struct iec61883_fraction { 115 int integer;116 int numerator;117 int denominator;135 int integer; 136 int numerator; 137 int denominator; 118 138 }; 119 139 120 140 struct iec61883_cip { 121 struct iec61883_fraction cycle_offset;122 struct iec61883_fraction ticks_per_syt_offset;123 struct iec61883_fraction ready_samples;124 struct iec61883_fraction samples_per_cycle;125 int dbc, dbs;126 int cycle_count;127 int cycle_count2;128 int mode;129 int syt_interval;130 int dimension;131 int rate;132 int fdf;133 int format;141 struct iec61883_fraction cycle_offset; 142 struct iec61883_fraction ticks_per_syt_offset; 143 struct iec61883_fraction ready_samples; 144 struct iec61883_fraction samples_per_cycle; 145 int dbc, dbs; 146 int cycle_count; 147 int cycle_count2; 148 int mode; 149 int syt_interval; 150 int dimension; 151 int rate; 152 int fdf; 153 int format; 134 154 }; 135 155 136 156 void 137 157 iec61883_cip_init(struct iec61883_cip *cip, int format, int fdf, 138 int rate, int dbs, int syt_interval);139 void 158 int rate, int dbs, int syt_interval); 159 void 140 160 iec61883_cip_set_transmission_mode(struct iec61883_cip *ptz, int mode); 141 161 142 int 162 int 143 163 iec61883_cip_get_max_packet_size(struct iec61883_cip *ptz); 144 164 145 165 int 146 166 iec61883_cip_fill_header(int node_id, struct iec61883_cip *cip, 147 struct iec61883_packet *packet);167 struct iec61883_packet *packet); 148 168 149 169 int 150 170 iec61883_cip_fill_header_nodata(int node_id, struct iec61883_cip *cip, 151 struct iec61883_packet *packet);171 struct iec61883_packet *packet); 152 172 153 173 #ifdef __cplusplus trunk/libffado/src/libstreaming/cycletimer.h
r411 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2005,2006,2007 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 27 */ 28 2 * Copyright (C) 2005-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 29 24 /* Definitions and utility macro's to handle the ISO cycle timer */ 30 25 … … 52 47 (CYCLE_TIMER_GET_CYCLES(x) * TICKS_PER_CYCLE ) +\ 53 48 (CYCLE_TIMER_GET_OFFSET(x) )) 54 49 55 50 // non-efficient versions, to be avoided in critical code 56 51 #define TICKS_TO_SECS(x) ((x)/TICKS_PER_SECOND) … … 61 56 | ((TICKS_TO_CYCLES(x) & 0x1FFF) << 12) \ 62 57 | ((TICKS_TO_OFFSET(x) & 0xFFF))) 63 58 64 59 #define TICKS_TO_SYT(x) (((TICKS_TO_CYCLES(x) & 0xF) << 12) \ 65 60 | ((TICKS_TO_OFFSET(x) & 0xFFF))) … … 114 109 if (x < 0) { 115 110 debugWarning("insufficient wrapping: %lld\n",x); 116 111 117 112 debugWarning("correcting...\n"); 118 113 while (x < 0) { 119 114 x += TICKS_PER_SECOND * 128L; 120 115 121 116 if (x < 0) { 122 117 debugWarning(" insufficient wrapping: %lld\n",x); … … 134 129 * 135 130 * The input value is wrapped to the maximum value of the cycle 136 * timer, in ticks (128sec * 24576000 ticks/sec), and 131 * timer, in ticks (128sec * 24576000 ticks/sec), and 137 132 * to the minimum value of the cycle timer, in ticks (= 0). 138 133 * … … 141 136 */ 142 137 static inline uint32_t wrapAtMinMaxTicks(int64_t x) { 143 138 144 139 if (x < 0) { 145 140 x += TICKS_PER_SECOND * 128L; … … 166 161 * such that it respects wrapping. 167 162 * 168 * If x wraps around, but y doesn't, the result of x-y is 163 * If x wraps around, but y doesn't, the result of x-y is 169 164 * negative and very large. However the real difference is 170 165 * not large. It can be calculated by unwrapping x and then 171 166 * calculating x-y. 172 167 * 173 * @param x First timestamp 168 * @param x First timestamp 174 169 * @param y Second timestamp 175 170 * @return the difference x-y, unwrapped … … 177 172 static inline int32_t diffTicks(uint32_t x, uint32_t y) { 178 173 int64_t diff=(int64_t)x - (int64_t)y; 179 174 180 175 // the maximal difference we allow (64secs) 181 176 const int64_t max=TICKS_PER_SECOND*64L; 182 177 183 178 if(diff > max) { 184 179 // this means that y has wrapped, but … … 194 189 diff += TICKS_PER_SECOND*128L; 195 190 } 196 191 197 192 return (int32_t)diff; 198 193 199 194 } 200 195 … … 205 200 * wrapping the result if necessary. 206 201 * 207 * @param x First timestamp 202 * @param x First timestamp 208 203 * @param y Second timestamp 209 204 * @return the sum x+y, wrapped … … 221 216 * wrapping the result if necessary. 222 217 * 223 * @param x First timestamp 218 * @param x First timestamp 224 219 * @param y Second timestamp 225 220 * @return the difference x-y, wrapped … … 238 233 * @param rcv_cycle The cycle this timestamp was received on 239 234 * @param ctr_now The current value of the cycle timer ('now') 240 * @return 235 * @return 241 236 */ 242 237 static inline uint32_t sytRecvToFullTicks(uint32_t syt_timestamp, unsigned int rcv_cycle, uint32_t ctr_now) { 243 238 uint32_t timestamp; 244 239 245 240 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"SYT=%08X CY=%04X CTR=%08X\n", 246 241 syt_timestamp,rcv_cycle,ctr_now); 247 242 248 243 // reconstruct the full cycle 249 244 uint32_t cc_cycles=CYCLE_TIMER_GET_CYCLES(ctr_now); 250 245 uint32_t cc_seconds=CYCLE_TIMER_GET_SECS(ctr_now); 251 246 252 247 // the cycletimer has wrapped since this packet was received 253 // we want cc_seconds to reflect the 'seconds' at the point this 248 // we want cc_seconds to reflect the 'seconds' at the point this 254 249 // was received 255 250 if (rcv_cycle>cc_cycles) { … … 262 257 } 263 258 } 264 259 265 260 // reconstruct the top part of the timestamp using the current cycle number 266 261 uint32_t rcv_cycle_masked=rcv_cycle & 0xF; 267 262 uint32_t syt_cycle=CYCLE_TIMER_GET_CYCLES(syt_timestamp); 268 263 269 264 // if this is true, wraparound has occurred, undo this wraparound 270 265 if(syt_cycle<rcv_cycle_masked) syt_cycle += 0x10; 271 266 272 267 // this is the difference in cycles wrt the cycle the 273 268 // timestamp was received 274 269 uint32_t delta_cycles=syt_cycle-rcv_cycle_masked; 275 270 276 271 // reconstruct the cycle part of the timestamp 277 272 uint32_t new_cycles=rcv_cycle + delta_cycles; 278 273 279 274 // if the cycles cause a wraparound of the cycle timer, 280 275 // perform this wraparound … … 286 281 "Detected wraparound: %d + %d = %d\n", 287 282 rcv_cycle,delta_cycles,new_cycles); 288 283 289 284 new_cycles-=8000; // wrap around 290 285 #ifdef DEBUG … … 297 292 timestamp += TICKS_PER_SECOND; 298 293 } 299 294 300 295 timestamp += CYCLE_TIMER_GET_OFFSET(syt_timestamp); 301 296 302 297 timestamp = addTicks(timestamp, cc_seconds * TICKS_PER_SECOND); 303 298 304 299 #ifdef DEBUG 305 300 if(( TICKS_TO_CYCLE_TIMER(timestamp) & 0xFFFF) != syt_timestamp) { … … 309 304 } 310 305 #endif 311 306 312 307 return timestamp; 313 308 } … … 317 312 * 318 313 * The difference between sytRecvToFullTicks and sytXmitToFullTicks is 319 * the way SYT cycle wraparound is detected: in the receive version, 314 * the way SYT cycle wraparound is detected: in the receive version, 320 315 * wraparound is present if rcv_cycle > current_cycle. In the xmit 321 316 * version this is when current_cycle > xmt_cycle. … … 324 319 * @param xmt_cycle The cycle this timestamp was received on 325 320 * @param ctr_now The current value of the cycle timer ('now') 326 * @return 321 * @return 327 322 */ 328 323 static inline uint32_t sytXmitToFullTicks(uint32_t syt_timestamp, unsigned int xmt_cycle, uint32_t ctr_now) { 329 324 uint32_t timestamp; 330 325 331 326 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"SYT=%08X CY=%04X CTR=%08X\n", 332 327 syt_timestamp,xmt_cycle,ctr_now); 333 328 334 329 // reconstruct the full cycle 335 330 uint32_t cc_cycles=CYCLE_TIMER_GET_CYCLES(ctr_now); 336 331 uint32_t cc_seconds=CYCLE_TIMER_GET_SECS(ctr_now); 337 332 338 333 // the cycletimer has wrapped since this packet was received 339 // we want cc_seconds to reflect the 'seconds' at the point this 334 // we want cc_seconds to reflect the 'seconds' at the point this 340 335 // is to be transmitted 341 336 if (xmt_cycle<cc_cycles) { … … 348 343 } 349 344 } 350 345 351 346 // reconstruct the top part of the timestamp using the current cycle number 352 347 uint32_t xmt_cycle_masked=xmt_cycle & 0xF; 353 348 uint32_t syt_cycle=CYCLE_TIMER_GET_CYCLES(syt_timestamp); 354 349 355 350 // if this is true, wraparound has occurred, undo this wraparound 356 351 if(syt_cycle<xmt_cycle_masked) syt_cycle += 0x10; 357 352 358 353 // this is the difference in cycles wrt the cycle the 359 354 // timestamp was received 360 355 uint32_t delta_cycles=syt_cycle-xmt_cycle_masked; 361 356 362 357 // reconstruct the cycle part of the timestamp 363 358 uint32_t new_cycles=xmt_cycle + delta_cycles; 364 359 365 360 // if the cycles cause a wraparound of the cycle timer, 366 361 // perform this wraparound … … 372 367 "Detected wraparound: %d + %d = %d\n", 373 368 xmt_cycle,delta_cycles,new_cycles); 374 369 375 370 new_cycles-=8000; // wrap around 376 371 #ifdef DEBUG … … 383 378 timestamp += TICKS_PER_SECOND; 384 379 } 385 380 386 381 timestamp += CYCLE_TIMER_GET_OFFSET(syt_timestamp); 387 382 388 383 timestamp = addTicks(timestamp, cc_seconds * TICKS_PER_SECOND); 389 384 390 385 #ifdef DEBUG 391 386 if(( TICKS_TO_CYCLE_TIMER(timestamp) & 0xFFFF) != syt_timestamp) { … … 395 390 } 396 391 #endif 397 392 398 393 return timestamp; 399 394 } … … 407 402 * See diffTicks 408 403 * 409 * @param x First cycle value 404 * @param x First cycle value 410 405 * @param y Second cycle value 411 406 * @return the difference x-y, unwrapped … … 413 408 static inline int diffCycles(unsigned int x, unsigned int y) { 414 409 int diff = x - y; 415 410 416 411 // the maximal difference we allow (64secs) 417 412 const int max=CYCLES_PER_SECOND/2; 418 413 419 414 if(diff > max) { 420 415 diff -= CYCLES_PER_SECOND; … … 422 417 diff += CYCLES_PER_SECOND; 423 418 } 424 419 425 420 return diff; 426 421 } trunk/libffado/src/libstreaming/IsoHandler.cpp
r419 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 2 * Copyright (C) 2005-2007 by Pieter Palmers 6 3 * 7 * http://freebob.sf.net 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 8 6 * 9 * Copyright (C) 2006 Pieter Palmers <pieterpalmers@users.sourceforge.net>7 * FFADO is based upon FreeBoB. 10 8 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 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; 15 12 * 16 * This programis distributed in the hope that it will be useful,17 * but WITHOUT ANY WARRANTY {}without even the implied warranty of18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the19 * GNUGeneral Public License for more details.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. 20 17 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 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 27 22 */ 28 23 … … 57 52 58 53 /* the C callbacks */ 59 enum raw1394_iso_disposition 54 enum raw1394_iso_disposition 60 55 IsoXmitHandler::iso_transmit_handler(raw1394handle_t handle, 61 unsigned char *data, unsigned int *length,62 unsigned char *tag, unsigned char *sy,63 int cycle, unsigned int dropped) {64 65 IsoXmitHandler *xmitHandler=static_cast<IsoXmitHandler *>(raw1394_get_userdata(handle));66 assert(xmitHandler);67 68 return xmitHandler->getPacket(data, length, tag, sy, cycle, dropped);69 } 70 71 enum raw1394_iso_disposition 72 IsoRecvHandler::iso_receive_handler(raw1394handle_t handle, unsigned char *data, 73 unsigned int length, unsigned char channel,74 unsigned char tag, unsigned char sy, unsigned int cycle, 75 unsigned int dropped) {76 77 IsoRecvHandler *recvHandler=static_cast<IsoRecvHandler *>(raw1394_get_userdata(handle));78 assert(recvHandler);79 80 return recvHandler->putPacket(data, length, channel, tag, sy, cycle, dropped);56 unsigned char *data, unsigned int *length, 57 unsigned char *tag, unsigned char *sy, 58 int cycle, unsigned int dropped) { 59 60 IsoXmitHandler *xmitHandler=static_cast<IsoXmitHandler *>(raw1394_get_userdata(handle)); 61 assert(xmitHandler); 62 63 return xmitHandler->getPacket(data, length, tag, sy, cycle, dropped); 64 } 65 66 enum raw1394_iso_disposition 67 IsoRecvHandler::iso_receive_handler(raw1394handle_t handle, unsigned char *data, 68 unsigned int length, unsigned char channel, 69 unsigned char tag, unsigned char sy, unsigned int cycle, 70 unsigned int dropped) { 71 72 IsoRecvHandler *recvHandler=static_cast<IsoRecvHandler *>(raw1394_get_userdata(handle)); 73 assert(recvHandler); 74 75 return recvHandler->putPacket(data, length, channel, tag, sy, cycle, dropped); 81 76 } 82 77 83 78 int IsoHandler::busreset_handler(raw1394handle_t handle, unsigned int generation) 84 { 85 debugOutput( DEBUG_LEVEL_VERBOSE, "Busreset happened, generation %d...\n", generation);86 87 IsoHandler *handler=static_cast<IsoHandler *>(raw1394_get_userdata(handle));88 assert(handler);89 return handler->handleBusReset(generation);79 { 80 debugOutput( DEBUG_LEVEL_VERBOSE, "Busreset happened, generation %d...\n", generation); 81 82 IsoHandler *handler=static_cast<IsoHandler *>(raw1394_get_userdata(handle)); 83 assert(handler); 84 return handler->handleBusReset(generation); 90 85 } 91 86 … … 93 88 /* Base class implementation */ 94 89 IsoHandler::IsoHandler(int port) 95 : m_handle(0), m_handle_util(0), m_port(port), 90 : m_handle(0), m_handle_util(0), m_port(port), 96 91 m_buf_packets(400), m_max_packet_size(1024), m_irq_interval(-1), 97 92 m_packetcount(0), m_dropped(0), m_Client(0), … … 101 96 102 97 IsoHandler::IsoHandler(int port, unsigned int buf_packets, unsigned int max_packet_size, int irq) 103 : m_handle(0), m_port(port), 104 m_buf_packets(buf_packets), m_max_packet_size( max_packet_size), 105 m_irq_interval(irq), 98 : m_handle(0), m_port(port), 99 m_buf_packets(buf_packets), m_max_packet_size( max_packet_size), 100 m_irq_interval(irq), 106 101 m_packetcount(0), m_dropped(0), m_Client(0), 107 102 m_State(E_Created) … … 121 116 stop(); 122 117 } 123 118 124 119 raw1394_destroy_handle(m_handle); 125 120 } 126 121 127 122 if(m_handle_util) raw1394_destroy_handle(m_handle_util); 128 123 … … 134 129 if(m_handle) { 135 130 if(raw1394_loop_iterate(m_handle)) { 136 debugOutput( DEBUG_LEVEL_VERBOSE, 131 debugOutput( DEBUG_LEVEL_VERBOSE, 137 132 "IsoHandler (%p): Failed to iterate handler: %s\n", 138 133 this,strerror(errno)); … … 142 137 } 143 138 } else { 144 return false; 139 return false; 145 140 } 146 141 } … … 156 151 return false; 157 152 } 158 153 159 154 // the main handle for the ISO traffic 160 155 m_handle = raw1394_new_handle_on_port( m_port ); … … 169 164 } 170 165 raw1394_set_userdata(m_handle, static_cast<void *>(this)); 171 166 172 167 // a second handle for utility stuff 173 168 m_handle_util = raw1394_new_handle_on_port( m_port ); … … 179 174 debugError("Are ieee1394 and raw1394 drivers loaded?\n"); 180 175 } 181 176 182 177 raw1394_destroy_handle(m_handle); 183 178 return false; 184 179 } 185 180 raw1394_set_userdata(m_handle_util, static_cast<void *>(this)); 186 181 187 182 // bus reset handling 188 183 if(raw1394_busreset_notify (m_handle, RAW1394_NOTIFY_ON)) { … … 209 204 // update the internal state 210 205 m_State=E_Initialized; 211 206 212 207 return true; 213 208 } … … 222 217 return false; 223 218 } 224 219 225 220 // Don't call until libraw1394's raw1394_new_handle() function has been 226 221 // fixed to correctly initialise the iso_packet_infos field. Bug is … … 228 223 229 224 // raw1394_iso_shutdown(m_handle); 230 225 231 226 m_State = E_Prepared; 232 227 233 228 return true; 234 229 } … … 237 232 { 238 233 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 239 234 240 235 // check the state 241 236 if(m_State != E_Prepared) { … … 252 247 { 253 248 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 254 249 255 250 // check state 256 251 if(m_State != E_Running) { … … 258 253 return false; 259 254 } 260 255 261 256 // this is put here to try and avoid the 262 257 // Runaway context problem 263 258 // don't know if it will help though. 264 259 raw1394_iso_xmit_sync(m_handle); 265 260 266 261 raw1394_iso_stop(m_handle); 267 262 268 263 m_State=E_Prepared; 269 264 270 265 return true; 271 266 } … … 276 271 * @return ? 277 272 */ 278 273 279 274 int IsoHandler::handleBusReset(unsigned int generation) { 280 275 debugOutput( DEBUG_LEVEL_VERBOSE, "bus reset...\n"); 281 282 276 277 283 278 return 0; 284 279 } … … 293 288 // the new api should be realtime safe. 294 289 // it might cause a reschedule when turning preemption, 295 // back on but that won't hurt us if we have sufficient 296 // priority 290 // back on but that won't hurt us if we have sufficient 291 // priority 297 292 int err; 298 293 uint32_t cycle_timer; … … 314 309 // the new api should be realtime safe. 315 310 // it might cause a reschedule when turning preemption, 316 // back on but that won't hurt us if we have sufficient 317 // priority 311 // back on but that won't hurt us if we have sufficient 312 // priority 318 313 int err; 319 314 uint32_t cycle_timer; … … 351 346 352 347 if (m_Client) { 353 debugFatal( "Generic IsoHandlers can have only one client\n"); 348 debugFatal( "Generic IsoHandlers can have only one client\n"); 354 349 return false; 355 350 } … … 369 364 370 365 if(stream != m_Client) { 371 debugFatal( "no client registered\n"); 366 debugFatal( "no client registered\n"); 372 367 return false; 373 368 } 374 369 375 370 m_Client->clearHandler(); 376 371 377 372 m_Client=0; 378 373 return true; … … 387 382 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 388 383 } 389 IsoRecvHandler::IsoRecvHandler(int port, unsigned int buf_packets, 384 IsoRecvHandler::IsoRecvHandler(int port, unsigned int buf_packets, 390 385 unsigned int max_packet_size, int irq) 391 386 : IsoHandler(port, buf_packets,max_packet_size,irq) … … 411 406 412 407 enum raw1394_iso_disposition IsoRecvHandler::putPacket( 413 unsigned char *data, unsigned int length, 414 unsigned char channel, unsigned char tag, unsigned char sy, 408 unsigned char *data, unsigned int length, 409 unsigned char channel, unsigned char tag, unsigned char sy, 415 410 unsigned int cycle, unsigned int dropped) { 416 411 … … 424 419 return m_Client->putPacket(data, length, channel, tag, sy, cycle, dropped); 425 420 } 426 421 427 422 return RAW1394_ISO_OK; 428 423 } … … 430 425 bool IsoRecvHandler::prepare() 431 426 { 432 427 433 428 // prepare the generic IsoHandler 434 429 if(!IsoHandler::prepare()) { … … 443 438 444 439 if(m_irq_interval > 1) { 445 if(raw1394_iso_recv_init(m_handle, 440 if(raw1394_iso_recv_init(m_handle, 446 441 iso_receive_handler, 447 442 m_buf_packets, … … 452 447 debugFatal("Could not do receive initialisation!\n" ); 453 448 debugFatal(" %s\n",strerror(errno)); 454 449 455 450 return false; 456 451 } 457 452 } else { 458 if(raw1394_iso_recv_init(m_handle, 453 if(raw1394_iso_recv_init(m_handle, 459 454 iso_receive_handler, 460 455 m_buf_packets, … … 465 460 debugFatal("Could not do receive initialisation!\n" ); 466 461 debugFatal(" %s\n",strerror(errno)); 467 462 468 463 return false; 469 } 464 } 470 465 } 471 466 return true; … … 475 470 { 476 471 debugOutput( DEBUG_LEVEL_VERBOSE, "start on cycle %d\n", cycle); 477 472 478 473 // start the generic IsoHandler 479 474 if(!IsoHandler::start(cycle)) { 480 475 return false; 481 476 } 482 477 483 478 if(raw1394_iso_recv_start(m_handle, cycle, -1, 0)) { 484 479 debugFatal("Could not start receive handler (%s)\n",strerror(errno)); … … 490 485 int IsoRecvHandler::handleBusReset(unsigned int generation) { 491 486 debugOutput( DEBUG_LEVEL_VERBOSE, "handle bus reset...\n"); 492 487 493 488 //TODO: implement busreset 494 489 495 490 // pass on the busreset signal 496 491 if(IsoHandler::handleBusReset(generation)) { … … 508 503 509 504 } 510 IsoXmitHandler::IsoXmitHandler(int port, unsigned int buf_packets, 505 IsoXmitHandler::IsoXmitHandler(int port, unsigned int buf_packets, 511 506 unsigned int max_packet_size, int irq) 512 507 : IsoHandler(port, buf_packets, max_packet_size,irq), … … 516 511 517 512 } 518 IsoXmitHandler::IsoXmitHandler(int port, unsigned int buf_packets, 513 IsoXmitHandler::IsoXmitHandler(int port, unsigned int buf_packets, 519 514 unsigned int max_packet_size, int irq, 520 515 enum raw1394_iso_speed speed) … … 575 570 { 576 571 debugOutput( DEBUG_LEVEL_VERBOSE, "start on cycle %d\n", cycle); 577 572 578 573 if(!(IsoHandler::start(cycle))) { 579 574 return false; 580 575 } 581 576 582 577 if(raw1394_iso_xmit_start(m_handle, cycle, m_prebuffers)) { 583 578 debugFatal("Could not start xmit handler (%s)\n",strerror(errno)); … … 608 603 debugOutput( DEBUG_LEVEL_VERBOSE, "bus reset...\n"); 609 604 //TODO: implement busreset 610 605 611 606 // pass on the busreset signal 612 607 if(IsoHandler::handleBusReset(generation)) { 613 608 return -1; 614 609 } 615 610 616 611 return 0; 617 612 } … … 622 617 #if 0 623 618 IsoRecvHandler::IsoRecvHandler(int port) 624 : IsoHandler(port)625 { 626 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n");627 } 628 IsoRecvHandler::IsoRecvHandler(int port, unsigned int buf_packets, 619 : IsoHandler(port) 620 { 621 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 622 } 623 IsoRecvHandler::IsoRecvHandler(int port, unsigned int buf_packets, 629 624 unsigned int max_packet_size, int irq) 630 : IsoHandler(port, buf_packets,max_packet_size,irq)631 { 632 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n");625 : IsoHandler(port, buf_packets,max_packet_size,irq) 626 { 627 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 633 628 634 629 } … … 640 635 // raw1394_destroy_handle() (in the base class destructor) will do any iso 641 636 // system shutdown required. 642 raw1394_iso_shutdown(m_handle);637 raw1394_iso_shutdown(m_handle); 643 638 644 639 } … … 646 641 bool 647 642 IsoRecvHandler::initialize() { 648 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n");649 650 IsoHandler *base=static_cast<IsoHandler *>(this);651 652 if(!(base->initialize())) {653 return false;654 }655 656 raw1394_set_userdata(m_handle, static_cast<void *>(this));657 658 if(raw1394_iso_multichannel_recv_init(m_handle,643 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 644 645 IsoHandler *base=static_cast<IsoHandler *>(this); 646 647 if(!(base->initialize())) { 648 return false; 649 } 650 651 raw1394_set_userdata(m_handle, static_cast<void *>(this)); 652 653 if(raw1394_iso_multichannel_recv_init(m_handle, 659 654 iso_receive_handler, 660 655 m_buf_packets, 661 656 m_max_packet_size, 662 657 m_irq_interval)) { 663 debugFatal("Could not do multichannel receive initialisation!\n" );664 665 return false;666 }667 668 return true;669 670 } 671 672 enum raw1394_iso_disposition IsoRecvHandler::putPacket(unsigned char *data, unsigned int length, 673 unsigned char channel, unsigned char tag, unsigned char sy, 674 unsigned int cycle, unsigned int dropped) {675 676 debugOutput( DEBUG_LEVEL_VERY_VERBOSE,677 "received packet: length=%d, channel=%d, cycle=%d\n",678 length, channel, cycle );679 680 return RAW1394_ISO_OK;658 debugFatal("Could not do multichannel receive initialisation!\n" ); 659 660 return false; 661 } 662 663 return true; 664 665 } 666 667 enum raw1394_iso_disposition IsoRecvHandler::putPacket(unsigned char *data, unsigned int length, 668 unsigned char channel, unsigned char tag, unsigned char sy, 669 unsigned int cycle, unsigned int dropped) { 670 671 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, 672 "received packet: length=%d, channel=%d, cycle=%d\n", 673 length, channel, cycle ); 674 675 return RAW1394_ISO_OK; 681 676 } 682 677 … … 686 681 int IsoRecvHandler::registerStream(IsoRecvStream *stream) 687 682 { 688 assert(stream);689 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n");690 691 m_Clients.push_back(stream);692 693 listen(stream->getChannel());694 return 0;683 assert(stream); 684 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 685 686 m_Clients.push_back(stream); 687 688 listen(stream->getChannel()); 689 return 0; 695 690 696 691 } … … 698 693 int IsoRecvHandler::unregisterStream(IsoRecvStream *stream) 699 694 { 700 assert(stream);701 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n");695 assert(stream); 696 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 702 697 703 698 for ( IsoRecvStreamVectorIterator it = m_Clients.begin(); … … 706 701 { 707 702 IsoRecvStream* s = *it; 708 if ( s == stream ) { 709 unListen(s->getChannel());703 if ( s == stream ) { 704 unListen(s->getChannel()); 710 705 m_Clients.erase(it); 711 return 0;706 return 0; 712 707 } 713 708 } 714 709 715 return -1; //not found710 return -1; //not found 716 711 717 712 } 718 713 719 714 void IsoRecvHandler::listen(int channel) { 720 int retval;721 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n");722 723 retval=raw1394_iso_recv_listen_channel(m_handle, channel);715 int retval; 716 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 717 718 retval=raw1394_iso_recv_listen_channel(m_handle, channel); 724 719 725 720 } 726 721 727 722 void IsoRecvHandler::unListen(int channel) { 728 int retval;729 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n");730 731 retval=raw1394_iso_recv_unlisten_channel(m_handle, channel);723 int retval; 724 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 725 726 retval=raw1394_iso_recv_unlisten_channel(m_handle, channel); 732 727 733 728 } … … 735 730 int IsoRecvHandler::start(int cycle) 736 731 { 737 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n");738 return raw1394_iso_recv_start(m_handle, cycle, -1, 0);732 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 733 return raw1394_iso_recv_start(m_handle, cycle, -1, 0); 739 734 } 740 735 #endif trunk/libffado/src/libstreaming/IsoHandler.h
r419 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 2 * Copyright (C) 2005-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 27 22 */ 28 #ifndef __FREEBOB_ISOHANDLER__ 29 #define __FREEBOB_ISOHANDLER__ 23 24 #ifndef __FFADO_ISOHANDLER__ 25 #define __FFADO_ISOHANDLER__ 30 26 31 27 #include "../debugmodule/debugmodule.h" … … 51 47 { 52 48 protected: 53 49 54 50 public: 55 51 56 52 enum EHandlerType { 57 53 EHT_Receive, … … 69 65 virtual bool start(int cycle); 70 66 virtual bool stop(); 71 67 72 68 bool iterate(); 73 69 74 70 void setVerboseLevel(int l); 75 71 … … 112 108 unsigned int m_max_packet_size; 113 109 int m_irq_interval; 114 110 115 111 int m_packetcount; 116 112 int m_dropped; … … 135 131 E_Error 136 132 }; 137 133 138 134 enum EHandlerStates m_State; 139 135 … … 141 137 142 138 /*! 143 \brief ISO receive handler class (not multichannel) 139 \brief ISO receive handler class (not multichannel) 144 140 */ 145 141 146 class IsoRecvHandler : public IsoHandler 142 class IsoRecvHandler : public IsoHandler 147 143 { 148 144 … … 153 149 154 150 bool init(); 155 151 156 152 enum EHandlerType getType() { return EHT_Receive;}; 157 153 … … 164 160 165 161 private: 166 static enum raw1394_iso_disposition 167 iso_receive_handler(raw1394handle_t handle, unsigned char *data, 162 static enum raw1394_iso_disposition 163 iso_receive_handler(raw1394handle_t handle, unsigned char *data, 168 164 unsigned int length, unsigned char channel, 169 unsigned char tag, unsigned char sy, unsigned int cycle, 165 unsigned char tag, unsigned char sy, unsigned int cycle, 170 166 unsigned int dropped); 171 167 172 enum raw1394_iso_disposition 173 putPacket(unsigned char *data, unsigned int length, 174 unsigned char channel, unsigned char tag, unsigned char sy, 168 enum raw1394_iso_disposition 169 putPacket(unsigned char *data, unsigned int length, 170 unsigned char channel, unsigned char tag, unsigned char sy, 175 171 unsigned int cycle, unsigned int dropped); 176 172 … … 181 177 */ 182 178 183 class IsoXmitHandler : public IsoHandler 179 class IsoXmitHandler : public IsoHandler 184 180 { 185 181 public: 186 182 IsoXmitHandler(int port); 187 IsoXmitHandler(int port, unsigned int buf_packets, 183 IsoXmitHandler(int port, unsigned int buf_packets, 188 184 unsigned int max_packet_size, int irq); 189 IsoXmitHandler(int port, unsigned int buf_packets, 190 unsigned int max_packet_size, int irq, 185 IsoXmitHandler(int port, unsigned int buf_packets, 186 unsigned int max_packet_size, int irq, 191 187 enum raw1394_iso_speed speed); 192 188 virtual ~IsoXmitHandler(); 193 189 194 190 bool init(); 195 191 196 192 enum EHandlerType getType() { return EHT_Transmit;}; 197 193 … … 211 207 unsigned char *tag, unsigned char *sy, 212 208 int cycle, unsigned int dropped); 213 enum raw1394_iso_disposition 209 enum raw1394_iso_disposition 214 210 getPacket(unsigned char *data, unsigned int *length, 215 211 unsigned char *tag, unsigned char *sy, … … 217 213 218 214 enum raw1394_iso_speed m_speed; 219 215 220 216 unsigned int m_prebuffers; 221 217 … … 224 220 } 225 221 226 #endif /* __F REEBOB_ISOHANDLER__ */227 228 229 222 #endif /* __FFADO_ISOHANDLER__ */ 223 224 225 trunk/libffado/src/libstreaming/IsoHandlerManager.cpp
r419 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 2 * Copyright (C) 2005-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 27 22 */ 28 23 … … 73 68 74 69 m_isoManagerThread=new Util::PosixThread( 75 this, 70 this, 76 71 m_realtime, prio, 77 72 PTHREAD_CANCEL_DEFERRED); … … 111 106 { 112 107 // updateCycleTimers(); 113 108 114 109 if(!iterate()) { 115 110 debugFatal("Could not iterate the isoManager\n"); 116 111 return false; 117 } 118 112 } 113 119 114 return true; 120 115 } … … 128 123 bool IsoHandlerManager::iterate() 129 124 { 130 int err;131 int i=0;132 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "enter...\n");133 134 err = poll (m_poll_fds, m_poll_nfds, m_poll_timeout);135 136 if (err == -1) {137 if (errno == EINTR) {138 return true;139 }140 debugFatal("poll error: %s\n", strerror (errno));141 return false;142 }143 144 for (i = 0; i < m_poll_nfds; i++) {145 if (m_poll_fds[i].revents & POLLERR) {146 debugWarning("error on fd for %d\n",i);147 }148 149 if (m_poll_fds[i].revents & POLLHUP) {150 debugWarning("hangup on fd for %d\n",i);151 }152 153 if(m_poll_fds[i].revents & (POLLIN)) {154 IsoHandler *s=m_IsoHandlers.at(i);155 assert(s);156 157 s->iterate();158 }159 }160 161 return true;125 int err; 126 int i=0; 127 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "enter...\n"); 128 129 err = poll (m_poll_fds, m_poll_nfds, m_poll_timeout); 130 131 if (err == -1) { 132 if (errno == EINTR) { 133 return true; 134 } 135 debugFatal("poll error: %s\n", strerror (errno)); 136 return false; 137 } 138 139 for (i = 0; i < m_poll_nfds; i++) { 140 if (m_poll_fds[i].revents & POLLERR) { 141 debugWarning("error on fd for %d\n",i); 142 } 143 144 if (m_poll_fds[i].revents & POLLHUP) { 145 debugWarning("hangup on fd for %d\n",i); 146 } 147 148 if(m_poll_fds[i].revents & (POLLIN)) { 149 IsoHandler *s=m_IsoHandlers.at(i); 150 assert(s); 151 152 s->iterate(); 153 } 154 } 155 156 return true; 162 157 163 158 } … … 167 162 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 168 163 assert(handler); 169 164 170 165 m_IsoHandlers.push_back(handler); 171 166 172 167 handler->setVerboseLevel(getDebugLevel()); 173 168 174 169 // rebuild the fd map for poll()'ing. 175 return rebuildFdMap(); 170 return rebuildFdMap(); 176 171 177 172 } … … 179 174 bool IsoHandlerManager::unregisterHandler(IsoHandler *handler) 180 175 { 181 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n");182 assert(handler);183 184 for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin();185 it != m_IsoHandlers.end();186 ++it )187 {188 if ( *it == handler ) {189 // erase the iso handler from the list190 m_IsoHandlers.erase(it);191 // rebuild the fd map for poll()'ing.192 return rebuildFdMap();193 }194 }195 debugFatal("Could not find handler (%p)\n", handler);196 197 return false; //not found176 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 177 assert(handler); 178 179 for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin(); 180 it != m_IsoHandlers.end(); 181 ++it ) 182 { 183 if ( *it == handler ) { 184 // erase the iso handler from the list 185 m_IsoHandlers.erase(it); 186 // rebuild the fd map for poll()'ing. 187 return rebuildFdMap(); 188 } 189 } 190 debugFatal("Could not find handler (%p)\n", handler); 191 192 return false; //not found 198 193 199 194 } 200 195 201 196 bool IsoHandlerManager::rebuildFdMap() { 202 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n");203 int i=0;204 205 m_poll_nfds=0;206 if(m_poll_fds) free(m_poll_fds);207 208 // count the number of handlers209 m_poll_nfds=m_IsoHandlers.size();210 211 // allocate the fd array212 m_poll_fds = (struct pollfd *) calloc (m_poll_nfds, sizeof (struct pollfd));213 if(!m_poll_fds) {214 debugFatal("Could not allocate memory for poll FD array\n");215 return false;216 }217 218 // fill the fd map219 for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin();220 it != m_IsoHandlers.end();221 ++it )222 {223 m_poll_fds[i].fd=(*it)->getFileDescriptor();224 m_poll_fds[i].events = POLLIN;225 i++;226 }227 228 return true;197 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 198 int i=0; 199 200 m_poll_nfds=0; 201 if(m_poll_fds) free(m_poll_fds); 202 203 // count the number of handlers 204 m_poll_nfds=m_IsoHandlers.size(); 205 206 // allocate the fd array 207 m_poll_fds = (struct pollfd *) calloc (m_poll_nfds, sizeof (struct pollfd)); 208 if(!m_poll_fds) { 209 debugFatal("Could not allocate memory for poll FD array\n"); 210 return false; 211 } 212 213 // fill the fd map 214 for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin(); 215 it != m_IsoHandlers.end(); 216 ++it ) 217 { 218 m_poll_fds[i].fd=(*it)->getFileDescriptor(); 219 m_poll_fds[i].events = POLLIN; 220 i++; 221 } 222 223 return true; 229 224 } 230 225 231 226 void IsoHandlerManager::disablePolling(IsoStream *stream) { 232 227 int i=0; 233 228 234 229 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "Disable polling on stream %p\n",stream); 235 230 … … 243 238 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "polling disabled\n"); 244 239 } 245 240 246 241 i++; 247 242 } … … 250 245 void IsoHandlerManager::enablePolling(IsoStream *stream) { 251 246 int i=0; 252 247 253 248 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "Enable polling on stream %p\n",stream); 254 249 255 250 for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin(); 256 251 it != m_IsoHandlers.end(); … … 262 257 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "polling enabled\n"); 263 258 } 264 259 265 260 i++; 266 261 } … … 279 274 * 280 275 * \todo : currently there is a one-to-one mapping 281 * between streams and handlers, this is not ok for 276 * between streams and handlers, this is not ok for 282 277 * multichannel receive 283 278 */ 284 279 bool IsoHandlerManager::registerStream(IsoStream *stream) 285 280 { 286 debugOutput( DEBUG_LEVEL_VERBOSE, "Registering stream %p\n",stream);287 assert(stream);288 289 // make sure the stream isn't already attached to a handler290 for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin();291 it != m_IsoHandlers.end();292 ++it )293 {294 if((*it)->isStreamRegistered(stream)) {295 debugWarning( "stream already registered!\n");296 (*it)->unregisterStream(stream);297 298 }299 }300 301 // clean up all handlers that aren't used302 pruneHandlers();303 304 // allocate a handler for this stream305 if (stream->getType()==IsoStream::EST_Receive) {306 // setup the optimal parameters for the raw1394 ISO buffering307 unsigned int packets_per_period=stream->getPacketsPerPeriod();308 281 debugOutput( DEBUG_LEVEL_VERBOSE, "Registering stream %p\n",stream); 282 assert(stream); 283 284 // make sure the stream isn't already attached to a handler 285 for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin(); 286 it != m_IsoHandlers.end(); 287 ++it ) 288 { 289 if((*it)->isStreamRegistered(stream)) { 290 debugWarning( "stream already registered!\n"); 291 (*it)->unregisterStream(stream); 292 293 } 294 } 295 296 // clean up all handlers that aren't used 297 pruneHandlers(); 298 299 // allocate a handler for this stream 300 if (stream->getType()==IsoStream::EST_Receive) { 301 // setup the optimal parameters for the raw1394 ISO buffering 302 unsigned int packets_per_period=stream->getPacketsPerPeriod(); 303 309 304 #if 1 310 // hardware interrupts occur when one DMA block is full, and the size of one DMA311 // block = PAGE_SIZE. Setting the max_packet_size makes sure that the HW irq 312 // occurs at a period boundary (optimal CPU use)313 314 // NOTE: try and use MINIMUM_INTERRUPTS_PER_PERIOD hardware interrupts315 // per period for better latency.316 unsigned int max_packet_size=(MINIMUM_INTERRUPTS_PER_PERIOD * getpagesize()) / packets_per_period;317 if (max_packet_size < stream->getMaxPacketSize()) {318 max_packet_size=stream->getMaxPacketSize();319 }320 321 // Ensure we don't request a packet size bigger than the322 // kernel-enforced maximum which is currently 1 page.323 if (max_packet_size > (unsigned int)getpagesize())324 max_packet_size = getpagesize();325 326 unsigned int irq_interval=packets_per_period / MINIMUM_INTERRUPTS_PER_PERIOD;327 if(irq_interval <= 0) irq_interval=1;305 // hardware interrupts occur when one DMA block is full, and the size of one DMA 306 // block = PAGE_SIZE. Setting the max_packet_size makes sure that the HW irq 307 // occurs at a period boundary (optimal CPU use) 308 309 // NOTE: try and use MINIMUM_INTERRUPTS_PER_PERIOD hardware interrupts 310 // per period for better latency. 311 unsigned int max_packet_size=(MINIMUM_INTERRUPTS_PER_PERIOD * getpagesize()) / packets_per_period; 312 if (max_packet_size < stream->getMaxPacketSize()) { 313 max_packet_size=stream->getMaxPacketSize(); 314 } 315 316 // Ensure we don't request a packet size bigger than the 317 // kernel-enforced maximum which is currently 1 page. 318 if (max_packet_size > (unsigned int)getpagesize()) 319 max_packet_size = getpagesize(); 320 321 unsigned int irq_interval=packets_per_period / MINIMUM_INTERRUPTS_PER_PERIOD; 322 if(irq_interval <= 0) irq_interval=1; 328 323 #else 329 // hardware interrupts occur when one DMA block is full, and the size of one DMA330 // block = PAGE_SIZE. Setting the max_packet_size enables control over the IRQ331 // frequency, as the controller uses max_packet_size, and not the effective size332 // when writing to the DMA buffer.333 334 // configure it such that we have an irq for every PACKETS_PER_INTERRUPT packets335 unsigned int irq_interval=PACKETS_PER_INTERRUPT;336 337 // unless the period size doesn't allow this338 if ((packets_per_period/MINIMUM_INTERRUPTS_PER_PERIOD) < irq_interval) {339 irq_interval=1;340 }341 342 // FIXME: test343 irq_interval=1;344 345 unsigned int max_packet_size=getpagesize() / irq_interval;346 347 if (max_packet_size < stream->getMaxPacketSize()) {348 max_packet_size=stream->getMaxPacketSize();349 }350 351 // Ensure we don't request a packet size bigger than the352 // kernel-enforced maximum which is currently 1 page.353 if (max_packet_size > (unsigned int)getpagesize())354 max_packet_size = getpagesize();324 // hardware interrupts occur when one DMA block is full, and the size of one DMA 325 // block = PAGE_SIZE. Setting the max_packet_size enables control over the IRQ 326 // frequency, as the controller uses max_packet_size, and not the effective size 327 // when writing to the DMA buffer. 328 329 // configure it such that we have an irq for every PACKETS_PER_INTERRUPT packets 330 unsigned int irq_interval=PACKETS_PER_INTERRUPT; 331 332 // unless the period size doesn't allow this 333 if ((packets_per_period/MINIMUM_INTERRUPTS_PER_PERIOD) < irq_interval) { 334 irq_interval=1; 335 } 336 337 // FIXME: test 338 irq_interval=1; 339 340 unsigned int max_packet_size=getpagesize() / irq_interval; 341 342 if (max_packet_size < stream->getMaxPacketSize()) { 343 max_packet_size=stream->getMaxPacketSize(); 344 } 345 346 // Ensure we don't request a packet size bigger than the 347 // kernel-enforced maximum which is currently 1 page. 348 if (max_packet_size > (unsigned int)getpagesize()) 349 max_packet_size = getpagesize(); 355 350 356 351 #endif 357 /* the receive buffer size doesn't matter for the latency,358 but it has a minimal value in order for libraw to operate correctly (300) */359 int buffers=400;360 361 // create the actual handler362 IsoRecvHandler *h = new IsoRecvHandler(stream->getPort(), buffers,363 max_packet_size, irq_interval);364 365 debugOutput( DEBUG_LEVEL_VERBOSE, " registering IsoRecvHandler\n");366 367 if(!h) {368 debugFatal("Could not create IsoRecvHandler\n");369 return false;370 }371 372 h->setVerboseLevel(getDebugLevel());373 374 // init the handler375 if(!h->init()) {376 debugFatal("Could not initialize receive handler\n");377 return false;378 }379 380 // register the stream with the handler381 if(!h->registerStream(stream)) {382 debugFatal("Could not register receive stream with handler\n");383 return false;384 }385 386 // register the handler with the manager387 if(!registerHandler(h)) {388 debugFatal("Could not register receive handler with manager\n");389 return false;390 }391 debugOutput( DEBUG_LEVEL_VERBOSE, " registered stream (%p) with handler (%p)\n",stream,h);392 }393 394 if (stream->getType()==IsoStream::EST_Transmit) {395 // setup the optimal parameters for the raw1394 ISO buffering396 unsigned int packets_per_period=stream->getPacketsPerPeriod();352 /* the receive buffer size doesn't matter for the latency, 353 but it has a minimal value in order for libraw to operate correctly (300) */ 354 int buffers=400; 355 356 // create the actual handler 357 IsoRecvHandler *h = new IsoRecvHandler(stream->getPort(), buffers, 358 max_packet_size, irq_interval); 359 360 debugOutput( DEBUG_LEVEL_VERBOSE, " registering IsoRecvHandler\n"); 361 362 if(!h) { 363 debugFatal("Could not create IsoRecvHandler\n"); 364 return false; 365 } 366 367 h->setVerboseLevel(getDebugLevel()); 368 369 // init the handler 370 if(!h->init()) { 371 debugFatal("Could not initialize receive handler\n"); 372 return false; 373 } 374 375 // register the stream with the handler 376 if(!h->registerStream(stream)) { 377 debugFatal("Could not register receive stream with handler\n"); 378 return false; 379 } 380 381 // register the handler with the manager 382 if(!registerHandler(h)) { 383 debugFatal("Could not register receive handler with manager\n"); 384 return false; 385 } 386 debugOutput( DEBUG_LEVEL_VERBOSE, " registered stream (%p) with handler (%p)\n",stream,h); 387 } 388 389 if (stream->getType()==IsoStream::EST_Transmit) { 390 // setup the optimal parameters for the raw1394 ISO buffering 391 unsigned int packets_per_period=stream->getPacketsPerPeriod(); 397 392 398 393 #if 1 399 // hardware interrupts occur when one DMA block is full, and the size of one DMA400 // block = PAGE_SIZE. Setting the max_packet_size makes sure that the HW irq 401 // occurs at a period boundary (optimal CPU use)402 // NOTE: try and use MINIMUM_INTERRUPTS_PER_PERIOD interrupts per period403 // for better latency.404 unsigned int max_packet_size=MINIMUM_INTERRUPTS_PER_PERIOD * getpagesize() / packets_per_period;405 if (max_packet_size < stream->getMaxPacketSize()) {406 max_packet_size=stream->getMaxPacketSize();407 }408 409 // Ensure we don't request a packet size bigger than the410 // kernel-enforced maximum which is currently 1 page.411 if (max_packet_size > (unsigned int)getpagesize())412 max_packet_size = getpagesize();413 414 unsigned int irq_interval=packets_per_period / MINIMUM_INTERRUPTS_PER_PERIOD;415 if(irq_interval <= 0) irq_interval=1;394 // hardware interrupts occur when one DMA block is full, and the size of one DMA 395 // block = PAGE_SIZE. Setting the max_packet_size makes sure that the HW irq 396 // occurs at a period boundary (optimal CPU use) 397 // NOTE: try and use MINIMUM_INTERRUPTS_PER_PERIOD interrupts per period 398 // for better latency. 399 unsigned int max_packet_size=MINIMUM_INTERRUPTS_PER_PERIOD * getpagesize() / packets_per_period; 400 if (max_packet_size < stream->getMaxPacketSize()) { 401 max_packet_size=stream->getMaxPacketSize(); 402 } 403 404 // Ensure we don't request a packet size bigger than the 405 // kernel-enforced maximum which is currently 1 page. 406 if (max_packet_size > (unsigned int)getpagesize()) 407 max_packet_size = getpagesize(); 408 409 unsigned int irq_interval=packets_per_period / MINIMUM_INTERRUPTS_PER_PERIOD; 410 if(irq_interval <= 0) irq_interval=1; 416 411 #else 417 // hardware interrupts occur when one DMA block is full, and the size of one DMA418 // block = PAGE_SIZE. Setting the max_packet_size enables control over the IRQ419 // frequency, as the controller uses max_packet_size, and not the effective size420 // when writing to the DMA buffer.421 422 // configure it such that we have an irq for every PACKETS_PER_INTERRUPT packets423 unsigned int irq_interval=PACKETS_PER_INTERRUPT;424 425 // unless the period size doesn't allow this426 if ((packets_per_period/MINIMUM_INTERRUPTS_PER_PERIOD) < irq_interval) {427 irq_interval=1;428 }429 430 // FIXME: test431 irq_interval=1;432 433 unsigned int max_packet_size=getpagesize() / irq_interval;434 435 if (max_packet_size < stream->getMaxPacketSize()) {436 max_packet_size=stream->getMaxPacketSize();437 }438 439 // Ensure we don't request a packet size bigger than the440 // kernel-enforced maximum which is currently 1 page.441 if (max_packet_size > (unsigned int)getpagesize())442 max_packet_size = getpagesize();412 // hardware interrupts occur when one DMA block is full, and the size of one DMA 413 // block = PAGE_SIZE. Setting the max_packet_size enables control over the IRQ 414 // frequency, as the controller uses max_packet_size, and not the effective size 415 // when writing to the DMA buffer. 416 417 // configure it such that we have an irq for every PACKETS_PER_INTERRUPT packets 418 unsigned int irq_interval=PACKETS_PER_INTERRUPT; 419 420 // unless the period size doesn't allow this 421 if ((packets_per_period/MINIMUM_INTERRUPTS_PER_PERIOD) < irq_interval) { 422 irq_interval=1; 423 } 424 425 // FIXME: test 426 irq_interval=1; 427 428 unsigned int max_packet_size=getpagesize() / irq_interval; 429 430 if (max_packet_size < stream->getMaxPacketSize()) { 431 max_packet_size=stream->getMaxPacketSize(); 432 } 433 434 // Ensure we don't request a packet size bigger than the 435 // kernel-enforced maximum which is currently 1 page. 436 if (max_packet_size > (unsigned int)getpagesize()) 437 max_packet_size = getpagesize(); 443 438 #endif 444 // the transmit buffer size should be as low as possible for latency. 445 // note however that the raw1394 subsystem tries to keep this buffer446 // full, so we have to make sure that we have enough events in our447 // event buffers448 449 // every irq_interval packets an interrupt will occur. that is when450 // buffers get transfered, meaning that we should have at least some451 // margin here452 int buffers=irq_interval * 2;453 454 // half a period. the xmit handler will take care of this455 // int buffers=packets_per_period/4;456 457 // NOTE: this is dangerous: what if there is not enough prefill?458 // if (buffers<10) buffers=10;459 460 // create the actual handler461 IsoXmitHandler *h = new IsoXmitHandler(stream->getPort(), buffers,462 max_packet_size, irq_interval);463 464 debugOutput( DEBUG_LEVEL_VERBOSE, " registering IsoXmitHandler\n");465 466 if(!h) {467 debugFatal("Could not create IsoXmitHandler\n");468 return false;469 }470 471 h->setVerboseLevel(getDebugLevel());472 473 // init the handler474 if(!h->init()) {475 debugFatal("Could not initialize transmit handler\n");476 return false;477 }478 479 // register the stream with the handler480 if(!h->registerStream(stream)) {481 debugFatal("Could not register transmit stream with handler\n");482 return false;483 }484 485 // register the handler with the manager486 if(!registerHandler(h)) {487 debugFatal("Could not register transmit handler with manager\n");488 return false;489 }490 debugOutput( DEBUG_LEVEL_VERBOSE, " registered stream (%p) with handler (%p)\n",stream,h);491 }492 493 m_IsoStreams.push_back(stream);494 debugOutput( DEBUG_LEVEL_VERBOSE, " %d streams, %d handlers registered\n",495 m_IsoStreams.size(), m_IsoHandlers.size());496 497 return true;439 // the transmit buffer size should be as low as possible for latency. 440 // note however that the raw1394 subsystem tries to keep this buffer 441 // full, so we have to make sure that we have enough events in our 442 // event buffers 443 444 // every irq_interval packets an interrupt will occur. that is when 445 // buffers get transfered, meaning that we should have at least some 446 // margin here 447 int buffers=irq_interval * 2; 448 449 // half a period. the xmit handler will take care of this 450 // int buffers=packets_per_period/4; 451 452 // NOTE: this is dangerous: what if there is not enough prefill? 453 // if (buffers<10) buffers=10; 454 455 // create the actual handler 456 IsoXmitHandler *h = new IsoXmitHandler(stream->getPort(), buffers, 457 max_packet_size, irq_interval); 458 459 debugOutput( DEBUG_LEVEL_VERBOSE, " registering IsoXmitHandler\n"); 460 461 if(!h) { 462 debugFatal("Could not create IsoXmitHandler\n"); 463 return false; 464 } 465 466 h->setVerboseLevel(getDebugLevel()); 467 468 // init the handler 469 if(!h->init()) { 470 debugFatal("Could not initialize transmit handler\n"); 471 return false; 472 } 473 474 // register the stream with the handler 475 if(!h->registerStream(stream)) { 476 debugFatal("Could not register transmit stream with handler\n"); 477 return false; 478 } 479 480 // register the handler with the manager 481 if(!registerHandler(h)) { 482 debugFatal("Could not register transmit handler with manager\n"); 483 return false; 484 } 485 debugOutput( DEBUG_LEVEL_VERBOSE, " registered stream (%p) with handler (%p)\n",stream,h); 486 } 487 488 m_IsoStreams.push_back(stream); 489 debugOutput( DEBUG_LEVEL_VERBOSE, " %d streams, %d handlers registered\n", 490 m_IsoStreams.size(), m_IsoHandlers.size()); 491 492 return true; 498 493 } 499 494 500 495 bool IsoHandlerManager::unregisterStream(IsoStream *stream) 501 496 { 502 debugOutput( DEBUG_LEVEL_VERBOSE, "Unregistering stream %p\n",stream);503 assert(stream);504 505 // make sure the stream isn't attached to a handler anymore506 for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin();507 it != m_IsoHandlers.end();508 ++it )509 {510 if((*it)->isStreamRegistered(stream)) {511 if(!(*it)->unregisterStream(stream)) {512 debugOutput( DEBUG_LEVEL_VERBOSE, " could not unregister stream (%p) from handler (%p)...\n",stream,*it);513 return false;514 }515 516 debugOutput( DEBUG_LEVEL_VERBOSE, " unregistered stream (%p) from handler (%p)...\n",stream,*it);517 }518 }519 520 // clean up all handlers that aren't used521 pruneHandlers();522 523 // remove the stream from the registered streams list524 for ( IsoStreamVectorIterator it = m_IsoStreams.begin();525 it != m_IsoStreams.end();526 ++it )527 {528 if ( *it == stream ) { 529 m_IsoStreams.erase(it);530 531 debugOutput( DEBUG_LEVEL_VERBOSE, " deleted stream (%p) from list...\n", *it);532 return true;533 }534 }535 536 return false; //not found497 debugOutput( DEBUG_LEVEL_VERBOSE, "Unregistering stream %p\n",stream); 498 assert(stream); 499 500 // make sure the stream isn't attached to a handler anymore 501 for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin(); 502 it != m_IsoHandlers.end(); 503 ++it ) 504 { 505 if((*it)->isStreamRegistered(stream)) { 506 if(!(*it)->unregisterStream(stream)) { 507 debugOutput( DEBUG_LEVEL_VERBOSE, " could not unregister stream (%p) from handler (%p)...\n",stream,*it); 508 return false; 509 } 510 511 debugOutput( DEBUG_LEVEL_VERBOSE, " unregistered stream (%p) from handler (%p)...\n",stream,*it); 512 } 513 } 514 515 // clean up all handlers that aren't used 516 pruneHandlers(); 517 518 // remove the stream from the registered streams list 519 for ( IsoStreamVectorIterator it = m_IsoStreams.begin(); 520 it != m_IsoStreams.end(); 521 ++it ) 522 { 523 if ( *it == stream ) { 524 m_IsoStreams.erase(it); 525 526 debugOutput( DEBUG_LEVEL_VERBOSE, " deleted stream (%p) from list...\n", *it); 527 return true; 528 } 529 } 530 531 return false; //not found 537 532 538 533 } … … 577 572 { 578 573 bool retval=true; 579 580 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 581 574 575 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 576 582 577 // check state 583 578 if(m_State != E_Created) { … … 585 580 return false; 586 581 } 587 582 588 583 for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin(); 589 584 it != m_IsoHandlers.end(); … … 611 606 bool IsoHandlerManager::startHandlers(int cycle) { 612 607 bool retval=true; 613 614 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 615 608 609 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 610 616 611 // check state 617 612 if(m_State != E_Prepared) { … … 619 614 return false; 620 615 } 621 616 622 617 for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin(); 623 618 it != m_IsoHandlers.end(); … … 630 625 } 631 626 } 632 627 633 628 debugOutput( DEBUG_LEVEL_VERBOSE, "Starting ISO iterator thread...\n"); 634 629 635 // note: libraw1394 doesn't like it if you poll() and/or iterate() before 630 // note: libraw1394 doesn't like it if you poll() and/or iterate() before 636 631 // starting the streams. 637 632 // start the iso runner thread 638 633 m_isoManagerThread->Start(); 639 634 640 635 if (retval) { 641 636 m_State=E_Running; … … 649 644 bool IsoHandlerManager::stopHandlers() { 650 645 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 651 646 652 647 // check state 653 648 if(m_State != E_Running) { … … 655 650 return false; 656 651 } 657 652 658 653 bool retval=true; 659 654 660 655 debugOutput( DEBUG_LEVEL_VERBOSE, "Stopping ISO iterator thread...\n"); 661 656 m_isoManagerThread->Stop(); 662 657 663 658 for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin(); 664 659 it != m_IsoHandlers.end(); … … 671 666 } 672 667 } 673 668 674 669 if (retval) { 675 670 m_State=E_Prepared; … … 677 672 m_State=E_Error; 678 673 } 679 674 680 675 return retval; 681 676 } … … 683 678 bool IsoHandlerManager::reset() { 684 679 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 685 680 686 681 // check state 687 682 if(m_State == E_Error) { … … 689 684 return false; 690 685 } 691 686 692 687 // if not in an error condition, reset means stop the handlers 693 688 return stopHandlers(); … … 708 703 void IsoHandlerManager::dumpInfo() { 709 704 int i=0; 710 705 711 706 debugOutputShort( DEBUG_LEVEL_NORMAL, "Dumping IsoHandlerManager Stream handler information...\n"); 712 707 debugOutputShort( DEBUG_LEVEL_NORMAL, " State: %d\n",(int)m_State); trunk/libffado/src/libstreaming/IsoHandlerManager.h
r419 r445 1 /* $Id$ */ 1 /* 2 * Copyright (C) 2005-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 */ 2 23 3 /* 4 * FreeBob streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 27 */ 28 #ifndef __FREEBOB_ISOHANDLERMANAGER__ 29 #define __FREEBOB_ISOHANDLERMANAGER__ 24 #ifndef __FFADO_ISOHANDLERMANAGER__ 25 #define __FFADO_ISOHANDLERMANAGER__ 30 26 31 27 #include "../debugmodule/debugmodule.h" … … 89 85 bool unregisterStream(IsoStream *); ///< unregister an iso stream from the manager 90 86 91 bool startHandlers(); ///< start the managed ISO handlers 92 bool startHandlers(int cycle); ///< start the managed ISO handlers 93 bool stopHandlers(); ///< stop the managed ISO handlers 87 bool startHandlers(); ///< start the managed ISO handlers 88 bool startHandlers(int cycle); ///< start the managed ISO handlers 89 bool stopHandlers(); ///< stop the managed ISO handlers 94 90 95 91 bool reset(); ///< reset the ISO manager and all streams 96 92 97 93 bool prepare(); ///< prepare the ISO manager and all streams 98 94 99 95 bool init(); 100 96 101 97 void disablePolling(IsoStream *); ///< disables polling on a stream 102 98 void enablePolling(IsoStream *); ///< enables polling on a stream … … 106 102 bool Execute(); // note that this is called in we while(running) loop 107 103 bool Init(); 108 104 109 105 // the state machine 110 106 private: … … 115 111 E_Error 116 112 }; 117 113 118 114 enum EHandlerStates m_State; 119 115 120 116 private: 121 117 /// iterate all child handlers … … 124 120 private: 125 121 // note: there is a disctinction between streams and handlers 126 // because one handler can serve multiple streams (in case of 122 // because one handler can serve multiple streams (in case of 127 123 // multichannel receive) 128 124 … … 152 148 unsigned int m_priority; 153 149 Util::PosixThread *m_isoManagerThread; 154 155 150 151 156 152 // debug stuff 157 153 DECLARE_DEBUG_MODULE; … … 161 157 } 162 158 163 #endif /* __F REEBOB_ISOHANDLERMANAGER__ */159 #endif /* __FFADO_ISOHANDLERMANAGER__ */ 164 160 165 161 trunk/libffado/src/libstreaming/IsoStream.cpp
r419 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 2 * Copyright (C) 2005-2007 by Pieter Palmers 6 3 * 7 * http://freebob.sf.net 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 8 6 * 9 * Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net>7 * FFADO is based upon FreeBoB. 10 8 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 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; 15 12 * 16 * This programis distributed in the hope that it will be useful,17 * but WITHOUT ANY WARRANTY {}without even the implied warranty of18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the19 * GNUGeneral Public License for more details.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. 20 17 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 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 27 22 */ 28 23 … … 35 30 IMPL_DEBUG_MODULE( IsoStream, IsoStream, DEBUG_LEVEL_NORMAL ); 36 31 37 enum raw1394_iso_disposition 38 IsoStream::putPacket(unsigned char *data, unsigned int length, 39 unsigned char channel, unsigned char tag, unsigned char sy, 32 enum raw1394_iso_disposition 33 IsoStream::putPacket(unsigned char *data, unsigned int length, 34 unsigned char channel, unsigned char tag, unsigned char sy, 40 35 unsigned int cycle, unsigned int dropped) { 41 36 … … 47 42 } 48 43 49 enum raw1394_iso_disposition 44 enum raw1394_iso_disposition 50 45 IsoStream::getPacket(unsigned char *data, unsigned int *length, 51 46 unsigned char *tag, unsigned char *sy, trunk/libffado/src/libstreaming/IsoStream.h
r419 r445 1 /* $Id$ */ 1 /* 2 * Copyright (C) 2005-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 */ 2 23 3 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 27 */ 28 #ifndef __FREEBOB_ISOSTREAM__ 29 #define __FREEBOB_ISOSTREAM__ 24 #ifndef __FFADO_ISOSTREAM__ 25 #define __FFADO_ISOSTREAM__ 30 26 31 27 #include <libraw1394/raw1394.h> … … 55 51 }; 56 52 57 IsoStream(enum EStreamType type) 53 IsoStream(enum EStreamType type) 58 54 : m_type(type), m_channel(-1), m_port(0), m_handler(0) 59 55 {}; 60 IsoStream(enum EStreamType type, int port) 56 IsoStream(enum EStreamType type, int port) 61 57 : m_type(type), m_channel(-1), m_port(port), m_handler(0) 62 58 {}; 63 59 virtual ~IsoStream() 64 60 {}; 65 61 66 62 virtual void setVerboseLevel(int l) { setDebugLevel( l ); }; 67 63 … … 75 71 virtual unsigned int getPacketsPerPeriod() {return 1;}; 76 72 virtual unsigned int getMaxPacketSize() {return 1024;}; //FIXME: arbitrary 77 73 78 74 virtual bool init(); 79 75 80 virtual enum raw1394_iso_disposition 81 putPacket(unsigned char *data, unsigned int length, 82 unsigned char channel, unsigned char tag, unsigned char sy, 76 virtual enum raw1394_iso_disposition 77 putPacket(unsigned char *data, unsigned int length, 78 unsigned char channel, unsigned char tag, unsigned char sy, 83 79 unsigned int cycle, unsigned int dropped); 84 virtual enum raw1394_iso_disposition 80 virtual enum raw1394_iso_disposition 85 81 getPacket(unsigned char *data, unsigned int *length, 86 82 unsigned char *tag, unsigned char *sy, … … 90 86 91 87 int getNodeId(); 92 88 93 89 virtual bool reset(); 94 virtual bool prepare(); 95 90 virtual bool prepare(); 91 96 92 protected: 97 93 … … 104 100 105 101 IsoHandler *m_handler; 106 102 107 103 DECLARE_DEBUG_MODULE; 108 104 … … 111 107 } 112 108 113 #endif /* __F REEBOB_ISOSTREAM__ */109 #endif /* __FFADO_ISOSTREAM__ */ 114 110 115 111 trunk/libffado/src/libstreaming/MotuPort.cpp
r419 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob Streaming API5 * FreeBob = Firewire (pro-)audio for linux2 * Copyright (C) 2005-2007 by Jonathan Woithe 3 * Copyright (C) 2005-2007 by Pieter Palmers 6 4 * 7 * http://freebob.sf.net 5 * This file is part of FFADO 6 * FFADO = Free Firewire (pro-)audio drivers for linux 8 7 * 9 * Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net>8 * FFADO is based upon FreeBoB. 10 9 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 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; 15 13 * 16 * This programis distributed in the hope that it will be useful,17 * but WITHOUT ANY WARRANTY {}without even the implied warranty of18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the19 * GNUGeneral Public License for more details.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. 20 18 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 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 27 23 */ 28 24 trunk/libffado/src/libstreaming/MotuPort.h
r419 r445 1 /* $Id$ */ 1 /* 2 * Copyright (C) 2005-2007 by Jonathan Woithe 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 */ 2 24 3 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 27 */ 28 #ifndef __FREEBOB_MOTUPORT__ 29 #define __FREEBOB_MOTUPORT__ 25 #ifndef __FFADO_MOTUPORT__ 26 #define __FFADO_MOTUPORT__ 30 27 31 28 /** … … 44 41 45 42 */ 46 class MotuAudioPort 47 : public AudioPort, public MotuPortInfo43 class MotuAudioPort 44 : public AudioPort, public MotuPortInfo 48 45 { 49 46 50 47 public: 51 48 52 MotuAudioPort(std::string name, 53 enum E_Direction direction,54 int position,55 int size)56 : AudioPort(name, direction),57 MotuPortInfo(name, position, size) // TODO: add more port information parameters here if nescessary58 {};49 MotuAudioPort(std::string name, 50 enum E_Direction direction, 51 int position, 52 int size) 53 : AudioPort(name, direction), 54 MotuPortInfo(name, position, size) // TODO: add more port information parameters here if nescessary 55 {}; 59 56 60 virtual ~MotuAudioPort() {};61 57 virtual ~MotuAudioPort() {}; 58 62 59 protected: 63 60 … … 69 66 70 67 */ 71 class MotuMidiPort 72 : public MidiPort, public MotuPortInfo68 class MotuMidiPort 69 : public MidiPort, public MotuPortInfo 73 70 { 74 71 75 72 public: 76 73 77 MotuMidiPort(std::string name, 78 enum E_Direction direction,79 int position)80 : MidiPort(name, direction),81 MotuPortInfo(name, position, 0) // TODO: add more port information parameters here if nescessary82 {};74 MotuMidiPort(std::string name, 75 enum E_Direction direction, 76 int position) 77 : MidiPort(name, direction), 78 MotuPortInfo(name, position, 0) // TODO: add more port information parameters here if nescessary 79 {}; 83 80 84 81 85 virtual ~MotuMidiPort() {};82 virtual ~MotuMidiPort() {}; 86 83 87 84 protected: 88 85 89 86 }; 90 87 … … 94 91 95 92 */ 96 class MotuControlPort 97 : public ControlPort, public MotuPortInfo93 class MotuControlPort 94 : public ControlPort, public MotuPortInfo 98 95 { 99 96 100 97 public: 101 98 102 MotuControlPort(std::string name, 103 enum E_Direction direction,104 int position)105 : ControlPort(name, direction),106 MotuPortInfo(name, position, 2) // TODO: add more port information parameters here if nescessary 107 {};99 MotuControlPort(std::string name, 100 enum E_Direction direction, 101 int position) 102 : ControlPort(name, direction), 103 MotuPortInfo(name, position, 2) // TODO: add more port information parameters here if nescessary 104 {}; 108 105 109 106 110 virtual ~MotuControlPort() {};107 virtual ~MotuControlPort() {}; 111 108 112 109 protected: 113 110 114 111 }; 115 112 116 113 } // end of namespace Streaming 117 114 118 #endif /* __F REEBOB_MOTUPORT__ */115 #endif /* __FFADO_MOTUPORT__ */ 119 116 trunk/libffado/src/libstreaming/MotuPortInfo.cpp
r419 r445 1 /* $Id$ */ 1 /* 2 * Copyright (C) 2005-2007 by Jonathan Woithe 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 */ 2 24 3 /*4 * FreeBob Streaming API5 * FreeBob = Firewire (pro-)audio for linux6 *7 * http://freebob.sf.net8 *9 * Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net>10 *11 * This program is free software {} you can redistribute it and/or modify12 * it under the terms of the GNU General Public License as published by13 * the Free Software Foundation {} either version 2 of the License, or14 * (at your option) any later version.15 *16 * This program is distributed in the hope that it will be useful,17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the19 * GNU General Public License for more details.20 *21 * You should have received a copy of the GNU General Public License22 * along with this program {} if not, write to the Free Software23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.24 *25 *26 *27 */28 25 #include "MotuPortInfo.h" 29 26 #include <assert.h> trunk/libffado/src/libstreaming/MotuPortInfo.h
r419 r445 1 /* $Id$ */ 1 /* 2 * Copyright (C) 2005-2007 by Jonathan Woithe 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 */ 2 24 3 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 27 */ 28 #ifndef __FREEBOB_MOTUPORTINFO__ 29 #define __FREEBOB_MOTUPORTINFO__ 25 #ifndef __FFADO_MOTUPORTINFO__ 26 #define __FFADO_MOTUPORTINFO__ 30 27 31 28 #include "../debugmodule/debugmodule.h" … … 36 33 \brief Class containing the stream information for a Motu channel 37 34 38 Contains the information that enables the decoding routine to find 39 this port's data in the ISO events 35 Contains the information that enables the decoding routine to find 36 this port's data in the ISO events 40 37 41 38 */ … … 44 41 public: 45 42 /** 46 * Sometimes a channel can have multiple formats, depending on the 43 * Sometimes a channel can have multiple formats, depending on the 47 44 * device configuration (e.g. an SPDIF port could be plain audio in 24bit integer 48 * or AC3 passthrough in IEC compliant frames.) 45 * or AC3 passthrough in IEC compliant frames.) 49 46 * 50 47 * This kind of enum allows to discriminate these formats when decoding 51 48 * If all channels always have the same format, you won't be needing this 52 49 */ 53 // enum E_Formats {54 // E_MBLA, // Multibit linear audio55 // E_Midi, // MIDI56 // };57 58 /**59 * Initialize Motu portinfo60 * should not be called directly, is inherited by motu ports61 *62 * the position parameter is an example63 * the name parameter is mandatory64 *65 * @param name Port name66 * @param position Start position of port's data in iso event67 * @param format Format of data in iso event68 * @param size Size in bits of port's data in iso event69 * @return 70 */71 MotuPortInfo(std::string name, int position, int size)72 : m_name(name), m_position(position), m_size(size)73 {};74 virtual ~MotuPortInfo() {};50 // enum E_Formats { 51 // E_MBLA, // Multibit linear audio 52 // E_Midi, // MIDI 53 // }; 54 55 /** 56 * Initialize Motu portinfo 57 * should not be called directly, is inherited by motu ports 58 * 59 * the position parameter is an example 60 * the name parameter is mandatory 61 * 62 * @param name Port name 63 * @param position Start position of port's data in iso event 64 * @param format Format of data in iso event 65 * @param size Size in bits of port's data in iso event 66 * @return 67 */ 68 MotuPortInfo(std::string name, int position, int size) 69 : m_name(name), m_position(position), m_size(size) 70 {}; 71 virtual ~MotuPortInfo() {}; 75 72 76 73 77 std::string getName() {return m_name;};78 int getPosition() {return m_position;};79 int getSize() {return m_size;};74 std::string getName() {return m_name;}; 75 int getPosition() {return m_position;}; 76 int getSize() {return m_size;}; 80 77 81 78 protected: … … 89 86 } // end of namespace Streaming 90 87 91 #endif /* __F REEBOB_MOTUPORTINFO__ */88 #endif /* __FFADO_MOTUPORTINFO__ */ trunk/libffado/src/libstreaming/MotuStreamProcessor.cpp
r430 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob Streaming API5 * FreeBob = Firewire (pro-)audio for linux2 * Copyright (C) 2005-2007 by Jonathan Woithe 3 * Copyright (C) 2005-2007 by Pieter Palmers 6 4 * 7 * http://freebob.sf.net 5 * This file is part of FFADO 6 * FFADO = Free Firewire (pro-)audio drivers for linux 8 7 * 9 * Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * Copyright (C) 2006 Jonathan Woithe <jwoithe@physics.adelaide.edu.au> 8 * FFADO is based upon FreeBoB. 11 9 * 12 * This program is free software {} you can redistribute it and/or modify 13 * it under the terms of the GNU General Public License as published by 14 * the Free Software Foundation {} either version 2 of the License, or 15 * (at your option) any later version. 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; 16 13 * 17 * This programis distributed in the hope that it will be useful,18 * but WITHOUT ANY WARRANTY {}without even the implied warranty of19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the20 * GNUGeneral Public License for more details.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. 21 18 * 22 * You should have received a copy of the GNU General Public License 23 * along with this program {} if not, write to the Free Software 24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 25 * 26 * 27 * 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 28 23 */ 24 29 25 #include "MotuStreamProcessor.h" 30 26 #include "Port.h" … … 61 57 uint32_t ts_sec = CYCLE_TIMER_GET_SECS(ct_now); 62 58 // If the cycles have wrapped, correct ts_sec so it represents when timestamp 63 // was received. The timestamps sent by the MOTU are always 1 or two cycles 59 // was received. The timestamps sent by the MOTU are always 1 or two cycles 64 60 // in advance of the cycle timer (reasons unknown at this stage). In addition, 65 61 // iso buffering can delay the arrival of packets for quite a number of cycles … … 82 78 /* transmit */ 83 79 MotuTransmitStreamProcessor::MotuTransmitStreamProcessor(int port, int framerate, 84 unsigned int event_size)85 : TransmitStreamProcessor(port, framerate), m_event_size(event_size),86 m_tx_dbc(0),87 m_closedown_count(-1), m_streaming_active(0) {80 unsigned int event_size) 81 : TransmitStreamProcessor(port, framerate), m_event_size(event_size), 82 m_tx_dbc(0), 83 m_closedown_count(-1), m_streaming_active(0) { 88 84 } 89 85 … … 94 90 bool MotuTransmitStreamProcessor::init() { 95 91 96 debugOutput( DEBUG_LEVEL_VERBOSE, "Initializing (%p)...\n");97 // call the parent init98 // this has to be done before allocating the buffers, 99 // because this sets the buffersizes from the processormanager100 if(!TransmitStreamProcessor::init()) {101 debugFatal("Could not do base class init (%p)\n",this);102 return false;103 }104 105 return true;92 debugOutput( DEBUG_LEVEL_VERBOSE, "Initializing (%p)...\n"); 93 // call the parent init 94 // this has to be done before allocating the buffers, 95 // because this sets the buffersizes from the processormanager 96 if(!TransmitStreamProcessor::init()) { 97 debugFatal("Could not do base class init (%p)\n",this); 98 return false; 99 } 100 101 return true; 106 102 } 107 103 108 104 void MotuTransmitStreamProcessor::setVerboseLevel(int l) { 109 setDebugLevel(l); // sets the debug level of the current object110 TransmitStreamProcessor::setVerboseLevel(l); // also set the level of the base class105 setDebugLevel(l); // sets the debug level of the current object 106 TransmitStreamProcessor::setVerboseLevel(l); // also set the level of the base class 111 107 } 112 108 … … 114 110 enum raw1394_iso_disposition 115 111 MotuTransmitStreamProcessor::getPacket(unsigned char *data, unsigned int *length, 116 unsigned char *tag, unsigned char *sy,117 int cycle, unsigned int dropped, unsigned int max_length) {112 unsigned char *tag, unsigned char *sy, 113 int cycle, unsigned int dropped, unsigned int max_length) { 118 114 119 115 // FIXME: the actual delays in the system need to be worked out so … … 121 117 uint64_t ts_head, fc; 122 118 123 quadlet_t *quadlet = (quadlet_t *)data;124 signed int i;125 119 quadlet_t *quadlet = (quadlet_t *)data; 120 signed int i; 121 126 122 m_last_cycle=cycle; 127 123 128 124 // determine if we want to send a packet or not 129 125 // note that we can't use getCycleTimer directly here, 130 126 // because packets are queued in advance. This means that 131 // we the packet we are constructing will be sent out 127 // we the packet we are constructing will be sent out 132 128 // on 'cycle', not 'now'. 133 129 unsigned int ctr=m_handler->getCycleTimer(); 134 130 int now_cycles = (int)CYCLE_TIMER_GET_CYCLES(ctr); 135 131 136 132 // the difference between the cycle this 137 133 // packet is intended for and 'now' 138 134 int cycle_diff = diffCycles(cycle, now_cycles); 139 140 // Signal that streaming is still active141 m_streaming_active = 1;135 136 // Signal that streaming is still active 137 m_streaming_active = 1; 142 138 143 139 // as long as the cycle parameter is not in sync with … … 154 150 if ((unsigned int)cycle == m_cycle_to_enable_at) { 155 151 m_is_disabled=false; 156 152 157 153 debugOutput(DEBUG_LEVEL_VERBOSE,"Enabling StreamProcessor %p at %u\n", this, cycle); 158 154 159 155 // initialize the buffer head & tail 160 156 m_SyncSource->m_data_buffer->getBufferHeadTimestamp(&ts_head, &fc); // thread safe 161 157 162 158 // the number of cycles the sync source lags (> 0) 163 159 // or leads (< 0) 164 160 int sync_lag_cycles=diffCycles(cycle, m_SyncSource->getLastCycle()); 165 161 166 162 // account for the cycle lag between sync SP and this SP 167 163 // the last update of the sync source's timestamps was sync_lag_cycles 168 164 // cycles before the cycle we are calculating the timestamp for. 169 // if we were to use one-frame buffers, you would expect the 165 // if we were to use one-frame buffers, you would expect the 170 166 // frame that is sent on cycle CT to have a timestamp T1. 171 167 // ts_head however is for cycle CT-sync_lag_cycles, and lies … … 173 169 // T1. 174 170 ts_head = addTicks(ts_head, sync_lag_cycles * TICKS_PER_CYCLE); 175 171 176 172 m_data_buffer->setBufferTailTimestamp(ts_head); 177 173 178 174 #ifdef DEBUG 179 175 if ((unsigned int)m_data_buffer->getFrameCounter() != m_data_buffer->getBufferSize()) { … … 190 186 } else if (m_disabled && !m_is_disabled) { 191 187 // trying to disable 192 debugOutput(DEBUG_LEVEL_VERBOSE,"disabling StreamProcessor %p at %u\n", 188 debugOutput(DEBUG_LEVEL_VERBOSE,"disabling StreamProcessor %p at %u\n", 193 189 this, cycle); 194 190 m_is_disabled=true; 195 191 } 196 192 197 // Do housekeeping expected for all packets sent to the MOTU, even198 // for packets containing no audio data.199 *sy = 0x00;200 *tag = 1; // All MOTU packets have a CIP-like header193 // Do housekeeping expected for all packets sent to the MOTU, even 194 // for packets containing no audio data. 195 *sy = 0x00; 196 *tag = 1; // All MOTU packets have a CIP-like header 201 197 202 198 203 199 // the base timestamp is the one of the next sample in the buffer 204 200 m_data_buffer->getBufferHeadTimestamp(&ts_head, &fc); // thread safe 205 201 206 202 int64_t timestamp = ts_head; 207 203 208 204 // we send a packet some cycles in advance, to avoid the 209 205 // following situation: 210 // suppose we are only a few ticks away from 206 // suppose we are only a few ticks away from 211 207 // the moment to send this packet. therefore we decide 212 208 // not to send the packet, but send it in the next cycle. 213 209 // This means that the next time point will be 3072 ticks 214 // later, making that the timestamp will be expired when the 210 // later, making that the timestamp will be expired when the 215 211 // packet is sent, unless TRANSFER_DELAY > 3072. 216 212 // this means that we need at least one cycle of extra buffering. 217 213 uint64_t ticks_to_advance = TICKS_PER_CYCLE * TRANSMIT_ADVANCE_CYCLES; 218 214 219 215 // if cycle lies cycle_diff cycles in the future, we should 220 216 // queue this packet cycle_diff * TICKS_PER_CYCLE earlier than … … 224 220 // determine the 'now' time in ticks 225 221 uint64_t cycle_timer=CYCLE_TIMER_TO_TICKS(ctr); 226 222 227 223 // time until the packet is to be sent (if > 0: send packet) 228 224 int32_t until_next=diffTicks(timestamp, cycle_timer + ticks_to_advance); 229 230 // Size of a single data frame in quadlets231 unsigned dbs = m_event_size / 4;232 225 226 // Size of a single data frame in quadlets 227 unsigned dbs = m_event_size / 4; 228 233 229 // don't process the stream when it is not enabled, not running 234 230 // or when the next sample is not due yet. 235 231 if((until_next>0) || m_is_disabled || !m_running) { 236 232 // send dummy packet 237 238 // construct the packet CIP-like header. Even if this is a data-less 239 // packet the dbs field is still set as if there were data blocks 233 234 // construct the packet CIP-like header. Even if this is a data-less 235 // packet the dbs field is still set as if there were data blocks 240 236 // present. For data-less packets the dbc is the same as the previously 241 237 // transmitted block. … … 245 241 quadlet++; 246 242 *length = 8; 247 243 248 244 #warning high-pitched sound protection removed! 249 245 // In the disabled state simply zero all data sent to the MOTU. If … … 252 248 // some reason. This is not completely sufficient, however (zeroed 253 249 // packets must also be sent on iso closedown). 254 250 255 251 // FIXME: Currently we simply send empty packets to the MOTU when 256 252 // the stream is disabled so the "m_disabled == 0" code is never 257 // executed. However, this may change in future so it's left in 253 // executed. However, this may change in future so it's left in 258 254 // for the moment for reference. 259 255 // FIXME: Currently we don't read the buffer at all during closedown. … … 263 259 //if (!m_is_disabled && m_running) 264 260 // return RAW1394_ISO_OK; 265 //else 261 //else 266 262 return RAW1394_ISO_DEFER; 267 263 } 268 264 269 // The number of events expected by the MOTU is solely dependent on270 // the current sample rate. An 'event' is one sample from all channels271 // plus possibly other midi and control data.272 signed n_events = m_framerate<=48000?8:(m_framerate<=96000?16:32);265 // The number of events expected by the MOTU is solely dependent on 266 // the current sample rate. An 'event' is one sample from all channels 267 // plus possibly other midi and control data. 268 signed n_events = m_framerate<=48000?8:(m_framerate<=96000?16:32); 273 269 274 270 // add the transmit transfer delay to construct the playout time 275 271 uint64_t ts=addTicks(timestamp, TRANSMIT_TRANSFER_DELAY); 276 272 277 273 if (m_data_buffer->readFrames(n_events, (char *)(data + 8))) { 278 274 279 275 // Increment the dbc (data block count). This is only done if the 280 276 // packet will contain events - that is, we are due to send some … … 286 282 if (m_tx_dbc > 0xff) 287 283 m_tx_dbc -= 0x100; 288 289 // construct the packet CIP-like header. Even if this is a data-less 290 // packet the dbs field is still set as if there were data blocks 284 285 // construct the packet CIP-like header. Even if this is a data-less 286 // packet the dbs field is still set as if there were data blocks 291 287 // present. For data-less packets the dbc is the same as the previously 292 288 // transmitted block. … … 301 297 // I assume that it is in ticks, and wraps as the cycle timer 302 298 #warning syt conversion to be done 303 304 // FIXME: if we choose to read the buffer even during closedown,305 // here is where the data is silenced.306 // if (m_closedown_count >= 0)307 // memset(data+8, 0, read_size);308 if (m_closedown_count > 0)309 m_closedown_count--;310 311 // Set up each frames's SPH. Note that the (int) typecast312 // appears to do rounding.299 300 // FIXME: if we choose to read the buffer even during closedown, 301 // here is where the data is silenced. 302 // if (m_closedown_count >= 0) 303 // memset(data+8, 0, read_size); 304 if (m_closedown_count > 0) 305 m_closedown_count--; 306 307 // Set up each frames's SPH. Note that the (int) typecast 308 // appears to do rounding. 313 309 314 310 float ticks_per_frame = m_SyncSource->m_data_buffer->getRate(); 315 for (i=0; i<n_events; i++, quadlet += dbs) {316 // unsigned int ts_frame = ts;317 unsigned int ts_frame = timestamp;318 ts_frame += (unsigned int)((float)i * ticks_per_frame);319 *quadlet = htonl( TICKS_TO_CYCLE_TIMER(ts_frame) & 0x1ffffff);311 for (i=0; i<n_events; i++, quadlet += dbs) { 312 // unsigned int ts_frame = ts; 313 unsigned int ts_frame = timestamp; 314 ts_frame += (unsigned int)((float)i * ticks_per_frame); 315 *quadlet = htonl( TICKS_TO_CYCLE_TIMER(ts_frame) & 0x1ffffff); 320 316 if (cycle==0) { 321 317 debugOutput(DEBUG_LEVEL_VERBOSE,"%d %d %d\n", … … 325 321 } 326 322 #if TESTTONE 327 // FIXME: remove this hacked in 1 kHz test signal to328 // analog-1 when testing is complete. Note that the tone is329 // *never* added during closedown.330 if (m_closedown_count<0) {331 static signed int a_cx = 0;332 signed int val;333 val = (int)(0x7fffff*sin(1000.0*2.0*M_PI*(a_cx/24576000.0)));334 if ((a_cx+=512) >= 24576000) {335 a_cx -= 24576000;336 }337 *(data+8+i*m_event_size+16) = (val >> 16) & 0xff;338 *(data+8+i*m_event_size+17) = (val >> 8) & 0xff;339 *(data+8+i*m_event_size+18) = val & 0xff;340 }323 // FIXME: remove this hacked in 1 kHz test signal to 324 // analog-1 when testing is complete. Note that the tone is 325 // *never* added during closedown. 326 if (m_closedown_count<0) { 327 static signed int a_cx = 0; 328 signed int val; 329 val = (int)(0x7fffff*sin(1000.0*2.0*M_PI*(a_cx/24576000.0))); 330 if ((a_cx+=512) >= 24576000) { 331 a_cx -= 24576000; 332 } 333 *(data+8+i*m_event_size+16) = (val >> 16) & 0xff; 334 *(data+8+i*m_event_size+17) = (val >> 8) & 0xff; 335 *(data+8+i*m_event_size+18) = val & 0xff; 336 } 341 337 #endif 342 338 343 }344 345 // Process all ports that should be handled on a per-packet base346 // this is MIDI for AMDTP (due to the need of DBC, which is lost 347 // when putting the events in the ringbuffer)348 // for motu this might also be control data, however as control349 // data isn't time specific I would also include it in the period350 // based processing351 352 // FIXME: m_tx_dbc probably needs to be initialised to a non-zero353 // value somehow so MIDI sync is possible. For now we ignore354 // this issue.355 if (!encodePacketPorts((quadlet_t *)(data+8), n_events, m_tx_dbc)) {356 debugWarning("Problem encoding Packet Ports\n");357 }339 } 340 341 // Process all ports that should be handled on a per-packet base 342 // this is MIDI for AMDTP (due to the need of DBC, which is lost 343 // when putting the events in the ringbuffer) 344 // for motu this might also be control data, however as control 345 // data isn't time specific I would also include it in the period 346 // based processing 347 348 // FIXME: m_tx_dbc probably needs to be initialised to a non-zero 349 // value somehow so MIDI sync is possible. For now we ignore 350 // this issue. 351 if (!encodePacketPorts((quadlet_t *)(data+8), n_events, m_tx_dbc)) { 352 debugWarning("Problem encoding Packet Ports\n"); 353 } 358 354 359 355 return RAW1394_ISO_OK; 360 356 361 357 } else if (now_cycles<cycle) { 362 358 // we can still postpone the queueing of the packets … … 364 360 } else { // there is no more data in the ringbuffer 365 361 366 debugWarning("Transmit buffer underrun (now %d, queue %d, target %d)\n", 362 debugWarning("Transmit buffer underrun (now %d, queue %d, target %d)\n", 367 363 now_cycles, cycle, TICKS_TO_CYCLES(ts)); 368 364 … … 377 373 // compose a no-data packet, we should always 378 374 // send a valid packet 379 375 380 376 // send dummy packet 381 382 // construct the packet CIP-like header. Even if this is a data-less 383 // packet the dbs field is still set as if there were data blocks 377 378 // construct the packet CIP-like header. Even if this is a data-less 379 // packet the dbs field is still set as if there were data blocks 384 380 // present. For data-less packets the dbc is the same as the previously 385 381 // transmitted block. … … 403 399 404 400 bool MotuTransmitStreamProcessor::prefill() { 405 // this is needed because otherwise there is no data to be 406 // sent when the streaming starts407 408 int i = m_nb_buffers;409 while (i--) {410 if(!transferSilence(m_period)) {411 debugFatal("Could not prefill transmit stream\n");412 return false;413 }414 }415 return true;401 // this is needed because otherwise there is no data to be 402 // sent when the streaming starts 403 404 int i = m_nb_buffers; 405 while (i--) { 406 if(!transferSilence(m_period)) { 407 debugFatal("Could not prefill transmit stream\n"); 408 return false; 409 } 410 } 411 return true; 416 412 } 417 413 418 414 bool MotuTransmitStreamProcessor::reset() { 419 415 420 debugOutput( DEBUG_LEVEL_VERBOSE, "Resetting...\n");416 debugOutput( DEBUG_LEVEL_VERBOSE, "Resetting...\n"); 421 417 422 418 // we have to make sure that the buffer HEAD timestamp 423 419 // lies in the future for every possible buffer fill case. 424 420 int offset=(int)(m_data_buffer->getBufferSize()*m_ticks_per_frame); 425 421 426 422 m_data_buffer->setTickOffset(offset); 427 428 // reset all non-device specific stuff429 // i.e. the iso stream and the associated ports430 if (!TransmitStreamProcessor::reset()) {431 debugFatal("Could not do base class reset\n");432 return false;433 }434 435 // we should prefill the event buffer436 if (!prefill()) {437 debugFatal("Could not prefill buffers\n");438 return false; 439 }440 441 return true;423 424 // reset all non-device specific stuff 425 // i.e. the iso stream and the associated ports 426 if (!TransmitStreamProcessor::reset()) { 427 debugFatal("Could not do base class reset\n"); 428 return false; 429 } 430 431 // we should prefill the event buffer 432 if (!prefill()) { 433 debugFatal("Could not prefill buffers\n"); 434 return false; 435 } 436 437 return true; 442 438 } 443 439 444 440 bool MotuTransmitStreamProcessor::prepare() { 445 446 debugOutput( DEBUG_LEVEL_VERBOSE, "Preparing...\n");447 448 // prepare all non-device specific stuff449 // i.e. the iso stream and the associated ports450 if (!TransmitStreamProcessor::prepare()) {451 debugFatal("Could not prepare base class\n");452 return false;453 }454 455 m_PeriodStat.setName("XMT PERIOD");456 m_PacketStat.setName("XMT PACKET");457 m_WakeupStat.setName("XMT WAKEUP");458 459 debugOutput( DEBUG_LEVEL_VERBOSE, "Event size: %d\n", m_event_size);460 461 // allocate the event buffer462 unsigned int ringbuffer_size_frames=m_nb_buffers * m_period;441 442 debugOutput( DEBUG_LEVEL_VERBOSE, "Preparing...\n"); 443 444 // prepare all non-device specific stuff 445 // i.e. the iso stream and the associated ports 446 if (!TransmitStreamProcessor::prepare()) { 447 debugFatal("Could not prepare base class\n"); 448 return false; 449 } 450 451 m_PeriodStat.setName("XMT PERIOD"); 452 m_PacketStat.setName("XMT PACKET"); 453 m_WakeupStat.setName("XMT WAKEUP"); 454 455 debugOutput( DEBUG_LEVEL_VERBOSE, "Event size: %d\n", m_event_size); 456 457 // allocate the event buffer 458 unsigned int ringbuffer_size_frames=m_nb_buffers * m_period; 463 459 464 460 // allocate the internal buffer 465 461 m_ticks_per_frame = (TICKS_PER_SECOND*1.0) / ((float)m_framerate); 466 unsigned int events_per_frame = m_framerate<=48000?8:(m_framerate<=96000?16:32);467 468 assert(m_data_buffer); 462 unsigned int events_per_frame = m_framerate<=48000?8:(m_framerate<=96000?16:32); 463 464 assert(m_data_buffer); 469 465 m_data_buffer->setBufferSize(ringbuffer_size_frames); 470 466 m_data_buffer->setEventSize(m_event_size); 471 467 m_data_buffer->setEventsPerFrame(1); 472 468 473 469 m_data_buffer->setUpdatePeriod(m_period); 474 470 m_data_buffer->setNominalRate(m_ticks_per_frame); 475 471 476 472 // FIXME: check if the timestamp wraps at one second 477 473 m_data_buffer->setWrapValue(128L*TICKS_PER_SECOND); 478 474 479 475 m_data_buffer->prepare(); 480 476 481 // Set the parameters of ports we can: we want the audio ports to be482 // period buffered, and the midi ports to be packet buffered.483 for ( PortVectorIterator it = m_Ports.begin();484 it != m_Ports.end();485 ++it ) {486 debugOutput(DEBUG_LEVEL_VERBOSE, "Setting up port %s\n",(*it)->getName().c_str());487 if(!(*it)->setBufferSize(m_period)) {488 debugFatal("Could not set buffer size to %d\n",m_period);489 return false;490 }491 492 switch ((*it)->getPortType()) {493 case Port::E_Audio:494 if (!(*it)->setSignalType(Port::E_PeriodSignalled)) {495 debugFatal("Could not set signal type to PeriodSignalling");496 return false;497 }498 break;499 500 case Port::E_Midi:501 if (!(*it)->setSignalType(Port::E_PacketSignalled)) {502 debugFatal("Could not set signal type to PacketSignalling");503 return false;504 }505 if (!(*it)->setBufferType(Port::E_RingBuffer)) {506 debugFatal("Could not set buffer type");507 return false;508 }509 if (!(*it)->setDataType(Port::E_MidiEvent)) {510 debugFatal("Could not set data type");511 return false;512 }513 // FIXME: probably need rate control too. See514 // Port::useRateControl() and AmdtpStreamProcessor.515 break;516 517 case Port::E_Control:518 if (!(*it)->setSignalType(Port::E_PeriodSignalled)) {519 debugFatal("Could not set signal type to PeriodSignalling");520 return false;521 }522 break;523 524 default:525 debugWarning("Unsupported port type specified\n");526 break;527 }528 }529 530 // The API specific settings of the ports are already set before531 // this routine is called, therefore we can init&prepare the ports532 if (!initPorts()) {533 debugFatal("Could not initialize ports!\n");534 return false;535 }536 537 if(!preparePorts()) {538 debugFatal("Could not initialize ports!\n");539 return false;540 }541 542 return true;477 // Set the parameters of ports we can: we want the audio ports to be 478 // period buffered, and the midi ports to be packet buffered. 479 for ( PortVectorIterator it = m_Ports.begin(); 480 it != m_Ports.end(); 481 ++it ) { 482 debugOutput(DEBUG_LEVEL_VERBOSE, "Setting up port %s\n",(*it)->getName().c_str()); 483 if(!(*it)->setBufferSize(m_period)) { 484 debugFatal("Could not set buffer size to %d\n",m_period); 485 return false; 486 } 487 488 switch ((*it)->getPortType()) { 489 case Port::E_Audio: 490 if (!(*it)->setSignalType(Port::E_PeriodSignalled)) { 491 debugFatal("Could not set signal type to PeriodSignalling"); 492 return false; 493 } 494 break; 495 496 case Port::E_Midi: 497 if (!(*it)->setSignalType(Port::E_PacketSignalled)) { 498 debugFatal("Could not set signal type to PacketSignalling"); 499 return false; 500 } 501 if (!(*it)->setBufferType(Port::E_RingBuffer)) { 502 debugFatal("Could not set buffer type"); 503 return false; 504 } 505 if (!(*it)->setDataType(Port::E_MidiEvent)) { 506 debugFatal("Could not set data type"); 507 return false; 508 } 509 // FIXME: probably need rate control too. See 510 // Port::useRateControl() and AmdtpStreamProcessor. 511 break; 512 513 case Port::E_Control: 514 if (!(*it)->setSignalType(Port::E_PeriodSignalled)) { 515 debugFatal("Could not set signal type to PeriodSignalling"); 516 return false; 517 } 518 break; 519 520 default: 521 debugWarning("Unsupported port type specified\n"); 522 break; 523 } 524 } 525 526 // The API specific settings of the ports are already set before 527 // this routine is called, therefore we can init&prepare the ports 528 if (!initPorts()) { 529 debugFatal("Could not initialize ports!\n"); 530 return false; 531 } 532 533 if(!preparePorts()) { 534 debugFatal("Could not initialize ports!\n"); 535 return false; 536 } 537 538 return true; 543 539 } 544 540 545 541 bool MotuTransmitStreamProcessor::prepareForStop() { 546 542 547 // If the stream is disabled or isn't running there's no need to548 // wait since the MOTU *should* still be in a "zero data" state.549 //550 // If the m_streaming_active flag is 0 it indicates that the551 // transmit callback hasn't been called since a closedown was552 // requested when this function was last called. This effectively553 // signifies that the streaming thread has been exitted due to an554 // xrun in either the receive or transmit handlers. In this case555 // there's no point in waiting for the closedown count to hit zero556 // because it never will; the zero data will never get to the MOTU. 557 // It's best to allow an immediate stop and let the xrun handler558 // proceed as best it can.559 //560 // The ability to detect the lack of streaming also prevents the561 // "wait for stop" in the stream processor manager's stop() method562 // from hitting its timeout which in turn seems to increase the563 // probability of a successful recovery.564 if (m_is_disabled || !isRunning() || !m_streaming_active)565 return true;566 567 if (m_closedown_count < 0) {568 // No closedown has been initiated, so start one now. Set569 // the closedown count to the number of zero packets which570 // will be sent to the MOTU before closing off the iso571 // streams. FIXME: 128 packets (each containing 8 frames at572 // 48 kHz) is the experimentally-determined figure for 48573 // kHz with a period size of 1024. It seems that at least574 // one period of zero samples need to be sent to allow for575 // inter-thread communication occuring on period boundaries. 576 // This needs to be confirmed for other rates and period577 // sizes.578 signed n_events = m_framerate<=48000?8:(m_framerate<=96000?16:32);579 m_closedown_count = m_period / n_events;580 581 // Set up a test to confirm that streaming is still active.582 // If the streaming function hasn't been called by the next583 // iteration through this function there's no point in584 // continuing since it means the zero data will never get to 585 // the MOTU.586 m_streaming_active = 0;587 return false;588 }589 590 // We are "go" for closedown once all requested zero packets591 // (initiated by a previous call to this function) have been sent to592 // the MOTU.593 return m_closedown_count == 0;543 // If the stream is disabled or isn't running there's no need to 544 // wait since the MOTU *should* still be in a "zero data" state. 545 // 546 // If the m_streaming_active flag is 0 it indicates that the 547 // transmit callback hasn't been called since a closedown was 548 // requested when this function was last called. This effectively 549 // signifies that the streaming thread has been exitted due to an 550 // xrun in either the receive or transmit handlers. In this case 551 // there's no point in waiting for the closedown count to hit zero 552 // because it never will; the zero data will never get to the MOTU. 553 // It's best to allow an immediate stop and let the xrun handler 554 // proceed as best it can. 555 // 556 // The ability to detect the lack of streaming also prevents the 557 // "wait for stop" in the stream processor manager's stop() method 558 // from hitting its timeout which in turn seems to increase the 559 // probability of a successful recovery. 560 if (m_is_disabled || !isRunning() || !m_streaming_active) 561 return true; 562 563 if (m_closedown_count < 0) { 564 // No closedown has been initiated, so start one now. Set 565 // the closedown count to the number of zero packets which 566 // will be sent to the MOTU before closing off the iso 567 // streams. FIXME: 128 packets (each containing 8 frames at 568 // 48 kHz) is the experimentally-determined figure for 48 569 // kHz with a period size of 1024. It seems that at least 570 // one period of zero samples need to be sent to allow for 571 // inter-thread communication occuring on period boundaries. 572 // This needs to be confirmed for other rates and period 573 // sizes. 574 signed n_events = m_framerate<=48000?8:(m_framerate<=96000?16:32); 575 m_closedown_count = m_period / n_events; 576 577 // Set up a test to confirm that streaming is still active. 578 // If the streaming function hasn't been called by the next 579 // iteration through this function there's no point in 580 // continuing since it means the zero data will never get to 581 // the MOTU. 582 m_streaming_active = 0; 583 return false; 584 } 585 586 // We are "go" for closedown once all requested zero packets 587 // (initiated by a previous call to this function) have been sent to 588 // the MOTU. 589 return m_closedown_count == 0; 594 590 } 595 591 596 592 bool MotuTransmitStreamProcessor::prepareForStart() { 597 593 // Reset some critical variables required so the stream starts cleanly. This 598 // method is called once on every stream restart. Initialisations which should 594 // method is called once on every stream restart. Initialisations which should 599 595 // be done once should be placed in the init() method instead. 600 m_running = 0;601 m_closedown_count = -1;602 m_streaming_active = 0;603 604 // At this point we'll also disable the stream processor here.605 // At this stage stream processors are always explicitly re-enabled606 // after being started, so by starting in the disabled state we 607 // ensure that every start will be exactly the same.608 disable();609 610 return true;596 m_running = 0; 597 m_closedown_count = -1; 598 m_streaming_active = 0; 599 600 // At this point we'll also disable the stream processor here. 601 // At this stage stream processors are always explicitly re-enabled 602 // after being started, so by starting in the disabled state we 603 // ensure that every start will be exactly the same. 604 disable(); 605 606 return true; 611 607 } 612 608 … … 615 611 debugOutput(DEBUG_LEVEL_VERBOSE,"Preparing to enable...\n"); 616 612 617 // for the transmit SP, we have to initialize the 613 // for the transmit SP, we have to initialize the 618 614 // buffer timestamp to something sane, because this timestamp 619 615 // is used when it is SyncSource 620 616 621 617 // the time we initialize to will determine the time at which 622 618 // the first sample in the buffer will be sent, so we should 623 619 // make it at least 'time_to_enable_at' 624 620 625 621 uint64_t now=m_handler->getCycleTimer(); 626 622 unsigned int now_secs=CYCLE_TIMER_GET_SECS(now); 627 623 628 624 // check if a wraparound on the secs will happen between 629 625 // now and the time we start … … 633 629 if (now_secs>=128) now_secs=0; 634 630 } 635 631 636 632 // uint64_t ts_head= now_secs*TICKS_PER_SECOND; 637 633 uint64_t ts_head = time_to_enable_at*TICKS_PER_CYCLE; 638 634 639 635 // we also add the nb of cycles we transmit in advance 640 636 ts_head=addTicks(ts_head, TRANSMIT_ADVANCE_CYCLES*TICKS_PER_CYCLE); 641 637 642 638 m_data_buffer->setBufferTailTimestamp(ts_head); 643 639 … … 652 648 bool MotuTransmitStreamProcessor::transferSilence(unsigned int size) { 653 649 bool retval; 654 655 // This function should tranfer 'size' frames of 'silence' to the event buffer656 char *dummybuffer=(char *)calloc(size,m_event_size);657 658 transmitSilenceBlock(dummybuffer, size, 0);650 651 // This function should tranfer 'size' frames of 'silence' to the event buffer 652 char *dummybuffer=(char *)calloc(size,m_event_size); 653 654 transmitSilenceBlock(dummybuffer, size, 0); 659 655 660 656 // add the silence data to the ringbuffer 661 if(m_data_buffer->writeFrames(size, dummybuffer, 0)) { 657 if(m_data_buffer->writeFrames(size, dummybuffer, 0)) { 662 658 retval=true; 663 659 } else { … … 666 662 } 667 663 668 free(dummybuffer);669 670 return retval;664 free(dummybuffer); 665 666 return retval; 671 667 } 672 668 673 669 bool MotuTransmitStreamProcessor::putFrames(unsigned int nbframes, int64_t ts) { 674 670 m_PeriodStat.mark(m_data_buffer->getBufferFill()); 675 671 676 672 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "MotuTransmitStreamProcessor::putFrames(%d, %llu)\n", nbframes, ts); 677 673 678 674 // transfer the data 679 675 m_data_buffer->blockProcessWriteFrames(nbframes, ts); … … 684 680 } 685 681 686 /* 682 /* 687 683 * write received events to the stream ringbuffers. 688 684 */ 689 685 690 bool MotuTransmitStreamProcessor::processWriteBlock(char *data, 686 bool MotuTransmitStreamProcessor::processWriteBlock(char *data, 691 687 unsigned int nevents, unsigned int offset) { 692 bool no_problem=true;693 unsigned int i;694 695 // FIXME: ensure the MIDI and control streams are all zeroed until696 // such time as they are fully implemented.697 for (i=0; i<nevents; i++) {698 memset(data+4+i*m_event_size, 0x00, 6);699 }700 701 for ( PortVectorIterator it = m_PeriodPorts.begin();702 it != m_PeriodPorts.end();703 ++it ) {704 // If this port is disabled, don't process it705 if((*it)->isDisabled()) {continue;};706 707 //FIXME: make this into a static_cast when not DEBUG?708 Port *port=dynamic_cast<Port *>(*it);709 710 switch(port->getPortType()) {711 712 case Port::E_Audio:713 if (encodePortToMotuEvents(static_cast<MotuAudioPort *>(*it), (quadlet_t *)data, offset, nevents)) {714 debugWarning("Could not encode port %s to MBLA events",(*it)->getName().c_str());715 no_problem=false;716 }717 break;718 // midi is a packet based port, don't process719 //case MotuPortInfo::E_Midi:720 //break;721 722 default: // ignore723 break;724 }725 }726 return no_problem;727 } 728 729 int MotuTransmitStreamProcessor::transmitSilenceBlock(char *data, 688 bool no_problem=true; 689 unsigned int i; 690 691 // FIXME: ensure the MIDI and control streams are all zeroed until 692 // such time as they are fully implemented. 693 for (i=0; i<nevents; i++) { 694 memset(data+4+i*m_event_size, 0x00, 6); 695 } 696 697 for ( PortVectorIterator it = m_PeriodPorts.begin(); 698 it != m_PeriodPorts.end(); 699 ++it ) { 700 // If this port is disabled, don't process it 701 if((*it)->isDisabled()) {continue;}; 702 703 //FIXME: make this into a static_cast when not DEBUG? 704 Port *port=dynamic_cast<Port *>(*it); 705 706 switch(port->getPortType()) { 707 708 case Port::E_Audio: 709 if (encodePortToMotuEvents(static_cast<MotuAudioPort *>(*it), (quadlet_t *)data, offset, nevents)) { 710 debugWarning("Could not encode port %s to MBLA events",(*it)->getName().c_str()); 711 no_problem=false; 712 } 713 break; 714 // midi is a packet based port, don't process 715 // case MotuPortInfo::E_Midi: 716 // break; 717 718 default: // ignore 719 break; 720 } 721 } 722 return no_problem; 723 } 724 725 int MotuTransmitStreamProcessor::transmitSilenceBlock(char *data, 730 726 unsigned int nevents, unsigned int offset) { 731 // This is the same as the non-silence version, except that is732 // doesn't read from the port buffers.733 734 int problem=0;735 736 for ( PortVectorIterator it = m_PeriodPorts.begin();737 it != m_PeriodPorts.end();738 ++it ) {739 //FIXME: make this into a static_cast when not DEBUG?740 Port *port=dynamic_cast<Port *>(*it);741 742 switch(port->getPortType()) {743 744 case Port::E_Audio:745 if (encodeSilencePortToMotuEvents(static_cast<MotuAudioPort *>(*it), (quadlet_t *)data, offset, nevents)) {746 debugWarning("Could not encode port %s to MBLA events",(*it)->getName().c_str());747 problem=1;748 }749 break;750 // midi is a packet based port, don't process751 //case MotuPortInfo::E_Midi:752 //break;753 754 default: // ignore755 break;756 }757 }758 return problem;727 // This is the same as the non-silence version, except that is 728 // doesn't read from the port buffers. 729 730 int problem=0; 731 732 for ( PortVectorIterator it = m_PeriodPorts.begin(); 733 it != m_PeriodPorts.end(); 734 ++it ) { 735 //FIXME: make this into a static_cast when not DEBUG? 736 Port *port=dynamic_cast<Port *>(*it); 737 738 switch(port->getPortType()) { 739 740 case Port::E_Audio: 741 if (encodeSilencePortToMotuEvents(static_cast<MotuAudioPort *>(*it), (quadlet_t *)data, offset, nevents)) { 742 debugWarning("Could not encode port %s to MBLA events",(*it)->getName().c_str()); 743 problem=1; 744 } 745 break; 746 // midi is a packet based port, don't process 747 // case MotuPortInfo::E_Midi: 748 // break; 749 750 default: // ignore 751 break; 752 } 753 } 754 return problem; 759 755 } 760 756 … … 767 763 * @return true if all successfull 768 764 */ 769 bool MotuTransmitStreamProcessor::encodePacketPorts(quadlet_t *data, unsigned int nevents, 770 unsigned int dbc) {771 bool ok=true;772 char byte;773 774 // Use char here since the target address won't necessarily be775 // aligned; use of an unaligned quadlet_t may cause issues on776 // certain architectures. Besides, the target for MIDI data going777 // directly to the MOTU isn't structured in quadlets anyway; it is a778 // sequence of 3 unaligned bytes.779 unsigned char *target = NULL;780 781 for ( PortVectorIterator it = m_PacketPorts.begin();782 it != m_PacketPorts.end();783 ++it ) {784 785 Port *port=static_cast<Port *>(*it);786 assert(port); // this should not fail!!787 788 // Currently the only packet type of events for MOTU 789 // is MIDI in mbla. However in future control data790 // might also be sent via "packet" events.791 // assert(pinfo->getFormat()==MotuPortInfo::E_Midi);792 793 // FIXME: MIDI output is completely untested at present.794 switch (port->getPortType()) {795 case Port::E_Midi: {796 MotuMidiPort *mp=static_cast<MotuMidiPort *>(*it);797 798 // Send a byte if we can. MOTU MIDI data is799 // sent using a 3-byte sequence starting at800 // the port's position. For now we'll801 // always send in the first event of a802 // packet, but this might need refinement803 // later.804 if (mp->canRead()) {805 mp->readEvent(&byte);806 target = (unsigned char *)data + mp->getPosition();807 *(target++) = 0x01;808 *(target++) = 0x00;809 *(target++) = byte;810 }811 break;812 }813 default:814 debugOutput(DEBUG_LEVEL_VERBOSE, "Unknown packet-type port type %d\n",port->getPortType());815 return ok; 816 }817 }818 819 return ok;820 } 821 822 int MotuTransmitStreamProcessor::encodePortToMotuEvents(MotuAudioPort *p, quadlet_t *data, 765 bool MotuTransmitStreamProcessor::encodePacketPorts(quadlet_t *data, unsigned int nevents, 766 unsigned int dbc) { 767 bool ok=true; 768 char byte; 769 770 // Use char here since the target address won't necessarily be 771 // aligned; use of an unaligned quadlet_t may cause issues on 772 // certain architectures. Besides, the target for MIDI data going 773 // directly to the MOTU isn't structured in quadlets anyway; it is a 774 // sequence of 3 unaligned bytes. 775 unsigned char *target = NULL; 776 777 for ( PortVectorIterator it = m_PacketPorts.begin(); 778 it != m_PacketPorts.end(); 779 ++it ) { 780 781 Port *port=static_cast<Port *>(*it); 782 assert(port); // this should not fail!! 783 784 // Currently the only packet type of events for MOTU 785 // is MIDI in mbla. However in future control data 786 // might also be sent via "packet" events. 787 // assert(pinfo->getFormat()==MotuPortInfo::E_Midi); 788 789 // FIXME: MIDI output is completely untested at present. 790 switch (port->getPortType()) { 791 case Port::E_Midi: { 792 MotuMidiPort *mp=static_cast<MotuMidiPort *>(*it); 793 794 // Send a byte if we can. MOTU MIDI data is 795 // sent using a 3-byte sequence starting at 796 // the port's position. For now we'll 797 // always send in the first event of a 798 // packet, but this might need refinement 799 // later. 800 if (mp->canRead()) { 801 mp->readEvent(&byte); 802 target = (unsigned char *)data + mp->getPosition(); 803 *(target++) = 0x01; 804 *(target++) = 0x00; 805 *(target++) = byte; 806 } 807 break; 808 } 809 default: 810 debugOutput(DEBUG_LEVEL_VERBOSE, "Unknown packet-type port type %d\n",port->getPortType()); 811 return ok; 812 } 813 } 814 815 return ok; 816 } 817 818 int MotuTransmitStreamProcessor::encodePortToMotuEvents(MotuAudioPort *p, quadlet_t *data, 823 819 unsigned int offset, unsigned int nevents) { 824 820 // Encodes nevents worth of data from the given port into the given buffer. The … … 836 832 // utilised. 837 833 838 unsigned int j=0;839 840 // Use char here since the target address won't necessarily be 841 // aligned; use of an unaligned quadlet_t may cause issues on certain842 // architectures. Besides, the target (data going directly to the MOTU)843 // isn't structured in quadlets anyway; it mainly consists of packed844 // 24-bit integers.845 unsigned char *target;846 target = (unsigned char *)data + p->getPosition();847 848 switch(p->getDataType()) {849 default:850 case Port::E_Int24:851 {852 quadlet_t *buffer=(quadlet_t *)(p->getBufferAddress());853 854 assert(nevents + offset <= p->getBufferSize());855 856 // Offset is in frames, but each port is only a single857 // channel, so the number of frames is the same as the858 // number of quadlets to offset (assuming the port buffer859 // uses one quadlet per sample, which is the case currently).860 buffer+=offset;861 862 for(j = 0; j < nevents; j += 1) { // Decode nsamples863 *target = (*buffer >> 16) & 0xff;864 *(target+1) = (*buffer >> 8) & 0xff;865 *(target+2) = (*buffer) & 0xff;866 867 buffer++;868 target+=m_event_size;869 }870 }871 break;872 case Port::E_Float:873 {874 const float multiplier = (float)(0x7FFFFF);875 float *buffer=(float *)(p->getBufferAddress());876 877 assert(nevents + offset <= p->getBufferSize());878 879 buffer+=offset;880 881 for(j = 0; j < nevents; j += 1) { // decode max nsamples 882 unsigned int v = (int)(*buffer * multiplier);883 *target = (v >> 16) & 0xff;884 *(target+1) = (v >> 8) & 0xff;885 *(target+2) = v & 0xff;886 887 buffer++;888 target+=m_event_size;889 }890 }891 break;892 }893 894 return 0;895 } 896 897 int MotuTransmitStreamProcessor::encodeSilencePortToMotuEvents(MotuAudioPort *p, quadlet_t *data, 834 unsigned int j=0; 835 836 // Use char here since the target address won't necessarily be 837 // aligned; use of an unaligned quadlet_t may cause issues on certain 838 // architectures. Besides, the target (data going directly to the MOTU) 839 // isn't structured in quadlets anyway; it mainly consists of packed 840 // 24-bit integers. 841 unsigned char *target; 842 target = (unsigned char *)data + p->getPosition(); 843 844 switch(p->getDataType()) { 845 default: 846 case Port::E_Int24: 847 { 848 quadlet_t *buffer=(quadlet_t *)(p->getBufferAddress()); 849 850 assert(nevents + offset <= p->getBufferSize()); 851 852 // Offset is in frames, but each port is only a single 853 // channel, so the number of frames is the same as the 854 // number of quadlets to offset (assuming the port buffer 855 // uses one quadlet per sample, which is the case currently). 856 buffer+=offset; 857 858 for(j = 0; j < nevents; j += 1) { // Decode nsamples 859 *target = (*buffer >> 16) & 0xff; 860 *(target+1) = (*buffer >> 8) & 0xff; 861 *(target+2) = (*buffer) & 0xff; 862 863 buffer++; 864 target+=m_event_size; 865 } 866 } 867 break; 868 case Port::E_Float: 869 { 870 const float multiplier = (float)(0x7FFFFF); 871 float *buffer=(float *)(p->getBufferAddress()); 872 873 assert(nevents + offset <= p->getBufferSize()); 874 875 buffer+=offset; 876 877 for(j = 0; j < nevents; j += 1) { // decode max nsamples 878 unsigned int v = (int)(*buffer * multiplier); 879 *target = (v >> 16) & 0xff; 880 *(target+1) = (v >> 8) & 0xff; 881 *(target+2) = v & 0xff; 882 883 buffer++; 884 target+=m_event_size; 885 } 886 } 887 break; 888 } 889 890 return 0; 891 } 892 893 int MotuTransmitStreamProcessor::encodeSilencePortToMotuEvents(MotuAudioPort *p, quadlet_t *data, 898 894 unsigned int offset, unsigned int nevents) { 899 unsigned int j=0;900 unsigned char *target = (unsigned char *)data + p->getPosition();901 902 switch (p->getDataType()) {903 default:895 unsigned int j=0; 896 unsigned char *target = (unsigned char *)data + p->getPosition(); 897 898 switch (p->getDataType()) { 899 default: 904 900 case Port::E_Int24: 905 901 case Port::E_Float: 906 for (j = 0; j < nevents; j++) {907 *target = *(target+1) = *(target+2) = 0;908 target += m_event_size;909 }910 break;911 }912 913 return 0;902 for (j = 0; j < nevents; j++) { 903 *target = *(target+1) = *(target+2) = 0; 904 target += m_event_size; 905 } 906 break; 907 } 908 909 return 0; 914 910 } 915 911 916 912 /* --------------------- RECEIVE ----------------------- */ 917 913 918 MotuReceiveStreamProcessor::MotuReceiveStreamProcessor(int port, int framerate, 919 unsigned int event_size)914 MotuReceiveStreamProcessor::MotuReceiveStreamProcessor(int port, int framerate, 915 unsigned int event_size) 920 916 : ReceiveStreamProcessor(port, framerate), m_event_size(event_size), 921 m_closedown_active(0) {917 m_closedown_active(0) { 922 918 923 919 } … … 929 925 bool MotuReceiveStreamProcessor::init() { 930 926 931 // call the parent init932 // this has to be done before allocating the buffers, 933 // because this sets the buffersizes from the processormanager934 if(!ReceiveStreamProcessor::init()) {935 debugFatal("Could not do base class init (%d)\n",this);936 return false;937 }938 939 return true;940 } 941 942 // NOTE by PP: timestamp based sync fixes this automagically by943 // enforcing that the roundtrip latency is constant:944 // Detect missed receive cycles945 // FIXME: it would be nice to advance the rx buffer by the amount of946 // frames missed. However, since the MOTU transmits more frames per947 // cycle than the average and "catches up" with periodic empty948 // cycles it's not trivial to work out precisely how many frames949 // were missed. Ultimately I think we need to do so if sync is to950 // be maintained across a transient receive failure.951 952 enum raw1394_iso_disposition 953 MotuReceiveStreamProcessor::putPacket(unsigned char *data, unsigned int length, 954 unsigned char channel, unsigned char tag, unsigned char sy, 927 // call the parent init 928 // this has to be done before allocating the buffers, 929 // because this sets the buffersizes from the processormanager 930 if(!ReceiveStreamProcessor::init()) { 931 debugFatal("Could not do base class init (%d)\n",this); 932 return false; 933 } 934 935 return true; 936 } 937 938 // NOTE by PP: timestamp based sync fixes this automagically by 939 // enforcing that the roundtrip latency is constant: 940 // Detect missed receive cycles 941 // FIXME: it would be nice to advance the rx buffer by the amount of 942 // frames missed. However, since the MOTU transmits more frames per 943 // cycle than the average and "catches up" with periodic empty 944 // cycles it's not trivial to work out precisely how many frames 945 // were missed. Ultimately I think we need to do so if sync is to 946 // be maintained across a transient receive failure. 947 948 enum raw1394_iso_disposition 949 MotuReceiveStreamProcessor::putPacket(unsigned char *data, unsigned int length, 950 unsigned char channel, unsigned char tag, unsigned char sy, 955 951 unsigned int cycle, unsigned int dropped) { 956 957 enum raw1394_iso_disposition retval=RAW1394_ISO_OK;958 // this is needed for the base class getLastCycle() to work.959 // this avoids a function call like StreamProcessor::updateLastCycle()952 953 enum raw1394_iso_disposition retval=RAW1394_ISO_OK; 954 // this is needed for the base class getLastCycle() to work. 955 // this avoids a function call like StreamProcessor::updateLastCycle() 960 956 m_last_cycle=cycle; 961 957 … … 965 961 if (cycle == m_cycle_to_enable_at) { 966 962 m_is_disabled=false; 967 debugOutput(DEBUG_LEVEL_VERBOSE,"Enabling StreamProcessor %p at %d\n", 963 debugOutput(DEBUG_LEVEL_VERBOSE,"Enabling StreamProcessor %p at %d\n", 968 964 this, cycle); 969 965 970 966 // the previous timestamp is the one we need to start with 971 967 // because we're going to update the buffer again this loop … … 988 984 m_is_disabled=true; 989 985 } 990 991 // If the packet length is 8 bytes (ie: just a CIP-like header)992 // there is no isodata.993 if (length > 8) {994 // The iso data blocks from the MOTUs comprise a CIP-like995 // header followed by a number of events (8 for 1x rates, 16996 // for 2x rates, 32 for 4x rates).997 quadlet_t *quadlet = (quadlet_t *)data;998 unsigned int dbs = get_bits(ntohl(quadlet[0]), 23, 8); // Size of one event in terms of fdf_size999 unsigned int fdf_size = get_bits(ntohl(quadlet[1]), 23, 8) == 0x22 ? 32:0; // Event unit size in bits1000 1001 // Don't even attempt to process a packet if it isn't what1002 // we expect from a MOTU. Yes, an FDF value of 32 bears1003 // little relationship to the actual data (24 bit integer)1004 // sent by the MOTU - it's one of those areas where MOTU1005 // have taken a curious detour around the standards.1006 if (tag!=1 || fdf_size!=32) {1007 return RAW1394_ISO_OK;1008 }1009 1010 // put this after the check because event_length can become 0 on invalid packets1011 unsigned int event_length = (fdf_size * dbs) / 8; // Event size in bytes1012 unsigned int n_events = (length-8) / event_length;1013 986 987 // If the packet length is 8 bytes (ie: just a CIP-like header) 988 // there is no isodata. 989 if (length > 8) { 990 // The iso data blocks from the MOTUs comprise a CIP-like 991 // header followed by a number of events (8 for 1x rates, 16 992 // for 2x rates, 32 for 4x rates). 993 quadlet_t *quadlet = (quadlet_t *)data; 994 unsigned int dbs = get_bits(ntohl(quadlet[0]), 23, 8); // Size of one event in terms of fdf_size 995 unsigned int fdf_size = get_bits(ntohl(quadlet[1]), 23, 8) == 0x22 ? 32:0; // Event unit size in bits 996 997 // Don't even attempt to process a packet if it isn't what 998 // we expect from a MOTU. Yes, an FDF value of 32 bears 999 // little relationship to the actual data (24 bit integer) 1000 // sent by the MOTU - it's one of those areas where MOTU 1001 // have taken a curious detour around the standards. 1002 if (tag!=1 || fdf_size!=32) { 1003 return RAW1394_ISO_OK; 1004 } 1005 1006 // put this after the check because event_length can become 0 on invalid packets 1007 unsigned int event_length = (fdf_size * dbs) / 8; // Event size in bytes 1008 unsigned int n_events = (length-8) / event_length; 1009 1014 1010 //=> store the previous timestamp 1015 1011 m_last_timestamp2=m_last_timestamp; 1016 1012 1017 1013 //=> convert the SYT to a full timestamp in ticks 1018 // m_last_timestamp=sytRecvToFullTicks((uint32_t)ntohl(*(quadlet_t *)(data+8)), 1014 // m_last_timestamp=sytRecvToFullTicks((uint32_t)ntohl(*(quadlet_t *)(data+8)), 1019 1015 // cycle, m_handler->getCycleTimer()); 1020 1016 //*** … … 1028 1024 m_last_timestamp = sphRecvToFullTicks(first_sph, m_handler->getCycleTimer()); 1029 1025 1030 // Signal that we're running1026 // Signal that we're running 1031 1027 if(!m_running && n_events && m_last_timestamp2 && m_last_timestamp) { 1032 1028 debugOutput(DEBUG_LEVEL_VERBOSE,"Receive StreamProcessor %p started running at %d\n", this, cycle); … … 1041 1037 // estimate as to when a period might be ready. i.e. it will not 1042 1038 // be ready earlier than this timestamp + period time 1043 1044 // the next (possible) sample is not this one, but lies 1039 1040 // the next (possible) sample is not this one, but lies 1045 1041 // SYT_INTERVAL * rate later 1046 1042 float frame_size=m_framerate<=48000?8:(m_framerate<=96000?16:32); … … 1056 1052 m_data_buffer->setBufferTailTimestamp(ts); 1057 1053 //debugOutput(DEBUG_LEVEL_VERBOSE,"%p, last ts=%lld, ts=%lld, lts2=%lld\n", m_data_buffer, m_last_timestamp, ts, m_last_timestamp2); 1058 1054 1059 1055 return RAW1394_ISO_DEFER; 1060 1056 } 1061 1057 1062 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "put packet...\n");1058 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "put packet...\n"); 1063 1059 //debugOutput(DEBUG_LEVEL_VERBOSE,"enabled: %p, last ts=%lld, ts2=%lld\n",m_data_buffer, m_last_timestamp, m_last_timestamp2); 1064 1060 1065 1061 //=> process the packet 1066 1062 // add the data payload to the ringbuffer 1067 if(m_data_buffer->writeFrames(n_events, (char *)(data+8), m_last_timestamp)) { 1063 if(m_data_buffer->writeFrames(n_events, (char *)(data+8), m_last_timestamp)) { 1068 1064 retval=RAW1394_ISO_OK; 1069 1065 1070 1066 int dbc = get_bits(ntohl(quadlet[0]), 8, 8); 1071 1067 1072 1068 // process all ports that should be handled on a per-packet base 1073 1069 // this is MIDI for AMDTP (due to the need of DBC) … … 1076 1072 retval=RAW1394_ISO_DEFER; 1077 1073 } 1078 1074 1079 1075 } else { 1080 1081 debugWarning("Receive buffer overrun (cycle %d, FC=%d, PC=%d)\n", 1076 1077 debugWarning("Receive buffer overrun (cycle %d, FC=%d, PC=%d)\n", 1082 1078 cycle, m_data_buffer->getFrameCounter(), m_handler->getPacketCount()); 1083 1079 1084 1080 m_xruns++; 1085 1081 1086 1082 // disable the processing, will be re-enabled when 1087 1083 // the xrun is handled … … 1093 1089 } 1094 1090 1095 return retval;1091 return retval; 1096 1092 } 1097 1093 … … 1100 1096 // ISO buffering 1101 1097 int MotuReceiveStreamProcessor::getMinimalSyncDelay() { 1102 unsigned int n_events = m_framerate<=48000?8:(m_framerate<=96000?16:32);1103 1098 unsigned int n_events = m_framerate<=48000?8:(m_framerate<=96000?16:32); 1099 1104 1100 return (int)(m_handler->getWakeupInterval() * n_events * m_ticks_per_frame); 1105 1101 } … … 1107 1103 bool MotuReceiveStreamProcessor::reset() { 1108 1104 1109 debugOutput( DEBUG_LEVEL_VERBOSE, "Resetting...\n");1105 debugOutput( DEBUG_LEVEL_VERBOSE, "Resetting...\n"); 1110 1106 1111 1107 m_data_buffer->setTickOffset(0); 1112 1108 1113 // reset all non-device specific stuff1114 // i.e. the iso stream and the associated ports1115 if(!ReceiveStreamProcessor::reset()) {1116 debugFatal("Could not do base class reset\n");1117 return false;1118 }1119 1120 return true;1109 // reset all non-device specific stuff 1110 // i.e. the iso stream and the associated ports 1111 if(!ReceiveStreamProcessor::reset()) { 1112 debugFatal("Could not do base class reset\n"); 1113 return false; 1114 } 1115 1116 return true; 1121 1117 } 1122 1118 1123 1119 bool MotuReceiveStreamProcessor::prepare() { 1124 1120 1125 // prepare all non-device specific stuff1126 // i.e. the iso stream and the associated ports1127 if(!ReceiveStreamProcessor::prepare()) {1128 debugFatal("Could not prepare base class\n");1129 return false;1130 }1131 1132 debugOutput( DEBUG_LEVEL_VERBOSE, "Preparing...\n");1133 1134 m_PeriodStat.setName("RCV PERIOD");1135 m_PacketStat.setName("RCV PACKET");1136 m_WakeupStat.setName("RCV WAKEUP");1121 // prepare all non-device specific stuff 1122 // i.e. the iso stream and the associated ports 1123 if(!ReceiveStreamProcessor::prepare()) { 1124 debugFatal("Could not prepare base class\n"); 1125 return false; 1126 } 1127 1128 debugOutput( DEBUG_LEVEL_VERBOSE, "Preparing...\n"); 1129 1130 m_PeriodStat.setName("RCV PERIOD"); 1131 m_PacketStat.setName("RCV PACKET"); 1132 m_WakeupStat.setName("RCV WAKEUP"); 1137 1133 1138 1134 // setup any specific stuff here 1139 1135 // FIXME: m_frame_size would be a better name 1140 debugOutput( DEBUG_LEVEL_VERBOSE, "Event size: %d\n", m_event_size);1141 1136 debugOutput( DEBUG_LEVEL_VERBOSE, "Event size: %d\n", m_event_size); 1137 1142 1138 // prepare the framerate estimate 1143 1139 m_ticks_per_frame = (TICKS_PER_SECOND*1.0) / ((float)m_framerate); 1144 1145 // initialize internal buffer1146 unsigned int ringbuffer_size_frames=m_nb_buffers * m_period;1147 1148 unsigned int events_per_frame = m_framerate<=48000?8:(m_framerate<=96000?16:32);1149 1150 assert(m_data_buffer); 1140 1141 // initialize internal buffer 1142 unsigned int ringbuffer_size_frames=m_nb_buffers * m_period; 1143 1144 unsigned int events_per_frame = m_framerate<=48000?8:(m_framerate<=96000?16:32); 1145 1146 assert(m_data_buffer); 1151 1147 m_data_buffer->setBufferSize(ringbuffer_size_frames); 1152 1148 m_data_buffer->setEventSize(m_event_size); 1153 m_data_buffer->setEventsPerFrame(1); 1154 1149 m_data_buffer->setEventsPerFrame(1); 1150 1155 1151 // JMW: The rx buffer receives a new timestamp once per received frame so I think the 1156 1152 // buffer update period is events_per_frame, not events per period. … … 1158 1154 m_data_buffer->setUpdatePeriod(events_per_frame); 1159 1155 m_data_buffer->setNominalRate(m_ticks_per_frame); 1160 1156 1161 1157 m_data_buffer->setWrapValue(128L*TICKS_PER_SECOND); 1162 1158 1163 1159 m_data_buffer->prepare(); 1164 1160 1165 // set the parameters of ports we can:1166 // we want the audio ports to be period buffered,1167 // and the midi ports to be packet buffered1168 for ( PortVectorIterator it = m_Ports.begin();1169 it != m_Ports.end();1170 ++it )1171 {1172 debugOutput(DEBUG_LEVEL_VERBOSE, "Setting up port %s\n",(*it)->getName().c_str());1173 1174 if(!(*it)->setBufferSize(m_period)) {1175 debugFatal("Could not set buffer size to %d\n",m_period);1176 return false;1177 }1178 1179 switch ((*it)->getPortType()) {1180 case Port::E_Audio:1181 if(!(*it)->setSignalType(Port::E_PeriodSignalled)) {1182 debugFatal("Could not set signal type to PeriodSignalling");1183 return false;1184 }1185 break;1186 case Port::E_Midi:1187 if(!(*it)->setSignalType(Port::E_PacketSignalled)) {1188 debugFatal("Could not set signal type to PacketSignalling");1189 return false;1190 }1191 if (!(*it)->setBufferType(Port::E_RingBuffer)) {1192 debugFatal("Could not set buffer type");1193 return false;1194 }1195 if (!(*it)->setDataType(Port::E_MidiEvent)) {1196 debugFatal("Could not set data type");1197 return false;1198 }1199 // FIXME: probably need rate control too. See1200 // Port::useRateControl() and AmdtpStreamProcessor.1201 break;1202 case Port::E_Control:1203 if(!(*it)->setSignalType(Port::E_PeriodSignalled)) {1204 debugFatal("Could not set signal type to PeriodSignalling");1205 return false;1206 }1207 break;1208 default:1209 debugWarning("Unsupported port type specified\n");1210 break;1211 }1212 1213 }1214 1215 // The API specific settings of the ports are already set before1216 // this routine is called, therefore we can init&prepare the ports1217 if(!initPorts()) {1218 debugFatal("Could not initialize ports!\n");1219 return false;1220 }1221 1222 if(!preparePorts()) {1223 debugFatal("Could not initialize ports!\n");1224 return false;1225 }1226 1227 return true;1161 // set the parameters of ports we can: 1162 // we want the audio ports to be period buffered, 1163 // and the midi ports to be packet buffered 1164 for ( PortVectorIterator it = m_Ports.begin(); 1165 it != m_Ports.end(); 1166 ++it ) 1167 { 1168 debugOutput(DEBUG_LEVEL_VERBOSE, "Setting up port %s\n",(*it)->getName().c_str()); 1169 1170 if(!(*it)->setBufferSize(m_period)) { 1171 debugFatal("Could not set buffer size to %d\n",m_period); 1172 return false; 1173 } 1174 1175 switch ((*it)->getPortType()) { 1176 case Port::E_Audio: 1177 if(!(*it)->setSignalType(Port::E_PeriodSignalled)) { 1178 debugFatal("Could not set signal type to PeriodSignalling"); 1179 return false; 1180 } 1181 break; 1182 case Port::E_Midi: 1183 if(!(*it)->setSignalType(Port::E_PacketSignalled)) { 1184 debugFatal("Could not set signal type to PacketSignalling"); 1185 return false; 1186 } 1187 if (!(*it)->setBufferType(Port::E_RingBuffer)) { 1188 debugFatal("Could not set buffer type"); 1189 return false; 1190 } 1191 if (!(*it)->setDataType(Port::E_MidiEvent)) { 1192 debugFatal("Could not set data type"); 1193 return false; 1194 } 1195 // FIXME: probably need rate control too. See 1196 // Port::useRateControl() and AmdtpStreamProcessor. 1197 break; 1198 case Port::E_Control: 1199 if(!(*it)->setSignalType(Port::E_PeriodSignalled)) { 1200 debugFatal("Could not set signal type to PeriodSignalling"); 1201 return false; 1202 } 1203 break; 1204 default: 1205 debugWarning("Unsupported port type specified\n"); 1206 break; 1207 } 1208 1209 } 1210 1211 // The API specific settings of the ports are already set before 1212 // this routine is called, therefore we can init&prepare the ports 1213 if(!initPorts()) { 1214 debugFatal("Could not initialize ports!\n"); 1215 return false; 1216 } 1217 1218 if(!preparePorts()) { 1219 debugFatal("Could not initialize ports!\n"); 1220 return false; 1221 } 1222 1223 return true; 1228 1224 1229 1225 } … … 1232 1228 bool MotuReceiveStreamProcessor::prepareForStop() { 1233 1229 1234 // A MOTU receive stream can stop at any time. However, signify1235 // that stopping is in progress because other streams (notably the1236 // transmit stream) may keep going for some time and cause an1237 // overflow in the receive buffers. If a closedown is in progress1238 // the receive handler simply throws all incoming data away so1239 // no buffer overflow can occur.1240 m_closedown_active = 1;1241 return true;1230 // A MOTU receive stream can stop at any time. However, signify 1231 // that stopping is in progress because other streams (notably the 1232 // transmit stream) may keep going for some time and cause an 1233 // overflow in the receive buffers. If a closedown is in progress 1234 // the receive handler simply throws all incoming data away so 1235 // no buffer overflow can occur. 1236 m_closedown_active = 1; 1237 return true; 1242 1238 } 1243 1239 … … 1247 1243 // xrun recovery. Initialisations which should be done once should be 1248 1244 // placed in the init() method instead. 1249 m_running = 0;1250 m_closedown_active = 0;1251 1252 // At this point we'll also disable the stream processor here.1253 // At this stage stream processors are always explicitly re-enabled1254 // after being started, so by starting in the disabled state we 1255 // ensure that every start will be exactly the same.1256 disable();1257 1258 return true;1245 m_running = 0; 1246 m_closedown_active = 0; 1247 1248 // At this point we'll also disable the stream processor here. 1249 // At this stage stream processors are always explicitly re-enabled 1250 // after being started, so by starting in the disabled state we 1251 // ensure that every start will be exactly the same. 1252 disable(); 1253 1254 return true; 1259 1255 } 1260 1256 … … 1274 1270 * \brief write received events to the port ringbuffers. 1275 1271 */ 1276 bool MotuReceiveStreamProcessor::processReadBlock(char *data, 1277 unsigned int nevents, unsigned int offset)1272 bool MotuReceiveStreamProcessor::processReadBlock(char *data, 1273 unsigned int nevents, unsigned int offset) 1278 1274 { 1279 bool no_problem=true;1280 for ( PortVectorIterator it = m_PeriodPorts.begin();1275 bool no_problem=true; 1276 for ( PortVectorIterator it = m_PeriodPorts.begin(); 1281 1277 it != m_PeriodPorts.end(); 1282 1278 ++it ) { 1283 if((*it)->isDisabled()) {continue;};1284 1285 //FIXME: make this into a static_cast when not DEBUG?1286 Port *port=dynamic_cast<Port *>(*it);1287 1288 switch(port->getPortType()) {1289 1290 case Port::E_Audio:1291 if(decodeMotuEventsToPort(static_cast<MotuAudioPort *>(*it), (quadlet_t *)data, offset, nevents)) {1292 debugWarning("Could not decode packet MBLA to port %s",(*it)->getName().c_str());1293 no_problem=false;1294 }1295 break;1296 // midi is a packet based port, don't process1297 //case MotuPortInfo::E_Midi:1298 //break;1299 1300 default: // ignore1301 break;1302 }1303 }1304 return no_problem;1279 if((*it)->isDisabled()) {continue;}; 1280 1281 //FIXME: make this into a static_cast when not DEBUG? 1282 Port *port=dynamic_cast<Port *>(*it); 1283 1284 switch(port->getPortType()) { 1285 1286 case Port::E_Audio: 1287 if(decodeMotuEventsToPort(static_cast<MotuAudioPort *>(*it), (quadlet_t *)data, offset, nevents)) { 1288 debugWarning("Could not decode packet MBLA to port %s",(*it)->getName().c_str()); 1289 no_problem=false; 1290 } 1291 break; 1292 // midi is a packet based port, don't process 1293 // case MotuPortInfo::E_Midi: 1294 // break; 1295 1296 default: // ignore 1297 break; 1298 } 1299 } 1300 return no_problem; 1305 1301 } 1306 1302 … … 1313 1309 * @return true if all successfull 1314 1310 */ 1315 bool MotuReceiveStreamProcessor::decodePacketPorts(quadlet_t *data, unsigned int nevents, 1316 unsigned int dbc) {1317 bool ok=true;1318 1319 // Use char here since the source address won't necessarily be1320 // aligned; use of an unaligned quadlet_t may cause issues on1321 // certain architectures. Besides, the source for MIDI data going1322 // directly to the MOTU isn't structured in quadlets anyway; it is a1323 // sequence of 3 unaligned bytes.1324 unsigned char *src = NULL;1325 1326 for ( PortVectorIterator it = m_PacketPorts.begin();1327 it != m_PacketPorts.end();1328 ++it ) {1329 1330 Port *port=dynamic_cast<Port *>(*it);1331 assert(port); // this should not fail!!1332 1333 // Currently the only packet type of events for MOTU 1334 // is MIDI in mbla. However in future control data1335 // might also be sent via "packet" events, so allow 1336 // for this possible expansion.1337 1338 // FIXME: MIDI input is completely untested at present.1339 switch (port->getPortType()) {1340 case Port::E_Midi: {1341 MotuMidiPort *mp=static_cast<MotuMidiPort *>(*it);1342 signed int sample;1343 unsigned int j = 0;1344 // Get MIDI bytes if present anywhere in the1345 // packet. MOTU MIDI data is sent using a1346 // 3-byte sequence starting at the port's1347 // position. It's thought that there can never1348 // be more than one MIDI byte per packet, but1349 // for completeness we'll check the entire packet1350 // anyway.1351 src = (unsigned char *)data + mp->getPosition();1352 while (j < nevents) {1353 if (*src==0x01 && *(src+1)==0x00) {1354 sample = *(src+2);1355 if (!mp->writeEvent(&sample)) {1356 debugWarning("MIDI packet port events lost\n");1357 ok = false;1358 }1359 }1360 j++;1361 src += m_event_size;1362 }1363 break;1364 }1365 default:1366 debugOutput(DEBUG_LEVEL_VERBOSE, "Unknown packet-type port format %d\n",port->getPortType());1367 return ok; 1368 }1369 }1370 1371 return ok;1372 } 1373 1374 signed int MotuReceiveStreamProcessor::decodeMotuEventsToPort(MotuAudioPort *p, 1375 quadlet_t *data, unsigned int offset, unsigned int nevents)1311 bool MotuReceiveStreamProcessor::decodePacketPorts(quadlet_t *data, unsigned int nevents, 1312 unsigned int dbc) { 1313 bool ok=true; 1314 1315 // Use char here since the source address won't necessarily be 1316 // aligned; use of an unaligned quadlet_t may cause issues on 1317 // certain architectures. Besides, the source for MIDI data going 1318 // directly to the MOTU isn't structured in quadlets anyway; it is a 1319 // sequence of 3 unaligned bytes. 1320 unsigned char *src = NULL; 1321 1322 for ( PortVectorIterator it = m_PacketPorts.begin(); 1323 it != m_PacketPorts.end(); 1324 ++it ) { 1325 1326 Port *port=dynamic_cast<Port *>(*it); 1327 assert(port); // this should not fail!! 1328 1329 // Currently the only packet type of events for MOTU 1330 // is MIDI in mbla. However in future control data 1331 // might also be sent via "packet" events, so allow 1332 // for this possible expansion. 1333 1334 // FIXME: MIDI input is completely untested at present. 1335 switch (port->getPortType()) { 1336 case Port::E_Midi: { 1337 MotuMidiPort *mp=static_cast<MotuMidiPort *>(*it); 1338 signed int sample; 1339 unsigned int j = 0; 1340 // Get MIDI bytes if present anywhere in the 1341 // packet. MOTU MIDI data is sent using a 1342 // 3-byte sequence starting at the port's 1343 // position. It's thought that there can never 1344 // be more than one MIDI byte per packet, but 1345 // for completeness we'll check the entire packet 1346 // anyway. 1347 src = (unsigned char *)data + mp->getPosition(); 1348 while (j < nevents) { 1349 if (*src==0x01 && *(src+1)==0x00) { 1350 sample = *(src+2); 1351 if (!mp->writeEvent(&sample)) { 1352 debugWarning("MIDI packet port events lost\n"); 1353 ok = false; 1354 } 1355 } 1356 j++; 1357 src += m_event_size; 1358 } 1359 break; 1360 } 1361 default: 1362 debugOutput(DEBUG_LEVEL_VERBOSE, "Unknown packet-type port format %d\n",port->getPortType()); 1363 return ok; 1364 } 1365 } 1366 1367 return ok; 1368 } 1369 1370 signed int MotuReceiveStreamProcessor::decodeMotuEventsToPort(MotuAudioPort *p, 1371 quadlet_t *data, unsigned int offset, unsigned int nevents) 1376 1372 { 1377 unsigned int j=0;1378 1379 // Use char here since a port's source address won't necessarily be1380 // aligned; use of an unaligned quadlet_t may cause issues on1381 // certain architectures. Besides, the source (data coming directly1382 // from the MOTU) isn't structured in quadlets anyway; it mainly1383 // consists of packed 24-bit integers.1384 1385 unsigned char *src_data;1386 src_data = (unsigned char *)data + p->getPosition();1387 1388 switch(p->getDataType()) {1389 default:1390 case Port::E_Int24:1391 {1392 quadlet_t *buffer=(quadlet_t *)(p->getBufferAddress());1393 1394 assert(nevents + offset <= p->getBufferSize());1395 1396 // Offset is in frames, but each port is only a single1397 // channel, so the number of frames is the same as the1398 // number of quadlets to offset (assuming the port buffer1399 // uses one quadlet per sample, which is the case currently).1400 buffer+=offset;1401 1402 for(j = 0; j < nevents; j += 1) { // Decode nsamples1403 *buffer = (*src_data<<16)+(*(src_data+1)<<8)+*(src_data+2);1404 // Sign-extend highest bit of 24-bit int.1405 // FIXME: this isn't strictly needed since E_Int24 is a 24-bit,1406 // but doing so shouldn't break anything and makes the data1407 // easier to deal with during debugging.1408 if (*src_data & 0x80)1409 *buffer |= 0xff000000;1410 1411 buffer++;1412 src_data+=m_event_size;1413 }1414 }1415 break;1416 case Port::E_Float:1417 {1418 const float multiplier = 1.0f / (float)(0x7FFFFF);1419 float *buffer=(float *)(p->getBufferAddress());1420 1421 assert(nevents + offset <= p->getBufferSize());1422 1423 buffer+=offset;1424 1425 for(j = 0; j < nevents; j += 1) { // decode max nsamples 1426 1427 unsigned int v = (*src_data<<16)+(*(src_data+1)<<8)+*(src_data+2);1428 1429 // sign-extend highest bit of 24-bit int1430 int tmp = (int)(v << 8) / 256;1431 1432 *buffer = tmp * multiplier;1433 1434 buffer++;1435 src_data+=m_event_size;1436 }1437 }1438 break;1439 }1440 1441 return 0;1373 unsigned int j=0; 1374 1375 // Use char here since a port's source address won't necessarily be 1376 // aligned; use of an unaligned quadlet_t may cause issues on 1377 // certain architectures. Besides, the source (data coming directly 1378 // from the MOTU) isn't structured in quadlets anyway; it mainly 1379 // consists of packed 24-bit integers. 1380 1381 unsigned char *src_data; 1382 src_data = (unsigned char *)data + p->getPosition(); 1383 1384 switch(p->getDataType()) { 1385 default: 1386 case Port::E_Int24: 1387 { 1388 quadlet_t *buffer=(quadlet_t *)(p->getBufferAddress()); 1389 1390 assert(nevents + offset <= p->getBufferSize()); 1391 1392 // Offset is in frames, but each port is only a single 1393 // channel, so the number of frames is the same as the 1394 // number of quadlets to offset (assuming the port buffer 1395 // uses one quadlet per sample, which is the case currently). 1396 buffer+=offset; 1397 1398 for(j = 0; j < nevents; j += 1) { // Decode nsamples 1399 *buffer = (*src_data<<16)+(*(src_data+1)<<8)+*(src_data+2); 1400 // Sign-extend highest bit of 24-bit int. 1401 // FIXME: this isn't strictly needed since E_Int24 is a 24-bit, 1402 // but doing so shouldn't break anything and makes the data 1403 // easier to deal with during debugging. 1404 if (*src_data & 0x80) 1405 *buffer |= 0xff000000; 1406 1407 buffer++; 1408 src_data+=m_event_size; 1409 } 1410 } 1411 break; 1412 case Port::E_Float: 1413 { 1414 const float multiplier = 1.0f / (float)(0x7FFFFF); 1415 float *buffer=(float *)(p->getBufferAddress()); 1416 1417 assert(nevents + offset <= p->getBufferSize()); 1418 1419 buffer+=offset; 1420 1421 for(j = 0; j < nevents; j += 1) { // decode max nsamples 1422 1423 unsigned int v = (*src_data<<16)+(*(src_data+1)<<8)+*(src_data+2); 1424 1425 // sign-extend highest bit of 24-bit int 1426 int tmp = (int)(v << 8) / 256; 1427 1428 *buffer = tmp * multiplier; 1429 1430 buffer++; 1431 src_data+=m_event_size; 1432 } 1433 } 1434 break; 1435 } 1436 1437 return 0; 1442 1438 } 1443 1439 1444 1440 signed int MotuReceiveStreamProcessor::setEventSize(unsigned int size) { 1445 m_event_size = size;1446 return 0;1441 m_event_size = size; 1442 return 0; 1447 1443 } 1448 1444 … … 1452 1448 // data packet in bytes. 1453 1449 // 1454 return m_event_size;1450 return m_event_size; 1455 1451 } 1456 1452 1457 1453 void MotuReceiveStreamProcessor::setVerboseLevel(int l) { 1458 setDebugLevel(l);1459 ReceiveStreamProcessor::setVerboseLevel(l);1454 setDebugLevel(l); 1455 ReceiveStreamProcessor::setVerboseLevel(l); 1460 1456 } 1461 1457 trunk/libffado/src/libstreaming/MotuStreamProcessor.h
r419 r445 1 /* $Id$ */ 1 /* 2 * Copyright (C) 2005-2007 by Jonathan Woithe 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 */ 2 24 3 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * Copyright (C) 2006 Jonathan Woithe <jwoithe@physics.adelaide.edu.au> 11 * 12 * This program is free software {} you can redistribute it and/or modify 13 * it under the terms of the GNU General Public License as published by 14 * the Free Software Foundation {} either version 2 of the License, or 15 * (at your option) any later version. 16 * 17 * This program is distributed in the hope that it will be useful, 18 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * GNU General Public License for more details. 21 * 22 * You should have received a copy of the GNU General Public License 23 * along with this program {} if not, write to the Free Software 24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 25 * 26 * 27 * 28 */ 29 #ifndef __FREEBOB_MOTUSTREAMPROCESSOR__ 30 #define __FREEBOB_MOTUSTREAMPROCESSOR__ 25 #ifndef __FFADO_MOTUSTREAMPROCESSOR__ 26 #define __FFADO_MOTUSTREAMPROCESSOR__ 31 27 #include <assert.h> 32 28 … … 48 44 { 49 45 public: 50 51 MotuTransmitStreamProcessor(int port, int framerate,52 unsigned int event_size);53 46 54 virtual ~MotuTransmitStreamProcessor(); 47 MotuTransmitStreamProcessor(int port, int framerate, 48 unsigned int event_size); 55 49 56 enum raw1394_iso_disposition 57 getPacket(unsigned char *data, unsigned int *length, 58 unsigned char *tag, unsigned char *sy, 59 int cycle, unsigned int dropped, unsigned int max_length); 50 virtual ~MotuTransmitStreamProcessor(); 60 51 61 bool init(); 62 bool reset(); 63 bool prepare(); 52 enum raw1394_iso_disposition 53 getPacket(unsigned char *data, unsigned int *length, 54 unsigned char *tag, unsigned char *sy, 55 int cycle, unsigned int dropped, unsigned int max_length); 64 56 65 bool prepareForStop(); 66 bool prepareForStart(); 67 57 bool init(); 58 bool reset(); 59 bool prepare(); 60 61 bool prepareForStop(); 62 bool prepareForStart(); 63 68 64 bool prepareForEnable(uint64_t time_to_enable_at); 69 65 70 66 bool putFrames(unsigned int nbframes, int64_t ts); ///< transfer the buffer contents from the client 71 72 // These two are important to calculate the optimal ISO DMA buffers73 // size. An estimate will do.74 unsigned int getPacketsPerPeriod() {return (m_period*8000) / m_framerate;};75 unsigned int getMaxPacketSize() {return m_framerate<=48000?616:(m_framerate<=96000?1032:1160);}; 67 68 // These two are important to calculate the optimal ISO DMA buffers 69 // size. An estimate will do. 70 unsigned int getPacketsPerPeriod() {return (m_period*8000) / m_framerate;}; 71 unsigned int getMaxPacketSize() {return m_framerate<=48000?616:(m_framerate<=96000?1032:1160);}; 76 72 77 73 int getMinimalSyncDelay(); 78 74 79 void setVerboseLevel(int l);75 void setVerboseLevel(int l); 80 76 81 77 protected: 82 /*83 * An iso packet mostly consists of multiple events. m_event_size84 * is the size of a single 'event' in bytes.85 */86 unsigned int m_event_size;78 /* 79 * An iso packet mostly consists of multiple events. m_event_size 80 * is the size of a single 'event' in bytes. 81 */ 82 unsigned int m_event_size; 87 83 88 // Keep track of transmission data block count89 unsigned int m_tx_dbc;84 // Keep track of transmission data block count 85 unsigned int m_tx_dbc; 90 86 91 // Used to keep track of the close-down zeroing of output data92 signed int m_closedown_count;93 signed int m_streaming_active;87 // Used to keep track of the close-down zeroing of output data 88 signed int m_closedown_count; 89 signed int m_streaming_active; 94 90 95 91 bool prefill(); 96 97 bool transferSilence(unsigned int size);92 93 bool transferSilence(unsigned int size); 98 94 99 95 bool processWriteBlock(char *data, unsigned int nevents, unsigned int offset); 100 96 101 bool encodePacketPorts(quadlet_t *data, unsigned int nevents, unsigned int dbc);102 103 int transmitSilenceBlock(char *data, unsigned int nevents, 104 unsigned int offset);105 106 int encodePortToMotuEvents(MotuAudioPort *p, quadlet_t *data, 107 unsigned int offset, unsigned int nevents);108 int encodeSilencePortToMotuEvents(MotuAudioPort *p, quadlet_t *data, 109 unsigned int offset, unsigned int nevents);97 bool encodePacketPorts(quadlet_t *data, unsigned int nevents, unsigned int dbc); 98 99 int transmitSilenceBlock(char *data, unsigned int nevents, 100 unsigned int offset); 101 102 int encodePortToMotuEvents(MotuAudioPort *p, quadlet_t *data, 103 unsigned int offset, unsigned int nevents); 104 int encodeSilencePortToMotuEvents(MotuAudioPort *p, quadlet_t *data, 105 unsigned int offset, unsigned int nevents); 110 106 111 107 DECLARE_DEBUG_MODULE; … … 118 114 */ 119 115 class MotuReceiveStreamProcessor 120 : public ReceiveStreamProcessor 116 : public ReceiveStreamProcessor 121 117 { 122 118 123 119 public: 124 120 125 MotuReceiveStreamProcessor(int port, int framerate, unsigned int event_size);126 virtual ~MotuReceiveStreamProcessor();127 128 enum raw1394_iso_disposition putPacket(unsigned char *data, unsigned int length, 129 unsigned char channel, unsigned char tag, unsigned char sy, 130 unsigned int cycle, unsigned int dropped);131 121 MotuReceiveStreamProcessor(int port, int framerate, unsigned int event_size); 122 virtual ~MotuReceiveStreamProcessor(); 123 124 enum raw1394_iso_disposition putPacket(unsigned char *data, unsigned int length, 125 unsigned char channel, unsigned char tag, unsigned char sy, 126 unsigned int cycle, unsigned int dropped); 127 132 128 bool getFrames(unsigned int nbframes); ///< transfer the buffer contents to the client 133 134 bool init();135 bool reset();136 bool prepare();129 130 bool init(); 131 bool reset(); 132 bool prepare(); 137 133 138 134 // these two are important to calculate the optimal 139 135 // ISO DMA buffers size 140 136 // an estimate will do 141 unsigned int getPacketsPerPeriod() {return (m_period*8000) / m_framerate;};142 unsigned int getMaxPacketSize() {return m_framerate<=48000?616:(m_framerate<=96000?1032:1160);}; 143 137 unsigned int getPacketsPerPeriod() {return (m_period*8000) / m_framerate;}; 138 unsigned int getMaxPacketSize() {return m_framerate<=48000?616:(m_framerate<=96000?1032:1160);}; 139 144 140 int getMinimalSyncDelay(); 145 141 146 virtual void setVerboseLevel(int l); 147 148 signed int setEventSize(unsigned int size); 149 unsigned int getEventSize(void); 142 virtual void setVerboseLevel(int l); 150 143 151 virtual bool prepareForStop(); 152 virtual bool prepareForStart(); 144 signed int setEventSize(unsigned int size); 145 unsigned int getEventSize(void); 146 147 virtual bool prepareForStop(); 148 virtual bool prepareForStart(); 153 149 154 150 protected: 155 151 156 bool processReadBlock(char *data, unsigned int nevents, unsigned int offset); 157 158 bool decodePacketPorts(quadlet_t *data, unsigned int nevents, unsigned int dbc); 159 signed int decodeMotuEventsToPort(MotuAudioPort *p, quadlet_t *data, unsigned int offset, unsigned int nevents); 152 bool processReadBlock(char *data, unsigned int nevents, unsigned int offset); 160 153 161 /* 162 * An iso packet mostly consists of multiple events. m_event_size 163 * is the size of a single 'event' in bytes. 164 */ 165 unsigned int m_event_size; 154 bool decodePacketPorts(quadlet_t *data, unsigned int nevents, unsigned int dbc); 155 signed int decodeMotuEventsToPort(MotuAudioPort *p, quadlet_t *data, unsigned int offset, unsigned int nevents); 166 156 167 // Signifies a closedown is in progress, in which case incoming data 157 /* 158 * An iso packet mostly consists of multiple events. m_event_size 159 * is the size of a single 'event' in bytes. 160 */ 161 unsigned int m_event_size; 162 163 // Signifies a closedown is in progress, in which case incoming data 168 164 // is junked. 169 165 signed int m_closedown_active; 170 166 171 167 uint64_t m_last_timestamp; /// last timestamp (in ticks) 172 168 uint64_t m_last_timestamp2; /// last timestamp (in ticks) 173 169 uint64_t m_last_timestamp_at_period_ticks; 174 170 175 171 DECLARE_DEBUG_MODULE; 176 172 … … 179 175 } // end of namespace Streaming 180 176 181 #endif /* __F REEBOB_MOTUSTREAMPROCESSOR__ */177 #endif /* __FFADO_MOTUSTREAMPROCESSOR__ */ 182 178 183 179 trunk/libffado/src/libstreaming/Port.cpp
r419 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 2 * Copyright (C) 2005-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 27 22 */ 28 23 29 24 #include "Port.h" 30 #include <stdlib.h>25 #include <stdlib.h> 31 26 #include <assert.h> 32 27 33 34 28 namespace Streaming { 35 29 36 30 IMPL_DEBUG_MODULE( Port, Port, DEBUG_LEVEL_NORMAL ); 37 31 38 Port::Port(std::string name, enum E_PortType porttype, enum E_Direction direction) 39 : m_Name(name),40 m_SignalType(E_PeriodSignalled),41 m_BufferType(E_PointerBuffer),42 m_disabled(true),43 m_initialized(false),44 m_buffersize(0),45 m_eventsize(0),46 m_DataType(E_Int24),47 m_PortType(porttype),48 m_Direction(direction),49 m_buffer(0),50 m_ringbuffer(0),51 m_use_external_buffer(false),52 m_do_ratecontrol(false),53 m_event_interval(0),54 m_slot_interval(0),55 m_rate_counter(0),56 m_rate_counter_minimum(0),57 m_average_ratecontrol(false)58 32 Port::Port(std::string name, enum E_PortType porttype, enum E_Direction direction) 33 : m_Name(name), 34 m_SignalType(E_PeriodSignalled), 35 m_BufferType(E_PointerBuffer), 36 m_disabled(true), 37 m_initialized(false), 38 m_buffersize(0), 39 m_eventsize(0), 40 m_DataType(E_Int24), 41 m_PortType(porttype), 42 m_Direction(direction), 43 m_buffer(0), 44 m_ringbuffer(0), 45 m_use_external_buffer(false), 46 m_do_ratecontrol(false), 47 m_event_interval(0), 48 m_slot_interval(0), 49 m_rate_counter(0), 50 m_rate_counter_minimum(0), 51 m_average_ratecontrol(false) 52 59 53 { 60 54 … … 69 63 */ 70 64 bool Port::init() { 71 if (m_initialized) {72 debugFatal("Port already initialized... (%s)\n",m_Name.c_str());73 return false;74 } 75 76 if (m_buffersize==0) {77 debugFatal("Cannot initialize a port with buffersize=0\n");78 return false; 79 }80 81 switch (m_BufferType) {82 case E_PointerBuffer:83 if (m_use_external_buffer) {84 // don't do anything85 } else if (!allocateInternalBuffer()) {86 debugFatal("Could not allocate internal buffer!\n");87 return false;88 }89 break;90 91 case E_RingBuffer:92 if (m_use_external_buffer) {93 debugFatal("Cannot use an external ringbuffer! \n");94 return false;95 } else if (!allocateInternalRingBuffer()) {96 debugFatal("Could not allocate internal ringbuffer!\n");97 return false;98 }99 break;100 default:101 debugFatal("Unsupported buffer type! (%d)\n",(int)m_BufferType);102 return false;103 break;104 }105 106 m_initialized=true;107 108 m_eventsize=getEventSize(); // this won't change, so cache it109 110 return m_initialized;65 if (m_initialized) { 66 debugFatal("Port already initialized... (%s)\n",m_Name.c_str()); 67 return false; 68 } 69 70 if (m_buffersize==0) { 71 debugFatal("Cannot initialize a port with buffersize=0\n"); 72 return false; 73 } 74 75 switch (m_BufferType) { 76 case E_PointerBuffer: 77 if (m_use_external_buffer) { 78 // don't do anything 79 } else if (!allocateInternalBuffer()) { 80 debugFatal("Could not allocate internal buffer!\n"); 81 return false; 82 } 83 break; 84 85 case E_RingBuffer: 86 if (m_use_external_buffer) { 87 debugFatal("Cannot use an external ringbuffer! \n"); 88 return false; 89 } else if (!allocateInternalRingBuffer()) { 90 debugFatal("Could not allocate internal ringbuffer!\n"); 91 return false; 92 } 93 break; 94 default: 95 debugFatal("Unsupported buffer type! (%d)\n",(int)m_BufferType); 96 return false; 97 break; 98 } 99 100 m_initialized=true; 101 102 m_eventsize=getEventSize(); // this won't change, so cache it 103 104 return m_initialized; 111 105 } 112 106 113 107 bool Port::reset() { 114 if (m_BufferType==E_RingBuffer) {115 freebob_ringbuffer_reset(m_ringbuffer);116 }117 return true;108 if (m_BufferType==E_RingBuffer) { 109 ffado_ringbuffer_reset(m_ringbuffer); 110 } 111 return true; 118 112 }; 119 113 120 114 121 115 void Port::setVerboseLevel(int l) { 122 setDebugLevel(l);116 setDebugLevel(l); 123 117 } 124 118 125 119 bool Port::setName(std::string name) { 126 debugOutput( DEBUG_LEVEL_VERBOSE, "Setting name to %s for port %s\n",name.c_str(),m_Name.c_str());127 128 if (m_initialized) {129 debugFatal("Port already initialized... (%s)\n",m_Name.c_str());130 return false;131 }132 133 m_Name=name;134 135 return true;120 debugOutput( DEBUG_LEVEL_VERBOSE, "Setting name to %s for port %s\n",name.c_str(),m_Name.c_str()); 121 122 if (m_initialized) { 123 debugFatal("Port already initialized... (%s)\n",m_Name.c_str()); 124 return false; 125 } 126 127 m_Name=name; 128 129 return true; 136 130 } 137 131 138 132 bool Port::setBufferSize(unsigned int newsize) { 139 debugOutput( DEBUG_LEVEL_VERBOSE, "Setting buffersize to %d for port %s\n",newsize,m_Name.c_str());140 if (m_initialized) {141 debugFatal("Port already initialized... (%s)\n",m_Name.c_str());142 return false;143 }144 145 m_buffersize=newsize;146 return true;133 debugOutput( DEBUG_LEVEL_VERBOSE, "Setting buffersize to %d for port %s\n",newsize,m_Name.c_str()); 134 if (m_initialized) { 135 debugFatal("Port already initialized... (%s)\n",m_Name.c_str()); 136 return false; 137 } 138 139 m_buffersize=newsize; 140 return true; 147 141 148 142 } 149 143 150 144 unsigned int Port::getEventSize() { 151 switch (m_DataType) {152 case E_Float:153 return sizeof(float);154 case E_Int24: // 24 bit 2's complement, packed in a 32bit integer (LSB's)155 return sizeof(uint32_t);156 case E_MidiEvent:157 return sizeof(uint32_t);158 default:159 return 0;160 }145 switch (m_DataType) { 146 case E_Float: 147 return sizeof(float); 148 case E_Int24: // 24 bit 2's complement, packed in a 32bit integer (LSB's) 149 return sizeof(uint32_t); 150 case E_MidiEvent: 151 return sizeof(uint32_t); 152 default: 153 return 0; 154 } 161 155 } 162 156 163 157 bool Port::setDataType(enum E_DataType d) { 164 debugOutput( DEBUG_LEVEL_VERBOSE, "Setting datatype to %d for port %s\n",(int) d,m_Name.c_str());165 if (m_initialized) {166 debugFatal("Port already initialized... (%s)\n",m_Name.c_str());167 return false;168 }169 170 // do some sanity checks171 bool type_is_ok=false;172 switch (m_PortType) {173 case E_Audio:174 if(d == E_Int24) type_is_ok=true;175 if(d == E_Float) type_is_ok=true;176 break;177 case E_Midi:178 if(d == E_MidiEvent) type_is_ok=true;179 break;180 case E_Control:181 if(d == E_Default) type_is_ok=true;182 break;183 default:184 break;185 }186 187 if(!type_is_ok) {188 debugFatal("Datatype not supported by this type of port!\n");189 return false;190 }191 192 m_DataType=d;193 return true;158 debugOutput( DEBUG_LEVEL_VERBOSE, "Setting datatype to %d for port %s\n",(int) d,m_Name.c_str()); 159 if (m_initialized) { 160 debugFatal("Port already initialized... (%s)\n",m_Name.c_str()); 161 return false; 162 } 163 164 // do some sanity checks 165 bool type_is_ok=false; 166 switch (m_PortType) { 167 case E_Audio: 168 if(d == E_Int24) type_is_ok=true; 169 if(d == E_Float) type_is_ok=true; 170 break; 171 case E_Midi: 172 if(d == E_MidiEvent) type_is_ok=true; 173 break; 174 case E_Control: 175 if(d == E_Default) type_is_ok=true; 176 break; 177 default: 178 break; 179 } 180 181 if(!type_is_ok) { 182 debugFatal("Datatype not supported by this type of port!\n"); 183 return false; 184 } 185 186 m_DataType=d; 187 return true; 194 188 } 195 189 196 190 bool Port::setSignalType(enum E_SignalType s) { 197 debugOutput( DEBUG_LEVEL_VERBOSE, "Setting signaltype to %d for port %s\n",(int)s,m_Name.c_str());198 if (m_initialized) {199 debugFatal("Port already initialized... (%s)\n",m_Name.c_str());200 return false;201 }202 203 // do some sanity checks204 bool type_is_ok=false;205 switch (m_PortType) {206 case E_Audio:207 if(s == E_PeriodSignalled) type_is_ok=true;208 break;209 case E_Midi:210 if(s == E_PacketSignalled) type_is_ok=true;211 break;212 case E_Control:213 if(s == E_PeriodSignalled) type_is_ok=true;214 break;215 default:216 break;217 }218 219 if(!type_is_ok) {220 debugFatal("Signalling type not supported by this type of port!\n");221 return false;222 }223 224 m_SignalType=s;225 return true;191 debugOutput( DEBUG_LEVEL_VERBOSE, "Setting signaltype to %d for port %s\n",(int)s,m_Name.c_str()); 192 if (m_initialized) { 193 debugFatal("Port already initialized... (%s)\n",m_Name.c_str()); 194 return false; 195 } 196 197 // do some sanity checks 198 bool type_is_ok=false; 199 switch (m_PortType) { 200 case E_Audio: 201 if(s == E_PeriodSignalled) type_is_ok=true; 202 break; 203 case E_Midi: 204 if(s == E_PacketSignalled) type_is_ok=true; 205 break; 206 case E_Control: 207 if(s == E_PeriodSignalled) type_is_ok=true; 208 break; 209 default: 210 break; 211 } 212 213 if(!type_is_ok) { 214 debugFatal("Signalling type not supported by this type of port!\n"); 215 return false; 216 } 217 218 m_SignalType=s; 219 return true; 226 220 227 221 } 228 222 229 223 bool Port::setBufferType(enum E_BufferType b) { 230 debugOutput( DEBUG_LEVEL_VERBOSE, "Setting buffer type to %d for port %s\n",(int)b,m_Name.c_str());231 if (m_initialized) {232 debugFatal("Port already initialized... (%s)\n",m_Name.c_str());233 return false;234 }235 236 // do some sanity checks237 bool type_is_ok=false;238 switch (m_PortType) {239 case E_Audio:240 if(b == E_PointerBuffer) type_is_ok=true;241 break;242 case E_Midi:243 if(b == E_RingBuffer) type_is_ok=true;244 break;245 case E_Control:246 break;247 default:248 break;249 }250 251 if(!type_is_ok) {252 debugFatal("Buffer type not supported by this type of port!\n");253 return false;254 }255 256 m_BufferType=b;257 return true;224 debugOutput( DEBUG_LEVEL_VERBOSE, "Setting buffer type to %d for port %s\n",(int)b,m_Name.c_str()); 225 if (m_initialized) { 226 debugFatal("Port already initialized... (%s)\n",m_Name.c_str()); 227 return false; 228 } 229 230 // do some sanity checks 231 bool type_is_ok=false; 232 switch (m_PortType) { 233 case E_Audio: 234 if(b == E_PointerBuffer) type_is_ok=true; 235 break; 236 case E_Midi: 237 if(b == E_RingBuffer) type_is_ok=true; 238 break; 239 case E_Control: 240 break; 241 default: 242 break; 243 } 244 245 if(!type_is_ok) { 246 debugFatal("Buffer type not supported by this type of port!\n"); 247 return false; 248 } 249 250 m_BufferType=b; 251 return true; 258 252 259 253 } … … 261 255 bool Port::useExternalBuffer(bool b) { 262 256 263 // If called on an initialised stream but the request isn't for a change silently264 // allow it (relied on by C API as used by jack backend driver)265 if (m_initialized && m_use_external_buffer==b)266 return true;267 268 debugOutput( DEBUG_LEVEL_VERBOSE, "Setting external buffer use to %d for port %s\n",(int)b,m_Name.c_str());269 270 if (m_initialized) {271 debugFatal("Port already initialized... (%s)\n",m_Name.c_str());272 return false;273 }274 275 m_use_external_buffer=b;276 return true;257 // If called on an initialised stream but the request isn't for a change silently 258 // allow it (relied on by C API as used by jack backend driver) 259 if (m_initialized && m_use_external_buffer==b) 260 return true; 261 262 debugOutput( DEBUG_LEVEL_VERBOSE, "Setting external buffer use to %d for port %s\n",(int)b,m_Name.c_str()); 263 264 if (m_initialized) { 265 debugFatal("Port already initialized... (%s)\n",m_Name.c_str()); 266 return false; 267 } 268 269 m_use_external_buffer=b; 270 return true; 277 271 } 278 272 … … 281 275 * Get the buffer address (being the external or the internal one). 282 276 * 283 * @param buff 277 * @param buff 284 278 */ 285 279 void *Port::getBufferAddress() { 286 assert(m_BufferType==E_PointerBuffer);287 return m_buffer;280 assert(m_BufferType==E_PointerBuffer); 281 return m_buffer; 288 282 }; 289 283 … … 292 286 * only call this when specifying an external buffer before init() 293 287 * 294 * @param buff 288 * @param buff 295 289 */ 296 290 void Port::setExternalBufferAddress(void *buff) { 297 assert(m_BufferType==E_PointerBuffer);298 assert(m_use_external_buffer); // don't call this with an internal buffer!299 m_buffer=buff;291 assert(m_BufferType==E_PointerBuffer); 292 assert(m_use_external_buffer); // don't call this with an internal buffer! 293 m_buffer=buff; 300 294 }; 301 295 302 296 // buffer handling api's for ringbuffers 303 297 bool Port::writeEvent(void *event) { 304 assert(m_BufferType==E_RingBuffer);305 assert(m_ringbuffer);306 307 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "Writing event %08X with size %d to port %s\n",*((quadlet_t *)event),m_eventsize, m_Name.c_str());308 309 return (freebob_ringbuffer_write(m_ringbuffer, (char *)event, m_eventsize)==m_eventsize);298 assert(m_BufferType==E_RingBuffer); 299 assert(m_ringbuffer); 300 301 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "Writing event %08X with size %d to port %s\n",*((quadlet_t *)event),m_eventsize, m_Name.c_str()); 302 303 return (ffado_ringbuffer_write(m_ringbuffer, (char *)event, m_eventsize)==m_eventsize); 310 304 } 311 305 312 306 bool Port::readEvent(void *event) { 313 assert(m_ringbuffer);314 315 unsigned int read=freebob_ringbuffer_read(m_ringbuffer, (char *)event, m_eventsize);316 317 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "Reading event %X with size %d from port %s\n",*((quadlet_t *)event),m_eventsize,m_Name.c_str());318 return (read==m_eventsize);307 assert(m_ringbuffer); 308 309 unsigned int read=ffado_ringbuffer_read(m_ringbuffer, (char *)event, m_eventsize); 310 311 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "Reading event %X with size %d from port %s\n",*((quadlet_t *)event),m_eventsize,m_Name.c_str()); 312 return (read==m_eventsize); 319 313 } 320 314 321 315 int Port::writeEvents(void *event, unsigned int nevents) { 322 assert(m_BufferType==E_RingBuffer); 323 assert(m_ringbuffer); 324 325 unsigned int bytes2write=m_eventsize*nevents; 326 327 unsigned int written=freebob_ringbuffer_write(m_ringbuffer, (char *)event,bytes2write)/m_eventsize; 328 329 if(written) { 330 unsigned int i=0; 331 quadlet_t * tmp=(quadlet_t *)event; 332 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "Written %d events (",written); 333 for (i=0;i<written;i++) { 334 debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, "%X ", *(tmp+i)); 335 } 336 debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, ") to port %s\n",m_Name.c_str()); 337 } 338 339 return written; 316 assert(m_BufferType==E_RingBuffer); 317 assert(m_ringbuffer); 318 319 unsigned int bytes2write=m_eventsize*nevents; 320 321 unsigned int written=ffado_ringbuffer_write(m_ringbuffer, (char *)event,bytes2write)/m_eventsize; 322 323 #ifdef DEBUG 324 if(written) { 325 unsigned int i=0; 326 quadlet_t * tmp=(quadlet_t *)event; 327 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "Written %d events (",written); 328 for (i=0;i<written;i++) { 329 debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, "%X ", *(tmp+i)); 330 } 331 debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, ") to port %s\n",m_Name.c_str()); 332 } 333 #endif 334 335 return written; 340 336 341 337 } 342 338 343 339 int Port::readEvents(void *event, unsigned int nevents) { 344 assert(m_ringbuffer); 345 346 unsigned int bytes2read=m_eventsize*nevents; 347 348 unsigned int read=freebob_ringbuffer_read(m_ringbuffer, (char *)event, bytes2read)/m_eventsize; 349 350 if(read) { 351 unsigned int i=0; 352 quadlet_t * tmp=(quadlet_t *)event; 353 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "Read %d events (",read); 354 for (i=0;i<read;i++) { 355 debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, "%X ", *(tmp+i)); 356 } 357 debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, ") from port %s\n",m_Name.c_str()); 358 } 359 360 return read; 340 assert(m_ringbuffer); 341 342 unsigned int bytes2read=m_eventsize*nevents; 343 344 unsigned int read=ffado_ringbuffer_read(m_ringbuffer, (char *)event, bytes2read)/m_eventsize; 345 346 #ifdef DEBUG 347 if(read) { 348 unsigned int i=0; 349 quadlet_t * tmp=(quadlet_t *)event; 350 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "Read %d events (",read); 351 for (i=0;i<read;i++) { 352 debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, "%X ", *(tmp+i)); 353 } 354 debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, ") from port %s\n",m_Name.c_str()); 355 } 356 #endif 357 358 return read; 361 359 } 362 360 363 361 /* rate control */ 364 362 bool Port::canRead() { 365 bool byte_present_in_buffer;366 367 bool retval=false;368 369 assert(m_ringbuffer);370 371 byte_present_in_buffer=(freebob_ringbuffer_read_space(m_ringbuffer) >= m_eventsize);372 373 if(byte_present_in_buffer) {374 375 if(!m_do_ratecontrol) {376 return true;377 }378 379 if(m_rate_counter <= 0) {380 // update the counter381 if(m_average_ratecontrol) {382 m_rate_counter += m_event_interval;383 assert(m_rate_counter<m_event_interval);384 } else {385 m_rate_counter = m_event_interval;386 }387 388 retval=true;389 } else {390 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "Rate limit (%s)! rate_counter=%d \n",m_Name.c_str(),m_rate_counter);391 392 }393 }394 395 396 m_rate_counter -= m_slot_interval;397 398 // we have to limit the decrement of the ratecounter somehow.399 // m_rate_counter_minimum is initialized when enabling ratecontrol400 if(m_rate_counter < m_rate_counter_minimum) {401 m_rate_counter = m_rate_counter_minimum;402 }403 404 return retval;405 } 406 407 bool Port::useRateControl(bool use, unsigned int slot_interval, 408 unsigned int event_interval, bool average) {409 410 if (use) {411 debugOutput(DEBUG_LEVEL_VERBOSE, "Enabling rate control for port %s...\n",m_Name.c_str());412 if(slot_interval>event_interval) {413 debugWarning("Rate control not needed!\n",m_Name.c_str());414 m_do_ratecontrol=false;415 return false;416 }417 if(slot_interval==0) {418 debugFatal("Cannot have slot interval == 0!\n");419 m_do_ratecontrol=false;420 return false;421 }422 if(event_interval==0) {423 debugFatal("Cannot have event interval == 0!\n");424 m_do_ratecontrol=false;425 return false;426 }427 m_do_ratecontrol=use;428 m_event_interval=event_interval;429 m_slot_interval=slot_interval;430 m_rate_counter=0;431 432 // NOTE: pretty arbitrary, but in average mode this limits the peak stream rate433 m_rate_counter_minimum=-(2*event_interval);434 435 m_average_ratecontrol=average;436 437 } else {438 debugOutput(DEBUG_LEVEL_VERBOSE, "Disabling rate control for port %s...\n",m_Name.c_str());439 m_do_ratecontrol=use;440 }441 return true;363 bool byte_present_in_buffer; 364 365 bool retval=false; 366 367 assert(m_ringbuffer); 368 369 byte_present_in_buffer=(ffado_ringbuffer_read_space(m_ringbuffer) >= m_eventsize); 370 371 if(byte_present_in_buffer) { 372 373 if(!m_do_ratecontrol) { 374 return true; 375 } 376 377 if(m_rate_counter <= 0) { 378 // update the counter 379 if(m_average_ratecontrol) { 380 m_rate_counter += m_event_interval; 381 assert(m_rate_counter<m_event_interval); 382 } else { 383 m_rate_counter = m_event_interval; 384 } 385 386 retval=true; 387 } else { 388 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "Rate limit (%s)! rate_counter=%d \n",m_Name.c_str(),m_rate_counter); 389 390 } 391 } 392 393 394 m_rate_counter -= m_slot_interval; 395 396 // we have to limit the decrement of the ratecounter somehow. 397 // m_rate_counter_minimum is initialized when enabling ratecontrol 398 if(m_rate_counter < m_rate_counter_minimum) { 399 m_rate_counter = m_rate_counter_minimum; 400 } 401 402 return retval; 403 } 404 405 bool Port::useRateControl(bool use, unsigned int slot_interval, 406 unsigned int event_interval, bool average) { 407 408 if (use) { 409 debugOutput(DEBUG_LEVEL_VERBOSE, "Enabling rate control for port %s...\n",m_Name.c_str()); 410 if(slot_interval>event_interval) { 411 debugWarning("Rate control not needed!\n",m_Name.c_str()); 412 m_do_ratecontrol=false; 413 return false; 414 } 415 if(slot_interval==0) { 416 debugFatal("Cannot have slot interval == 0!\n"); 417 m_do_ratecontrol=false; 418 return false; 419 } 420 if(event_interval==0) { 421 debugFatal("Cannot have event interval == 0!\n"); 422 m_do_ratecontrol=false; 423 return false; 424 } 425 m_do_ratecontrol=use; 426 m_event_interval=event_interval; 427 m_slot_interval=slot_interval; 428 m_rate_counter=0; 429 430 // NOTE: pretty arbitrary, but in average mode this limits the peak stream rate 431 m_rate_counter_minimum=-(2*event_interval); 432 433 m_average_ratecontrol=average; 434 435 } else { 436 debugOutput(DEBUG_LEVEL_VERBOSE, "Disabling rate control for port %s...\n",m_Name.c_str()); 437 m_do_ratecontrol=use; 438 } 439 return true; 442 440 } 443 441 444 442 /// Enable the port. (this can be called anytime) 445 void 443 void 446 444 Port::enable() { 447 debugOutput(DEBUG_LEVEL_VERBOSE, "Enabling port %s...\n",m_Name.c_str()); 448 m_disabled=false; 449 }; 450 451 /// Disable the port. (this can be called anytime) 452 void 453 Port::disable() { 454 debugOutput(DEBUG_LEVEL_VERBOSE, "Disabling port %s...\n",m_Name.c_str()); 445 debugOutput(DEBUG_LEVEL_VERBOSE, "Enabling port %s...\n",m_Name.c_str()); 455 446 m_disabled=false; 456 447 }; 457 448 449 /// Disable the port. (this can be called anytime) 450 void 451 Port::disable() { 452 debugOutput(DEBUG_LEVEL_VERBOSE, "Disabling port %s...\n",m_Name.c_str()); 453 m_disabled=false; 454 }; 455 458 456 459 457 /* Private functions */ 460 458 461 459 bool Port::allocateInternalBuffer() { 462 int event_size=getEventSize();463 464 debugOutput(DEBUG_LEVEL_VERBOSE,465 "Allocating internal buffer of %d events with size %d (%s)\n",466 m_buffersize, event_size, m_Name.c_str());467 468 if(m_buffer) {469 debugWarning("already has an internal buffer attached, re-allocating\n");470 freeInternalBuffer();471 }472 473 m_buffer=calloc(m_buffersize,event_size);474 if (!m_buffer) {475 debugFatal("could not allocate internal buffer\n");476 m_buffersize=0;477 return false;478 }479 480 return true;460 int event_size=getEventSize(); 461 462 debugOutput(DEBUG_LEVEL_VERBOSE, 463 "Allocating internal buffer of %d events with size %d (%s)\n", 464 m_buffersize, event_size, m_Name.c_str()); 465 466 if(m_buffer) { 467 debugWarning("already has an internal buffer attached, re-allocating\n"); 468 freeInternalBuffer(); 469 } 470 471 m_buffer=calloc(m_buffersize,event_size); 472 if (!m_buffer) { 473 debugFatal("could not allocate internal buffer\n"); 474 m_buffersize=0; 475 return false; 476 } 477 478 return true; 481 479 } 482 480 483 481 void Port::freeInternalBuffer() { 484 debugOutput(DEBUG_LEVEL_VERBOSE,485 "Freeing internal buffer (%s)\n",m_Name.c_str());486 487 if(m_buffer) {488 free(m_buffer);489 m_buffer=0;490 }482 debugOutput(DEBUG_LEVEL_VERBOSE, 483 "Freeing internal buffer (%s)\n",m_Name.c_str()); 484 485 if(m_buffer) { 486 free(m_buffer); 487 m_buffer=0; 488 } 491 489 } 492 490 493 491 bool Port::allocateInternalRingBuffer() { 494 int event_size=getEventSize();495 496 debugOutput(DEBUG_LEVEL_VERBOSE,497 "Allocating internal buffer of %d events with size %d (%s)\n",498 m_buffersize, event_size, m_Name.c_str());499 500 if(m_ringbuffer) {501 debugWarning("already has an internal ringbuffer attached, re-allocating\n");502 freeInternalRingBuffer();503 }504 505 m_ringbuffer=freebob_ringbuffer_create(m_buffersize * event_size);506 if (!m_ringbuffer) {507 debugFatal("could not allocate internal ringbuffer\n");508 m_buffersize=0;509 return false;510 }511 512 return true;492 int event_size=getEventSize(); 493 494 debugOutput(DEBUG_LEVEL_VERBOSE, 495 "Allocating internal buffer of %d events with size %d (%s)\n", 496 m_buffersize, event_size, m_Name.c_str()); 497 498 if(m_ringbuffer) { 499 debugWarning("already has an internal ringbuffer attached, re-allocating\n"); 500 freeInternalRingBuffer(); 501 } 502 503 m_ringbuffer=ffado_ringbuffer_create(m_buffersize * event_size); 504 if (!m_ringbuffer) { 505 debugFatal("could not allocate internal ringbuffer\n"); 506 m_buffersize=0; 507 return false; 508 } 509 510 return true; 513 511 } 514 512 515 513 void Port::freeInternalRingBuffer() { 516 debugOutput(DEBUG_LEVEL_VERBOSE,517 "Freeing internal ringbuffer (%s)\n",m_Name.c_str());518 519 if(m_ringbuffer) {520 freebob_ringbuffer_free(m_ringbuffer);521 m_ringbuffer=0;522 }523 } 524 525 } 514 debugOutput(DEBUG_LEVEL_VERBOSE, 515 "Freeing internal ringbuffer (%s)\n",m_Name.c_str()); 516 517 if(m_ringbuffer) { 518 ffado_ringbuffer_free(m_ringbuffer); 519 m_ringbuffer=0; 520 } 521 } 522 523 } trunk/libffado/src/libstreaming/Port.h
r419 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 2 * Copyright (C) 2005-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 27 22 */ 28 #ifndef __FREEBOB_PORT__ 29 #define __FREEBOB_PORT__ 23 24 #ifndef __FFADO_PORT__ 25 #define __FFADO_PORT__ 30 26 31 27 #include <stdint.h> … … 43 39 layer and the datatype-specific layer. You can define port types by subclassing 44 40 the base port class. 45 41 46 42 After creating a port, you have to set its parameters and then call the init() function. 47 This is because a port needs information from two sources to operate: 43 This is because a port needs information from two sources to operate: 48 44 1) the stream composition information from the AvDevice 49 45 2) the streaming API setup (buffer type, data type, ...) 50 46 51 47 \note There are not much virtual functions here because of the high frequency of 52 48 calling. We try to do everything with a base class getter, and a child class 53 49 setter. If this isn't possible, we do a static_cast. This however can only be 54 done inside the streamprocessor that handles the specific sub-class types of 50 done inside the streamprocessor that handles the specific sub-class types of 55 51 the ports. i.e. by design you should make sure that the static_cast will be 56 52 OK. 57 53 58 54 \todo rework the implementation into something more beautifull 59 55 */ … … 61 57 62 58 public: 63 friend class PortManager;64 65 /*66 * IMPORTANT: if you add something to any of these enum's, be sure to67 * check the code where they are used.68 */69 70 /*!71 \brief Specifies the buffer type for ports72 73 A PointerBuffer uses the getBufferAddress() and setBufferAddres() interface74 A Ringbuffer uses the read/write interface75 */76 enum E_BufferType {77 E_PointerBuffer, 78 E_RingBuffer79 };80 81 /*!82 \brief Specifies the signalling type for ports83 */84 enum E_SignalType {85 E_PacketSignalled, ///< the port is to be processed for every packet86 E_PeriodSignalled, ///< the port is to be processed after a period of frames87 // E_SampleSignalled ///< the port is to be processed after each frame (sample)88 };89 90 /*!91 \brief The datatype of the port buffer92 */93 enum E_DataType {94 E_Float,95 E_Int24,96 E_MidiEvent,97 E_Default,98 };99 100 /*!101 \brief The port type102 */103 enum E_PortType {104 E_Audio,105 E_Midi,106 E_Control,107 };108 109 /*!110 \brief The port direction111 */112 enum E_Direction {113 E_Playback,114 E_Capture,115 };116 117 Port(std::string name, enum E_PortType porttype, enum E_Direction direction);118 119 virtual ~Port() 120 {};121 122 123 /// Enable the port. (this can be called anytime)124 void enable();125 /// Disable the port. (this can be called anytime)126 void disable();127 /// is the port disabled? (this can be called anytime)128 bool isDisabled() {return m_disabled;};129 130 /*!131 \brief Initialize the port132 */133 bool init();134 135 bool prepare() {return true;};136 bool reset();137 138 std::string getName() {return m_Name;};139 bool setName(std::string name);140 141 /**142 * \brief returns the size of the events in the port buffer, in bytes143 *144 */145 unsigned int getEventSize();146 147 /**148 * \brief sets the event type for the port buffer149 *150 * \note use before calling init()151 */152 virtual bool setDataType(enum E_DataType);153 154 enum E_DataType getDataType() {return m_DataType;};155 156 /**157 * \brief sets the event type for the port buffer158 *159 * \note use before calling init()160 */161 virtual bool setSignalType(enum E_SignalType );162 163 enum E_SignalType getSignalType() {return m_SignalType;}; ///< returns the signalling type of the port164 165 /**166 * \brief sets the buffer type for the port167 *168 * \note use before calling init()169 */170 virtual bool setBufferType(enum E_BufferType );171 172 enum E_BufferType getBufferType() {return m_BufferType;}; ///< returns the buffer type of the port173 174 enum E_PortType getPortType() {return m_PortType;}; ///< returns the port type (is fixed)175 enum E_Direction getDirection() {return m_Direction;}; ///< returns the direction (is fixed)176 177 /**178 * \brief returns the size of the port buffer179 *180 * counted in number of E_DataType units (events), not in bytes181 *182 */183 unsigned int getBufferSize() {return m_buffersize;};184 185 /**186 * \brief sets the size of the port buffer187 *188 * counted in number of E_DataType units, not in bytes189 *190 * if there is an external buffer assigned, it should191 * be large enough192 * if there is an internal buffer, it will be resized193 *194 * \note use before calling init()195 */196 virtual bool setBufferSize(unsigned int);197 198 /**199 * \brief use an external buffer (or not)200 *201 * \note use before calling init()202 */203 virtual bool useExternalBuffer(bool b);204 205 void setExternalBufferAddress(void *buff);206 207 208 /**209 * \brief enable/disable ratecontrol210 *211 * Rate control is nescessary for some types of ports (most notably 212 * midi). The StreamProcessor that handles the port should call canRead()213 * everytime a 'slot' that could be filled with an event passes. The canRead 214 * function will return true if 215 * (1) there is an event ready in the buffer216 * (2) we are allowed to send an event in this slot217 *218 * Setting the rate works is done with the slot_interval and the event_interval219 * parameters. On every call to canRead(), a counter is decremented with 220 * slot_interval. If the counter drops below 0, canRead() returns true and resets221 * the counter to event_interval.222 *223 * e.g. for AMDTP midi, we are only allowed to send a midi byte every 320us224 * if the SYT interval is 8, there is exactly one midi slot every packet.225 * therefore the slot_interval is 1/8000s (=125us), and the event_interval 226 * is 320us.227 * 228 * Note that the interval parameters are unitless, so you can adapt them229 * to your needs. In the AMDTP case for example, when the SYT interval is 32230 * (when the samplerate is 192kHz for example) there are 4 midi slots in231 * each packet, making the slot time interval 125us/4 = 31.25us. 232 * The event time interval stays the same (320us). We can however set the233 *slot_interval to 3125 and the event_interval to 32000, as we can choose234 *the unit of the counter time step (chosen to be 10ns in this case).235 *236 * The average argument deserves some attention too. If average is true, we use237 * average rate control. This means that on average there will be a delay of238 * event_interval between two events, but that sometimes there can be a smaller239 * delay. This mode fixes the average rate of the stream.240 * If average is false, there will always be a minimal delay of event_interval241 * between two events. This means that the maximum rate of the stream is fixed,242 * and that the average rate will be lower than (or at max equal to) the rate in 243 * average mode.244 *245 *246 * \note only works for the E_RingBuffer ports247 * \note use before calling init()248 *249 * @param use set this to true to use rate control250 * @param slot_interval the interval between slots251 * @param event_interval the interval between events252 * @param average use average rate control253 * @return true if rate control was enabled/disabled successfully254 */255 virtual bool useRateControl(bool use, unsigned int slot_interval, 256 unsigned int event_interval, bool average);257 258 bool usingRateControl() { return m_do_ratecontrol;}; ///< are we using rate control?259 260 /**261 * Can we send an event in this slot. subject to rate control and 262 * byte availability.263 * @return true if we can send an event on this slot264 */265 bool canRead();266 267 // FIXME: this is not really OO, but for performance???268 void *getBufferAddress();269 270 // TODO: extend this with a blocking interface271 bool writeEvent(void *event); ///< write one event272 bool readEvent(void *event); ///< read one event273 int writeEvents(void *event, unsigned int nevents); ///< write multiple events274 int readEvents(void *event, unsigned int nevents); ///< read multiple events275 276 virtual void setVerboseLevel(int l);59 friend class PortManager; 60 61 /* 62 * IMPORTANT: if you add something to any of these enum's, be sure to 63 * check the code where they are used. 64 */ 65 66 /*! 67 \brief Specifies the buffer type for ports 68 69 A PointerBuffer uses the getBufferAddress() and setBufferAddres() interface 70 A Ringbuffer uses the read/write interface 71 */ 72 enum E_BufferType { 73 E_PointerBuffer, 74 E_RingBuffer 75 }; 76 77 /*! 78 \brief Specifies the signalling type for ports 79 */ 80 enum E_SignalType { 81 E_PacketSignalled, ///< the port is to be processed for every packet 82 E_PeriodSignalled, ///< the port is to be processed after a period of frames 83 // E_SampleSignalled ///< the port is to be processed after each frame (sample) 84 }; 85 86 /*! 87 \brief The datatype of the port buffer 88 */ 89 enum E_DataType { 90 E_Float, 91 E_Int24, 92 E_MidiEvent, 93 E_Default, 94 }; 95 96 /*! 97 \brief The port type 98 */ 99 enum E_PortType { 100 E_Audio, 101 E_Midi, 102 E_Control, 103 }; 104 105 /*! 106 \brief The port direction 107 */ 108 enum E_Direction { 109 E_Playback, 110 E_Capture, 111 }; 112 113 Port(std::string name, enum E_PortType porttype, enum E_Direction direction); 114 115 virtual ~Port() 116 {}; 117 118 119 /// Enable the port. (this can be called anytime) 120 void enable(); 121 /// Disable the port. (this can be called anytime) 122 void disable(); 123 /// is the port disabled? (this can be called anytime) 124 bool isDisabled() {return m_disabled;}; 125 126 /*! 127 \brief Initialize the port 128 */ 129 bool init(); 130 131 bool prepare() {return true;}; 132 bool reset(); 133 134 std::string getName() {return m_Name;}; 135 bool setName(std::string name); 136 137 /** 138 * \brief returns the size of the events in the port buffer, in bytes 139 * 140 */ 141 unsigned int getEventSize(); 142 143 /** 144 * \brief sets the event type for the port buffer 145 * 146 * \note use before calling init() 147 */ 148 virtual bool setDataType(enum E_DataType); 149 150 enum E_DataType getDataType() {return m_DataType;}; 151 152 /** 153 * \brief sets the event type for the port buffer 154 * 155 * \note use before calling init() 156 */ 157 virtual bool setSignalType(enum E_SignalType ); 158 159 enum E_SignalType getSignalType() {return m_SignalType;}; ///< returns the signalling type of the port 160 161 /** 162 * \brief sets the buffer type for the port 163 * 164 * \note use before calling init() 165 */ 166 virtual bool setBufferType(enum E_BufferType ); 167 168 enum E_BufferType getBufferType() {return m_BufferType;}; ///< returns the buffer type of the port 169 170 enum E_PortType getPortType() {return m_PortType;}; ///< returns the port type (is fixed) 171 enum E_Direction getDirection() {return m_Direction;}; ///< returns the direction (is fixed) 172 173 /** 174 * \brief returns the size of the port buffer 175 * 176 * counted in number of E_DataType units (events), not in bytes 177 * 178 */ 179 unsigned int getBufferSize() {return m_buffersize;}; 180 181 /** 182 * \brief sets the size of the port buffer 183 * 184 * counted in number of E_DataType units, not in bytes 185 * 186 * if there is an external buffer assigned, it should 187 * be large enough 188 * if there is an internal buffer, it will be resized 189 * 190 * \note use before calling init() 191 */ 192 virtual bool setBufferSize(unsigned int); 193 194 /** 195 * \brief use an external buffer (or not) 196 * 197 * \note use before calling init() 198 */ 199 virtual bool useExternalBuffer(bool b); 200 201 void setExternalBufferAddress(void *buff); 202 203 204 /** 205 * \brief enable/disable ratecontrol 206 * 207 * Rate control is nescessary for some types of ports (most notably 208 * midi). The StreamProcessor that handles the port should call canRead() 209 * everytime a 'slot' that could be filled with an event passes. The canRead 210 * function will return true if 211 * (1) there is an event ready in the buffer 212 * (2) we are allowed to send an event in this slot 213 * 214 * Setting the rate works is done with the slot_interval and the event_interval 215 * parameters. On every call to canRead(), a counter is decremented with 216 * slot_interval. If the counter drops below 0, canRead() returns true and resets 217 * the counter to event_interval. 218 * 219 * e.g. for AMDTP midi, we are only allowed to send a midi byte every 320us 220 * if the SYT interval is 8, there is exactly one midi slot every packet. 221 * therefore the slot_interval is 1/8000s (=125us), and the event_interval 222 * is 320us. 223 * 224 * Note that the interval parameters are unitless, so you can adapt them 225 * to your needs. In the AMDTP case for example, when the SYT interval is 32 226 * (when the samplerate is 192kHz for example) there are 4 midi slots in 227 * each packet, making the slot time interval 125us/4 = 31.25us. 228 * The event time interval stays the same (320us). We can however set the 229 * slot_interval to 3125 and the event_interval to 32000, as we can choose 230 * the unit of the counter time step (chosen to be 10ns in this case). 231 * 232 * The average argument deserves some attention too. If average is true, we use 233 * average rate control. This means that on average there will be a delay of 234 * event_interval between two events, but that sometimes there can be a smaller 235 * delay. This mode fixes the average rate of the stream. 236 * If average is false, there will always be a minimal delay of event_interval 237 * between two events. This means that the maximum rate of the stream is fixed, 238 * and that the average rate will be lower than (or at max equal to) the rate in 239 * average mode. 240 * 241 * 242 * \note only works for the E_RingBuffer ports 243 * \note use before calling init() 244 * 245 * @param use set this to true to use rate control 246 * @param slot_interval the interval between slots 247 * @param event_interval the interval between events 248 * @param average use average rate control 249 * @return true if rate control was enabled/disabled successfully 250 */ 251 virtual bool useRateControl(bool use, unsigned int slot_interval, 252 unsigned int event_interval, bool average); 253 254 bool usingRateControl() { return m_do_ratecontrol;}; ///< are we using rate control? 255 256 /** 257 * Can we send an event in this slot. subject to rate control and 258 * byte availability. 259 * @return true if we can send an event on this slot 260 */ 261 bool canRead(); 262 263 // FIXME: this is not really OO, but for performance??? 264 void *getBufferAddress(); 265 266 // TODO: extend this with a blocking interface 267 bool writeEvent(void *event); ///< write one event 268 bool readEvent(void *event); ///< read one event 269 int writeEvents(void *event, unsigned int nevents); ///< write multiple events 270 int readEvents(void *event, unsigned int nevents); ///< read multiple events 271 272 virtual void setVerboseLevel(int l); 277 273 278 274 protected: 279 std::string m_Name; ///< Port name, [at construction]280 281 enum E_SignalType m_SignalType; ///< Signalling type, [at construction]282 enum E_BufferType m_BufferType; ///< Buffer type, [at construction]283 284 bool m_disabled; ///< is the port disabled?, [anytime]285 bool m_initialized; ///< is the port initialized? [after init()]286 287 unsigned int m_buffersize; 288 unsigned int m_eventsize; 289 290 enum E_DataType m_DataType;291 enum E_PortType m_PortType;292 enum E_Direction m_Direction;293 294 void *m_buffer;295 freebob_ringbuffer_t *m_ringbuffer;296 bool m_use_external_buffer;297 298 bool m_do_ratecontrol;299 int m_event_interval;300 int m_slot_interval;301 int m_rate_counter;302 int m_rate_counter_minimum;303 bool m_average_ratecontrol;304 305 bool allocateInternalBuffer();306 void freeInternalBuffer();307 308 bool allocateInternalRingBuffer();309 void freeInternalRingBuffer();275 std::string m_Name; ///< Port name, [at construction] 276 277 enum E_SignalType m_SignalType; ///< Signalling type, [at construction] 278 enum E_BufferType m_BufferType; ///< Buffer type, [at construction] 279 280 bool m_disabled; ///< is the port disabled?, [anytime] 281 bool m_initialized; ///< is the port initialized? [after init()] 282 283 unsigned int m_buffersize; 284 unsigned int m_eventsize; 285 286 enum E_DataType m_DataType; 287 enum E_PortType m_PortType; 288 enum E_Direction m_Direction; 289 290 void *m_buffer; 291 ffado_ringbuffer_t *m_ringbuffer; 292 bool m_use_external_buffer; 293 294 bool m_do_ratecontrol; 295 int m_event_interval; 296 int m_slot_interval; 297 int m_rate_counter; 298 int m_rate_counter_minimum; 299 bool m_average_ratecontrol; 300 301 bool allocateInternalBuffer(); 302 void freeInternalBuffer(); 303 304 bool allocateInternalRingBuffer(); 305 void freeInternalRingBuffer(); 310 306 311 307 DECLARE_DEBUG_MODULE; … … 322 318 public: 323 319 324 AudioPort(std::string name, enum E_Direction direction) 325 : Port(name, E_Audio, direction)326 {};327 328 virtual ~AudioPort() {};320 AudioPort(std::string name, enum E_Direction direction) 321 : Port(name, E_Audio, direction) 322 {}; 323 324 virtual ~AudioPort() {}; 329 325 330 326 protected: 331 327 332 328 333 329 }; 334 330 … … 342 338 public: 343 339 344 MidiPort(std::string name, enum E_Direction direction) 345 : Port(name, E_Midi, direction)346 {};347 virtual ~MidiPort() {};340 MidiPort(std::string name, enum E_Direction direction) 341 : Port(name, E_Midi, direction) 342 {}; 343 virtual ~MidiPort() {}; 348 344 349 345 … … 362 358 public: 363 359 364 ControlPort(std::string name, enum E_Direction direction) 365 : Port(name, E_Control, direction)366 {};367 virtual ~ControlPort() {};360 ControlPort(std::string name, enum E_Direction direction) 361 : Port(name, E_Control, direction) 362 {}; 363 virtual ~ControlPort() {}; 368 364 369 365 … … 375 371 } 376 372 377 #endif /* __F REEBOB_PORT__ */378 379 373 #endif /* __FFADO_PORT__ */ 374 375 trunk/libffado/src/libstreaming/PortManager.cpp
r419 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob porting API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 2 * Copyright (C) 2005-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 27 22 */ 28 23 … … 41 36 42 37 PortManager::~PortManager() { 43 // deleteAllPorts();38 // deleteAllPorts(); 44 39 } 45 40 46 41 // bool PortManager::setPortBuffersize(unsigned int newsize) { 47 // debugOutput( DEBUG_LEVEL_VERBOSE, "setting port buffer size to %d\n",newsize);48 // 49 // 50 // for ( PortVectorIterator it = m_Ports.begin();51 // it != m_Ports.end();52 // ++it )53 // {54 // if(!(*it)->setBufferSize(newsize)) {55 // debugFatal("Could not set buffer size for port %s\n",(*it)->getName().c_str());56 // return false;57 // }58 // }59 // 60 // return true; //not found61 // 42 // debugOutput( DEBUG_LEVEL_VERBOSE, "setting port buffer size to %d\n",newsize); 43 // 44 // 45 // for ( PortVectorIterator it = m_Ports.begin(); 46 // it != m_Ports.end(); 47 // ++it ) 48 // { 49 // if(!(*it)->setBufferSize(newsize)) { 50 // debugFatal("Could not set buffer size for port %s\n",(*it)->getName().c_str()); 51 // return false; 52 // } 53 // } 54 // 55 // return true; //not found 56 // 62 57 // } 63 58 64 59 /** 65 * 66 * @param port 67 * @return 60 * 61 * @param port 62 * @return 68 63 */ 69 64 bool PortManager::addPort(Port *port) 70 65 { 71 assert(port);72 73 debugOutput( DEBUG_LEVEL_VERBOSE, "Adding port %s\n",port->getName().c_str());74 m_Ports.push_back(port);75 76 return true;66 assert(port); 67 68 debugOutput( DEBUG_LEVEL_VERBOSE, "Adding port %s\n",port->getName().c_str()); 69 m_Ports.push_back(port); 70 71 return true; 77 72 } 78 73 79 74 bool PortManager::deletePort(Port *port) 80 75 { 81 assert(port);82 debugOutput( DEBUG_LEVEL_VERBOSE, "deleting port %s\n",port->getName().c_str());83 84 for ( PortVectorIterator it = m_Ports.begin();85 it != m_Ports.end();86 ++it )87 {88 if(*it == port) {89 m_Ports.erase(it);90 // delete *it;91 return true;92 }93 }94 95 debugOutput( DEBUG_LEVEL_VERBOSE, "port %s not found \n",port->getName().c_str());96 97 return false; //not found76 assert(port); 77 debugOutput( DEBUG_LEVEL_VERBOSE, "deleting port %s\n",port->getName().c_str()); 78 79 for ( PortVectorIterator it = m_Ports.begin(); 80 it != m_Ports.end(); 81 ++it ) 82 { 83 if(*it == port) { 84 m_Ports.erase(it); 85 // delete *it; 86 return true; 87 } 88 } 89 90 debugOutput( DEBUG_LEVEL_VERBOSE, "port %s not found \n",port->getName().c_str()); 91 92 return false; //not found 98 93 99 94 } … … 101 96 void PortManager::deleteAllPorts() 102 97 { 103 debugOutput( DEBUG_LEVEL_VERBOSE, "deleting all ports\n");104 105 for ( PortVectorIterator it = m_Ports.begin();106 it != m_Ports.end();107 ++it )108 {109 m_Ports.erase(it);110 // delete *it;111 }112 113 return;98 debugOutput( DEBUG_LEVEL_VERBOSE, "deleting all ports\n"); 99 100 for ( PortVectorIterator it = m_Ports.begin(); 101 it != m_Ports.end(); 102 ++it ) 103 { 104 m_Ports.erase(it); 105 // delete *it; 106 } 107 108 return; 114 109 115 110 } 116 111 117 112 int PortManager::getPortCount(enum Port::E_PortType type) { 118 int count=0;119 120 for ( PortVectorIterator it = m_Ports.begin();121 it != m_Ports.end();122 ++it )123 {124 if ( (*it)->getPortType() == type ) { 125 count++;126 }127 }128 return count;113 int count=0; 114 115 for ( PortVectorIterator it = m_Ports.begin(); 116 it != m_Ports.end(); 117 ++it ) 118 { 119 if ( (*it)->getPortType() == type ) { 120 count++; 121 } 122 } 123 return count; 129 124 } 130 125 131 126 int PortManager::getPortCount() { 132 int count=0;133 134 count+=m_Ports.size();135 136 return count;127 int count=0; 128 129 count+=m_Ports.size(); 130 131 return count; 137 132 } 138 133 139 134 Port * PortManager::getPortAtIdx(unsigned int index) { 140 135 141 return m_Ports.at(index);136 return m_Ports.at(index); 142 137 143 138 } … … 145 140 void PortManager::setVerboseLevel(int i) { 146 141 147 setDebugLevel(i);148 149 for ( PortVectorIterator it = m_Ports.begin();150 it != m_Ports.end();151 ++it )152 {153 (*it)->setVerboseLevel(i);154 }142 setDebugLevel(i); 143 144 for ( PortVectorIterator it = m_Ports.begin(); 145 it != m_Ports.end(); 146 ++it ) 147 { 148 (*it)->setVerboseLevel(i); 149 } 155 150 156 151 } … … 158 153 159 154 bool PortManager::resetPorts() { 160 debugOutput( DEBUG_LEVEL_VERBOSE, "reset ports\n");161 162 for ( PortVectorIterator it = m_Ports.begin();163 it != m_Ports.end();164 ++it )165 {166 if(!(*it)->reset()) {167 debugFatal("Could not reset port %s",(*it)->getName().c_str());168 return false;169 }170 }171 return true;155 debugOutput( DEBUG_LEVEL_VERBOSE, "reset ports\n"); 156 157 for ( PortVectorIterator it = m_Ports.begin(); 158 it != m_Ports.end(); 159 ++it ) 160 { 161 if(!(*it)->reset()) { 162 debugFatal("Could not reset port %s",(*it)->getName().c_str()); 163 return false; 164 } 165 } 166 return true; 172 167 } 173 168 174 169 bool PortManager::initPorts() { 175 debugOutput( DEBUG_LEVEL_VERBOSE, "init ports\n");176 177 for ( PortVectorIterator it = m_Ports.begin();178 it != m_Ports.end();179 ++it )180 {181 if(!(*it)->init()) {182 debugFatal("Could not init port %s",(*it)->getName().c_str());183 return false;184 }185 }186 return true;170 debugOutput( DEBUG_LEVEL_VERBOSE, "init ports\n"); 171 172 for ( PortVectorIterator it = m_Ports.begin(); 173 it != m_Ports.end(); 174 ++it ) 175 { 176 if(!(*it)->init()) { 177 debugFatal("Could not init port %s",(*it)->getName().c_str()); 178 return false; 179 } 180 } 181 return true; 187 182 } 188 183 189 184 bool PortManager::preparePorts() { 190 debugOutput( DEBUG_LEVEL_VERBOSE, "preparing ports\n");191 192 // clear the cache lists193 m_PeriodPorts.clear();194 m_PacketPorts.clear();195 196 for ( PortVectorIterator it = m_Ports.begin();197 it != m_Ports.end();198 ++it )199 {200 if(!(*it)->prepare()) {201 debugFatal("Could not prepare port %s",(*it)->getName().c_str());202 return false;203 }204 205 // now prepare the cache lists206 switch((*it)->getSignalType()) {207 case Port::E_PacketSignalled:208 m_PacketPorts.push_back(*it);209 break;210 case Port::E_PeriodSignalled:211 m_PeriodPorts.push_back(*it);212 break;213 default:214 debugWarning("%s has unsupported port type\n",215 (*it)->getName().c_str()); 216 break;217 }218 }219 220 221 222 return true;223 } 224 225 } 185 debugOutput( DEBUG_LEVEL_VERBOSE, "preparing ports\n"); 186 187 // clear the cache lists 188 m_PeriodPorts.clear(); 189 m_PacketPorts.clear(); 190 191 for ( PortVectorIterator it = m_Ports.begin(); 192 it != m_Ports.end(); 193 ++it ) 194 { 195 if(!(*it)->prepare()) { 196 debugFatal("Could not prepare port %s",(*it)->getName().c_str()); 197 return false; 198 } 199 200 // now prepare the cache lists 201 switch((*it)->getSignalType()) { 202 case Port::E_PacketSignalled: 203 m_PacketPorts.push_back(*it); 204 break; 205 case Port::E_PeriodSignalled: 206 m_PeriodPorts.push_back(*it); 207 break; 208 default: 209 debugWarning("%s has unsupported port type\n", 210 (*it)->getName().c_str()); 211 break; 212 } 213 } 214 215 216 217 return true; 218 } 219 220 } trunk/libffado/src/libstreaming/PortManager.h
r419 r445 1 /* $Id$ */ 1 /* 2 * Copyright (C) 2005-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 */ 2 23 3 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 27 */ 28 #ifndef __FREEBOB_PORTMANAGER__ 29 #define __FREEBOB_PORTMANAGER__ 24 #ifndef __FFADO_PORTMANAGER__ 25 #define __FFADO_PORTMANAGER__ 30 26 31 27 #include "../debugmodule/debugmodule.h" … … 43 39 44 40 Contains helper classes that allow the easy maintaining of Port collections. 45 41 46 42 */ 47 43 class PortManager { … … 49 45 public: 50 46 51 PortManager();52 virtual ~PortManager();47 PortManager(); 48 virtual ~PortManager(); 53 49 54 virtual bool addPort(Port *port);55 virtual bool deletePort(Port *port);56 virtual void deleteAllPorts();50 virtual bool addPort(Port *port); 51 virtual bool deletePort(Port *port); 52 virtual void deleteAllPorts(); 57 53 58 int getPortCount(enum Port::E_PortType);59 int getPortCount();54 int getPortCount(enum Port::E_PortType); 55 int getPortCount(); 60 56 61 // virtual bool setPortBuffersize(unsigned int newsize);57 // virtual bool setPortBuffersize(unsigned int newsize); 62 58 63 Port *getPortAtIdx(unsigned int index);59 Port *getPortAtIdx(unsigned int index); 64 60 65 virtual bool resetPorts();66 virtual bool initPorts(); 67 virtual bool preparePorts(); 61 virtual bool resetPorts(); 62 virtual bool initPorts(); 63 virtual bool preparePorts(); 68 64 69 virtual void setVerboseLevel(int l);65 virtual void setVerboseLevel(int l); 70 66 71 67 protected: 72 PortVector m_Ports;73 PortVector m_PacketPorts;74 PortVector m_PeriodPorts;75 // PortVector m_SamplePorts;68 PortVector m_Ports; 69 PortVector m_PacketPorts; 70 PortVector m_PeriodPorts; 71 // PortVector m_SamplePorts; 76 72 77 73 DECLARE_DEBUG_MODULE; … … 81 77 } 82 78 83 #endif /* __F REEBOB_PORTMANAGER__ */79 #endif /* __FFADO_PORTMANAGER__ */ 84 80 85 81 trunk/libffado/src/libstreaming/StreamProcessor.cpp
r428 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 2 * Copyright (C) 2005-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 27 22 */ 28 23 … … 41 36 IMPL_DEBUG_MODULE( TransmitStreamProcessor, TransmitStreamProcessor, DEBUG_LEVEL_VERBOSE ); 42 37 43 StreamProcessor::StreamProcessor(enum IsoStream::EStreamType type, int port, int framerate) 44 : IsoStream(type, port)45 , m_nb_buffers(0)46 , m_period(0)47 , m_xruns(0)48 , m_framerate(framerate)49 , m_manager(NULL)50 , m_running(false)51 , m_disabled(true)52 , m_is_disabled(true)53 , m_cycle_to_enable_at(0)54 , m_SyncSource(NULL)55 , m_ticks_per_frame(0)56 , m_last_cycle(0)57 , m_sync_delay(0)38 StreamProcessor::StreamProcessor(enum IsoStream::EStreamType type, int port, int framerate) 39 : IsoStream(type, port) 40 , m_nb_buffers(0) 41 , m_period(0) 42 , m_xruns(0) 43 , m_framerate(framerate) 44 , m_manager(NULL) 45 , m_running(false) 46 , m_disabled(true) 47 , m_is_disabled(true) 48 , m_cycle_to_enable_at(0) 49 , m_SyncSource(NULL) 50 , m_ticks_per_frame(0) 51 , m_last_cycle(0) 52 , m_sync_delay(0) 58 53 { 59 54 // create the timestamped buffer and register ourselves as its client … … 70 65 debugOutputShort( DEBUG_LEVEL_NORMAL, " StreamProcessor information\n"); 71 66 debugOutputShort( DEBUG_LEVEL_NORMAL, " Iso stream info:\n"); 72 67 73 68 IsoStream::dumpInfo(); 74 69 debugOutputShort( DEBUG_LEVEL_NORMAL, " StreamProcessor info:\n"); … … 79 74 debugOutputShort( DEBUG_LEVEL_NORMAL, " Enabled : %s\n", m_disabled ? "No" : "Yes"); 80 75 debugOutputShort( DEBUG_LEVEL_NORMAL, " enable status : %s\n", m_is_disabled ? "No" : "Yes"); 81 82 debugOutputShort( DEBUG_LEVEL_NORMAL, " Device framerate : Sync: %f, Buffer %f\n", 76 77 debugOutputShort( DEBUG_LEVEL_NORMAL, " Device framerate : Sync: %f, Buffer %f\n", 83 78 24576000.0/m_SyncSource->m_data_buffer->getRate(), 84 79 24576000.0/m_data_buffer->getRate() 85 80 ); 86 81 87 82 m_data_buffer->dumpInfo(); 88 83 89 84 // m_PeriodStat.dumpInfo(); 90 85 // m_PacketStat.dumpInfo(); … … 96 91 { 97 92 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "enter...\n"); 98 93 99 94 m_data_buffer->init(); 100 95 101 96 return IsoStream::init(); 102 97 } … … 115 110 return false; 116 111 } 117 112 118 113 resetXrunCounter(); 119 114 … … 130 125 } 131 126 return true; 132 127 133 128 } 134 129 … … 150 145 bool StreamProcessor::prepare() { 151 146 152 debugOutput( DEBUG_LEVEL_VERBOSE, "Preparing...\n");153 154 // init the ports155 156 if(!m_manager) {157 debugFatal("Not attached to a manager!\n");158 return -1;159 }160 161 m_nb_buffers=m_manager->getNbBuffers();162 debugOutput( DEBUG_LEVEL_VERBOSE, "Setting m_nb_buffers : %d\n", m_nb_buffers);163 164 m_period=m_manager->getPeriodSize();165 debugOutput( DEBUG_LEVEL_VERBOSE, "Setting m_period : %d\n", m_period);166 167 // loop over the ports to reset them168 PortManager::preparePorts();169 170 // reset the iso stream171 IsoStream::prepare();172 173 return true;147 debugOutput( DEBUG_LEVEL_VERBOSE, "Preparing...\n"); 148 149 // init the ports 150 151 if(!m_manager) { 152 debugFatal("Not attached to a manager!\n"); 153 return -1; 154 } 155 156 m_nb_buffers=m_manager->getNbBuffers(); 157 debugOutput( DEBUG_LEVEL_VERBOSE, "Setting m_nb_buffers : %d\n", m_nb_buffers); 158 159 m_period=m_manager->getPeriodSize(); 160 debugOutput( DEBUG_LEVEL_VERBOSE, "Setting m_period : %d\n", m_period); 161 162 // loop over the ports to reset them 163 PortManager::preparePorts(); 164 165 // reset the iso stream 166 IsoStream::prepare(); 167 168 return true; 174 169 175 170 } … … 192 187 // FIXME: time_to_enable_at will be in 'time' not cycles 193 188 m_cycle_to_enable_at=time_to_enable_at; 194 189 195 190 if(!m_running) { 196 191 debugWarning("The StreamProcessor is not running yet, enable() might not be a good idea.\n"); … … 200 195 uint64_t now_cycles=CYCLE_TIMER_GET_CYCLES(m_handler->getCycleTimer()); 201 196 const int64_t max=(int64_t)(CYCLES_PER_SECOND/2); 202 197 203 198 int64_t diff=(int64_t)m_cycle_to_enable_at-(int64_t)now_cycles; 204 199 205 200 if (diff > max) { 206 201 diff-=TICKS_PER_SECOND; … … 208 203 diff+=TICKS_PER_SECOND; 209 204 } 210 205 211 206 if (diff<0) { 212 207 debugWarning("Request to enable streamprocessor %lld cycles ago (now=%llu, cy=%llu).\n", … … 231 226 int64_t StreamProcessor::getTimeUntilNextPeriodSignalUsecs() { 232 227 uint64_t time_at_period=getTimeAtPeriod(); 233 228 234 229 // we delay the period signal with the sync delay 235 230 // this makes that the period signals lag a little compared to reality … … 243 238 244 239 uint64_t cycle_timer=m_handler->getCycleTimerTicks(); 245 240 246 241 // calculate the time until the next period 247 242 int32_t until_next=diffTicks(time_at_period,cycle_timer); 248 243 249 244 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "=> TAP=%11llu, CTR=%11llu, UTN=%11lld\n", 250 245 time_at_period, cycle_timer, until_next 251 246 ); 252 247 253 248 // now convert to usecs 254 249 // don't use the mapping function because it only works … … 267 262 */ 268 263 void StreamProcessor::resetXrunCounter() { 269 ZERO_ATOMIC((SInt32 *)&m_xruns);264 ZERO_ATOMIC((SInt32 *)&m_xruns); 270 265 } 271 266 272 267 void StreamProcessor::setVerboseLevel(int l) { 273 setDebugLevel(l);274 IsoStream::setVerboseLevel(l);275 PortManager::setVerboseLevel(l);276 277 } 278 279 ReceiveStreamProcessor::ReceiveStreamProcessor(int port, int framerate) 280 : StreamProcessor(IsoStream::EST_Receive, port, framerate) {268 setDebugLevel(l); 269 IsoStream::setVerboseLevel(l); 270 PortManager::setVerboseLevel(l); 271 272 } 273 274 ReceiveStreamProcessor::ReceiveStreamProcessor(int port, int framerate) 275 : StreamProcessor(IsoStream::EST_Receive, port, framerate) { 281 276 282 277 } … … 287 282 288 283 void ReceiveStreamProcessor::setVerboseLevel(int l) { 289 setDebugLevel(l);290 StreamProcessor::setVerboseLevel(l);284 setDebugLevel(l); 285 StreamProcessor::setVerboseLevel(l); 291 286 292 287 } … … 294 289 uint64_t ReceiveStreamProcessor::getTimeAtPeriod() { 295 290 uint64_t next_period_boundary=m_data_buffer->getTimestampFromHead(m_period); 296 291 297 292 #ifdef DEBUG 298 293 uint64_t ts,fc; 299 294 m_data_buffer->getBufferTailTimestamp(&ts,&fc); 300 295 301 296 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "=> NPD=%11lld, LTS=%11llu, FC=%5u, TPF=%f\n", 302 297 next_period_boundary, ts, fc, m_ticks_per_frame 303 298 ); 304 299 #endif 305 300 306 301 return next_period_boundary; 307 302 } … … 311 306 } 312 307 313 TransmitStreamProcessor::TransmitStreamProcessor( int port, int framerate) 314 : StreamProcessor(IsoStream::EST_Transmit, port, framerate) {308 TransmitStreamProcessor::TransmitStreamProcessor( int port, int framerate) 309 : StreamProcessor(IsoStream::EST_Transmit, port, framerate) { 315 310 316 311 } … … 321 316 322 317 void TransmitStreamProcessor::setVerboseLevel(int l) { 323 setDebugLevel(l);324 StreamProcessor::setVerboseLevel(l);318 setDebugLevel(l); 319 StreamProcessor::setVerboseLevel(l); 325 320 326 321 } … … 332 327 uint64_t ts,fc; 333 328 m_data_buffer->getBufferTailTimestamp(&ts,&fc); 334 329 335 330 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "=> NPD=%11lld, LTS=%11llu, FC=%5u, TPF=%f\n", 336 331 next_period_boundary, ts, fc, m_ticks_per_frame 337 332 ); 338 333 #endif 339 334 340 335 return next_period_boundary; 341 336 } trunk/libffado/src/libstreaming/StreamProcessor.h
r424 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 2 * Copyright (C) 2005-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 27 22 */ 28 #ifndef __FREEBOB_STREAMPROCESSOR__ 29 #define __FREEBOB_STREAMPROCESSOR__ 23 24 #ifndef __FFADO_STREAMPROCESSOR__ 25 #define __FFADO_STREAMPROCESSOR__ 30 26 31 27 #include "../debugmodule/debugmodule.h" … … 47 43 \brief Class providing a generic interface for Stream Processors 48 44 49 A stream processor multiplexes or demultiplexes an ISO stream into a 45 A stream processor multiplexes or demultiplexes an ISO stream into a 50 46 collection of ports. This class should be subclassed, and the relevant 51 47 functions should be overloaded. 52 48 53 49 */ 54 class StreamProcessor : public IsoStream, 55 public PortManager, 50 class StreamProcessor : public IsoStream, 51 public PortManager, 56 52 public Util::TimestampedBufferClient, 57 53 public Util::OptionContainer { … … 68 64 virtual ~StreamProcessor(); 69 65 70 virtual enum raw1394_iso_disposition 71 putPacket(unsigned char *data, unsigned int length, 72 unsigned char channel, unsigned char tag, unsigned char sy, 66 virtual enum raw1394_iso_disposition 67 putPacket(unsigned char *data, unsigned int length, 68 unsigned char channel, unsigned char tag, unsigned char sy, 73 69 unsigned int cycle, unsigned int dropped) = 0; 74 virtual enum raw1394_iso_disposition 70 virtual enum raw1394_iso_disposition 75 71 getPacket(unsigned char *data, unsigned int *length, 76 72 unsigned char *tag, unsigned char *sy, … … 80 76 81 77 bool xrunOccurred() { return (m_xruns>0);}; 82 78 83 79 // move to private? 84 80 void resetXrunCounter(); 85 81 86 82 bool isRunning(); ///< returns true if there is some stream data processed 87 83 88 84 virtual bool prepareForEnable(uint64_t time_to_enable_at); 89 85 virtual bool prepareForDisable(); 90 91 bool enable(uint64_t time_to_enable_at); ///< enable the stream processing 92 bool disable(); ///< disable the stream processing 86 87 bool enable(uint64_t time_to_enable_at); ///< enable the stream processing 88 bool disable(); ///< disable the stream processing 93 89 bool isEnabled() {return !m_is_disabled;}; 94 90 … … 116 112 void setManager(StreamProcessorManager *manager) {m_manager=manager;}; 117 113 void clearManager() {m_manager=0;}; 118 114 119 115 protected: 120 116 unsigned int m_nb_buffers; ///< cached from manager->getNbBuffers(), the number of periods to buffer … … 126 122 127 123 StreamProcessorManager *m_manager; 128 124 129 125 bool m_running; 130 126 bool m_disabled; 131 127 bool m_is_disabled; 132 128 unsigned int m_cycle_to_enable_at; 133 129 134 130 StreamStatistics m_PacketStat; 135 131 StreamStatistics m_PeriodStat; 136 132 137 133 StreamStatistics m_WakeupStat; 138 134 139 135 140 136 DECLARE_DEBUG_MODULE; 141 137 142 138 // frame counter & sync stuff 143 139 public: … … 145 141 * @brief Can this StreamProcessor handle a transfer of nframes frames? 146 142 * 147 * this function indicates if the streamprocessor can handle a transfer of 143 * this function indicates if the streamprocessor can handle a transfer of 148 144 * nframes frames. It is used to detect underruns-to-be. 149 145 * … … 153 149 */ 154 150 virtual bool canClientTransferFrames(unsigned int nframes) = 0; 155 151 156 152 /** 157 153 * \brief return the time until the next period boundary should be signaled (in microseconds) 158 154 * 159 * Return the time until the next period boundary signal. If this StreamProcessor 160 * is the current synchronization source, this function is called to 155 * Return the time until the next period boundary signal. If this StreamProcessor 156 * is the current synchronization source, this function is called to 161 157 * determine when a buffer transfer can be made. When this value is 162 158 * smaller than 0, a period boundary is assumed to be crossed, hence a … … 180 176 181 177 /** 182 * \brief return the time of the next period boundary (in internal units) 178 * \brief return the time of the next period boundary (in internal units) 183 179 * 184 180 * The same as getTimeUntilNextPeriodSignalUsecs() but in internal units. … … 189 185 190 186 uint64_t getTimeNow(); 191 192 187 188 193 189 /** 194 190 * Returns the sync delay. This is the time a syncsource … … 202 198 */ 203 199 void setSyncDelay(int d) {m_sync_delay=d;}; 204 200 205 201 /** 206 202 * Returns the minimal sync delay a SP needs … … 215 211 216 212 int getBufferFill(); 217 213 218 214 protected: 219 215 StreamProcessor *m_SyncSource; … … 233 229 234 230 public: 235 ReceiveStreamProcessor(int port, int framerate);236 237 virtual ~ReceiveStreamProcessor();238 239 240 virtual enum EProcessorType getType() {return E_Receive;};241 242 virtual enum raw1394_iso_disposition 243 getPacket(unsigned char *data, unsigned int *length,244 unsigned char *tag, unsigned char *sy,245 int cycle, unsigned int dropped, unsigned int max_length) 246 {return RAW1394_ISO_STOP;};231 ReceiveStreamProcessor(int port, int framerate); 232 233 virtual ~ReceiveStreamProcessor(); 234 235 236 virtual enum EProcessorType getType() {return E_Receive;}; 237 238 virtual enum raw1394_iso_disposition 239 getPacket(unsigned char *data, unsigned int *length, 240 unsigned char *tag, unsigned char *sy, 241 int cycle, unsigned int dropped, unsigned int max_length) 242 {return RAW1394_ISO_STOP;}; 247 243 virtual bool putFrames(unsigned int nbframes, int64_t ts) {return false;}; 248 249 virtual enum raw1394_iso_disposition putPacket(unsigned char *data, unsigned int length, 250 unsigned char channel, unsigned char tag, unsigned char sy, 251 unsigned int cycle, unsigned int dropped) = 0;252 virtual void setVerboseLevel(int l);244 245 virtual enum raw1394_iso_disposition putPacket(unsigned char *data, unsigned int length, 246 unsigned char channel, unsigned char tag, unsigned char sy, 247 unsigned int cycle, unsigned int dropped) = 0; 248 virtual void setVerboseLevel(int l); 253 249 254 250 uint64_t getTimeAtPeriod(); … … 269 265 270 266 public: 271 TransmitStreamProcessor(int port, int framerate);272 273 virtual ~TransmitStreamProcessor();274 275 virtual enum EProcessorType getType() {return E_Transmit;};276 277 virtual enum raw1394_iso_disposition 278 putPacket(unsigned char *data, unsigned int length, 279 unsigned char channel, unsigned char tag, unsigned char sy, 280 unsigned int cycle, unsigned int dropped) {return RAW1394_ISO_STOP;};267 TransmitStreamProcessor(int port, int framerate); 268 269 virtual ~TransmitStreamProcessor(); 270 271 virtual enum EProcessorType getType() {return E_Transmit;}; 272 273 virtual enum raw1394_iso_disposition 274 putPacket(unsigned char *data, unsigned int length, 275 unsigned char channel, unsigned char tag, unsigned char sy, 276 unsigned int cycle, unsigned int dropped) {return RAW1394_ISO_STOP;}; 281 277 virtual bool getFrames(unsigned int nbframes) {return false;}; 282 278 283 virtual enum raw1394_iso_disposition 284 getPacket(unsigned char *data, unsigned int *length,285 unsigned char *tag, unsigned char *sy,286 int cycle, unsigned int dropped, unsigned int max_length) = 0;287 virtual void setVerboseLevel(int l);279 virtual enum raw1394_iso_disposition 280 getPacket(unsigned char *data, unsigned int *length, 281 unsigned char *tag, unsigned char *sy, 282 int cycle, unsigned int dropped, unsigned int max_length) = 0; 283 virtual void setVerboseLevel(int l); 288 284 289 285 uint64_t getTimeAtPeriod(); … … 300 296 } 301 297 302 #endif /* __F REEBOB_STREAMPROCESSOR__ */303 304 298 #endif /* __FFADO_STREAMPROCESSOR__ */ 299 300 trunk/libffado/src/libstreaming/StreamProcessorManager.cpp
r435 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 2 * Copyright (C) 2005-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 27 22 */ 28 23 … … 60 55 61 56 StreamProcessorManager::~StreamProcessorManager() { 62 if (m_isoManager) delete m_isoManager;63 57 if (m_isoManager) delete m_isoManager; 58 64 59 } 65 60 … … 72 67 * and be sure that the processors are also ->init()'ed 73 68 * 74 * @param processor 69 * @param processor 75 70 * @return true if successfull 76 71 */ 77 72 bool StreamProcessorManager::registerProcessor(StreamProcessor *processor) 78 73 { 79 debugOutput( DEBUG_LEVEL_VERBOSE, "Registering processor (%p)\n",processor);80 assert(processor);81 assert(m_isoManager);82 83 if (processor->getType()==StreamProcessor::E_Receive) {84 processor->setVerboseLevel(getDebugLevel()); // inherit debug level85 86 m_ReceiveProcessors.push_back(processor);87 88 processor->setManager(this);89 90 return true;91 }92 93 if (processor->getType()==StreamProcessor::E_Transmit) {94 processor->setVerboseLevel(getDebugLevel()); // inherit debug level95 96 m_TransmitProcessors.push_back(processor);97 98 processor->setManager(this);99 100 return true;101 }102 103 debugFatal("Unsupported processor type!\n");104 105 return false;74 debugOutput( DEBUG_LEVEL_VERBOSE, "Registering processor (%p)\n",processor); 75 assert(processor); 76 assert(m_isoManager); 77 78 if (processor->getType()==StreamProcessor::E_Receive) { 79 processor->setVerboseLevel(getDebugLevel()); // inherit debug level 80 81 m_ReceiveProcessors.push_back(processor); 82 83 processor->setManager(this); 84 85 return true; 86 } 87 88 if (processor->getType()==StreamProcessor::E_Transmit) { 89 processor->setVerboseLevel(getDebugLevel()); // inherit debug level 90 91 m_TransmitProcessors.push_back(processor); 92 93 processor->setManager(this); 94 95 return true; 96 } 97 98 debugFatal("Unsupported processor type!\n"); 99 100 return false; 106 101 } 107 102 108 103 bool StreamProcessorManager::unregisterProcessor(StreamProcessor *processor) 109 104 { 110 debugOutput( DEBUG_LEVEL_VERBOSE, "Unregistering processor (%p)\n",processor);111 assert(processor);112 113 if (processor->getType()==StreamProcessor::E_Receive) {114 115 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin();116 it != m_ReceiveProcessors.end();117 ++it ) {118 119 if ( *it == processor ) { 120 m_ReceiveProcessors.erase(it);121 122 processor->clearManager();123 124 if(!m_isoManager->unregisterStream(processor)) {125 debugOutput(DEBUG_LEVEL_VERBOSE,"Could not unregister receive stream processor from the Iso manager\n");126 127 return false;128 129 }130 131 return true;132 }133 }134 }135 136 if (processor->getType()==StreamProcessor::E_Transmit) {137 for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin();138 it != m_TransmitProcessors.end();139 ++it ) {140 141 if ( *it == processor ) { 142 m_TransmitProcessors.erase(it);143 144 processor->clearManager();145 146 if(!m_isoManager->unregisterStream(processor)) {147 debugOutput(DEBUG_LEVEL_VERBOSE,"Could not unregister transmit stream processor from the Iso manager\n");148 149 return false;150 151 }152 153 return true;154 }155 }156 }157 158 debugFatal("Processor (%p) not found!\n",processor);159 160 return false; //not found105 debugOutput( DEBUG_LEVEL_VERBOSE, "Unregistering processor (%p)\n",processor); 106 assert(processor); 107 108 if (processor->getType()==StreamProcessor::E_Receive) { 109 110 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 111 it != m_ReceiveProcessors.end(); 112 ++it ) { 113 114 if ( *it == processor ) { 115 m_ReceiveProcessors.erase(it); 116 117 processor->clearManager(); 118 119 if(!m_isoManager->unregisterStream(processor)) { 120 debugOutput(DEBUG_LEVEL_VERBOSE,"Could not unregister receive stream processor from the Iso manager\n"); 121 122 return false; 123 124 } 125 126 return true; 127 } 128 } 129 } 130 131 if (processor->getType()==StreamProcessor::E_Transmit) { 132 for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); 133 it != m_TransmitProcessors.end(); 134 ++it ) { 135 136 if ( *it == processor ) { 137 m_TransmitProcessors.erase(it); 138 139 processor->clearManager(); 140 141 if(!m_isoManager->unregisterStream(processor)) { 142 debugOutput(DEBUG_LEVEL_VERBOSE,"Could not unregister transmit stream processor from the Iso manager\n"); 143 144 return false; 145 146 } 147 148 return true; 149 } 150 } 151 } 152 153 debugFatal("Processor (%p) not found!\n",processor); 154 155 return false; //not found 161 156 162 157 } … … 175 170 bool StreamProcessorManager::init() 176 171 { 177 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n");178 179 m_isoManager=new IsoHandlerManager(m_thread_realtime, m_thread_priority);180 181 if(!m_isoManager) {182 debugFatal("Could not create IsoHandlerManager\n");183 return false;184 }185 186 // propagate the debug level187 m_isoManager->setVerboseLevel(getDebugLevel());188 189 if(!m_isoManager->init()) {190 debugFatal("Could not initialize IsoHandlerManager\n");191 return false;192 }193 194 m_xrun_happened=false;195 196 return true;172 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 173 174 m_isoManager=new IsoHandlerManager(m_thread_realtime, m_thread_priority); 175 176 if(!m_isoManager) { 177 debugFatal("Could not create IsoHandlerManager\n"); 178 return false; 179 } 180 181 // propagate the debug level 182 m_isoManager->setVerboseLevel(getDebugLevel()); 183 184 if(!m_isoManager->init()) { 185 debugFatal("Could not initialize IsoHandlerManager\n"); 186 return false; 187 } 188 189 m_xrun_happened=false; 190 191 return true; 197 192 } 198 193 199 194 bool StreamProcessorManager::prepare() { 200 195 201 debugOutput( DEBUG_LEVEL_VERBOSE, "Preparing...\n");202 196 debugOutput( DEBUG_LEVEL_VERBOSE, "Preparing...\n"); 197 203 198 m_is_slave=false; 204 199 if(!getOption("snoopMode", m_is_slave)) { … … 219 214 } 220 215 } 221 216 222 217 for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); 223 218 it != m_TransmitProcessors.end(); … … 234 229 it != m_ReceiveProcessors.end(); 235 230 ++it ) { 236 231 237 232 if(!(*it)->setSyncSource(m_SyncSource)) { 238 233 debugFatal( " could not set sync source (%p)...\n",(*it)); … … 267 262 } 268 263 269 // if there are no stream processors registered, 264 // if there are no stream processors registered, 270 265 // fail 271 266 if (m_ReceiveProcessors.size() + m_TransmitProcessors.size() == 0) { … … 274 269 } 275 270 276 return true;271 return true; 277 272 } 278 273 … … 287 282 wait_cycles--; 288 283 notRunning=false; 289 284 290 285 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 291 286 it != m_ReceiveProcessors.end(); … … 299 294 if(!(*it)->isRunning()) notRunning=true; 300 295 } 301 296 302 297 // EXPERIMENT: 303 298 // the only stream that should be running is the sync … … 305 300 // when to signal buffers. Maybe we get an xrun at startup, 306 301 // but that should be handled. 307 308 // the problem is that otherwise a setup with a device 309 // that waits for decent input before sending output 302 303 // the problem is that otherwise a setup with a device 304 // that waits for decent input before sending output 310 305 // will not start up (e.g. the bounce device), because 311 306 // all streams are required to be running. 312 313 // other streams still have at least ENABLE_DELAY_CYCLES cycles 307 308 // other streams still have at least ENABLE_DELAY_CYCLES cycles 314 309 // to start up 315 310 // if(!m_SyncSource->isRunning()) notRunning=true; 316 311 317 312 usleep(1000); 318 313 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "Running check: %d\n",notRunning); … … 327 322 if(!(*it)->isRunning()) { 328 323 debugFatal(" receive stream %p not running\n",*it); 329 } else { 324 } else { 330 325 debugFatal(" receive stream %p running\n",*it); 331 326 } … … 337 332 if(!(*it)->isRunning()) { 338 333 debugFatal(" transmit stream %p not running\n",*it); 339 } else { 334 } else { 340 335 debugFatal(" transmit stream %p running\n",*it); 341 336 } … … 344 339 } 345 340 346 // we want to make sure that everything is running well, 341 // we want to make sure that everything is running well, 347 342 // so wait for a while 348 343 usleep(USECS_PER_CYCLE * CYCLES_TO_SLEEP_AFTER_RUN_SIGNAL); 349 344 350 345 debugOutput( DEBUG_LEVEL_VERBOSE, " StreamProcessor streams running...\n"); 351 346 352 347 debugOutput( DEBUG_LEVEL_VERBOSE, "Finding minimal sync delay...\n"); 353 348 … … 360 355 if(min_delay>max_of_min_delay) max_of_min_delay=min_delay; 361 356 } 362 357 363 358 for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); 364 359 it != m_TransmitProcessors.end(); … … 367 362 if(min_delay>max_of_min_delay) max_of_min_delay=min_delay; 368 363 } 369 364 370 365 debugOutput( DEBUG_LEVEL_VERBOSE, " %d ticks\n", max_of_min_delay); 371 366 m_SyncSource->setSyncDelay(max_of_min_delay); 372 373 367 368 374 369 debugOutput( DEBUG_LEVEL_VERBOSE, "Resetting StreamProcessors...\n"); 375 370 // now we reset the frame counters … … 379 374 (*it)->reset(); 380 375 } 381 376 382 377 for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); 383 378 it != m_TransmitProcessors.end(); … … 385 380 (*it)->reset(); 386 381 } 387 382 388 383 debugOutput( DEBUG_LEVEL_VERBOSE, "Enabling StreamProcessors...\n"); 389 384 390 385 uint64_t now=m_SyncSource->getTimeNow(); // fixme: should be in usecs, not ticks 391 386 392 387 // FIXME: this should not be in cycles, but in 'time' 393 388 unsigned int enable_at=TICKS_TO_CYCLES(now)+ENABLE_DELAY_CYCLES; … … 403 398 404 399 bool StreamProcessorManager::start() { 405 debugOutput( DEBUG_LEVEL_VERBOSE, "Starting Processors...\n");406 assert(m_isoManager);407 408 debugOutput( DEBUG_LEVEL_VERBOSE, "Creating handlers for the StreamProcessors...\n");409 debugOutput( DEBUG_LEVEL_VERBOSE, " Receive processors...\n");410 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin();411 it != m_ReceiveProcessors.end();412 ++it ) {413 if (!(*it)->prepareForStart()) {414 debugOutput(DEBUG_LEVEL_VERBOSE,"Receive stream processor (%p) failed to prepare for start\n", *it);415 return false;416 }417 if (!m_isoManager->registerStream(*it)) {418 debugOutput(DEBUG_LEVEL_VERBOSE,"Could not register receive stream processor (%p) with the Iso manager\n",*it);419 return false;420 }421 }422 423 debugOutput( DEBUG_LEVEL_VERBOSE, " Transmit processors...\n");424 for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin();425 it != m_TransmitProcessors.end();426 ++it ) {427 if (!(*it)->prepareForStart()) {428 debugOutput(DEBUG_LEVEL_VERBOSE,"Transmit stream processor (%p) failed to prepare for start\n", *it);429 return false;430 }431 if (!m_isoManager->registerStream(*it)) {432 debugOutput(DEBUG_LEVEL_VERBOSE,"Could not register transmit stream processor (%p) with the Iso manager\n",*it);433 return false;434 }435 }436 437 debugOutput( DEBUG_LEVEL_VERBOSE, "Preparing IsoHandlerManager...\n");438 if (!m_isoManager->prepare()) {439 debugFatal("Could not prepare isoManager\n");440 return false;441 }442 443 debugOutput( DEBUG_LEVEL_VERBOSE, "Disabling StreamProcessors...\n");400 debugOutput( DEBUG_LEVEL_VERBOSE, "Starting Processors...\n"); 401 assert(m_isoManager); 402 403 debugOutput( DEBUG_LEVEL_VERBOSE, "Creating handlers for the StreamProcessors...\n"); 404 debugOutput( DEBUG_LEVEL_VERBOSE, " Receive processors...\n"); 405 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 406 it != m_ReceiveProcessors.end(); 407 ++it ) { 408 if (!(*it)->prepareForStart()) { 409 debugOutput(DEBUG_LEVEL_VERBOSE,"Receive stream processor (%p) failed to prepare for start\n", *it); 410 return false; 411 } 412 if (!m_isoManager->registerStream(*it)) { 413 debugOutput(DEBUG_LEVEL_VERBOSE,"Could not register receive stream processor (%p) with the Iso manager\n",*it); 414 return false; 415 } 416 } 417 418 debugOutput( DEBUG_LEVEL_VERBOSE, " Transmit processors...\n"); 419 for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); 420 it != m_TransmitProcessors.end(); 421 ++it ) { 422 if (!(*it)->prepareForStart()) { 423 debugOutput(DEBUG_LEVEL_VERBOSE,"Transmit stream processor (%p) failed to prepare for start\n", *it); 424 return false; 425 } 426 if (!m_isoManager->registerStream(*it)) { 427 debugOutput(DEBUG_LEVEL_VERBOSE,"Could not register transmit stream processor (%p) with the Iso manager\n",*it); 428 return false; 429 } 430 } 431 432 debugOutput( DEBUG_LEVEL_VERBOSE, "Preparing IsoHandlerManager...\n"); 433 if (!m_isoManager->prepare()) { 434 debugFatal("Could not prepare isoManager\n"); 435 return false; 436 } 437 438 debugOutput( DEBUG_LEVEL_VERBOSE, "Disabling StreamProcessors...\n"); 444 439 if (!disableStreamProcessors()) { 445 debugFatal("Could not disable StreamProcessors...\n");446 return false;447 }448 449 debugOutput( DEBUG_LEVEL_VERBOSE, "Starting IsoHandlers...\n");450 if (!m_isoManager->startHandlers(-1)) {451 debugFatal("Could not start handlers...\n");452 return false;453 }454 455 // start all SP's synchonized456 if (!syncStartAll()) {457 debugFatal("Could not syncStartAll...\n");458 return false;459 }460 461 // dump the iso stream information when in verbose mode462 if(getDebugLevel()>=DEBUG_LEVEL_VERBOSE) {463 m_isoManager->dumpInfo();464 }465 466 return true;467 440 debugFatal("Could not disable StreamProcessors...\n"); 441 return false; 442 } 443 444 debugOutput( DEBUG_LEVEL_VERBOSE, "Starting IsoHandlers...\n"); 445 if (!m_isoManager->startHandlers(-1)) { 446 debugFatal("Could not start handlers...\n"); 447 return false; 448 } 449 450 // start all SP's synchonized 451 if (!syncStartAll()) { 452 debugFatal("Could not syncStartAll...\n"); 453 return false; 454 } 455 456 // dump the iso stream information when in verbose mode 457 if(getDebugLevel()>=DEBUG_LEVEL_VERBOSE) { 458 m_isoManager->dumpInfo(); 459 } 460 461 return true; 462 468 463 } 469 464 470 465 bool StreamProcessorManager::stop() { 471 debugOutput( DEBUG_LEVEL_VERBOSE, "Stopping...\n");472 assert(m_isoManager);473 474 debugOutput( DEBUG_LEVEL_VERBOSE, "Waiting for all StreamProcessors to prepare to stop...\n");475 // Most stream processors can just stop without special treatment. However, some476 // (like the MOTU) need to do a few things before it's safe to turn off the iso477 // handling.478 int wait_cycles=PREPARE_TIMEOUT_MSEC; // two seconds ought to be sufficient479 bool allReady = false;480 while (!allReady && wait_cycles) {481 wait_cycles--;482 allReady = true;483 484 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin();485 it != m_ReceiveProcessors.end();486 ++it ) {487 if(!(*it)->prepareForStop()) allReady = false;488 }489 490 for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin();491 it != m_TransmitProcessors.end();492 ++it ) {493 if(!(*it)->prepareForStop()) allReady = false;494 }495 usleep(1000);496 }497 498 499 debugOutput( DEBUG_LEVEL_VERBOSE, "Stopping handlers...\n");500 if(!m_isoManager->stopHandlers()) {501 debugFatal("Could not stop ISO handlers\n");502 return false;503 }504 505 debugOutput( DEBUG_LEVEL_VERBOSE, "Unregistering processors from handlers...\n");466 debugOutput( DEBUG_LEVEL_VERBOSE, "Stopping...\n"); 467 assert(m_isoManager); 468 469 debugOutput( DEBUG_LEVEL_VERBOSE, "Waiting for all StreamProcessors to prepare to stop...\n"); 470 // Most stream processors can just stop without special treatment. However, some 471 // (like the MOTU) need to do a few things before it's safe to turn off the iso 472 // handling. 473 int wait_cycles=PREPARE_TIMEOUT_MSEC; // two seconds ought to be sufficient 474 bool allReady = false; 475 while (!allReady && wait_cycles) { 476 wait_cycles--; 477 allReady = true; 478 479 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 480 it != m_ReceiveProcessors.end(); 481 ++it ) { 482 if(!(*it)->prepareForStop()) allReady = false; 483 } 484 485 for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); 486 it != m_TransmitProcessors.end(); 487 ++it ) { 488 if(!(*it)->prepareForStop()) allReady = false; 489 } 490 usleep(1000); 491 } 492 493 494 debugOutput( DEBUG_LEVEL_VERBOSE, "Stopping handlers...\n"); 495 if(!m_isoManager->stopHandlers()) { 496 debugFatal("Could not stop ISO handlers\n"); 497 return false; 498 } 499 500 debugOutput( DEBUG_LEVEL_VERBOSE, "Unregistering processors from handlers...\n"); 506 501 // now unregister all streams from iso manager 507 debugOutput( DEBUG_LEVEL_VERBOSE, " Receive processors...\n");508 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin();509 it != m_ReceiveProcessors.end();510 ++it ) {511 if (!m_isoManager->unregisterStream(*it)) {512 debugOutput(DEBUG_LEVEL_VERBOSE,"Could not unregister receive stream processor (%p) from the Iso manager\n",*it);513 return false;514 }515 516 }517 518 debugOutput( DEBUG_LEVEL_VERBOSE, " Transmit processors...\n");519 for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin();520 it != m_TransmitProcessors.end();521 ++it ) {522 if (!m_isoManager->unregisterStream(*it)) {523 debugOutput(DEBUG_LEVEL_VERBOSE,"Could not unregister transmit stream processor (%p) from the Iso manager\n",*it);524 return false;525 }526 527 }528 529 return true;530 502 debugOutput( DEBUG_LEVEL_VERBOSE, " Receive processors...\n"); 503 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 504 it != m_ReceiveProcessors.end(); 505 ++it ) { 506 if (!m_isoManager->unregisterStream(*it)) { 507 debugOutput(DEBUG_LEVEL_VERBOSE,"Could not unregister receive stream processor (%p) from the Iso manager\n",*it); 508 return false; 509 } 510 511 } 512 513 debugOutput( DEBUG_LEVEL_VERBOSE, " Transmit processors...\n"); 514 for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); 515 it != m_TransmitProcessors.end(); 516 ++it ) { 517 if (!m_isoManager->unregisterStream(*it)) { 518 debugOutput(DEBUG_LEVEL_VERBOSE,"Could not unregister transmit stream processor (%p) from the Iso manager\n",*it); 519 return false; 520 } 521 522 } 523 524 return true; 525 531 526 } 532 527 … … 547 542 debugOutput( DEBUG_LEVEL_VERBOSE, " Enable...\n"); 548 543 m_SyncSource->enable(time_to_enable_at); 549 544 550 545 debugOutput( DEBUG_LEVEL_VERBOSE, " Other StreamProcessors...\n"); 551 546 552 547 // we prepare the streamprocessors for enable 553 548 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); … … 572 567 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 573 568 it != m_ReceiveProcessors.end(); 574 ++it ) { 569 ++it ) { 575 570 if(*it != m_SyncSource) { 576 571 debugOutput( DEBUG_LEVEL_VERBOSE, " Enable Receive SP (%p)...\n",*it); … … 597 592 wait_cycles--; 598 593 notEnabled=false; 599 594 600 595 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 601 596 it != m_ReceiveProcessors.end(); … … 611 606 usleep(1000); // one cycle 612 607 } 613 608 614 609 if(!wait_cycles) { // timout has occurred 615 610 debugFatal("One or more streams couldn't be enabled (timeout):\n"); 616 611 617 612 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 618 613 it != m_ReceiveProcessors.end(); … … 620 615 if(!(*it)->isEnabled()) { 621 616 debugFatal(" receive stream %p not enabled\n",*it); 622 } else { 617 } else { 623 618 debugFatal(" receive stream %p enabled\n",*it); 624 619 } 625 620 } 626 621 627 622 for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); 628 623 it != m_TransmitProcessors.end(); … … 630 625 if(!(*it)->isEnabled()) { 631 626 debugFatal(" transmit stream %p not enabled\n",*it); 632 } else { 627 } else { 633 628 debugFatal(" transmit stream %p enabled\n",*it); 634 629 } … … 636 631 return false; 637 632 } 638 633 639 634 debugOutput( DEBUG_LEVEL_VERBOSE, " => all StreamProcessors enabled...\n"); 640 635 … … 682 677 wait_cycles--; 683 678 enabled=false; 684 679 685 680 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 686 681 it != m_ReceiveProcessors.end(); … … 696 691 usleep(1000); // one cycle 697 692 } 698 693 699 694 if(!wait_cycles) { // timout has occurred 700 695 debugFatal("One or more streams couldn't be disabled (timeout):\n"); 701 696 702 697 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 703 698 it != m_ReceiveProcessors.end(); … … 705 700 if(!(*it)->isEnabled()) { 706 701 debugFatal(" receive stream %p not enabled\n",*it); 707 } else { 702 } else { 708 703 debugFatal(" receive stream %p enabled\n",*it); 709 704 } 710 705 } 711 706 712 707 for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); 713 708 it != m_TransmitProcessors.end(); … … 715 710 if(!(*it)->isEnabled()) { 716 711 debugFatal(" transmit stream %p not enabled\n",*it); 717 } else { 712 } else { 718 713 debugFatal(" transmit stream %p enabled\n",*it); 719 714 } … … 721 716 return false; 722 717 } 723 718 724 719 debugOutput( DEBUG_LEVEL_VERBOSE, " => all StreamProcessors disabled...\n"); 725 720 726 721 return true; 727 722 } … … 736 731 bool StreamProcessorManager::handleXrun() { 737 732 738 debugOutput( DEBUG_LEVEL_VERBOSE, "Handling Xrun ...\n");739 740 /* 741 * Reset means:742 * 1) Disabling the SP's, so that they don't process any packets743 * note: the isomanager does keep on delivering/requesting them744 * 2) Bringing all buffers & streamprocessors into a know state745 * - Clear all capture buffers746 * - Put nb_periods*period_size of null frames into the playback buffers747 * 3) Re-enable the SP's748 */749 debugOutput( DEBUG_LEVEL_VERBOSE, "Disabling StreamProcessors...\n");733 debugOutput( DEBUG_LEVEL_VERBOSE, "Handling Xrun ...\n"); 734 735 /* 736 * Reset means: 737 * 1) Disabling the SP's, so that they don't process any packets 738 * note: the isomanager does keep on delivering/requesting them 739 * 2) Bringing all buffers & streamprocessors into a know state 740 * - Clear all capture buffers 741 * - Put nb_periods*period_size of null frames into the playback buffers 742 * 3) Re-enable the SP's 743 */ 744 debugOutput( DEBUG_LEVEL_VERBOSE, "Disabling StreamProcessors...\n"); 750 745 if (!disableStreamProcessors()) { 751 debugFatal("Could not disable StreamProcessors...\n");752 return false;753 }754 755 debugOutput( DEBUG_LEVEL_VERBOSE, "Restarting StreamProcessors...\n");756 // start all SP's synchonized757 if (!syncStartAll()) {758 debugFatal("Could not syncStartAll...\n");759 return false;760 }761 762 debugOutput( DEBUG_LEVEL_VERBOSE, "Xrun handled...\n");763 764 return true;746 debugFatal("Could not disable StreamProcessors...\n"); 747 return false; 748 } 749 750 debugOutput( DEBUG_LEVEL_VERBOSE, "Restarting StreamProcessors...\n"); 751 // start all SP's synchonized 752 if (!syncStartAll()) { 753 debugFatal("Could not syncStartAll...\n"); 754 return false; 755 } 756 757 debugOutput( DEBUG_LEVEL_VERBOSE, "Xrun handled...\n"); 758 759 return true; 765 760 } 766 761 … … 769 764 * 770 765 * This function does not return until a full period of samples is (or should be) 771 * ready to be transferred. 766 * ready to be transferred. 772 767 * 773 768 * @return true if the period is ready, false if an xrun occurred … … 776 771 int time_till_next_period; 777 772 bool xrun_occurred=false; 778 773 779 774 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "enter...\n"); 780 775 781 776 assert(m_SyncSource); 782 777 783 778 time_till_next_period=m_SyncSource->getTimeUntilNextPeriodSignalUsecs(); 784 779 785 780 while(time_till_next_period > 0) { 786 781 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "waiting for %d usecs...\n", time_till_next_period); 787 782 788 783 // wait for the period 789 784 usleep(time_till_next_period); 790 785 791 786 // check for underruns on the ISO side, 792 787 // those should make us bail out of the wait loop … … 807 802 time_till_next_period=m_SyncSource->getTimeUntilNextPeriodSignalUsecs(); 808 803 } 809 804 810 805 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "delayed for %d usecs...\n", time_till_next_period); 811 812 // this is to notify the client of the delay 813 // that we introduced 806 807 // this is to notify the client of the delay 808 // that we introduced 814 809 m_delayed_usecs=time_till_next_period; 815 810 816 811 // we save the 'ideal' time of the transfer at this point, 817 // because we can have interleaved read - process - write 812 // because we can have interleaved read - process - write 818 813 // cycles making that we modify a receiving stream's buffer 819 814 // before we get to writing. … … 821 816 // and the receive processors should have done their transfer. 822 817 m_time_of_transfer=m_SyncSource->getTimeAtPeriod(); 823 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "transfer at %llu ticks...\n", 818 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "transfer at %llu ticks...\n", 824 819 m_time_of_transfer); 825 820 826 821 #ifdef DEBUG 827 822 int rcv_bf=0, xmt_bf=0; … … 836 831 xmt_bf = (*it)->getBufferFill(); 837 832 } 838 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "XF at %011llu ticks, RBF=%d, XBF=%d, SUM=%d...\n", 833 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "XF at %011llu ticks, RBF=%d, XBF=%d, SUM=%d...\n", 839 834 m_time_of_transfer,rcv_bf,xmt_bf,rcv_bf+xmt_bf); 840 835 841 836 #endif 842 837 843 838 xrun_occurred=false; 844 839 845 840 // check if xruns occurred on the Iso side. 846 841 // also check if xruns will occur should we transfer() now 847 842 848 843 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 849 844 it != m_ReceiveProcessors.end(); … … 851 846 // a xrun has occurred on the Iso side 852 847 xrun_occurred |= (*it)->xrunOccurred(); 853 848 854 849 // if this is true, a xrun will occur 855 850 xrun_occurred |= !((*it)->canClientTransferFrames(m_period)); 856 851 857 852 #ifdef DEBUG 858 853 if ((*it)->xrunOccurred()) { … … 865 860 } 866 861 #endif 867 862 868 863 } 869 864 for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); … … 872 867 // a xrun has occurred on the Iso side 873 868 xrun_occurred |= (*it)->xrunOccurred(); 874 869 875 870 // if this is true, a xrun will occur 876 871 xrun_occurred |= !((*it)->canClientTransferFrames(m_period)); 877 872 878 873 #ifdef DEBUG 879 874 if ((*it)->xrunOccurred()) { … … 883 878 debugWarning("Xrun on XMIT SP %p due to buffer xrun\n",*it); 884 879 } 885 #endif 886 } 887 880 #endif 881 } 882 888 883 m_nbperiods++; 889 884 890 885 // now we can signal the client that we are (should be) ready 891 886 return !xrun_occurred; … … 900 895 */ 901 896 bool StreamProcessorManager::transfer() { 902 897 903 898 debugOutput( DEBUG_LEVEL_VERBOSE, "Transferring period...\n"); 904 899 … … 920 915 bool StreamProcessorManager::transfer(enum StreamProcessor::EProcessorType t) { 921 916 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "Transferring period...\n"); 922 917 923 918 // a static cast could make sure that there is no performance 924 919 // penalty for the virtual functions (to be checked) … … 927 922 it != m_ReceiveProcessors.end(); 928 923 ++it ) { 929 924 930 925 if(!(*it)->getFrames(m_period)) { 931 926 debugOutput(DEBUG_LEVEL_VERBOSE,"could not getFrames(%u, %11llu) from stream processor (%p)", … … 939 934 it != m_TransmitProcessors.end(); 940 935 ++it ) { 941 936 942 937 if(!(*it)->putFrames(m_period, (int64_t)m_time_of_transfer)) { 943 938 debugOutput(DEBUG_LEVEL_VERBOSE, "could not putFrames(%u,%llu) to stream processor (%p)", … … 953 948 954 949 void StreamProcessorManager::dumpInfo() { 955 debugOutputShort( DEBUG_LEVEL_NORMAL, "----------------------------------------------------\n");956 debugOutputShort( DEBUG_LEVEL_NORMAL, "Dumping StreamProcessorManager information...\n");957 debugOutputShort( DEBUG_LEVEL_NORMAL, "Period count: %6d\n", m_nbperiods);958 959 debugOutputShort( DEBUG_LEVEL_NORMAL, " Receive processors...\n");960 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin();961 it != m_ReceiveProcessors.end();962 ++it ) {963 (*it)->dumpInfo();964 }965 966 debugOutputShort( DEBUG_LEVEL_NORMAL, " Transmit processors...\n");967 for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin();968 it != m_TransmitProcessors.end();969 ++it ) {970 (*it)->dumpInfo();971 }972 973 debugOutputShort( DEBUG_LEVEL_NORMAL, "Iso handler info:\n");974 m_isoManager->dumpInfo();975 debugOutputShort( DEBUG_LEVEL_NORMAL, "----------------------------------------------------\n");950 debugOutputShort( DEBUG_LEVEL_NORMAL, "----------------------------------------------------\n"); 951 debugOutputShort( DEBUG_LEVEL_NORMAL, "Dumping StreamProcessorManager information...\n"); 952 debugOutputShort( DEBUG_LEVEL_NORMAL, "Period count: %6d\n", m_nbperiods); 953 954 debugOutputShort( DEBUG_LEVEL_NORMAL, " Receive processors...\n"); 955 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 956 it != m_ReceiveProcessors.end(); 957 ++it ) { 958 (*it)->dumpInfo(); 959 } 960 961 debugOutputShort( DEBUG_LEVEL_NORMAL, " Transmit processors...\n"); 962 for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); 963 it != m_TransmitProcessors.end(); 964 ++it ) { 965 (*it)->dumpInfo(); 966 } 967 968 debugOutputShort( DEBUG_LEVEL_NORMAL, "Iso handler info:\n"); 969 m_isoManager->dumpInfo(); 970 debugOutputShort( DEBUG_LEVEL_NORMAL, "----------------------------------------------------\n"); 976 971 977 972 } 978 973 979 974 void StreamProcessorManager::setVerboseLevel(int l) { 980 setDebugLevel(l);981 982 if (m_isoManager) m_isoManager->setVerboseLevel(l);983 984 debugOutput( DEBUG_LEVEL_VERBOSE, " Receive processors...\n");985 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin();986 it != m_ReceiveProcessors.end();987 ++it ) {988 (*it)->setVerboseLevel(l);989 }990 991 debugOutput( DEBUG_LEVEL_VERBOSE, " Transmit processors...\n");992 for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin();993 it != m_TransmitProcessors.end();994 ++it ) {995 (*it)->setVerboseLevel(l);996 }975 setDebugLevel(l); 976 977 if (m_isoManager) m_isoManager->setVerboseLevel(l); 978 979 debugOutput( DEBUG_LEVEL_VERBOSE, " Receive processors...\n"); 980 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 981 it != m_ReceiveProcessors.end(); 982 ++it ) { 983 (*it)->setVerboseLevel(l); 984 } 985 986 debugOutput( DEBUG_LEVEL_VERBOSE, " Transmit processors...\n"); 987 for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); 988 it != m_TransmitProcessors.end(); 989 ++it ) { 990 (*it)->setVerboseLevel(l); 991 } 997 992 } 998 993 999 994 1000 995 int StreamProcessorManager::getPortCount(enum Port::E_PortType type, enum Port::E_Direction direction) { 1001 int count=0;1002 1003 if (direction == Port::E_Capture) {1004 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin();1005 it != m_ReceiveProcessors.end();1006 ++it ) {1007 count += (*it)->getPortCount(type);1008 }1009 } else {1010 for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin();1011 it != m_TransmitProcessors.end();1012 ++it ) {1013 count += (*it)->getPortCount(type);1014 }1015 }1016 return count;996 int count=0; 997 998 if (direction == Port::E_Capture) { 999 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 1000 it != m_ReceiveProcessors.end(); 1001 ++it ) { 1002 count += (*it)->getPortCount(type); 1003 } 1004 } else { 1005 for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); 1006 it != m_TransmitProcessors.end(); 1007 ++it ) { 1008 count += (*it)->getPortCount(type); 1009 } 1010 } 1011 return count; 1017 1012 } 1018 1013 1019 1014 int StreamProcessorManager::getPortCount(enum Port::E_Direction direction) { 1020 int count=0;1021 1022 if (direction == Port::E_Capture) {1023 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin();1024 it != m_ReceiveProcessors.end();1025 ++it ) {1026 count += (*it)->getPortCount();1027 }1028 } else {1029 for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin();1030 it != m_TransmitProcessors.end();1031 ++it ) {1032 count += (*it)->getPortCount();1033 }1034 }1035 return count;1015 int count=0; 1016 1017 if (direction == Port::E_Capture) { 1018 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 1019 it != m_ReceiveProcessors.end(); 1020 ++it ) { 1021 count += (*it)->getPortCount(); 1022 } 1023 } else { 1024 for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); 1025 it != m_TransmitProcessors.end(); 1026 ++it ) { 1027 count += (*it)->getPortCount(); 1028 } 1029 } 1030 return count; 1036 1031 } 1037 1032 … … 1039 1034 1040 1035 Port* StreamProcessorManager::getPortByIndex(int idx, enum Port::E_Direction direction) { 1041 int count=0;1042 int prevcount=0;1043 1044 if (direction == Port::E_Capture) {1045 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin();1046 it != m_ReceiveProcessors.end();1047 ++it ) {1048 count += (*it)->getPortCount();1049 if (count > idx) {1050 return (*it)->getPortAtIdx(idx-prevcount);1051 }1052 prevcount=count;1053 }1054 } else {1055 for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin();1056 it != m_TransmitProcessors.end();1057 ++it ) {1058 count += (*it)->getPortCount();1059 if (count > idx) {1060 return (*it)->getPortAtIdx(idx-prevcount);1061 }1062 prevcount=count;1063 }1064 }1065 return NULL;1036 int count=0; 1037 int prevcount=0; 1038 1039 if (direction == Port::E_Capture) { 1040 for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 1041 it != m_ReceiveProcessors.end(); 1042 ++it ) { 1043 count += (*it)->getPortCount(); 1044 if (count > idx) { 1045 return (*it)->getPortAtIdx(idx-prevcount); 1046 } 1047 prevcount=count; 1048 } 1049 } else { 1050 for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); 1051 it != m_TransmitProcessors.end(); 1052 ++it ) { 1053 count += (*it)->getPortCount(); 1054 if (count > idx) { 1055 return (*it)->getPortAtIdx(idx-prevcount); 1056 } 1057 prevcount=count; 1058 } 1059 } 1060 return NULL; 1066 1061 } 1067 1062 trunk/libffado/src/libstreaming/StreamProcessorManager.h
r424 r445 1 /* $Id$ */ 1 /* 2 * Copyright (C) 2005-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 */ 2 23 3 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 27 */ 28 #ifndef __FREEBOB_STREAMPROCESSORMANAGER__ 29 #define __FREEBOB_STREAMPROCESSORMANAGER__ 24 #ifndef __FFADO_STREAMPROCESSORMANAGER__ 25 #define __FFADO_STREAMPROCESSORMANAGER__ 30 26 31 27 #include "debugmodule/debugmodule.h" … … 49 45 /*! 50 46 \brief Manages a collection of StreamProcessors and provides a synchronisation interface 51 47 52 48 */ 53 49 class StreamProcessorManager : public Util::OptionContainer { 54 50 friend class StreamProcessor; 55 51 56 52 public: 57 53 … … 64 60 bool start(); 65 61 bool stop(); 66 62 67 63 bool syncStartAll(); 68 64 … … 91 87 bool transfer(); ///< transfer the buffer contents from/to client 92 88 bool transfer(enum StreamProcessor::EProcessorType); ///< transfer the buffer contents from/to client (single processor type) 93 89 94 90 int getDelayedUsecs() {return m_delayed_usecs;}; 95 91 bool xrunOccurred(); 96 92 int getXrunCount() {return m_xruns;}; 97 93 98 94 private: 99 95 int m_delayed_usecs; … … 102 98 // for the transmit SP's 103 99 uint64_t m_time_of_transfer; 104 100 105 101 public: 106 102 bool handleXrun(); ///< reset the streams & buffers after xrun … … 113 109 private: // slaving support 114 110 bool m_is_slave; 115 111 116 112 // the sync source stuff 117 113 private: 118 114 StreamProcessor *m_SyncSource; 119 115 120 116 public: 121 117 bool setSyncSource(StreamProcessor *s); … … 125 121 126 122 // thread sync primitives 127 bool m_xrun_happened; 123 bool m_xrun_happened; 128 124 129 125 bool m_thread_realtime; … … 137 133 unsigned int m_period; 138 134 unsigned int m_xruns; 139 135 140 136 IsoHandlerManager *m_isoManager; 141 137 … … 148 144 } 149 145 150 #endif /* __F REEBOB_STREAMPROCESSORMANAGER__ */146 #endif /* __FFADO_STREAMPROCESSORMANAGER__ */ 151 147 152 148 trunk/libffado/src/libutil/Atomic.h
r254 r445 1 1 /* 2 Modifications for F reebob (C) 2006Pieter Palmers2 Modifications for FFADO by Pieter Palmers 3 3 4 4 Copied from the jackd/jackdmp sources … … 6 6 a jackd backend. 7 7 8 Copyright (C) 2004-2006 Grame 8 Copyright (C) 2004-2006 Grame 9 9 10 10 This program is free software; you can redistribute it and/or modify … … 24 24 */ 25 25 26 #ifndef __F reebobAtomic__27 #define __F reebobAtomic__26 #ifndef __FFADOATOMIC__ 27 #define __FFADOATOMIC__ 28 28 29 29 typedef unsigned short UInt16; … … 40 40 register int result; 41 41 asm volatile ( 42 "# CAS \n"43 " lwarx r0, 0, %1\n" // creates a reservation on addr44 " cmpw r0, %2 \n"// test value at addr45 " bne-1f \n"46 " sync\n" // synchronize instructions47 " stwcx. %3, 0, %1\n" // if the reservation is not altered42 "# CAS \n" 43 " lwarx r0, 0, %1 \n" // creates a reservation on addr 44 " cmpw r0, %2 \n" // test value at addr 45 " bne- 1f \n" 46 " sync \n" // synchronize instructions 47 " stwcx. %3, 0, %1 \n" // if the reservation is not altered 48 48 // stores the new value at addr 49 " bne-1f \n"49 " bne- 1f \n" 50 50 " li %0, 1 \n" 51 " b2f \n"51 " b 2f \n" 52 52 "1: \n" 53 53 " li %0, 0 \n" 54 54 "2: \n" 55 : "=r" (result)56 : "r" (addr), "r" (value), "r" (newvalue)57 : "r0"58 );55 : "=r" (result) 56 : "r" (addr), "r" (value), "r" (newvalue) 57 : "r0" 58 ); 59 59 return result; 60 60 } … … 62 62 #endif 63 63 64 #if defined(__i386__) || defined(__x86_64__) 64 #if defined(__i386__) || defined(__x86_64__) 65 65 66 66 #ifdef __SMP__ 67 # define LOCK "lock ; "67 # define LOCK "lock ; " 68 68 #else 69 # define LOCK ""69 # define LOCK "" 70 70 #endif 71 71 … … 77 77 LOCK "cmpxchg %2, (%1) \n\t" 78 78 "sete %0 \n\t" 79 : "=a" (ret)80 : "c" (addr), "d" (newvalue), "a" (value)81 );79 : "=a" (ret) 80 : "c" (addr), "d" (newvalue), "a" (value) 81 ); 82 82 return ret; 83 83 } … … 96 96 register UInt32 tmp; 97 97 asm volatile ( 98 "# CAS \n"99 " lwarx %4, 0, %1\n" // creates a reservation on addr100 " cmpw %4, %2\n" // test value at addr101 " bne-1f \n"102 " sync\n" // synchronize instructions103 " stwcx. %3, 0, %1\n" // if the reservation is not altered98 "# CAS \n" 99 " lwarx %4, 0, %1 \n" // creates a reservation on addr 100 " cmpw %4, %2 \n" // test value at addr 101 " bne- 1f \n" 102 " sync \n" // synchronize instructions 103 " stwcx. %3, 0, %1 \n" // if the reservation is not altered 104 104 // stores the new value at addr 105 " bne-1f \n"105 " bne- 1f \n" 106 106 " li %0, 1 \n" 107 " b2f \n"107 " b 2f \n" 108 108 "1: \n" 109 109 " li %0, 0 \n" 110 110 "2: \n" 111 : "=r" (result)112 : "r" (addr), "r" (value), "r" (newvalue), "r" (tmp)113 );111 : "=r" (result) 112 : "r" (addr), "r" (value), "r" (newvalue), "r" (tmp) 113 ); 114 114 return result; 115 115 } … … 117 117 #endif 118 118 119 #if defined(__i386__) || defined(__x86_64__) 119 #if defined(__i386__) || defined(__x86_64__) 120 120 121 121 #ifdef __SMP__ 122 # define LOCK "lock ; "122 # define LOCK "lock ; " 123 123 #else 124 # define LOCK ""124 # define LOCK "" 125 125 #endif 126 126 … … 132 132 LOCK "cmpxchg %2, (%1) \n\t" 133 133 "sete %0 \n\t" 134 : "=a" (ret)135 : "c" (addr), "d" (newvalue), "a" (value)136 );134 : "=a" (ret) 135 : "c" (addr), "d" (newvalue), "a" (value) 136 ); 137 137 return ret; 138 138 } … … 187 187 } 188 188 189 #endif // __FFADO_ATOMIC__ 189 190 190 #endif191 trunk/libffado/src/libutil/cycles.h
r384 r445 1 1 /* cycles.h 2 2 3 F reeBobStreaming API4 F reeBob= Firewire (pro-)audio for linux3 FFADO Streaming API 4 FFADO = Firewire (pro-)audio for linux 5 5 6 http://f reebob.sf.net6 http://ffado.sf.net 7 7 8 8 Based upon cycles.h from the jackdmp package. … … 11 11 Copyright (C) 2001 Paul Davis 12 12 Code derived from various headers from the Linux kernel 13 13 14 14 This program is free software; you can redistribute it and/or modify 15 15 it under the terms of the GNU General Public License as published by … … 28 28 */ 29 29 30 #ifndef __ freebob_cycles_h__31 #define __ freebob_cycles_h__30 #ifndef __FFADO_CYCLES_H__ 31 #define __FFADO_CYCLES_H__ 32 32 33 33 /* … … 43 43 * that we reschedule before that wraps. Scheduling at least every 44 44 * four billion cycles just basically sounds like a good idea, 45 * regardless of how fast the machine is. 45 * regardless of how fast the machine is. 46 46 */ 47 47 … … 52 52 /* PowerPC */ 53 53 54 #define CPU_FTR_601 0x0000010054 #define CPU_FTR_601 0x00000100 55 55 56 56 typedef unsigned long cycles_t; … … 65 65 66 66 __asm__ __volatile__( 67 "98: mftb %0\n"67 "98: mftb %0\n" 68 68 "99:\n" 69 69 ".section __ftr_fixup,\"a\"\n" 70 " .long %1\n"71 " .long 0\n"72 " .long 98b\n"73 " .long 99b\n"70 " .long %1\n" 71 " .long 0\n" 72 " .long 98b\n" 73 " .long 99b\n" 74 74 ".previous" 75 75 : "=r" (ret) : "i" (CPU_FTR_601)); … … 100 100 #endif 101 101 102 #endif / * __freebob_cycles_h__ */102 #endif // __FFADO_CYCLES_H__ trunk/libffado/src/libutil/DelayLockedLoop.cpp
r419 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 2 * Copyright (C) 2005-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 27 22 */ 28 23 … … 41 36 * @param coeffs coefficients to use 42 37 */ 43 DelayLockedLoop::DelayLockedLoop(unsigned int order, float *coeffs) 38 DelayLockedLoop::DelayLockedLoop(unsigned int order, float *coeffs) 44 39 { 45 40 unsigned int i; 46 41 47 42 m_order=order; 48 43 if (m_order==0) m_order=1; 49 44 50 45 m_coeffs=new float[order]; 51 46 m_nodes=new float[order]; 52 47 53 48 for (i=0;i<order;i++) { 54 49 m_coeffs[i]=coeffs[i]; … … 68 63 { 69 64 unsigned int i; 70 65 71 66 m_order=order; 72 67 if (m_order==0) m_order=1; 73 68 74 69 m_coeffs=new float[order]; 75 70 m_nodes=new float[order]; 76 71 77 72 for (i=0;i<order;i++) { 78 73 m_coeffs[i]=0.0; … … 88 83 DelayLockedLoop::DelayLockedLoop() { 89 84 m_order=1; 90 85 91 86 m_coeffs=new float[1]; 92 87 m_coeffs[0]=0.0; 93 88 94 89 m_nodes=new float[1]; 95 90 m_nodes[0]=0.0; … … 99 94 if(m_coeffs) delete[] m_coeffs; 100 95 if(m_nodes) delete[] m_nodes; 101 102 } 103 96 97 } 98 104 99 /** 105 100 * Returns the coefficient with index i … … 110 105 * @return value of the coefficient 111 106 */ 112 float 107 float 113 108 DelayLockedLoop::getCoefficient(unsigned int i) { 114 115 unsigned int x; 116 if (x<m_order) { 117 return m_coeffs[x]; 109 110 if (i<m_order) { 111 return m_coeffs[i]; 118 112 } else { 119 113 return 0.0; … … 124 118 * 125 119 * i should be smaller than the DLL order 126 * 120 * 127 121 * @param i index of the coefficient 128 122 * @param c value of the coefficient … … 130 124 void 131 125 DelayLockedLoop::setCoefficient(unsigned int i, float c) { 132 133 unsigned int x; 134 if (x<m_order) { 135 m_coeffs[x]=c; 126 127 if (i<m_order) { 128 m_coeffs[i]=c; 136 129 } 137 130 } … … 142 135 * 143 136 * i should be smaller than the DLL order 144 * 137 * 145 138 * 146 139 * @param i index of the integrator … … 149 142 void 150 143 DelayLockedLoop::setIntegrator(unsigned int i, float c) { 151 144 152 145 if (i<m_order) { 153 146 m_nodes[i]=c; … … 156 149 157 150 /** 158 * Clears the internal state of the DLL, 151 * Clears the internal state of the DLL, 159 152 * meaning that it will set all internal nodes to 0.0 160 153 */ 161 void 154 void 162 155 DelayLockedLoop::reset() { 163 156 164 157 unsigned int i; 165 158 for (i=0;i<m_order;i++) { 166 159 m_nodes[i]=0.0; 167 160 } 168 161 169 162 } 170 163 … … 173 166 * @return DLL order 174 167 */ 175 unsigned int 168 unsigned int 176 169 DelayLockedLoop::getOrder() { 177 170 return m_order; … … 190 183 * @param coeffs coefficients to use 191 184 */ 192 void 185 void 193 186 DelayLockedLoop::setOrder(unsigned int order, float* coeffs) { 194 187 unsigned int i; 195 188 196 189 reset(); 197 190 198 191 m_order=order; 199 192 if (m_order==0) m_order=1; 200 193 201 194 if(m_coeffs) delete[] m_coeffs; 202 195 m_coeffs=new float[order]; 203 196 204 197 if(m_nodes) delete[] m_nodes; 205 198 m_nodes=new float[order]; 206 199 207 200 for (i=0;i<order;i++) { 208 201 m_coeffs[i]=coeffs[i]; … … 221 214 * @param order new order for the DLL 222 215 */ 223 void 216 void 224 217 DelayLockedLoop::setOrder(unsigned int order) { 225 218 unsigned int i; 226 219 227 220 reset(); 228 221 229 222 m_order=order; 230 223 231 224 if (m_order==0) m_order=1; 232 225 233 226 if(m_coeffs) delete[] m_coeffs; 234 227 m_coeffs=new float[order]; 235 228 236 229 if(m_nodes) delete[] m_nodes; 237 230 m_nodes=new float[order]; 238 231 239 232 for (i=0;i<order;i++) { 240 233 m_coeffs[i]=0.0; … … 243 236 244 237 } 245 238 246 239 /** 247 240 * Put a new value in the loop, updating all internal nodes and … … 250 243 * @param v new value 251 244 */ 252 void 245 void 253 246 DelayLockedLoop::put(float v) { 254 247 … … 256 249 // to make use of pipeline-ing and out of order execution 257 250 // except for very high order loops, then we do it looped 258 251 259 252 // error = newval - output 260 253 m_error=v-m_nodes[0]; … … 262 255 // update the output value 263 256 m_nodes[0]+=m_error*m_coeffs[0]; 264 257 265 258 if(m_order==1) return; // we are done 266 259 267 260 // add the output of the second integrator 268 261 m_nodes[0]+=m_nodes[1]; 269 262 270 263 // update the second integrator 271 264 m_nodes[1]+=m_error*m_coeffs[1]; 272 265 273 266 if(m_order==2) return; // we are done 274 267 275 268 // if the order is even higher, we are using a loop 276 269 unsigned int i; … … 278 271 // add the i-th integrator value 279 272 m_nodes[i-1] += m_nodes[i]; 280 273 281 274 // update the i-th integrator 282 275 m_nodes[i] = m_coeffs[i] * m_error; 283 276 } 284 277 285 278 return; 286 279 } 287 280 288 281 /** 289 * Get the output value of the DLL 282 * Get the output value of the DLL 290 283 * 291 284 * @return current output value 292 285 */ 293 float 286 float 294 287 DelayLockedLoop::get() { 295 288 return m_nodes[0]; … … 301 294 * @return current error signal value 302 295 */ 303 float 296 float 304 297 DelayLockedLoop::getError() { 305 298 return m_error; 306 299 } 307 300 308 } // end of namespace F reeBobUtil301 } // end of namespace FFADOUtil trunk/libffado/src/libutil/DelayLockedLoop.h
r419 r445 1 /* $Id$ */ 1 /* 2 * Copyright (C) 2005-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 */ 2 23 3 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 27 */ 28 #ifndef __FREEBOB_DELAYLOCKEDLOOP__ 29 #define __FREEBOB_DELAYLOCKEDLOOP__ 24 #ifndef __FFADO_DELAYLOCKEDLOOP__ 25 #define __FFADO_DELAYLOCKEDLOOP__ 30 26 31 27 namespace Util { … … 35 31 public: 36 32 37 DelayLockedLoop(unsigned int order, float *coeffs);38 DelayLockedLoop(unsigned int order);39 DelayLockedLoop();40 41 virtual ~DelayLockedLoop();42 33 DelayLockedLoop(unsigned int order, float *coeffs); 34 DelayLockedLoop(unsigned int order); 35 DelayLockedLoop(); 36 37 virtual ~DelayLockedLoop(); 38 43 39 float getCoefficient(unsigned int i); 44 40 void setCoefficient(unsigned int i, float c); 45 41 46 42 void setIntegrator(unsigned int i, float c); 47 43 48 44 void reset(); 49 45 50 46 unsigned int getOrder(); 51 47 void setOrder(unsigned int i); 52 48 void setOrder(unsigned int order, float* coeffs); 53 49 54 50 void put(float v); 55 51 float get(); 56 52 float getError(); 57 53 58 54 protected: 59 55 … … 65 61 }; 66 62 67 } // end of namespace F reeBobUtil63 } // end of namespace FFADOUtil 68 64 69 #endif /* __F REEBOB_DELAYLOCKEDLOOP__ */65 #endif /* __FFADO_DELAYLOCKEDLOOP__ */ 70 66 71 67 trunk/libffado/src/libutil/OptionContainer.cpp
r419 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 2 * Copyright (C) 2005-2007 by Pieter Palmers 6 3 * 7 * http://freebob.sf.net 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 8 6 * 9 * Copyright (C) 2007 Pieter Palmers <pieterpalmers@users.sourceforge.net>7 * FFADO is based upon FreeBoB. 10 8 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 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; 15 12 * 16 * This programis distributed in the hope that it will be useful,17 * but WITHOUT ANY WARRANTY {}without even the implied warranty of18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the19 * GNUGeneral Public License for more details.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. 20 17 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 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 27 22 */ 28 23 … … 36 31 IMPL_DEBUG_MODULE( OptionContainer, OptionContainer, DEBUG_LEVEL_NORMAL ); 37 32 38 OptionContainer::Option::Option() 33 OptionContainer::Option::Option() 39 34 : m_Name(""), 40 35 m_stringValue(""), … … 46 41 {} 47 42 48 OptionContainer::Option::Option(std::string n) 43 OptionContainer::Option::Option(std::string n) 49 44 : m_Name(n), 50 45 m_stringValue(""), … … 56 51 {} 57 52 58 OptionContainer::Option::Option(std::string n, std::string v) 53 OptionContainer::Option::Option(std::string n, std::string v) 59 54 : m_Name(n), 60 55 m_stringValue(v), … … 66 61 {} 67 62 68 OptionContainer::Option::Option(std::string n, bool v) 63 OptionContainer::Option::Option(std::string n, bool v) 69 64 : m_Name(n), 70 65 m_stringValue(""), … … 76 71 {} 77 72 78 OptionContainer::Option::Option(std::string n, double v) 73 OptionContainer::Option::Option(std::string n, double v) 79 74 : m_Name(n), 80 75 m_stringValue(""), … … 86 81 {} 87 82 88 OptionContainer::Option::Option(std::string n, int64_t v) 83 OptionContainer::Option::Option(std::string n, int64_t v) 89 84 : m_Name(n), 90 85 m_stringValue(""), … … 96 91 {} 97 92 98 OptionContainer::Option::Option(std::string n, uint64_t v) 93 OptionContainer::Option::Option(std::string n, uint64_t v) 99 94 : m_Name(n), 100 95 m_stringValue(""), … … 135 130 Option op=Option(); 136 131 Glib::ustring tmpstr; 137 132 138 133 result = deser.read( basePath + "m_Name", tmpstr ); 139 134 op.m_Name = tmpstr; … … 341 336 return false; 342 337 } 343 338 344 339 m_Options.push_back(o); 345 340 346 341 return true; 347 342 } … … 449 444 std::ostringstream strstrm; 450 445 strstrm << basePath << "/" << "Option" << i; 451 446 452 447 Option pOption = Option::deserialize( strstrm.str() + "/", 453 448 deser ); trunk/libffado/src/libutil/OptionContainer.h
r419 r445 1 /* $Id$ */ 1 /* 2 * Copyright (C) 2005-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 */ 2 23 3 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2007 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 */ 26 #ifndef __FREEBOB_OPTIONCONTAINER__ 27 #define __FREEBOB_OPTIONCONTAINER__ 24 #ifndef __FFADO_OPTIONCONTAINER__ 25 #define __FFADO_OPTIONCONTAINER__ 28 26 29 27 #include "../debugmodule/debugmodule.h" … … 48 46 EUInt = 5, 49 47 }; 50 48 51 49 public: 52 50 Option(); … … 57 55 Option(std::string, int64_t); 58 56 Option(std::string, uint64_t); 59 57 60 58 ~Option() {}; 61 59 62 60 std::string getName() {return m_Name;}; 63 61 enum EType getType() {return m_Type;}; 64 62 65 63 void set(std::string v); 66 64 void set(bool v); … … 68 66 void set(int64_t v); 69 67 void set(uint64_t v); 70 68 71 69 std::string getString() {return m_stringValue;}; 72 70 bool getBool() {return m_boolValue;}; … … 74 72 int64_t getInt() {return m_intValue;}; 75 73 uint64_t getUInt() {return m_uintValue;}; 76 74 77 75 public: // serialization support 78 76 bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; … … 81 79 private: 82 80 std::string m_Name; 83 81 84 82 std::string m_stringValue; 85 83 86 84 bool m_boolValue; 87 85 double m_doubleValue; 88 86 int64_t m_intValue; 89 87 uint64_t m_uintValue; 90 88 91 89 enum EType m_Type; 92 90 }; … … 96 94 OptionContainer(); 97 95 virtual ~OptionContainer(); 98 96 99 97 bool setOption(std::string name, std::string v); 100 98 bool setOption(std::string name, bool v); … … 108 106 bool setOption(std::string name, int8_t v); 109 107 bool setOption(std::string name, uint8_t v); 110 108 111 109 bool getOption(std::string name, std::string &v); 112 110 bool getOption(std::string name, bool &v); … … 121 119 bool getOption(std::string name, int8_t &v); 122 120 bool getOption(std::string name, uint8_t &v); 123 121 124 122 Option::EType getOptionType(std::string name); 125 123 126 124 bool hasOption(std::string name); 127 125 128 126 int countOptions() {return m_Options.size();}; 129 127 … … 131 129 bool setOption(Option o); 132 130 Option getOption(std::string name); 133 131 134 132 bool hasOption(Option o); 135 133 136 134 bool addOption(Option o); 137 135 138 136 bool removeOption(Option o); 139 137 bool removeOption(std::string name); 140 138 141 139 void clearOptions() {m_Options.clear();}; 142 140 143 141 public: // provide an iterator interface 144 142 … … 148 146 return(m_Options.begin()); 149 147 } 150 148 151 149 iterator end() 152 150 { … … 155 153 156 154 protected: // serialization support 157 bool serializeOptions( Glib::ustring basePath, 155 bool serializeOptions( Glib::ustring basePath, 158 156 Util::IOSerialize& ser) const; 159 157 static bool deserializeOptions( Glib::ustring basePath, … … 164 162 int findOption(Option o); 165 163 int findOption(std::string name); 166 164 167 165 typedef std::vector< Option > OptionVector; 168 166 typedef std::vector< Option >::iterator OptionVectorIterator; 169 167 OptionVector m_Options; 170 168 171 169 protected: 172 170 DECLARE_DEBUG_MODULE; … … 176 174 } // end of namespace Util 177 175 178 #endif /* __F REEBOB_OPTIONCONTAINER__ */176 #endif /* __FFADO_OPTIONCONTAINER__ */ 179 177 180 178 trunk/libffado/src/libutil/PacketBuffer.cpp
r419 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 2 * Copyright (C) 2005-2007 by Pieter Palmers 6 3 * 7 * http://freebob.sf.net 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 8 6 * 9 * Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net>7 * FFADO is based upon FreeBoB. 10 8 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 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; 15 12 * 16 * This programis distributed in the hope that it will be useful,17 * but WITHOUT ANY WARRANTY {}without even the implied warranty of18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the19 * GNUGeneral Public License for more details.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. 20 17 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 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 27 22 */ 28 23 … … 37 32 38 33 PacketBuffer::~PacketBuffer() { 39 if(payload_buffer) freebob_ringbuffer_free(payload_buffer);40 if(header_buffer) freebob_ringbuffer_free(header_buffer);41 if(len_buffer) freebob_ringbuffer_free(len_buffer);34 if(payload_buffer) ffado_ringbuffer_free(payload_buffer); 35 if(header_buffer) ffado_ringbuffer_free(header_buffer); 36 if(len_buffer) ffado_ringbuffer_free(len_buffer); 42 37 } 43 38 44 39 int PacketBuffer::initialize() { 45 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n");40 debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 46 41 47 if(payload_buffer) freebob_ringbuffer_free(payload_buffer);48 if(header_buffer) freebob_ringbuffer_free(header_buffer);49 if(len_buffer) freebob_ringbuffer_free(len_buffer);42 if(payload_buffer) ffado_ringbuffer_free(payload_buffer); 43 if(header_buffer) ffado_ringbuffer_free(header_buffer); 44 if(len_buffer) ffado_ringbuffer_free(len_buffer); 50 45 51 payload_buffer=freebob_ringbuffer_create(m_buffersize * m_max_packetsize * sizeof(quadlet_t));52 if(!payload_buffer) {53 debugFatal("Could not allocate payload buffer\n");54 return -1;55 }46 payload_buffer=ffado_ringbuffer_create(m_buffersize * m_max_packetsize * sizeof(quadlet_t)); 47 if(!payload_buffer) { 48 debugFatal("Could not allocate payload buffer\n"); 49 return -1; 50 } 56 51 57 header_buffer=freebob_ringbuffer_create(m_buffersize * (m_headersize) * sizeof(quadlet_t));58 if(!header_buffer) {59 debugFatal("Could not allocate header buffer\n");60 return -1;61 }52 header_buffer=ffado_ringbuffer_create(m_buffersize * (m_headersize) * sizeof(quadlet_t)); 53 if(!header_buffer) { 54 debugFatal("Could not allocate header buffer\n"); 55 return -1; 56 } 62 57 63 len_buffer=freebob_ringbuffer_create(m_buffersize * sizeof(unsigned int));64 if(!len_buffer) {65 debugFatal("Could not allocate len buffer\n");66 return -1;67 }68 debugOutput( DEBUG_LEVEL_VERBOSE, "exit...\n");58 len_buffer=ffado_ringbuffer_create(m_buffersize * sizeof(unsigned int)); 59 if(!len_buffer) { 60 debugFatal("Could not allocate len buffer\n"); 61 return -1; 62 } 63 debugOutput( DEBUG_LEVEL_VERBOSE, "exit...\n"); 69 64 70 return 0;65 return 0; 71 66 } 72 67 73 68 void PacketBuffer::flush() { 74 if(header_buffer) {75 freebob_ringbuffer_reset(header_buffer);76 }77 if(payload_buffer) {78 freebob_ringbuffer_reset(payload_buffer);79 }80 if(len_buffer) {81 freebob_ringbuffer_reset(len_buffer);82 }69 if(header_buffer) { 70 ffado_ringbuffer_reset(header_buffer); 71 } 72 if(payload_buffer) { 73 ffado_ringbuffer_reset(payload_buffer); 74 } 75 if(len_buffer) { 76 ffado_ringbuffer_reset(len_buffer); 77 } 83 78 } 84 79 85 80 int PacketBuffer::addPacket(quadlet_t *packet, int packet_len) { 86 81 87 unsigned int payload_bytes=sizeof(quadlet_t)*(packet_len-m_headersize);88 unsigned int header_bytes=sizeof(quadlet_t)*(m_headersize);82 unsigned int payload_bytes=sizeof(quadlet_t)*(packet_len-m_headersize); 83 unsigned int header_bytes=sizeof(quadlet_t)*(m_headersize); 89 84 90 debugOutput( DEBUG_LEVEL_VERY_VERBOSE,91 "add packet: length=%d\n",92 packet_len);85 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, 86 "add packet: length=%d\n", 87 packet_len); 93 88 94 if ((freebob_ringbuffer_write_space(payload_buffer) > payload_bytes) 95 && (freebob_ringbuffer_write_space(header_buffer) > header_bytes)) {89 if ((ffado_ringbuffer_write_space(payload_buffer) > payload_bytes) 90 && (ffado_ringbuffer_write_space(header_buffer) > header_bytes)) { 96 91 97 freebob_ringbuffer_write(payload_buffer,(char *)(packet)+header_bytes, payload_bytes);98 freebob_ringbuffer_write(len_buffer,(char *)(&payload_bytes),sizeof(unsigned int));99 freebob_ringbuffer_write(header_buffer,(char *)(packet), header_bytes);92 ffado_ringbuffer_write(payload_buffer,(char *)(packet)+header_bytes, payload_bytes); 93 ffado_ringbuffer_write(len_buffer,(char *)(&payload_bytes),sizeof(unsigned int)); 94 ffado_ringbuffer_write(header_buffer,(char *)(packet), header_bytes); 100 95 101 } else return -1;102 return 0;96 } else return -1; 97 return 0; 103 98 104 99 } … … 106 101 int PacketBuffer::getNextPacket(quadlet_t *packet, int max_packet_len) { 107 102 108 unsigned int bytes=sizeof(quadlet_t)*(m_headersize);109 quadlet_t *ptr=packet+m_headersize;103 unsigned int bytes=sizeof(quadlet_t)*(m_headersize); 104 quadlet_t *ptr=packet+m_headersize; 110 105 111 debugOutput( DEBUG_LEVEL_VERY_VERBOSE,112 "getNextPacket\n");106 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, 107 "getNextPacket\n"); 113 108 114 if(max_packet_len<m_headersize) return -2;109 if(max_packet_len<m_headersize) return -2; 115 110 116 if (freebob_ringbuffer_read(header_buffer,(char *)packet,bytes) < bytes) {117 return -1;118 }111 if (ffado_ringbuffer_read(header_buffer,(char *)packet,bytes) < bytes) { 112 return -1; 113 } 119 114 120 if (freebob_ringbuffer_read(len_buffer,(char *)&bytes, sizeof(unsigned int)) < sizeof(unsigned int)) {121 return -3;122 }115 if (ffado_ringbuffer_read(len_buffer,(char *)&bytes, sizeof(unsigned int)) < sizeof(unsigned int)) { 116 return -3; 117 } 123 118 124 if(bytes>(max_packet_len-m_headersize)*sizeof(quadlet_t)) return -2;119 if(bytes>(max_packet_len-m_headersize)*sizeof(quadlet_t)) return -2; 125 120 126 if(freebob_ringbuffer_read(payload_buffer,(char *)(ptr),bytes) < bytes) {127 return -3;128 }121 if(ffado_ringbuffer_read(payload_buffer,(char *)(ptr),bytes) < bytes) { 122 return -3; 123 } 129 124 130 return bytes/sizeof(quadlet_t)+m_headersize;125 return bytes/sizeof(quadlet_t)+m_headersize; 131 126 } 132 127 133 128 int PacketBuffer::getBufferFillPackets() { 134 129 135 return freebob_ringbuffer_read_space(len_buffer)/sizeof(unsigned int);130 return ffado_ringbuffer_read_space(len_buffer)/sizeof(unsigned int); 136 131 } 137 132 … … 139 134 int PacketBuffer::getBufferFillPayload() { 140 135 141 return freebob_ringbuffer_read_space(payload_buffer)/sizeof(quadlet_t);136 return ffado_ringbuffer_read_space(payload_buffer)/sizeof(quadlet_t); 142 137 } 143 138 trunk/libffado/src/libutil/PacketBuffer.h
r419 r445 1 /* $Id$ */ 1 /* 2 * Copyright (C) 2005-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 */ 2 23 3 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 27 */ 28 #ifndef __FREEBOB_PACKETBUFFER__ 29 #define __FREEBOB_PACKETBUFFER__ 24 #ifndef __FFADO_PACKETBUFFER__ 25 #define __FFADO_PACKETBUFFER__ 30 26 31 27 #include "../debugmodule/debugmodule.h" … … 39 35 public: 40 36 41 PacketBuffer(int headersize, int buffersize, int max_packetsize) 42 : m_headersize(headersize), m_buffersize(buffersize), m_max_packetsize(max_packetsize),43 payload_buffer(0), header_buffer(0), len_buffer(0)44 {};37 PacketBuffer(int headersize, int buffersize, int max_packetsize) 38 : m_headersize(headersize), m_buffersize(buffersize), m_max_packetsize(max_packetsize), 39 payload_buffer(0), header_buffer(0), len_buffer(0) 40 {}; 45 41 46 virtual ~PacketBuffer();47 void setVerboseLevel(int l) { setDebugLevel( l ); };42 virtual ~PacketBuffer(); 43 void setVerboseLevel(int l) { setDebugLevel( l ); }; 48 44 49 int initialize();45 int initialize(); 50 46 51 void flush();47 void flush(); 52 48 53 int addPacket(quadlet_t *packet, int packet_len);49 int addPacket(quadlet_t *packet, int packet_len); 54 50 55 int getNextPacket(quadlet_t *packet, int packet_len);56 int getBufferFillPackets();57 int getBufferFillPayload();51 int getNextPacket(quadlet_t *packet, int packet_len); 52 int getBufferFillPackets(); 53 int getBufferFillPayload(); 58 54 59 55 protected: 60 int m_headersize;61 int m_buffersize;62 int m_max_packetsize;56 int m_headersize; 57 int m_buffersize; 58 int m_max_packetsize; 63 59 64 freebob_ringbuffer_t *payload_buffer;65 freebob_ringbuffer_t *header_buffer;66 freebob_ringbuffer_t *len_buffer;67 60 ffado_ringbuffer_t *payload_buffer; 61 ffado_ringbuffer_t *header_buffer; 62 ffado_ringbuffer_t *len_buffer; 63 68 64 DECLARE_DEBUG_MODULE; 69 65 … … 72 68 } 73 69 74 #endif /* __F REEBOB_PACKETBUFFER__ */70 #endif /* __FFADO_PACKETBUFFER__ */ 75 71 76 72 trunk/libffado/src/libutil/PosixThread.cpp
r419 r445 1 1 /* 2 Modifications for F reebob (C) 2006,Pieter Palmers2 Modifications for FFADO by Pieter Palmers 3 3 4 4 Copied from the jackd/jackdmp sources … … 6 6 a jackd backend. 7 7 8 Copyright (C) 2001 Paul Davis 8 Copyright (C) 2001 Paul Davis 9 9 Copyright (C) 2004-2006 Grame 10 10 … … 54 54 55 55 // If Init succeed start the thread loop 56 bool res = true;56 bool res = true; 57 57 while (obj->fRunning && res) { 58 58 res = runnable->Execute(); 59 //pthread_testcancel();59 //pthread_testcancel(); 60 60 } 61 61 … … 67 67 { 68 68 int res; 69 fRunning = true;69 fRunning = true; 70 70 71 71 if (fRealTime) { … … 121 121 return -1; 122 122 } 123 123 124 124 return 0; 125 125 } … … 142 142 { 143 143 if (fThread) { // If thread has been started 144 debugOutput( DEBUG_LEVEL_VERBOSE, "PosixThread::Stop\n");145 void* status;144 debugOutput( DEBUG_LEVEL_VERBOSE, "PosixThread::Stop\n"); 145 void* status; 146 146 fRunning = false; // Request for the thread to stop 147 pthread_join(fThread, &status);147 pthread_join(fThread, &status); 148 148 return 0; 149 149 } else { trunk/libffado/src/libutil/PosixThread.h
r419 r445 1 1 /* 2 Modifications for F reebob (C) 2006,Pieter Palmers2 Modifications for FFADO by Pieter Palmers 3 3 4 4 Copied from the jackd/jackdmp sources … … 25 25 */ 26 26 27 #ifndef __ POSIXTHREAD__28 #define __ POSIXTHREAD__27 #ifndef __FFADO_POSIXTHREAD__ 28 #define __FFADO_POSIXTHREAD__ 29 29 30 30 #include "Thread.h" … … 46 46 int fPriority; 47 47 bool fRealTime; 48 volatile bool fRunning;48 volatile bool fRunning; 49 49 int fCancellation; 50 50 … … 68 68 virtual int Start(); 69 69 virtual int Kill(); 70 virtual int Stop();70 virtual int Stop(); 71 71 72 72 virtual int AcquireRealTime(); … … 76 76 pthread_t GetThreadID(); 77 77 78 protected:78 protected: 79 79 80 80 }; … … 83 83 84 84 85 #endif 85 #endif // __FFADO_POSIXTHREAD__ trunk/libffado/src/libutil/ringbuffer.c
r386 r445 1 1 /* 2 Modifications for F reeBoBby Pieter Palmers2 Modifications for FFADO by Pieter Palmers 3 3 4 4 Copied from the jackd sources … … 39 39 actual buffer size is rounded up to the next power of two. */ 40 40 41 f reebob_ringbuffer_t *42 f reebob_ringbuffer_create (size_t sz)41 ffado_ringbuffer_t * 42 ffado_ringbuffer_create (size_t sz) 43 43 { 44 44 int power_of_two; 45 f reebob_ringbuffer_t *rb;46 47 rb = malloc (sizeof (f reebob_ringbuffer_t));45 ffado_ringbuffer_t *rb; 46 47 rb = malloc (sizeof (ffado_ringbuffer_t)); 48 48 49 49 for (power_of_two = 1; 1 << power_of_two < sz; power_of_two++); … … 63 63 64 64 void 65 f reebob_ringbuffer_free (freebob_ringbuffer_t * rb)65 ffado_ringbuffer_free (ffado_ringbuffer_t * rb) 66 66 { 67 67 #ifdef USE_MLOCK … … 76 76 77 77 int 78 f reebob_ringbuffer_mlock (freebob_ringbuffer_t * rb)78 ffado_ringbuffer_mlock (ffado_ringbuffer_t * rb) 79 79 { 80 80 #ifdef USE_MLOCK … … 91 91 92 92 void 93 f reebob_ringbuffer_reset (freebob_ringbuffer_t * rb)93 ffado_ringbuffer_reset (ffado_ringbuffer_t * rb) 94 94 { 95 95 rb->read_ptr = 0; … … 102 102 103 103 size_t 104 f reebob_ringbuffer_read_space (const freebob_ringbuffer_t * rb)104 ffado_ringbuffer_read_space (const ffado_ringbuffer_t * rb) 105 105 { 106 106 size_t w, r; … … 121 121 122 122 size_t 123 f reebob_ringbuffer_write_space (const freebob_ringbuffer_t * rb)123 ffado_ringbuffer_write_space (const ffado_ringbuffer_t * rb) 124 124 { 125 125 size_t w, r; … … 141 141 142 142 size_t 143 f reebob_ringbuffer_read (freebob_ringbuffer_t * rb, char *dest, size_t cnt)143 ffado_ringbuffer_read (ffado_ringbuffer_t * rb, char *dest, size_t cnt) 144 144 { 145 145 size_t free_cnt; … … 148 148 size_t n1, n2; 149 149 150 if ((free_cnt = f reebob_ringbuffer_read_space (rb)) == 0) {150 if ((free_cnt = ffado_ringbuffer_read_space (rb)) == 0) { 151 151 return 0; 152 152 } … … 182 182 183 183 size_t 184 f reebob_ringbuffer_peek (freebob_ringbuffer_t * rb, char *dest, size_t cnt)184 ffado_ringbuffer_peek (ffado_ringbuffer_t * rb, char *dest, size_t cnt) 185 185 { 186 186 size_t free_cnt; … … 192 192 tmp_read_ptr = rb->read_ptr; 193 193 194 if ((free_cnt = f reebob_ringbuffer_read_space (rb)) == 0) {194 if ((free_cnt = ffado_ringbuffer_read_space (rb)) == 0) { 195 195 return 0; 196 196 } … … 226 226 227 227 size_t 228 f reebob_ringbuffer_write (freebob_ringbuffer_t * rb, const char *src, size_t cnt)228 ffado_ringbuffer_write (ffado_ringbuffer_t * rb, const char *src, size_t cnt) 229 229 { 230 230 size_t free_cnt; … … 233 233 size_t n1, n2; 234 234 235 if ((free_cnt = f reebob_ringbuffer_write_space (rb)) == 0) {235 if ((free_cnt = ffado_ringbuffer_write_space (rb)) == 0) { 236 236 return 0; 237 237 } … … 265 265 266 266 void 267 f reebob_ringbuffer_read_advance (freebob_ringbuffer_t * rb, size_t cnt)267 ffado_ringbuffer_read_advance (ffado_ringbuffer_t * rb, size_t cnt) 268 268 { 269 269 rb->read_ptr += cnt; … … 274 274 275 275 void 276 f reebob_ringbuffer_write_advance (freebob_ringbuffer_t * rb, size_t cnt)276 ffado_ringbuffer_write_advance (ffado_ringbuffer_t * rb, size_t cnt) 277 277 { 278 278 rb->write_ptr += cnt; … … 286 286 287 287 void 288 f reebob_ringbuffer_get_read_vector (const freebob_ringbuffer_t * rb,289 f reebob_ringbuffer_data_t * vec)288 ffado_ringbuffer_get_read_vector (const ffado_ringbuffer_t * rb, 289 ffado_ringbuffer_data_t * vec) 290 290 { 291 291 size_t free_cnt; … … 330 330 331 331 void 332 f reebob_ringbuffer_get_write_vector (const freebob_ringbuffer_t * rb,333 f reebob_ringbuffer_data_t * vec)332 ffado_ringbuffer_get_write_vector (const ffado_ringbuffer_t * rb, 333 ffado_ringbuffer_data_t * vec) 334 334 { 335 335 size_t free_cnt; trunk/libffado/src/libutil/ringbuffer.h
r386 r445 3 3 function names changed in order to avoid naming problems when using this in 4 4 a jackd backend. 5 6 Modifications for F reeBoBby Pieter Palmers7 5 6 Modifications for FFADO by Pieter Palmers 7 8 8 Copyright (C) 2000 Paul Davis 9 9 Copyright (C) 2003 Rohan Drape 10 10 11 11 This program is free software; you can redistribute it and/or modify 12 12 it under the terms of the GNU Lesser General Public License as published by 13 13 the Free Software Foundation; either version 2.1 of the License, or 14 14 (at your option) any later version. 15 15 16 16 This program is distributed in the hope that it will be useful, 17 17 but WITHOUT ANY WARRANTY; without even the implied warranty of 18 18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 19 GNU Lesser General Public License for more details. 20 20 21 21 You should have received a copy of the GNU Lesser General Public License 22 along with this program; if not, write to the Free Software 22 along with this program; if not, write to the Free Software 23 23 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 24 24 25 25 */ 26 26 27 #ifndef _ RINGBUFFER_H28 #define _ RINGBUFFER_H27 #ifndef _FFADO_RINGBUFFER_H 28 #define _FFADO_RINGBUFFER_H 29 29 30 30 #ifdef __cplusplus … … 45 45 */ 46 46 47 typedef struct 47 typedef struct 48 48 { 49 49 char *buf; 50 50 size_t len; 51 } 52 f reebob_ringbuffer_data_t ;51 } 52 ffado_ringbuffer_data_t ; 53 53 54 54 typedef struct 55 55 { 56 char *buf;56 char *buf; 57 57 volatile size_t write_ptr; 58 58 volatile size_t read_ptr; 59 size_t size;60 size_t size_mask;61 int mlocked;62 } 63 f reebob_ringbuffer_t ;59 size_t size; 60 size_t size_mask; 61 int mlocked; 62 } 63 ffado_ringbuffer_t ; 64 64 65 65 /** 66 66 * Allocates a ringbuffer data structure of a specified size. The 67 * caller must arrange for a call to f reebob_ringbuffer_free() to release67 * caller must arrange for a call to ffado_ringbuffer_free() to release 68 68 * the memory associated with the ringbuffer. 69 69 * 70 70 * @param sz the ringbuffer size in bytes. 71 71 * 72 * @return a pointer to a new f reebob_ringbuffer_t, if successful; NULL72 * @return a pointer to a new ffado_ringbuffer_t, if successful; NULL 73 73 * otherwise. 74 74 */ 75 f reebob_ringbuffer_t *freebob_ringbuffer_create(size_t sz);75 ffado_ringbuffer_t *ffado_ringbuffer_create(size_t sz); 76 76 77 77 /** 78 78 * Frees the ringbuffer data structure allocated by an earlier call to 79 * f reebob_ringbuffer_create().80 * 81 * @param rb a pointer to the ringbuffer structure. 82 */ 83 void f reebob_ringbuffer_free(freebob_ringbuffer_t *rb);79 * ffado_ringbuffer_create(). 80 * 81 * @param rb a pointer to the ringbuffer structure. 82 */ 83 void ffado_ringbuffer_free(ffado_ringbuffer_t *rb); 84 84 85 85 /** 86 86 * Fill a data structure with a description of the current readable 87 87 * data held in the ringbuffer. This description is returned in a two 88 * element array of f reebob_ringbuffer_data_t. Two elements are needed88 * element array of ffado_ringbuffer_data_t. Two elements are needed 89 89 * because the data to be read may be split across the end of the 90 90 * ringbuffer. … … 100 100 * 101 101 * @param rb a pointer to the ringbuffer structure. 102 * @param vec a pointer to a 2 element array of f reebob_ringbuffer_data_t.103 * 104 */ 105 void f reebob_ringbuffer_get_read_vector(const freebob_ringbuffer_t *rb,106 freebob_ringbuffer_data_t *vec);102 * @param vec a pointer to a 2 element array of ffado_ringbuffer_data_t. 103 * 104 */ 105 void ffado_ringbuffer_get_read_vector(const ffado_ringbuffer_t *rb, 106 ffado_ringbuffer_data_t *vec); 107 107 108 108 /** 109 109 * Fill a data structure with a description of the current writable 110 110 * space in the ringbuffer. The description is returned in a two 111 * element array of f reebob_ringbuffer_data_t. Two elements are needed111 * element array of ffado_ringbuffer_data_t. Two elements are needed 112 112 * because the space available for writing may be split across the end 113 113 * of the ringbuffer. … … 123 123 * 124 124 * @param rb a pointer to the ringbuffer structure. 125 * @param vec a pointer to a 2 element array of f reebob_ringbuffer_data_t.126 */ 127 void f reebob_ringbuffer_get_write_vector(const freebob_ringbuffer_t *rb,128 freebob_ringbuffer_data_t *vec);125 * @param vec a pointer to a 2 element array of ffado_ringbuffer_data_t. 126 */ 127 void ffado_ringbuffer_get_write_vector(const ffado_ringbuffer_t *rb, 128 ffado_ringbuffer_data_t *vec); 129 129 130 130 /** … … 138 138 * @return the number of bytes read, which may range from 0 to cnt. 139 139 */ 140 size_t f reebob_ringbuffer_read(freebob_ringbuffer_t *rb, char *dest, size_t cnt);141 142 /** 143 * Read data from the ringbuffer. Opposed to f reebob_ringbuffer_read()140 size_t ffado_ringbuffer_read(ffado_ringbuffer_t *rb, char *dest, size_t cnt); 141 142 /** 143 * Read data from the ringbuffer. Opposed to ffado_ringbuffer_read() 144 144 * this function does not move the read pointer. Thus it's 145 145 * a convenient way to inspect data in the ringbuffer in a 146 146 * continous fashion. The price is that the data is copied 147 147 * into a user provided buffer. For "raw" non-copy inspection 148 * of the data in the ringbuffer use f reebob_ringbuffer_get_read_vector().148 * of the data in the ringbuffer use ffado_ringbuffer_get_read_vector(). 149 149 * 150 150 * @param rb a pointer to the ringbuffer structure. … … 155 155 * @return the number of bytes read, which may range from 0 to cnt. 156 156 */ 157 size_t f reebob_ringbuffer_peek(freebob_ringbuffer_t *rb, char *dest, size_t cnt);157 size_t ffado_ringbuffer_peek(ffado_ringbuffer_t *rb, char *dest, size_t cnt); 158 158 159 159 /** … … 161 161 * 162 162 * After data have been read from the ringbuffer using the pointers 163 * returned by f reebob_ringbuffer_get_read_vector(), use this function to163 * returned by ffado_ringbuffer_get_read_vector(), use this function to 164 164 * advance the buffer pointers, making that space available for future 165 165 * write operations. … … 168 168 * @param cnt the number of bytes read. 169 169 */ 170 void f reebob_ringbuffer_read_advance(freebob_ringbuffer_t *rb, size_t cnt);170 void ffado_ringbuffer_read_advance(ffado_ringbuffer_t *rb, size_t cnt); 171 171 172 172 /** … … 177 177 * @return the number of bytes available to read. 178 178 */ 179 size_t f reebob_ringbuffer_read_space(const freebob_ringbuffer_t *rb);179 size_t ffado_ringbuffer_read_space(const ffado_ringbuffer_t *rb); 180 180 181 181 /** … … 186 186 * @param rb a pointer to the ringbuffer structure. 187 187 */ 188 int f reebob_ringbuffer_mlock(freebob_ringbuffer_t *rb);188 int ffado_ringbuffer_mlock(ffado_ringbuffer_t *rb); 189 189 190 190 /** … … 195 195 * @param rb a pointer to the ringbuffer structure. 196 196 */ 197 void f reebob_ringbuffer_reset(freebob_ringbuffer_t *rb);197 void ffado_ringbuffer_reset(ffado_ringbuffer_t *rb); 198 198 199 199 /** … … 206 206 * @return the number of bytes write, which may range from 0 to cnt 207 207 */ 208 size_t f reebob_ringbuffer_write(freebob_ringbuffer_t *rb, const char *src,209 size_t cnt);208 size_t ffado_ringbuffer_write(ffado_ringbuffer_t *rb, const char *src, 209 size_t cnt); 210 210 211 211 /** … … 213 213 * 214 214 * After data have been written the ringbuffer using the pointers 215 * returned by f reebob_ringbuffer_get_write_vector(), use this function215 * returned by ffado_ringbuffer_get_write_vector(), use this function 216 216 * to advance the buffer pointer, making the data available for future 217 217 * read operations. … … 220 220 * @param cnt the number of bytes written. 221 221 */ 222 void f reebob_ringbuffer_write_advance(freebob_ringbuffer_t *rb, size_t cnt);222 void ffado_ringbuffer_write_advance(ffado_ringbuffer_t *rb, size_t cnt); 223 223 224 224 /** … … 229 229 * @return the amount of free space (in bytes) available for writing. 230 230 */ 231 size_t f reebob_ringbuffer_write_space(const freebob_ringbuffer_t *rb);231 size_t ffado_ringbuffer_write_space(const ffado_ringbuffer_t *rb); 232 232 233 233 … … 236 236 #endif 237 237 238 #endif 238 #endif // FFADO_RINGBUFFER trunk/libffado/src/libutil/serialize.cpp
r417 r445 1 /* serialize.cpp 2 * Copyright (C) 2006,07 by Daniel Wagner 3 * 4 * This file is part of FreeBoB. 5 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.14 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 … … 49 52 { 50 53 try { 51 m_doc.create_root_node( "f reebob_cache" );54 m_doc.create_root_node( "ffado_cache" ); 52 55 } catch ( const exception& ex ) { 53 56 cout << "Exception caught: " << ex.what(); … … 212 215 } 213 216 xmlpp::Node* pNode = pDoc->get_root_node(); 214 217 215 218 xmlpp::NodeSet nodeSet = pNode->find( strMemberName ); 216 219 for ( xmlpp::NodeSet::iterator it = nodeSet.begin(); trunk/libffado/src/libutil/serialize.h
r372 r445 1 /* serialize.h2 * Copyright (C) 200 7 by Daniel Wagner1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 3 * 4 * This file is part of FreeBoB. 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 5 6 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 14 17 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 trunk/libffado/src/libutil/StreamStatistics.cpp
r419 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 2 * Copyright (C) 2005-2007 by Pieter Palmers 6 3 * 7 * http://freebob.sf.net 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 8 6 * 9 * Copyright (C) 2005,2006,2007 Pieter Palmers <pieterpalmers@users.sourceforge.net>7 * FFADO is based upon FreeBoB. 10 8 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 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; 15 12 * 16 * This programis distributed in the hope that it will be useful,17 * but WITHOUT ANY WARRANTY {}without even the implied warranty of18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the19 * GNUGeneral Public License for more details.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. 20 17 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 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 27 22 */ 28 23 trunk/libffado/src/libutil/StreamStatistics.h
r419 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 2 * Copyright (C) 2005-2007 by Pieter Palmers 6 3 * 7 * http://freebob.sf.net 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 8 6 * 9 * Copyright (C) 2005,2006,2007 Pieter Palmers <pieterpalmers@users.sourceforge.net>7 * FFADO is based upon FreeBoB. 10 8 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 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; 15 12 * 16 * This programis distributed in the hope that it will be useful,17 * but WITHOUT ANY WARRANTY {}without even the implied warranty of18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the19 * GNUGeneral Public License for more details.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. 20 17 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 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 27 22 */ 28 23 29 #ifndef F REEBOBSTREAMINGSTREAMSTATISTICS_H30 #define F REEBOBSTREAMINGSTREAMSTATISTICS_H24 #ifndef FFADOSTREAMINGSTREAMSTATISTICS_H 25 #define FFADOSTREAMINGSTREAMSTATISTICS_H 31 26 32 27 #include <string> … … 41 36 42 37 void setName(std::string n) {m_name=n;}; 43 38 44 39 void mark(int value); 45 40 46 41 void dumpInfo(); 47 42 void reset(); 48 43 49 44 std::string m_name; 50 45 51 46 long m_count; 52 47 float m_average; … … 54 49 long m_max; 55 50 long m_sum; 56 51 57 52 private: 58 53 59 54 }; 60 55 trunk/libffado/src/libutil/SystemTimeSource.cpp
r419 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 2 * Copyright (C) 2005-2007 by Pieter Palmers 6 3 * 7 * http://freebob.sf.net 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 8 6 * 9 * Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net>7 * FFADO is based upon FreeBoB. 10 8 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 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; 15 12 * 16 * This programis distributed in the hope that it will be useful,17 * but WITHOUT ANY WARRANTY {}without even the implied warranty of18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the19 * GNUGeneral Public License for more details.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. 20 17 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 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 27 22 */ 28 23 … … 41 36 42 37 } 43 44 f reebob_microsecs_t SystemTimeSource::getCurrentTime() {38 39 ffado_microsecs_t SystemTimeSource::getCurrentTime() { 45 40 struct timeval tv; 46 41 gettimeofday(&tv, NULL); 47 42 return tv.tv_sec * 1000000ULL + tv.tv_usec; 48 43 49 44 // return GetMicroSeconds(); 50 45 } 51 46 52 f reebob_microsecs_t SystemTimeSource::getCurrentTimeAsUsecs() {47 ffado_microsecs_t SystemTimeSource::getCurrentTimeAsUsecs() { 53 48 return getCurrentTime(); 54 49 } trunk/libffado/src/libutil/SystemTimeSource.h
r419 r445 1 /* $Id$ */ 1 /* 2 * Copyright (C) 2005-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 */ 2 23 3 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 27 */ 28 #ifndef __FREEBOB_SYSTEMTIMESOURCE__ 29 #define __FREEBOB_SYSTEMTIMESOURCE__ 24 #ifndef __FFADO_SYSTEMTIMESOURCE__ 25 #define __FFADO_SYSTEMTIMESOURCE__ 30 26 31 27 #include "../debugmodule/debugmodule.h" … … 34 30 namespace Util { 35 31 36 class SystemTimeSource 32 class SystemTimeSource 37 33 : public Util::TimeSource 38 34 { … … 40 36 public: 41 37 42 SystemTimeSource();43 virtual ~SystemTimeSource();44 38 SystemTimeSource(); 39 virtual ~SystemTimeSource(); 40 45 41 // implement the TimeSource interface 46 f reebob_microsecs_t getCurrentTime();47 f reebob_microsecs_t getCurrentTimeAsUsecs();48 inline f reebob_microsecs_t unWrapTime(freebob_microsecs_t t) {return t;};49 inline f reebob_microsecs_t wrapTime(freebob_microsecs_t t) {return t;};42 ffado_microsecs_t getCurrentTime(); 43 ffado_microsecs_t getCurrentTimeAsUsecs(); 44 inline ffado_microsecs_t unWrapTime(ffado_microsecs_t t) {return t;}; 45 inline ffado_microsecs_t wrapTime(ffado_microsecs_t t) {return t;}; 50 46 51 47 protected: … … 56 52 } // end of namespace Util 57 53 58 #endif /* __F REEBOB_SYSTEMTIMESOURCE__ */54 #endif /* __FFADO_SYSTEMTIMESOURCE__ */ 59 55 60 56 trunk/libffado/src/libutil/test-dll.cpp
r419 r445 1 1 /* 2 * FreeBob Streaming API 3 * FreeBob = Firewire (pro-)audio for linux 2 * Copyright (C) 2005-2007 by Pieter Palmers 4 3 * 5 * http://freebob.sf.net 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 6 6 * 7 * Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net>7 * FFADO is based upon FreeBoB. 8 8 * 9 * This program is free software {} you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation {} either version 2 of the License, or 12 * (at your option) any later version. 9 * This is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License version 2 11 * as published by the Free Software Foundation. 12 * 13 * FFADO 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 16 * GNU General Public License for more details. 13 17 * 14 * This program 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 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program {} if not, write to the Free Software 21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 * 23 * 24 * Test for the delay locked loop class 25 * 18 * You should have received a copy of the GNU General Public License 19 * along with FFADO; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21 * MA 02111-1307 USA. 26 22 */ 27 23 … … 34 30 int i=0; 35 31 int i2=0; 36 32 37 33 #define MAX_TEST_ORDER 2 38 34 39 35 #define NB_VALUES 12 40 36 #define NB_LOOPS 50000 41 37 42 38 // this test is for a second order loop, 43 39 44 40 45 41 float omega=6.28*0.001; … … 47 43 coeffs[0]=1.41*omega; 48 44 coeffs[1]=omega*omega; 49 45 50 46 DelayLockedLoop d1(1, coeffs); 51 47 52 48 DelayLockedLoop d2(2, coeffs); 53 49 54 50 // this sequence represents the average deviation of the sample period 55 51 float deviation[NB_VALUES]={-0.001, 0.0, 0.001, 0.001, -0.001, 0.001, -0.001, 0.001, -0.001, 0.00, 0.001, -0.001}; 56 52 float average=0.0; 57 53 58 54 // these are the actual period times 59 55 float ideal_values[NB_LOOPS]; 60 56 float actual_values[NB_LOOPS]; 61 57 float actual_values2[NB_LOOPS]; 62 58 63 59 // we define a nominal sample time: 64 60 float ts_nominal=1.0/48000.0; 65 61 float period=100.0; 66 62 67 63 // we calculate the deviated sample times 68 64 for (i=0;i<NB_LOOPS;i++) { 69 65 unsigned int idx=i % NB_VALUES; 70 66 71 67 // this constructs time-between-samples type of data 72 68 // for testing the first order loop 73 69 actual_values[i]=period*ts_nominal*(1+deviation[idx]); 74 70 75 71 // this is constructing an incrementing time line 76 72 ideal_values[i]=0; 77 73 if (i==0) ideal_values[i] = ts_nominal * period; 78 74 else ideal_values[i] = ideal_values[i-1] + (ts_nominal * period); 79 75 80 76 actual_values2[i] = ideal_values[i] + (ts_nominal*deviation[idx]); 81 82 // calculate the average deviation to check which 77 78 // calculate the average deviation to check which 83 79 // direction the deviation sequence takes. 84 average+=deviation[idx]*ts_nominal; 80 average+=deviation[idx]*ts_nominal; 85 81 } 86 82 average /= NB_LOOPS; 87 83 88 84 d1.setIntegrator(0,period*ts_nominal); 89 85 90 86 d2.setIntegrator(0,ideal_values[0]); 91 87 d2.setIntegrator(1,ideal_values[0]); 92 88 93 89 for(i=0;i<50;i++) { 94 90 d1.put(actual_values[i]); 95 91 printf("%06d: IN = %8.4fms - OUT = %8.4fms, error output=%e\n", i, actual_values[i]*1000, d1.get()*1000, d1.getError()); 96 92 } 97 93 98 94 printf("--------\n"); 99 95 for(i2=0;i2<50;i2++) { … … 101 97 printf("%06d: IN = %8.4fms - OUT = %8.4fms, error output=%e\n", i, actual_values2[i2]*1000, d2.get()*1000, d2.getError()); 102 98 } 103 99 104 100 printf("========= CONVERGENCE =========\n"); 105 101 for(;i<NB_LOOPS;i++) { 106 102 d1.put(actual_values[i]); 107 103 } 108 printf("%06d: OUT = %8.4fms, E=%e, ideal=%8.4fms, diff=%f%%\n", i, 109 d1.get()*1000, 104 printf("%06d: OUT = %8.4fms, E=%e, ideal=%8.4fms, diff=%f%%\n", i, 105 d1.get()*1000, 110 106 d1.getError(), 111 107 ts_nominal * period*1000, 112 108 (d1.get()-ts_nominal * period)/(ts_nominal * period)*100); 113 109 114 110 printf("--------\n"); 115 111 for(;i2<NB_LOOPS;i2++) { 116 112 d2.put(actual_values2[i2]); 117 113 } 118 printf("%06d: OUT = %8.4fms, E=%e, ideal=%8.4fms, diff=%f%%\n", i, 119 d2.get()*1000, 114 printf("%06d: OUT = %8.4fms, E=%e, ideal=%8.4fms, diff=%f%%\n", i, 115 d2.get()*1000, 120 116 d2.getError(), 121 117 ideal_values[NB_LOOPS-1]*1000, 122 118 (d2.get()-ideal_values[NB_LOOPS-1])/(ideal_values[NB_LOOPS-1])*100); 123 124 119 120 125 121 printf("Average deviation: %f, period time = %fms\n",average, ts_nominal * period*1000); 126 122 trunk/libffado/src/libutil/Thread.h
r419 r445 1 1 /* 2 Modifications for F reebob (C) 2006,Pieter Palmers2 Modifications for FFADO by Pieter Palmers 3 3 4 4 Copied from the jackd/jackdmp sources … … 77 77 virtual int Start() = 0; 78 78 virtual int Kill() = 0; 79 virtual int Stop() = 0;79 virtual int Stop() = 0; 80 80 81 81 virtual int AcquireRealTime() = 0; … … 87 87 88 88 virtual pthread_t GetThreadID() = 0; 89 89 90 90 protected: 91 DECLARE_DEBUG_MODULE;91 DECLARE_DEBUG_MODULE; 92 92 93 93 }; trunk/libffado/src/libutil/Time.c
r360 r445 1 /* Time.c 2 FreeBob Streaming API 3 FreeBob = Firewire (pro-)audio for linux 1 /* 2 Copyright (C) 2005-2007 by Pieter Palmers 4 3 5 http://freebob.sf.net 4 This file is part of FFADO 5 FFADO = Free Firewire (pro-)audio drivers for linux 6 6 7 Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> 7 FFADO is based upon FreeBoB. 8 8 9 10 9 Based upon JackTime.c from the jackdmp package. 11 10 Original Copyright: … … 13 12 Copyright (C) 2001-2003 Paul Davis 14 13 Copyright (C) 2004-2006 Grame 15 16 14 17 15 This program is free software; you can redistribute it and/or modify trunk/libffado/src/libutil/Time.h
r384 r445 1 1 /* 2 Time.h 3 FreeBob Streaming API 4 FreeBob = Firewire (pro-)audio for linux 2 Copyright (C) 2005-2007 by Pieter Palmers 5 3 6 http://freebob.sf.net 4 This file is part of FFADO 5 FFADO = Free Firewire (pro-)audio drivers for linux 7 6 8 Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> 9 10 Based upon JackTime.h from the jackdmp package. 11 Original Copyright: 7 FFADO is based upon FreeBoB. 12 8 13 Copyright (C) 2001-2003 Paul Davis 14 Copyright (C) 2004-2006 Grame 9 Based upon JackTime.h from the jackdmp package. 10 Original Copyright: 15 11 16 This program is free software; you can redistribute it and/or modify 17 it under the terms of the GNU Lesser General Public License as published by 18 the Free Software Foundation; either version 2.1 of the License, or 19 (at your option) any later version. 12 Copyright (C) 2001-2003 Paul Davis 13 Copyright (C) 2004-2006 Grame 20 14 21 This program is distributed in the hope that it will be useful, 22 but WITHOUT ANY WARRANTY; without even the implied warranty of 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 GNU Lesser General Public License for more details.15 This program is free software; you can redistribute it and/or modify 16 it under the terms of the GNU General Public License as published by 17 the Free Software Foundation; either version 2 of the License, or 18 (at your option) any later version. 25 19 26 You should have received a copy of the GNU Lesser General Public License 27 along with this program; if not, write to the Free Software 28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 This program is distributed in the hope that it will be useful, 21 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 GNU General Public License for more details. 24 25 You should have received a copy of the GNU General Public License 26 along with this program; if not, write to the Free Software 27 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 29 28 30 29 */ … … 43 42 */ 44 43 45 typedef uint64_t f reebob_microsecs_t;44 typedef uint64_t ffado_microsecs_t; 46 45 47 46 … … 54 53 #include <unistd.h> 55 54 56 static inline void F reebobSleep(long usec) {55 static inline void FFADOSleep(long usec) { 57 56 usleep(usec); 58 57 } 59 58 60 59 #ifdef GETCYCLE_TIME 61 #include "cycles.h"62 extern f reebob_microsecs_t __freebob_cpu_mhz;63 extern f reebob_microsecs_t GetMhz();60 #include "cycles.h" 61 extern ffado_microsecs_t __ffado_cpu_mhz; 62 extern ffado_microsecs_t GetMhz(); 64 63 extern void InitTime(); 65 static inline f reebob_microsecs_t GetMicroSeconds (void) {66 return get_cycles() / __f reebob_cpu_mhz;64 static inline ffado_microsecs_t GetMicroSeconds (void) { 65 return get_cycles() / __ffado_cpu_mhz; 67 66 } 68 67 #else 69 #include <time.h>68 #include <time.h> 70 69 extern void InitTime(); 71 static inline f reebob_microsecs_t GetMicroSeconds (void) {70 static inline ffado_microsecs_t GetMicroSeconds (void) { 72 71 struct timespec ts; 73 72 clock_gettime(CLOCK_MONOTONIC, &ts); 74 return (f reebob_microsecs_t)ts.tv_sec * 1000000LL + ts.tv_nsec / 1000;73 return (ffado_microsecs_t)ts.tv_sec * 1000000LL + ts.tv_nsec / 1000; 75 74 } 76 75 #endif trunk/libffado/src/libutil/TimeSource.cpp
r419 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 27 */ 28 2 * Copyright (C) 2005-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 */ 29 23 30 24 #include "TimeSource.h" … … 56 50 */ 57 51 void TimeSource::initSlaveTimeSource() { 58 f reebob_microsecs_t my_time;59 f reebob_microsecs_t master_time;60 f reebob_microsecs_t my_time2;61 f reebob_microsecs_t master_time2;62 52 ffado_microsecs_t my_time; 53 ffado_microsecs_t master_time; 54 ffado_microsecs_t my_time2; 55 ffado_microsecs_t master_time2; 56 63 57 if (m_Master) { 64 58 my_time=getCurrentTime(); 65 59 master_time=m_Master->getCurrentTime(); 66 60 67 61 struct timespec ts; 68 62 69 63 // sleep for ten milliseconds 70 64 ts.tv_sec=0; 71 65 ts.tv_nsec=10000000L; 72 66 73 67 nanosleep(&ts,NULL); 74 68 75 69 my_time2=getCurrentTime(); 76 70 master_time2=m_Master->getCurrentTime(); 77 71 78 72 float diff_slave=my_time2-my_time; 79 73 float diff_master=master_time2-master_time; 80 74 81 75 m_slave_rate=diff_slave/diff_master; 82 76 83 77 // average of the two offset estimates 84 m_slave_offset = my_time-wrapTime((f reebob_microsecs_t)(master_time*m_slave_rate));85 m_slave_offset += my_time2-wrapTime((f reebob_microsecs_t)(master_time2*m_slave_rate));78 m_slave_offset = my_time-wrapTime((ffado_microsecs_t)(master_time*m_slave_rate)); 79 m_slave_offset += my_time2-wrapTime((ffado_microsecs_t)(master_time2*m_slave_rate)); 86 80 m_slave_offset /= 2; 87 81 88 82 m_last_master_time=master_time2; 89 83 m_last_time=my_time2; … … 95 89 debugOutput(DEBUG_LEVEL_NORMAL,"init slave: slave rate=%f, slave_offset=%lu\n", 96 90 m_slave_rate, m_slave_offset 97 ); 98 } 99 100 101 } 102 103 /** 104 * Maps a time point of the master to a time point 91 ); 92 } 93 94 95 } 96 97 /** 98 * Maps a time point of the master to a time point 105 99 * on it's own timeline 106 100 * 107 101 * @return the mapped time point 108 102 */ 109 f reebob_microsecs_t TimeSource::mapMasterTime(freebob_microsecs_t master_time) {103 ffado_microsecs_t TimeSource::mapMasterTime(ffado_microsecs_t master_time) { 110 104 if(m_Master) { 111 105 // calculate the slave based upon the master 112 106 // and the estimated rate 113 107 114 108 // linear interpolation 115 109 int delta_master=master_time-m_last_master_time; 116 110 117 111 float offset=m_slave_rate * ((float)delta_master); 118 119 f reebob_microsecs_t mapped=m_last_time+(int)offset;120 112 113 ffado_microsecs_t mapped=m_last_time+(int)offset; 114 121 115 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"map time: master=%d, offset=%f, slave_base=%lu, pred_ticks=%lu\n", 122 116 master_time, offset, m_last_time,mapped 123 117 ); 124 118 125 119 return wrapTime(mapped); 126 120 127 121 } else { 128 122 debugOutput( DEBUG_LEVEL_VERBOSE, "Requested map for non-slave TimeSource\n"); 129 123 130 124 return master_time; 131 125 } … … 140 134 for ( TimeSourceVectorIterator it = m_Slaves.begin(); 141 135 it != m_Slaves.end(); ++it ) { 142 143 // update the slave with the current 136 137 // update the slave with the current 144 138 // master time 145 139 if (!(*it)->updateTimeSource()) return false; 146 140 } 147 141 148 142 // this TimeSource has a master 149 143 if(m_Master) { 150 f reebob_microsecs_t my_time=getCurrentTime();151 f reebob_microsecs_t master_time=m_Master->getCurrentTime();152 153 // we assume that the master and slave time are 144 ffado_microsecs_t my_time=getCurrentTime(); 145 ffado_microsecs_t master_time=m_Master->getCurrentTime(); 146 147 // we assume that the master and slave time are 154 148 // measured at the same time, but that of course is 155 149 // not really true. The DLL will have to filter this 156 150 // out. 157 151 158 152 // the difference in master time 159 153 int64_t delta_master; … … 163 157 delta_master=m_Master->unWrapTime(master_time)-m_last_master_time; 164 158 } 165 159 166 160 // the difference in slave time 167 161 int64_t delta_slave; … … 171 165 delta_slave=unWrapTime(my_time)-m_last_time; 172 166 } 173 167 174 168 // the estimated slave difference 175 169 int delta_slave_est=(int)(m_slave_rate * ((double)delta_master)); 176 170 177 171 // the measured & estimated rate 178 172 double rate_meas=((double)delta_slave/(double)delta_master); 179 173 double rate_est=((double)m_slave_rate); 180 174 181 175 m_last_err=(rate_meas-rate_est); 182 176 183 177 m_slave_rate += 0.01*m_last_err; 184 178 185 179 debugOutput(DEBUG_LEVEL_VERBOSE,"update slave: master=%llu, master2=%llu, diff=%lld\n", 186 180 master_time, m_last_master_time, delta_master); … … 191 185 ); 192 186 193 187 194 188 m_last_master_time=master_time; 195 189 196 190 int64_t tmp = delta_slave_est; 197 191 tmp += m_last_time; 198 192 199 193 m_last_time = tmp; 200 201 202 194 195 196 203 197 } 204 198 … … 209 203 * Sets the master TimeSource for this timesource. 210 204 * This TimeSource will sync to the master TimeSource, 211 * making that it will be able to map a time point of 205 * making that it will be able to map a time point of 212 206 * the master to a time point on it's own timeline 213 207 * 214 * @param ts master TimeSource 208 * @param ts master TimeSource 215 209 * @return true if successful 216 210 */ … … 218 212 if (m_Master==NULL) { 219 213 m_Master=ts; 220 214 221 215 // initialize ourselves. 222 216 initSlaveTimeSource(); 223 217 224 218 return true; 225 219 } else return false; … … 238 232 * Registers a slave timesource to this master. 239 233 * A slave TimeSource will sync to this TimeSource, 240 * making that it will be able to map a time point of 241 * the master (this) TimeSource to a time point on 234 * making that it will be able to map a time point of 235 * the master (this) TimeSource to a time point on 242 236 * it's own timeline 243 237 * … … 247 241 bool TimeSource::registerSlave(TimeSource *ts) { 248 242 // TODO: we should check for circular master-slave relationships. 249 243 250 244 debugOutput( DEBUG_LEVEL_VERBOSE, "Registering slave (%p)\n", ts); 251 245 assert(ts); 252 246 253 247 // inherit debug level 254 ts->setVerboseLevel(getDebugLevel()); 255 248 ts->setVerboseLevel(getDebugLevel()); 249 256 250 if(ts->setMaster(this)) { 257 251 m_Slaves.push_back(ts); … … 275 269 it != m_Slaves.end(); ++it ) { 276 270 277 if ( *it == ts ) { 271 if ( *it == ts ) { 278 272 m_Slaves.erase(it); 279 273 ts->clearMaster(); … … 281 275 } 282 276 } 283 277 284 278 debugOutput( DEBUG_LEVEL_VERBOSE, " TimeSource (%p) not found\n", ts); 285 279 286 280 return false; 287 281 } … … 298 292 for ( TimeSourceVectorIterator it = m_Slaves.begin(); 299 293 it != m_Slaves.end(); ++it ) { 300 294 301 295 (*it)->setVerboseLevel(l); 302 296 } … … 313 307 debugOutputShort( DEBUG_LEVEL_NORMAL, " Last slave time : %llu\n",m_last_time ); 314 308 315 309 316 310 for ( TimeSourceVectorIterator it = m_Slaves.begin(); 317 311 it != m_Slaves.end(); ++it ) { 318 312 319 313 (*it)->printTimeSourceInfo(); 320 314 } trunk/libffado/src/libutil/TimeSource.h
r419 r445 1 /* $Id$ */ 1 /* 2 * Copyright (C) 2005-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 */ 2 23 3 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 6 * 7 * http://freebob.sf.net 8 * 9 * Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> 10 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 26 * 27 */ 28 #ifndef __FREEBOB_TIMESOURCE__ 29 #define __FREEBOB_TIMESOURCE__ 24 #ifndef __FFADO_TIMESOURCE__ 25 #define __FFADO_TIMESOURCE__ 30 26 31 27 #include "../debugmodule/debugmodule.h" … … 33 29 #include <vector> 34 30 35 typedef uint64_t f reebob_microsecs_t;31 typedef uint64_t ffado_microsecs_t; 36 32 37 33 namespace Util { … … 44 40 \brief The base class for all TimeSource's. 45 41 46 Any object that can act as a source of timing 42 Any object that can act as a source of timing 47 43 information should subclass this class and implement 48 44 its virtual functions. 49 45 50 46 A TimeSource can be slaved to another TimeSource, allowing 51 47 the mapping of the master's time to the slave's time. … … 58 54 virtual ~TimeSource(); 59 55 60 virtual f reebob_microsecs_t getCurrentTime()=0;61 virtual f reebob_microsecs_t getCurrentTimeAsUsecs()=0;62 virtual f reebob_microsecs_t unWrapTime(freebob_microsecs_t t)=0;63 virtual f reebob_microsecs_t wrapTime(freebob_microsecs_t t)=0;64 65 f reebob_microsecs_t mapMasterTime(freebob_microsecs_t t);66 56 virtual ffado_microsecs_t getCurrentTime()=0; 57 virtual ffado_microsecs_t getCurrentTimeAsUsecs()=0; 58 virtual ffado_microsecs_t unWrapTime(ffado_microsecs_t t)=0; 59 virtual ffado_microsecs_t wrapTime(ffado_microsecs_t t)=0; 60 61 ffado_microsecs_t mapMasterTime(ffado_microsecs_t t); 62 67 63 bool updateTimeSource(); 68 64 69 65 bool registerSlave(TimeSource *ts); 70 66 bool unregisterSlave(TimeSource *ts); 71 67 72 68 virtual void setVerboseLevel(int l); 73 69 74 70 virtual void printTimeSourceInfo(); 75 71 76 72 protected: 77 73 … … 79 75 bool setMaster(TimeSource *ts); 80 76 void clearMaster(); 81 77 82 78 void initSlaveTimeSource(); 83 79 84 80 TimeSource * m_Master; 85 81 TimeSourceVector m_Slaves; 86 87 f reebob_microsecs_t m_last_master_time;88 f reebob_microsecs_t m_last_time;89 82 83 ffado_microsecs_t m_last_master_time; 84 ffado_microsecs_t m_last_time; 85 90 86 double m_slave_rate; 91 87 int64_t m_slave_offset; 92 88 double m_last_err; 93 89 94 90 DECLARE_DEBUG_MODULE; 95 91 … … 98 94 } // end of namespace Util 99 95 100 #endif /* __F REEBOB_TIMESOURCE__ */96 #endif /* __FFADO_TIMESOURCE__ */ 101 97 102 98 trunk/libffado/src/libutil/TimestampedBuffer.cpp
r419 r445 2 2 3 3 /* 4 * F reeBobStreaming API5 * F reeBob= Firewire (pro-)audio for linux6 * 7 * http://f reebob.sf.net4 * FFADO Streaming API 5 * FFADO = Firewire (pro-)audio for linux 6 * 7 * http://ffado.sf.net 8 8 * 9 9 * Copyright (C) 2005,2006,2007 Pieter Palmers <pieterpalmers@users.sourceforge.net> … … 23 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 24 * 25 * 26 * 27 */ 28 25 * 26 * 27 */ 28 29 29 #include "libutil/Atomic.h" 30 30 #include "libstreaming/cycletimer.h" … … 54 54 55 55 TimestampedBuffer::~TimestampedBuffer() { 56 f reebob_ringbuffer_free(m_event_buffer);56 ffado_ringbuffer_free(m_event_buffer); 57 57 free(m_cluster_buffer); 58 58 } … … 71 71 m_nominal_rate=r; 72 72 debugOutput(DEBUG_LEVEL_VERBOSE," nominal rate=%e set to %e\n", 73 m_nominal_rate, r); 73 m_nominal_rate, r); 74 74 return true; 75 75 } … … 100 100 101 101 /** 102 * \brief return the effective rate 102 * \brief return the effective rate 103 103 * 104 104 * Returns the effective rate calculated by the DLL. … … 109 109 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"getRate: %f/%f=%f\n", 110 110 m_dll_e2,(float)m_update_period, m_dll_e2/((float) m_update_period)); 111 111 112 112 return m_dll_e2/((float) m_update_period); 113 113 } … … 120 120 bool TimestampedBuffer::setEventSize(unsigned int s) { 121 121 m_event_size=s; 122 122 123 123 m_bytes_per_frame=m_event_size*m_events_per_frame; 124 124 m_bytes_per_buffer=m_bytes_per_frame*m_buffer_size; 125 125 126 126 return true; 127 127 } … … 134 134 bool TimestampedBuffer::setEventsPerFrame(unsigned int n) { 135 135 m_events_per_frame=n; 136 136 137 137 m_bytes_per_frame=m_event_size*m_events_per_frame; 138 138 m_bytes_per_buffer=m_bytes_per_frame*m_buffer_size; 139 139 140 140 return true; 141 141 } … … 155 155 156 156 /** 157 * Sets the buffer offset in ticks. 157 * Sets the buffer offset in ticks. 158 158 * 159 159 * A positive value means that the buffer is 'delayed' for nticks ticks. 160 160 * 161 161 * @note These offsets are only used when reading timestamps. Any function 162 * that returns a timestamp will incorporate this offset. 162 * that returns a timestamp will incorporate this offset. 163 163 * @param nframes the number of ticks (positive = delay buffer) 164 164 * @return true if successful … … 174 174 * 175 175 * This returns the buffer fill of the internal ringbuffer. This 176 * can only be used as an indication because it's state is not 176 * can only be used as an indication because it's state is not 177 177 * guaranteed to be consistent at all times due to threading issues. 178 178 * 179 * In order to get the number of frames in the buffer, use the 179 * In order to get the number of frames in the buffer, use the 180 180 * getFrameCounter, getBufferHeadTimestamp, getBufferTailTimestamp 181 181 * functions … … 184 184 */ 185 185 unsigned int TimestampedBuffer::getBufferFill() { 186 return f reebob_ringbuffer_read_space(m_event_buffer)/(m_bytes_per_frame);186 return ffado_ringbuffer_read_space(m_event_buffer)/(m_bytes_per_frame); 187 187 } 188 188 … … 204 204 * Resets the TimestampedBuffer, clearing the buffers and counters. 205 205 * (not true yet: Also resets the DLL to the nominal values.) 206 * 206 * 207 207 * \note when this is called, you should make sure that the buffer 208 208 * tail timestamp gets set before continuing … … 211 211 */ 212 212 bool TimestampedBuffer::reset() { 213 f reebob_ringbuffer_reset(m_event_buffer);214 213 ffado_ringbuffer_reset(m_event_buffer); 214 215 215 resetFrameCounter(); 216 216 217 217 return true; 218 218 } … … 220 220 /** 221 221 * \brief Perpares the TimestampedBuffer 222 * 223 * Prepare the TimestampedBuffer. This allocates all internal buffers and 222 * 223 * Prepare the TimestampedBuffer. This allocates all internal buffers and 224 224 * initializes all data structures. 225 * 225 * 226 226 * This should be called after parameters such as buffer size, event size etc.. are set, 227 227 * and before any read/write operations are performed. 228 * 228 * 229 229 * @return true if successful 230 230 */ … … 233 233 debugOutput(DEBUG_LEVEL_VERBOSE," Size=%u events, events/frame=%u, event size=%ubytes\n", 234 234 m_buffer_size,m_events_per_frame,m_event_size); 235 235 236 236 debugOutput(DEBUG_LEVEL_VERBOSE," update period %u\n", 237 237 m_update_period); 238 238 debugOutput(DEBUG_LEVEL_VERBOSE," nominal rate=%f\n", 239 239 m_nominal_rate); 240 240 241 241 debugOutput(DEBUG_LEVEL_VERBOSE," wrapping at %llu\n",m_wrap_at); 242 242 … … 247 247 assert(m_nominal_rate != 0.0L); 248 248 assert(m_update_period != 0); 249 250 if( !(m_event_buffer=f reebob_ringbuffer_create(249 250 if( !(m_event_buffer=ffado_ringbuffer_create( 251 251 (m_events_per_frame * m_buffer_size) * m_event_size))) { 252 252 debugFatal("Could not allocate memory event ringbuffer\n"); 253 253 return false; 254 254 } 255 255 256 256 // allocate the temporary cluster buffer 257 257 if( !(m_cluster_buffer=(char *)calloc(m_events_per_frame,m_event_size))) { 258 258 debugFatal("Could not allocate temporary cluster buffer\n"); 259 f reebob_ringbuffer_free(m_event_buffer);259 ffado_ringbuffer_free(m_event_buffer); 260 260 return false; 261 261 } 262 262 263 263 // init the DLL 264 264 m_dll_e2=m_nominal_rate * (float)m_update_period; 265 265 266 266 m_dll_b=((float)(0.877)); 267 267 m_dll_c=((float)(0.384)); … … 272 272 /** 273 273 * @brief Write frames to the buffer 274 * 274 * 275 275 * Copies \ref nframes of frames from the buffer pointed to by \ref data to the 276 276 * internal ringbuffer. The time of the last frame in the buffer is set to \ref ts. 277 * 277 * 278 278 * @param nframes number of frames to copy 279 279 * @param data pointer to the frame buffer … … 286 286 287 287 // add the data payload to the ringbuffer 288 if (f reebob_ringbuffer_write(m_event_buffer,data,write_size) < write_size)288 if (ffado_ringbuffer_write(m_event_buffer,data,write_size) < write_size) 289 289 { 290 290 // debugWarning("writeFrames buffer overrun\n"); 291 291 return false; 292 292 } 293 293 294 294 incrementFrameCounter(nframes,ts); 295 295 296 296 return true; 297 297 … … 299 299 /** 300 300 * @brief Read frames from the buffer 301 * 302 * Copies \ref nframes of frames from the internal buffer to the data buffer pointed 301 * 302 * Copies \ref nframes of frames from the internal buffer to the data buffer pointed 303 303 * to by \ref data. 304 * 304 * 305 305 * @param nframes number of frames to copy 306 306 * @param data pointer to the frame buffer … … 312 312 313 313 // get the data payload to the ringbuffer 314 if ((f reebob_ringbuffer_read(m_event_buffer,data,read_size)) < read_size)314 if ((ffado_ringbuffer_read(m_event_buffer,data,read_size)) < read_size) 315 315 { 316 316 // debugWarning("readFrames buffer underrun\n"); 317 317 return false; 318 318 } 319 319 320 320 decrementFrameCounter(nframes); 321 321 322 322 return true; 323 323 … … 326 326 /** 327 327 * @brief Performs block processing write of frames 328 * 328 * 329 329 * This function allows for zero-copy writing into the ringbuffer. 330 330 * It calls the client's processWriteBlock function to write frames 331 331 * into the internal buffer's data area, in a thread safe fashion. 332 * 332 * 333 333 * It also updates the timestamp. 334 * 334 * 335 335 * @param nbframes number of frames to process 336 336 * @param ts timestamp of the last frame written to the buffer … … 342 342 int xrun; 343 343 unsigned int offset=0; 344 345 f reebob_ringbuffer_data_t vec[2];344 345 ffado_ringbuffer_data_t vec[2]; 346 346 // we received one period of frames 347 347 // this is period_size*dimension of events … … 349 349 unsigned int bytes2write=events2write*m_event_size; 350 350 351 /* write events2write bytes to the ringbuffer 351 /* write events2write bytes to the ringbuffer 352 352 * first see if it can be done in one read. 353 * if so, ok. 353 * if so, ok. 354 354 * otherwise write up to a multiple of clusters directly to the buffer 355 355 * then do the buffer wrap around using ringbuffer_write 356 * then write the remaining data directly to the buffer in a third pass 356 * then write the remaining data directly to the buffer in a third pass 357 357 * Make sure that we cannot end up on a non-cluster aligned position! 358 358 */ … … 361 361 while(bytes2write>0) { 362 362 int byteswritten=0; 363 363 364 364 unsigned int frameswritten=(nbframes*cluster_size-bytes2write)/cluster_size; 365 365 offset=frameswritten; 366 367 f reebob_ringbuffer_get_write_vector(m_event_buffer, vec);368 366 367 ffado_ringbuffer_get_write_vector(m_event_buffer, vec); 368 369 369 if(vec[0].len==0) { // this indicates a full event buffer 370 370 debugError("Event buffer overrun in buffer %p\n",this); 371 371 break; 372 372 } 373 373 374 374 /* if we don't take care we will get stuck in an infinite loop 375 375 * because we align to a cluster boundary later 376 * the remaining nb of bytes in one write operation can be 376 * the remaining nb of bytes in one write operation can be 377 377 * smaller than one cluster 378 378 * this can happen because the ringbuffer size is always a power of 2 379 379 */ 380 380 if(vec[0].len<cluster_size) { 381 381 382 382 // encode to the temporary buffer 383 383 xrun = m_Client->processWriteBlock(m_cluster_buffer, 1, offset); 384 384 385 385 if(xrun<0) { 386 386 // xrun detected … … 388 388 return false; 389 389 } 390 391 // use the ringbuffer function to write one cluster 390 391 // use the ringbuffer function to write one cluster 392 392 // the write function handles the wrap around. 393 f reebob_ringbuffer_write(m_event_buffer,393 ffado_ringbuffer_write(m_event_buffer, 394 394 m_cluster_buffer, 395 395 cluster_size); 396 396 397 397 // we advanced one cluster_size 398 398 bytes2write-=cluster_size; 399 400 } else { // 401 399 400 } else { // 401 402 402 if(bytes2write>vec[0].len) { 403 403 // align to a cluster boundary … … 406 406 byteswritten=bytes2write; 407 407 } 408 408 409 409 xrun = m_Client->processWriteBlock(vec[0].buf, 410 410 byteswritten/cluster_size, 411 411 offset); 412 412 413 413 if(xrun<0) { 414 414 // xrun detected … … 417 417 } 418 418 419 f reebob_ringbuffer_write_advance(m_event_buffer, byteswritten);419 ffado_ringbuffer_write_advance(m_event_buffer, byteswritten); 420 420 bytes2write -= byteswritten; 421 421 } … … 425 425 426 426 } 427 427 428 428 incrementFrameCounter(nbframes,ts); 429 430 return true; 431 429 430 return true; 431 432 432 } 433 433 434 434 /** 435 435 * @brief Performs block processing read of frames 436 * 436 * 437 437 * This function allows for zero-copy reading from the ringbuffer. 438 438 * It calls the client's processReadBlock function to read frames 439 * directly from the internal buffer's data area, in a thread safe 439 * directly from the internal buffer's data area, in a thread safe 440 440 * fashion. 441 * 441 * 442 442 * @param nbframes number of frames to process 443 443 * @return true if successful … … 446 446 447 447 debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "Reading %u from buffer (%p)...\n", nbframes, this); 448 448 449 449 int xrun; 450 450 unsigned int offset=0; 451 452 f reebob_ringbuffer_data_t vec[2];451 452 ffado_ringbuffer_data_t vec[2]; 453 453 // we received one period of frames on each connection 454 454 // this is period_size*dimension of events … … 456 456 unsigned int events2read=nbframes*m_events_per_frame; 457 457 unsigned int bytes2read=events2read*m_event_size; 458 /* read events2read bytes from the ringbuffer 459 * first see if it can be done in one read. 460 * if so, ok. 458 /* read events2read bytes from the ringbuffer 459 * first see if it can be done in one read. 460 * if so, ok. 461 461 * otherwise read up to a multiple of clusters directly from the buffer 462 462 * then do the buffer wrap around using ringbuffer_read 463 * then read the remaining data directly from the buffer in a third pass 463 * then read the remaining data directly from the buffer in a third pass 464 464 * Make sure that we cannot end up on a non-cluster aligned position! 465 465 */ 466 466 unsigned int cluster_size=m_events_per_frame*m_event_size; 467 467 468 468 while(bytes2read>0) { 469 469 unsigned int framesread=(nbframes*cluster_size-bytes2read)/cluster_size; … … 472 472 int bytesread=0; 473 473 474 f reebob_ringbuffer_get_read_vector(m_event_buffer, vec);474 ffado_ringbuffer_get_read_vector(m_event_buffer, vec); 475 475 476 476 if(vec[0].len==0) { // this indicates an empty event buffer … … 485 485 */ 486 486 if(vec[0].len<cluster_size) { 487 // use the ringbuffer function to read one cluster 487 // use the ringbuffer function to read one cluster 488 488 // the read function handles wrap around 489 f reebob_ringbuffer_read(m_event_buffer,m_cluster_buffer,cluster_size);489 ffado_ringbuffer_read(m_event_buffer,m_cluster_buffer,cluster_size); 490 490 491 491 assert(m_Client); … … 501 501 bytes2read-=cluster_size; 502 502 503 } else { // 503 } else { // 504 504 505 505 if(bytes2read>vec[0].len) { … … 509 509 bytesread=bytes2read; 510 510 } 511 511 512 512 assert(m_Client); 513 513 xrun = m_Client->processReadBlock(vec[0].buf, bytesread/cluster_size, offset); … … 519 519 } 520 520 521 f reebob_ringbuffer_read_advance(m_event_buffer, bytesread);521 ffado_ringbuffer_read_advance(m_event_buffer, bytesread); 522 522 bytes2read -= bytesread; 523 523 } … … 528 528 529 529 decrementFrameCounter(nbframes); 530 530 531 531 return true; 532 532 } … … 534 534 /** 535 535 * @brief Sets the buffer tail timestamp. 536 * 536 * 537 537 * Set the buffer tail timestamp to \ref new_timestamp. This will recalculate 538 * the internal state such that the buffer's timeframe starts at 538 * the internal state such that the buffer's timeframe starts at 539 539 * \ref new_timestamp. 540 * 540 * 541 541 * This is thread safe. 542 542 * 543 543 * @note considers offsets 544 * 545 * @param new_timestamp 544 * 545 * @param new_timestamp 546 546 */ 547 547 void TimestampedBuffer::setBufferTailTimestamp(uint64_t new_timestamp) { … … 550 550 int64_t ts=new_timestamp; 551 551 ts += m_tick_offset; 552 552 553 553 if (ts >= (int64_t)m_wrap_at) { 554 554 ts -= m_wrap_at; … … 556 556 ts += m_wrap_at; 557 557 } 558 558 559 559 #ifdef DEBUG 560 560 if (new_timestamp >= m_wrap_at) { 561 561 debugWarning("timestamp not wrapped: %llu\n",new_timestamp); 562 } 562 } 563 563 if ((ts >= (int64_t)m_wrap_at) || (ts < 0 )) { 564 564 debugWarning("ts not wrapped correctly: %lld\n",ts); … … 567 567 568 568 pthread_mutex_lock(&m_framecounter_lock); 569 569 570 570 m_buffer_tail_timestamp = ts; 571 571 572 572 m_dll_e2=m_update_period * m_nominal_rate; 573 573 m_buffer_next_tail_timestamp = (uint64_t)((float)m_buffer_tail_timestamp + m_dll_e2); 574 575 pthread_mutex_unlock(&m_framecounter_lock); 576 574 575 pthread_mutex_unlock(&m_framecounter_lock); 576 577 577 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "Set buffer tail timestamp for (%p) to %11llu => %11lld, NTS=%llu, DLL2=%f, RATE=%f\n", 578 578 this, new_timestamp, ts, m_buffer_next_tail_timestamp, m_dll_e2, m_nominal_rate); … … 582 582 /** 583 583 * @brief Sets the buffer head timestamp. 584 * 585 * Set the buffer tail timestamp such that the buffer head timestamp becomes 584 * 585 * Set the buffer tail timestamp such that the buffer head timestamp becomes 586 586 * \ref new_timestamp. This does not consider offsets, because it's use is to 587 587 * make sure the following is true after setBufferHeadTimestamp(x): 588 588 * x == getBufferHeadTimestamp() 589 * 589 * 590 590 * This is thread safe. 591 * 592 * @param new_timestamp 591 * 592 * @param new_timestamp 593 593 */ 594 594 void TimestampedBuffer::setBufferHeadTimestamp(uint64_t new_timestamp) { 595 595 596 596 #ifdef DEBUG 597 597 if (new_timestamp >= m_wrap_at) { 598 598 debugWarning("timestamp not wrapped: %llu\n",new_timestamp); 599 } 599 } 600 600 #endif 601 601 … … 603 603 604 604 pthread_mutex_lock(&m_framecounter_lock); 605 605 606 606 // add the time 607 607 ts += (int64_t)(m_nominal_rate * (float)m_framecounter); 608 608 609 609 if (ts >= (int64_t)m_wrap_at) { 610 610 ts -= m_wrap_at; … … 612 612 ts += m_wrap_at; 613 613 } 614 614 615 615 m_buffer_tail_timestamp = ts; 616 616 617 617 m_dll_e2=m_update_period * m_nominal_rate; 618 618 m_buffer_next_tail_timestamp = (uint64_t)((float)m_buffer_tail_timestamp + m_dll_e2); 619 620 pthread_mutex_unlock(&m_framecounter_lock); 621 619 620 pthread_mutex_unlock(&m_framecounter_lock); 621 622 622 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "Set buffer head timestamp for (%p) to %11llu => %11lld, NTS=%llu, DLL2=%f, RATE=%f\n", 623 623 this, new_timestamp, ts, m_buffer_next_tail_timestamp, m_dll_e2, m_nominal_rate); … … 627 627 /** 628 628 * \brief return the timestamp of the first frame in the buffer 629 * 629 * 630 630 * This function returns the timestamp of the very first sample in 631 * the StreamProcessor's buffer. It also returns the framecounter value 631 * the StreamProcessor's buffer. It also returns the framecounter value 632 632 * for which this timestamp is valid. 633 633 * … … 644 644 /** 645 645 * \brief return the timestamp of the last frame in the buffer 646 * 646 * 647 647 * This function returns the timestamp of the last frame in 648 * the StreamProcessor's buffer. It also returns the framecounter 648 * the StreamProcessor's buffer. It also returns the framecounter 649 649 * value for which this timestamp is valid. 650 650 * … … 662 662 * @brief Get timestamp for a specific position from the buffer tail 663 663 * 664 * Returns the timestamp for a position that is nframes earlier than the 664 * Returns the timestamp for a position that is nframes earlier than the 665 665 * buffer tail 666 666 * … … 672 672 // ts(x) = m_buffer_tail_timestamp - 673 673 // (m_buffer_next_tail_timestamp - m_buffer_tail_timestamp)/(samples_between_updates)*(x) 674 674 675 675 int64_t diff=m_buffer_next_tail_timestamp - m_buffer_tail_timestamp; 676 676 if (diff < 0) diff += m_wrap_at; 677 677 678 678 float rate=(float)diff / (float)m_update_period; 679 679 680 680 int64_t timestamp; 681 681 682 682 pthread_mutex_lock(&m_framecounter_lock); 683 683 … … 685 685 686 686 pthread_mutex_unlock(&m_framecounter_lock); 687 687 688 688 if(timestamp >= (int64_t)m_wrap_at) { 689 689 timestamp -= m_wrap_at; … … 691 691 timestamp += m_wrap_at; 692 692 } 693 693 694 694 return (uint64_t)timestamp; 695 695 } … … 698 698 * @brief Get timestamp for a specific position from the buffer head 699 699 * 700 * Returns the timestamp for a position that is nframes later than the 700 * Returns the timestamp for a position that is nframes later than the 701 701 * buffer head 702 702 * … … 721 721 /** 722 722 * Decrements the frame counter in a thread safe way. 723 * 723 * 724 724 * @param nbframes number of frames to decrement 725 725 */ … … 741 741 */ 742 742 void TimestampedBuffer::incrementFrameCounter(int nbframes, uint64_t new_timestamp) { 743 743 744 744 // add the offsets 745 745 int64_t diff=m_buffer_next_tail_timestamp - m_buffer_tail_timestamp; 746 746 if (diff < 0) diff += m_wrap_at; 747 747 748 #ifdef DEBUG 748 749 float rate=(float)diff / (float)m_update_period; 749 750 #endif 751 750 752 int64_t ts=new_timestamp; 751 753 ts += (int64_t)m_tick_offset; 752 754 753 755 if (ts >= (int64_t)m_wrap_at) { 754 756 ts -= m_wrap_at; … … 756 758 ts += m_wrap_at; 757 759 } 758 760 759 761 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "Setting buffer tail timestamp for (%p) to %11llu => %11lld\n", 760 762 this, new_timestamp, ts); 761 763 762 764 #ifdef DEBUG 763 765 if (new_timestamp >= m_wrap_at) { 764 766 debugWarning("timestamp not wrapped: %llu\n",new_timestamp); 765 } 767 } 766 768 if ((ts >= (int64_t)m_wrap_at) || (ts < 0 )) { 767 769 debugWarning("ts not wrapped correctly: %lld\n",ts); … … 771 773 // update the DLL 772 774 diff = ts-(int64_t)m_buffer_next_tail_timestamp; 773 775 774 776 #ifdef DEBUG 775 777 if ((diff > 1000) || (diff < -1000)) { 776 debugWarning("(%p) difference rather large: %lld, %011lld, %011lld\n", 778 debugWarning("(%p) difference rather large: %lld, %011lld, %011lld\n", 777 779 this, diff, ts, m_buffer_next_tail_timestamp); 778 780 } … … 782 784 // diff = diff * nbframes/m_update_period 783 785 // m_buffer_next_tail_timestamp = m_buffer_tail_timestamp + diff 784 786 785 787 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "(%p): diff=%lld ", 786 788 this, diff); 787 789 788 790 // the maximal difference we can allow (64secs) 789 791 const int64_t max=m_wrap_at/2; 790 792 791 793 if(diff > max) { 792 794 diff -= m_wrap_at; … … 794 796 diff += m_wrap_at; 795 797 } 796 798 797 799 float err=diff; 798 800 799 801 debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, "diff2=%lld err=%f\n", 800 802 diff, err); 801 803 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "B: FC=%10u, TS=%011llu, NTS=%011llu\n", 802 804 m_framecounter, m_buffer_tail_timestamp, m_buffer_next_tail_timestamp); 803 805 804 806 pthread_mutex_lock(&m_framecounter_lock); 805 807 m_framecounter += nbframes; 806 808 807 809 m_buffer_tail_timestamp=m_buffer_next_tail_timestamp; 808 810 m_buffer_next_tail_timestamp += (int64_t)(m_dll_b * err + m_dll_e2); 809 811 810 812 m_dll_e2 += m_dll_c*err; 811 813 812 814 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "U: FC=%10u, TS=%011llu, NTS=%011llu\n", 813 815 m_framecounter, m_buffer_tail_timestamp, m_buffer_next_tail_timestamp); 814 816 815 817 if (m_buffer_next_tail_timestamp >= m_wrap_at) { 816 818 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "Unwrapping next tail timestamp: %011llu", 817 819 m_buffer_next_tail_timestamp); 818 820 819 821 m_buffer_next_tail_timestamp -= m_wrap_at; 820 822 821 823 debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, " => %011llu\n", 822 824 m_buffer_next_tail_timestamp); 823 825 824 826 } 825 827 826 828 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "A: TS=%011llu, NTS=%011llu, DLLe2=%f, RATE=%f\n", 827 829 m_buffer_tail_timestamp, m_buffer_next_tail_timestamp, m_dll_e2, rate); 828 830 829 831 pthread_mutex_unlock(&m_framecounter_lock); 830 832 831 833 if(m_buffer_tail_timestamp>=m_wrap_at) { 832 834 debugError("Wrapping failed for m_buffer_tail_timestamp! %011llu\n",m_buffer_tail_timestamp); 833 835 debugOutput(DEBUG_LEVEL_VERY_VERBOSE, " IN=%011lld, TS=%011llu, NTS=%011llu\n", 834 836 ts, m_buffer_tail_timestamp, m_buffer_next_tail_timestamp); 835 837 836 838 } 837 839 if(m_buffer_next_tail_timestamp>=m_wrap_at) { … … 840 842 ts, m_buffer_tail_timestamp, m_buffer_next_tail_timestamp); 841 843 } 842 844 843 845 // this DLL allows the calculation of any sample timestamp relative to the buffer tail, 844 846 // to the next period and beyond (through extrapolation) … … 846 848 // ts(x) = m_buffer_tail_timestamp + 847 849 // (m_buffer_next_tail_timestamp - m_buffer_tail_timestamp)/(samples_between_updates)*x 848 850 849 851 } 850 852 … … 853 855 */ 854 856 void TimestampedBuffer::dumpInfo() { 855 857 856 858 uint64_t ts_head, fc; 857 859 getBufferHeadTimestamp(&ts_head,&fc); 858 860 861 #ifdef DEBUG 859 862 int64_t diff=(int64_t)ts_head - (int64_t)m_buffer_tail_timestamp; 863 #endif 860 864 861 865 debugOutputShort( DEBUG_LEVEL_NORMAL, " TimestampedBuffer (%p) info:\n",this); trunk/libffado/src/libutil/TimestampedBuffer.h
r419 r445 2 2 3 3 /* 4 * F reeBobStreaming API5 * F reeBob= Firewire (pro-)audio for linux6 * 7 * http://f reebob.sf.net4 * FFADO Streaming API 5 * FFADO = Firewire (pro-)audio for linux 6 * 7 * http://ffado.sf.net 8 8 * 9 9 * Copyright (C) 2005,2006,2007 Pieter Palmers <pieterpalmers@users.sourceforge.net> … … 23 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 24 * 25 * 25 * 26 26 * 27 27 */ 28 #ifndef __F REEBOB_TIMESTAMPEDBUFFER__29 #define __F REEBOB_TIMESTAMPEDBUFFER__28 #ifndef __FFADO_TIMESTAMPEDBUFFER__ 29 #define __FFADO_TIMESTAMPEDBUFFER__ 30 30 31 31 #include "../debugmodule/debugmodule.h" … … 39 39 * \brief Class implementing a frame buffer that is time-aware 40 40 * 41 * This class implements a buffer that is time-aware. Whenever new frames 41 * This class implements a buffer that is time-aware. Whenever new frames 42 42 * are written to the buffer, the timestamp corresponding to the last frame 43 43 * in the buffer is updated. This allows to calculate the timestamp of any … … 50 50 * - event_size: the storage size of the events (in bytes) (setEventSize()) 51 51 * 52 * The total size of the buffer (in bytes) is at least 52 * The total size of the buffer (in bytes) is at least 53 53 * buff_size*events_per_frame*event_size. 54 54 * … … 63 63 * 64 64 * The TimestampedBuffer class is time unit agnostic. It can handle any time unit 65 * as long as it fits in a 64 bit unsigned integer. The buffer supports wrapped 65 * as long as it fits in a 64 bit unsigned integer. The buffer supports wrapped 66 66 * timestamps using (...). 67 67 * 68 * There are two methods of reading and writing to the buffer. 68 * There are two methods of reading and writing to the buffer. 69 69 * 70 70 * The first method uses conventional readFrames() and writeFrames() functions. 71 71 * 72 * The second method makes use of the TimestampedBufferClient interface. When a 72 * The second method makes use of the TimestampedBufferClient interface. When a 73 73 * TimestampedBuffer is created, it is required that a TimestampedBufferClient is 74 74 * registered. This client implements the processReadBlock and processWriteBlock 75 75 * functions. These are block processing 'callbacks' that allow zero-copy processing 76 76 * of the buffer contents. In order to initiate block processing, the 77 * blockProcessWriteFrames and blockProcessReadFrames functions are provided by 77 * blockProcessWriteFrames and blockProcessReadFrames functions are provided by 78 78 * TimestampedBuffer. 79 79 * … … 86 86 TimestampedBuffer(TimestampedBufferClient *); 87 87 virtual ~TimestampedBuffer(); 88 88 89 89 bool writeFrames(unsigned int nbframes, char *data, uint64_t ts); 90 90 bool readFrames(unsigned int nbframes, char *data); 91 91 92 92 bool blockProcessWriteFrames(unsigned int nbframes, int64_t ts); 93 93 bool blockProcessReadFrames(unsigned int nbframes); 94 94 95 95 bool init(); 96 96 bool prepare(); 97 97 bool reset(); 98 98 99 99 bool setEventSize(unsigned int s); 100 100 bool setEventsPerFrame(unsigned int s); 101 101 bool setBufferSize(unsigned int s); 102 102 unsigned int getBufferSize() {return m_buffer_size;}; 103 103 104 104 bool setWrapValue(uint64_t w); 105 105 106 106 unsigned int getBufferFill(); 107 107 108 108 // timestamp stuff 109 109 int getFrameCounter() {return m_framecounter;}; … … 111 111 void getBufferHeadTimestamp(uint64_t *ts, uint64_t *fc); 112 112 void getBufferTailTimestamp(uint64_t *ts, uint64_t *fc); 113 113 114 114 void setBufferTailTimestamp(uint64_t new_timestamp); 115 115 void setBufferHeadTimestamp(uint64_t new_timestamp); 116 116 117 117 uint64_t getTimestampFromTail(int nframes); 118 118 uint64_t getTimestampFromHead(int nframes); 119 119 120 120 // buffer offset stuff 121 121 /// return the tick offset value 122 122 signed int getTickOffset() {return m_tick_offset;}; 123 123 124 124 bool setFrameOffset(int nframes); 125 125 bool setTickOffset(int nframes); 126 126 127 127 // dll stuff 128 128 bool setNominalRate(float r); 129 129 float getRate(); 130 130 131 131 bool setUpdatePeriod(unsigned int t); 132 132 133 133 // misc stuff 134 134 void dumpInfo(); … … 142 142 protected: 143 143 144 f reebob_ringbuffer_t * m_event_buffer;144 ffado_ringbuffer_t * m_event_buffer; 145 145 char* m_cluster_buffer; 146 146 147 147 unsigned int m_event_size; // the size of one event 148 148 unsigned int m_events_per_frame; // the number of events in a frame … … 150 150 unsigned int m_bytes_per_frame; 151 151 unsigned int m_bytes_per_buffer; 152 152 153 153 uint64_t m_wrap_at; // value to wrap at 154 154 155 155 TimestampedBufferClient *m_Client; 156 156 157 157 DECLARE_DEBUG_MODULE; 158 158 159 159 private: 160 160 // the framecounter gives the number of frames in the buffer 161 161 signed int m_framecounter; 162 162 163 163 // the offset that define the timing of the buffer 164 164 signed int m_tick_offset; 165 165 166 166 // the buffer tail timestamp gives the timestamp of the last frame 167 167 // that was put into the buffer 168 168 uint64_t m_buffer_tail_timestamp; 169 169 uint64_t m_buffer_next_tail_timestamp; 170 170 171 171 // this mutex protects the access to the framecounter 172 172 // and the buffer head timestamp. … … 177 177 float m_dll_b; 178 178 float m_dll_c; 179 179 180 180 float m_nominal_rate; 181 181 unsigned int m_update_period; … … 197 197 } // end of namespace Util 198 198 199 #endif /* __F REEBOB_TIMESTAMPEDBUFFER__ */200 201 199 #endif /* __FFADO_TIMESTAMPEDBUFFER__ */ 200 201 trunk/libffado/src/libutil/unittests.cpp
r435 r445 1 1 /* unittests.cpp 2 * Copyright (C) 200 6,07by Daniel Wagner2 * Copyright (C) 2005-2007 by by Daniel Wagner 3 3 * 4 * This file is part of FreeBoB. 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 5 6 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * FFADO is based upon FreeBoB. 8 * 9 * FFADO is free software; you can redistribute it and/or modify 7 10 * it under the terms of the GNU General Public License as published by 8 11 * the Free Software Foundation; either version 2 of the License, or 9 12 * (at your option) any later version. 10 * F reeBoBis distributed in the hope that it will be useful,13 * FFADO is distributed in the hope that it will be useful, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the … … 14 17 * 15 18 * You should have received a copy of the GNU General Public License 16 * along with F reeBoB; if not, write to the Free Software19 * along with FFADO; if not, write to the Free Software 17 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 18 21 * MA 02111-1307 USA. … … 416 419 testOC() {}; 417 420 ~testOC() {}; 418 421 419 422 bool test() { 420 423 bool result=true; 421 424 422 425 Option op1=Option(); 423 426 result &= TEST_SHOULD_RETURN_FALSE(addOption(op1)); 424 427 425 428 op1=Option("option1"); 426 429 result &= TEST_SHOULD_RETURN_FALSE(addOption(op1)); … … 432 435 result &= TEST_SHOULD_RETURN_FALSE(hasOption(op1)); 433 436 434 437 435 438 op1=Option("option1", (int64_t)1); 436 439 result &= TEST_SHOULD_RETURN_TRUE(addOption(op1)); … … 440 443 result &= TEST_SHOULD_RETURN_FALSE(hasOption(op1)); 441 444 442 445 443 446 op1=Option("option1", (int64_t)(-1)); 444 447 result &= TEST_SHOULD_RETURN_TRUE(addOption(op1)); … … 447 450 result &= TEST_SHOULD_RETURN_FALSE(addOption(op2)); 448 451 449 452 450 453 op2=Option("option2", (double)(1.75)); 451 454 result &= TEST_SHOULD_RETURN_TRUE(addOption(op2)); … … 454 457 result &= TEST_SHOULD_RETURN_TRUE(addOption(op3)); 455 458 456 459 457 460 result &= TEST_SHOULD_RETURN_TRUE(countOptions() == 3); 458 461 … … 466 469 } 467 470 result &= TEST_SHOULD_RETURN_TRUE(i==3); 468 471 469 472 clearOptions(); 470 473 return result; 471 474 } 472 475 473 476 void prepare() { 474 477 Option op1=Option("option1", (int64_t)(-1)); … … 476 479 printf( "prepare: could not add valid option (3)\n" ); 477 480 } 478 481 479 482 Option op2=Option("option2", (double)(1.75)); 480 483 if(!addOption(op2)) { … … 494 497 testOC oc; 495 498 result &= TEST_SHOULD_RETURN_TRUE(oc.test()); 496 499 497 500 // now manipulate it externally 498 501 oc.prepare(); 499 502 500 503 result &= TEST_SHOULD_RETURN_TRUE(oc.hasOption("option1")); 501 504 result &= TEST_SHOULD_RETURN_TRUE(oc.hasOption("option2")); 502 505 result &= TEST_SHOULD_RETURN_TRUE(oc.hasOption("option3")); 503 506 result &= TEST_SHOULD_RETURN_FALSE(oc.hasOption("option4")); 504 507 505 508 oc.setOption("option1", 1024); 506 509 int tst; 507 510 result &= TEST_SHOULD_RETURN_TRUE(oc.getOption("option1", tst)); 508 511 result &= TEST_SHOULD_RETURN_TRUE(tst == 1024); 509 512 510 513 return result; 511 514 } trunk/libffado/src/Makefile.am
r435 r445 1 # Makefile.am - Makefile template 2 # Copyright (C) 2005,06 by Daniel Wagner. 3 # Copyright (C) 2006 by Pieter Palmers. 4 # 5 # This file is part of FreeBoB. 6 # 7 # FreeBoB is free software; you can redistribute it and/or modify 8 # it under the terms of the GNU General Public License as published by 9 # the Free Software Foundation; either version 2 of the License, or 10 # (at your option) any later version. 11 # FreeBoB is distributed in the hope that it will be useful, 1 # Makefile.am 2 # 3 # Copyright (C) 2005-2007 by Daniel Wagner. 4 # Copyright (C) 2005-2007 by Pieter Palmers. 5 # 6 # This file is part of FFADO. 7 # FFADO = Free Firewire (pro-)audio drivers for linux 8 # 9 # FFADO is based upon FreeBoB. 10 # 11 # FFADO is free software. 12 # 13 # you can redistribute and/or modify the library code 14 # under the terms of the GNU Lesser General Public License 15 # version 2.1, as published by the Free Software Foundation 16 # 17 # you can redistribute and/or modify the applications 18 # under the terms of the GNU General Public License 19 # version 2, as published by the Free Software Foundation 20 # 21 # FFADO is distributed in the hope that it will be useful, 12 22 # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 # GNU General Public License for more details. 15 # You should have received a copy of the GNU General Public License 16 # along with FreeBoB; if not, write to the Free Software 24 # GNU (Lesser) General Public License for more details. 25 # 26 # You should have received a copy of the GNU (Lesser) General Public License 27 # along with FFADO; if not, write to the Free Software 17 28 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 29 … … 23 34 -I$(top_srcdir) -I$(top_srcdir)/src 24 35 25 lib_LTLIBRARIES = libf reebob.la26 27 libf reebob_la_LDFLAGS = \36 lib_LTLIBRARIES = libffado.la 37 38 libffado_la_LDFLAGS = \ 28 39 -version-info $(LT_VERSION) $(LIBRAW1394_LIBS) \ 29 40 $(LIBIEC61883_LIBS) $(LIBAVC1394_LIBS) \ … … 31 42 -lpthread -lrt 32 43 33 libf reebob_la_LIBADD = -lrt44 libffado_la_LIBADD = -lrt 34 45 35 46 noinst_HEADERS = \ 36 libieee1394/configrom.h libieee1394/csr1212.h \37 libieee1394/ieee1394service.h libieee1394/ARMHandler.h \38 libieee1394/IEC61883.h \39 debugmodule/debugmodule.h \47 libieee1394/configrom.h libieee1394/csr1212.h \ 48 libieee1394/ieee1394service.h libieee1394/ARMHandler.h \ 49 libieee1394/IEC61883.h \ 50 debugmodule/debugmodule.h \ 40 51 devicemanager.h fbtypes.h iavdevice.h threads.h bebob/bebob_avdevice.h \ 41 52 bebob/bebob_avdevice_subunit.h bebob/bebob_avplug.h bebob/bebob_dl_bcd.h bebob/bebob_dl_codes.h \ … … 64 75 65 76 # common sources 66 libf reebob_la_SOURCES = \67 devicemanager.cpp \68 freebob.cpp \69 freebob_streaming.cpp \70 iavdevice.cpp \71 debugmodule/debugmodule.cpp \72 libavc/avc_connect.cpp \73 libavc/avc_definitions.cpp \74 libavc/avc_extended_cmd_generic.cpp \75 libavc/avc_extended_plug_info.cpp \76 libavc/avc_extended_stream_format.cpp \77 libavc/avc_extended_subunit_info.cpp \78 libavc/avc_function_block.cpp \79 libavc/avc_generic.cpp \80 libavc/avc_plug_info.cpp \81 libavc/avc_serialize.cpp \82 libavc/avc_signal_source.cpp \83 libavc/avc_subunit_info.cpp \84 libavc/avc_unit_info.cpp \85 libieee1394/ARMHandler.cpp \86 libieee1394/configrom.cpp \87 libieee1394/csr1212.c \88 libieee1394/ieee1394service.cpp \89 libieee1394/IEC61883.cpp \90 libosc/OscArgument.cpp \91 libosc/OscMessage.cpp \92 libosc/OscNode.cpp \93 libosc/OscResponse.cpp \94 libosc/OscServer.cpp \95 libstreaming/cip.c \96 libstreaming/IsoHandler.cpp \97 libstreaming/IsoHandlerManager.cpp \98 libstreaming/IsoStream.cpp \99 libstreaming/Port.cpp \100 libstreaming/PortManager.cpp \101 libstreaming/StreamProcessor.cpp \102 libstreaming/StreamProcessorManager.cpp \103 libutil/DelayLockedLoop.cpp \104 libutil/PacketBuffer.cpp \105 libutil/OptionContainer.cpp \106 libutil/PosixThread.cpp \107 libutil/ringbuffer.c \108 libutil/serialize.cpp \109 libutil/StreamStatistics.cpp \110 libutil/SystemTimeSource.cpp \111 libutil/Time.c \112 libutil/TimeSource.cpp \113 libutil/TimestampedBuffer.cpp77 libffado_la_SOURCES = \ 78 devicemanager.cpp \ 79 ffado.cpp \ 80 ffado_streaming.cpp \ 81 iavdevice.cpp \ 82 debugmodule/debugmodule.cpp \ 83 libavc/avc_connect.cpp \ 84 libavc/avc_definitions.cpp \ 85 libavc/avc_extended_cmd_generic.cpp \ 86 libavc/avc_extended_plug_info.cpp \ 87 libavc/avc_extended_stream_format.cpp \ 88 libavc/avc_extended_subunit_info.cpp \ 89 libavc/avc_function_block.cpp \ 90 libavc/avc_generic.cpp \ 91 libavc/avc_plug_info.cpp \ 92 libavc/avc_serialize.cpp \ 93 libavc/avc_signal_source.cpp \ 94 libavc/avc_subunit_info.cpp \ 95 libavc/avc_unit_info.cpp \ 96 libieee1394/ARMHandler.cpp \ 97 libieee1394/configrom.cpp \ 98 libieee1394/csr1212.c \ 99 libieee1394/ieee1394service.cpp \ 100 libieee1394/IEC61883.cpp \ 101 libosc/OscArgument.cpp \ 102 libosc/OscMessage.cpp \ 103 libosc/OscNode.cpp \ 104 libosc/OscResponse.cpp \ 105 libosc/OscServer.cpp \ 106 libstreaming/cip.c \ 107 libstreaming/IsoHandler.cpp \ 108 libstreaming/IsoHandlerManager.cpp \ 109 libstreaming/IsoStream.cpp \ 110 libstreaming/Port.cpp \ 111 libstreaming/PortManager.cpp \ 112 libstreaming/StreamProcessor.cpp \ 113 libstreaming/StreamProcessorManager.cpp \ 114 libutil/DelayLockedLoop.cpp \ 115 libutil/PacketBuffer.cpp \ 116 libutil/OptionContainer.cpp \ 117 libutil/PosixThread.cpp \ 118 libutil/ringbuffer.c \ 119 libutil/serialize.cpp \ 120 libutil/StreamStatistics.cpp \ 121 libutil/SystemTimeSource.cpp \ 122 libutil/Time.c \ 123 libutil/TimeSource.cpp \ 124 libutil/TimestampedBuffer.cpp 114 125 115 126 # class specific sources 116 127 bebob_src = \ 117 bebob/bebob_avdevice.cpp \118 bebob/bebob_avdevice_subunit.cpp \119 bebob/bebob_avplug.cpp \120 bebob/bebob_dl_bcd.cpp \121 bebob/bebob_dl_codes.cpp \122 bebob/bebob_dl_mgr.cpp \123 bebob/bebob_functionblock.cpp \124 maudio/maudio_avdevice.cpp128 bebob/bebob_avdevice.cpp \ 129 bebob/bebob_avdevice_subunit.cpp \ 130 bebob/bebob_avplug.cpp \ 131 bebob/bebob_dl_bcd.cpp \ 132 bebob/bebob_dl_codes.cpp \ 133 bebob/bebob_dl_mgr.cpp \ 134 bebob/bebob_functionblock.cpp \ 135 maudio/maudio_avdevice.cpp 125 136 126 137 motu_src = \ 127 motu/motu_avdevice.cpp \128 libstreaming/MotuPort.cpp \129 libstreaming/MotuPortInfo.cpp \130 libstreaming/MotuStreamProcessor.cpp138 motu/motu_avdevice.cpp \ 139 libstreaming/MotuPort.cpp \ 140 libstreaming/MotuPortInfo.cpp \ 141 libstreaming/MotuStreamProcessor.cpp 131 142 132 143 dice_src = \ 133 dice/dice_avdevice.cpp144 dice/dice_avdevice.cpp 134 145 135 146 bounce_src = \ 136 bounce/bounce_avdevice.cpp \137 bounce/bounce_slave_avdevice.cpp \138 libstreaming/AmdtpSlaveStreamProcessor.cpp147 bounce/bounce_avdevice.cpp \ 148 bounce/bounce_slave_avdevice.cpp \ 149 libstreaming/AmdtpSlaveStreamProcessor.cpp 139 150 140 151 metric_halo_src = \ 141 metrichalo/mh_avdevice.cpp152 metrichalo/mh_avdevice.cpp 142 153 143 154 rme_src = \ 144 rme/rme_avdevice.cpp155 rme/rme_avdevice.cpp 145 156 146 157 amdtp_src = \ 147 libstreaming/AmdtpPort.cpp \148 libstreaming/AmdtpPortInfo.cpp \149 libstreaming/AmdtpStreamProcessor.cpp158 libstreaming/AmdtpPort.cpp \ 159 libstreaming/AmdtpPortInfo.cpp \ 160 libstreaming/AmdtpStreamProcessor.cpp 150 161 151 162 # data … … 163 174 164 175 # class specific 165 bebob_bin = freebob-downloader freebob-sync166 167 freebob_downloader_SOURCES = freebob-downloader.cpp168 freebob_downloader_LDADD = $(top_builddir)/src/libfreebob.la169 170 freebob_sync_SOURCES = freebob-sync.cpp171 freebob_sync_LDADD = $(top_builddir)/src/libfreebob.la176 bebob_bin = bridgeco-downloader bebob-sync 177 178 bridgeco_downloader_SOURCES = bridgeco-downloader.cpp 179 bridgeco_downloader_LDADD = $(top_builddir)/src/libffado.la 180 181 bebob_sync_SOURCES = bebob-sync.cpp 182 bebob_sync_LDADD = $(top_builddir)/src/libffado.la 172 183 173 184 # programs not intended for installation 174 185 # generic 175 186 noinst_PROGRAMS = test-dll test-debugmodule \ 176 test-unittests-util test-unittests-osc \177 test-ser187 test-unittests-util test-unittests-osc \ 188 test-ser 178 189 179 190 test_dll_SOURCES = libutil/test-dll.cpp 180 test_dll_LDADD = $(top_builddir)/src/libf reebob.la191 test_dll_LDADD = $(top_builddir)/src/libffado.la 181 192 182 193 test_debugmodule_SOURCES = debugmodule/test_debugmodule.cpp 183 test_debugmodule_LDADD = $(top_builddir)/src/libf reebob.la194 test_debugmodule_LDADD = $(top_builddir)/src/libffado.la 184 195 185 196 test_unittests_util_SOURCES = libutil/unittests.cpp 186 test_unittests_util_LDADD = $(top_builddir)/src/libf reebob.la197 test_unittests_util_LDADD = $(top_builddir)/src/libffado.la 187 198 188 199 test_unittests_osc_SOURCES = libosc/unittests.cpp 189 test_unittests_osc_LDADD = $(top_builddir)/src/libf reebob.la200 test_unittests_osc_LDADD = $(top_builddir)/src/libffado.la 190 201 191 202 test_ser_SOURCES = ser.cpp 192 test_ser_LDADD = $(top_builddir)/src/libf reebob.la203 test_ser_LDADD = $(top_builddir)/src/libffado.la 193 204 194 205 # build customisation 195 206 196 207 if BUILD_BEBOB 197 libf reebob_la_SOURCES += $(bebob_src)208 libffado_la_SOURCES += $(bebob_src) 198 209 bin_PROGRAMS += $(bebob_bin) 199 210 noinst_PROGRAMS += $(bebob_noinst) … … 202 213 203 214 if BUILD_BOUNCE 204 libf reebob_la_SOURCES += $(bounce_src)215 libffado_la_SOURCES += $(bounce_src) 205 216 bin_PROGRAMS += $(bounce_bin) 206 217 noinst_PROGRAMS += $(bounce_noinst) … … 209 220 210 221 if BUILD_DICE 211 libf reebob_la_SOURCES += $(dice_src)222 libffado_la_SOURCES += $(dice_src) 212 223 bin_PROGRAMS += $(dice_bin) 213 224 noinst_PROGRAMS += $(dice_noinst) … … 216 227 217 228 if BUILD_MOTU 218 libf reebob_la_SOURCES += $(motu_src)229 libffado_la_SOURCES += $(motu_src) 219 230 bin_PROGRAMS += $(motu_bin) 220 231 noinst_PROGRAMS += $(motu_noinst) … … 223 234 224 235 if BUILD_METRIC_HALO 225 libf reebob_la_SOURCES += $(metric_halo_src)236 libffado_la_SOURCES += $(metric_halo_src) 226 237 bin_PROGRAMS += $(metric_halo_bin) 227 238 noinst_PROGRAMS += $(metric_halo_noinst) … … 230 241 231 242 if BUILD_RME 232 libf reebob_la_SOURCES += $(rme_src)243 libffado_la_SOURCES += $(rme_src) 233 244 bin_PROGRAMS += $(rme_bin) 234 245 noinst_PROGRAMS += $(rme_noinst) … … 237 248 238 249 if BUILD_AMDTP 239 libf reebob_la_SOURCES += $(amdtp_src)250 libffado_la_SOURCES += $(amdtp_src) 240 251 bin_PROGRAMS += $(amdtp_bin) 241 252 noinst_PROGRAMS += $(amdtp_noinst) trunk/libffado/src/maudio/fw410.xml
r303 r445 1 1 <?xml version="1.0"?> 2 <F reeBoBConnectionInfo>2 <FFADOConnectionInfo> 3 3 <Device> 4 4 <NodeId>0</NodeId> … … 257 257 </StreamFormats> 258 258 </Device> 259 </F reeBoBConnectionInfo>259 </FFADOConnectionInfo> trunk/libffado/src/maudio/fwap.xml
r339 r445 1 1 <?xml version="1.0"?> 2 <F reeBoBConnectionInfo>2 <FFADOConnectionInfo> 3 3 <Device> 4 4 <NodeId>0</NodeId> … … 155 155 </StreamFormats> 156 156 </Device> 157 </F reeBoBConnectionInfo>157 </FFADOConnectionInfo> trunk/libffado/src/maudio/maudio_avdevice.cpp
r436 r445 1 /* maudio_avdevice.cpp2 * Copyright (C) 200 6by Daniel Wagner1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 3 * 4 * This file is part of FreeBoB. 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 5 6 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 14 17 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 23 20 24 #include "maudio/maudio_avdevice.h" 21 25 #include "bebob/bebob_avdevice.h" … … 91 95 { 92 96 if ( ( supportedDeviceList[i].vendor_id == vendorId ) 93 && ( supportedDeviceList[i].model_id == modelId ) 97 && ( supportedDeviceList[i].model_id == modelId ) 94 98 ) 95 99 { … … 103 107 m_model->vendor_name, m_model->model_name); 104 108 } else return false; 105 109 106 110 return true; 107 111 } trunk/libffado/src/maudio/maudio_avdevice.h
r436 r445 1 /* maudioe_avdevice.h 2 * Copyright (C) 2006 by Daniel Wagner 1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 * Copyright (C) 2005-2007 by Pieter Palmers 3 4 * 4 * This file is part of FreeBoB. 5 * This file is part of FFADO 6 * FFADO = Free Firewire (pro-)audio drivers for linux 5 7 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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, 11 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * Lesser General Public License for more details. 14 18 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 23 */ 20 24 … … 43 47 unsigned int model_id; 44 48 char *vendor_name; 45 char *model_name; 49 char *model_name; 46 50 char *filename; 47 51 }; … … 50 54 public: 51 55 AvDevice( std::auto_ptr<ConfigRom>( configRom ), 52 Ieee1394Service& ieee1394Service,56 Ieee1394Service& ieee1394Service, 53 57 int nodeId ); 54 58 virtual ~AvDevice(); … … 56 60 static bool probe( ConfigRom& configRom ); 57 61 bool discover(); 58 62 59 63 void showDevice(); 60 64 61 65 bool setSamplingFrequency( ESamplingFrequency samplingFrequency ); 62 66 int getSamplingFrequency( ); trunk/libffado/src/maudio/refdesign.xml
r298 r445 1 1 <?xml version="1.0"?> 2 <F reeBoBConnectionInfo>2 <FFADOConnectionInfo> 3 3 <Device> 4 4 <NodeId>1</NodeId> … … 190 190 </StreamFormats> 191 191 </Device> 192 </F reeBoBConnectionInfo>192 </FFADOConnectionInfo> trunk/libffado/src/metrichalo/mh_avdevice.cpp
r436 r445 1 /* mh_avdevice.cpp2 * Copyright (C) 200 7 by Pieter Palmers1 /* 2 * Copyright (C) 2005-2007 by Pieter Palmers 3 3 * 4 * This file is part of FreeBob. 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 5 6 * 6 * FreeBob is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBob is distributed in the hope that it will be useful, 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 14 17 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBob; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 … … 52 55 : IAvDevice( configRom, ieee1394service, nodeId ) 53 56 , m_model( NULL ) 54 57 55 58 { 56 59 debugOutput( DEBUG_LEVEL_VERBOSE, "Created MetricHalo::MHAvDevice (NodeID %d)\n", … … 74 77 { 75 78 if ( ( supportedDeviceList[i].vendor_id == vendorId ) 76 && ( supportedDeviceList[i].model_id == modelId ) 79 && ( supportedDeviceList[i].model_id == modelId ) 77 80 ) 78 81 { … … 95 98 { 96 99 if ( ( supportedDeviceList[i].vendor_id == vendorId ) 97 && ( supportedDeviceList[i].model_id == modelId ) 100 && ( supportedDeviceList[i].model_id == modelId ) 98 101 ) 99 102 { … … 111 114 } 112 115 113 int 116 int 114 117 MHAvDevice::getSamplingFrequency( ) { 115 118 return 0; … … 150 153 } 151 154 152 int 155 int 153 156 MHAvDevice::getStreamCount() { 154 157 return 0; trunk/libffado/src/metrichalo/mh_avdevice.h
r436 r445 1 /* mh_avdevice.h2 * Copyright (C) 200 7 by Pieter Palmers1 /* 2 * Copyright (C) 2005-2007 by Pieter Palmers 3 3 * 4 * This file is part of FreeBob. 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 5 6 * 6 * FreeBob is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBob is distributed in the hope that it will be useful, 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 14 17 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBob; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 … … 45 48 public: 46 49 MHAvDevice( std::auto_ptr<ConfigRom>( configRom ), 47 Ieee1394Service& ieee1394Service,48 int nodeId );50 Ieee1394Service& ieee1394Service, 51 int nodeId ); 49 52 virtual ~MHAvDevice(); 50 53 … … 69 72 signed int getIsoRecvChannel(void); 70 73 signed int getIsoSendChannel(void); 71 74 72 75 protected: 73 76 struct VendorModelEntry *m_model; trunk/libffado/src/motu/motu_avdevice.cpp
r436 r445 1 /* motu_avdevice.cpp2 * Copyright (C) 200 6,2007 by Pieter Palmers3 * Copyright (C) 200 6by Jonathan Woithe1 /* 2 * Copyright (C) 2005-2007 by Pieter Palmers 3 * Copyright (C) 2005-2007 by Jonathan Woithe 4 4 * 5 * This file is part of FreeBob. 5 * This file is part of FFADO 6 * FFADO = Free Firewire (pro-)audio drivers for linux 6 7 * 7 * FreeBob is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * FreeBob is distributed in the hope that it will be useful, 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, 12 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNUGeneral Public License for more details.16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * Lesser General Public License for more details. 15 18 * 16 * You should have received a copy of the GNU General Public License17 * along with FreeBob; if not, write to the Free Software18 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,19 * MA 0211 1-1307 USA.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 20 23 */ 24 21 25 #include "motu/motu_avdevice.h" 22 26 … … 62 66 , m_receiveProcessor ( 0 ) 63 67 , m_transmitProcessor ( 0 ) 64 68 65 69 { 66 70 debugOutput( DEBUG_LEVEL_VERBOSE, "Created Motu::MotuDevice (NodeID %d)\n", … … 95 99 { 96 100 if ( ( supportedDeviceList[i].vendor_id == vendorId ) 97 // && ( supportedDeviceList[i].model_id == modelId ) 98 && ( supportedDeviceList[i].unit_version == unitVersion ) 99 && ( supportedDeviceList[i].unit_specifier_id == unitSpecifierId ) 101 // && ( supportedDeviceList[i].model_id == modelId ) 102 && ( supportedDeviceList[i].unit_version == unitVersion ) 103 && ( supportedDeviceList[i].unit_specifier_id == unitSpecifierId ) 100 104 ) 101 105 { … … 120 124 { 121 125 if ( ( supportedDeviceList[i].vendor_id == vendorId ) 122 // && ( supportedDeviceList[i].model_id == modelId ) 123 && ( supportedDeviceList[i].unit_version == unitVersion ) 124 && ( supportedDeviceList[i].unit_specifier_id == unitSpecifierId ) 126 // && ( supportedDeviceList[i].model_id == modelId ) 127 && ( supportedDeviceList[i].unit_version == unitVersion ) 128 && ( supportedDeviceList[i].unit_specifier_id == unitSpecifierId ) 125 129 ) 126 130 { … … 139 143 } 140 144 141 int 145 int 142 146 MotuDevice::getSamplingFrequency( ) { 143 147 /* 144 148 * Retrieve the current sample rate from the MOTU device. 145 149 */ 146 quadlet_t q = ReadRegister(MOTUFW_REG_CLK_CTRL);147 int rate = 0;148 149 switch (q & MOTUFW_RATE_BASE_MASK) {150 case MOTUFW_RATE_BASE_44100:151 rate = 44100;152 break;153 case MOTUFW_RATE_BASE_48000:154 rate = 48000;155 break;156 }157 switch (q & MOTUFW_RATE_MULTIPLIER_MASK) {158 case MOTUFW_RATE_MULTIPLIER_2X:159 rate *= 2;160 break;161 case MOTUFW_RATE_MULTIPLIER_4X:162 rate *= 4;163 break;164 }165 return rate;150 quadlet_t q = ReadRegister(MOTUFW_REG_CLK_CTRL); 151 int rate = 0; 152 153 switch (q & MOTUFW_RATE_BASE_MASK) { 154 case MOTUFW_RATE_BASE_44100: 155 rate = 44100; 156 break; 157 case MOTUFW_RATE_BASE_48000: 158 rate = 48000; 159 break; 160 } 161 switch (q & MOTUFW_RATE_MULTIPLIER_MASK) { 162 case MOTUFW_RATE_MULTIPLIER_2X: 163 rate *= 2; 164 break; 165 case MOTUFW_RATE_MULTIPLIER_4X: 166 rate *= 4; 167 break; 168 } 169 return rate; 166 170 } 167 171 … … 172 176 * Set the MOTU device's samplerate. 173 177 */ 174 char *src_name;175 quadlet_t q, new_rate=0;176 int i, supported=true, cancel_adat=false;177 178 switch ( samplingFrequency ) {179 case eSF_22050Hz:180 supported=false;181 break;182 case eSF_24000Hz:183 supported=false;184 break;185 case eSF_32000Hz:186 supported=false;187 break;188 case eSF_44100Hz:189 new_rate = MOTUFW_RATE_BASE_44100 | MOTUFW_RATE_MULTIPLIER_1X;190 break;191 case eSF_48000Hz:192 new_rate = MOTUFW_RATE_BASE_48000 | MOTUFW_RATE_MULTIPLIER_1X;193 break;194 case eSF_88200Hz:195 new_rate = MOTUFW_RATE_BASE_44100 | MOTUFW_RATE_MULTIPLIER_2X;196 break;197 case eSF_96000Hz:198 new_rate = MOTUFW_RATE_BASE_48000 | MOTUFW_RATE_MULTIPLIER_2X;199 break;200 case eSF_176400Hz:201 // Currently only the Traveler supports 4x sample rates202 if (m_motu_model == MOTUFW_MODEL_TRAVELER) {203 new_rate = MOTUFW_RATE_BASE_44100 | MOTUFW_RATE_MULTIPLIER_4X;204 cancel_adat = true;205 } else206 supported=false;207 break;208 case eSF_192000Hz:209 // Currently only the Traveler supports 4x sample rates210 if (m_motu_model == MOTUFW_MODEL_TRAVELER) {211 new_rate = MOTUFW_RATE_BASE_48000 | MOTUFW_RATE_MULTIPLIER_4X;212 cancel_adat = true;213 } else214 supported=false;215 break;216 default:217 supported=false;218 }219 220 // Update the clock control register. FIXME: while this is now rather221 // comprehensive there may still be a need to manipulate MOTUFW_REG_CLK_CTRL222 // a little more than we do.223 if (supported) {224 quadlet_t value=ReadRegister(MOTUFW_REG_CLK_CTRL);225 226 // If optical port must be disabled (because a 4x sample rate has227 // been selected) then do so before changing the sample rate. At228 // this stage it will be up to the user to re-enable the optical229 // port if the sample rate is set to a 1x or 2x rate later.230 if (cancel_adat) {231 setOpticalMode(MOTUFW_DIR_INOUT, MOTUFW_OPTICAL_MODE_OFF);232 }233 234 value &= ~(MOTUFW_RATE_BASE_MASK|MOTUFW_RATE_MULTIPLIER_MASK);235 value |= new_rate;236 237 // In other OSes bit 26 of MOTUFW_REG_CLK_CTRL always seems238 // to be set when this register is written to although the239 // reason isn't currently known. When we set it, it appears240 // to prevent output being produced so we'll leave it unset241 // until we work out what's going on. Other systems write242 // to MOTUFW_REG_CLK_CTRL multiple times, so that may be243 // part of the mystery.244 // value |= 0x04000000;245 if (WriteRegister(MOTUFW_REG_CLK_CTRL, value) == 0) {246 supported=true;247 } else {248 supported=false;249 }250 // A write to the rate/clock control register requires the 251 // textual name of the current clock source be sent to the 252 // clock source name registers.253 switch (value & MOTUFW_CLKSRC_MASK) {254 case MOTUFW_CLKSRC_INTERNAL:255 src_name = "Internal ";256 break;257 case MOTUFW_CLKSRC_ADAT_OPTICAL:258 src_name = "ADAT Optical ";259 break;260 case MOTUFW_CLKSRC_SPDIF_TOSLINK:261 if (getOpticalMode(MOTUFW_DIR_IN) == MOTUFW_OPTICAL_MODE_TOSLINK)262 src_name = "TOSLink ";263 else264 src_name = "SPDIF ";265 break;266 case MOTUFW_CLKSRC_SMTPE:267 src_name = "SMPTE ";268 break;269 case MOTUFW_CLKSRC_WORDCLOCK:270 src_name = "Word Clock In ";271 break;272 case MOTUFW_CLKSRC_ADAT_9PIN:273 src_name = "ADAT 9-pin ";274 break;275 case MOTUFW_CLKSRC_AES_EBU:276 src_name = "AES-EBU ";277 break;278 default:279 src_name = "Unknown ";280 }281 for (i=0; i<16; i+=4) {282 q = (src_name[i]<<24) | (src_name[i+1]<<16) | 283 (src_name[i+2]<<8) | src_name[i+3];284 WriteRegister(MOTUFW_REG_CLKSRC_NAME0+i, q);285 }286 }287 return supported;178 char *src_name; 179 quadlet_t q, new_rate=0; 180 int i, supported=true, cancel_adat=false; 181 182 switch ( samplingFrequency ) { 183 case eSF_22050Hz: 184 supported=false; 185 break; 186 case eSF_24000Hz: 187 supported=false; 188 break; 189 case eSF_32000Hz: 190 supported=false; 191 break; 192 case eSF_44100Hz: 193 new_rate = MOTUFW_RATE_BASE_44100 | MOTUFW_RATE_MULTIPLIER_1X; 194 break; 195 case eSF_48000Hz: 196 new_rate = MOTUFW_RATE_BASE_48000 | MOTUFW_RATE_MULTIPLIER_1X; 197 break; 198 case eSF_88200Hz: 199 new_rate = MOTUFW_RATE_BASE_44100 | MOTUFW_RATE_MULTIPLIER_2X; 200 break; 201 case eSF_96000Hz: 202 new_rate = MOTUFW_RATE_BASE_48000 | MOTUFW_RATE_MULTIPLIER_2X; 203 break; 204 case eSF_176400Hz: 205 // Currently only the Traveler supports 4x sample rates 206 if (m_motu_model == MOTUFW_MODEL_TRAVELER) { 207 new_rate = MOTUFW_RATE_BASE_44100 | MOTUFW_RATE_MULTIPLIER_4X; 208 cancel_adat = true; 209 } else 210 supported=false; 211 break; 212 case eSF_192000Hz: 213 // Currently only the Traveler supports 4x sample rates 214 if (m_motu_model == MOTUFW_MODEL_TRAVELER) { 215 new_rate = MOTUFW_RATE_BASE_48000 | MOTUFW_RATE_MULTIPLIER_4X; 216 cancel_adat = true; 217 } else 218 supported=false; 219 break; 220 default: 221 supported=false; 222 } 223 224 // Update the clock control register. FIXME: while this is now rather 225 // comprehensive there may still be a need to manipulate MOTUFW_REG_CLK_CTRL 226 // a little more than we do. 227 if (supported) { 228 quadlet_t value=ReadRegister(MOTUFW_REG_CLK_CTRL); 229 230 // If optical port must be disabled (because a 4x sample rate has 231 // been selected) then do so before changing the sample rate. At 232 // this stage it will be up to the user to re-enable the optical 233 // port if the sample rate is set to a 1x or 2x rate later. 234 if (cancel_adat) { 235 setOpticalMode(MOTUFW_DIR_INOUT, MOTUFW_OPTICAL_MODE_OFF); 236 } 237 238 value &= ~(MOTUFW_RATE_BASE_MASK|MOTUFW_RATE_MULTIPLIER_MASK); 239 value |= new_rate; 240 241 // In other OSes bit 26 of MOTUFW_REG_CLK_CTRL always seems 242 // to be set when this register is written to although the 243 // reason isn't currently known. When we set it, it appears 244 // to prevent output being produced so we'll leave it unset 245 // until we work out what's going on. Other systems write 246 // to MOTUFW_REG_CLK_CTRL multiple times, so that may be 247 // part of the mystery. 248 // value |= 0x04000000; 249 if (WriteRegister(MOTUFW_REG_CLK_CTRL, value) == 0) { 250 supported=true; 251 } else { 252 supported=false; 253 } 254 // A write to the rate/clock control register requires the 255 // textual name of the current clock source be sent to the 256 // clock source name registers. 257 switch (value & MOTUFW_CLKSRC_MASK) { 258 case MOTUFW_CLKSRC_INTERNAL: 259 src_name = "Internal "; 260 break; 261 case MOTUFW_CLKSRC_ADAT_OPTICAL: 262 src_name = "ADAT Optical "; 263 break; 264 case MOTUFW_CLKSRC_SPDIF_TOSLINK: 265 if (getOpticalMode(MOTUFW_DIR_IN) == MOTUFW_OPTICAL_MODE_TOSLINK) 266 src_name = "TOSLink "; 267 else 268 src_name = "SPDIF "; 269 break; 270 case MOTUFW_CLKSRC_SMTPE: 271 src_name = "SMPTE "; 272 break; 273 case MOTUFW_CLKSRC_WORDCLOCK: 274 src_name = "Word Clock In "; 275 break; 276 case MOTUFW_CLKSRC_ADAT_9PIN: 277 src_name = "ADAT 9-pin "; 278 break; 279 case MOTUFW_CLKSRC_AES_EBU: 280 src_name = "AES-EBU "; 281 break; 282 default: 283 src_name = "Unknown "; 284 } 285 for (i=0; i<16; i+=4) { 286 q = (src_name[i]<<24) | (src_name[i+1]<<16) | 287 (src_name[i+2]<<8) | src_name[i+3]; 288 WriteRegister(MOTUFW_REG_CLKSRC_NAME0+i, q); 289 } 290 } 291 return supported; 288 292 } 289 293 … … 312 316 MotuDevice::prepare() { 313 317 314 int samp_freq = getSamplingFrequency();315 unsigned int optical_in_mode = getOpticalMode(MOTUFW_DIR_IN);316 unsigned int optical_out_mode = getOpticalMode(MOTUFW_DIR_OUT);317 unsigned int event_size_in = getEventSize(MOTUFW_DIR_IN);318 unsigned int event_size_out= getEventSize(MOTUFW_DIR_OUT);319 320 debugOutput(DEBUG_LEVEL_NORMAL, "Preparing MotuDevice...\n" );321 322 // Allocate bandwidth if not previously done.323 // FIXME: The bandwidth allocation calculation can probably be324 // refined somewhat since this is currently based on a rudimentary325 // understanding of the iso protocol.326 // Currently we assume the following.327 // * Ack/iso gap = 0.05 us328 // * DATA_PREFIX = 0.16 us329 // * DATA_END = 0.26 us330 // These numbers are the worst-case figures given in the ieee1394331 // standard. This gives approximately 0.5 us of overheads per332 // packet - around 25 bandwidth allocation units (from the ieee1394333 // standard 1 bandwidth allocation unit is 125/6144 us). We further334 // assume the MOTU is running at S400 (which it should be) so one335 // allocation unit is equivalent to 1 transmitted byte; thus the336 // bandwidth allocation required for the packets themselves is just337 // the size of the packet. We allocate based on the maximum packet338 // size (1160 bytes at 192 kHz) so the sampling frequency can be339 // changed dynamically if this ends up being useful in future.340 // Therefore we get a *per stream* bandwidth figure of 25+1160.341 m_bandwidth = 25 + 1160;342 343 // Assign iso channels if not already done344 if (m_iso_recv_channel < 0)345 m_iso_recv_channel = m_p1394Service->allocateIsoChannelGeneric(m_bandwidth);346 347 if (m_iso_send_channel < 0)348 m_iso_send_channel = m_p1394Service->allocateIsoChannelGeneric(m_bandwidth);349 350 debugOutput(DEBUG_LEVEL_VERBOSE, "recv channel = %d, send channel = %d\n",351 m_iso_recv_channel, m_iso_send_channel);352 353 if (m_iso_recv_channel<0 || m_iso_send_channel<0) {354 // be nice and deallocate355 if (m_iso_recv_channel >= 0)356 m_p1394Service->freeIsoChannel(m_iso_recv_channel);357 if (m_iso_send_channel >= 0)358 m_p1394Service->freeIsoChannel(m_iso_send_channel);359 360 debugFatal("Could not allocate iso channels!\n");361 return false;362 }363 364 m_receiveProcessor=new Streaming::MotuReceiveStreamProcessor(365 m_p1394Service->getPort(), samp_freq, event_size_in);366 367 // The first thing is to initialize the processor. This creates the368 // data structures.369 if(!m_receiveProcessor->init()) {370 debugFatal("Could not initialize receive processor!\n");371 return false;372 }373 m_receiveProcessor->setVerboseLevel(getDebugLevel());374 375 // Now we add ports to the processor376 debugOutput(DEBUG_LEVEL_VERBOSE,"Adding ports to receive processor\n");377 378 char *buff;379 Streaming::Port *p=NULL;380 381 // retrieve the ID318 int samp_freq = getSamplingFrequency(); 319 unsigned int optical_in_mode = getOpticalMode(MOTUFW_DIR_IN); 320 unsigned int optical_out_mode = getOpticalMode(MOTUFW_DIR_OUT); 321 unsigned int event_size_in = getEventSize(MOTUFW_DIR_IN); 322 unsigned int event_size_out= getEventSize(MOTUFW_DIR_OUT); 323 324 debugOutput(DEBUG_LEVEL_NORMAL, "Preparing MotuDevice...\n" ); 325 326 // Allocate bandwidth if not previously done. 327 // FIXME: The bandwidth allocation calculation can probably be 328 // refined somewhat since this is currently based on a rudimentary 329 // understanding of the iso protocol. 330 // Currently we assume the following. 331 // * Ack/iso gap = 0.05 us 332 // * DATA_PREFIX = 0.16 us 333 // * DATA_END = 0.26 us 334 // These numbers are the worst-case figures given in the ieee1394 335 // standard. This gives approximately 0.5 us of overheads per 336 // packet - around 25 bandwidth allocation units (from the ieee1394 337 // standard 1 bandwidth allocation unit is 125/6144 us). We further 338 // assume the MOTU is running at S400 (which it should be) so one 339 // allocation unit is equivalent to 1 transmitted byte; thus the 340 // bandwidth allocation required for the packets themselves is just 341 // the size of the packet. We allocate based on the maximum packet 342 // size (1160 bytes at 192 kHz) so the sampling frequency can be 343 // changed dynamically if this ends up being useful in future. 344 // Therefore we get a *per stream* bandwidth figure of 25+1160. 345 m_bandwidth = 25 + 1160; 346 347 // Assign iso channels if not already done 348 if (m_iso_recv_channel < 0) 349 m_iso_recv_channel = m_p1394Service->allocateIsoChannelGeneric(m_bandwidth); 350 351 if (m_iso_send_channel < 0) 352 m_iso_send_channel = m_p1394Service->allocateIsoChannelGeneric(m_bandwidth); 353 354 debugOutput(DEBUG_LEVEL_VERBOSE, "recv channel = %d, send channel = %d\n", 355 m_iso_recv_channel, m_iso_send_channel); 356 357 if (m_iso_recv_channel<0 || m_iso_send_channel<0) { 358 // be nice and deallocate 359 if (m_iso_recv_channel >= 0) 360 m_p1394Service->freeIsoChannel(m_iso_recv_channel); 361 if (m_iso_send_channel >= 0) 362 m_p1394Service->freeIsoChannel(m_iso_send_channel); 363 364 debugFatal("Could not allocate iso channels!\n"); 365 return false; 366 } 367 368 m_receiveProcessor=new Streaming::MotuReceiveStreamProcessor( 369 m_p1394Service->getPort(), samp_freq, event_size_in); 370 371 // The first thing is to initialize the processor. This creates the 372 // data structures. 373 if(!m_receiveProcessor->init()) { 374 debugFatal("Could not initialize receive processor!\n"); 375 return false; 376 } 377 m_receiveProcessor->setVerboseLevel(getDebugLevel()); 378 379 // Now we add ports to the processor 380 debugOutput(DEBUG_LEVEL_VERBOSE,"Adding ports to receive processor\n"); 381 382 char *buff; 383 Streaming::Port *p=NULL; 384 385 // retrieve the ID 382 386 std::string id=std::string("dev?"); 383 387 if(!getOption("id", id)) { 384 388 debugWarning("Could not retrieve id parameter, defauling to 'dev?'\n"); 385 389 } 386 387 // Add audio capture ports388 if (!addDirPorts(Streaming::Port::E_Capture, samp_freq, optical_in_mode)) {389 return false;390 }391 392 // Add MIDI port. The MOTU only has one MIDI input port, with each393 // MIDI byte sent using a 3 byte sequence starting at byte 4 of the394 // event data.395 asprintf(&buff,"%s_cap_MIDI0",id.c_str());396 p = new Streaming::MotuMidiPort(buff,397 Streaming::Port::E_Capture, 4);398 if (!p) {399 debugOutput(DEBUG_LEVEL_VERBOSE, "Skipped port %s\n", buff);400 } else {401 if (!m_receiveProcessor->addPort(p)) {402 debugWarning("Could not register port with stream processor\n");403 free(buff);404 return false;405 } else {406 debugOutput(DEBUG_LEVEL_VERBOSE, "Added port %s\n", buff);407 }408 }409 free(buff);410 411 // example of adding an control port:390 391 // Add audio capture ports 392 if (!addDirPorts(Streaming::Port::E_Capture, samp_freq, optical_in_mode)) { 393 return false; 394 } 395 396 // Add MIDI port. The MOTU only has one MIDI input port, with each 397 // MIDI byte sent using a 3 byte sequence starting at byte 4 of the 398 // event data. 399 asprintf(&buff,"%s_cap_MIDI0",id.c_str()); 400 p = new Streaming::MotuMidiPort(buff, 401 Streaming::Port::E_Capture, 4); 402 if (!p) { 403 debugOutput(DEBUG_LEVEL_VERBOSE, "Skipped port %s\n", buff); 404 } else { 405 if (!m_receiveProcessor->addPort(p)) { 406 debugWarning("Could not register port with stream processor\n"); 407 free(buff); 408 return false; 409 } else { 410 debugOutput(DEBUG_LEVEL_VERBOSE, "Added port %s\n", buff); 411 } 412 } 413 free(buff); 414 415 // example of adding an control port: 412 416 // asprintf(&buff,"%s_cap_%s",id.c_str(),"myportnamehere"); 413 417 // p=new Streaming::MotuControlPort( 414 418 // buff, 415 // Streaming::Port::E_Capture, 416 // 0 // you can add all other port specific stuff you 419 // Streaming::Port::E_Capture, 420 // 0 // you can add all other port specific stuff you 417 421 // // need to pass by extending MotuXXXPort and MotuPortInfo 418 422 // ); … … 431 435 // } 432 436 433 // Do the same for the transmit processor434 m_transmitProcessor=new Streaming::MotuTransmitStreamProcessor(435 m_p1394Service->getPort(), getSamplingFrequency(), event_size_out);436 437 m_transmitProcessor->setVerboseLevel(getDebugLevel());438 439 if(!m_transmitProcessor->init()) {440 debugFatal("Could not initialize transmit processor!\n");441 return false;442 }443 444 // Now we add ports to the processor445 debugOutput(DEBUG_LEVEL_VERBOSE,"Adding ports to transmit processor\n");446 447 // Add audio playback ports448 if (!addDirPorts(Streaming::Port::E_Playback, samp_freq, optical_out_mode)) {449 return false;450 }451 452 // Add MIDI port. The MOTU only has one output MIDI port, with each453 // MIDI byte transmitted using a 3 byte sequence starting at byte 4454 // of the event data.455 asprintf(&buff,"%s_pbk_MIDI0",id.c_str());456 p = new Streaming::MotuMidiPort(buff,457 Streaming::Port::E_Capture, 4);458 if (!p) {459 debugOutput(DEBUG_LEVEL_VERBOSE, "Skipped port %s\n", buff);460 } else {461 if (!m_receiveProcessor->addPort(p)) {462 debugWarning("Could not register port with stream processor\n");463 free(buff);464 return false;465 } else {466 debugOutput(DEBUG_LEVEL_VERBOSE, "Added port %s\n", buff);467 }468 }469 free(buff);470 471 // example of adding an control port:437 // Do the same for the transmit processor 438 m_transmitProcessor=new Streaming::MotuTransmitStreamProcessor( 439 m_p1394Service->getPort(), getSamplingFrequency(), event_size_out); 440 441 m_transmitProcessor->setVerboseLevel(getDebugLevel()); 442 443 if(!m_transmitProcessor->init()) { 444 debugFatal("Could not initialize transmit processor!\n"); 445 return false; 446 } 447 448 // Now we add ports to the processor 449 debugOutput(DEBUG_LEVEL_VERBOSE,"Adding ports to transmit processor\n"); 450 451 // Add audio playback ports 452 if (!addDirPorts(Streaming::Port::E_Playback, samp_freq, optical_out_mode)) { 453 return false; 454 } 455 456 // Add MIDI port. The MOTU only has one output MIDI port, with each 457 // MIDI byte transmitted using a 3 byte sequence starting at byte 4 458 // of the event data. 459 asprintf(&buff,"%s_pbk_MIDI0",id.c_str()); 460 p = new Streaming::MotuMidiPort(buff, 461 Streaming::Port::E_Capture, 4); 462 if (!p) { 463 debugOutput(DEBUG_LEVEL_VERBOSE, "Skipped port %s\n", buff); 464 } else { 465 if (!m_receiveProcessor->addPort(p)) { 466 debugWarning("Could not register port with stream processor\n"); 467 free(buff); 468 return false; 469 } else { 470 debugOutput(DEBUG_LEVEL_VERBOSE, "Added port %s\n", buff); 471 } 472 } 473 free(buff); 474 475 // example of adding an control port: 472 476 // asprintf(&buff,"%s_pbk_%s",id.c_str(),"myportnamehere"); 473 // 477 // 474 478 // p=new Streaming::MotuControlPort( 475 479 // buff, 476 // Streaming::Port::E_Playback, 477 // 0 // you can add all other port specific stuff you 480 // Streaming::Port::E_Playback, 481 // 0 // you can add all other port specific stuff you 478 482 // // need to pass by extending MotuXXXPort and MotuPortInfo 479 483 // ); … … 490 494 // } 491 495 // } 492 493 return true;494 } 495 496 int 496 497 return true; 498 } 499 500 int 497 501 MotuDevice::getStreamCount() { 498 return 2; // one receive, one transmit502 return 2; // one receive, one transmit 499 503 } 500 504 501 505 Streaming::StreamProcessor * 502 506 MotuDevice::getStreamProcessorByIndex(int i) { 503 switch (i) {504 case 0:505 return m_receiveProcessor;506 case 1:507 return m_transmitProcessor;508 default:509 return NULL;510 }511 return 0;507 switch (i) { 508 case 0: 509 return m_receiveProcessor; 510 case 1: 511 return m_transmitProcessor; 512 default: 513 return NULL; 514 } 515 return 0; 512 516 } 513 517 … … 517 521 quadlet_t isoctrl = ReadRegister(MOTUFW_REG_ISOCTRL); 518 522 519 // NOTE: this assumes that you have two streams520 switch (i) {521 case 0:522 // TODO: do the stuff that is nescessary to make the device523 // receive a stream524 525 // Set the streamprocessor channel to the one obtained by 526 // the connection management527 m_receiveProcessor->setChannel(m_iso_recv_channel);528 529 // Mask out current transmit settings of the MOTU and replace530 // with new ones. Turn bit 24 on to enable changes to the531 // MOTU's iso transmit settings when the iso control register532 // is written. Bit 23 enables iso transmit from the MOTU.533 isoctrl &= 0xff00ffff;534 isoctrl |= (m_iso_recv_channel << 16);535 isoctrl |= 0x00c00000;536 WriteRegister(MOTUFW_REG_ISOCTRL, isoctrl);537 break;538 case 1:539 // TODO: do the stuff that is nescessary to make the device540 // transmit a stream541 542 // Set the streamprocessor channel to the one obtained by 543 // the connection management544 m_transmitProcessor->setChannel(m_iso_send_channel);545 546 // Mask out current receive settings of the MOTU and replace547 // with new ones. Turn bit 31 on to enable changes to the548 // MOTU's iso receive settings when the iso control register549 // is written. Bit 30 enables iso receive by the MOTU.550 isoctrl &= 0x00ffffff;551 isoctrl |= (m_iso_send_channel << 24);552 isoctrl |= 0xc0000000;553 WriteRegister(MOTUFW_REG_ISOCTRL, isoctrl);554 break;555 556 default: // Invalid stream index557 return false;558 }559 560 return true;523 // NOTE: this assumes that you have two streams 524 switch (i) { 525 case 0: 526 // TODO: do the stuff that is nescessary to make the device 527 // receive a stream 528 529 // Set the streamprocessor channel to the one obtained by 530 // the connection management 531 m_receiveProcessor->setChannel(m_iso_recv_channel); 532 533 // Mask out current transmit settings of the MOTU and replace 534 // with new ones. Turn bit 24 on to enable changes to the 535 // MOTU's iso transmit settings when the iso control register 536 // is written. Bit 23 enables iso transmit from the MOTU. 537 isoctrl &= 0xff00ffff; 538 isoctrl |= (m_iso_recv_channel << 16); 539 isoctrl |= 0x00c00000; 540 WriteRegister(MOTUFW_REG_ISOCTRL, isoctrl); 541 break; 542 case 1: 543 // TODO: do the stuff that is nescessary to make the device 544 // transmit a stream 545 546 // Set the streamprocessor channel to the one obtained by 547 // the connection management 548 m_transmitProcessor->setChannel(m_iso_send_channel); 549 550 // Mask out current receive settings of the MOTU and replace 551 // with new ones. Turn bit 31 on to enable changes to the 552 // MOTU's iso receive settings when the iso control register 553 // is written. Bit 30 enables iso receive by the MOTU. 554 isoctrl &= 0x00ffffff; 555 isoctrl |= (m_iso_send_channel << 24); 556 isoctrl |= 0xc0000000; 557 WriteRegister(MOTUFW_REG_ISOCTRL, isoctrl); 558 break; 559 560 default: // Invalid stream index 561 return false; 562 } 563 564 return true; 561 565 } 562 566 … … 566 570 quadlet_t isoctrl = ReadRegister(MOTUFW_REG_ISOCTRL); 567 571 568 // TODO: connection management: break connection569 // cfr the start function570 571 // NOTE: this assumes that you have two streams572 switch (i) {573 case 0:574 // Turn bit 22 off to disable iso send by the MOTU. Turn575 // bit 23 on to enable changes to the MOTU's iso transmit576 // settings when the iso control register is written.577 isoctrl &= 0xffbfffff;578 isoctrl |= 0x00800000;579 WriteRegister(MOTUFW_REG_ISOCTRL, isoctrl);580 break;581 case 1:582 // Turn bit 30 off to disable iso receive by the MOTU. Turn583 // bit 31 on to enable changes to the MOTU's iso receive584 // settings when the iso control register is written.585 isoctrl &= 0xbfffffff;586 isoctrl |= 0x80000000;587 WriteRegister(MOTUFW_REG_ISOCTRL, isoctrl);588 break;589 590 default: // Invalid stream index591 return false;592 }593 594 return true;572 // TODO: connection management: break connection 573 // cfr the start function 574 575 // NOTE: this assumes that you have two streams 576 switch (i) { 577 case 0: 578 // Turn bit 22 off to disable iso send by the MOTU. Turn 579 // bit 23 on to enable changes to the MOTU's iso transmit 580 // settings when the iso control register is written. 581 isoctrl &= 0xffbfffff; 582 isoctrl |= 0x00800000; 583 WriteRegister(MOTUFW_REG_ISOCTRL, isoctrl); 584 break; 585 case 1: 586 // Turn bit 30 off to disable iso receive by the MOTU. Turn 587 // bit 31 on to enable changes to the MOTU's iso receive 588 // settings when the iso control register is written. 589 isoctrl &= 0xbfffffff; 590 isoctrl |= 0x80000000; 591 WriteRegister(MOTUFW_REG_ISOCTRL, isoctrl); 592 break; 593 594 default: // Invalid stream index 595 return false; 596 } 597 598 return true; 595 599 } 596 600 597 601 signed int MotuDevice::getIsoRecvChannel(void) { 598 return m_iso_recv_channel;602 return m_iso_recv_channel; 599 603 } 600 604 601 605 signed int MotuDevice::getIsoSendChannel(void) { 602 return m_iso_send_channel;606 return m_iso_send_channel; 603 607 } 604 608 605 609 unsigned int MotuDevice::getOpticalMode(unsigned int dir) { 606 unsigned int reg = ReadRegister(MOTUFW_REG_ROUTE_PORT_CONF);610 unsigned int reg = ReadRegister(MOTUFW_REG_ROUTE_PORT_CONF); 607 611 608 612 debugOutput(DEBUG_LEVEL_VERBOSE, "optical mode: %x %x %x %x\n",dir, reg, reg & MOTUFW_OPTICAL_IN_MODE_MASK, 609 613 reg & MOTUFW_OPTICAL_OUT_MODE_MASK); 610 614 611 if (dir == MOTUFW_DIR_IN)612 return (reg & MOTUFW_OPTICAL_IN_MODE_MASK) >> 8;613 else614 return (reg & MOTUFW_OPTICAL_OUT_MODE_MASK) >> 10;615 if (dir == MOTUFW_DIR_IN) 616 return (reg & MOTUFW_OPTICAL_IN_MODE_MASK) >> 8; 617 else 618 return (reg & MOTUFW_OPTICAL_OUT_MODE_MASK) >> 10; 615 619 } 616 620 617 621 signed int MotuDevice::setOpticalMode(unsigned int dir, unsigned int mode) { 618 unsigned int reg = ReadRegister(MOTUFW_REG_ROUTE_PORT_CONF);619 unsigned int opt_ctrl = 0x0000002;620 621 // Set up the optical control register value according to the current622 // optical port modes. At this stage it's not completely understood 623 // what the "Optical control" register does, so the values it's set to624 // are more or less "magic" numbers.625 if (reg & MOTUFW_OPTICAL_IN_MODE_MASK != (MOTUFW_OPTICAL_MODE_ADAT<<8))626 opt_ctrl |= 0x00000080;627 if (reg & MOTUFW_OPTICAL_OUT_MODE_MASK != (MOTUFW_OPTICAL_MODE_ADAT<<10))628 opt_ctrl |= 0x00000040;629 630 if (mode & MOTUFW_DIR_IN) {631 reg &= ~MOTUFW_OPTICAL_IN_MODE_MASK;632 reg |= (mode << 8) & MOTUFW_OPTICAL_IN_MODE_MASK;633 if (mode != MOTUFW_OPTICAL_MODE_ADAT)634 opt_ctrl |= 0x00000080;635 else636 opt_ctrl &= ~0x00000080;637 }638 if (mode & MOTUFW_DIR_OUT) {639 reg &= ~MOTUFW_OPTICAL_OUT_MODE_MASK;640 reg |= (mode <<10) & MOTUFW_OPTICAL_OUT_MODE_MASK;641 if (mode != MOTUFW_OPTICAL_MODE_ADAT)642 opt_ctrl |= 0x00000040;643 else644 opt_ctrl &= ~0x00000040;645 }646 647 // FIXME: there seems to be more to it than this, but for 648 // the moment at least this seems to work.649 WriteRegister(MOTUFW_REG_ROUTE_PORT_CONF, reg);650 return WriteRegister(MOTUFW_REG_OPTICAL_CTRL, opt_ctrl);622 unsigned int reg = ReadRegister(MOTUFW_REG_ROUTE_PORT_CONF); 623 unsigned int opt_ctrl = 0x0000002; 624 625 // Set up the optical control register value according to the current 626 // optical port modes. At this stage it's not completely understood 627 // what the "Optical control" register does, so the values it's set to 628 // are more or less "magic" numbers. 629 if (reg & MOTUFW_OPTICAL_IN_MODE_MASK != (MOTUFW_OPTICAL_MODE_ADAT<<8)) 630 opt_ctrl |= 0x00000080; 631 if (reg & MOTUFW_OPTICAL_OUT_MODE_MASK != (MOTUFW_OPTICAL_MODE_ADAT<<10)) 632 opt_ctrl |= 0x00000040; 633 634 if (mode & MOTUFW_DIR_IN) { 635 reg &= ~MOTUFW_OPTICAL_IN_MODE_MASK; 636 reg |= (mode << 8) & MOTUFW_OPTICAL_IN_MODE_MASK; 637 if (mode != MOTUFW_OPTICAL_MODE_ADAT) 638 opt_ctrl |= 0x00000080; 639 else 640 opt_ctrl &= ~0x00000080; 641 } 642 if (mode & MOTUFW_DIR_OUT) { 643 reg &= ~MOTUFW_OPTICAL_OUT_MODE_MASK; 644 reg |= (mode <<10) & MOTUFW_OPTICAL_OUT_MODE_MASK; 645 if (mode != MOTUFW_OPTICAL_MODE_ADAT) 646 opt_ctrl |= 0x00000040; 647 else 648 opt_ctrl &= ~0x00000040; 649 } 650 651 // FIXME: there seems to be more to it than this, but for 652 // the moment at least this seems to work. 653 WriteRegister(MOTUFW_REG_ROUTE_PORT_CONF, reg); 654 return WriteRegister(MOTUFW_REG_OPTICAL_CTRL, opt_ctrl); 651 655 } 652 656 … … 668 672 signed int size = 4+6+8*3; 669 673 670 // 2 channels of AES/EBU is present if a 1x or 2x sample rate is in 674 // 2 channels of AES/EBU is present if a 1x or 2x sample rate is in 671 675 // use 672 676 if (sample_rate <= 96000) … … 674 678 675 679 // 2 channels of (coax) SPDIF is present for 1x or 2x sample rates so 676 // long as the optical mode is not TOSLINK. If the optical mode is 677 // TOSLINK the coax SPDIF channels are replaced by optical TOSLINK 678 // channels. Thus between these options we always have an addition 680 // long as the optical mode is not TOSLINK. If the optical mode is 681 // TOSLINK the coax SPDIF channels are replaced by optical TOSLINK 682 // channels. Thus between these options we always have an addition 679 683 // 2 channels here for 1x or 2x sample rates regardless of the optical 680 684 // mode. … … 692 696 size += 4*3; 693 697 694 // When 1x or 2x sample rate is active there are an additional695 // 2 channels sent in an event. For capture it is a Mix1 return,696 // while for playback it is a separate headphone mix.697 if (sample_rate<=96000)698 size += 2*3;698 // When 1x or 2x sample rate is active there are an additional 699 // 2 channels sent in an event. For capture it is a Mix1 return, 700 // while for playback it is a separate headphone mix. 701 if (sample_rate<=96000) 702 size += 2*3; 699 703 700 704 // Finally round size up to the next quadlet boundary … … 704 708 705 709 bool MotuDevice::addPort(Streaming::StreamProcessor *s_processor, 706 char *name, enum Streaming::Port::E_Direction direction, 710 char *name, enum Streaming::Port::E_Direction direction, 707 711 int position, int size) { 708 712 /* 709 * Internal helper function to add a MOTU port to a given stream processor. 713 * Internal helper function to add a MOTU port to a given stream processor. 710 714 * This just saves the unnecessary replication of what is essentially 711 715 * boilerplate code. Note that the port name is freed by this function … … 714 718 Streaming::Port *p=NULL; 715 719 716 p = new Streaming::MotuAudioPort(name, direction, position, size);717 718 if (!p) {719 debugOutput(DEBUG_LEVEL_VERBOSE, "Skipped port %s\n",name);720 } else {721 if (!s_processor->addPort(p)) {722 debugWarning("Could not register port with stream processor\n");723 free(name);724 return false;725 } else {726 debugOutput(DEBUG_LEVEL_VERBOSE, "Added port %s\n",name);727 }728 p->enable();729 }730 free(name);731 return true;720 p = new Streaming::MotuAudioPort(name, direction, position, size); 721 722 if (!p) { 723 debugOutput(DEBUG_LEVEL_VERBOSE, "Skipped port %s\n",name); 724 } else { 725 if (!s_processor->addPort(p)) { 726 debugWarning("Could not register port with stream processor\n"); 727 free(name); 728 return false; 729 } else { 730 debugOutput(DEBUG_LEVEL_VERBOSE, "Added port %s\n",name); 731 } 732 p->enable(); 733 } 734 free(name); 735 return true; 732 736 } 733 737 /* ======================================================================= */ 734 738 735 739 bool MotuDevice::addDirPorts( 736 enum Streaming::Port::E_Direction direction, 740 enum Streaming::Port::E_Direction direction, 737 741 unsigned int sample_rate, unsigned int optical_mode) { 738 742 /* … … 750 754 char *buff; 751 755 752 // retrieve the ID756 // retrieve the ID 753 757 std::string id=std::string("dev?"); 754 758 if(!getOption("id", id)) { … … 756 760 } 757 761 758 if (direction == Streaming::Port::E_Capture) {759 s_processor = m_receiveProcessor;760 } else {761 s_processor = m_transmitProcessor;762 }763 // Offset into an event's data of the first audio data764 ofs = 10;765 766 // Add ports for the Mix1 return / Phones send which is present for 767 // 1x and 2x sampling rates.768 if (sample_rate<=96000) {769 for (i=0; i<2; i++, ofs+=3) {770 asprintf(&buff,"%s_%s_%s-%c", id.c_str(), mode_str,771 aux_str, i==0?'L':'R');772 if (!addPort(s_processor, buff, direction, ofs, 0))773 return false;774 }775 }776 777 // Unconditionally add the 8 analog capture ports since they are778 // always present no matter what the device configuration is.779 for (i=0; i<8; i++, ofs+=3) {780 asprintf(&buff,"%s_%s_Analog%d", id.c_str(), mode_str, i+1);781 if (!addPort(s_processor, buff, direction, ofs, 0))782 return false;783 }784 785 // AES/EBU ports are present for 1x and 2x sampling rates on the 786 // Traveler. On earlier interfaces (for example, 828 MkII) this787 // space was taken up with a separate "main out" send.788 // FIXME: what is in this position of incoming data on an 828 MkII?789 if (sample_rate <= 96000) {790 for (i=0; i<2; i++, ofs+=3) {791 if (m_motu_model == MOTUFW_MODEL_TRAVELER) {792 asprintf(&buff,"%s_%s_AES/EBU%d", id.c_str(), mode_str, i+1);793 } else {794 if (direction == Streaming::Port::E_Capture)795 asprintf(&buff,"%s_%s_Mic%d", id.c_str(), mode_str, i+1);796 else797 asprintf(&buff,"%s_%s_MainOut-%c", id.c_str(), mode_str, i==0?'L':'R');798 }799 if (!addPort(s_processor, buff, direction, ofs, 0))800 return false;801 }802 }803 804 // SPDIF ports are present for 1x and 2x sampling rates so long805 // as the optical mode is not TOSLINK.806 if (sample_rate<=96000 && optical_mode!=MOTUFW_OPTICAL_MODE_TOSLINK) {807 for (i=0; i<2; i++, ofs+=3) {808 asprintf(&buff,"%s_%s_SPDIF%d", id.c_str(), mode_str, i+1);809 if (!addPort(s_processor, buff, direction, ofs, 0))810 return false;811 }812 }813 814 // TOSLINK ports are present for 1x and 2x sampling rates so long815 // as the optical mode is set to TOSLINK.816 if (sample_rate<=96000 && optical_mode==MOTUFW_OPTICAL_MODE_TOSLINK) {817 for (i=0; i<2; i++, ofs+=3) {818 asprintf(&buff,"%s_%s_TOSLINK%d", id.c_str(), mode_str, i+1);819 if (!addPort(s_processor, buff, direction, ofs, 0))820 return false;821 }822 }823 824 // ADAT ports 1-4 are present for 1x and 2x sampling rates so long825 // as the optical mode is set to ADAT.826 if (sample_rate<=96000 && optical_mode==MOTUFW_OPTICAL_MODE_ADAT) {827 for (i=0; i<4; i++, ofs+=3) {828 asprintf(&buff,"%s_%s_ADAT%d", id.c_str(), mode_str, i+1);829 if (!addPort(s_processor, buff, direction, ofs, 0))830 return false;831 }832 }833 834 // ADAT ports 5-8 are present for 1x sampling rates so long as the835 // optical mode is set to ADAT.836 if (sample_rate<=48000 && optical_mode==MOTUFW_OPTICAL_MODE_ADAT) {837 for (i=4; i<8; i++, ofs+=3) {838 asprintf(&buff,"%s_%s_ADAT%d", id.c_str(), mode_str, i+1);839 if (!addPort(s_processor, buff, direction, ofs, 0))840 return false;841 }842 }843 844 return true;762 if (direction == Streaming::Port::E_Capture) { 763 s_processor = m_receiveProcessor; 764 } else { 765 s_processor = m_transmitProcessor; 766 } 767 // Offset into an event's data of the first audio data 768 ofs = 10; 769 770 // Add ports for the Mix1 return / Phones send which is present for 771 // 1x and 2x sampling rates. 772 if (sample_rate<=96000) { 773 for (i=0; i<2; i++, ofs+=3) { 774 asprintf(&buff,"%s_%s_%s-%c", id.c_str(), mode_str, 775 aux_str, i==0?'L':'R'); 776 if (!addPort(s_processor, buff, direction, ofs, 0)) 777 return false; 778 } 779 } 780 781 // Unconditionally add the 8 analog capture ports since they are 782 // always present no matter what the device configuration is. 783 for (i=0; i<8; i++, ofs+=3) { 784 asprintf(&buff,"%s_%s_Analog%d", id.c_str(), mode_str, i+1); 785 if (!addPort(s_processor, buff, direction, ofs, 0)) 786 return false; 787 } 788 789 // AES/EBU ports are present for 1x and 2x sampling rates on the 790 // Traveler. On earlier interfaces (for example, 828 MkII) this 791 // space was taken up with a separate "main out" send. 792 // FIXME: what is in this position of incoming data on an 828 MkII? 793 if (sample_rate <= 96000) { 794 for (i=0; i<2; i++, ofs+=3) { 795 if (m_motu_model == MOTUFW_MODEL_TRAVELER) { 796 asprintf(&buff,"%s_%s_AES/EBU%d", id.c_str(), mode_str, i+1); 797 } else { 798 if (direction == Streaming::Port::E_Capture) 799 asprintf(&buff,"%s_%s_Mic%d", id.c_str(), mode_str, i+1); 800 else 801 asprintf(&buff,"%s_%s_MainOut-%c", id.c_str(), mode_str, i==0?'L':'R'); 802 } 803 if (!addPort(s_processor, buff, direction, ofs, 0)) 804 return false; 805 } 806 } 807 808 // SPDIF ports are present for 1x and 2x sampling rates so long 809 // as the optical mode is not TOSLINK. 810 if (sample_rate<=96000 && optical_mode!=MOTUFW_OPTICAL_MODE_TOSLINK) { 811 for (i=0; i<2; i++, ofs+=3) { 812 asprintf(&buff,"%s_%s_SPDIF%d", id.c_str(), mode_str, i+1); 813 if (!addPort(s_processor, buff, direction, ofs, 0)) 814 return false; 815 } 816 } 817 818 // TOSLINK ports are present for 1x and 2x sampling rates so long 819 // as the optical mode is set to TOSLINK. 820 if (sample_rate<=96000 && optical_mode==MOTUFW_OPTICAL_MODE_TOSLINK) { 821 for (i=0; i<2; i++, ofs+=3) { 822 asprintf(&buff,"%s_%s_TOSLINK%d", id.c_str(), mode_str, i+1); 823 if (!addPort(s_processor, buff, direction, ofs, 0)) 824 return false; 825 } 826 } 827 828 // ADAT ports 1-4 are present for 1x and 2x sampling rates so long 829 // as the optical mode is set to ADAT. 830 if (sample_rate<=96000 && optical_mode==MOTUFW_OPTICAL_MODE_ADAT) { 831 for (i=0; i<4; i++, ofs+=3) { 832 asprintf(&buff,"%s_%s_ADAT%d", id.c_str(), mode_str, i+1); 833 if (!addPort(s_processor, buff, direction, ofs, 0)) 834 return false; 835 } 836 } 837 838 // ADAT ports 5-8 are present for 1x sampling rates so long as the 839 // optical mode is set to ADAT. 840 if (sample_rate<=48000 && optical_mode==MOTUFW_OPTICAL_MODE_ADAT) { 841 for (i=4; i<8; i++, ofs+=3) { 842 asprintf(&buff,"%s_%s_ADAT%d", id.c_str(), mode_str, i+1); 843 if (!addPort(s_processor, buff, direction, ofs, 0)) 844 return false; 845 } 846 } 847 848 return true; 845 849 } 846 850 /* ======================================================================== */ … … 853 857 quadlet_t quadlet; 854 858 assert(m_p1394Service); 855 859 856 860 quadlet = 0; 857 861 // Note: 1394Service::read() expects a physical ID, not the node id trunk/libffado/src/motu/motu_avdevice.h
r436 r445 1 /* motu_avdevice.h2 * Copyright (C) 200 6by Pieter Palmers3 * Copyright (C) 200 6Jonathan Woithe1 /* 2 * Copyright (C) 2005-2007 by Pieter Palmers 3 * Copyright (C) 2005-2007 by Jonathan Woithe 4 4 * 5 * This file is part of FreeBob. 5 * This file is part of FFADO 6 * FFADO = Free Firewire (pro-)audio drivers for linux 6 7 * 7 * FreeBob is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * FreeBob is distributed in the hope that it will be useful, 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, 12 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNUGeneral Public License for more details.16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * Lesser General Public License for more details. 15 18 * 16 * You should have received a copy of the GNU General Public License17 * along with FreeBob; if not, write to the Free Software18 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,19 * MA 0211 1-1307 USA.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 20 23 */ 21 24 … … 40 43 #define MOTUFW_RATE_MULTIPLIER_MASK (0x00000030) 41 44 42 #define MOTUFW_OPTICAL_MODE_OFF 0x0043 #define MOTUFW_OPTICAL_MODE_ADAT 0x0144 #define MOTUFW_OPTICAL_MODE_TOSLINK 0x0245 #define MOTUFW_OPTICAL_IN_MODE_MASK (0x00000300)46 #define MOTUFW_OPTICAL_OUT_MODE_MASK (0x00000c00)47 #define MOTUFW_OPTICAL_MODE_MASK (MOTUFW_OPTICAL_IN_MODE_MASK|MOTUFW_OPTICAL_MODE_MASK)45 #define MOTUFW_OPTICAL_MODE_OFF 0x00 46 #define MOTUFW_OPTICAL_MODE_ADAT 0x01 47 #define MOTUFW_OPTICAL_MODE_TOSLINK 0x02 48 #define MOTUFW_OPTICAL_IN_MODE_MASK (0x00000300) 49 #define MOTUFW_OPTICAL_OUT_MODE_MASK (0x00000c00) 50 #define MOTUFW_OPTICAL_MODE_MASK (MOTUFW_OPTICAL_IN_MODE_MASK|MOTUFW_OPTICAL_MODE_MASK) 48 51 49 #define MOTUFW_CLKSRC_MASK 0x0000000750 #define MOTUFW_CLKSRC_INTERNAL 051 #define MOTUFW_CLKSRC_ADAT_OPTICAL 152 #define MOTUFW_CLKSRC_SPDIF_TOSLINK 253 #define MOTUFW_CLKSRC_SMTPE 354 #define MOTUFW_CLKSRC_WORDCLOCK 455 #define MOTUFW_CLKSRC_ADAT_9PIN 556 #define MOTUFW_CLKSRC_AES_EBU 752 #define MOTUFW_CLKSRC_MASK 0x00000007 53 #define MOTUFW_CLKSRC_INTERNAL 0 54 #define MOTUFW_CLKSRC_ADAT_OPTICAL 1 55 #define MOTUFW_CLKSRC_SPDIF_TOSLINK 2 56 #define MOTUFW_CLKSRC_SMTPE 3 57 #define MOTUFW_CLKSRC_WORDCLOCK 4 58 #define MOTUFW_CLKSRC_ADAT_9PIN 5 59 #define MOTUFW_CLKSRC_AES_EBU 7 57 60 58 #define MOTUFW_DIR_IN 159 #define MOTUFW_DIR_OUT 260 #define MOTUFW_DIR_INOUT (MOTUFW_DIR_IN | MOTUFW_DIR_OUT)61 #define MOTUFW_DIR_IN 1 62 #define MOTUFW_DIR_OUT 2 63 #define MOTUFW_DIR_INOUT (MOTUFW_DIR_IN | MOTUFW_DIR_OUT) 61 64 62 65 /* Device registers */ 63 #define MOTUFW_REG_ISOCTRL 0x0b0064 #define MOTUFW_REG_OPTICAL_CTRL 0x0b1065 #define MOTUFW_REG_CLK_CTRL 0x0b1466 #define MOTUFW_REG_ISOCTRL 0x0b00 67 #define MOTUFW_REG_OPTICAL_CTRL 0x0b10 68 #define MOTUFW_REG_CLK_CTRL 0x0b14 66 69 #define MOTUFW_REG_ROUTE_PORT_CONF 0x0c04 67 #define MOTUFW_REG_CLKSRC_NAME0 0x0c6070 #define MOTUFW_REG_CLKSRC_NAME0 0x0c60 68 71 69 72 class ConfigRom; … … 93 96 MotuDevice( std::auto_ptr<ConfigRom>( configRom ), 94 97 Ieee1394Service& ieee1394Service, 95 int nodeId );98 int nodeId ); 96 99 virtual ~MotuDevice(); 97 100 … … 110 113 bool lock(); 111 114 bool unlock(); 112 115 113 116 bool startStreamByIndex(int i); 114 117 bool stopStreamByIndex(int i); … … 120 123 121 124 signed int getEventSize(unsigned int dir); 122 125 123 126 protected: 124 127 signed int m_motu_model; … … 126 129 signed int m_iso_recv_channel, m_iso_send_channel; 127 130 signed int m_bandwidth; 128 129 Streaming::MotuReceiveStreamProcessor *m_receiveProcessor;130 Streaming::MotuTransmitStreamProcessor *m_transmitProcessor;131 132 Streaming::MotuReceiveStreamProcessor *m_receiveProcessor; 133 Streaming::MotuTransmitStreamProcessor *m_transmitProcessor; 131 134 132 135 private: 133 bool addPort(Streaming::StreamProcessor *s_processor,134 char *name, 135 enum Streaming::Port::E_Direction direction,136 int position, int size);137 bool addDirPorts(138 enum Streaming::Port::E_Direction direction,139 unsigned int sample_rate, unsigned int optical_mode);140 141 unsigned int ReadRegister(unsigned int reg);142 signed int WriteRegister(unsigned int reg, quadlet_t data);136 bool addPort(Streaming::StreamProcessor *s_processor, 137 char *name, 138 enum Streaming::Port::E_Direction direction, 139 int position, int size); 140 bool addDirPorts( 141 enum Streaming::Port::E_Direction direction, 142 unsigned int sample_rate, unsigned int optical_mode); 143 144 unsigned int ReadRegister(unsigned int reg); 145 signed int WriteRegister(unsigned int reg, quadlet_t data); 143 146 144 147 }; trunk/libffado/src/rme/rme_avdevice.cpp
r436 r445 1 /* rme_avdevice.cpp2 * Copyright (C) 200 6by Jonathan Woithe3 * Copyright (C) 200 6,2007 by Pieter Palmers1 /* 2 * Copyright (C) 2005-2007 by Jonathan Woithe 3 * Copyright (C) 2005-2007 by Pieter Palmers 4 4 * 5 * This file is part of FreeBob. 5 * This file is part of FFADO 6 * FFADO = Free Firewire (pro-)audio drivers for linux 6 7 * 7 * FreeBob is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * FreeBob is distributed in the hope that it will be useful, 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, 12 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNUGeneral Public License for more details.16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * Lesser General Public License for more details. 15 18 * 16 * You should have received a copy of the GNU General Public License17 * along with FreeBob; if not, write to the Free Software18 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,19 * MA 0211 1-1307 USA.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 20 23 */ 24 21 25 #warning RME support is currently useless (detection only) 22 26 trunk/libffado/src/rme/rme_avdevice.h
r436 r445 1 /* rme_avdevice.h2 * Copyright (C) 200 6Jonathan Woithe3 * Copyright (C) 200 6,2007 by Pieter Palmers1 /* 2 * Copyright (C) 2005-2007 by Jonathan Woithe 3 * Copyright (C) 2005-2007 by Pieter Palmers 4 4 * 5 * This file is part of FreeBob. 5 * This file is part of FFADO 6 * FFADO = Free Firewire (pro-)audio drivers for linux 6 7 * 7 * FreeBob is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * FreeBob is distributed in the hope that it will be useful, 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, 12 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNUGeneral Public License for more details.16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * Lesser General Public License for more details. 15 18 * 16 * You should have received a copy of the GNU General Public License17 * along with FreeBob; if not, write to the Free Software18 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,19 * MA 0211 1-1307 USA.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 20 23 */ 24 21 25 #ifndef RMEDEVICE_H 22 26 #define RMEDEVICE_H trunk/libffado/src/ser.cpp
r436 r445 1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 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 is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License version 2 11 * as published by the Free Software Foundation. 12 * 13 * FFADO 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 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with FFADO; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21 * MA 02111-1307 USA. 22 */ 23 1 24 #include "devicemanager.h" 2 25 #include "libutil/serialize.h" … … 14 37 return false; 15 38 } 16 39 17 40 // devMgr.setVerboseLevel(DEBUG_LEVEL_VERBOSE); 18 41 19 42 if (!devMgr.discover( )) { 20 43 std::cerr << "could not discover devices" << std::endl; … … 42 65 port=atoi(argv[1]); 43 66 } 44 67 45 68 if ( !serialize( FileName, port ) ) { 46 69 std::cerr << "serializing failed" << std::endl; trunk/libffado/src/threads.h
r412 r445 1 /* threads.h2 * Copyright (C) 200 6by Daniel Wagner1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 3 3 * 4 * This file is part of FreeBoB. 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 5 6 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 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, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNUGeneral Public License for more details.15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 14 17 * 15 * You should have received a copy of the GNU General Public License16 * along with FreeBoB; if not, write to the Free Software17 * Foundation, Inc., 5 9 Temple Place, Suite 330, Boston,18 * MA 0211 1-1307 USA.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 19 22 */ 20 23 … … 40 43 { 41 44 public: 42 MemberFunctor0( const CalleePtr& pCallee, 43 MemFunPtr pMemFun, 45 MemberFunctor0( const CalleePtr& pCallee, 46 MemFunPtr pMemFun, 44 47 bool bDelete = true ) 45 48 : m_pCallee( pCallee ) … … 49 52 {} 50 53 51 MemberFunctor0( const CalleePtr& pCallee, 52 MemFunPtr pMemFun, 54 MemberFunctor0( const CalleePtr& pCallee, 55 MemFunPtr pMemFun, 53 56 sem_t* pSem, 54 57 bool bDelete = true ) … … 64 67 virtual void operator() () 65 68 { 66 ( ( *m_pCallee ).*m_pMemFun )(); 69 ( ( *m_pCallee ).*m_pMemFun )(); 67 70 if ( m_pSem ) { 68 71 sem_post( m_pSem); … … 85 88 { 86 89 public: 87 MemberFunctor1( const CalleePtr& pCallee, 88 MemFunPtr pMemFun, 90 MemberFunctor1( const CalleePtr& pCallee, 91 MemFunPtr pMemFun, 89 92 Parm0 parm0, 90 93 bool bDelete = true) … … 93 96 , m_parm0( parm0 ) 94 97 , m_pSem( 0 ) 95 , m_bDelete( bDelete ) 98 , m_bDelete( bDelete ) 96 99 {} 97 100 98 MemberFunctor1( const CalleePtr& pCallee, 99 MemFunPtr pMemFun, 101 MemberFunctor1( const CalleePtr& pCallee, 102 MemFunPtr pMemFun, 100 103 Parm0 parm0, 101 104 sem_t* pSem, … … 112 115 virtual void operator() () 113 116 { 114 ( ( *m_pCallee ).*m_pMemFun )( m_parm0 ); 117 ( ( *m_pCallee ).*m_pMemFun )( m_parm0 ); 115 118 if ( m_pSem ) { 116 119 sem_post( m_pSem); trunk/libffado/support/jack/ffado_driver.c
r444 r445 1 1 /* 2 * FreeBob Backend for Jack 3 * FreeBob = Firewire (pro-)audio for linux 2 * FireWire Backend for Jack 3 * using FFADO 4 * FFADO = Firewire (pro-)audio for linux 4 5 * 5 * http://f reebob.sf.net6 * http://ffado.sf.net 6 7 * http://jackit.sf.net 7 8 * 8 * Copyright (C) 2005 Pieter Palmers <pieterpalmers@users.sourceforge.net>9 * Copyright (C) 2005-2007 Pieter Palmers 9 10 * 10 11 * This program is free software; you can redistribute it and/or modify … … 42 43 #include <sysdeps/time.h> 43 44 44 #include "f reebob_driver.h"45 #include "ffado_driver.h" 45 46 46 47 #define SAMPLE_MAX_24BIT 8388608.0f 47 48 #define SAMPLE_MAX_16BIT 32768.0f 48 49 49 static int f reebob_driver_stop (freebob_driver_t *driver);50 51 #ifdef F REEBOB_DRIVER_WITH_MIDI52 static f reebob_driver_midi_handle_t *freebob_driver_midi_init(freebob_driver_t *driver);53 static void f reebob_driver_midi_finish (freebob_driver_midi_handle_t *m);54 static int f reebob_driver_midi_start (freebob_driver_midi_handle_t *m);55 static int f reebob_driver_midi_stop (freebob_driver_midi_handle_t *m);50 static int ffado_driver_stop (ffado_driver_t *driver); 51 52 #ifdef FFADO_DRIVER_WITH_ASEQ_MIDI 53 static ffado_driver_midi_handle_t *ffado_driver_midi_init(ffado_driver_t *driver); 54 static void ffado_driver_midi_finish (ffado_driver_midi_handle_t *m); 55 static int ffado_driver_midi_start (ffado_driver_midi_handle_t *m); 56 static int ffado_driver_midi_stop (ffado_driver_midi_handle_t *m); 56 57 #endif 57 58 … … 60 61 61 62 static int 62 f reebob_driver_attach (freebob_driver_t *driver)63 ffado_driver_attach (ffado_driver_t *driver) 63 64 { 64 65 char buf[64]; … … 77 78 78 79 driver->device_options.packetizer_priority=driver->engine->control->client_priority + 79 F REEBOB_RT_PRIORITY_PACKETIZER_RELATIVE;80 FFADO_RT_PRIORITY_PACKETIZER_RELATIVE; 80 81 if (driver->device_options.packetizer_priority>98) { 81 82 driver->device_options.packetizer_priority=98; 82 83 } 83 84 84 driver->dev=f reebob_streaming_init(&driver->device_info,driver->device_options);85 driver->dev=ffado_streaming_init(&driver->device_info,driver->device_options); 85 86 86 87 if(!driver->dev) { 87 printError("Error creating freebobstreaming device");88 printError("Error creating FFADO streaming device"); 88 89 return -1; 89 90 } 90 91 91 #ifdef F REEBOB_DRIVER_WITH_MIDI92 driver->midi_handle=f reebob_driver_midi_init(driver);92 #ifdef FFADO_DRIVER_WITH_ASEQ_MIDI 93 driver->midi_handle=ffado_driver_midi_init(driver); 93 94 if(!driver->midi_handle) { 94 95 printError("-----------------------------------------------------------"); 95 96 printError("Error creating midi device!"); 96 printError(" FreeBobwill run without MIDI support.");97 printError("The FireWire backend will run without MIDI support."); 97 98 printError("Consult the above error messages to solve the problem. "); 98 99 printError("-----------------------------------------------------------\n\n"); … … 110 111 port_flags = JackPortIsOutput|JackPortIsPhysical|JackPortIsTerminal; 111 112 112 driver->capture_nchannels=f reebob_streaming_get_nb_capture_streams(driver->dev);113 driver->capture_nchannels=ffado_streaming_get_nb_capture_streams(driver->dev); 113 114 114 115 for (chn = 0; chn < driver->capture_nchannels; chn++) { 115 116 116 f reebob_streaming_get_capture_stream_name(driver->dev, chn, buf, sizeof(buf) - 1);117 ffado_streaming_get_capture_stream_name(driver->dev, chn, buf, sizeof(buf) - 1); 117 118 118 if(f reebob_streaming_get_capture_stream_type(driver->dev, chn) != freebob_stream_type_audio) {119 if(ffado_streaming_get_capture_stream_type(driver->dev, chn) != ffado_stream_type_audio) { 119 120 printMessage ("Don't register capture port %s", buf); 120 121 … … 133 134 jack_slist_append (driver->capture_ports, port); 134 135 // setup port parameters 135 if(f reebob_streaming_set_capture_buffer_type(driver->dev, chn, freebob_buffer_type_float)) {136 if(ffado_streaming_set_capture_buffer_type(driver->dev, chn, ffado_buffer_type_float)) { 136 137 printError(" cannot set port buffer type for %s", buf); 137 138 } 138 if (f reebob_streaming_set_capture_stream_buffer(driver->dev, chn, NULL)) {139 if (ffado_streaming_set_capture_stream_buffer(driver->dev, chn, NULL)) { 139 140 printError(" cannot configure initial port buffer for %s", buf); 140 141 } 141 if(f reebob_streaming_capture_stream_onoff(driver->dev, chn, 1)) {142 if(ffado_streaming_capture_stream_onoff(driver->dev, chn, 1)) { 142 143 printError(" cannot enable port %s", buf); 143 144 } … … 149 150 port_flags = JackPortIsInput|JackPortIsPhysical|JackPortIsTerminal; 150 151 151 driver->playback_nchannels=f reebob_streaming_get_nb_playback_streams(driver->dev);152 driver->playback_nchannels=ffado_streaming_get_nb_playback_streams(driver->dev); 152 153 153 154 for (chn = 0; chn < driver->playback_nchannels; chn++) { 154 155 155 f reebob_streaming_get_playback_stream_name(driver->dev, chn, buf, sizeof(buf) - 1);156 ffado_streaming_get_playback_stream_name(driver->dev, chn, buf, sizeof(buf) - 1); 156 157 157 if(f reebob_streaming_get_playback_stream_type(driver->dev, chn) != freebob_stream_type_audio) {158 if(ffado_streaming_get_playback_stream_type(driver->dev, chn) != ffado_stream_type_audio) { 158 159 printMessage ("Don't register playback port %s", buf); 159 160 … … 173 174 174 175 // setup port parameters 175 if(f reebob_streaming_set_playback_buffer_type(driver->dev, chn, freebob_buffer_type_float)) {176 if(ffado_streaming_set_playback_buffer_type(driver->dev, chn, ffado_buffer_type_float)) { 176 177 printError(" cannot set port buffer type for %s", buf); 177 178 } 178 if (f reebob_streaming_set_playback_stream_buffer(driver->dev, chn, NULL)) {179 if (ffado_streaming_set_playback_stream_buffer(driver->dev, chn, NULL)) { 179 180 printError(" cannot configure initial port buffer for %s", buf); 180 181 } 181 if(f reebob_streaming_playback_stream_onoff(driver->dev, chn, 1)) {182 if(ffado_streaming_playback_stream_onoff(driver->dev, chn, 1)) { 182 183 printError(" cannot enable port %s", buf); 183 184 } … … 187 188 } 188 189 189 if(!f reebob_streaming_prepare(driver->dev)) {190 if(!ffado_streaming_prepare(driver->dev)) { 190 191 printError("Could not prepare streaming device!"); 191 192 return -1; … … 197 198 198 199 static int 199 f reebob_driver_detach (freebob_driver_t *driver)200 ffado_driver_detach (ffado_driver_t *driver) 200 201 { 201 202 JSList *node; … … 208 209 node = jack_slist_next (node)) { 209 210 // Don't try to unregister NULL entries added for non-audio 210 // f reebob ports by freebob_driver_attach().211 // ffado ports by ffado_driver_attach(). 211 212 if (node->data != NULL) { 212 213 jack_port_unregister (driver->client, … … 220 221 for (node = driver->playback_ports; node; 221 222 node = jack_slist_next (node)) { 222 jack_port_unregister (driver->client, 223 if (node->data != NULL) { 224 jack_port_unregister (driver->client, 223 225 ((jack_port_t *) node->data)); 226 } 224 227 } 225 228 … … 227 230 driver->playback_ports = 0; 228 231 229 f reebob_streaming_finish(driver->dev);232 ffado_streaming_finish(driver->dev); 230 233 driver->dev=NULL; 231 234 232 #ifdef F REEBOB_DRIVER_WITH_MIDI235 #ifdef FFADO_DRIVER_WITH_ASEQ_MIDI 233 236 if(driver->midi_handle) { 234 f reebob_driver_midi_finish(driver->midi_handle);237 ffado_driver_midi_finish(driver->midi_handle); 235 238 } 236 239 driver->midi_handle=NULL; … … 238 241 239 242 return 0; 240 241 243 } 242 244 243 245 static inline void 244 f reebob_driver_read_from_channel (freebob_driver_t *driver,246 ffado_driver_read_from_channel (ffado_driver_t *driver, 245 247 channel_t channel, 246 248 jack_default_audio_sample_t *dst, … … 248 250 { 249 251 250 f reebob_sample_t buffer[nsamples];252 ffado_sample_t buffer[nsamples]; 251 253 char *src=(char *)buffer; 252 254 253 f reebob_streaming_read(driver->dev, channel, buffer, nsamples);255 ffado_streaming_read(driver->dev, channel, buffer, nsamples); 254 256 255 257 /* ALERT: signed sign-extension portability !!! */ … … 265 267 *dst = x / SAMPLE_MAX_24BIT; 266 268 dst++; 267 src += sizeof(f reebob_sample_t);269 src += sizeof(ffado_sample_t); 268 270 } 269 271 … … 271 273 272 274 static int 273 f reebob_driver_read (freebob_driver_t * driver, jack_nframes_t nframes)275 ffado_driver_read (ffado_driver_t * driver, jack_nframes_t nframes) 274 276 { 275 277 jack_default_audio_sample_t* buf; … … 278 280 jack_port_t* port; 279 281 280 f reebob_sample_t nullbuffer[nframes];281 282 f reebob_streaming_stream_type stream_type;282 ffado_sample_t nullbuffer[nframes]; 283 284 ffado_streaming_stream_type stream_type; 283 285 284 286 printEnter(); 285 287 286 288 for (chn = 0, node = driver->capture_ports; node; node = jack_slist_next (node), chn++) { 287 stream_type = f reebob_streaming_get_capture_stream_type(driver->dev, chn);288 if(stream_type == f reebob_stream_type_audio) {289 stream_type = ffado_streaming_get_capture_stream_type(driver->dev, chn); 290 if(stream_type == ffado_stream_type_audio) { 289 291 port = (jack_port_t *) node->data; 290 292 … … 292 294 if(!buf) buf=(jack_default_audio_sample_t*)nullbuffer; 293 295 294 f reebob_streaming_set_capture_stream_buffer(driver->dev, chn, (char *)(buf));296 ffado_streaming_set_capture_stream_buffer(driver->dev, chn, (char *)(buf)); 295 297 } 296 298 } 297 299 298 300 // now transfer the buffers 299 f reebob_streaming_transfer_capture_buffers(driver->dev);301 ffado_streaming_transfer_capture_buffers(driver->dev); 300 302 301 303 printExit(); … … 306 308 307 309 static inline void 308 f reebob_driver_write_to_channel (freebob_driver_t *driver,310 ffado_driver_write_to_channel (ffado_driver_t *driver, 309 311 channel_t channel, 310 312 jack_default_audio_sample_t *buf, … … 312 314 { 313 315 long long y; 314 f reebob_sample_t buffer[nsamples];316 ffado_sample_t buffer[nsamples]; 315 317 unsigned int i=0; 316 318 char *dst=(char *)buffer; … … 330 332 memcpy (dst, (char *)&y + 5, 3); 331 333 #endif 332 dst += sizeof(f reebob_sample_t);334 dst += sizeof(ffado_sample_t); 333 335 buf++; 334 336 } 335 337 336 // write to the f reebobstreaming device337 f reebob_streaming_write(driver->dev, channel, buffer, nsamples);338 // write to the ffado streaming device 339 ffado_streaming_write(driver->dev, channel, buffer, nsamples); 338 340 339 341 } 340 342 341 343 static int 342 f reebob_driver_write (freebob_driver_t * driver, jack_nframes_t nframes)344 ffado_driver_write (ffado_driver_t * driver, jack_nframes_t nframes) 343 345 { 344 346 channel_t chn; … … 348 350 jack_port_t *port; 349 351 350 f reebob_streaming_stream_type stream_type;351 352 f reebob_sample_t nullbuffer[nframes];353 354 memset(&nullbuffer,0,nframes*sizeof(f reebob_sample_t));352 ffado_streaming_stream_type stream_type; 353 354 ffado_sample_t nullbuffer[nframes]; 355 356 memset(&nullbuffer,0,nframes*sizeof(ffado_sample_t)); 355 357 356 358 printEnter(); … … 365 367 366 368 for (chn = 0, node = driver->playback_ports; node; node = jack_slist_next (node), chn++) { 367 stream_type=f reebob_streaming_get_playback_stream_type(driver->dev, chn);368 if(stream_type == f reebob_stream_type_audio) {369 stream_type=ffado_streaming_get_playback_stream_type(driver->dev, chn); 370 if(stream_type == ffado_stream_type_audio) { 369 371 port = (jack_port_t *) node->data; 370 372 … … 372 374 if(!buf) buf=(jack_default_audio_sample_t*)nullbuffer; 373 375 374 f reebob_streaming_set_playback_stream_buffer(driver->dev, chn, (char *)(buf));375 } 376 } 377 378 f reebob_streaming_transfer_playback_buffers(driver->dev);376 ffado_streaming_set_playback_stream_buffer(driver->dev, chn, (char *)(buf)); 377 } 378 } 379 380 ffado_streaming_transfer_playback_buffers(driver->dev); 379 381 380 382 printExit(); … … 385 387 //static inline jack_nframes_t 386 388 static jack_nframes_t 387 f reebob_driver_wait (freebob_driver_t *driver, int extra_fd, int *status,389 ffado_driver_wait (ffado_driver_t *driver, int extra_fd, int *status, 388 390 float *delayed_usecs) 389 391 { … … 408 410 // *status = -4; extra FD 409 411 410 nframes=f reebob_streaming_wait(driver->dev);412 nframes=ffado_streaming_wait(driver->dev); 411 413 412 414 wait_ret = jack_get_microseconds (); … … 421 423 // transfer the streaming buffers 422 424 // we now do this in the read/write functions 423 // f reebob_streaming_transfer_buffers(driver->dev);425 // ffado_streaming_transfer_buffers(driver->dev); 424 426 425 427 if (nframes < 0) { … … 443 445 444 446 static int 445 f reebob_driver_run_cycle (freebob_driver_t *driver)447 ffado_driver_run_cycle (ffado_driver_t *driver) 446 448 { 447 449 jack_engine_t *engine = driver->engine; … … 449 451 float delayed_usecs=0.0; 450 452 451 jack_nframes_t nframes = f reebob_driver_wait (driver, -1,453 jack_nframes_t nframes = ffado_driver_wait (driver, -1, 452 454 &wait_status, &delayed_usecs); 453 455 … … 472 474 */ 473 475 static int 474 f reebob_driver_null_cycle (freebob_driver_t* driver, jack_nframes_t nframes)476 ffado_driver_null_cycle (ffado_driver_t* driver, jack_nframes_t nframes) 475 477 { 476 478 channel_t chn; … … 478 480 snd_pcm_sframes_t nwritten; 479 481 480 f reebob_streaming_stream_type stream_type;482 ffado_streaming_stream_type stream_type; 481 483 482 484 jack_default_audio_sample_t buff[nframes]; … … 497 499 498 500 for (chn = 0, node = driver->playback_ports; node; node = jack_slist_next (node), chn++) { 499 stream_type=f reebob_streaming_get_playback_stream_type(driver->dev, chn);500 501 if(stream_type == f reebob_stream_type_audio) {502 f reebob_streaming_set_playback_stream_buffer(driver->dev, chn, (char *)(buffer));503 } 504 } 505 506 f reebob_streaming_transfer_playback_buffers(driver->dev);501 stream_type=ffado_streaming_get_playback_stream_type(driver->dev, chn); 502 503 if(stream_type == ffado_stream_type_audio) { 504 ffado_streaming_set_playback_stream_buffer(driver->dev, chn, (char *)(buffer)); 505 } 506 } 507 508 ffado_streaming_transfer_playback_buffers(driver->dev); 507 509 508 510 // read & discard from input ports 509 511 for (chn = 0, node = driver->capture_ports; node; node = jack_slist_next (node), chn++) { 510 stream_type=f reebob_streaming_get_capture_stream_type(driver->dev, chn);511 if(stream_type == f reebob_stream_type_audio) {512 f reebob_streaming_set_capture_stream_buffer(driver->dev, chn, (char *)(buffer));512 stream_type=ffado_streaming_get_capture_stream_type(driver->dev, chn); 513 if(stream_type == ffado_stream_type_audio) { 514 ffado_streaming_set_capture_stream_buffer(driver->dev, chn, (char *)(buffer)); 513 515 } 514 516 } 515 517 516 518 // now transfer the buffers 517 f reebob_streaming_transfer_capture_buffers(driver->dev);519 ffado_streaming_transfer_capture_buffers(driver->dev); 518 520 519 521 printExit(); … … 522 524 523 525 static int 524 f reebob_driver_start (freebob_driver_t *driver)526 ffado_driver_start (ffado_driver_t *driver) 525 527 { 526 528 int retval=0; 527 529 528 #ifdef F REEBOB_DRIVER_WITH_MIDI530 #ifdef FFADO_DRIVER_WITH_ASEQ_MIDI 529 531 if(driver->midi_handle) { 530 if((retval=f reebob_driver_midi_start(driver->midi_handle))) {532 if((retval=ffado_driver_midi_start(driver->midi_handle))) { 531 533 printError("Could not start MIDI threads"); 532 534 return retval; … … 535 537 #endif 536 538 537 if((retval=f reebob_streaming_start(driver->dev))) {539 if((retval=ffado_streaming_start(driver->dev))) { 538 540 printError("Could not start streaming threads"); 539 #ifdef F REEBOB_DRIVER_WITH_MIDI541 #ifdef FFADO_DRIVER_WITH_ASEQ_MIDI 540 542 if(driver->midi_handle) { 541 f reebob_driver_midi_stop(driver->midi_handle);543 ffado_driver_midi_stop(driver->midi_handle); 542 544 } 543 545 #endif … … 550 552 551 553 static int 552 f reebob_driver_stop (freebob_driver_t *driver)554 ffado_driver_stop (ffado_driver_t *driver) 553 555 { 554 556 int retval=0; 555 557 556 #ifdef F REEBOB_DRIVER_WITH_MIDI558 #ifdef FFADO_DRIVER_WITH_ASEQ_MIDI 557 559 if(driver->midi_handle) { 558 if((retval=f reebob_driver_midi_stop(driver->midi_handle))) {560 if((retval=ffado_driver_midi_stop(driver->midi_handle))) { 559 561 printError("Could not stop MIDI threads"); 560 562 return retval; … … 562 564 } 563 565 #endif 564 if((retval=f reebob_streaming_stop(driver->dev))) {566 if((retval=ffado_streaming_stop(driver->dev))) { 565 567 printError("Could not stop streaming threads"); 566 568 return retval; … … 572 574 573 575 static int 574 f reebob_driver_bufsize (freebob_driver_t* driver, jack_nframes_t nframes)576 ffado_driver_bufsize (ffado_driver_t* driver, jack_nframes_t nframes) 575 577 { 576 578 printError("Buffer size change requested but not supported!!!"); … … 591 593 typedef void (*JackDriverFinishFunction) (jack_driver_t *); 592 594 593 f reebob_driver_t *594 f reebob_driver_new (jack_client_t * client,595 ffado_driver_t * 596 ffado_driver_new (jack_client_t * client, 595 597 char *name, 596 f reebob_jack_settings_t *params)597 { 598 f reebob_driver_t *driver;598 ffado_jack_settings_t *params) 599 { 600 ffado_driver_t *driver; 599 601 600 602 assert(params); 601 603 602 if(f reebob_get_api_version() != 2) {603 printError("Incompatible libf reebob version! (%s)", freebob_get_version());604 if(ffado_get_api_version() != 2) { 605 printError("Incompatible libffado version! (%s)", ffado_get_version()); 604 606 return NULL; 605 607 } 606 608 607 printMessage("Starting Freebob backend (%s)", f reebob_get_version());608 609 driver = calloc (1, sizeof (f reebob_driver_t));609 printMessage("Starting Freebob backend (%s)", ffado_get_version()); 610 611 driver = calloc (1, sizeof (ffado_driver_t)); 610 612 611 613 /* Setup the jack interfaces */ 612 614 jack_driver_nt_init ((jack_driver_nt_t *) driver); 613 615 614 driver->nt_attach = (JackDriverNTAttachFunction) f reebob_driver_attach;615 driver->nt_detach = (JackDriverNTDetachFunction) f reebob_driver_detach;616 driver->nt_start = (JackDriverNTStartFunction) f reebob_driver_start;617 driver->nt_stop = (JackDriverNTStopFunction) f reebob_driver_stop;618 driver->nt_run_cycle = (JackDriverNTRunCycleFunction) f reebob_driver_run_cycle;619 driver->null_cycle = (JackDriverNullCycleFunction) f reebob_driver_null_cycle;620 driver->write = (JackDriverReadFunction) f reebob_driver_write;621 driver->read = (JackDriverReadFunction) f reebob_driver_read;622 driver->nt_bufsize = (JackDriverNTBufSizeFunction) f reebob_driver_bufsize;616 driver->nt_attach = (JackDriverNTAttachFunction) ffado_driver_attach; 617 driver->nt_detach = (JackDriverNTDetachFunction) ffado_driver_detach; 618 driver->nt_start = (JackDriverNTStartFunction) ffado_driver_start; 619 driver->nt_stop = (JackDriverNTStopFunction) ffado_driver_stop; 620 driver->nt_run_cycle = (JackDriverNTRunCycleFunction) ffado_driver_run_cycle; 621 driver->null_cycle = (JackDriverNullCycleFunction) ffado_driver_null_cycle; 622 driver->write = (JackDriverReadFunction) ffado_driver_write; 623 driver->read = (JackDriverReadFunction) ffado_driver_read; 624 driver->nt_bufsize = (JackDriverNTBufSizeFunction) ffado_driver_bufsize; 623 625 624 626 /* copy command line parameter contents to the driver structure */ 625 memcpy(&driver->settings,params,sizeof(f reebob_jack_settings_t));627 memcpy(&driver->settings,params,sizeof(ffado_jack_settings_t)); 626 628 627 629 /* prepare all parameters */ … … 646 648 647 649 if(!params->capture_ports) { 648 driver->device_options.directions |= F REEBOB_IGNORE_CAPTURE;650 driver->device_options.directions |= FFADO_IGNORE_CAPTURE; 649 651 } 650 652 651 653 if(!params->playback_ports) { 652 driver->device_options.directions |= F REEBOB_IGNORE_PLAYBACK;654 driver->device_options.directions |= FFADO_IGNORE_PLAYBACK; 653 655 } 654 656 … … 659 661 debugPrint(DEBUG_LEVEL_STARTUP, " sample rate: %d", driver->sample_rate); 660 662 661 return (f reebob_driver_t *) driver;663 return (ffado_driver_t *) driver; 662 664 663 665 } 664 666 665 667 static void 666 f reebob_driver_delete (freebob_driver_t *driver)668 ffado_driver_delete (ffado_driver_t *driver) 667 669 { 668 670 jack_driver_nt_finish ((jack_driver_nt_t *) driver); … … 670 672 } 671 673 672 #ifdef F REEBOB_DRIVER_WITH_MIDI674 #ifdef FFADO_DRIVER_WITH_ASEQ_MIDI 673 675 /* 674 676 * MIDI support … … 677 679 // the thread that will queue the midi events from the seq to the stream buffers 678 680 679 void * f reebob_driver_midi_queue_thread(void *arg)680 { 681 f reebob_driver_midi_handle_t *m=(freebob_driver_midi_handle_t *)arg;681 void * ffado_driver_midi_queue_thread(void *arg) 682 { 683 ffado_driver_midi_handle_t *m=(ffado_driver_midi_handle_t *)arg; 682 684 assert(m); 683 685 snd_seq_event_t *ev; … … 693 695 while ((snd_seq_event_input(m->seq_handle, &ev) > 0)) { 694 696 // get the port this event is originated from 695 f reebob_midi_port_t *port=NULL;697 ffado_midi_port_t *port=NULL; 696 698 for (i=0;i<m->nb_output_ports;i++) { 697 699 if(m->output_ports[i]->seq_port_nr == ev->dest.port) { … … 719 721 720 722 for(b=0;b<bytes_to_send;b++) { 721 f reebob_sample_t tmp_event=work_buffer[b];722 if(f reebob_streaming_write(m->dev, port->stream_nr, &tmp_event, 1)<1) {723 ffado_sample_t tmp_event=work_buffer[b]; 724 if(ffado_streaming_write(m->dev, port->stream_nr, &tmp_event, 1)<1) { 723 725 printError(" Midi send buffer overrun"); 724 726 } … … 734 736 735 737 // the dequeue thread (maybe we need one thread per stream) 736 void *f reebob_driver_midi_dequeue_thread (void *arg) {737 f reebob_driver_midi_handle_t *m=(freebob_driver_midi_handle_t *)arg;738 void *ffado_driver_midi_dequeue_thread (void *arg) { 739 ffado_driver_midi_handle_t *m=(ffado_driver_midi_handle_t *)arg; 738 740 739 741 int i; … … 750 752 unsigned int buff[64]; 751 753 752 f reebob_midi_port_t *port=m->input_ports[i];754 ffado_midi_port_t *port=m->input_ports[i]; 753 755 754 756 if(!port) { … … 757 759 758 760 do { 759 samples_read=f reebob_streaming_read(m->dev, port->stream_nr, buff, 64);761 samples_read=ffado_streaming_read(m->dev, port->stream_nr, buff, 64); 760 762 761 763 for (s=0;s<samples_read;s++) { … … 779 781 } 780 782 781 static f reebob_driver_midi_handle_t *freebob_driver_midi_init(freebob_driver_t *driver) {783 static ffado_driver_midi_handle_t *ffado_driver_midi_init(ffado_driver_t *driver) { 782 784 // int err; 783 785 … … 787 789 int i=0; 788 790 789 f reebob_device_t *dev=driver->dev;791 ffado_device_t *dev=driver->dev; 790 792 791 793 assert(dev); 792 794 793 f reebob_driver_midi_handle_t *m=calloc(1,sizeof(freebob_driver_midi_handle_t));795 ffado_driver_midi_handle_t *m=calloc(1,sizeof(ffado_driver_midi_handle_t)); 794 796 if (!m) { 795 797 printError("not enough memory to create midi structure"); … … 806 808 807 809 // find out the number of midi in/out ports we need to setup 808 nchannels=f reebob_streaming_get_nb_capture_streams(dev);810 nchannels=ffado_streaming_get_nb_capture_streams(dev); 809 811 810 812 m->nb_input_ports=0; 811 813 812 814 for (chn = 0; chn < nchannels; chn++) { 813 if(f reebob_streaming_get_capture_stream_type(dev, chn) == freebob_stream_type_midi) {815 if(ffado_streaming_get_capture_stream_type(dev, chn) == ffado_stream_type_midi) { 814 816 m->nb_input_ports++; 815 817 } 816 818 } 817 819 818 m->input_ports=calloc(m->nb_input_ports,sizeof(f reebob_midi_port_t *));820 m->input_ports=calloc(m->nb_input_ports,sizeof(ffado_midi_port_t *)); 819 821 if(!m->input_ports) { 820 822 printError("not enough memory to create midi structure"); … … 825 827 i=0; 826 828 for (chn = 0; chn < nchannels; chn++) { 827 if(f reebob_streaming_get_capture_stream_type(dev, chn) == freebob_stream_type_midi) {828 m->input_ports[i]=calloc(1,sizeof(f reebob_midi_port_t));829 if(ffado_streaming_get_capture_stream_type(dev, chn) == ffado_stream_type_midi) { 830 m->input_ports[i]=calloc(1,sizeof(ffado_midi_port_t)); 829 831 if(!m->input_ports[i]) { 830 832 // fixme … … 833 835 } 834 836 835 f reebob_streaming_get_capture_stream_name(dev, chn, buf, sizeof(buf) - 1);837 ffado_streaming_get_capture_stream_name(dev, chn, buf, sizeof(buf) - 1); 836 838 printMessage("Register MIDI IN port %s", buf); 837 839 … … 852 854 m->input_ports[i]->seq_port_nr=-1; 853 855 } else { 854 if(f reebob_streaming_set_capture_buffer_type(dev, chn, freebob_buffer_type_midi)) {856 if(ffado_streaming_set_capture_buffer_type(dev, chn, ffado_buffer_type_midi)) { 855 857 printError(" cannot set port buffer type for %s", buf); 856 858 m->input_ports[i]->stream_nr=-1; 857 859 m->input_ports[i]->seq_port_nr=-1; 858 860 } 859 if(f reebob_streaming_capture_stream_onoff(dev, chn, 1)) {861 if(ffado_streaming_capture_stream_onoff(dev, chn, 1)) { 860 862 printError(" cannot enable port %s", buf); 861 863 m->input_ports[i]->stream_nr=-1; … … 871 873 872 874 // playback 873 nchannels=f reebob_streaming_get_nb_playback_streams(dev);875 nchannels=ffado_streaming_get_nb_playback_streams(dev); 874 876 875 877 m->nb_output_ports=0; 876 878 877 879 for (chn = 0; chn < nchannels; chn++) { 878 if(f reebob_streaming_get_playback_stream_type(dev, chn) == freebob_stream_type_midi) {880 if(ffado_streaming_get_playback_stream_type(dev, chn) == ffado_stream_type_midi) { 879 881 m->nb_output_ports++; 880 882 } 881 883 } 882 884 883 m->output_ports=calloc(m->nb_output_ports,sizeof(f reebob_midi_port_t *));885 m->output_ports=calloc(m->nb_output_ports,sizeof(ffado_midi_port_t *)); 884 886 if(!m->output_ports) { 885 887 printError("not enough memory to create midi structure"); … … 894 896 i=0; 895 897 for (chn = 0; chn < nchannels; chn++) { 896 if(f reebob_streaming_get_playback_stream_type(dev, chn) == freebob_stream_type_midi) {897 m->output_ports[i]=calloc(1,sizeof(f reebob_midi_port_t));898 if(ffado_streaming_get_playback_stream_type(dev, chn) == ffado_stream_type_midi) { 899 m->output_ports[i]=calloc(1,sizeof(ffado_midi_port_t)); 898 900 if(!m->output_ports[i]) { 899 901 // fixme … … 902 904 } 903 905 904 f reebob_streaming_get_playback_stream_name(dev, chn, buf, sizeof(buf) - 1);906 ffado_streaming_get_playback_stream_name(dev, chn, buf, sizeof(buf) - 1); 905 907 printMessage("Register MIDI OUT port %s", buf); 906 908 … … 922 924 m->output_ports[i]->seq_port_nr=-1; 923 925 } else { 924 if(f reebob_streaming_set_playback_buffer_type(dev, chn, freebob_buffer_type_midi)) {926 if(ffado_streaming_set_playback_buffer_type(dev, chn, ffado_buffer_type_midi)) { 925 927 printError(" cannot set port buffer type for %s", buf); 926 928 m->input_ports[i]->stream_nr=-1; 927 929 m->input_ports[i]->seq_port_nr=-1; 928 930 } 929 if(f reebob_streaming_playback_stream_onoff(dev, chn, 1)) {931 if(ffado_streaming_playback_stream_onoff(dev, chn, 1)) { 930 932 printError(" cannot enable port %s", buf); 931 933 m->input_ports[i]->stream_nr=-1; … … 946 948 947 949 static int 948 f reebob_driver_midi_start (freebob_driver_midi_handle_t *m)950 ffado_driver_midi_start (ffado_driver_midi_handle_t *m) 949 951 { 950 952 assert(m); … … 954 956 m->queue_thread_priority= 955 957 m->driver->engine->control->client_priority + 956 F REEBOB_RT_PRIORITY_MIDI_RELATIVE;958 FFADO_RT_PRIORITY_MIDI_RELATIVE; 957 959 958 960 if (m->queue_thread_priority>98) { … … 966 968 } 967 969 968 if (jack_client_create_thread(NULL, &m->queue_thread, m->queue_thread_priority, m->queue_thread_realtime, f reebob_driver_midi_queue_thread, (void *)m)) {970 if (jack_client_create_thread(NULL, &m->queue_thread, m->queue_thread_priority, m->queue_thread_realtime, ffado_driver_midi_queue_thread, (void *)m)) { 969 971 printError(" cannot create midi queueing thread"); 970 972 return -1; 971 973 } 972 974 973 if (jack_client_create_thread(NULL, &m->dequeue_thread, m->queue_thread_priority, m->queue_thread_realtime, f reebob_driver_midi_dequeue_thread, (void *)m)) {975 if (jack_client_create_thread(NULL, &m->dequeue_thread, m->queue_thread_priority, m->queue_thread_realtime, ffado_driver_midi_dequeue_thread, (void *)m)) { 974 976 printError(" cannot create midi dequeueing thread"); 975 977 return -1; … … 979 981 980 982 static int 981 f reebob_driver_midi_stop (freebob_driver_midi_handle_t *m)983 ffado_driver_midi_stop (ffado_driver_midi_handle_t *m) 982 984 { 983 985 assert(m); … … 993 995 994 996 static void 995 f reebob_driver_midi_finish (freebob_driver_midi_handle_t *m)997 ffado_driver_midi_finish (ffado_driver_midi_handle_t *m) 996 998 { 997 999 assert(m); … … 1018 1020 */ 1019 1021 1020 const char driver_client_name[] = "f reebob_pcm";1022 const char driver_client_name[] = "firewire_pcm"; 1021 1023 1022 1024 const jack_driver_desc_t * … … 1029 1031 desc = calloc (1, sizeof (jack_driver_desc_t)); 1030 1032 1031 strcpy (desc->name, "f reebob");1033 strcpy (desc->name, "firewire"); 1032 1034 desc->nparams = 8; 1033 1035 … … 1115 1117 const jack_driver_param_t * param; 1116 1118 1117 f reebob_jack_settings_t cmlparams;1119 ffado_jack_settings_t cmlparams; 1118 1120 1119 1121 char *device_name="hw:0"; … … 1197 1199 jack_error("Freebob using Firewire port %d, node %d",cmlparams.port,cmlparams.node_id); 1198 1200 1199 driver=(jack_driver_t *)f reebob_driver_new (client, "freebob_pcm", &cmlparams);1201 driver=(jack_driver_t *)ffado_driver_new (client, "ffado_pcm", &cmlparams); 1200 1202 1201 1203 return driver; … … 1205 1207 driver_finish (jack_driver_t *driver) 1206 1208 { 1207 f reebob_driver_t *drv=(freebob_driver_t *) driver;1209 ffado_driver_t *drv=(ffado_driver_t *) driver; 1208 1210 // If jack hasn't called the detach method, do it now. As of jack 0.101.1 1209 1211 // the detach method was not being called explicitly on closedown, and 1210 1212 // we need it to at least deallocate the iso resources. 1211 1213 if (drv->dev != NULL) 1212 f reebob_driver_detach(drv);1213 f reebob_driver_delete (drv);1214 } 1214 ffado_driver_detach(drv); 1215 ffado_driver_delete (drv); 1216 } trunk/libffado/support/jack/ffado_driver.h
r444 r445 1 /* freebob_driver.h2 * 3 * FreeBob Backend for Jack4 * F reeBob= Firewire (pro-)audio for linux5 * 6 * http://f reebob.sf.net1 /* 2 * FireWire Backend for Jack 3 * using FFADO 4 * FFADO = Firewire (pro-)audio for linux 5 * 6 * http://ffado.sf.net 7 7 * http://jackit.sf.net 8 8 * 9 * Copyright (C) 2005 Pieter Palmers <pieterpalmers@users.sourceforge.net>9 * Copyright (C) 2005-2007 Pieter Palmers 10 10 * 11 11 * This program is free software; you can redistribute it and/or modify … … 29 29 */ 30 30 31 #ifndef __JACK_FREEBOB_DRIVER_H__ 32 #define __JACK_FREEBOB_DRIVER_H__ 33 34 #define FREEBOB_DRIVER_WITH_MIDI 35 36 #include <libfreebob/freebob.h> 37 #include <libfreebob/freebob_streaming.h> 31 #ifndef __JACK_FFADO_DRIVER_H__ 32 #define __JACK_FFADO_DRIVER_H__ 33 34 #define FFADO_DRIVER_WITH_ASEQ_MIDI 35 36 #include <libffado/ffado.h> 38 37 39 38 #include <jack/driver.h> … … 114 113 115 114 // thread priority setup 116 #define F REEBOB_RT_PRIORITY_PACKETIZER_RELATIVE 5117 118 #ifdef F REEBOB_DRIVER_WITH_MIDI115 #define FFADO_RT_PRIORITY_PACKETIZER_RELATIVE 5 116 117 #ifdef FFADO_DRIVER_WITH_ASEQ_MIDI 119 118 120 119 #define ALSA_SEQ_BUFF_SIZE 1024 … … 125 124 // but I think it should be smaller than the packetizer thread in order not 126 125 // to lose any packets 127 #define F REEBOB_RT_PRIORITY_MIDI_RELATIVE 4128 129 #endif 130 131 typedef struct _f reebob_driver freebob_driver_t;126 #define FFADO_RT_PRIORITY_MIDI_RELATIVE 4 127 128 #endif 129 130 typedef struct _ffado_driver ffado_driver_t; 132 131 133 132 /* … … 135 134 */ 136 135 137 typedef struct _f reebob_jack_settings freebob_jack_settings_t;138 struct _f reebob_jack_settings {136 typedef struct _ffado_jack_settings ffado_jack_settings_t; 137 struct _ffado_jack_settings { 139 138 int period_size_set; 140 139 jack_nframes_t period_size; … … 158 157 int snoop_mode; 159 158 160 f reebob_handle_t fb_handle;159 ffado_handle_t fb_handle; 161 160 }; 162 161 163 #ifdef FREEBOB_DRIVER_WITH_MIDI 164 162 #ifdef FFADO_DRIVER_WITH_ASEQ_MIDI 165 163 166 164 typedef struct { … … 169 167 snd_midi_event_t *parser; 170 168 snd_seq_t *seq_handle; 171 } f reebob_midi_port_t;172 173 typedef struct _f reebob_driver_midi_handle {174 f reebob_device_t *dev;175 f reebob_driver_t *driver;169 } ffado_midi_port_t; 170 171 typedef struct _ffado_driver_midi_handle { 172 ffado_device_t *dev; 173 ffado_driver_t *driver; 176 174 177 175 snd_seq_t *seq_handle; … … 185 183 int nb_output_ports; 186 184 187 f reebob_midi_port_t **input_ports;188 f reebob_midi_port_t **output_ports;189 190 f reebob_midi_port_t **input_stream_port_map;185 ffado_midi_port_t **input_ports; 186 ffado_midi_port_t **output_ports; 187 188 ffado_midi_port_t **input_stream_port_map; 191 189 int *output_port_stream_map; 192 190 193 191 194 } f reebob_driver_midi_handle_t;192 } ffado_driver_midi_handle_t; 195 193 196 194 #endif … … 200 198 201 199 202 struct _f reebob_driver200 struct _ffado_driver 203 201 { 204 202 JACK_DRIVER_NT_DECL … … 220 218 221 219 /* settings from the command line */ 222 f reebob_jack_settings_t settings;220 ffado_jack_settings_t settings; 223 221 224 222 /* the freebob virtual device */ 225 f reebob_device_t *dev;223 ffado_device_t *dev; 226 224 227 225 JSList *capture_ports; … … 231 229 channel_t capture_nchannels; 232 230 233 f reebob_device_info_t device_info;234 f reebob_options_t device_options;235 236 #ifdef F REEBOB_DRIVER_WITH_MIDI237 f reebob_driver_midi_handle_t *midi_handle;231 ffado_device_info_t device_info; 232 ffado_options_t device_options; 233 234 #ifdef FFADO_DRIVER_WITH_ASEQ_MIDI 235 ffado_driver_midi_handle_t *midi_handle; 238 236 #endif 239 237 … … 242 240 243 241 244 #endif /* __JACK_F REEBOB_DRIVER_H__ */245 246 242 #endif /* __JACK_FFADO_DRIVER_H__ */ 243 244 trunk/libffado/tests/Makefile.am
r435 r445 1 # Makefile.am - Makefile template 2 # Copyright (C) 2005,06 by Daniel Wagner. 1 # Makefile.am 3 2 # 4 # This file is part of FreeBoB. 3 # Copyright (C) 2005-2007 by Daniel Wagner. 4 # Copyright (C) 2005-2007 by Pieter Palmers. 5 5 # 6 # FreeBoB is free software; you can redistribute it and/or modify 7 # it under the terms of the GNU General Public License as published by 8 # the Free Software Foundation; either version 2 of the License, or 9 # (at your option) any later version. 10 # FreeBoB is distributed in the hope that it will be useful, 6 # This file is part of FFADO. 7 # FFADO = Free Firewire (pro-)audio drivers for linux 8 # 9 # FFADO is based upon FreeBoB. 10 # 11 # FFADO is free software. 12 # 13 # you can redistribute and/or modify the applications 14 # under the terms of the GNU General Public License 15 # version 2, as published by the Free Software Foundation 16 # 17 # FFADO is distributed in the hope that it will be useful, 11 18 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU General Public License for more details. 14 # You should have received a copy of the GNU General Public License 15 # along with FreeBoB; if not, write to the Free Software 20 # GNU (Lesser) General Public License for more details. 21 # 22 # You should have received a copy of the GNU (Lesser) General Public License 23 # along with FFADO; if not, write to the Free Software 16 24 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 25 18 # SUBDIRS =streaming26 #SUBDIRS=streaming 19 27 20 28 INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src $(LIBXML_CFLAGS) \ 21 29 $(LIBAVC1394_CFLAGS) $(LIBXMLCPP_CFLAGS) 22 30 23 31 noinst_PROGRAMS = 24 32 25 33 if BUILD_TESTS 26 noinst_PROGRAMS += test-f reebobtest-extplugcmd test-fw410 \27 test-volume test-mixer test-cycletimer test-sytmonitor \28 test-timestampedbuffer test-ieee1394service34 noinst_PROGRAMS += test-ffado test-extplugcmd test-fw410 \ 35 test-volume test-mixer test-cycletimer test-sytmonitor \ 36 test-timestampedbuffer test-ieee1394service 29 37 endif 30 38 31 noinst_HEADERS = 39 noinst_HEADERS = 32 40 33 test_f reebob_SOURCES = test-freebob.cpp34 test_f reebob_LDADD = $(top_builddir)/src/libfreebob.la \41 test_ffado_SOURCES = test-ffado.cpp 42 test_ffado_LDADD = $(top_builddir)/src/libffado.la \ 35 43 $(LIBXML_LIBS) $(LIBAVC1394_LIBS) $(LIBIEC61883_LIBS) 36 44 37 45 test_extplugcmd_SOURCES = test-extplugcmd.cpp 38 test_extplugcmd_LDADD = $(top_builddir)/src/libf reebob.la \46 test_extplugcmd_LDADD = $(top_builddir)/src/libffado.la \ 39 47 $(LIBAVC1394_LIBS) 40 48 41 49 test_volume_SOURCES = test-volume.cpp 42 test_volume_LDADD = $(top_builddir)/src/libf reebob.la \50 test_volume_LDADD = $(top_builddir)/src/libffado.la \ 43 51 $(LIBAVC1394_LIBS) 44 52 45 53 test_mixer_SOURCES = test-mixer.cpp 46 test_mixer_LDADD = $(top_builddir)/src/libf reebob.la \54 test_mixer_LDADD = $(top_builddir)/src/libffado.la \ 47 55 $(LIBAVC1394_LIBS) 48 56 … … 51 59 52 60 test_ieee1394service_SOURCES = test-ieee1394service.cpp 53 test_ieee1394service_LDADD = $(top_builddir)/src/libf reebob.la \54 $(LIBAVC1394_LIBS) $(LIBIEC61883_LIBS) -lrom139461 test_ieee1394service_LDADD = $(top_builddir)/src/libffado.la \ 62 $(LIBAVC1394_LIBS) $(LIBIEC61883_LIBS) -lrom1394 55 63 56 64 #TESTS_ENVIRONMENT 57 TEST = test-f reebob65 TEST = test-ffado 58 66 59 test_cycletimer_LDADD = $(top_builddir)/src/libf reebob.la $(LIBIEC61883_LIBS) \67 test_cycletimer_LDADD = $(top_builddir)/src/libffado.la $(LIBIEC61883_LIBS) \ 60 68 $(LIBRAW1394_LIBS) $(LIBAVC1394_LIBS) 61 69 test_cycletimer_SOURCES = test-cycletimer.cpp 62 70 63 test_sytmonitor_LDADD = $(top_builddir)/src/libf reebob.la $(LIBIEC61883_LIBS) \71 test_sytmonitor_LDADD = $(top_builddir)/src/libffado.la $(LIBIEC61883_LIBS) \ 64 72 $(LIBRAW1394_LIBS) $(LIBAVC1394_LIBS) 65 73 test_sytmonitor_SOURCES = test-sytmonitor.cpp SytMonitor.cpp \ 66 SytMonitor.h74 SytMonitor.h 67 75 68 test_timestampedbuffer_LDADD = $(top_builddir)/src/libf reebob.la $(LIBIEC61883_LIBS) \76 test_timestampedbuffer_LDADD = $(top_builddir)/src/libffado.la $(LIBIEC61883_LIBS) \ 69 77 $(LIBRAW1394_LIBS) $(LIBAVC1394_LIBS) 70 78 test_timestampedbuffer_SOURCES = test-timestampedbuffer.cpp trunk/libffado/tests/streaming/debugtools.c
r159 r445 1 /* 2 * Copyright (C) 2005-2007 by by Daniel Wagner 3 * Copyright (C) 2005-2007 by 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 * FFADO is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU General Public License as published by 12 * the Free Software Foundation; either version 2 of the License, or 13 * (at your option) any later version. 14 * FFADO 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 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with FFADO; if not, write to the Free Software 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 22 * MA 02111-1307 USA. 23 */ 24 1 25 #include <libfreebob/freebob.h> 2 26 #include <libraw1394/raw1394.h> trunk/libffado/tests/streaming/debugtools.h
r159 r445 1 /* 2 * Copyright (C) 2005-2007 by by Daniel Wagner 3 * Copyright (C) 2005-2007 by 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 * FFADO is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU General Public License as published by 12 * the Free Software Foundation; either version 2 of the License, or 13 * (at your option) any later version. 14 * FFADO 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 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with FFADO; if not, write to the Free Software 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 22 * MA 02111-1307 USA. 23 */ 24 1 25 #ifndef DEBUG_TOOLS_H 2 26 #define DEBUG_TOOLS_H trunk/libffado/tests/streaming/Makefile.am
r335 r445 1 # Makefile.am - Makefile template 2 # Copyright (C) 2005 by Daniel Wagner. 3 # Copyright (C) 2006 by Pieter Palmers. 1 # Makefile.am 4 2 # 5 # This file is part of FreeBoB. 3 # Copyright (C) 2005-2007 by Daniel Wagner. 4 # Copyright (C) 2005-2007 by Pieter Palmers. 6 5 # 7 # FreeBoB is free software; you can redistribute it and/or modify 8 # it under the terms of the GNU General Public License as published by 9 # the Free Software Foundation; either version 2 of the License, or 10 # (at your option) any later version. 11 # FreeBoB is distributed in the hope that it will be useful, 6 # This file is part of FFADO. 7 # FFADO = Free Firewire (pro-)audio drivers for linux 8 # 9 # FFADO is based upon FreeBoB. 10 # 11 # FFADO is free software. 12 # 13 # you can redistribute and/or modify the applications 14 # under the terms of the GNU General Public License 15 # version 2, as published by the Free Software Foundation 16 # 17 # FFADO is distributed in the hope that it will be useful, 12 18 # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 # GNU General Public License for more details. 15 # You should have received a copy of the GNU General Public License 16 # along with FreeBoB; if not, write to the Free Software 20 # GNU (Lesser) General Public License for more details. 21 # 22 # You should have received a copy of the GNU (Lesser) General Public License 23 # along with FFADO; if not, write to the Free Software 17 24 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 25 … … 23 30 24 31 teststreaming_SOURCES = teststreaming.c debugtools.c 25 teststreaming_LDADD = $(top_builddir)/src/libf reebob.la \32 teststreaming_LDADD = $(top_builddir)/src/libffado.la \ 26 33 $(LIBAVC1394_LIBS) $(LIBIEC61883_LIBS) 27 34 28 35 teststreaming2_SOURCES = teststreaming2.c debugtools.c 29 teststreaming2_LDADD = $(top_builddir)/src/libf reebob.la \36 teststreaming2_LDADD = $(top_builddir)/src/libffado.la \ 30 37 $(LIBAVC1394_LIBS) $(LIBIEC61883_LIBS) 31 38 32 39 teststreaming3_SOURCES = teststreaming3.c debugtools.c 33 teststreaming3_LDADD = $(top_builddir)/src/libf reebob.la \40 teststreaming3_LDADD = $(top_builddir)/src/libffado.la \ 34 41 $(LIBAVC1394_LIBS) $(LIBIEC61883_LIBS) 35 42 36 43 testmidistreaming1_SOURCES = testmidistreaming1.c debugtools.c 37 testmidistreaming1_LDADD = $(top_builddir)/src/libf reebob.la -lasound \44 testmidistreaming1_LDADD = $(top_builddir)/src/libffado.la -lasound \ 38 45 $(LIBAVC1394_LIBS) $(LIBIEC61883_LIBS) trunk/libffado/tests/streaming/test-isohandling.cpp
r419 r445 1 /*************************************************************************** 2 Copyright (C) 2005 by Pieter Palmers * 3 * 4 This program is free software; you can redistribute it and/or modify * 5 it under the terms of the GNU General Public License as published by * 6 the Free Software Foundation; either version 2 of the License, or * 7 (at your option) any later version. * 8 * 9 This program is distributed in the hope that it will be useful, * 10 but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 GNU General Public License for more details. * 13 * 14 You should have received a copy of the GNU General Public License * 15 along with this program; if not, write to the * 16 Free Software Foundation, Inc., * 17 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 ***************************************************************************/ 1 /* 2 * Copyright (C) 2005-2007 by 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 * FFADO is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or 12 * (at your option) any later version. 13 * FFADO 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 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with FFADO; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21 * MA 02111-1307 USA. 22 */ 19 23 20 24 #ifdef HAVE_CONFIG_H … … 46 50 static void sighandler (int sig) 47 51 { 48 run = 0;52 run = 0; 49 53 } 50 54 … … 52 56 { 53 57 54 int retval=0;55 int i=0;56 run=1;57 58 signal (SIGINT, sighandler);59 signal (SIGPIPE, sighandler);60 61 printf("Freebobstreaming test application\n");62 printf(" ISO handler tests\n");63 64 // also create a processor manager to manage the actual stream65 // processors 66 StreamProcessorManager *procMan = new StreamProcessorManager(512,3);67 if(!procMan) {68 printf("Could not create StreamProcessorManager\n");69 return -1;70 }71 procMan->setVerboseLevel(DEBUG_LEVEL_VERBOSE);72 73 // now we can allocate the stream processors themselves74 75 // StreamProcessor *spt = new AmdtpTransmitStreamProcessor(3,2,44100,10);76 // if(!spt) {77 // printf("Could not create transmit AmdtpTransmitStreamProcessor\n");78 // return -1;79 // }80 // spt->setVerboseLevel(DEBUG_LEVEL_VERBOSE);81 82 AmdtpReceiveStreamProcessor *spr = new AmdtpReceiveStreamProcessor(2,44100,7);83 // ReceiveStreamProcessor *spr = new ReceiveStreamProcessor(0,2,44100);84 if(!spr) {85 printf("Could not create receive AmdtpStreamProcessor\n");86 return -1;87 }88 spr->setVerboseLevel(DEBUG_LEVEL_VERBOSE);89 spr->setChannel(0);90 91 AmdtpReceiveStreamProcessor *spr2 = new AmdtpReceiveStreamProcessor(2,44100,11);92 // ReceiveStreamProcessor *spr = new ReceiveStreamProcessor(0,2,44100);93 if(!spr2) {94 printf("Could not create receive AmdtpStreamProcessor\n");95 return -1;96 }97 spr2->setVerboseLevel(DEBUG_LEVEL_VERBOSE);98 spr2->setChannel(1);99 100 // printf("----------------------\n");101 // if (procMan->registerProcessor(spt)) {102 // printf("Could not register transmit stream processor with the Processor manager\n");103 // return -1;104 // }105 // printf("----------------------\n");106 107 // also register it with the processor manager, so that it is aware of 108 // buffer sizes etc...109 if (procMan->registerProcessor(spr)) {110 printf("Could not register receive stream processor with the Processor manager\n");111 return -1;112 }113 printf("----------------------\n");114 115 if (procMan->registerProcessor(spr2)) {116 printf("Could not register receive stream processor with the Processor manager\n");117 return -1;118 }119 printf("----------------------\n");120 121 AmdtpAudioPort *p1=new AmdtpAudioPort(122 std::string("Test port 1"), 123 AmdtpAudioPort::E_Capture, 124 1, 125 0, 126 AmdtpPortInfo::E_MBLA, 127 0128 );129 if (!p1) {130 printf("Could not create port 1\n");131 return -1;132 }133 134 p1->setBufferSize(512);135 136 printf("----------------------\n");137 138 if (spr2->addPort(p1)) {139 printf("Could not register port with receive stream processor\n");140 return -1;141 }142 143 Util::PosixThread *thread=new Util::PosixThread(procMan);144 145 146 procMan->prepare();147 148 // start the runner149 thread->Start();150 printf("----------------------\n");151 152 if(procMan->start()) {153 printf("Could not start handlers\n");154 return -1;155 }156 printf("----------------------\n");157 158 int periods=0;159 int periods_print=0;160 while(run) {161 periods++;162 if(periods>periods_print) {163 printf("\n");164 printf("============================================\n");165 procMan->dumpInfo();166 printf("--------------------------------------------\n");167 /* hexDumpQuadlets((quadlet_t*)(p1->getBufferAddress()),10);168 printf("--------------------------------------------\n");*/169 hexDumpQuadlets((quadlet_t*)(p1->getBufferAddress()),10);170 printf("============================================\n");171 printf("\n");172 periods_print+=100;173 }174 procMan->waitForPeriod();175 procMan->transfer();176 177 }178 179 thread->Stop();180 181 procMan->stop();182 183 // procMan->unregisterProcessor(spt);184 procMan->unregisterProcessor(spr);185 procMan->unregisterProcessor(spr2);186 187 delete thread;188 189 delete procMan;190 191 // delete spt;192 delete spr;193 delete spr2;194 195 printf("Bye...\n");58 int retval=0; 59 int i=0; 60 run=1; 61 62 signal (SIGINT, sighandler); 63 signal (SIGPIPE, sighandler); 64 65 printf("FFADO streaming test application\n"); 66 printf(" ISO handler tests\n"); 67 68 // also create a processor manager to manage the actual stream 69 // processors 70 StreamProcessorManager *procMan = new StreamProcessorManager(512,3); 71 if(!procMan) { 72 printf("Could not create StreamProcessorManager\n"); 73 return -1; 74 } 75 procMan->setVerboseLevel(DEBUG_LEVEL_VERBOSE); 76 77 // now we can allocate the stream processors themselves 78 79 // StreamProcessor *spt = new AmdtpTransmitStreamProcessor(3,2,44100,10); 80 // if(!spt) { 81 // printf("Could not create transmit AmdtpTransmitStreamProcessor\n"); 82 // return -1; 83 // } 84 // spt->setVerboseLevel(DEBUG_LEVEL_VERBOSE); 85 86 AmdtpReceiveStreamProcessor *spr = new AmdtpReceiveStreamProcessor(2,44100,7); 87 // ReceiveStreamProcessor *spr = new ReceiveStreamProcessor(0,2,44100); 88 if(!spr) { 89 printf("Could not create receive AmdtpStreamProcessor\n"); 90 return -1; 91 } 92 spr->setVerboseLevel(DEBUG_LEVEL_VERBOSE); 93 spr->setChannel(0); 94 95 AmdtpReceiveStreamProcessor *spr2 = new AmdtpReceiveStreamProcessor(2,44100,11); 96 // ReceiveStreamProcessor *spr = new ReceiveStreamProcessor(0,2,44100); 97 if(!spr2) { 98 printf("Could not create receive AmdtpStreamProcessor\n"); 99 return -1; 100 } 101 spr2->setVerboseLevel(DEBUG_LEVEL_VERBOSE); 102 spr2->setChannel(1); 103 104 // printf("----------------------\n"); 105 // if (procMan->registerProcessor(spt)) { 106 // printf("Could not register transmit stream processor with the Processor manager\n"); 107 // return -1; 108 // } 109 // printf("----------------------\n"); 110 111 // also register it with the processor manager, so that it is aware of 112 // buffer sizes etc... 113 if (procMan->registerProcessor(spr)) { 114 printf("Could not register receive stream processor with the Processor manager\n"); 115 return -1; 116 } 117 printf("----------------------\n"); 118 119 if (procMan->registerProcessor(spr2)) { 120 printf("Could not register receive stream processor with the Processor manager\n"); 121 return -1; 122 } 123 printf("----------------------\n"); 124 125 AmdtpAudioPort *p1=new AmdtpAudioPort( 126 std::string("Test port 1"), 127 AmdtpAudioPort::E_Capture, 128 1, 129 0, 130 AmdtpPortInfo::E_MBLA, 131 0 132 ); 133 if (!p1) { 134 printf("Could not create port 1\n"); 135 return -1; 136 } 137 138 p1->setBufferSize(512); 139 140 printf("----------------------\n"); 141 142 if (spr2->addPort(p1)) { 143 printf("Could not register port with receive stream processor\n"); 144 return -1; 145 } 146 147 Util::PosixThread *thread=new Util::PosixThread(procMan); 148 149 150 procMan->prepare(); 151 152 // start the runner 153 thread->Start(); 154 printf("----------------------\n"); 155 156 if(procMan->start()) { 157 printf("Could not start handlers\n"); 158 return -1; 159 } 160 printf("----------------------\n"); 161 162 int periods=0; 163 int periods_print=0; 164 while(run) { 165 periods++; 166 if(periods>periods_print) { 167 printf("\n"); 168 printf("============================================\n"); 169 procMan->dumpInfo(); 170 printf("--------------------------------------------\n"); 171 /* hexDumpQuadlets((quadlet_t*)(p1->getBufferAddress()),10); 172 printf("--------------------------------------------\n");*/ 173 hexDumpQuadlets((quadlet_t*)(p1->getBufferAddress()),10); 174 printf("============================================\n"); 175 printf("\n"); 176 periods_print+=100; 177 } 178 procMan->waitForPeriod(); 179 procMan->transfer(); 180 181 } 182 183 thread->Stop(); 184 185 procMan->stop(); 186 187 // procMan->unregisterProcessor(spt); 188 procMan->unregisterProcessor(spr); 189 procMan->unregisterProcessor(spr2); 190 191 delete thread; 192 193 delete procMan; 194 195 // delete spt; 196 delete spr; 197 delete spr2; 198 199 printf("Bye...\n"); 196 200 197 201 trunk/libffado/tests/streaming/testmidistreaming1.c
r334 r445 1 /*************************************************************************** 2 Copyright (C) 2005 by Pieter Palmers * 3 * 4 This program is free software; you can redistribute it and/or modify * 5 it under the terms of the GNU General Public License as published by * 6 the Free Software Foundation; either version 2 of the License, or * 7 (at your option) any later version. * 8 * 9 This program is distributed in the hope that it will be useful, * 10 but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 GNU General Public License for more details. * 13 * 14 You should have received a copy of the GNU General Public License * 15 along with this program; if not, write to the * 16 Free Software Foundation, Inc., * 17 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 ***************************************************************************/ 1 /* 2 * Copyright (C) 2005-2007 by 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 * FFADO is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or 12 * (at your option) any later version. 13 * FFADO 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 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with FFADO; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21 * MA 02111-1307 USA. 22 */ 19 23 20 24 trunk/libffado/tests/streaming/teststreaming.c
r272 r445 1 /*************************************************************************** 2 Copyright (C) 2005 by Pieter Palmers * 3 * 4 This program is free software; you can redistribute it and/or modify * 5 it under the terms of the GNU General Public License as published by * 6 the Free Software Foundation; either version 2 of the License, or * 7 (at your option) any later version. * 8 * 9 This program is distributed in the hope that it will be useful, * 10 but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 GNU General Public License for more details. * 13 * 14 You should have received a copy of the GNU General Public License * 15 along with this program; if not, write to the * 16 Free Software Foundation, Inc., * 17 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 ***************************************************************************/ 1 /* 2 * Copyright (C) 2005-2007 by 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 * FFADO is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or 12 * (at your option) any later version. 13 * FFADO 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 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with FFADO; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21 * MA 02111-1307 USA. 22 */ 23 19 24 /** 20 25 * Test application for the per-stream decode API trunk/libffado/tests/streaming/teststreaming2.c
r296 r445 1 /*************************************************************************** 2 Copyright (C) 2005 by Pieter Palmers * 3 * 4 This program is free software; you can redistribute it and/or modify * 5 it under the terms of the GNU General Public License as published by * 6 the Free Software Foundation; either version 2 of the License, or * 7 (at your option) any later version. * 8 * 9 This program is distributed in the hope that it will be useful, * 10 but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 GNU General Public License for more details. * 13 * 14 You should have received a copy of the GNU General Public License * 15 along with this program; if not, write to the * 16 Free Software Foundation, Inc., * 17 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 ***************************************************************************/ 1 /* 2 * Copyright (C) 2005-2007 by 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 * FFADO is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or 12 * (at your option) any later version. 13 * FFADO 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 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with FFADO; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21 * MA 02111-1307 USA. 22 */ 19 23 20 24 trunk/libffado/tests/streaming/teststreaming3.c
r334 r445 1 /*************************************************************************** 2 Copyright (C) 2005 by Pieter Palmers * 3 * 4 This program is free software; you can redistribute it and/or modify * 5 it under the terms of the GNU General Public License as published by * 6 the Free Software Foundation; either version 2 of the License, or * 7 (at your option) any later version. * 8 * 9 This program is distributed in the hope that it will be useful, * 10 but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 GNU General Public License for more details. * 13 * 14 You should have received a copy of the GNU General Public License * 15 along with this program; if not, write to the * 16 Free Software Foundation, Inc., * 17 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 ***************************************************************************/ 1 /* 2 * Copyright (C) 2005-2007 by 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 * FFADO is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or 12 * (at your option) any later version. 13 * FFADO 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 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with FFADO; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21 * MA 02111-1307 USA. 22 */ 19 23 20 24 trunk/libffado/tests/SytMonitor.cpp
r399 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 2 * Copyright (C) 2005-2007 by Pieter Palmers 6 3 * 7 * http://freebob.sf.net 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 8 6 * 9 * Copyright (C) 2005,2006,2007 Pieter Palmers <pieterpalmers@users.sourceforge.net>7 * FFADO is based upon FreeBoB 10 8 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 9 * FFADO is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or 12 * (at your option) any later version. 13 * FFADO 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 16 * GNU General Public License for more details. 15 17 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 18 * You should have received a copy of the GNU General Public License 19 * along with FFADO; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21 * MA 02111-1307 USA. 26 22 * 27 23 */ … … 41 37 SytMonitor::SytMonitor(int port) 42 38 : IsoStream(IsoStream::EST_Receive, port) { 43 m_cinfo_buffer=f reebob_ringbuffer_create(16384*sizeof(struct cycle_info));39 m_cinfo_buffer=ffado_ringbuffer_create(16384*sizeof(struct cycle_info)); 44 40 45 41 } 46 42 47 43 SytMonitor::~SytMonitor() { 48 freebob_ringbuffer_free(m_cinfo_buffer);44 ffado_ringbuffer_free(m_cinfo_buffer); 49 45 50 46 } 51 47 52 enum raw1394_iso_disposition 53 SytMonitor::putPacket(unsigned char *data, unsigned int length, 54 unsigned char channel, unsigned char tag, unsigned char sy, 48 enum raw1394_iso_disposition 49 SytMonitor::putPacket(unsigned char *data, unsigned int length, 50 unsigned char channel, unsigned char tag, unsigned char sy, 55 51 unsigned int cycle, unsigned int dropped) { 56 52 enum raw1394_iso_disposition retval=RAW1394_ISO_OK; 57 53 58 54 struct iec61883_packet *packet = (struct iec61883_packet *) data; 59 55 unsigned int syt_timestamp=ntohs(packet->syt); 60 56 61 57 if (syt_timestamp == 0xFFFF) { 62 58 return RAW1394_ISO_OK; 63 59 } 64 60 65 61 uint32_t m_full_timestamp; 66 62 uint32_t m_full_timestamp_ticks; 67 63 68 64 debugOutput(DEBUG_LEVEL_VERBOSE,"%2u,%2u: CY=%4u, SYT=%08X (%3u secs + %4u cycles + %04u ticks)\n", 69 65 m_port,channel, 70 66 cycle,syt_timestamp, 71 CYCLE_TIMER_GET_SECS(syt_timestamp), 72 CYCLE_TIMER_GET_CYCLES(syt_timestamp), 67 CYCLE_TIMER_GET_SECS(syt_timestamp), 68 CYCLE_TIMER_GET_CYCLES(syt_timestamp), 73 69 CYCLE_TIMER_GET_OFFSET(syt_timestamp) 74 70 75 71 ); 76 72 77 73 // reconstruct the full cycle 78 74 unsigned int cc=m_handler->getCycleTimer(); 79 75 80 76 unsigned int cc_cycles=CYCLE_TIMER_GET_CYCLES(cc); 81 77 82 78 unsigned int cc_seconds=CYCLE_TIMER_GET_SECS(cc); 83 84 79 80 85 81 // the cycletimer has wrapped since this packet was received 86 // we want cc_seconds to reflect the 'seconds' at the point this 82 // we want cc_seconds to reflect the 'seconds' at the point this 87 83 // was received 88 84 if (cycle>cc_cycles) cc_seconds--; 89 85 90 86 m_full_timestamp_ticks=sytRecvToFullTicks((uint32_t)syt_timestamp, cycle, cc); 91 87 m_full_timestamp=TICKS_TO_CYCLE_TIMER(m_full_timestamp_ticks); 92 88 93 89 struct cycle_info cif; 94 90 cif.cycle=cycle; 95 91 cif.seconds=cc_seconds; 96 92 97 93 cif.syt=packet->syt; 98 94 cif.full_syt=m_full_timestamp; 99 95 100 96 // now we reconstruct the presentation time 101 97 cif.pres_seconds = CYCLE_TIMER_GET_SECS(m_full_timestamp); … … 103 99 cif.pres_offset = CYCLE_TIMER_GET_OFFSET(m_full_timestamp); 104 100 cif.pres_ticks = m_full_timestamp_ticks; 105 101 106 102 if (cif.pres_offset != (syt_timestamp & 0xFFF)) { 107 debugOutput(DEBUG_LEVEL_NORMAL,"P-offset error: %04X != %04X (P: %08X, R: %08X)\n", 103 debugOutput(DEBUG_LEVEL_NORMAL,"P-offset error: %04X != %04X (P: %08X, R: %08X)\n", 108 104 cif.pres_offset, syt_timestamp & 0xFFF, m_full_timestamp, syt_timestamp); 109 105 } 110 106 if ((cif.pres_cycle & 0xF) != ((syt_timestamp & 0xF000)>>12)) { 111 debugOutput(DEBUG_LEVEL_NORMAL,"P-cycle error: %01X != %01X (P: %08X, R: %08X)\n", 107 debugOutput(DEBUG_LEVEL_NORMAL,"P-cycle error: %01X != %01X (P: %08X, R: %08X)\n", 112 108 cif.pres_cycle &0xF, (syt_timestamp & 0xF000)>>12, m_full_timestamp, syt_timestamp); 113 109 } 114 110 115 111 putCycleInfo(&cif); 116 112 … … 119 115 120 116 bool SytMonitor::putCycleInfo(struct cycle_info *cif) { 121 if(freebob_ringbuffer_write(m_cinfo_buffer,(char *)cif,sizeof(struct cycle_info)) 122 !=sizeof(struct cycle_info)) { 123 return false; 124 } 125 return true; 126 } 127 128 bool SytMonitor::readNextCycleInfo(struct cycle_info *cif) { 129 if(freebob_ringbuffer_peek(m_cinfo_buffer,(char *)cif,sizeof(struct cycle_info)) 117 if(ffado_ringbuffer_write(m_cinfo_buffer,(char *)cif,sizeof(struct cycle_info)) 130 118 !=sizeof(struct cycle_info)) { 131 119 return false; 132 120 } 133 121 return true; 134 122 } 123 124 bool SytMonitor::readNextCycleInfo(struct cycle_info *cif) { 125 if(ffado_ringbuffer_peek(m_cinfo_buffer,(char *)cif,sizeof(struct cycle_info)) 126 !=sizeof(struct cycle_info)) { 127 return false; 128 } 129 return true; 130 135 131 } 136 132 137 133 bool SytMonitor::consumeNextCycleInfo() { 138 134 struct cycle_info cif; 139 if(f reebob_ringbuffer_read(m_cinfo_buffer,(char *)&cif,sizeof(struct cycle_info))135 if(ffado_ringbuffer_read(m_cinfo_buffer,(char *)&cif,sizeof(struct cycle_info)) 140 136 !=sizeof(struct cycle_info)) { 141 137 return false; … … 147 143 { 148 144 IsoStream::dumpInfo(); 149 debugOutputShort( DEBUG_LEVEL_NORMAL, " Ringbuffer fill: %d\n",150 freebob_ringbuffer_read_space(m_cinfo_buffer)/sizeof(struct cycle_info));145 debugOutputShort( DEBUG_LEVEL_NORMAL, " Ringbuffer fill: %d\n", 146 ffado_ringbuffer_read_space(m_cinfo_buffer)/sizeof(struct cycle_info)); 151 147 }; trunk/libffado/tests/SytMonitor.h
r419 r445 1 /* $Id$ */2 3 1 /* 4 * FreeBob Streaming API 5 * FreeBob = Firewire (pro-)audio for linux 2 * Copyright (C) 2005-2007 by Pieter Palmers 6 3 * 7 * http://freebob.sf.net 4 * This file is part of FFADO 5 * FFADO = Free Firewire (pro-)audio drivers for linux 8 6 * 9 * Copyright (C) 2007 Pieter Palmers <pieterpalmers@users.sourceforge.net>7 * FFADO is based upon FreeBoB 10 8 * 11 * This program is free software {} you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation {} either version 2 of the License, or 14 * (at your option) any later version. 9 * FFADO is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or 12 * (at your option) any later version. 13 * FFADO 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 16 * GNU General Public License for more details. 15 17 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY {} without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program {} if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * 25 * 18 * You should have received a copy of the GNU General Public License 19 * along with FFADO; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21 * MA 02111-1307 USA. 26 22 * 27 23 */ 28 #ifndef __FREEBOB_SYTMONITOR__ 29 #define __FREEBOB_SYTMONITOR__ 24 25 #ifndef __FFADO_SYTMONITOR__ 26 #define __FFADO_SYTMONITOR__ 30 27 #include "src/libstreaming/IsoStream.h" 31 28 #include "src/libstreaming/cip.h" … … 46 43 }; 47 44 48 class SytMonitor 45 class SytMonitor 49 46 : public IsoStream 50 47 { … … 53 50 SytMonitor(int port); 54 51 virtual ~SytMonitor(); 55 56 virtual enum raw1394_iso_disposition 57 putPacket(unsigned char *data, unsigned int length, 58 unsigned char channel, unsigned char tag, unsigned char sy, 59 unsigned int cycle, unsigned int dropped);60 61 void dumpInfo();62 unsigned int getMaxPacketSize() {return 4096;};63 unsigned int getPacketsPerPeriod() {return 1;};64 52 53 virtual enum raw1394_iso_disposition 54 putPacket(unsigned char *data, unsigned int length, 55 unsigned char channel, unsigned char tag, unsigned char sy, 56 unsigned int cycle, unsigned int dropped); 57 58 void dumpInfo(); 59 unsigned int getMaxPacketSize() {return 4096;}; 60 unsigned int getPacketsPerPeriod() {return 1;}; 61 65 62 bool readNextCycleInfo(struct cycle_info *cif); 66 63 bool consumeNextCycleInfo(); 67 64 68 65 bool putCycleInfo(struct cycle_info *cif); 69 66 70 67 IsoHandler * getHandler() {return m_handler;}; 71 72 protected:73 freebob_ringbuffer_t * m_cinfo_buffer;74 75 76 DECLARE_DEBUG_MODULE;77 78 79 68 69 protected: 70 ffado_ringbuffer_t * m_cinfo_buffer; 71 72 DECLARE_DEBUG_MODULE; 80 73 }; 81 74 82 75 83 #endif /* __FREEBOB_SYTMONITOR__ */ 84 85 76 #endif /* __FFADO_SYTMONITOR__ */ trunk/libffado/tests/test-cycletimer.cpp
r419 r445 1 /*************************************************************************** 2 Copyright (C) 2005 by Pieter Palmers * 3 * 4 This program is free software; you can redistribute it and/or modify * 5 it under the terms of the GNU General Public License as published by * 6 the Free Software Foundation; either version 2 of the License, or * 7 (at your option) any later version. * 8 * 9 This program is distributed in the hope that it will be useful, * 10 but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 GNU General Public License for more details. * 13 * 14 You should have received a copy of the GNU General Public License * 15 along with this program; if not, write to the * 16 Free Software Foundation, Inc., * 17 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 ***************************************************************************/ 1 /* 2 * Copyright (C) 2005-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 * FFADO is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or 12 * (at your option) any later version. 13 * FFADO 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 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with FFADO; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21 * MA 02111-1307 USA. 22 * 23 */ 19 24 20 25 #ifdef HAVE_CONFIG_H … … 51 56 52 57 struct CYCLE_TIMER_REGISTER { 53 uint16_t seconds;54 uint16_t cycles;55 uint16_t offset;58 uint16_t seconds; 59 uint16_t cycles; 60 uint16_t offset; 56 61 }; 57 62 58 63 uint64_t ctr_to_quadlet(struct CYCLE_TIMER_REGISTER x) { 59 64 uint64_t retval=0; 60 65 61 66 x.seconds &= 0x7F; 62 67 63 68 x.cycles &= 0x1FFF; 64 69 x.cycles %= 8000; 65 70 66 71 x.offset &= 0xFFF; 67 72 x.offset %= 3072; 68 73 69 74 retval = (x.seconds << 25) + (x.cycles << 12) + (x.offset); 70 75 return retval & 0xFFFFFFFF; … … 73 78 static void sighandler (int sig) 74 79 { 75 run = 0;80 run = 0; 76 81 } 77 82 78 83 int do_cycletimer_test() { 79 84 80 85 struct CYCLE_TIMER_REGISTER cycle_timer; 81 86 uint32_t *cycle_timer_as_uint=(uint32_t *)&cycle_timer; 82 87 83 88 uint32_t i=0; 84 89 uint32_t targetval=0; 85 90 86 91 int failures=0; 87 88 92 93 89 94 // test 1 90 // 91 95 // 96 92 97 *cycle_timer_as_uint=0; 93 98 for (i=0;i<3072;i++) { 94 99 cycle_timer.offset=i; 95 100 targetval=CYCLE_TIMER_GET_OFFSET(ctr_to_quadlet(cycle_timer)); 96 101 97 102 if(targetval != i) { 98 103 debugOutput(DEBUG_LEVEL_NORMAL, " test1 failed on i=%d (%08X), returns %d (%08X)\n",i,i,targetval,targetval); … … 100 105 } 101 106 } 102 107 103 108 for (i=0;i<8000;i++) { 104 109 cycle_timer.cycles=i; 105 110 targetval=CYCLE_TIMER_GET_CYCLES(ctr_to_quadlet(cycle_timer)); 106 111 107 112 if(targetval != i) { 108 113 debugOutput(DEBUG_LEVEL_NORMAL, " test2 failed on i=%d (%08X), returns %d (%08X)\n",i,i,targetval,targetval); … … 110 115 } 111 116 } 112 117 113 118 for (i=0;i<128;i++) { 114 119 cycle_timer.seconds=i; 115 120 targetval=CYCLE_TIMER_GET_SECS(ctr_to_quadlet(cycle_timer)); 116 121 117 122 if(targetval != i) { 118 123 debugOutput(DEBUG_LEVEL_NORMAL, " test3 failed on i=%d (%08X), returns %d (%08X)\n",i,i,targetval,targetval); … … 120 125 } 121 126 } 122 123 127 128 124 129 // a value in ticks 125 130 // should be: 10sec, 1380cy, 640ticks … … 128 133 cycle_timer.cycles = TICKS_TO_CYCLES(targetval); 129 134 cycle_timer.offset = TICKS_TO_OFFSET(targetval); 130 135 131 136 if((cycle_timer.seconds != 10) | 132 137 (cycle_timer.cycles != 1380) | … … 139 144 debugOutput(DEBUG_LEVEL_NORMAL, " test4 ok\n"); 140 145 } 141 146 142 147 i=TICKS_TO_CYCLE_TIMER(targetval); 143 148 if (i != 0x14564280) { 144 149 debugOutput(DEBUG_LEVEL_NORMAL, " test5 failed: (0x%08X,0x14564280)\n", 145 150 i); 146 failures++; 151 failures++; 147 152 } else { 148 153 debugOutput(DEBUG_LEVEL_NORMAL, " test5 ok\n"); 149 154 } 150 155 151 156 targetval=CYCLE_TIMER_TO_TICKS(i); 152 157 if (targetval!=250000000L) { 153 158 debugOutput(DEBUG_LEVEL_NORMAL, " test6 failed: (%u,250000000)\n", 154 159 targetval); 155 failures++; 160 failures++; 156 161 } else { 157 162 debugOutput(DEBUG_LEVEL_NORMAL, " test6 ok\n"); 158 163 } 159 164 160 165 int32_t subs; 161 166 subs=diffTicks(10, 8); … … 163 168 debugOutput(DEBUG_LEVEL_NORMAL, " diffTicks(10, 8) != 2 : %ld\n", 164 169 subs); 165 failures++; 166 } 167 170 failures++; 171 } 172 168 173 subs=diffTicks(10, 12); 169 174 if (subs != -2) { 170 175 debugOutput(DEBUG_LEVEL_NORMAL, " diffTicks(10, 12) != -2 : %ld\n", 171 176 subs); 172 failures++; 173 } 174 177 failures++; 178 } 179 175 180 subs=diffTicks(TICKS_PER_SECOND*128L + 10, 8); 176 181 if (subs != 2) { 177 182 debugOutput(DEBUG_LEVEL_NORMAL, " diffTicks(TICKS_PER_SECOND*128L + 10, 8) != 2 : %ld\n", 178 183 subs); 179 failures++; 180 } 181 184 failures++; 185 } 186 182 187 subs=diffTicks(TICKS_PER_SECOND*128L + 10, 12); 183 188 if (subs != -2) { 184 189 debugOutput(DEBUG_LEVEL_NORMAL, " diffTicks(TICKS_PER_SECOND*128L + 10, 12) != -2 : %ld\n", 185 190 subs); 186 failures++; 187 } 188 191 failures++; 192 } 193 189 194 subs=diffTicks(10, TICKS_PER_SECOND*128L + 8); 190 195 if (subs != 2) { 191 196 debugOutput(DEBUG_LEVEL_NORMAL, " diffTicks(10, TICKS_PER_SECOND*128L + 8) != 2 : %ld\n", 192 197 subs); 193 failures++; 194 } 195 198 failures++; 199 } 200 196 201 subs=diffTicks(10, TICKS_PER_SECOND*128L + 12); 197 202 if (subs != -2) { … … 200 205 failures++; 201 206 } 202 207 203 208 //--------- 204 209 // now = 10sec, 1380cy, 640ticks 205 210 206 211 uint32_t st=sytRecvToFullTicks(0x1234, 1000, 0x14564280); 207 212 if (st != 248860212LLU) { 208 213 debugOutput(DEBUG_LEVEL_NORMAL, " sytToRecvFullTicks(0x1234, 1000, 0x14564280) != 248860212 : %011lu\n", 209 214 st); 210 failures++; 211 } 212 215 failures++; 216 } 217 213 218 st=sytRecvToFullTicks(0xB2B6, 7000, TICKS_TO_CYCLE_TIMER(3118082282LU)); 214 219 if (st != 3118089910LLU) { 215 220 debugOutput(DEBUG_LEVEL_NORMAL, " sytToRecvFullTicks(0x1234, 1000, %08X) != 3118089910 : %011lu\n", 216 221 TICKS_TO_CYCLE_TIMER(3118082282LU), st); 217 failures++; 218 } 219 222 failures++; 223 } 224 220 225 st=sytXmitToFullTicks(0xC4EA, 3000, TICKS_TO_CYCLE_TIMER(2958285668LU)); 221 226 if (st != 2958349546LLU) { 222 227 debugOutput(DEBUG_LEVEL_NORMAL, " sytToXmitFullTicks(0x1234, 1000, %08X) != 2958349546 : %011lu\n", 223 228 TICKS_TO_CYCLE_TIMER(2958285668LU), st); 224 failures++; 225 } 226 229 failures++; 230 } 231 227 232 if (failures) { 228 233 debugOutput(DEBUG_LEVEL_NORMAL, " %d failures\n",failures); … … 237 242 { 238 243 239 run=1;240 241 IsoHandlerManager *m_isoManager=NULL;242 243 #ifdef TEST_PORT_0 244 run=1; 245 246 IsoHandlerManager *m_isoManager=NULL; 247 248 #ifdef TEST_PORT_0 244 249 IsoStream *s=NULL; 245 250 #endif 246 #ifdef TEST_PORT_1 251 #ifdef TEST_PORT_1 247 252 IsoStream *s2=NULL; 248 253 #endif … … 251 256 #endif 252 257 253 signal (SIGINT, sighandler);254 signal (SIGPIPE, sighandler);255 256 debugOutput(DEBUG_LEVEL_NORMAL, "FreebobCycle timer test application\n");257 258 debugOutput(DEBUG_LEVEL_NORMAL, "Testing cycle timer helper functions & macro's... \n");259 if(do_cycletimer_test()) {260 debugOutput(DEBUG_LEVEL_NORMAL, " !!! FAILED !!!\n");261 exit(1);262 } else {263 debugOutput(DEBUG_LEVEL_NORMAL, " !!! PASSED !!!\n");264 }265 266 // exit(1);267 268 m_isoManager=new IsoHandlerManager();269 270 if(!m_isoManager) {271 debugOutput(DEBUG_LEVEL_NORMAL, "Could not create IsoHandlerManager\n");272 goto finish;273 }274 275 m_isoManager->setVerboseLevel(DEBUG_LEVEL_VERBOSE);276 277 if(!m_isoManager->init()) {278 debugOutput(DEBUG_LEVEL_NORMAL, "Could not init() IsoHandlerManager\n");279 goto finish;280 }281 282 283 #ifdef TEST_PORT_0 284 // add a stream to the manager so that it has something to do285 s=new IsoStream(IsoStream::EST_Receive, 0);286 287 if (!s) {288 debugOutput(DEBUG_LEVEL_NORMAL, "Could not create IsoStream\n");289 goto finish;290 } 291 292 s->setVerboseLevel(DEBUG_LEVEL_VERBOSE);293 294 if (!s->init()) {295 debugOutput(DEBUG_LEVEL_NORMAL, "Could not init IsoStream\n");296 goto finish;297 }298 299 s->setChannel(0);300 301 if(!m_isoManager->registerStream(s)) {302 debugOutput(DEBUG_LEVEL_NORMAL, "Could not register IsoStream\n");303 goto finish;304 }305 #endif 306 307 #ifdef TEST_PORT_1 308 // add a stream to the manager so that it has something to do309 s2=new IsoStream(IsoStream::EST_Receive, 1);310 311 if (!s2) {312 debugOutput(DEBUG_LEVEL_NORMAL, "Could not create IsoStream\n");313 goto finish;314 } 315 316 s2->setVerboseLevel(DEBUG_LEVEL_VERBOSE);317 318 if (!s2->init()) {319 debugOutput(DEBUG_LEVEL_NORMAL, "Could not init IsoStream\n");320 goto finish;321 }322 323 s2->setChannel(0);324 325 if(!m_isoManager->registerStream(s2)) {326 debugOutput(DEBUG_LEVEL_NORMAL, "Could not register IsoStream\n");327 goto finish;328 }329 #endif 330 331 #ifdef TEST_PORT_2 332 // add a stream to the manager so that it has something to do333 s3=new IsoStream(IsoStream::EST_Receive,2);334 335 if (!s3) {336 debugOutput(DEBUG_LEVEL_NORMAL, "Could not create IsoStream\n");337 goto finish;338 } 339 340 s3->setVerboseLevel(DEBUG_LEVEL_VERBOSE);341 342 if (!s3->init()) {343 debugOutput(DEBUG_LEVEL_NORMAL, "Could not init IsoStream\n");344 goto finish;345 }346 347 s3->setChannel(0);348 349 if(!m_isoManager->registerStream(s3)) {350 debugOutput(DEBUG_LEVEL_NORMAL, "Could not register IsoStream\n");351 goto finish;352 }353 #endif 354 355 debugOutput(DEBUG_LEVEL_NORMAL, "Preparing IsoHandlerManager...\n");356 if (!m_isoManager->prepare()) {357 debugOutput(DEBUG_LEVEL_NORMAL, "Could not prepare isoManager\n");358 goto finish;359 }360 361 debugOutput(DEBUG_LEVEL_NORMAL, "Starting IsoHandler...\n");362 if (!m_isoManager->startHandlers(0)) {363 debugOutput(DEBUG_LEVEL_NORMAL, "Could not start handlers...\n");364 goto finish;365 }366 367 while(run) {258 signal (SIGINT, sighandler); 259 signal (SIGPIPE, sighandler); 260 261 debugOutput(DEBUG_LEVEL_NORMAL, "FFADO Cycle timer test application\n"); 262 263 debugOutput(DEBUG_LEVEL_NORMAL, "Testing cycle timer helper functions & macro's... \n"); 264 if(do_cycletimer_test()) { 265 debugOutput(DEBUG_LEVEL_NORMAL, " !!! FAILED !!!\n"); 266 exit(1); 267 } else { 268 debugOutput(DEBUG_LEVEL_NORMAL, " !!! PASSED !!!\n"); 269 } 270 271 // exit(1); 272 273 m_isoManager=new IsoHandlerManager(); 274 275 if(!m_isoManager) { 276 debugOutput(DEBUG_LEVEL_NORMAL, "Could not create IsoHandlerManager\n"); 277 goto finish; 278 } 279 280 m_isoManager->setVerboseLevel(DEBUG_LEVEL_VERBOSE); 281 282 if(!m_isoManager->init()) { 283 debugOutput(DEBUG_LEVEL_NORMAL, "Could not init() IsoHandlerManager\n"); 284 goto finish; 285 } 286 287 288 #ifdef TEST_PORT_0 289 // add a stream to the manager so that it has something to do 290 s=new IsoStream(IsoStream::EST_Receive, 0); 291 292 if (!s) { 293 debugOutput(DEBUG_LEVEL_NORMAL, "Could not create IsoStream\n"); 294 goto finish; 295 } 296 297 s->setVerboseLevel(DEBUG_LEVEL_VERBOSE); 298 299 if (!s->init()) { 300 debugOutput(DEBUG_LEVEL_NORMAL, "Could not init IsoStream\n"); 301 goto finish; 302 } 303 304 s->setChannel(0); 305 306 if(!m_isoManager->registerStream(s)) { 307 debugOutput(DEBUG_LEVEL_NORMAL, "Could not register IsoStream\n"); 308 goto finish; 309 } 310 #endif 311 312 #ifdef TEST_PORT_1 313 // add a stream to the manager so that it has something to do 314 s2=new IsoStream(IsoStream::EST_Receive, 1); 315 316 if (!s2) { 317 debugOutput(DEBUG_LEVEL_NORMAL, "Could not create IsoStream\n"); 318 goto finish; 319 } 320 321 s2->setVerboseLevel(DEBUG_LEVEL_VERBOSE); 322 323 if (!s2->init()) { 324 debugOutput(DEBUG_LEVEL_NORMAL, "Could not init IsoStream\n"); 325 goto finish; 326 } 327 328 s2->setChannel(0); 329 330 if(!m_isoManager->registerStream(s2)) { 331 debugOutput(DEBUG_LEVEL_NORMAL, "Could not register IsoStream\n"); 332 goto finish; 333 } 334 #endif 335 336 #ifdef TEST_PORT_2 337 // add a stream to the manager so that it has something to do 338 s3=new IsoStream(IsoStream::EST_Receive,2); 339 340 if (!s3) { 341 debugOutput(DEBUG_LEVEL_NORMAL, "Could not create IsoStream\n"); 342 goto finish; 343 } 344 345 s3->setVerboseLevel(DEBUG_LEVEL_VERBOSE); 346 347 if (!s3->init()) { 348 debugOutput(DEBUG_LEVEL_NORMAL, "Could not init IsoStream\n"); 349 goto finish; 350 } 351 352 s3->setChannel(0); 353 354 if(!m_isoManager->registerStream(s3)) { 355 debugOutput(DEBUG_LEVEL_NORMAL, "Could not register IsoStream\n"); 356 goto finish; 357 } 358 #endif 359 360 debugOutput(DEBUG_LEVEL_NORMAL, "Preparing IsoHandlerManager...\n"); 361 if (!m_isoManager->prepare()) { 362 debugOutput(DEBUG_LEVEL_NORMAL, "Could not prepare isoManager\n"); 363 goto finish; 364 } 365 366 debugOutput(DEBUG_LEVEL_NORMAL, "Starting IsoHandler...\n"); 367 if (!m_isoManager->startHandlers(0)) { 368 debugOutput(DEBUG_LEVEL_NORMAL, "Could not start handlers...\n"); 369 goto finish; 370 } 371 372 while(run) { 368 373 sleep(1); 369 374 m_isoManager->dumpInfo(); 370 }371 372 debugOutput(DEBUG_LEVEL_NORMAL, "Stopping handlers...\n");373 if(!m_isoManager->stopHandlers()) {374 debugOutput(DEBUG_LEVEL_NORMAL, "Could not stop ISO handlers\n");375 goto finish;376 }377 378 #ifdef TEST_PORT_0 379 if(!m_isoManager->unregisterStream(s)) {380 debugOutput(DEBUG_LEVEL_NORMAL, "Could not unregister IsoStream\n");381 goto finish;382 }383 delete s;384 #endif 385 386 #ifdef TEST_PORT_1 387 if(!m_isoManager->unregisterStream(s1)) {388 debugOutput(DEBUG_LEVEL_NORMAL, "Could not unregister IsoStream\n");389 goto finish;390 }391 delete s1;392 #endif 393 394 #ifdef TEST_PORT_2 395 if(!m_isoManager->unregisterStream(s2)) {396 debugOutput(DEBUG_LEVEL_NORMAL, "Could not unregister IsoStream\n");397 goto finish;398 }399 delete s2;400 #endif 401 375 } 376 377 debugOutput(DEBUG_LEVEL_NORMAL, "Stopping handlers...\n"); 378 if(!m_isoManager->stopHandlers()) { 379 debugOutput(DEBUG_LEVEL_NORMAL, "Could not stop ISO handlers\n"); 380 goto finish; 381 } 382 383 #ifdef TEST_PORT_0 384 if(!m_isoManager->unregisterStream(s)) { 385 debugOutput(DEBUG_LEVEL_NORMAL, "Could not unregister IsoStream\n"); 386 goto finish; 387 } 388 delete s; 389 #endif 390 391 #ifdef TEST_PORT_1 392 if(!m_isoManager->unregisterStream(s1)) { 393 debugOutput(DEBUG_LEVEL_NORMAL, "Could not unregister IsoStream\n"); 394 goto finish; 395 } 396 delete s1; 397 #endif 398 399 #ifdef TEST_PORT_2 400 if(!m_isoManager->unregisterStream(s2)) { 401 debugOutput(DEBUG_LEVEL_NORMAL, "Could not unregister IsoStream\n"); 402 goto finish; 403 } 404 delete s2; 405 #endif 406 402 407 delete m_isoManager; 403 408 404 409 finish: 405 debugOutput(DEBUG_LEVEL_NORMAL, "Bye...\n");410 debugOutput(DEBUG_LEVEL_NORMAL, "Bye...\n"); 406 411 407 412 return EXIT_SUCCESS; trunk/libffado/tests/test-extplugcmd.cpp
r420 r445 1 /* test-extplugcmd.cpp 2 * Copyright (C) 2005,06 by Daniel Wagner 3 * 4 * This file is part of FreeBoB. 5 * 6 * FreeBoB is free software; you can redistribute it and/or modify 1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 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 * FFADO is free software; you can redistribute it and/or modify 7 10 * it under the terms of the GNU General Public License as published by 8 11 * the Free Software Foundation; either version 2 of the License, or 9 12 * (at your option) any later version. 10 * F reeBoBis distributed in the hope that it will be useful,13 * FFADO is distributed in the hope that it will be useful, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the … … 14 17 * 15 18 * You should have received a copy of the GNU General Public License 16 * along with F reeBoB; if not, write to the Free Software19 * along with FFADO; if not, write to the Free Software 17 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 18 21 * MA 02111-1307 USA. 22 * 19 23 */ 20 24 … … 34 38 //////////////////////////////////////////////// 35 39 const char *argp_program_version = "test-extplugcmd 0.2"; 36 const char *argp_program_bug_address = "<f reebob-devel@lists.sf.net>";40 const char *argp_program_bug_address = "<ffado-devel@lists.sf.net>"; 37 41 static char doc[] = "test-extplugcmd -- tests some extended plug info commands on a BeBoB device"; 38 42 static char args_doc[] = "NODE_ID"; … … 206 210 int node_id = strtol(arguments.args[0], &tail, 0); 207 211 if (errno) { 208 perror("argument parsing failed:");209 return -1;212 perror("argument parsing failed:"); 213 return -1; 210 214 } 211 215 Ieee1394Service ieee1394service; trunk/libffado/tests/test-ffado.cpp
r443 r445 1 /* test-freebob.c2 * Copyright (C) 2005 by Daniel Wagner3 * Copyright (C) 200 7by Pieter Palmers1 /* 2 * Copyright (C) 2005-2007 by by Daniel Wagner 3 * Copyright (C) 2005-2007 by by Pieter Palmers 4 4 * 5 * This file is part of FreeBoB. 5 * This file is part of FFADO 6 * FFADO = Free Firewire (pro-)audio drivers for linux 6 7 * 7 * FreeBoB is free software; you can redistribute it and/or modify 8 * FFADO is based upon FreeBoB. 9 * 10 * FFADO is free software; you can redistribute it and/or modify 8 11 * it under the terms of the GNU General Public License as published by 9 12 * the Free Software Foundation; either version 2 of the License, or 10 13 * (at your option) any later version. 11 * F reeBoBis distributed in the hope that it will be useful,14 * FFADO is distributed in the hope that it will be useful, 12 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the … … 15 18 * 16 19 * You should have received a copy of the GNU General Public License 17 * along with F reeBoB; if not, write to the Free Software20 * along with FFADO; if not, write to the Free Software 18 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 19 22 * MA 02111-1307 USA. … … 26 29 #include <config.h> 27 30 28 #include "libf reebob/freebob.h"31 #include "libffado/ffado.h" 29 32 30 33 #include "debugmodule/debugmodule.h" … … 60 63 string osc_value; 61 64 62 int osc_path_response_handler(const char *path, const char *types, lo_arg **argv, int argc, 65 int osc_path_response_handler(const char *path, const char *types, lo_arg **argv, int argc, 63 66 void *data, void *user_data); 64 65 int osc_param_response_handler(const char *path, const char *types, lo_arg **argv, int argc, 67 68 int osc_param_response_handler(const char *path, const char *types, lo_arg **argv, int argc, 66 69 void *data, void *user_data); 67 68 int osc_data_response_handler(const char *path, const char *types, lo_arg **argv, int argc, 70 71 int osc_data_response_handler(const char *path, const char *types, lo_arg **argv, int argc, 69 72 void *data, void *user_data); 70 73 71 74 void osc_error_handler(int num, const char *msg, const char *path); 72 75 … … 83 86 84 87 // Program documentation. 85 static char doc[] = "F reeBoB-- a driver for Firewire Audio devices (test application)\n\n"88 static char doc[] = "FFADO -- a driver for Firewire Audio devices (test application)\n\n" 86 89 "OPERATION: Discover\n" 87 90 " SetSamplerate\n" … … 99 102 int node_id; 100 103 int node_id_set; 101 char* args[2]; 104 char* args[2]; 102 105 }; 103 106 … … 134 137 arguments->verbose = strtol( arg, &tail, 0 ); 135 138 if ( errno ) { 136 debugError("Could not parse 'verbose' argument\n" );139 fprintf( stderr, "Could not parse 'verbose' argument\n" ); 137 140 return ARGP_ERR_UNKNOWN; 138 141 } … … 143 146 arguments->port = strtol( arg, &tail, 0 ); 144 147 if ( errno ) { 145 debugError("Could not parse 'port' argument\n" );148 fprintf( stderr, "Could not parse 'port' argument\n" ); 146 149 return ARGP_ERR_UNKNOWN; 147 150 } 148 151 } else { 149 152 if ( errno ) { 150 debugError("Could not parse 'port' argumen\n" );153 fprintf( stderr, "Could not parse 'port' argumen\n" ); 151 154 return ARGP_ERR_UNKNOWN; 152 155 } … … 157 160 arguments->node_id = strtol( arg, &tail, 0 ); 158 161 if ( errno ) { 159 debugError("Could not parse 'node' argument\n" );162 fprintf( stderr, "Could not parse 'node' argument\n" ); 160 163 return ARGP_ERR_UNKNOWN; 161 164 } … … 163 166 } else { 164 167 if ( errno ) { 165 debugError("Could not parse 'node' argumen\n" );168 fprintf( stderr, "Could not parse 'node' argumen\n" ); 166 169 return ARGP_ERR_UNKNOWN; 167 170 } … … 197 200 // Default values. 198 201 arguments.silent = 0; 199 arguments.verbose = DEBUG_LEVEL_NORMAL;202 arguments.verbose = 0; 200 203 arguments.port = 0; 201 204 arguments.node_id = 0; … … 207 210 // be reflected in `arguments'. 208 211 if ( argp_parse ( &argp, argc, argv, 0, 0, &arguments ) ) { 209 debugError("Could not parse command line\n" );212 fprintf( stderr, "Could not parse command line\n" ); 210 213 return -1; 211 214 } 212 215 213 setDebugLevel(arguments.verbose); 214 215 debugOutput(DEBUG_LEVEL_NORMAL, "verbose level = %d\n", arguments.verbose); 216 217 debugOutput(DEBUG_LEVEL_NORMAL, "Using freebob library version: %s\n\n", freebob_get_version() ); 218 216 printf("verbose level = %d\n", arguments.verbose); 217 218 printf( "Using ffado library version: %s\n\n", ffado_get_version() ); 219 219 220 if ( strcmp( arguments.args[0], "Discover" ) == 0 ) { 220 221 DeviceManager *m_deviceManager = new DeviceManager(); 221 222 if ( !m_deviceManager ) { 222 debugError("Could not allocate device manager\n" );223 fprintf( stderr, "Could not allocate device manager\n" ); 223 224 return -1; 224 225 } 225 226 if ( !m_deviceManager->initialize( arguments.port ) ) { 226 debugError("Could not initialize device manager\n" );227 fprintf( stderr, "Could not initialize device manager\n" ); 227 228 delete m_deviceManager; 228 229 return -1; 229 230 } 230 231 m_deviceManager->setVerboseLevel(arguments.verbose); 231 if ( arguments.verbose ) { 232 m_deviceManager->setVerboseLevel(arguments.verbose); 233 } 232 234 if ( !m_deviceManager->discover() ) { 233 debugError("Could not discover devices\n" );235 fprintf( stderr, "Could not discover devices\n" ); 234 236 delete m_deviceManager; 235 237 return -1; 236 238 } 237 238 int devices_on_bus = m_deviceManager->getNbDevices();239 debugOutput(DEBUG_LEVEL_NORMAL, "port = %d, devices_on_bus = %d\n", arguments.port, devices_on_bus);240 241 for(int i=0;i<devices_on_bus;i++) {242 int node_id=m_deviceManager->getDeviceNodeId(i);243 debugOutput(DEBUG_LEVEL_NORMAL, " device = %d, node = %d\n", i, node_id);244 IAvDevice* avDevice = m_deviceManager->getAvDevice( node_id );245 if ( avDevice ) {246 avDevice->showDevice();247 }248 }249 250 239 delete m_deviceManager; 251 240 return 0; … … 254 243 int samplerate = strtol( arguments.args[1], &tail, 0 ); 255 244 if ( errno ) { 256 debugError("Could not parse samplerate argument\n" );257 return -1; 258 } 259 245 fprintf( stderr, "Could not parse samplerate argument\n" ); 246 return -1; 247 } 248 260 249 DeviceManager *m_deviceManager = new DeviceManager(); 261 250 if ( !m_deviceManager ) { 262 debugError("Could not allocate device manager\n" );251 fprintf( stderr, "Could not allocate device manager\n" ); 263 252 return -1; 264 253 } 265 254 if ( !m_deviceManager->initialize( arguments.port ) ) { 266 debugError("Could not initialize device manager\n" );255 fprintf( stderr, "Could not initialize device manager\n" ); 267 256 delete m_deviceManager; 268 257 return -1; 269 258 } 270 271 m_deviceManager->setVerboseLevel(arguments.verbose); 259 if ( arguments.verbose ) { 260 m_deviceManager->setVerboseLevel(arguments.verbose); 261 } 272 262 if ( !m_deviceManager->discover() ) { 273 debugError("Could not discover devices\n" );263 fprintf( stderr, "Could not discover devices\n" ); 274 264 delete m_deviceManager; 275 265 return -1; 276 266 } 277 267 278 268 if(arguments.node_id_set) { 279 269 IAvDevice* avDevice = m_deviceManager->getAvDevice( arguments.node_id ); 280 270 if ( avDevice ) { 281 if ( avDevice->setSampl eRate( parseSampleRate( samplerate ) ) ) {271 if ( avDevice->setSamplingFrequency( parseSampleRate( samplerate ) ) ) { 282 272 m_deviceManager->discover(); 283 273 } else { 284 debugError("Could not set samplerate\n" );274 fprintf( stderr, "Could not set samplerate\n" ); 285 275 } 286 276 } 287 277 } else { 288 278 int i=0; 289 279 290 280 int devices_on_bus = m_deviceManager->getNbDevices(); 291 debugOutput(DEBUG_LEVEL_NORMAL," port = %d, devices_on_bus = %d\n", arguments.port, devices_on_bus);292 281 printf(" port = %d, devices_on_bus = %d\n", arguments.port, devices_on_bus); 282 293 283 for(i=0;i<devices_on_bus;i++) { 294 284 int node_id=m_deviceManager->getDeviceNodeId(i); 295 debugOutput(DEBUG_LEVEL_NORMAL," set samplerate for device = %d, node = %d\n", i, node_id);285 printf(" set samplerate for device = %d, node = %d\n", i, node_id); 296 286 IAvDevice* avDevice = m_deviceManager->getAvDevice( node_id ); 297 287 if ( avDevice ) { 298 if ( !avDevice->setSampl eRate( parseSampleRate( samplerate ) ) ) {299 debugError("Could not set samplerate\n" );288 if ( !avDevice->setSamplingFrequency( parseSampleRate( samplerate ) ) ) { 289 fprintf( stderr, "Could not set samplerate\n" ); 300 290 } 301 291 } … … 307 297 // list osc space by using OSC messages 308 298 // a server is assumed to be present 309 299 310 300 /* start a new server. 311 301 when sending a message from this context, the response … … 314 304 lo_server s = lo_server_new(NULL, osc_error_handler); 315 305 lo_address t = lo_address_new(NULL, "17820"); 316 306 317 307 list_osc_paths(s, t, "/"); 318 308 319 309 lo_address_free(t); 320 310 lo_server_free(s); 321 311 322 312 } else if ( strcmp( arguments.args[0], "OscServer" ) == 0 ) { 323 313 DeviceManager *m_deviceManager = new DeviceManager(); 324 314 if ( !m_deviceManager ) { 325 debugError("Could not allocate device manager\n" );315 fprintf( stderr, "Could not allocate device manager\n" ); 326 316 return -1; 327 317 } 328 318 if ( !m_deviceManager->initialize( arguments.port ) ) { 329 debugError("Could not initialize device manager\n" );319 fprintf( stderr, "Could not initialize device manager\n" ); 330 320 delete m_deviceManager; 331 321 return -1; 332 322 } 333 334 m_deviceManager->setVerboseLevel(arguments.verbose); 323 if ( arguments.verbose ) { 324 m_deviceManager->setVerboseLevel(arguments.verbose); 325 } 335 326 if ( !m_deviceManager->discover() ) { 336 debugError("Could not discover devices\n" );327 fprintf( stderr, "Could not discover devices\n" ); 337 328 delete m_deviceManager; 338 329 return -1; 339 330 } 340 331 341 debugOutput(DEBUG_LEVEL_NORMAL,"server started\n");342 debugOutput(DEBUG_LEVEL_NORMAL,"press ctrl-c to stop it & continue\n");343 332 printf("server started\n"); 333 printf("press ctrl-c to stop it & continue\n"); 334 344 335 signal (SIGINT, sighandler); 345 336 346 337 run=1; 347 338 while(run) { … … 351 342 } 352 343 signal (SIGINT, SIG_DFL); 353 354 debugOutput(DEBUG_LEVEL_NORMAL,"server stopped\n");344 345 printf("server stopped\n"); 355 346 delete m_deviceManager; 356 347 return 0; 357 348 358 349 } else { 359 debugOutput(DEBUG_LEVEL_NORMAL,"unknown operation\n" );350 printf( "unknown operation\n" ); 360 351 } 361 352 … … 364 355 void list_osc_paths(lo_server s, lo_address t, const char *path) { 365 356 vector<string> my_paths; 366 367 debugOutput(DEBUG_LEVEL_NORMAL,"listing path: %s\n", path);368 357 358 printf("listing path: %s\n", path); 359 369 360 osc_paths.clear(); 370 361 lo_server_add_method(s, "/response", NULL, osc_path_response_handler, NULL); 371 362 372 363 if (lo_send(t, path, "s", "list") == -1) { 373 debugOutput(DEBUG_LEVEL_NORMAL," OSC error %d: %s\n", lo_address_errno(t), lo_address_errstr(t));364 printf(" OSC error %d: %s\n", lo_address_errno(t), lo_address_errstr(t)); 374 365 } 375 366 376 367 if (lo_server_recv_noblock(s, 1000) == 0) { 377 debugOutput(DEBUG_LEVEL_NORMAL,"timeout\n");368 printf("timeout\n"); 378 369 return; 379 370 } 380 371 381 372 lo_server_del_method(s, "/response", NULL); 382 373 383 374 list_osc_params(s, t, path); 384 375 385 376 my_paths=osc_paths; 386 377 for ( vector<string>::iterator it = my_paths.begin(); … … 397 388 void list_osc_params(lo_server s, lo_address t, const char *path) { 398 389 vector<string> my_paths; 399 debugOutput(DEBUG_LEVEL_NORMAL,"params for: %s\n", path);400 390 printf("params for: %s\n", path); 391 401 392 osc_params.clear(); 402 393 lo_server_add_method(s, "/response", NULL, osc_param_response_handler, NULL); 403 394 404 395 if (lo_send(t, path, "s", "params") == -1) { 405 debugOutput(DEBUG_LEVEL_NORMAL," OSC error %d: %s\n", lo_address_errno(t), lo_address_errstr(t));406 } 407 396 printf(" OSC error %d: %s\n", lo_address_errno(t), lo_address_errstr(t)); 397 } 398 408 399 if (lo_server_recv_noblock(s, 1000) == 0) { 409 debugOutput(DEBUG_LEVEL_NORMAL,"timeout\n");400 printf("timeout\n"); 410 401 return; 411 402 } 412 403 413 404 lo_server_del_method(s, "/response", NULL); 414 405 415 406 vector<string> my_params=osc_params; 416 407 417 408 for ( vector<string>::iterator it = my_params.begin(); 418 409 it != my_params.end(); … … 420 411 { 421 412 string value=osc_param_get_value(s, t, path, (*it).c_str()); 422 debugOutput(DEBUG_LEVEL_NORMAL," %20s = %s\n", (*it).c_str(), value.c_str());413 printf(" %20s = %s\n", (*it).c_str(), value.c_str()); 423 414 } 424 415 … … 429 420 430 421 if (lo_send(t, path, "ss", "get", param) == -1) { 431 debugOutput(DEBUG_LEVEL_NORMAL," OSC error %d: %s\n", lo_address_errno(t), lo_address_errstr(t));432 } 433 422 printf(" OSC error %d: %s\n", lo_address_errno(t), lo_address_errstr(t)); 423 } 424 434 425 if (lo_server_recv_noblock(s, 1000) == 0) { 435 426 return string("timeout"); 436 427 } 437 428 438 429 lo_server_del_method(s, "/response", NULL); 439 430 return osc_value; … … 442 433 void osc_error_handler(int num, const char *msg, const char *path) 443 434 { 444 debugOutput(DEBUG_LEVEL_NORMAL,"liblo server error %d in path %s: %s\n", num, path, msg);435 printf("liblo server error %d in path %s: %s\n", num, path, msg); 445 436 } 446 437 … … 455 446 break; 456 447 default: 457 debugOutput(DEBUG_LEVEL_NORMAL,"unexpected data type in response message\n");448 printf("unexpected data type in response message\n"); 458 449 } 459 450 } … … 471 462 break; 472 463 default: 473 debugOutput(DEBUG_LEVEL_NORMAL,"unexpected data type in response message\n");464 printf("unexpected data type in response message\n"); 474 465 } 475 466 } … … 481 472 { 482 473 std::ostringstream str; 483 474 484 475 if(argc==1) { 485 476 switch (lo_type(types[0])) { trunk/libffado/tests/test-fw410.cpp
r336 r445 1 /* test-fw410.cpp 2 * Copyright (C) 2006 by Daniel Wagner 3 * 4 * This file is part of FreeBoB. 5 * 6 * FreeBoB is free software; you can redistribute it and/or modify 1 /* 2 * Copyright (C) 2005-2007 by Daniel Wagner 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 * FFADO is free software; you can redistribute it and/or modify 7 10 * it under the terms of the GNU General Public License as published by 8 11 * the Free Software Foundation; either version 2 of the License, or 9 12 * (at your option) any later version. 10 * F reeBoBis distributed in the hope that it will be useful,13 * FFADO is distributed in the hope that it will be useful, 11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the … … 14 17 * 15 18 * You should have received a copy of the GNU General Public License 16 * along with F reeBoB; if not, write to the Free Software19 * along with FFADO; if not, write to the Free Software 17 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 18 21 * MA 02111-1307 USA. 22 * 19 23 */ 20 24 … … 32 36 //////////////////////////////////////////////// 33 37 const char *argp_program_version = "test-fw410 0.1"; 34 const char *argp_program_bug_address = "<f reebob-devel@lists.sf.net>";38 const char *argp_program_bug_address = "<ffado-devel@lists.sf.net>"; 35 39 static char doc[] = "test-fw410 -- test program to get the fw410 streaming"; 36 40 static char args_doc[] = "NODE_ID"; … … 115 119 int iNodeId = strtol(arguments.args[0], &tail, 0); 116 120 if (errno) { 117 perror("argument parsing failed:");118 return -1;121 perror("argument parsing failed:"); 122 return -1; 119 123 } 120 124 … … 158 162 Connection* pCons = &cons[i]; 159 163 160 // the bandwith calculation fails, so its better to use 164 // the bandwith calculation fails, so its better to use 161 165 // some default values. 162 166 pCons->m_iBandwith = iec61883_cmp_calc_bandwidth ( pHandle, trunk/libffado/tests/test-ieee1394service.cpp
r415 r445 1 /*************************************************************************** 2 Copyright (C) 2005,2007 by Pieter Palmers * 3 * 4 This program is free software; you can redistribute it and/or modify * 5 it under the terms of the GNU General Public License as published by * 6 the Free Software Foundation; either version 2 of the License, or * 7 (at your option) any later version. * 8 * 9 This program is distributed in the hope that it will be useful, * 10 but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 GNU General Public License for more details. * 13 * 14 You should have received a copy of the GNU General Public License * 15 along with this program; if not, write to the * 16 Free Software Foundation, Inc., * 17 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 ***************************************************************************/ 1 /* 2 * Copyright (C) 2005-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 * FFADO is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or 12 * (at your option) any later version. 13 * FFADO 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 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with FFADO; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21 * MA 02111-1307 USA. 22 * 23 */ 19 24 20 25 #ifdef HAVE_CONFIG_H … … 64 69 signal (SIGPIPE, sighandler); 65 70 66 printf("F reebobIeee1394Service test application\n");67 71 printf("FFADO Ieee1394Service test application\n"); 72 68 73 Ieee1394Service *m_service=NULL; 69 74 70 75 m_service=new Ieee1394Service(); 71 76 m_service->initialize(2); 72 77 73 78 MyFunctor *test_busreset=new MyFunctor(); 74 79 75 80 printf(" adding (%p) as busreset handler\n", test_busreset); 76 77 m_service->addBusResetHandler(test_busreset); 78 81 82 m_service->addBusResetHandler(test_busreset); 83 79 84 nodeaddr_t addr = m_service->findFreeARMBlock(0x0000FFFFE0000000ULL, 4, 4 ); 80 85 81 86 ARMHandler *test_arm=new ARMHandler(addr, 82 87 4, … … 84 89 RAW1394_ARM_READ | RAW1394_ARM_WRITE | RAW1394_ARM_LOCK, 85 90 0); 86 91 87 92 printf(" adding (%p) as arm handler\n", test_arm); 88 93 89 94 if (!m_service->registerARMHandler(test_arm)) { 90 95 printf(" failed\n"); 91 96 } 92 97 93 98 addr = m_service->findFreeARMBlock(0x0000FFFFE0000000ULL, 4, 4 ); 94 99 95 100 ARMHandler *test_arm2=new ARMHandler(addr, 96 101 4, … … 100 105 101 106 printf(" adding (%p) as arm handler\n", test_arm2); 102 107 103 108 if (!m_service->registerARMHandler(test_arm2)) { 104 109 printf(" failed\n"); 105 110 } 106 111 107 112 while(run) { 108 113 fflush(stderr); … … 115 120 delete test_arm; 116 121 delete test_arm2; 117 122 118 123 printf("Bye...\n"); 119 124 trunk/libffado/tests/test-mixer.cpp
r437 r445 1 /* test-mixer.cpp 2 * Copyright (C) 2006 by Daniel Wagner 3 * 4 * This file is part of FreeBoB. 5 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with FreeBoB; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 18 * MA 02111-1307 USA. 19 */ 1 /* 2 * Copyright (C) 2005-2007 by by Daniel Wagner 3 * Copyright (C) 2005-2007 by 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 * FFADO is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU General Public License as published by 12 * the Free Software Foundation; either version 2 of the License, or 13 * (at your option) any later version. 14 * FFADO 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 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with FFADO; if not, write to the Free Software 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 22 * MA 02111-1307 USA. 23 */ 20 24 21 25 #include "libavc/avc_function_block.h" … … 50 54 ieee1394service.setVerboseLevel( DEBUG_LEVEL_VERY_VERBOSE ); 51 55 } 52 56 53 57 if ( !fbCmd.fire() ) { 54 58 printf( "cmd failed\n" ); trunk/libffado/tests/test-sytmonitor.cpp
r419 r445 1 /*************************************************************************** 2 Copyright (C) 2007 by Pieter Palmers * 3 * 4 This program is free software; you can redistribute it and/or modify * 5 it under the terms of the GNU General Public License as published by * 6 the Free Software Foundation; either version 2 of the License, or * 7 (at your option) any later version. * 8 * 9 This program is distributed in the hope that it will be useful, * 10 but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 GNU General Public License for more details. * 13 * 14 You should have received a copy of the GNU General Public License * 15 along with this program; if not, write to the * 16 Free Software Foundation, Inc., * 17 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 ***************************************************************************/ 1 /* 2 * Copyright (C) 2005-2007 by 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 * FFADO is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or 12 * (at your option) any later version. 13 * FFADO 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 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with FFADO; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21 * MA 02111-1307 USA. 22 */ 19 23 20 24 #ifdef HAVE_CONFIG_H … … 51 55 int run; 52 56 // Program documentation. 53 static char doc[] = "F reeBoB-- SYT monitor application\n\n";57 static char doc[] = "FFADO -- SYT monitor application\n\n"; 54 58 55 59 // A description of the arguments we accept. … … 109 113 case 'R': 110 114 arguments->realtime = true; 111 break; 115 break; 112 116 case 'r': 113 117 if (arg) { … … 118 122 } 119 123 } 120 break; 124 break; 121 125 case ARGP_KEY_ARG: 122 126 if (state->arg_num >= 128) { … … 124 128 argp_usage( state ); 125 129 } 126 127 if(sscanf( arg, "%d,%d", 128 &arguments->args[state->arg_num].port, 130 131 if(sscanf( arg, "%d,%d", 132 &arguments->args[state->arg_num].port, 129 133 &arguments->args[state->arg_num].channel) != 2) { 130 134 fprintf( stderr, "Could not parse port-channel specification ('%s')\n", arg); 131 135 132 136 } else { 133 137 printf("Adding Port %d, Channel %d to list...\n", … … 166 170 struct sched_param params; 167 171 uint64_t last_print_time=0; 168 172 169 173 SystemTimeSource masterTimeSource; 170 174 171 175 IsoHandlerManager *m_isoManager=NULL; 172 176 173 177 SytMonitor *monitors[128]; 174 178 int64_t stream_offset_ticks[128]; … … 189 193 goto finish; 190 194 } 191 195 192 196 memset(&stream_offset_ticks, 0, sizeof(int64_t) * 128); 193 197 194 198 run=1; 195 199 196 200 run_realtime=arguments.realtime; 197 201 realtime_prio=arguments.rtprio; … … 200 204 signal (SIGPIPE, sighandler); 201 205 202 debugOutput(DEBUG_LEVEL_NORMAL, "F reebobSYT monitor\n");203 206 debugOutput(DEBUG_LEVEL_NORMAL, "FFADO SYT monitor\n"); 207 204 208 m_isoManager=new IsoHandlerManager(); 205 209 206 210 if(!m_isoManager) { 207 211 debugOutput(DEBUG_LEVEL_NORMAL, "Could not create IsoHandlerManager\n"); 208 212 goto finish; 209 213 } 210 214 211 215 m_isoManager->setVerboseLevel(DEBUG_LEVEL_VERBOSE); 212 216 213 217 if(!m_isoManager->init()) { 214 218 debugOutput(DEBUG_LEVEL_NORMAL, "Could not init() IsoHandlerManager\n"); … … 219 223 for (i=0;i<arguments.nb_combos;i++) { 220 224 debugOutput(DEBUG_LEVEL_NORMAL, "Registering SytMonitor %d\n",i); 221 225 222 226 // add a stream to the manager so that it has something to do 223 227 monitors[i]=new SytMonitor(arguments.args[i].port); 224 228 225 229 if (!monitors[i]) { 226 230 debugOutput(DEBUG_LEVEL_NORMAL, "Could not create SytMonitor %d\n", i); 227 231 goto finish; 228 } 229 232 } 233 230 234 monitors[i]->setVerboseLevel(DEBUG_LEVEL_VERBOSE); 231 235 232 236 if (!monitors[i]->init()) { 233 237 debugOutput(DEBUG_LEVEL_NORMAL, "Could not init SytMonitor %d\n", i); 234 238 goto finish; 235 239 } 236 240 237 241 monitors[i]->setChannel(arguments.args[i].channel); 238 242 239 243 if(!m_isoManager->registerStream(monitors[i])) { 240 244 debugOutput(DEBUG_LEVEL_NORMAL, "Could not register SytMonitor %d with isoManager\n", i); … … 258 262 goto finish; 259 263 } 260 264 261 265 if (arguments.realtime) { 262 266 // get rt priority for this thread too. … … 266 270 } 267 271 } 268 272 269 273 // do the actual work 270 274 nb_iter=0; 271 275 272 276 while(run) { 273 277 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"--- Iterate ---\n"); 274 278 275 279 // if(!m_isoManager->iterate()) { 276 280 // debugFatal("Could not iterate the isoManager\n"); 277 281 // return false; 278 282 // } 279 283 280 284 if(!masterTimeSource.updateTimeSource()) { 281 285 debugFatal("Could not update the masterTimeSource\n"); 282 286 return false; 283 287 } 284 288 285 289 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"--- Process ---\n"); 286 290 // process the cycle info's … … 288 292 int master_guard=0; 289 293 struct cycle_info master_cif; 290 294 291 295 bool advance_master=true; 292 296 293 297 while (advance_master && monitors[0]->readNextCycleInfo(&master_cif)) { 294 298 advance_master=true; 295 299 296 300 master_guard++; 297 301 if(master_guard>1000) { 298 302 debugWarning("Guard passed on master sync!\n"); 299 303 break; 300 } 304 } 301 305 // we try to match the packets received on equal cycles 302 306 303 307 // unwrap the seconds counter 304 308 if (master_cif.seconds==0) master_cif.seconds+=128; 305 309 306 310 debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"MASTER: [%2d: %04us %04uc, %04X]\n", 307 311 0,master_cif.seconds,master_cif.cycle,master_cif.syt); 308 312 309 313 for (i=1;i<arguments.nb_combos;i++) { 310 314 struct cycle_info cif; 311 315 int slave_guard=0; 312 316 bool read_slave=monitors[i]->readNextCycleInfo(&cif); 313 317 314 318 while(read_slave) { 315 319 slave_guard++; … … 326 330 i,cif.seconds, cif.cycle,cif.syt); 327 331 monitors[i]->consumeNextCycleInfo(); 328 332 329 333 // we have a match ;) 330 334 if ((cif.syt != 0xFFFF) && (master_cif.syt != 0xFFFF)) { … … 338 342 // average out the offset 339 343 int64_t err=(((uint64_t)master_cif.pres_ticks) - ((uint64_t)cif.pres_ticks)); 340 344 341 345 debugOutput(DEBUG_LEVEL_NORMAL,"Diff for %d at cycle %04d: %6lld (MTS: %11llu | STS: %11llu\n", 342 346 i,cif.cycle,err, master_cif.pres_ticks, cif.pres_ticks); 343 347 344 348 err = err - stream_offset_ticks[i]; 345 349 346 350 if(err>50000 || err < -50000) { 347 351 debugOutput(DEBUG_LEVEL_NORMAL, 348 352 " Large Diff: %dticks, delta=%d; avg=%d\n", 349 353 err,(((int)master_cif.pres_ticks) - ((int)cif.pres_ticks)),stream_offset_ticks[i]); 350 354 351 355 debugOutput(DEBUG_LEVEL_NORMAL, 352 356 " Master : %04X -> %10u (%04us %04uc %04ut)\n", 353 master_cif.syt, master_cif.pres_ticks, 357 master_cif.syt, master_cif.pres_ticks, 354 358 master_cif.pres_seconds, master_cif.pres_cycle, master_cif.pres_offset 355 359 ); … … 359 363 master_cif.syt, CYCLE_TIMER_GET_CYCLES(master_cif.syt), 360 364 CYCLE_TIMER_GET_OFFSET(master_cif.syt)); 361 365 362 366 debugOutput(DEBUG_LEVEL_NORMAL, 363 367 " Current : %04X -> %10u (%04us %04uc %04ut)\n", 364 cif.syt, cif.pres_ticks, 368 cif.syt, cif.pres_ticks, 365 369 cif.pres_seconds, cif.pres_cycle, cif.pres_offset 366 370 ); … … 372 376 debugOutput(DEBUG_LEVEL_NORMAL,"\n"); 373 377 } 374 378 375 379 stream_offset_ticks[i] += err/1000; 376 380 377 381 debugOutput(DEBUG_LEVEL_VERY_VERBOSE," Difference: %dticks\n", 378 382 (((int)master_cif.pres_ticks) - ((int)cif.pres_ticks))); 379 383 } 380 384 381 385 break; 382 386 } else { 383 if ((cif.seconds < master_cif.seconds) || 384 ((cif.seconds == master_cif.seconds) 387 if ((cif.seconds < master_cif.seconds) || 388 ((cif.seconds == master_cif.seconds) 385 389 && (cif.cycle < master_cif.cycle))) { 386 390 387 391 debugOutput(DEBUG_LEVEL_VERY_VERBOSE," LAGS : [%2d: %04us %04uc, %04X]\n", 388 392 i,cif.seconds, cif.cycle,cif.syt); 389 393 // the stream lags behind 390 394 391 395 // advance the read pointer 392 // this will always succeed, otherwise we wouldn't be 396 // this will always succeed, otherwise we wouldn't be 393 397 // in this while() 394 398 monitors[i]->consumeNextCycleInfo(); … … 396 400 debugOutput(DEBUG_LEVEL_VERY_VERBOSE," LEADS: [%2d: %04us %04uc, %04X]\n", 397 401 i,cif.seconds, cif.cycle,cif.syt); 398 402 399 403 // the stream is too far ahead, 400 404 // don't do anything … … 418 422 } 419 423 } 420 424 421 425 // show info every x iterations 422 if (masterTimeSource.getCurrentTimeAsUsecs() 426 if (masterTimeSource.getCurrentTimeAsUsecs() 423 427 - last_print_time > 1000000L) { 424 428 425 429 m_isoManager->dumpInfo(); 426 430 for (i=0;i<arguments.nb_combos;i++) { … … 432 436 last_print_time=masterTimeSource.getCurrentTimeAsUsecs(); 433 437 } 434 438 435 439 // 125us/packet, so sleep for a while 436 440 usleep(100); … … 442 446 goto finish; 443 447 } 444 448 445 449 // unregister monitors 446 450 for (i=0;i<arguments.nb_combos;i++) { 447 451 debugOutput(DEBUG_LEVEL_NORMAL, "Unregistering SytMonitor %d\n",i); 448 452 449 453 if(!m_isoManager->unregisterStream(monitors[i])) { 450 454 debugOutput(DEBUG_LEVEL_NORMAL, "Could not unregister SytMonitor %d\n",i); … … 453 457 delete monitors[i]; 454 458 } 455 459 456 460 delete m_isoManager; 457 461 trunk/libffado/tests/test-timestampedbuffer.cpp
r419 r445 1 /*************************************************************************** 2 Copyright (C) 2007 by Pieter Palmers * 3 * 4 This program is free software; you can redistribute it and/or modify * 5 it under the terms of the GNU General Public License as published by * 6 the Free Software Foundation; either version 2 of the License, or * 7 (at your option) any later version. * 8 * 9 This program is distributed in the hope that it will be useful, * 10 but WITHOUT ANY WARRANTY; without even the implied warranty of * 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 12 GNU General Public License for more details. * 13 * 14 You should have received a copy of the GNU General Public License * 15 along with this program; if not, write to the * 16 Free Software Foundation, Inc., * 17 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 ***************************************************************************/ 1 /* 2 * Copyright (C) 2005-2007 by 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 * FFADO is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or 12 * (at your option) any later version. 13 * FFADO 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 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with FFADO; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21 * MA 02111-1307 USA. 22 */ 19 23 20 24 #ifdef HAVE_CONFIG_H … … 41 45 using namespace Util; 42 46 43 class TimestampedBufferTestClient 47 class TimestampedBufferTestClient 44 48 : public TimestampedBufferClient { 45 49 public: 46 50 bool processReadBlock(char *data, unsigned int nevents, unsigned int offset) {return true;}; 47 51 bool processWriteBlock(char *data, unsigned int nevents, unsigned int offset) {return true;}; 48 52 49 53 void setVerboseLevel(int l) {setDebugLevel(l);}; 50 54 private: … … 58 62 int run; 59 63 // Program documentation. 60 static char doc[] = "F reeBoB-- Timestamped buffer test\n\n";64 static char doc[] = "FFADO -- Timestamped buffer test\n\n"; 61 65 62 66 // A description of the arguments we accept. … … 212 216 } 213 217 } 214 break; 218 break; 215 219 default: 216 220 return ARGP_ERR_UNKNOWN; … … 230 234 int main(int argc, char *argv[]) 231 235 { 232 236 233 237 TimestampedBuffer *t=NULL; 234 238 TimestampedBufferTestClient *c=NULL; 235 239 236 240 struct arguments arguments; 237 241 … … 245 249 arguments.buffersize = 1024; 246 250 arguments.start_at_cycle = 0; 247 251 248 252 // Parse our arguments; every option seen by `parse_opt' will 249 253 // be reflected in `arguments'. … … 252 256 exit(1); 253 257 } 254 258 255 259 setDebugLevel(arguments.verbose); 256 260 257 261 run=1; 258 262 259 263 signal (SIGINT, sighandler); 260 264 signal (SIGPIPE, sighandler); 261 265 262 266 c=new TimestampedBufferTestClient(); 263 267 264 268 if(!c) { 265 269 debugOutput(DEBUG_LEVEL_NORMAL, "Could not create TimestampedBufferTestClient\n"); … … 267 271 } 268 272 c->setVerboseLevel(arguments.verbose); 269 273 270 274 t=new TimestampedBuffer(c); 271 275 272 276 if(!t) { 273 277 debugOutput(DEBUG_LEVEL_NORMAL, "Could not create TimestampedBuffer\n"); … … 278 282 279 283 t->init(); 280 281 // Setup the buffer 284 285 // Setup the buffer 282 286 t->setBufferSize(arguments.buffersize); 283 287 t->setEventSize(sizeof(int)); … … 286 290 t->setUpdatePeriod(arguments.frames_per_packet); 287 291 t->setNominalRate(arguments.rate); 288 292 289 293 t->setWrapValue(arguments.wrap_at); 290 294 291 295 t->setTickOffset(10000); 292 296 293 297 t->prepare(); 294 298 295 299 usleep(1000); 296 300 297 301 debugOutput(DEBUG_LEVEL_NORMAL, "Start setBufferHeadTimestamp test...\n"); 298 302 { … … 300 304 uint64_t time=arguments.start_at_cycle*3072; 301 305 int dummyframe_in[arguments.events_per_frame*arguments.frames_per_packet]; 302 306 303 307 // initialize the timestamp 304 308 uint64_t timestamp=time; … … 307 311 timestamp %= arguments.wrap_at; 308 312 } 309 313 310 314 // account for the fact that there is offset, 311 315 // and that setBufferHeadTimestamp doesn't take offset … … 315 319 timestamp2-=arguments.wrap_at; 316 320 } 317 321 318 322 t->setBufferHeadTimestamp(timestamp2); 319 323 320 324 timestamp += (uint64_t)(arguments.rate * arguments.frames_per_packet); 321 325 if (timestamp >= arguments.wrap_at) { 322 326 timestamp -= arguments.wrap_at; 323 327 } 324 328 325 329 // write some packets 326 330 for (unsigned int i=0;i<20;i++) { … … 331 335 } 332 336 } 333 337 334 338 for(unsigned int cycle=arguments.start_at_cycle; 335 cycle < arguments.start_at_cycle+arguments.total_cycles; 339 cycle < arguments.start_at_cycle+arguments.total_cycles; 336 340 cycle++) { 337 341 uint64_t ts_head, fc_head; 338 342 339 343 t->setBufferHeadTimestamp(timestamp); 340 344 t->getBufferHeadTimestamp(&ts_head, &fc_head); 341 345 342 346 if (timestamp != ts_head) { 343 347 debugError(" cycle %4u error: %011llu != %011llu\n", … … 345 349 pass=false; 346 350 } 347 351 348 352 timestamp += (uint64_t)(arguments.rate * arguments.frames_per_packet); 349 353 if (timestamp >= arguments.wrap_at) { 350 354 timestamp -= arguments.wrap_at; 351 355 } 352 356 353 357 // simulate the cycle timer clock in ticks 354 358 time += 3072; … … 356 360 time -= arguments.wrap_at; 357 361 } 358 362 359 363 // allow for the messagebuffer thread to catch up 360 364 usleep(200); 361 365 362 366 if(!run) break; 363 367 } 364 368 365 369 if(!pass) { 366 370 debugError("Test failed, exiting...\n"); 367 371 368 372 delete t; 369 373 delete c; 370 374 371 375 return -1; 372 373 } 374 } 375 376 377 376 377 } 378 } 379 380 381 378 382 debugOutput(DEBUG_LEVEL_NORMAL, "Start read/write test...\n"); 379 383 { 380 384 int dummyframe_in[arguments.events_per_frame*arguments.frames_per_packet]; 381 385 int dummyframe_out[arguments.events_per_frame*arguments.frames_per_packet]; 382 386 383 387 for (unsigned int i=0;i<arguments.events_per_frame*arguments.frames_per_packet;i++) { 384 388 dummyframe_in[i]=i; 385 389 } 386 390 387 391 uint64_t time=arguments.start_at_cycle*3072; 388 392 389 393 // initialize the timestamp 390 394 uint64_t timestamp=time; … … 394 398 } 395 399 t->setBufferTailTimestamp(timestamp); 396 400 397 401 timestamp += (uint64_t)(arguments.rate * arguments.frames_per_packet); 398 402 if (timestamp >= arguments.wrap_at) { 399 403 timestamp -= arguments.wrap_at; 400 404 } 401 405 402 406 for(unsigned int cycle=arguments.start_at_cycle; 403 cycle < arguments.start_at_cycle+arguments.total_cycles; 407 cycle < arguments.start_at_cycle+arguments.total_cycles; 404 408 cycle++) { 405 409 406 410 // simulate the rate adaptation 407 411 int64_t diff=(time%arguments.wrap_at)-timestamp; 408 412 409 413 if (diff>(int64_t)arguments.wrap_at/2) { 410 414 diff -= arguments.wrap_at; … … 412 416 diff += arguments.wrap_at; 413 417 } 414 418 415 419 debugOutput(DEBUG_LEVEL_NORMAL, "Simulating cycle %d @ time=%011llu, diff=%lld\n",cycle,time,diff); 416 420 417 421 if(diff>0) { 418 422 uint64_t ts_head, fc_head; 419 423 uint64_t ts_tail, fc_tail; 420 424 421 425 // write one packet 422 426 t->writeFrames(arguments.frames_per_packet, (char *)&dummyframe_in, timestamp); 423 427 424 428 // read the buffer head timestamp 425 429 t->getBufferHeadTimestamp(&ts_head, &fc_head); 426 430 t->getBufferTailTimestamp(&ts_tail, &fc_tail); 427 debugOutput(DEBUG_LEVEL_NORMAL, 431 debugOutput(DEBUG_LEVEL_NORMAL, 428 432 " TS after write: HEAD: %011llu, FC=%04u\n", 429 433 ts_head,fc_head); 430 debugOutput(DEBUG_LEVEL_NORMAL, 434 debugOutput(DEBUG_LEVEL_NORMAL, 431 435 " TAIL: %011llu, FC=%04u\n", 432 436 ts_tail,fc_tail); 433 437 434 438 // read one packet 435 439 t->readFrames(arguments.frames_per_packet, (char *)&dummyframe_out); 436 440 437 441 // read the buffer head timestamp 438 442 t->getBufferHeadTimestamp(&ts_head, &fc_head); 439 443 t->getBufferTailTimestamp(&ts_tail, &fc_tail); 440 debugOutput(DEBUG_LEVEL_NORMAL, 444 debugOutput(DEBUG_LEVEL_NORMAL, 441 445 " TS after write: HEAD: %011llu, FC=%04u\n", 442 446 ts_head,fc_head); 443 debugOutput(DEBUG_LEVEL_NORMAL, 447 debugOutput(DEBUG_LEVEL_NORMAL, 444 448 " TAIL: %011llu, FC=%04u\n", 445 449 ts_tail,fc_tail); 446 450 447 451 // check 448 452 bool pass=true; … … 453 457 debugOutput(DEBUG_LEVEL_NORMAL, "write/read check for cycle %d failed\n",cycle); 454 458 } 455 459 456 460 // update the timestamp 457 461 timestamp += (uint64_t)(arguments.rate * arguments.frames_per_packet); … … 460 464 } 461 465 } 462 466 463 467 // simulate the cycle timer clock in ticks 464 468 time += 3072; … … 466 470 time -= arguments.wrap_at; 467 471 } 468 472 469 473 // allow for the messagebuffer thread to catch up 470 474 usleep(200); 471 475 472 476 if(!run) break; 473 477 } 474 478 } 475 479 476 480 // second run, now do block processing 477 481 debugOutput(DEBUG_LEVEL_NORMAL, "Start block read test...\n"); … … 480 484 int dummyframe_out_block[arguments.events_per_frame*arguments.frames_per_packet*blocksize]; 481 485 int dummyframe_in[arguments.events_per_frame*arguments.frames_per_packet]; 482 486 483 487 for (unsigned int i=0;i<arguments.events_per_frame*arguments.frames_per_packet;i++) { 484 488 dummyframe_in[i]=i; 485 489 } 486 490 487 491 uint64_t time=arguments.start_at_cycle*3072; 488 492 489 493 // initialize the timestamp 490 494 uint64_t timestamp=time; … … 494 498 } 495 499 t->setBufferTailTimestamp(timestamp); 496 500 497 501 timestamp += (uint64_t)(arguments.rate * arguments.frames_per_packet); 498 502 if (timestamp >= arguments.wrap_at) { 499 503 timestamp -= arguments.wrap_at; 500 504 } 501 505 502 506 for(unsigned int cycle=arguments.start_at_cycle; 503 cycle < arguments.start_at_cycle+arguments.total_cycles; 507 cycle < arguments.start_at_cycle+arguments.total_cycles; 504 508 cycle++) { 505 509 506 510 // simulate the rate adaptation 507 511 int64_t diff=(time%arguments.wrap_at)-timestamp; 508 512 509 513 if (diff>(int64_t)arguments.wrap_at/2) { 510 514 diff -= arguments.wrap_at; … … 512 516 diff += arguments.wrap_at; 513 517 } 514 518 515 519 debugOutput(DEBUG_LEVEL_NORMAL, "Simulating cycle %d @ time=%011llu, diff=%lld\n",cycle,time,diff); 516 520 517 521 if(diff>0) { 518 522 uint64_t ts_head, fc_head; 519 523 uint64_t ts_tail, fc_tail; 520 524 521 525 // write one packet 522 526 t->writeFrames(arguments.frames_per_packet, (char *)&dummyframe_in, timestamp); 523 527 524 528 // read the buffer head timestamp 525 529 t->getBufferHeadTimestamp(&ts_head, &fc_head); 526 530 t->getBufferTailTimestamp(&ts_tail, &fc_tail); 527 debugOutput(DEBUG_LEVEL_NORMAL, 531 debugOutput(DEBUG_LEVEL_NORMAL, 528 532 " TS after write: HEAD: %011llu, FC=%04u\n", 529 533 ts_head,fc_head); 530 debugOutput(DEBUG_LEVEL_NORMAL, 534 debugOutput(DEBUG_LEVEL_NORMAL, 531 535 " TAIL: %011llu, FC=%04u\n", 532 536 ts_tail,fc_tail); 533 537 534 538 if (fc_head > blocksize) { 535 539 debugOutput(DEBUG_LEVEL_NORMAL,"Reading one block (%u frames)\n",blocksize); 536 540 537 541 // read one block 538 542 t->readFrames(blocksize, (char *)&dummyframe_out_block); 539 543 540 544 // read the buffer head timestamp 541 545 t->getBufferHeadTimestamp(&ts_head, &fc_head); 542 546 t->getBufferTailTimestamp(&ts_tail, &fc_tail); 543 debugOutput(DEBUG_LEVEL_NORMAL, 547 debugOutput(DEBUG_LEVEL_NORMAL, 544 548 " TS after read: HEAD: %011llu, FC=%04u\n", 545 549 ts_head,fc_head); 546 debugOutput(DEBUG_LEVEL_NORMAL, 550 debugOutput(DEBUG_LEVEL_NORMAL, 547 551 " TAIL: %011llu, FC=%04u\n", 548 552 ts_tail,fc_tail); 549 553 } 550 554 551 555 // update the timestamp 552 556 timestamp += (uint64_t)(arguments.rate * arguments.frames_per_packet); … … 555 559 } 556 560 } 557 561 558 562 // simulate the cycle timer clock in ticks 559 563 time += 3072; … … 561 565 time -= arguments.wrap_at; 562 566 } 563 567 564 568 // allow for the messagebuffer thread to catch up 565 569 usleep(200); 566 570 567 571 if(!run) break; 568 572 } … … 571 575 delete t; 572 576 delete c; 573 577 574 578 return EXIT_SUCCESS; 575 579 } trunk/libffado/tests/test-volume.cpp
r436 r445 1 /* test-volume.cpp 2 * Copyright (C) 2006 by Daniel Wagner 3 * 4 * This file is part of FreeBoB. 5 * 6 * FreeBoB is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * FreeBoB is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with FreeBoB; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 18 * MA 02111-1307 USA. 19 */ 1 /* 2 * Copyright (C) 2005-2007 by by Daniel Wagner 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 * FFADO is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or 12 * (at your option) any later version. 13 * FFADO 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 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with FFADO; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21 * MA 02111-1307 USA. 22 */ 20 23 21 24 #include "libavc/avc_function_block.h"
