Changeset 445

Show
Ignore:
Timestamp:
04/02/07 12:35:17 (5 years ago)
Author:
pieterpalmers
Message:

* name change from FreeBoB to FFADO
* replaced tabs by 4 spaces
* got rid of end-of-line spaces
* made all license and copyrights conform

library becomes LGPL, apps become GPL
explicitly state LGPL v2.1 and GPL v2 (don't like v3 draft)

copyrights are 2005-2007 Daniel & Pieter
except for the MotU stuff (C) Jonathan, Pieter

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/autogen.sh

    r125 r445  
    22# Run this to generate all the initial makefiles, etc. 
    33 
    4  
    54autoreconf -f -i -s 
    6 ./configure --enable-maintainer-mode 
    7 make 
  • trunk/libffado/ChangeLog

    r336 r445  
     1REMARK: Please use the SVN commit messages as replacement for ChangeLog 
     2 
     32007-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 
    1132006-11-20  Daniel Wagner  <wagi@monom.org> 
    214 
    3        * freebob_set_samplerate: return value consitency fix. On success 
    4        it return 0 else -1. Reported by Jamie Gennis jgennis at gmail dot com 
    5  
    6        * freebob_streaming_start: Reset the playback ringbuffer before calling  
    7        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     
    9212006-11-12  Daniel Wagner  <wagi@monom.org> 
    1022 
    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. 
    1527 
    16282006-11-11  Daniel Wagner  <wagi@monom.org> 
    1729 
    18        * src/bebob/bebob_avdevice.cpp (setSamplingFrequencyPlug): copy past 
    19        error fixed. Reported by Jamie Gennis jgennis at gmail dot com 
     30    * src/bebob/bebob_avdevice.cpp (setSamplingFrequencyPlug): copy past 
     31    error fixed. Reported by Jamie Gennis jgennis at gmail dot com 
    2032 
    21332006-08-27  Daniel Wagner  <wagi@monom.org> 
    2234 
    23        * configure.ac: Version set to 1.4.0 
    24        * maudio device support infrastructure added. Implements 
    25        IAvDevice interface, discover reads the information from 
    26        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.  
    2739 
    28402006-08-22  Daniel Wagner  <wagi@monom.org> 
    2941 
    30        * configure.ac: Version bump to 1.3.0 
    31        * freebob_sync allows now to set the sync mode. It does not 
    32        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. 
    3345 
    34462006-07-17  Daniel Wagner  <wagi@monom.org> 
    3547 
    36        * configure.ac: Version bump to 1.2.0 
    37        * freebob_sync program added 
    38        * Basic interface added for sync info 
     48    * configure.ac: Version bump to 1.2.0 
     49    * freebob_sync program added 
     50    * Basic interface added for sync info 
    3951 
    40522006-07-02  Daniel Wagner  <wagi@monom.org> 
    4153 
    42        * firmware downloader: check device firmware compatibility 
     54    * firmware downloader: check device firmware compatibility 
    4355 
    44562006-06-27  Daniel Wagner  <wagi@monom.org> 
    4557 
    46        * configure.ac: Version bump to 1.1.0 
    47        * remove bebob_light code 
    48        * downloader various improvements 
    49        * 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. 
    5163 
    52642006-06-24  Daniel Wagner  <wagi@monom.org> 
    5365 
    54        * tests/streaming/Makefile.am: Fixed build problem with missing '/'. 
     66    * tests/streaming/Makefile.am: Fixed build problem with missing '/'. 
    5567 
    56682006-06-21  Daniel Wagner  <wagi@monom.org> 
    5769 
    58        * freebob-downloader first version added 
     70    * freebob-downloader first version added 
    5971 
    60722006-06-10  Daniel Wagner  <wagi@monom.org> 
    6173 
    62        * Changed building rules: No static sub libraries 
    63        are build anymore. 
     74    * Changed building rules: No static sub libraries 
     75    are build anymore. 
    6476 
    65772006-06-01  Daniel Wagner  <wagi@monom.org> 
    6678 
    67        * configure.ac: Version bump to 1.0.0 
    68  
    69        * Changed all FreeBob to FreeBoB 
    70        * Removed all .cvsignore 
    71        * Added Pieter to AUTHORS 
    72        * 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) 
    7385 
    74862006-05-31  Daniel Wagner  <wagi@monom.org> 
    7587 
    76        * Free all allocated asprintf buffers after xmlNewChild. 
    77        Compiler warning removed 
     88    * Free all allocated asprintf buffers after xmlNewChild. 
     89    Compiler warning removed 
    7890 
    79912006-05-31  Pieter Palmers  <pieterpalmers@users.sourceforge.net> 
     
    110122 
    1111232006-05-26  Pieter Palmers  <pieterpalmers@users.sourceforge.net> 
    112        * src/libfreebobstreaming/*:  
     124    * src/libfreebobstreaming/*:  
    113125    - added a 'verbose' option to disable/enable message output 
    114126    - removed some residual messages 
     
    131143 
    1321442006-05-12  Pieter Palmers  <pieterpalmers@users.sourceforge.net> 
    133        * src/libfreebobstreaming/*:  
    134        - Code cleanup 
    135        - Improved SSE code 
    136        - ISO connection parameters are calculated instead of being user 
    137          specified. Note: you need a new jackd backend version due to this. 
    138          
    139        * configure.ac: Version bumped to 0.8.2 
     145    * 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 
    140152 
    1411532006-05-06  Daniel Wagner  <wagi@monom.org> 
    142154 
    143        * This patch fixes two issues when building: 
    144        - libfreebob include files aren't found when build dir != source dir 
    145        - some libraries aren't found when they're not in a system install dir 
    146  
    147        Jeremy Kerr 
     155    * 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 
    148160 
    1491612006-05-04  Pieter Palmers  <pieterpalmers@users.sourceforge.net> 
    150162 
    151        * configure.ac: Version bumped to 0.8.1 
    152  
    153        * Introduced SSE-accellerated packet encoders/decoders 
     163    * configure.ac: Version bumped to 0.8.1 
     164 
     165    * Introduced SSE-accellerated packet encoders/decoders 
    154166 
    1551672006-05-04  Daniel Wagner  <wagi@monom.org> 
    156168 
    157        * configure.ac: Version bumped to 0.8.0 
    158  
    159        * Discovering code ported stable 0.2.0 version 
    160        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. 
    161173 
    1621742006-05-04  Daniel Wagner  <wagi@monom.org> 
    163175 
    164        * configure.ac: Version bumped to 0.7.2 
    165  
    166        * src/bebob: Some cleanup on naming and 
    167        namespaces. 
     176    * configure.ac: Version bumped to 0.7.2 
     177 
     178    * src/bebob: Some cleanup on naming and 
     179    namespaces. 
    168180 
    1691812006-05-03  Daniel Wagner  <wagi@monom.org> 
    170182 
    171        * configure.ac: Version bumped to 0.7.1 
    172  
    173        * Fixed bug in SignalSource command which 
    174        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. 
    175187 
    1761882006-04-23  Daniel Wagner  <wagi@monom.org> 
    177189 
    178        * configure.ac: Version bumped to 0.7.0 
    179  
    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. 
    183195 
    1841962006-04-17  Daniel Wagner  <wagi@monom.org> 
    185197 
    186        * configure.ac: Version bumped to 0.6.4 
    187  
    188        * src/libfreebobavc/avc_generic.cpp (serialize): Decode subunit_type  
    189        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. 
    193205 
    1942062006-04-11  Daniel Wagner  <wagi@monom.org> 
    195207 
    196        * configure.ac: Version bumped to 0.6.3 
    197          
    198        * src/avdevicesubunit.cpp (discoverFunctionBlocks): reformating. 
    199        (discoverFunctionBlocksDo): Really added a correct 
    200        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. 
    201213 
    2022142006-04-07  Pieter Palmers <pieterpalmers@users.sourceforge.net> 
    203215 
    204        * src/avdevice.h src/avdevice.cpp: moved the include of stdint.h 
    205        from the implementation to the header, to fix certain compilation 
    206        problems wrt uint64_t. This datatype is also used in the class 
    207        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. 
    208220 
    2092212006-04-05  Pieter Palmers <pieterpalmers@users.sourceforge.net> 
    210222 
    211        * configure.ac: Version bump to 0.6.2 
    212  
    213        * src/freebob.cpp: Retry setting the sample rate if it fails the 
    214        first time. 
    215          
    216        * src/libfreebobstreaming/*: Added an way to choose for playback 
    217        or capture only (for ALSA plugin), using the options passed when 
    218        creating the freebob device.  * src/libfreebobstreaming/*: fixed 
    219        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. 
    220232 
    2212332006-04-04  Daniel Wagner  <wagi@monom.org> 
    222234 
    223        * configure.ac: Version bump to 0.6.1 
    224  
    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. 
    228240 
    2292412006-03-30  Daniel Wagner  <wagi@monom.org> 
    230242 
    231        * configure.ac: Version bump to 0.6.0 
    232  
    233        * src/*: Verbose bool turned int verbose level. 
    234          
    235        * src/libfreebobavc/*: Moved fire implementation to  
    236        base class (AVCCommand).  
    237          
    238        * libfreebob/freebob.h: freebob_sleep_after_avc_command 
    239        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. 
    248260 
    2492612006-03-20  Daniel Wagner  <wagi@monom.org> 
    250262 
    251        * configure.ac: Version bump to 0.5.2 
    252  
    253        * src/avplug.cpp (discoverStreamFormat): If no stream format information 
    254        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) 
    256268 
    2572692006-03-15  Daniel Wagner  <wagi@monom.org> 
    258270 
    259        * configure.ac: Version bump to 0.5.1 
    260          
    261        * src/libfreebobavc/avc_extended_plug_info.cpp (fire):  
    262          Handle NOT_IMPLEMENTED. 
    263          
    264        * src/avplug.h: Input and output plug discovering part 
    265        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. 
    268280 
    2692812006-03-12  Daniel Wagner  <wagi@monom.org> 
    270282 
    271        * src/libfreebobavc/ieee1394service.cpp (transactionBlock): Set retry 
    272        value to 10.  
     283    * src/libfreebobavc/ieee1394service.cpp (transactionBlock): Set retry 
     284    value to 10.  
    273285 
    2742862006-03-10  Daniel Wagner  <wagi@monom.org> 
    275287 
    276        * configure.ac: Version bump to 0.5.0 
    277  
    278        * src/avdevice.cpp: Plug connection discovering 
    279        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: Likewise 
    290  
    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. 
    296308 
    2973092006-03-05  Daniel Wagner  <wagi@monom.org> 
    298310 
    299        * src/avdevice.cpp: Plug connection discovering also on 
    300        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 and 
    309        functionblock.h 
    310        * src/functionblock.cpp: New file 
    311        * 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. 
    312324 
    3133252006-03-04  Daniel Wagner  <wagi@monom.org> 
    314326 
    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 which 
    321        does not print the xml stuff. 
    322  
    323        * src/avdevice.cpp: Added 'verbose' argument to constructor 
    324        and set debug level to DEBUG_LEVEL_VERBOSE if 'verbose' 
    325        is true, e.g enables verbose mode with '-v' argument passed 
    326        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_ and  
    339        ExtendedPlugInfoPlugTypeSpecificData::eEPIPT_* exchanged with corresponding 
    340        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. 
    347359 
    3483602006-03-02  Daniel Wagner  <wagi@monom.org> 
    349361 
    350        * src/avplug.cpp (discoverStreamFormat): Sanity check turned 
    351        into warning. 
    352  
    353        * configure.ac: bumb minor version to 0.4 
    354  
    355        * src/libfreebobavc/avc_extended_cmd_generic.h: plugAddressPlugDirectionToString 
    356        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 instead 
    366        of hardcoded id to find sync plugs. 
    367  
    368        * src/devicemanager.h: Verbose argument not in constructor 
    369        instead in discover method. 
    370        * src/devicemanager.cpp: Likewise. 
    371  
    372        * libfreebob/freebob.h (freebob_discover_devices): Verbose argument 
    373        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. 
    377389 
    3783902006-03-01  Daniel Wagner  <wagi@monom.org> 
    379391 
    380        * configure.ac: bumb minor version to 0.3 
    381  
    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: Give 
    394        return value to caller. New undefined plug address 
    395        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-debug 
    411        switch. 
    412  
    413        * src/libfreebobstreaming/freebob_connections.h: Removed double defined variable  
    414        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. 
    415427 
    4164282006-02-28  Pieter Palmers <pieterpalmers@users.sourceforge.net> 
    417        * Added the streaming API that was previously hardcoded into the jackd backend 
    418          to the library as src/libfreebobstreaming. 
    419        * Added test programs for the streaming API in tests/streaming 
     429    * 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 
    420432 
    4214332006-02-26  Daniel Wagner  <wagi@monom.org> 
    422434 
    423        * src/avdevice.cpp: Some more refactoring (m_isoInputPlugs and m_isoOutputPlugs 
    424        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. 
    434446 
    4354472006-02-22  Daniel Wagner  <wagi@monom.org> 
    436448 
    437        *  configure.ac 
    438        src/Makefile.am 
     449    *  configure.ac 
     450    src/Makefile.am 
    439451        src/avdevice.cpp 
    440452        src/avdevice.h 
     
    443455        src/avdevicexml.cpp 
    444456        src/avplug.cpp 
    445        src/avplug.h 
     457    src/avplug.h 
    446458        src/avplugxml.cpp 
    447459        src/libfreebobavc/avc_extended_plug_info.cpp 
     
    451463        src/libfreebobavc/avc_plug_info.cpp 
    452464        src/libfreebobavc/avc_plug_info.h: 
    453        Refactoring: plug discovering is now part of AvPlug 
    454        instead of AvDevice. 
    455        All plugs of music and audio subunit are now also 
    456        discovered. 
    457        libfreebobavc: Copy constructor added. 
    458  
    459        The overhaul is not finished. This is the first 
    460        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. 
    461473 
    4624742006-01-19  Daniel Wagner  <wagi@monom.org> 
    463475 
    464476        * This patch cleans up the external dependency detection for  
    465        libfreebob. At present, building libfreebob is not possible  
    466        if libraries are outside the system include/library paths  
    467        (ie /usr/ and /usr/local). Use the results of pkg-config to  
    468        specify the correct paths to the automake system. 
    469  
    470        Becuase we're using pkgconfig, there's no real need to use  
    471        AC_CHECK_LIB or AC_CHECK_HEADERS. However, these could  
    472        potentially be reinstated, but need to be fixed to check in  
    473        the locations specified by pkgconfig. 
    474  
    475        * It is not currently possible to build freebob in a directory  
    476        outside the source dir (ie, builddir != srcdir). This patch  
    477        fixes the include paths to allow this. (it's handy for keeping  
    478        the source tree clean, or when building on multiple architectures  
    479        - I use a build dir of $srcdir/obj-$arch-$os) 
    480  
    481        Both patches are written by Jeremy Kerr jk at ozlabs dot org 
     477    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 
    482494 
    4834952006-01-12  Daniel Wagner  <wagi@monom.org> 
    484496 
    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. 
    487499 
    4885002006-01-08  Daniel Wagner  <wagi@monom.org> 
    489501 
    490        *  libfreebob/freebob.h 
    491        libfreebob/xmlparser.h 
    492        src/avdevice.cpp 
    493        src/xmlparser.c 
    494        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. 
    496508 
    497509        * 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 of 
    515        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.cpp 
    526  
    527        * src/libfreebobavc/avc_definitions.h 
    528        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. 
    533545 
    5345462006-01-06  Daniel Wagner  <wagi@monom.org> 
    535547 
    536        * tests/test-freebob.c (main): setsamplerate on all 
    537        devices takes now the samplerate argument. 
    538  
    539        * src/freebob.cpp (freebob_set_samplerate): After setting 
    540        sampling rate rediscover devices. 
    541  
    542        * src/devicemanager.cpp (discover): Clear vector as well after 
    543        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.h  
    551        src/avdevice.cpp (setSampleRate): Implementation added. 
    552  
    553        * src/devicemanager.cpp  
    554        src/devicemanager.h (getAvDevice): New functions 
    555        (setNodeSampleFrequency): removed. 
    556  
    557        * src/freebob.cpp (parseSampleRate): New function. 
    558        (freebob_set_samplerate): Use AvDevice directly 
    559        for setting samplerate. 
    560  
    561        * src/libfreebobavc/avc_definitions.h 
    562        src/libfreebobavc/avc_definitions.cpp: Changed ESampleFrequency 
    563        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 :) 
    568580 
    5695812006-01-04  Daniel Wagner  <wagi@monom.org> 
    570582 
    571        * tests/test-extplugcmd.cpp: Changed test application 
    572        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 workaround 
    576        added which converts the C++ string into a C string before strlen 
    577        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. 
    578590 
    5795912006-01-03  Daniel Wagner  <wagi@monom.org> 
    580592 
    581        * src/devicemanager.cpp (discover): If config rom initializing 
    582        failes just skip this device. The PHY might be in power safe  
    583        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. 
    584596 
    5855972006-01-02  Pieter Palmer <pieterpalmers@users.sourceforge.net> 
    586598 
    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_description  
    591        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.cpp  
    598        src/libfreebobavc/avc_extended_stream_format.cpp 
    599        src/libfreebobavc/avc_extended_stream_format.h 
    600        src/libfreebobavc/avc_plug_info.cpp 
    601        src/libfreebobavc/avc_signal_source.cpp 
    602        src/avcdevice.cpp  
    603        src/avdevice.h  
    604        src/avplug.cpp  
    605        src/avplug.h 
    606        src/devicemanager.cpp 
    607        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 verson 
    615  
    616        * src/xmlparser.c 
    617        tests/test-freeebob.c: Added support to detect & use  
    618        multiple devices on the bus. 
    619  
    620        * src/libfreebobavc/avc_extendec_plug_info.cpp 
    621        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     
    6246362006-01-02  Daniel Wagner  <wagi@monom.org> 
    625637 
    626        * src/avdevice.cpp (discoverStep9): Sanity check: 8 logical 
    627        midi channel fit into 1 channel. 
     638    * src/avdevice.cpp (discoverStep9): Sanity check: 8 logical 
     639    midi channel fit into 1 channel. 
    628640 
    6296412005-12-31  Daniel Wagner  <wagi@monom.org> 
    630642 
    631        * src/debugmodule/debugmodule.h: debugFatal, debugError 
    632        and debugWarning declaration always declared. 
    633  
    634        * src/xmlparser.c (freebob_xmlparse_connection): Parse IsoChannel 
    635        node. 
    636  
    637        * src/freebob.cpp (freebob_print_connection_info): Print all 
    638        members from connection_spec (IsoChannel and IsMaster). 
    639  
    640        * src/avdevice.cpp (addPlugToXmlDescription): Set direction 
    641        according library interface definition and not according 
    642        avc model.  
    643        Add IsoChannel node. 
    644  
    645        * configure.ac: Version set to 0.0.2 
     643    * 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 
    646658 
    6476592005-12-30  Daniel Wagner  <wagi@monom.org> 
    648660 
    649        * src/libfreebobavc/avc_extended_stream_format.cpp (fire): Buffer 
    650        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 and  
    656        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. 
    657669 
    6586702005-12-28  Daniel Wagner  <wagi@monom.org> 
    659671 
    660        * tests/test-freebob.c (main): Debug info added. 
    661  
    662        * src/libfreebobavc/ieee1394service.cpp (initialize): Use  
    663        raw1394_new_handle_on_port instead of raw1394_new_handle and 
    664        raw1394_set_port. 
    665  
    666        * src/devicemanager.cpp (initialize): After deleteing 1394 service  
    667        clear also pointer. 
    668  
    669        * libfreebob/freebob.h: freebob_direction enum names changed 
    670        members which jack backed freebob needs to freebob_connection added 
    671          
    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. 
    673685 
    6746862005-12-27  Daniel Wagner  <wagi@monom.org> 
    675687 
    676        * src/libfreebobavc/avc_extended_plug_info.cpp (serialize):  
    677        Do cast of the length field to let the compiler know which version 
    678        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. 
    679691 
    6806922005-12-26  Daniel Wagner  <wagi@monom.org> 
    681693 
    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 FreeBoB
     1# configure.ac - Configure script for FFADO
    22# Copyright (C) 2005,06 by Daniel Wagner. 
    33# Copyright (C) 2006,07 by Pieter Palmers. 
    44# 
    5 # This file is part of FreeBoB. 
     5# This file is part of FFADO. 
     6# FFADO is based upon FreeBoB. 
    67# 
    7 # FreeBoB is free software; you can redistribute it and/or modify 
     8# FFADO is free software; you can redistribute it and/or modify 
    89# it under the terms of the GNU General Public License as published by 
    910# the Free Software Foundation; either version 2 of the License, or 
    1011# (at your option) any later version. 
    11 # FreeBoB is distributed in the hope that it will be useful, 
     12# FFADO is distributed in the hope that it will be useful, 
    1213# but WITHOUT ANY WARRANTY; without even the implied warranty of 
    1314# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1415# GNU General Public License for more details. 
    1516# You should have received a copy of the GNU General Public License 
    16 # along with FreeBoB; if not, write to the Free Software 
     17# along with FFADO; if not, write to the Free Software 
    1718# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
    1819# 
     
    2324 
    2425 
    25 m4_define(freebob_major_version, 1) 
    26 m4_define(freebob_minor_version, 999) 
    27 m4_define(freebob_micro_version, 4) 
    28  
    29 m4_define(freebob_version, freebob_major_version.freebob_minor_version.freebob_micro_version) 
    30  
    31 AC_INIT(libfreebob, freebob_version, <freebob-devel@lists.sf.net>) 
     26m4_define(ffado_major_version, 1) 
     27m4_define(ffado_minor_version, 999) 
     28m4_define(ffado_micro_version, 4) 
     29 
     30m4_define(ffado_version, ffado_major_version.ffado_minor_version.ffado_micro_version) 
     31 
     32AC_INIT(libffado, ffado_version, <ffado-devel@lists.sf.net>) 
    3233 
    3334# Before making a release, the LT_VERSION string should be modified. 
     
    3940# - If the interface is the same as the previous version, change to C:R+1:A 
    4041 
    41 LT_VERSION=2:0:0 
     42LT_VERSION=1:0:0 
    4243AC_SUBST(LT_VERSION) 
    4344 
    44 AC_DEFINE(FREEBOB_MAJOR_VERSION, freebob_major_version,[Freebob major version]) 
    45 AC_DEFINE(FREEBOB_MINOR_VERSION, freebob_minor_version,[Freebob minor version]) 
    46 AC_DEFINE(FREEBOB_MICRO_VERSION, freebob_micro_version,[Freebob micro version]) 
    47 AC_SUBST(FREEBOB_MINOR_VERSION, freebob_minor_version) 
    48 AC_SUBST(FREEBOB_MAJOR_VERSION, freebob_major_version) 
    49 AC_SUBST(FREEBOB_MICRO_VERSION, freebob_micro_version) 
     45AC_DEFINE(FFADO_MAJOR_VERSION, ffado_major_version,[FFADO major version]) 
     46AC_DEFINE(FFADO_MINOR_VERSION, ffado_minor_version,[FFADO minor version]) 
     47AC_DEFINE(FFADO_MICRO_VERSION, ffado_micro_version,[FFADO micro version]) 
     48AC_SUBST(FFADO_MINOR_VERSION, ffado_minor_version) 
     49AC_SUBST(FFADO_MAJOR_VERSION, ffado_major_version) 
     50AC_SUBST(FFADO_MICRO_VERSION, ffado_micro_version) 
    5051 
    5152AM_INIT_AUTOMAKE([subdir-objects]) 
    5253AM_MAINTAINER_MODE 
    53 AC_CONFIG_SRCDIR([src/freebob.cpp]) 
     54AC_CONFIG_SRCDIR([src/ffado.cpp]) 
    5455AC_CONFIG_HEADER([config.h]) 
    5556AC_GNU_SOURCE 
     
    109110AC_CHECK_LIB(pthread, pthread_create,, 
    110111[ 
    111         AC_ERROR(You need the pthread library to compile freebob
     112        AC_ERROR(You need the pthread library to compile ffado
    112113]) 
    113114 
     
    181182 
    182183  if test "$target_cpu" = "i586"; then 
    183       FREEBOB_OPT_CFLAGS="-march=i586 " 
     184      FFADO_OPT_CFLAGS="-march=i586 " 
    184185  elif test "$target_cpu" = "i686"; then 
    185       FREEBOB_OPT_CFLAGS="-march=i686" 
     186      FFADO_OPT_CFLAGS="-march=i686" 
    186187  else 
    187188      : 
    188189  fi 
    189190 
    190   FREEBOB_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" 
    191192 
    192193 
     
    195196                   [ask the compiler for its best optimizations]), 
    196197    [ if test x$enable_optimize != xno ; then 
    197         CFLAGS="$CFLAGS $FREEBOB_OPT_CFLAGS" ; 
    198         CXXFLAGS="$CXXFLAGS $FREEBOB_OPT_CFLAGS" 
     198        CFLAGS="$CFLAGS $FFADO_OPT_CFLAGS" ; 
     199        CXXFLAGS="$CXXFLAGS $FFADO_OPT_CFLAGS" 
    199200      fi  
    200201    ] 
     
    399400                 doc/Makefile 
    400401                 doc/reference.doxygen 
    401                  libfreebob/Makefile 
     402                 libffado/Makefile 
    402403                 src/Makefile 
    403404                 tests/Makefile 
    404405                 tests/streaming/Makefile 
    405                  libfreebob.pc]) 
     406                 libffado.pc]) 
    406407 
    407408AC_OUTPUT 
     
    410411AC_MSG_RESULT([ 
    411412 
    412 FreeBoB $VERSION is now configured for $canonical_host_type 
     413FFADO $VERSION is now configured for $canonical_host_type 
    413414 
    414415  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 using 
    3  * doxygen. 
    4  */ 
    5  
    61/** 
    7 @page adding_devices Adding support for new devices to LibFreeBoB 
     2@page adding_devices Adding support for new devices to libffado 
    83 
    94@author Pieter Palmers <pieterpalmers@users.sourceforge.net> 
     
    2116 Layer 2 is implemented by subclassing the StreamProcessor class in src/libstreaming/ 
    2217  
    23  Basic operation of libfreebob is: 
     18 Basic operation of libffado is: 
    2419 - Create a DeviceManager that iterates over all nodes connected to the 1394 bus.  
    2520   For every node present, it tries the probeFunctions (probeBeBoB, probeMotu, ...). 
     
    5449         the start/stop mechanism differ. 
    5550  
    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: 
    5752  - an IAvDevice descendant that takes care of the device discovery & configuration 
    5853  - a StreamProcessor descendant that takes care of the device specific stream translation 
     
    6560@section streamingbaseclasses Streaming base class hierarchy and operation 
    6661 
    67 This section explains the implementation details of the streaming part of LibFreeBoB.  
     62This section explains the implementation details of the streaming part of libffado.  
    6863 
    6964The following figure shows the base class diagram, and the derrived classed that implement 
     
    8984- an IsoHandlerManager instance 
    9085 
    91 Related classes: FreebobStreaming::StreamProcessorManager 
     86Related classes: Streaming::StreamProcessorManager 
    9287 
    9388@subsection isoside The ISO side: 1394 isochronous traffic management 
     
    10398\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... 
    10499 
    105 Related classes: FreebobStreaming::IsoStream, FreebobStreaming::IsoHandlerManager, FreebobStreaming::IsoHandler 
     100Related classes: Streaming::IsoStream, Streaming::IsoHandlerManager, Streaming::IsoHandler 
    106101 
    107102@subsection audioapiside The Audio API side: port management 
     
    137132The 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. 
    138133 
    139 Related classes: FreebobStreaming::Port, FreebobStreaming::PortManager 
     134Related classes: Streaming::Port, Streaming::PortManager 
    140135 
    141136@subsection connectingisoandaudio Connecting the ISO side with the Audio API side 
     
    161156A StreamProcessor also has the init(), prepare() and reset() calls, which are still to be documented (see later). 
    162157 
    163 Related classes: FreebobStreaming::StreamProcessor, FreebobStreaming::ReceiveStreamProcessor, FreebobStreaming::TransmitStreamProcessor, FreebobStreaming::PortManager 
     158Related classes: Streaming::StreamProcessor, Streaming::ReceiveStreamProcessor, Streaming::TransmitStreamProcessor, Streaming::PortManager 
    164159 
    165160@subsection mappingports Mapping Ports to IsoStreams 
     
    167162 
    168163@subsection puttingtogether Putting it all together 
     164 
     165@note this is outdated 
     166 
    169167The framework is completed by introducing the StreamProcessorManager. As indicated before, this class implements a 'collection of StreamProcessors' and an IsoHandlerManager.  
    170168 
    171169First 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. 
    172170 
    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. 
     171Furthermore 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. 
    174172 
    175173The 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. 
     
    181179\note A blocking-read/nonblocking write (and the other way around) version of access to PacketBuffered Ports is planned. 
    182180 
    183 Related classes: FreebobStreaming::StreamProcessorManager, FreebobStreaming::IsoHandlerManager, FreebobStreaming::Port 
     181Related classes: Streaming::StreamProcessorManager, Streaming::IsoHandlerManager, Streaming::Port 
    184182 
    185183@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 using 
    3  * doxygen. 
    4  */ 
    5  
    61/** 
    72@page amdtpdescription The AMDTP StreamProcessor 
  • trunk/libffado/doc/mainpage.dox

    r249 r445  
    11/* 
    2  * This is the main page of the FreeBoB reference manual, built using 
     2 * This is the main page of the FFADO reference manual, built using 
    33 * doxygen. 
    44 */ 
    55 
    66/** 
    7 @mainpage FreeBoB - Firewire (pro-)audio for Linux 
     7@mainpage FFADO - Free Firewire (pro-)Audio Drivers for Linux 
    88 
    99@author Pieter Palmers <pieterpalmers@users.sourceforge.net> 
     
    1111@section intro Introduction 
    1212 
    13 FreeBoB is intended as an intermediate layer between the Linux1394 kernel/userspace layer, and the various audio API's (ALSA, jack, ...) present. 
     13FFADO is intended as an intermediate layer between the Linux1394 kernel/userspace layer, and the various audio API's (ALSA, jack, ...) present. 
    1414 
    1515\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. 
    1616 
    17 @see <http://freebob.sourceforge.net> 
     17@see <http://ffado.sourceforge.net> 
    1818 
    1919@section library Client side library 
    2020 
    21 FreeBoB presents an interface that can be used to implement backends for various audio 
     21FFADO presents an interface that can be used to implement backends for various audio 
    2222API's. Currently the best support is for the JACK backend. It is also intended to implement configuration applications like mixer controls etc.. 
    2323 
    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  
     24The library API's external C interface is defined in: 
     25        - @ref ffado.h "<libffado/ffado.h>"  
    2826 
    2927@section devicesupport Adding support for unsupported devices 
    3028 
    31 Initial support is/was for BeBoB devices only, however the framework  
    32 is usable for all firewire audio devices. 
     29Initial support by FreeBoB was for BeBoB devices only, however the FFADO framework  
     30is usable for all FireWire audio devices. 
    3331 
    3432Take a look at the @ref adding_devices page for a detailed description. 
  • trunk/libffado/doc/reference.doxygen.in

    r250 r445  
    1818# by quotes) that should identify the project. 
    1919 
    20 PROJECT_NAME           = LIBFREEBOB 
     20PROJECT_NAME           = LIBFFADO 
    2121 
    2222# The PROJECT_NUMBER tag can be used to enter a project or revision number.  
     
    366366                         @top_srcdir@/src/ \ 
    367367                         @top_srcdir@/src/debugmodule \ 
     368                         @top_srcdir@/src/libavc \ 
     369                         @top_srcdir@/src/libieee1394 \ 
     370                         @top_srcdir@/src/libosc \ 
    368371                         @top_srcdir@/src/libstreaming \ 
    369372                         @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 
    372382 
    373383# If the value of the INPUT tag contains directories, you can use the  
  • trunk/libffado/doc/streaming.xmi

    r403 r445  
    8585        <UML:DataType stereotype="12706" isSpecification="false" isLeaf="false" visibility="public" namespace="88018" xmi.id="13397" isRoot="false" isAbstract="false" name="PortVectorIterator" elementReference="13396" /> 
    8686        <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="FreebobRunnableInterface*" 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" /> 
    8888        <UML:DataType stereotype="12706" isSpecification="false" isLeaf="false" visibility="public" namespace="88018" xmi.id="14530" isRoot="false" isAbstract="false" name="unsigned char*" elementReference="14529" /> 
    8989        <UML:DataType stereotype="12706" isSpecification="false" isLeaf="false" visibility="public" namespace="88018" xmi.id="14540" isRoot="false" isAbstract="false" name="unsigned int*" elementReference="12734" /> 
     
    9696        <UML:DataType stereotype="12706" isSpecification="false" isLeaf="false" visibility="public" namespace="88018" xmi.id="14665" isRoot="false" isAbstract="false" name="IsoHandlerManager*" elementReference="14659" /> 
    9797        <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="freebob_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" /> 
    9999        <UML:DataType stereotype="12706" isSpecification="false" isLeaf="false" visibility="public" namespace="88018" xmi.id="15236" isRoot="false" isAbstract="false" name="IsoHandler*" elementReference="15194" /> 
    100100        <UML:DataType stereotype="12706" isSpecification="false" isLeaf="false" visibility="public" namespace="88018" xmi.id="15278" isRoot="false" isAbstract="false" name="PacketBuffer*" elementReference="15167" /> 
     
    109109      </UML:Package> 
    110110      <UML:Class comment="Id$ *//* 
    111   FreeBob Streaming API 
    112   FreeBob = Firewire (pro-)audio for linux 
     111  FFADO Streaming API 
     112  FFADO = Firewire (pro-)audio for linux 
    113113 
    114   http://freebob.sf.net 
     114  http://ffado.sf.net 
    115115 
    116116  Copyright (C) 2005,2006 Pieter Palmers &lt;pieterpalmers@users.sourceforge.net> 
     
    958958      </UML:Class> 
    959959      <UML:Class comment="Id$ *//* 
    960   FreeBob Streaming API 
    961   FreeBob = Firewire (pro-)audio for linux 
     960  FFADO Streaming API 
     961  FFADO = Firewire (pro-)audio for linux 
    962962 
    963   http://freebob.sf.net 
     963  http://ffado.sf.net 
    964964 
    965965  Copyright (C) 2005,2006 Pieter Palmers &lt;pieterpalmers@users.sourceforge.net> 
     
    10341034      <UML:Class isSpecification="false" isLeaf="false" visibility="public" namespace="1" xmi.id="13000" isRoot="false" isAbstract="false" name="enum E_Formats" /> 
    10351035      <UML:Class comment="Id$ *//* 
    1036   FreeBob Streaming API 
    1037   FreeBob = Firewire (pro-)audio for linux 
     1036  FFADO Streaming API 
     1037  FFADO = Firewire (pro-)audio for linux 
    10381038 
    1039   http://freebob.sf.net 
     1039  http://ffado.sf.net 
    10401040 
    10411041  Copyright (C) 2005,2006 Pieter Palmers &lt;pieterpalmers@users.sourceforge.net> 
     
    15311531      <UML:Class stereotype="13989" isSpecification="false" isLeaf="false" visibility="public" namespace="1" xmi.id="13991" isRoot="false" isAbstract="false" name="SInt32" /> 
    15321532      <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 Freebob (C) 2006, Pieter Palmers 
     1533      <UML:Class comment="Modifications for FFADO (C) 2006, Pieter Palmers 
    15341534Copied from the jackd/jackdmp sources 
    15351535function names changed in order to avoid naming problems when using this in 
     
    15491549Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
    15501550//*! 
    1551 \brief The POSIX thread base class." isSpecification="false" isLeaf="false" visibility="public" namespace="1" xmi.id="13993" isRoot="false" isAbstract="false" name="FreebobPosixThread" > 
     1551\brief The POSIX thread base class." isSpecification="false" isLeaf="false" visibility="public" namespace="1" xmi.id="13993" isRoot="false" isAbstract="false" name="FFADOPosixThread" > 
    15521552       <UML:GeneralizableElement.generalization> 
    15531553        <UML:Generalization xmi.idref="13995" /> 
     
    16601660         </UML:BehavioralFeature.parameter> 
    16611661        </UML:Operation> 
    1662         <UML:Operation stereotype="12714" isSpecification="false" isLeaf="false" visibility="public" xmi.id="14007" isRoot="false" isAbstract="false" isQuery="false" name="FreebobPosixThread" > 
     1662        <UML:Operation stereotype="12714" isSpecification="false" isLeaf="false" visibility="public" xmi.id="14007" isRoot="false" isAbstract="false" isQuery="false" name="FFADOPosixThread" > 
    16631663         <UML:BehavioralFeature.parameter> 
    16641664          <UML:Parameter isSpecification="false" visibility="private" xmi.id="14010" value="" type="14009" name="runnable" /> 
     
    16681668         </UML:BehavioralFeature.parameter> 
    16691669        </UML:Operation> 
    1670         <UML:Operation stereotype="12714" isSpecification="false" isLeaf="false" visibility="public" xmi.id="14014" isRoot="false" isAbstract="false" isQuery="false" name="FreebobPosixThread" > 
     1670        <UML:Operation stereotype="12714" isSpecification="false" isLeaf="false" visibility="public" xmi.id="14014" isRoot="false" isAbstract="false" isQuery="false" name="FFADOPosixThread" > 
    16711671         <UML:BehavioralFeature.parameter> 
    16721672          <UML:Parameter isSpecification="false" visibility="private" xmi.id="14015" value="" type="14009" name="runnable" /> 
    16731673         </UML:BehavioralFeature.parameter> 
    16741674        </UML:Operation> 
    1675         <UML:Operation stereotype="12714" isSpecification="false" isLeaf="false" visibility="public" xmi.id="14016" isRoot="false" isAbstract="false" isQuery="false" name="FreebobPosixThread" > 
     1675        <UML:Operation stereotype="12714" isSpecification="false" isLeaf="false" visibility="public" xmi.id="14016" isRoot="false" isAbstract="false" isQuery="false" name="FFADOPosixThread" > 
    16761676         <UML:BehavioralFeature.parameter> 
    16771677          <UML:Parameter isSpecification="false" visibility="private" xmi.id="14017" value="" type="14009" name="runnable" /> 
     
    16791679         </UML:BehavioralFeature.parameter> 
    16801680        </UML:Operation> 
    1681         <UML:Operation isSpecification="false" isLeaf="false" visibility="public" xmi.id="14019" isRoot="false" isAbstract="false" isQuery="false" name="~ FreebobPosixThread" /> 
     1681        <UML:Operation isSpecification="false" isLeaf="false" visibility="public" xmi.id="14019" isRoot="false" isAbstract="false" isQuery="false" name="~ FFADOPosixThread" /> 
    16821682        <UML:Operation isSpecification="false" isLeaf="false" visibility="public" xmi.id="14020" isRoot="false" isAbstract="false" isQuery="false" name="Start" > 
    16831683         <UML:BehavioralFeature.parameter> 
     
    17181718       </UML:Classifier.feature> 
    17191719      </UML:Class> 
    1720       <UML:Class isSpecification="false" isLeaf="false" visibility="public" namespace="1" xmi.id="13994" isRoot="false" isAbstract="false" name="FreebobThread" /> 
     1720      <UML:Class isSpecification="false" isLeaf="false" visibility="public" namespace="1" xmi.id="13994" isRoot="false" isAbstract="false" name="FFADOThread" /> 
    17211721      <UML:Class isSpecification="false" isLeaf="false" visibility="public" namespace="1" xmi.id="13998" isRoot="false" isAbstract="false" name="pthread_t" /> 
    17221722      <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="FreebobRunnableInterface" /> 
     1723      <UML:Class isSpecification="false" isLeaf="false" visibility="public" namespace="1" xmi.id="14008" isRoot="false" isAbstract="false" name="FFADORunnableInterface" /> 
    17241724      <UML:Class comment="Id$ *//* 
    1725   FreeBob Streaming API 
    1726   FreeBob = Firewire (pro-)audio for linux 
     1725  FFADO Streaming API 
     1726  FFADO = Firewire (pro-)audio for linux 
    17271727 
    1728   http://freebob.sf.net 
     1728  http://ffado.sf.net 
    17291729 
    17301730  Copyright (C) 2005,2006 Pieter Palmers &lt;pieterpalmers@users.sourceforge.net> 
     
    25542554      </UML:Class> 
    25552555      <UML:Class comment="Id$ *//* 
    2556   FreeBob Streaming API 
    2557   FreeBob = Firewire (pro-)audio for linux 
     2556  FFADO Streaming API 
     2557  FFADO = Firewire (pro-)audio for linux 
    25582558 
    2559   http://freebob.sf.net 
     2559  http://ffado.sf.net 
    25602560 
    25612561  Copyright (C) 2005,2006 Pieter Palmers &lt;pieterpalmers@users.sourceforge.net> 
     
    35563556         </UML:BehavioralFeature.parameter> 
    35573557        </UML:Operation> 
    3558         <UML:Operation comment="// FreebobRunnableInterface 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" > 
    35593559         <UML:BehavioralFeature.parameter> 
    35603560          <UML:Parameter kind="return" xmi.id="LlXy8i6aXj2o" type="12708" /> 
     
    36863686        </UML:Operation> 
    36873687        <UML:Operation isSpecification="false" isLeaf="false" visibility="public" xmi.id="14668" isRoot="false" isAbstract="false" isQuery="false" name="~ StreamRunner" /> 
    3688         <UML:Operation comment="// FreebobRunnableInterface 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" > 
    36893689         <UML:BehavioralFeature.parameter> 
    36903690          <UML:Parameter kind="return" xmi.id="9wZVdbzyKUvQ" type="12708" /> 
     
    36983698       </UML:Classifier.feature> 
    36993699      </UML:Class> 
    3700       <UML:Class stereotype="13989" isSpecification="false" isLeaf="false" visibility="public" namespace="1" xmi.id="15165" isRoot="false" isAbstract="false" name="freebob_ringbuffer_data_t" /> 
    3701       <UML:Class stereotype="13989" isSpecification="false" isLeaf="false" visibility="public" namespace="1" xmi.id="15166" isRoot="false" isAbstract="false" name="freebob_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" /> 
    37023702      <UML:Class comment="Id$ *//* 
    3703   FreeBob Streaming API 
    3704   FreeBob = Firewire (pro-)audio for linux 
     3703  FFADO Streaming API 
     3704  FFADO = Firewire (pro-)audio for linux 
    37053705 
    3706   http://freebob.sf.net 
     3706  http://ffado.sf.net 
    37073707 
    37083708  Copyright (C) 2005,2006 Pieter Palmers &lt;pieterpalmers@users.sourceforge.net> 
  • trunk/libffado/libffado.pc.in

    r442 r445  
    44includedir=@includedir@ 
    55 
    6 Name: libfreebob 
    7 Description: FreeBoB 
     6Name: libffado 
     7Description: FFADO 
    88Version: @VERSION@ 
    9 Libs: -L${libdir} -lfreebob 
     9Libs: -L${libdir} -lffado 
    1010Cflags: -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 
    32# 
    4 # This file is part of FreeBoB. 
     3# Copyright (C) 2005-2007 by Daniel Wagner. 
     4# Copyright (C) 2005-2007 by Pieter Palmers. 
    55# 
    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, 
    1122# but WITHOUT ANY WARRANTY; without even the implied warranty of 
    1223# 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 
    1628# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
    1729 
    18 SUBDIRS = libfreebob src tests doc 
     30SUBDIRS = libffado src tests doc 
    1931 
    2032pkgconfigdir = $(libdir)/pkgconfig 
    21 pkgconfig_DATA = libfreebob.pc 
     33pkgconfig_DATA = libffado.pc 
    2234 
    2335$(srcdir)/configure: configure.ac aclocal.m4 
     
    3951config.status: configure 
    4052        ./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, 
    1114 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    1215 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     
    1417 * 
    1518 * You should have received a copy of the GNU General Public License 
    16  * along with FreeBoB; if not, write to the Free Software 
     19 * along with FFADO; if not, write to the Free Software 
    1720 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
    1821 * MA 02111-1307 USA. 
     
    3033// arg parsing 
    3134//////////////////////////////////////////////// 
    32 const char *argp_program_version = "freebob_sync 0.1"; 
    33 const char *argp_program_bug_address = "<freebob-devel@lists.sf.net>"; 
    34 static char doc[] = "freebob_sync -- select sync mode\n\n" 
     35const char *argp_program_version = "bebob-sync 0.1"; 
     36const char *argp_program_bug_address = "<ffado-devel@lists.sf.net>"; 
     37static char doc[] = "bebob-sync -- select sync mode on a BeBoB device\n\n" 
    3538                    "OPERATION:  set <nr>\n"; 
    3639static char args_doc[] = "NODE_ID OPERATION"; 
     
    4144}; 
    4245 
    43 IMPL_GLOBAL_DEBUG_MODULE( freebob-sync, DebugModule::eDL_Normal ); 
     46// IMPL_GLOBAL_DEBUG_MODULE( bebob-sync, DebugModule::eDL_Normal ); 
     47DECLARE_GLOBAL_DEBUG_MODULE; 
    4448 
    4549struct arguments 
     
    118122    int node_id = strtol(arguments.args[0], &tail, 0); 
    119123    if (errno) { 
    120        perror("argument parsng failed:"); 
    121        return -1; 
     124    perror("argument parsng failed:"); 
     125    return -1; 
    122126    } 
    123127 
  • trunk/libffado/src/bebob/bebob_avdevice.cpp

    r436 r445  
    1 /* bebob_avdevice.cpp 
    2  * Copyright (C) 2005,06,07 by Daniel Wagner 
     1/* 
     2 * Copyright (C) 2005-2007 by Daniel Wagner 
    33 * 
    4  * This file is part of FreeBoB. 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    56 * 
    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, 
    1114 * 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. 
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     16 * Lesser General Public License for more details. 
    1417 * 
    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. 
     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 
    1922 */ 
    2023 
     
    4245{ 
    4346    {0x00000f, 0x00010065, "Mackie", "Onyx Firewire"}, 
    44      
     47 
    4548    {0x0003db, 0x00010048, "Apogee Electronics", "Rosetta 200"}, 
    4649 
     
    105108 
    106109void 
    107 AvDevice::setVerboseLevel(int l)  
     110AvDevice::setVerboseLevel(int l) 
    108111{ 
    109112//     m_pPlugManager->setVerboseLevel(l); 
    110      
     113 
    111114    IAvDevice::setVerboseLevel(l); 
    112115} 
     
    143146    { 
    144147        if ( ( supportedDeviceList[i].vendor_id == vendorId ) 
    145              && ( supportedDeviceList[i].model_id == modelId )  
     148             && ( supportedDeviceList[i].model_id == modelId ) 
    146149           ) 
    147150        { 
     
    155158                m_model->vendor_name, m_model->model_name); 
    156159    } else return false; 
    157      
     160 
    158161    if ( !enumerateSubUnits() ) { 
    159162        debugError( "Could not enumarate sub units\n" ); 
     
    709712        debugWarning("Could not retrieve snoopMode parameter, defauling to false\n"); 
    710713    } 
    711      
     714 
    712715    if(snoopMode) { 
    713716        int current_sr=getSamplingFrequency(); 
     
    724727            return false; 
    725728        } 
    726      
     729 
    727730        if ( !setSamplingFrequencyPlug( *plug, 
    728731                                        AvPlug::eAPD_Input, 
     
    732735            return false; 
    733736        } 
    734      
     737 
    735738        plug = getPlugById( m_pcrPlugs, AvPlug::eAPD_Output,  0 ); 
    736739        if ( !plug ) { 
     
    738741            return false; 
    739742        } 
    740      
     743 
    741744        if ( !setSamplingFrequencyPlug( *plug, 
    742745                                        AvPlug::eAPD_Output, 
     
    746749            return false; 
    747750        } 
    748      
     751 
    749752        debugOutput( DEBUG_LEVEL_VERBOSE, 
    750753                     "setSampleRate: Set sample rate to %d\n", 
     
    886889        "%s %s at node %d\n", m_model->vendor_name, m_model->model_name, 
    887890        m_nodeId); 
    888          
     891 
    889892    m_pPlugManager->showPlugs(); 
    890893} 
     
    946949        // don't lock 
    947950    } else { 
    948      
     951 
    949952    } 
    950953 
     
    962965        // don't unlock 
    963966    } else { 
    964      
     967 
    965968    } 
    966969    return true; 
     
    973976        debugWarning("Could not retrieve snoopMode parameter, defauling to false\n"); 
    974977    } 
    975      
     978 
    976979    /////////// 
    977980    // get plugs 
     
    989992 
    990993    int samplerate=outputPlug->getSampleRate(); 
    991      
     994 
    992995    debugOutput( DEBUG_LEVEL_VERBOSE, "Initializing receive processor...\n"); 
    993996    // create & add streamprocessors 
    994997    Streaming::StreamProcessor *p; 
    995      
     998 
    996999    p=new Streaming::AmdtpReceiveStreamProcessor( 
    9971000                             m_p1394Service->getPort(), 
     
    10111014        return false; 
    10121015    } 
    1013      
     1016 
    10141017    m_receiveProcessors.push_back(p); 
    10151018 
     
    10291032                                inputPlug->getNrOfChannels()); 
    10301033    } 
    1031      
     1034 
    10321035    if(!p->init()) { 
    10331036        debugFatal("Could not initialize transmit processor %s!\n", 
     
    10501053        } 
    10511054    } 
    1052      
     1055 
    10531056    // we put this SP into the transmit SP vector, 
    10541057    // no matter if we are in snoop mode or not 
     
    10651068    Streaming::StreamProcessor *processor, 
    10661069    Streaming::AmdtpAudioPort::E_Direction direction) { 
    1067      
     1070 
    10681071    std::string id=std::string("dev?"); 
    10691072    if(!getOption("id", id)) { 
    10701073        debugWarning("Could not retrieve id parameter, defauling to 'dev?'\n"); 
    10711074    } 
    1072      
     1075 
    10731076    AvPlug::ClusterInfoVector& clusterInfos = plug.getClusterInfos(); 
    10741077    for ( AvPlug::ClusterInfoVector::const_iterator it = clusterInfos.begin(); 
     
    11731176        int n=i; 
    11741177        Streaming::StreamProcessor *p=m_receiveProcessors.at(n); 
    1175          
     1178 
    11761179        if(snoopMode) { // a stream from the device to another host 
    11771180            // FIXME: put this into a decent framework! 
     
    11791182            struct iec61883_oPCR opcr; 
    11801183            if (iec61883_get_oPCRX( 
    1181                     m_p1394Service->getHandle(),  
     1184                    m_p1394Service->getHandle(), 
    11821185                    m_pConfigRom->getNodeId() | 0xffc0, 
    11831186                    (quadlet_t *)&opcr, 
    11841187                    n)) { 
    1185                      
     1188 
    11861189                debugWarning("Error getting the channel for SP %d\n",i); 
    11871190                return false; 
    11881191            } 
    1189              
     1192 
    11901193            iso_channel=opcr.channel; 
    11911194        } else { 
    11921195            iso_channel=m_p1394Service->allocateIsoChannelCMP( 
    1193                 m_pConfigRom->getNodeId() | 0xffc0, n,  
     1196                m_pConfigRom->getNodeId() | 0xffc0, n, 
    11941197                m_p1394Service->getLocalNodeId()| 0xffc0, -1); 
    11951198        } 
     
    11981201            return false; 
    11991202        } 
    1200          
     1203 
    12011204        debugOutput(DEBUG_LEVEL_VERBOSE, "Started SP %d on channel %d\n",i,iso_channel); 
    1202          
     1205 
    12031206        p->setChannel(iso_channel); 
    12041207        return true; 
    1205          
     1208 
    12061209    } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) { 
    12071210        int n=i-m_receiveProcessors.size(); 
    12081211        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 
    12111214            // FIXME: put this into a decent framework! 
    12121215            // we should check the iPCR[n] on the device 
    12131216            struct iec61883_iPCR ipcr; 
    12141217            if (iec61883_get_iPCRX( 
    1215                     m_p1394Service->getHandle(),  
     1218                    m_p1394Service->getHandle(), 
    12161219                    m_pConfigRom->getNodeId() | 0xffc0, 
    12171220                    (quadlet_t *)&ipcr, 
    12181221                    n)) { 
    1219                      
     1222 
    12201223                debugWarning("Error getting the channel for SP %d\n",i); 
    12211224                return false; 
    12221225            } 
    1223              
     1226 
    12241227            iso_channel=ipcr.channel; 
    1225              
     1228 
    12261229        } else { 
    12271230            iso_channel=m_p1394Service->allocateIsoChannelCMP( 
     
    12291232                m_pConfigRom->getNodeId() | 0xffc0, n); 
    12301233        } 
    1231          
     1234 
    12321235        if (iso_channel<0) { 
    12331236            debugError("Could not allocate ISO channel for SP %d\n",i); 
    12341237            return false; 
    12351238        } 
    1236          
     1239 
    12371240        debugOutput(DEBUG_LEVEL_VERBOSE, "Started SP %d on channel %d\n",i,iso_channel); 
    1238          
     1241 
    12391242        p->setChannel(iso_channel); 
    12401243        return true; 
    12411244    } 
    1242      
     1245 
    12431246    debugError("SP index %d out of range!\n",i); 
    12441247    return false; 
     
    12661269        } 
    12671270        p->setChannel(-1); 
    1268          
     1271 
    12691272        return true; 
    1270          
     1273 
    12711274    } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) { 
    12721275        int n=i-m_receiveProcessors.size(); 
    12731276        Streaming::StreamProcessor *p=m_transmitProcessors.at(n); 
    1274          
     1277 
    12751278        if(snoopMode) { 
    12761279 
     
    12831286        } 
    12841287        p->setChannel(-1); 
    1285          
     1288 
    12861289        return true; 
    12871290    } 
    1288      
     1291 
    12891292    debugError("SP index %d out of range!\n",i); 
    12901293    return false; 
     
    14141417                     Util::IOSerialize& ser ) const 
    14151418{ 
    1416      
     1419 
    14171420    bool result; 
    14181421    result  = m_pConfigRom->serialize( basePath + "m_pConfigRom/", ser ); 
     
    14351438        i++; 
    14361439    } 
    1437      
     1440 
    14381441    result &= serializeOptions( basePath + "Options", ser ); 
    14391442 
     
    14511454    ConfigRom *configRom = 
    14521455        ConfigRom::deserialize( basePath + "m_pConfigRom/", deser, ieee1394Service ); 
    1453          
     1456 
    14541457    if ( !configRom ) { 
    14551458        return NULL; 
     
    14571460 
    14581461    AvDevice* pDev = new AvDevice( 
    1459         std::auto_ptr<ConfigRom>(configRom),  
     1462        std::auto_ptr<ConfigRom>(configRom), 
    14601463        ieee1394Service, configRom->getNodeId()); 
    14611464 
     
    14631466        bool result; 
    14641467        result  = deser.read( basePath + "m_verboseLevel", pDev->m_verboseLevel ); 
    1465          
     1468 
    14661469        if (pDev->m_pPlugManager) delete pDev->m_pPlugManager; 
    14671470        pDev->m_pPlugManager = AvPlugManager::deserialize( basePath + "AvPlug", deser, *pDev ); 
     
    14841487            } 
    14851488        } 
    1486          
     1489 
    14871490        result &= deserializeOptions( basePath + "Options", deser, *pDev ); 
    14881491    } 
  • trunk/libffado/src/bebob/bebob_avdevice.h

    r436 r445  
    1 /* bebob_avdevice.h 
    2  * Copyright (C) 2005,06,07 by Daniel Wagner 
     1/* 
     2 * Copyright (C) 2005-2007 by Daniel Wagner 
    33 * 
    4  * This file is part of FreeBoB. 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    56 * 
    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, 
    1114 * 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. 
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     16 * Lesser General Public License for more details. 
    1417 * 
    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. 
     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 
    1922 */ 
     23 
    2024#ifndef BEBOB_AVDEVICE_H 
    2125#define BEBOB_AVDEVICE_H 
     
    5155    unsigned int model_id; 
    5256    char *vendor_name; 
    53     char *model_name;  
     57    char *model_name; 
    5458}; 
    5559 
     
    6064              int nodeId ); 
    6165    virtual ~AvDevice(); 
    62      
     66 
    6367    void setVerboseLevel(int l); 
    6468 
     
    115119    static AvDevice* deserialize( Glib::ustring basePath, 
    116120                                  Util::IODeserialize& deser, 
    117                                  Ieee1394Service& ieee1394Service ); 
     121                  Ieee1394Service& ieee1394Service ); 
    118122protected: 
    119123 
  • trunk/libffado/src/bebob/bebob_avdevice_subunit.cpp

    r420 r445  
    1 /* bebob_avdevice_subunit.cpp 
    2  * Copyright (C) 2005,06,07 by Daniel Wagner 
     1/* 
     2 * Copyright (C) 2005-2007 by Daniel Wagner 
    33 * 
    4  * This file is part of FreeBoB. 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    56 * 
    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, 
    1114 * 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. 
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     16 * Lesser General Public License for more details. 
    1417 * 
    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. 
     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 
    1922 */ 
    2023 
  • trunk/libffado/src/bebob/bebob_avdevice_subunit.h

    r420 r445  
    1 /* bebob_avdevice_subunit.h 
    2  * Copyright (C) 2005,06,07 by Daniel Wagner 
     1/* 
     2 * Copyright (C) 2005-2007 by Daniel Wagner 
    33 * 
    4  * This file is part of FreeBoB. 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    56 * 
    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, 
    1114 * 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. 
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     16 * Lesser General Public License for more details. 
    1417 * 
    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. 
     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 
    1922 */ 
     23 
    2024#ifndef BEBOB_AVDEVICESUBUNIT_H 
    2125#define BEBOB_AVDEVICESUBUNIT_H 
     
    3842 public: 
    3943    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 ); 
    4347    virtual ~AvDeviceSubunit(); 
    4448 
     
    5054 
    5155    subunit_t getSubunitId() 
    52        { return m_sbId; } 
     56    { return m_sbId; } 
    5357    AVCCommand::ESubunitType getSubunitType() 
    54        { return m_sbType; } 
     58    { return m_sbType; } 
    5559 
    5660    AvPlugVector& getPlugs() 
    57        { return m_plugs; } 
     61    { return m_plugs; } 
    5862    AvPlug* getPlug(AvPlug::EAvPlugDirection direction, plug_id_t plugId); 
    5963 
     
    6569    bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; 
    6670    static AvDeviceSubunit* deserialize( Glib::ustring basePath, 
    67                                         Util::IODeserialize& deser, 
     71                    Util::IODeserialize& deser, 
    6872                                         AvDevice& avDevice ); 
    6973 protected: 
     
    98102 public: 
    99103    AvDeviceSubunitAudio( AvDevice& avDevice, 
    100                          subunit_t id, 
    101                          int verboseLevel ); 
     104              subunit_t id, 
     105              int verboseLevel ); 
    102106    AvDeviceSubunitAudio(); 
    103107    virtual ~AvDeviceSubunitAudio(); 
     
    135139 public: 
    136140    AvDeviceSubunitMusic( AvDevice& avDevice, 
    137                          subunit_t id, 
    138                          int verboseLevel ); 
     141              subunit_t id, 
     142              int verboseLevel ); 
    139143    AvDeviceSubunitMusic(); 
    140144    virtual ~AvDeviceSubunitMusic(); 
  • trunk/libffado/src/bebob/bebob_avplug.cpp

    r420 r445  
    1 /* bebob_avplug.cpp 
    2  * Copyright (C) 2005,06,07 by Daniel Wagner 
     1/* 
     2 * Copyright (C) 2005-2007 by Daniel Wagner 
    33 * 
    4  * This file is part of FreeBoB. 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    56 * 
    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, 
    1114 * 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. 
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     16 * Lesser General Public License for more details. 
    1417 * 
    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. 
     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 
    1922 */ 
    2023 
  • 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, 
    1114 * 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. 
     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 
    1922 */ 
    2023 
     
    5053 
    5154    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, 
    5861    }; 
    5962 
     
    6972 
    7073    enum EAvPlugDirection { 
    71        eAPD_Input, 
    72        eAPD_Output, 
    73        eAPD_Unknown, 
     74    eAPD_Input, 
     75    eAPD_Output, 
     76    eAPD_Unknown, 
    7477    }; 
    7578 
    7679    // \todo This constructors sucks. too many parameters. fix it. 
    7780    AvPlug( Ieee1394Service& ieee1394Service, 
    78            ConfigRom& configRom, 
     81        ConfigRom& configRom, 
    7982            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 ); 
    8891    AvPlug( const AvPlug& rhs ); 
    8992    virtual ~AvPlug(); 
     
    9699 
    97100    int getGlobalId() const 
    98        { return m_globalId; } 
     101        { return m_globalId; } 
    99102    plug_id_t getPlugId() const 
    100        { return m_id; } 
     103        { return m_id; } 
    101104    AVCCommand::ESubunitType getSubunitType() const 
    102        { return m_subunitType; } 
     105        { return m_subunitType; } 
    103106    subunit_id_t getSubunitId() const 
    104        { return m_subunitId; } 
     107        { return m_subunitId; } 
    105108    const char* getName() const 
    106        { return m_name.c_str(); } 
     109        { return m_name.c_str(); } 
    107110    EAvPlugDirection getPlugDirection() const 
    108        { return m_direction; } 
     111        { return m_direction; } 
    109112    sampling_frequency_t getSamplingFrequency() const 
    110        { return m_samplingFrequency; } 
     113        { return m_samplingFrequency; } 
    111114    int getSampleRate() const; // 22050, 24000, 32000, ... 
    112115    int getNrOfChannels() const; 
     
    118121        { return m_addressType; } 
    119122    EAvPlugType getPlugType() const 
    120        { return m_infoPlugType; } 
     123        { return m_infoPlugType; } 
    121124 
    122125    function_block_type_t getFunctionBlockType() const 
    123        { return m_functionBlockType; } 
     126        { return m_functionBlockType; } 
    124127    function_block_id_t getFunctionBlockId() const 
    125128        { return m_functionBlockId; } 
     
    131134 
    132135    static PlugAddress::EPlugDirection convertPlugDirection( 
    133        EAvPlugDirection direction); 
     136    EAvPlugDirection direction); 
    134137 
    135138    void showPlug() const; 
     
    148151        stream_position_t          m_streamPosition; 
    149152        stream_position_location_t m_location; 
    150        Glib::ustring              m_name; 
     153    Glib::ustring              m_name; 
    151154    }; 
    152155    typedef std::vector<ChannelInfo> ChannelInfoVector; 
    153156 
    154157    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; 
    158161 
    159162        nr_of_channels_t         m_nrOfChannels; 
    160163        ChannelInfoVector        m_channelInfos; 
    161        stream_format_t          m_streamFormat; 
     164    stream_format_t          m_streamFormat; 
    162165    }; 
    163166    typedef std::vector<ClusterInfo> ClusterInfoVector; 
     
    183186 
    184187    ExtendedStreamFormatCmd setPlugAddrToStreamFormatCmd( 
    185        ExtendedStreamFormatCmd::ESubFunction subFunction); 
     188    ExtendedStreamFormatCmd::ESubFunction subFunction); 
    186189 
    187190    SignalSourceCmd setSrcPlugAddrToSignalCmd(); 
    188191 
    189192    void setDestPlugAddrToSignalCmd( 
    190        SignalSourceCmd& signalSourceCmd, AvPlug& plug ); 
     193    SignalSourceCmd& signalSourceCmd, AvPlug& plug ); 
    191194 
    192195    void debugOutputClusterInfos( int debugLevel ); 
     
    245248            , m_index( 0xff ) 
    246249            {} 
    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; 
    252255    }; 
    253256    typedef std::vector<FormatInfo> FormatInfoVector; 
     
    297300    AvPlug* getPlug( AVCCommand::ESubunitType subunitType, 
    298301                     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, 
    301304                     AvPlug::EAvPlugAddressType plugAddressType, 
    302305                     AvPlug::EAvPlugDirection plugDirection, 
     
    304307    AvPlug* getPlug( int iGlobalId ) const; 
    305308    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; 
    312315 
    313316    bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; 
     
    351354} 
    352355 
    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, 
    1114 * 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. 
     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 
    1922 */ 
    2023 
  • trunk/libffado/src/bebob/bebob_dl_bcd.h

    r407 r445  
    1 /* bebob_dl_bcd.h 
    2  * Copyright (C) 2006 by Daniel Wagner 
     1/* 
     2 * Copyright (C) 2005-2007 by Daniel Wagner 
    33 * 
    4  * This file is part of FreeBoB. 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    56 * 
    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, 
    1114 * 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. 
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     16 * Lesser General Public License for more details. 
    1417 * 
    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. 
     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 
    1922 */ 
     23 
    2024#ifndef BEBOB_DL_BCD_H 
    2125#define BEBOB_DL_BCD_H 
     
    4549        fb_quadlet_t getSoftwareVersion() const 
    4650            { return m_softwareVersion; } 
    47        fb_quadlet_t getHardwareId() const 
    48            { return m_hardwareId; } 
    49        fb_quadlet_t getVendorOUI() const 
    50            { 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 
    5256        fb_quadlet_t getImageBaseAddress() const 
    5357            { return m_imageBaseAddress; } 
     
    5963            { return m_imageCRC; } 
    6064 
    61        fb_quadlet_t getCnEOffset() const 
    62            { return m_cneOffset; } 
     65    fb_quadlet_t getCnEOffset() const 
     66        { return m_cneOffset; } 
    6367        fb_quadlet_t getCnELength() const 
    6468            { return m_cneLength; } 
    65        fb_quadlet_t getCnECRC() const 
    66            { return m_cneCRC; } 
     69    fb_quadlet_t getCnECRC() const 
     70        { return m_cneCRC; } 
    6771 
    6872        bool read( int addr, fb_quadlet_t* q ); 
    6973        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 ); 
    7175 
    72        void displayInfo(); 
     76    void displayInfo(); 
    7377 
    7478    protected: 
    7579        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); 
    7983        bool checkHeaderCRC( unsigned int crcOffset, 
    8084                             unsigned int headerSize ); 
     
    8993        fb_quadlet_t m_softwareId; 
    9094        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 
    9498 
    9599        fb_quadlet_t m_imageBaseAddress; 
     
    99103 
    100104        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; 
    103107 
    104108 
    105109 
    106        DECLARE_DEBUG_MODULE; 
     110    DECLARE_DEBUG_MODULE; 
    107111    }; 
    108112 
  • 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, 
    1114 * 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. 
     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 
    1922 */ 
     23 
    2024#include "bebob/bebob_dl_codes.h" 
    2125#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, 
    1114 * 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. 
     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 
    1922 */ 
    2023 
     
    6467                      fb_byte_t operandSizeRequestField, 
    6568                      fb_byte_t operandSizeResponseField ); 
    66        virtual ~CommandCodes(); 
     69    virtual ~CommandCodes(); 
    6770 
    6871        virtual bool serialize( IOSSerialize& se ); 
     
    7477            { return static_cast<EBootloaderCommandCodes>( m_commandCode ); } 
    7578 
    76        fb_byte_t getProtocolVersion() const 
    77            { return m_protocolVersion; } 
     79    fb_byte_t getProtocolVersion() const 
     80        { return m_protocolVersion; } 
    7881        size_t getMsgSize() const 
    7982            { return m_msgSize; } 
     
    163166        enum EObject { 
    164167            eO_Application    = 0, 
    165            eO_Config         = 1, 
    166            eO_Debugger       = 2, 
     168        eO_Config         = 1, 
     169        eO_Debugger       = 2, 
    167170            eO_Bootloader     = 3, 
    168            eO_WarpImage      = 4, 
    169            eO_SerialBootCode = 5, 
     171        eO_WarpImage      = 4, 
     172        eO_SerialBootCode = 5, 
    170173        }; 
    171174 
    172175        CommandCodesDownloadStart( fb_quadlet_t protocolVersion, 
    173                                     EObject object ); 
     176                     EObject object ); 
    174177        virtual ~CommandCodesDownloadStart(); 
    175178 
     
    218221        virtual bool deserialize( IISDeserialize& de ); 
    219222 
    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 ) 
    223226            { m_address = address; return true; } 
    224227        bool setNumberBytes( fb_quadlet_t numByte ) 
     
    233236        fb_quadlet_t m_numBytes; 
    234237 
    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; 
    237240    }; 
    238241 
     
    287290        enum EStartMode { 
    288291            eSM_Application = 0, 
    289            eSM_Debugger = 2, 
     292        eSM_Debugger = 2, 
    290293        }; 
    291294 
     
    306309    private: 
    307310        fb_quadlet_t m_startMode; 
    308        fb_quadlet_t m_resp_validCRC; 
     311    fb_quadlet_t m_resp_validCRC; 
    309312    }; 
    310313 
  • trunk/libffado/src/bebob/bebob_dl_mgr.cpp

    r420 r445  
    1 /* bebob_dl_mgr.cpp 
    2  * Copyright (C) 2006 by Daniel Wagner 
     1/* 
     2 * Copyright (C) 2005-2007 by Daniel Wagner 
    33 * 
    4  * This file is part of FreeBoB. 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    56 * 
    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, 
    1114 * 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. 
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     16 * Lesser General Public License for more details. 
    1417 * 
    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. 
     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 
    1922 */ 
     23 
    2024#include "bebob_dl_mgr.h" 
    2125#include "bebob_dl_codes.h" 
  • trunk/libffado/src/bebob/bebob_dl_mgr.h

    r407 r445  
    1 /* bebob_dl_mgr.h 
    2  * Copyright (C) 2006 by Daniel Wagner 
     1/* 
     2 * Copyright (C) 2005-2007 by Daniel Wagner 
    33 * 
    4  * This file is part of FreeBoB. 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    56 * 
    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, 
    1114 * 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. 
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     16 * Lesser General Public License for more details. 
    1417 * 
    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. 
     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 
    1922 */ 
     23 
    2024#ifndef BEBOB_DL_MGR_H 
    2125#define BEBOB_DL_MGR_H 
     
    5155        bool programGUID( octlet_t guid ); 
    5256 
    53        void busresetHandler(); 
     57    void busresetHandler(); 
    5458 
    55        Ieee1394Service* get1394Serivce() const 
     59    Ieee1394Service* get1394Serivce() const 
    5660            { return m_ieee1394service; } 
    5761 
    58        bool setForceOperations( bool enabled ) 
     62    bool setForceOperations( bool enabled ) 
    5963            { m_forceEnabled = enabled; return true; } 
    6064 
    61        bool setStartBootloader( bool bStartBootloader ) 
    62            { m_bStartBootloader = bStartBootloader; return true; } 
     65    bool setStartBootloader( bool bStartBootloader ) 
     66        { m_bStartBootloader = bStartBootloader; return true; } 
    6367    protected: 
    64        enum EObjectType { 
    65            eOT_Application, 
    66            eOT_CnE 
    67        }; 
     68    enum EObjectType { 
     69        eOT_Application, 
     70        eOT_CnE 
     71    }; 
    6872 
    69        void waitForBusReset(); 
     73    void waitForBusReset(); 
    7074        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 ); 
    7377 
    7478        bool programGUIDCmd( octlet_t guid ); 
    75        bool startBootloaderCmd(); 
     79    bool startBootloaderCmd(); 
    7680        bool startApplicationCmd(); 
    7781        bool initializePersParamCmd(); 
     
    111115        info_register_t    m_cachedInfoRegs; 
    112116 
    113        pthread_mutex_t m_mutex; 
    114        pthread_cond_t  m_cond; 
     117    pthread_mutex_t m_mutex; 
     118    pthread_cond_t  m_cond; 
    115119 
    116        Functor*        m_functor; 
     120    Functor*        m_functor; 
    117121 
    118122        bool            m_forceEnabled; 
    119        bool            m_bStartBootloader; 
     123    bool            m_bStartBootloader; 
    120124 
    121        DECLARE_DEBUG_MODULE; 
     125    DECLARE_DEBUG_MODULE; 
    122126    }; 
    123127} 
  • trunk/libffado/src/bebob/bebob_functionblock.cpp

    r413 r445  
    1 /* bebob_functionblock.cpp 
    2  * Copyright (C) 2006,07 by Daniel Wagner 
     1/* 
     2 * Copyright (C) 2005-2007 by Daniel Wagner 
    33 * 
    4  * This file is part of FreeBoB. 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    56 * 
    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, 
    1114 * 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. 
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     16 * Lesser General Public License for more details. 
    1417 * 
    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. 
     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 
    1922 */ 
     23 
    2024#include "bebob/bebob_functionblock.h" 
    2125#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, 
    1114 * 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. 
     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 
    1922 */ 
     23 
    2024#ifndef BEBOB_FUNCTION_BLOCK_H 
    2125#define BEBOB_FUNCTION_BLOCK_H 
     
    4751 
    4852    FunctionBlock( AvDeviceSubunit& subunit, 
    49                   function_block_type_t type, 
     53           function_block_type_t type, 
    5054                   function_block_type_t subtype, 
    5155                   function_block_id_t id, 
     
    6569    bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; 
    6670    static FunctionBlock* deserialize( Glib::ustring basePath, 
    67                                       Util::IODeserialize& deser, 
    68                                       AvDevice& avDevice, 
     71                       Util::IODeserialize& deser, 
     72                       AvDevice& avDevice, 
    6973                                       AvDeviceSubunit& subunit); 
    7074protected: 
  • trunk/libffado/src/bounce/bounce_avdevice.cpp

    r436 r445  
    1 /* bounce_avdevice.cpp 
    2  * Copyright (C) 2006 by Pieter Palmers 
    3  * Copyright (C) 2006 by Daniel Wagner 
     1/* 
     2 * Copyright (C) 2005-2007 by Pieter Palmers 
     3 * Copyright (C) 2005-2007 by Daniel Wagner 
    44 * 
    5  * This file is part of FreeBoB. 
     5 * This file is part of FFADO 
     6 * FFADO = Free Firewire (pro-)audio drivers for linux 
    67 * 
    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, 
    1215 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    14  * GNU General Public License for more details. 
     16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     17 * Lesser General Public License for more details. 
    1518 * 
    16  * You should have received a copy of the GNU General Public License 
    17  * along with FreeBoB; if not, write to the Free Software 
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
    19  * MA 02111-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 
    2023 */ 
     24 
    2125#include "bounce/bounce_avdevice.h" 
    2226 
     
    4549static VendorModelEntry supportedDeviceList[] = 
    4650{ 
    47     {0x0B0001LU, 0x0B0001LU, 0x0B0001LU, "FreeBoB", "Bounce"}, 
     51    {0x0B0001LU, 0x0B0001LU, 0x0B0001LU, "FFADO", "Bounce"}, 
    4852}; 
    4953 
     
    8084          ++i ) 
    8185    { 
    82         if (  
     86        if ( 
    8387//             ( supportedDeviceList[i].vendor_id == vendorId ) 
    8488             ( supportedDeviceList[i].model_id == modelId ) 
    85              && ( supportedDeviceList[i].unit_specifier_id == unitSpecifierId )  
     89             && ( supportedDeviceList[i].unit_specifier_id == unitSpecifierId ) 
    8690           ) 
    8791        { 
     
    98102    debugOutput( DEBUG_LEVEL_VERBOSE, "discovering BounceDevice (NodeID %d)\n", 
    99103                 m_nodeId ); 
    100                   
     104 
    101105//     unsigned int vendorId = m_pConfigRom->getNodeVendorId(); 
    102106    unsigned int modelId = m_pConfigRom->getModelId(); 
     
    108112    { 
    109113        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 ) 
    112116           ) 
    113117        { 
     
    168172 
    169173    debugOutput(DEBUG_LEVEL_VERBOSE,"Adding ports to processor\n"); 
    170      
     174 
    171175    std::string id=std::string("dev?"); 
    172176    if(!getOption("id", id)) { 
    173177        debugWarning("Could not retrieve id parameter, defauling to 'dev?'\n"); 
    174178    } 
    175      
     179 
    176180    int i=0; 
    177181    for (i=0;i<BOUNCE_NB_AUDIO_CHANNELS;i++) { 
     
    205209        free(buff); 
    206210    } 
    207      
     211 
    208212    for (i=0;i<BOUNCE_NB_MIDI_CHANNELS;i++) { 
    209213        char *buff; 
     
    237241     } 
    238242 
    239        return true; 
     243    return true; 
    240244} 
    241245 
     
    243247BounceDevice::prepare() { 
    244248    debugOutput(DEBUG_LEVEL_NORMAL, "Preparing BounceDevice...\n" ); 
    245      
     249 
    246250    bool snoopMode=false; 
    247251    if(!getOption("snoopMode", snoopMode)) { 
     
    251255    // create & add streamprocessors 
    252256    Streaming::StreamProcessor *p; 
    253      
     257 
    254258    p=new Streaming::AmdtpReceiveStreamProcessor( 
    255259                             m_p1394Service->getPort(), 
     
    285289                                BOUNCE_NB_AUDIO_CHANNELS+(BOUNCE_NB_MIDI_CHANNELS?1:0)); 
    286290    } 
    287      
     291 
    288292    if(!p->init()) { 
    289293        debugFatal("Could not initialize transmit processor %s!\n", 
     
    335339        int n=i; 
    336340        Streaming::StreamProcessor *p=m_receiveProcessors.at(n); 
    337          
     341 
    338342        // allocate ISO channel 
    339343        int isochannel=allocateIsoChannel(p->getMaxPacketSize()); 
     
    343347        } 
    344348        p->setChannel(isochannel); 
    345          
     349 
    346350        fb_quadlet_t reg_isoch; 
    347351        // check value of ISO_CHANNEL register 
     
    358362            return false; 
    359363        } 
    360          
     364 
    361365        // write value of ISO_CHANNEL register 
    362366        reg_isoch=isochannel; 
     
    367371            return false; 
    368372        } 
    369          
     373 
    370374        return true; 
    371          
     375 
    372376    } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) { 
    373377        int n=i-m_receiveProcessors.size(); 
    374378        Streaming::StreamProcessor *p=m_transmitProcessors.at(n); 
    375          
     379 
    376380        // allocate ISO channel 
    377381        int isochannel=allocateIsoChannel(p->getMaxPacketSize()); 
     
    381385        } 
    382386        p->setChannel(isochannel); 
    383          
     387 
    384388        fb_quadlet_t reg_isoch; 
    385389        // check value of ISO_CHANNEL register 
     
    396400            return false; 
    397401        } 
    398          
     402 
    399403        // write value of ISO_CHANNEL register 
    400404        reg_isoch=isochannel; 
     
    405409            return false; 
    406410        } 
    407          
     411 
    408412        return true; 
    409413    } 
    410      
     414 
    411415    debugError("SP index %d out of range!\n",i); 
    412      
     416 
    413417    return false; 
    414418} 
     
    420424        Streaming::StreamProcessor *p=m_receiveProcessors.at(n); 
    421425        unsigned int isochannel=p->getChannel(); 
    422          
     426 
    423427        fb_quadlet_t reg_isoch; 
    424428        // check value of ISO_CHANNEL register 
     
    431435            return false; 
    432436        } 
    433          
     437 
    434438        // write value of ISO_CHANNEL register 
    435439        reg_isoch=0xFFFFFFFFUL; 
     
    438442            return false; 
    439443        } 
    440          
     444 
    441445        // deallocate ISO channel 
    442446        if(!deallocateIsoChannel(isochannel)) { 
     
    444448            return false; 
    445449        } 
    446          
     450 
    447451        p->setChannel(-1); 
    448452        return true; 
    449          
     453 
    450454    } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) { 
    451455        int n=i-m_receiveProcessors.size(); 
    452456        Streaming::StreamProcessor *p=m_transmitProcessors.at(n); 
    453          
     457 
    454458        unsigned int isochannel=p->getChannel(); 
    455          
     459 
    456460        fb_quadlet_t reg_isoch; 
    457461        // check value of ISO_CHANNEL register 
     
    464468            return false; 
    465469        } 
    466          
     470 
    467471        // write value of ISO_CHANNEL register 
    468472        reg_isoch=0xFFFFFFFFUL; 
     
    471475            return false; 
    472476        } 
    473          
     477 
    474478        // deallocate ISO channel 
    475479        if(!deallocateIsoChannel(isochannel)) { 
     
    477481            return false; 
    478482        } 
    479          
     483 
    480484        p->setChannel(-1); 
    481485        return true; 
    482486    } 
    483      
     487 
    484488    debugError("SP index %d out of range!\n",i); 
    485489    return false; 
     
    491495int BounceDevice::allocateIsoChannel(unsigned int packet_size) { 
    492496    unsigned int bandwidth=8+packet_size; 
    493      
     497 
    494498    int ch=m_p1394Service->allocateIsoChannelGeneric(bandwidth); 
    495          
     499 
    496500    debugOutput(DEBUG_LEVEL_VERBOSE, "allocated channel %d, bandwidth %d\n", 
    497501        ch, bandwidth); 
    498      
     502 
    499503    return ch; 
    500504} 
     
    510514BounceDevice::readReg(fb_nodeaddr_t offset, fb_quadlet_t *result) { 
    511515    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading base register offset 0x%08llX\n", offset); 
    512      
     516 
    513517    if(offset >= BOUNCE_INVALID_OFFSET) { 
    514518        debugError("invalid offset: 0x%016llX\n", offset); 
    515519        return false; 
    516520    } 
    517      
     521 
    518522    fb_nodeaddr_t addr=BOUNCE_REGISTER_BASE + offset; 
    519523    fb_nodeid_t nodeId=m_nodeId | 0xFFC0; 
    520      
     524 
    521525    if(!m_p1394Service->read_quadlet( nodeId, addr, result ) ) { 
    522526        debugError("Could not read from node 0x%04X addr 0x%012X\n", nodeId, addr); 
     
    524528    } 
    525529    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Read result: 0x%08X\n", *result); 
    526     
     530 
    527531    return true; 
    528532} 
     
    530534bool 
    531535BounceDevice::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", 
    533537        offset, data); 
    534      
     538 
    535539    if(offset >= BOUNCE_INVALID_OFFSET) { 
    536540        debugError("invalid offset: 0x%016llX\n", offset); 
    537541        return false; 
    538542    } 
    539      
     543 
    540544    fb_nodeaddr_t addr=BOUNCE_REGISTER_BASE + offset; 
    541545    fb_nodeid_t nodeId=m_nodeId | 0xFFC0; 
    542      
     546 
    543547    if(!m_p1394Service->write_quadlet( nodeId, addr, data ) ) { 
    544548        debugError("Could not write to node 0x%04X addr 0x%012X\n", nodeId, addr); 
     
    548552} 
    549553 
    550 bool  
     554bool 
    551555BounceDevice::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", 
    553557        offset, length); 
    554      
     558 
    555559    if(offset >= BOUNCE_INVALID_OFFSET) { 
    556560        debugError("invalid offset: 0x%016llX\n", offset); 
    557561        return false; 
    558562    } 
    559      
     563 
    560564    fb_nodeaddr_t addr=BOUNCE_REGISTER_BASE + offset; 
    561565    fb_nodeid_t nodeId=m_nodeId | 0xFFC0; 
    562      
     566 
    563567    if(!m_p1394Service->read( nodeId, addr, length, data ) ) { 
    564568        debugError("Could not read from node 0x%04X addr 0x%012llX\n", nodeId, addr); 
     
    568572} 
    569573 
    570 bool  
     574bool 
    571575BounceDevice::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", 
    573577        offset, length); 
    574      
     578 
    575579    if(offset >= BOUNCE_INVALID_OFFSET) { 
    576580        debugError("invalid offset: 0x%016llX\n", offset); 
    577581        return false; 
    578582    } 
    579      
     583 
    580584    fb_nodeaddr_t addr=BOUNCE_REGISTER_BASE + offset; 
    581585    fb_nodeid_t nodeId=m_nodeId | 0xFFC0; 
  • trunk/libffado/src/bounce/bounce_avdevice.h

    r436 r445  
    1 /* bounce_avdevice.h 
    2  * Copyright (C) 2006 by Pieter Palmers 
    3  * Copyright (C) 2006 by Daniel Wagner 
     1/* 
     2 * Copyright (C) 2005-2007 by Pieter Palmers 
     3 * Copyright (C) 2005-2007 by Daniel Wagner 
    44 * 
    5  * This file is part of FreeBoB. 
     5 * This file is part of FFADO 
     6 * FFADO = Free Firewire (pro-)audio drivers for linux 
    67 * 
    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, 
    1215 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    14  * GNU General Public License for more details. 
     16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     17 * Lesser General Public License for more details. 
    1518 * 
    16  * You should have received a copy of the GNU General Public License 
    17  * along with FreeBoB; if not, write to the Free Software 
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
    19  * MA 02111-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 
    2023 */ 
     24 
    2125#ifndef BOUNCEDEVICE_H 
    2226#define BOUNCEDEVICE_H 
     
    6670public: 
    6771    BounceDevice( std::auto_ptr<ConfigRom>( configRom ), 
    68                  Ieee1394Service& ieee1394Service, 
    69                  int nodeId ); 
     72          Ieee1394Service& ieee1394Service, 
     73          int nodeId ); 
    7074    virtual ~BounceDevice(); 
    7175 
    7276    static bool probe( ConfigRom& configRom ); 
    7377    bool discover(); 
    74      
     78 
    7579    bool setSamplingFrequency( ESamplingFrequency samplingFrequency ); 
    7680    int getSamplingFrequency( ); 
    77      
     81 
    7882    bool prepare(); 
    7983    bool lock(); 
     
    8690    bool startStreamByIndex(int i); 
    8791    bool stopStreamByIndex(int i); 
    88      
     92 
    8993    void showDevice(); 
    9094 
     
    99103 
    100104    bool addPortsToProcessor( 
    101        Streaming::StreamProcessor *processor,  
     105       Streaming::StreamProcessor *processor, 
    102106       Streaming::Port::E_Direction direction); 
    103      
     107 
    104108private: // generic helpers 
    105109    int allocateIsoChannel(unsigned int packet_size); 
     
    112116    bool readRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t); 
    113117    bool writeRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t); 
    114      
     118 
    115119private: 
    116120    BounceNotifier *m_Notifier; 
    117121    /** 
    118      * this class reacts on the other side writing to the  
     122     * this class reacts on the other side writing to the 
    119123     * hosts address space 
    120124     */ 
     
    126130        BounceNotifier(BounceDevice *, nodeaddr_t start); 
    127131        virtual ~BounceNotifier(); 
    128          
     132 
    129133    private: 
    130134        BounceDevice *m_bouncedevice; 
  • trunk/libffado/src/bounce/bounce_slave_avdevice.cpp

    r435 r445  
    1 /* $Id$ */ 
    2  
    31/* 
    4  *   FreeBob Streaming API 
    5  *   FreeBob = Firewire (pro-)audio for linux 
     2 * Copyright (C) 2005-2007 by Pieter Palmers 
     3 * Copyright (C) 2005-2007 by Daniel Wagner 
    64 * 
    7  *   http://freebob.sf.net 
     5 * This file is part of FFADO 
     6 * FFADO = Free Firewire (pro-)audio drivers for linux 
    87 * 
    9  *   Copyright (C) 2007 Pieter Palmers <pieterpalmers@users.sourceforge.net> 
     8 * FFADO is based upon FreeBoB 
    109 * 
    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; 
    1513 * 
    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. 
     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. 
    2018 * 
    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 
    2723 */ 
    2824 
     
    4238{ 
    4339  //{vendor_id, model_id, unit_specifier_id, vendor_name, model_name}, 
    44     {0x0B0001, 0x0B0001, 0x0B0001, "FreeBoB", "Bounce Slave"}, 
     40    {0x0B0001, 0x0B0001, 0x0B0001, "FFADO", "Bounce Slave"}, 
    4541}; 
    4642 
     
    8076    debugOutput(DEBUG_LEVEL_VERBOSE, "Initializing memory space...\n"); 
    8177    fb_quadlet_t result=0xFFFFFFFFLU; 
    82      
     78 
    8379    // initialize the ISO channel registers 
    8480    // this will write to our own registers 
     
    9187        return false; 
    9288    } 
    93      
     89 
    9490    // set everything such that we can be discovered 
    9591    m_original_config_rom=save_config_rom( m_p1394Service->getHandle() ); 
    96      
     92 
    9793    if ( init_config_rom( m_p1394Service->getHandle() ) < 0 ) { 
    9894        debugError("Could not initalize local config rom\n"); 
    9995        return false; 
    10096    } 
    101      
     97 
    10298    // refresh our config rom cache 
    10399    if ( !m_pConfigRom->initialize() ) { 
     
    122118bool 
    123119BounceSlaveDevice::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", 
    125121        m_model->vendor_name, m_model->model_name, m_nodeId); 
    126      
     122 
    127123    // get a notifier to handle device notifications 
    128124    nodeaddr_t notify_address; 
     
    131127                        BOUNCE_REGISTER_LENGTH, 
    132128                        BOUNCE_REGISTER_LENGTH); 
    133      
     129 
    134130    if (notify_address == 0xFFFFFFFFFFFFFFFFLLU) { 
    135131        debugError("Could not find free ARM block for notification\n"); 
    136132        return false; 
    137133    } 
    138      
     134 
    139135    m_Notifier=new BounceSlaveDevice::BounceSlaveNotifier(this, notify_address); 
    140      
     136 
    141137    if(!m_Notifier) { 
    142138        debugError("Could not allocate notifier\n"); 
    143139        return false; 
    144140    } 
    145      
     141 
    146142    if (!m_p1394Service->registerARMHandler(m_Notifier)) { 
    147143        debugError("Could not register notifier\n"); 
     
    150146        return false; 
    151147    } 
    152      
     148 
    153149    // (re)initialize the memory space 
    154150    if (!initMemSpace()) { 
     
    156152        return false; 
    157153    } 
    158      
     154 
    159155    return true; 
    160156} 
     
    177173BounceSlaveDevice::prepare() { 
    178174    debugOutput(DEBUG_LEVEL_NORMAL, "Preparing BounceSlaveDevice...\n" ); 
    179      
     175 
    180176    // create & add streamprocessors 
    181177    Streaming::StreamProcessor *p; 
    182      
     178 
    183179    p=new Streaming::AmdtpSlaveReceiveStreamProcessor( 
    184180                             m_p1394Service->getPort(), 
     
    206202                                m_samplerate, 
    207203                                BOUNCE_NB_AUDIO_CHANNELS); 
    208      
     204 
    209205    if(!p->init()) { 
    210206        debugFatal("Could not initialize transmit processor!\n"); 
     
    227223bool 
    228224BounceSlaveDevice::startStreamByIndex(int i) { 
    229      
     225 
    230226    if (i<(int)m_receiveProcessors.size()) { 
    231227        int n=i; 
    232228        Streaming::StreamProcessor *p=m_receiveProcessors.at(n); 
    233          
     229 
    234230        // the other side sends on this channel 
    235231        nodeaddr_t iso_channel_offset = BOUNCE_REGISTER_RX_ISOCHANNEL; 
    236232        iso_channel_offset += ((unsigned)n)*4; 
    237          
     233 
    238234        if (!waitForRegisterNotEqualTo(iso_channel_offset, 0xFFFFFFFFLU)) { 
    239235            debugError("Timeout waiting for stream %d to get an ISO channel\n",i); 
    240236            return false; 
    241237        } 
    242          
     238 
    243239        fb_quadlet_t result; 
    244240        // this will read from our own registers 
     
    247243            return false; 
    248244        } 
    249          
     245 
    250246        // set ISO channel 
    251247        p->setChannel(result); 
    252248 
    253249        return true; 
    254          
     250 
    255251    } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) { 
    256252        int n=i-m_receiveProcessors.size(); 
    257253        Streaming::StreamProcessor *p=m_transmitProcessors.at(n); 
    258          
     254 
    259255        // the other side sends on this channel 
    260256        nodeaddr_t iso_channel_offset = BOUNCE_REGISTER_TX_ISOCHANNEL; 
    261257        iso_channel_offset += ((unsigned)n)*4; 
    262          
     258 
    263259        if (!waitForRegisterNotEqualTo(iso_channel_offset, 0xFFFFFFFF)) { 
    264260            debugError("Timeout waiting for stream %d to get an ISO channel\n",i); 
    265261            return false; 
    266262        } 
    267          
     263 
    268264        fb_quadlet_t result; 
    269265        // this will read from our own registers 
     
    272268            return false; 
    273269        } 
    274          
     270 
    275271        // set ISO channel 
    276272        p->setChannel(result); 
     
    279275 
    280276    } 
    281      
     277 
    282278    debugError("SP index %d out of range!\n",i); 
    283      
     279 
    284280    return false; 
    285281} 
     
    301297        debugWarning("Could not retrieve isoTimeoutSecs parameter, defauling to 120secs\n"); 
    302298    } 
    303      
     299 
    304300    int wait_cycles=timeoutSecs*10; // two seconds 
    305      
     301 
    306302    fb_quadlet_t reg=v; 
    307      
     303 
    308304    while ((v == reg) && wait_cycles) { 
    309305        wait_cycles--; 
     
    318314        return false; 
    319315    } 
    320      
     316 
    321317    return true; 
    322318} 
     
    326322 
    327323 
    328 struct BounceSlaveDevice::configrom_backup  
     324struct BounceSlaveDevice::configrom_backup 
    329325BounceSlaveDevice::save_config_rom(raw1394handle_t handle) 
    330326{ 
     
    333329    /* get the current rom image */ 
    334330    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); 
    336332//     printf("save_config_rom get_config_rom returned %d, romsize %d, rom_version %d:\n",retval,tmp.rom_size,tmp.rom_version); 
    337333 
     
    339335} 
    340336 
    341 int  
     337int 
    342338BounceSlaveDevice::restore_config_rom(raw1394handle_t handle, struct BounceSlaveDevice::configrom_backup old) 
    343339{ 
    344340    int retval; 
    345341//     int i; 
    346      
     342 
    347343    quadlet_t current_rom[0x100]; 
    348344    size_t current_rom_size; 
     
    371367} 
    372368 
    373 int  
     369int 
    374370BounceSlaveDevice::init_config_rom(raw1394handle_t handle) 
    375371{ 
     
    380376    rom1394_directory dir; 
    381377    char *leaf; 
    382      
     378 
    383379    /* get the current rom image */ 
    384380    retval=raw1394_get_config_rom(handle, rom, 0x100, &rom_size, &rom_version); 
     
    391387//     } 
    392388//     printf("\n"); 
    393      
     389 
    394390    /* get the local directory */ 
    395391    rom1394_get_directory( handle, raw1394_get_local_id(handle) & 0x3f, &dir); 
    396      
     392 
    397393    /* change the vendor description for kicks */ 
    398394    i = strlen(dir.textual_leafs[0]); 
    399     strncpy(dir.textual_leafs[0], FREEBOB_BOUNCE_SERVER_VENDORNAME "                                          ", i); 
    400      
    401     dir.vendor_id=FREEBOB_BOUNCE_SERVER_VENDORID; 
    402     dir.model_id=FREEBOB_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 
    404400    /* update the rom */ 
    405401    retval = rom1394_set_directory(rom, &dir); 
     
    411407//     } 
    412408//     printf("\n"); 
    413      
     409 
    414410    /* free the allocated mem for the textual leaves */ 
    415411    rom1394_free_directory( &dir); 
    416      
     412 
    417413    /* add an AV/C unit directory */ 
    418     dir.unit_spec_id    = FREEBOB_BOUNCE_SERVER_SPECID; 
     414    dir.unit_spec_id    = FFADO_BOUNCE_SERVER_SPECID; 
    419415    dir.unit_sw_version = 0x00010001; 
    420     leaf = FREEBOB_BOUNCE_SERVER_MODELNAME; 
     416    leaf = FFADO_BOUNCE_SERVER_MODELNAME; 
    421417    dir.nr_textual_leafs = 1; 
    422418    dir.textual_leafs = &leaf; 
    423      
     419 
    424420    /* manipulate the rom */ 
    425421    retval = rom1394_add_unit( rom, &dir); 
    426      
     422 
    427423    /* get the computed size of the rom image */ 
    428424    rom_size = rom1394_get_size(rom); 
    429      
     425 
    430426//     printf("rom1394_add_unit_directory returned %d, romsize %d:",retval,rom_size); 
    431427//     for (i = 0; i < rom_size; i++) 
     
    435431//     } 
    436432//     printf("\n"); 
    437 //      
     433// 
    438434    /* convert computed rom size from quadlets to bytes before update */ 
    439435    rom_size *= sizeof(quadlet_t); 
    440436    retval = raw1394_update_config_rom(handle, rom, rom_size, rom_version); 
    441437//     printf("update_config_rom returned %d\n",retval); 
    442      
     438 
    443439    retval=raw1394_get_config_rom(handle, rom, 0x100, &rom_size, &rom_version); 
    444440//     printf("get_config_rom returned %d, romsize %d, rom_version %d:",retval,rom_size,rom_version); 
     
    449445//     } 
    450446//     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 
    454450    return 0; 
    455451} 
     
    459455 
    460456BounceSlaveDevice::BounceSlaveNotifier::BounceSlaveNotifier(BounceSlaveDevice *d, nodeaddr_t start) 
    461  : ARMHandler(start, BOUNCE_REGISTER_LENGTH,  
     457 : ARMHandler(start, BOUNCE_REGISTER_LENGTH, 
    462458              RAW1394_ARM_READ | RAW1394_ARM_WRITE, // allowed operations 
    463459              0, //RAW1394_ARM_READ | RAW1394_ARM_WRITE, // operations to be notified of 
     
    468464} 
    469465 
    470 BounceSlaveDevice::BounceSlaveNotifier::~BounceSlaveNotifier()  
     466BounceSlaveDevice::BounceSlaveNotifier::~BounceSlaveNotifier() 
    471467{ 
    472468 
  • 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 */ 
    224 
    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__ 
    3027 
    3128#include "debugmodule/debugmodule.h" 
    3229#include "bounce_avdevice.h" 
    3330 
    34 #define FREEBOB_MAX_NAME_LEN 256 
     31#define FFADO_MAX_NAME_LEN 256 
    3532 
    36 #define FREEBOB_BOUNCE_SERVER_VENDORNAME  "FreeBoB Server" 
    37 #define FREEBOB_BOUNCE_SERVER_MODELNAME   "freebob-server" 
     33#define FFADO_BOUNCE_SERVER_VENDORNAME  "FFADO Server" 
     34#define FFADO_BOUNCE_SERVER_MODELNAME   "ffado-server" 
    3835 
    3936// NOTE: this is currently free, but it is not really allowed to use 
    40 #define FREEBOB_BOUNCE_SERVER_VENDORID    0x000B0001 
    41 #define FREEBOB_BOUNCE_SERVER_MODELID     0x000B0001 
    42 #define FREEBOB_BOUNCE_SERVER_SPECID      0x000B0001 
     37#define FFADO_BOUNCE_SERVER_VENDORID    0x000B0001 
     38#define FFADO_BOUNCE_SERVER_MODELID     0x000B0001 
     39#define FFADO_BOUNCE_SERVER_SPECID      0x000B0001 
    4340 
    4441namespace Bounce { 
     
    5148          Ieee1394Service& ieee1394Service ); 
    5249    virtual ~BounceSlaveDevice(); 
    53      
     50 
    5451    static bool probe( ConfigRom& configRom ); 
    5552    bool discover(); 
     
    5754    bool lock(); 
    5855    bool unlock(); 
    59      
     56 
    6057    bool startStreamByIndex(int i); 
    6158    bool stopStreamByIndex(int i); 
     
    6562    bool initMemSpace(); 
    6663    bool restoreMemSpace(); 
    67      
     64 
    6865private: // configrom shit 
    6966 
     
    7471    }; 
    7572    struct configrom_backup m_original_config_rom; 
    76      
    77     struct configrom_backup  
     73 
     74    struct configrom_backup 
    7875        save_config_rom(raw1394handle_t handle); 
    7976    int restore_config_rom(raw1394handle_t handle, struct configrom_backup old); 
    8077    int init_config_rom(raw1394handle_t handle); 
    81      
     78 
    8279private: 
    8380    BounceSlaveNotifier *m_Notifier; 
    8481    /** 
    85      * this class reacts on the ohter side writing to the  
     82     * this class reacts on the ohter side writing to the 
    8683     * hosts address space 
    8784     */ 
     
    9188        BounceSlaveNotifier(BounceSlaveDevice *, nodeaddr_t start); 
    9289        virtual ~BounceSlaveNotifier(); 
    93          
     90 
    9491    private: 
    9592        BounceSlaveDevice *m_bounceslavedevice; 
     
    9996} // end of namespace Bounce 
    10097 
    101 #endif /* __FREEBOB_BOUNCESLAVEDEVICE__ */ 
     98#endif /* __FFADO_BOUNCESLAVEDEVICE__ */ 
    10299 
    103100 
  • 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, 
    1114 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    1215 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     
    1417 * 
    1518 * You should have received a copy of the GNU General Public License 
    16  * along with FreeBoB; if not, write to the Free Software 
     19 * along with FFADO; if not, write to the Free Software 
    1720 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
    1821 * MA 02111-1307 USA. 
     
    3235// arg parsing 
    3336//////////////////////////////////////////////// 
    34 const char *argp_program_version = "freebob_downloader 0.1"; 
    35 const char *argp_program_bug_address = "<freebob-devel@lists.sf.net>"; 
    36 static char doc[] = "freebob_downloader -- firmware downloader application\n\n" 
     37const char *argp_program_version = "bridgeco-downloader 0.1"; 
     38const char *argp_program_bug_address = "<ffado-devel@lists.sf.net>"; 
     39static char doc[] = "bridgeco-downloader -- firmware downloader application for BridgeCo devices\n\n" 
    3740                    "OPERATION: display\n" 
    3841                    "           setguid GUID\n" 
     
    135138    int node_id = strtol(arguments.args[0], &tail, 0); 
    136139    if (errno) { 
    137        perror("argument parsing failed:"); 
    138        return -1; 
     140    perror("argument parsing failed:"); 
     141    return -1; 
    139142    } 
    140143 
     
    220223    return 0; 
    221224} 
    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 
    34 * 
    4  * This file is part of FreeBoB. 
     5 * This file is part of FFADO 
     6 * FFADO = Free Firewire (pro-)audio drivers for linux 
    57 * 
    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, 
    1115 * 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. 
     16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     17 * Lesser General Public License for more details. 
    1418 * 
    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 * 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 
    1923 */ 
    2024 
     
    5458DebugModule::~DebugModule() 
    5559{ 
    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//     } 
    6266    if ( !DebugModuleManager::instance()->unregisterModule( *this ) ) { 
    6367        cerr << "Could not unregister DebugModule at DebugModuleManager" 
     
    99103    va_list arg; 
    100104    va_start( arg, format ); 
    101      
     105 
    102106    // remove the path info from the filename 
    103107    const char *f = file; 
     
    107111        fname=f; 
    108112    } 
    109      
     113 
    110114    DebugModuleManager::instance()->print( "%s (%s)[%4d] %s: ", getPreSequence( level ), 
    111115                 fname,  line,  function ); 
     
    149153DebugModuleManager::~DebugModuleManager() 
    150154{ 
    151        // cleanin up leftover modules 
     155    // cleanin up leftover modules 
    152156    for ( DebugModuleVectorIterator it = m_debugModules.begin(); 
    153157          it != m_debugModules.end(); 
     
    159163    } 
    160164 
    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        else 
    176                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); 
    180184 
    181185} 
     
    184188DebugModuleManager::init() 
    185189{ 
    186        if (mb_initialized) 
    187                return true; 
     190    if (mb_initialized) 
     191        return true; 
    188192 
    189193        // if ( m_level >= eDL_VeryVerbose ) 
    190194        //         cout << "DebugModuleManager init..." << endl; 
    191195 
    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; 
    200204 
    201205    return true; 
     
    223227{ 
    224228    bool already_present=false; 
    225      
     229 
    226230    for ( DebugModuleVectorIterator it = m_debugModules.begin(); 
    227231          it != m_debugModules.end(); 
     
    233237        } 
    234238    } 
    235      
     239 
    236240    if (already_present) { 
    237241        cerr << "DebugModuleManager::registerModule: Module already registered: " 
     
    246250DebugModuleManager::unregisterModule( DebugModule& debugModule ) 
    247251{ 
    248      
     252 
    249253    for ( DebugModuleVectorIterator it = m_debugModules.begin(); 
    250254          it != m_debugModules.end(); 
     
    256260        } 
    257261    } 
    258      
     262 
    259263    cerr << "DebugModuleManager::unregisterModule: Could not unregister " 
    260264         << "DebugModule (" << debugModule.getName() << ")" << endl; 
     
    288292DebugModuleManager::mb_flush() 
    289293{ 
    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   
    295299} 
    296300 
     
    301305    DebugModuleManager *m=static_cast<DebugModuleManager *>(arg); 
    302306 
    303        /* The mutex is only to eliminate collisions between multiple 
    304         * 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; 
    319323} 
    320324 
     
    322326DebugModuleManager::print(const char *fmt, ...) 
    323327{ 
    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: atomicity 
    347                mb_overruns++; // skip the atomicness for now 
    348        
     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   
    349353} 
    350354 
     
    353357DebugModuleManager::va_print (const char *fmt, va_list ap) 
    354358{ 
    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: atomicity 
    376                mb_overruns++; // skip the atomicness for now 
    377        
     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   
    378382} 
    379383 
  • 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, 
    1115 * 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. 
     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 
    1923 */ 
    2024 
     
    3135 
    3236/* MB_NEXT() relies on the fact that MB_BUFFERS is a power of two */ 
    33 #define MB_BUFFERS     8192 
     37#define MB_BUFFERS    8192 
    3438#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 */ 
    3640 
    3741#define debugFatal( format, args... )                               \ 
     
    7882#define IMPL_GLOBAL_DEBUG_MODULE( RegisterName, Level )            \ 
    7983                DebugModule m_debugModule =                        \ 
    80                    DebugModule( #RegisterName, Level ) 
     84            DebugModule( #RegisterName, Level ) 
    8185 
    8286#define setDebugLevel( Level ) {                                    \ 
    8387                m_debugModule.setLevel( Level ); \ 
    84                                
     88               
    8589 
    8690/*                m_debugModule.print( eDL_Normal,                        \ 
     
    9094                                     "Setting debug level to %d\n",  \ 
    9195                                     Level ); \ 
    92                                }*/ 
     96                }*/ 
    9397 
    9498#define getDebugLevel(  )                                     \ 
     
    97101 
    98102#ifdef DEBUG 
    99      
     103 
    100104    #define debugOutput( level, format, args... )                  \ 
    101105                m_debugModule.print( level,                        \ 
     
    129133 
    130134#include <sys/time.h> 
    131   
     135 
    132136#ifdef DO_PREEMPTION_CHECKING 
    133137#define CHECK_PREEMPTION(onoff) \ 
    134        gettimeofday((struct timeval *)1, (struct timezone *)onoff) 
     138    gettimeofday((struct timeval *)1, (struct timezone *)onoff) 
    135139#else 
    136140#define CHECK_PREEMPTION(onoff) 
     
    196200    static DebugModuleManager* instance(); 
    197201    ~DebugModuleManager(); 
    198      
     202 
    199203    bool setMgrDebugLevel( std::string name, debug_level_t level ); 
    200204 
     
    206210 
    207211    bool init(); 
    208      
     212 
    209213    void print(const char *fmt, ...); 
    210214    void va_print(const char *fmt, va_list); 
    211      
     215 
    212216private: 
    213217    DebugModuleManager(); 
     
    227231    static void *mb_thread_func(void *arg); 
    228232    void mb_flush(); 
    229      
     233 
    230234    static DebugModuleManager* m_instance; 
    231235    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 
    125#include "debugmodule.h" 
    226 
  • 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, 
    1115 * 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. 
     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 
    1923 */ 
    2024 
     
    9498 
    9599void 
    96 DeviceManager::setVerboseLevel(int l)  
     100DeviceManager::setVerboseLevel(int l) 
    97101{ 
    98102    m_verboseLevel=l; 
    99103    setDebugLevel(l); 
    100      
     104 
    101105    if (m_1394Service) m_1394Service->setVerboseLevel(l); 
    102106    if (m_oscServer) m_oscServer->setVerboseLevel(l); 
    103107    OscNode::setVerboseLevel(l); 
    104      
     108 
    105109    for ( IAvDeviceVectorIterator it = m_avDevices.begin(); 
    106110          it != m_avDevices.end(); 
     
    126130        return false; 
    127131    } 
    128      
     132 
    129133    m_oscServer = new OSC::OscServer("17820"); 
    130      
     134 
    131135    if (!m_oscServer) { 
    132136        debugFatal("failed to create osc server\n"); 
     
    135139        return false; 
    136140    } 
    137      
     141 
    138142    if (!m_oscServer->init()) { 
    139143        debugFatal("failed to init osc server\n"); 
     
    144148        return false; 
    145149    } 
    146      
     150 
    147151    if (!m_oscServer->registerAtRootNode(this)) { 
    148152        debugFatal("failed to register devicemanager at server\n"); 
     
    153157        return false; 
    154158    } 
    155      
     159 
    156160    if (!m_oscServer->start()) { 
    157161        debugFatal("failed to start osc server\n"); 
     
    162166        return false; 
    163167    } 
    164      
     168 
    165169    setVerboseLevel(m_verboseLevel); 
    166170    return true; 
     
    198202        { 
    199203            debugOutput( DEBUG_LEVEL_VERBOSE, "Probing node %d...\n", nodeId ); 
    200      
     204 
    201205            if (nodeId == m_1394Service->getLocalNodeId()) { 
    202206                debugOutput( DEBUG_LEVEL_VERBOSE, "Skipping local node (%d)...\n", nodeId ); 
    203207                continue; 
    204208            } 
    205      
     209 
    206210            std::auto_ptr<ConfigRom> configRom = 
    207211                std::auto_ptr<ConfigRom>( new ConfigRom( *m_1394Service, 
     
    219223                continue; 
    220224            } 
    221      
     225 
    222226            IAvDevice* avDevice = getDriverForDevice( configRom, 
    223227                                                      nodeId ); 
     
    228232 
    229233                avDevice->setVerboseLevel( m_verboseLevel ); 
    230                  
     234 
    231235                if ( !avDevice->discover() ) { 
    232236                    debugError( "discover: could not discover device\n" ); 
     
    238242                    debugError( "setting Id failed\n" ); 
    239243                } 
    240                  
     244 
    241245                if (snoopMode) { 
    242246                    debugOutput( DEBUG_LEVEL_VERBOSE, 
     
    249253                    } 
    250254                } 
    251                  
     255 
    252256                if ( m_verboseLevel >= DEBUG_LEVEL_VERBOSE ) { 
    253257                    avDevice->showDevice(); 
     
    255259 
    256260                m_avDevices.push_back( avDevice ); 
    257                  
     261 
    258262                if (!addChildOscNode(avDevice)) { 
    259263                    debugWarning("failed to register AvDevice at OSC server\n"); 
     
    263267        } 
    264268        return true; 
    265          
     269 
    266270    } else { // slave mode 
    267271        fb_nodeid_t nodeId = m_1394Service->getLocalNodeId(); 
     
    289293                         "discover: driver found for device %d\n", 
    290294                         nodeId ); 
    291              
     295 
    292296            avDevice->setVerboseLevel( m_verboseLevel ); 
    293297 
     
    307311            m_avDevices.push_back( avDevice ); 
    308312        } 
    309      
     313 
    310314        return true; 
    311315    } 
     
    392396 
    393397        if (avDevice->getConfigRom().getNodeId() == node) { 
    394                return true; 
    395        
     398            return true; 
     399   
    396400    } 
    397401    return false; 
     
    440444DeviceManager::getAvDeviceByIndex( int idx ) 
    441445{ 
    442        return m_avDevices.at(idx); 
     446    return m_avDevices.at(idx); 
    443447} 
    444448 
     
    446450DeviceManager::getAvDeviceCount( ) 
    447451{ 
    448        return m_avDevices.size(); 
     452    return m_avDevices.size(); 
    449453} 
    450454 
     
    465469        debugWarning("Could not retrieve slaveMode parameter, defauling to false\n"); 
    466470    } 
    467     
     471 
    468472    #warning TEST CODE FOR BOUNCE DEVICE !! 
    469473    // this makes the bounce slave use the xmit SP as sync source 
     
    473477        return device->getStreamProcessorByIndex(0); 
    474478    } 
    475      
    476479} 
    477480 
     
    487490    int i; 
    488491    i=0; // avoids unused warning 
    489      
     492 
    490493    for ( IAvDeviceVectorIterator it = m_avDevices.begin(); 
    491494          it != m_avDevices.end(); 
     
    494497        IAvDevice* pAvDevice; 
    495498        pAvDevice = *it; // avoids unused warning 
    496          
     499 
    497500        #ifdef ENABLE_BEBOB 
    498501        BeBoB::AvDevice* pBeBoBDevice = reinterpret_cast< BeBoB::AvDevice* >( pAvDevice ); 
     
    577580    } while ( pBeBoBDevice ); 
    578581    #endif 
    579      
     582 
    580583    return true; 
    581584} 
  • 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 
    34 * 
    4  * This file is part of FreeBoB. 
     5 * This file is part of FFADO 
     6 * FFADO = Free Firewire (pro-)audio drivers for linux 
    57 * 
    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, 
    1115 * 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. 
     16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     17 * Lesser General Public License for more details. 
    1418 * 
    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 * 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 
    1923 */ 
    2024 
    21 #ifndef FREEBOBDEVICEMANAGER_H 
    22 #define FREEBOBDEVICEMANAGER_H 
     25#ifndef FFADODEVICEMANAGER_H 
     26#define FFADODEVICEMANAGER_H 
    2327 
    2428#include "debugmodule/debugmodule.h" 
     
    4448typedef std::vector< IAvDevice* >::iterator IAvDeviceVectorIterator; 
    4549 
    46 class DeviceManager  
     50class DeviceManager 
    4751    : public Util::OptionContainer, 
    4852      public OSC::OscNode 
     
    7882    Ieee1394Service* m_1394Service; 
    7983    IAvDeviceVector  m_avDevices; 
    80      
     84 
    8185    OSC::OscServer*  m_oscServer; 
    82      
     86 
    8387// debug stuff 
    8488public: 
  • trunk/libffado/src/dice/dice_avdevice.cpp

    r436 r445  
    1 /* dice_avdevice.cpp 
    2  * Copyright (C) 2007 by Pieter Palmers 
     1/* 
     2 * Copyright (C) 2005-2007 by Pieter Palmers 
    33 * 
    4  * This file is part of FreeBob. 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    56 * 
    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, 
    1114 * 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. 
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     16 * Lesser General Public License for more details. 
    1417 * 
    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. 
     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 
    1922 */ 
    2023 
     
    9497    { 
    9598        if ( ( supportedDeviceList[i].vendor_id == vendorId ) 
    96              && ( supportedDeviceList[i].model_id == modelId )  
     99             && ( supportedDeviceList[i].model_id == modelId ) 
    97100           ) 
    98101        { 
     
    115118    { 
    116119        if ( ( supportedDeviceList[i].vendor_id == vendorId ) 
    117              && ( supportedDeviceList[i].model_id == modelId )  
     120             && ( supportedDeviceList[i].model_id == modelId ) 
    118121           ) 
    119122        { 
     
    126129        return false; 
    127130    } 
    128      
     131 
    129132    if ( !initIoFunctions() ) { 
    130133        debugError("Could not initialize I/O functions\n"); 
     
    138141} 
    139142 
    140 int  
     143int 
    141144DiceAvDevice::getSamplingFrequency( ) { 
    142145    ESamplingFrequency samplingFrequency; 
    143      
     146 
    144147    fb_quadlet_t clockreg; 
    145148    if (!readGlobalReg(DICE_REGISTER_GLOBAL_CLOCK_SELECT, &clockreg)) { 
     
    147150        return false; 
    148151    } 
    149      
     152 
    150153    clockreg = DICE_GET_RATE(clockreg); 
    151154 
     
    164167        default:                 samplingFrequency = eSF_DontCare; break; 
    165168    } 
    166      
     169 
    167170    return convertESamplingFrequency(samplingFrequency); 
    168171} 
     
    171174DiceAvDevice::setSamplingFrequency( ESamplingFrequency samplingFrequency ) 
    172175{ 
    173     debugOutput(DEBUG_LEVEL_VERBOSE, "Setting sample rate: %d\n",  
     176    debugOutput(DEBUG_LEVEL_VERBOSE, "Setting sample rate: %d\n", 
    174177        convertESamplingFrequency(samplingFrequency)); 
    175          
     178 
    176179    bool supported=false; 
    177180    fb_quadlet_t select=0x0; 
    178      
     181 
    179182    switch ( samplingFrequency ) { 
    180183    default: 
     
    236239        return false; 
    237240    } 
    238      
     241 
    239242    fb_quadlet_t clockreg; 
    240243    if (!readGlobalReg(DICE_REGISTER_GLOBAL_CLOCK_SELECT, &clockreg)) { 
     
    256259        return false; 
    257260    } 
    258      
     261 
    259262    if(clockreg != clockreg_verify) { 
    260263        debugError("Samplerate register write failed\n"); 
    261264        return false; 
    262265    } 
    263      
     266 
    264267    return true; 
    265268} 
     
    270273    fb_quadlet_t tmp_quadlet; 
    271274    fb_octlet_t tmp_octlet; 
    272      
     275 
    273276    debugOutput(DEBUG_LEVEL_VERBOSE, 
    274277        "%s %s at node %d\n", m_model->vendor_name, m_model->model_name, 
     
    285288 
    286289    debugOutput(DEBUG_LEVEL_VERBOSE," Global param space:\n"); 
    287      
     290 
    288291    readGlobalRegBlock(DICE_REGISTER_GLOBAL_OWNER, (fb_quadlet_t *)&tmp_octlet,sizeof(fb_octlet_t)); 
    289292    debugOutput(DEBUG_LEVEL_VERBOSE,"  Owner            : 0x%016X\n",tmp_octlet); 
    290      
     293 
    291294    readGlobalReg(DICE_REGISTER_GLOBAL_NOTIFICATION, &tmp_quadlet); 
    292295    debugOutput(DEBUG_LEVEL_VERBOSE,"  Notification     : 0x%08X\n",tmp_quadlet); 
    293      
     296 
    294297    readGlobalReg(DICE_REGISTER_GLOBAL_NOTIFICATION, &tmp_quadlet); 
    295298    debugOutput(DEBUG_LEVEL_VERBOSE,"  Nick name        : %s\n",getDeviceNickName().c_str()); 
    296      
     299 
    297300    readGlobalReg(DICE_REGISTER_GLOBAL_CLOCK_SELECT, &tmp_quadlet); 
    298301    debugOutput(DEBUG_LEVEL_VERBOSE,"  Clock Select     : 0x%02X 0x%02X\n", 
    299302        (tmp_quadlet>>8) & 0xFF, tmp_quadlet & 0xFF); 
    300      
     303 
    301304    readGlobalReg(DICE_REGISTER_GLOBAL_ENABLE, &tmp_quadlet); 
    302305    debugOutput(DEBUG_LEVEL_VERBOSE,"  Enable           : %s\n", 
    303306        (tmp_quadlet&0x1?"true":"false")); 
    304      
     307 
    305308    readGlobalReg(DICE_REGISTER_GLOBAL_STATUS, &tmp_quadlet); 
    306309    debugOutput(DEBUG_LEVEL_VERBOSE,"  Clock Status     : %s 0x%02X\n", 
    307310        (tmp_quadlet&0x1?"locked":"not locked"), (tmp_quadlet>>8) & 0xFF); 
    308      
     311 
    309312    readGlobalReg(DICE_REGISTER_GLOBAL_EXTENDED_STATUS, &tmp_quadlet); 
    310313    debugOutput(DEBUG_LEVEL_VERBOSE,"  Extended Status  : 0x%08X\n",tmp_quadlet); 
    311      
     314 
    312315    readGlobalReg(DICE_REGISTER_GLOBAL_SAMPLE_RATE, &tmp_quadlet); 
    313316    debugOutput(DEBUG_LEVEL_VERBOSE,"  Samplerate       : 0x%08X (%lu)\n",tmp_quadlet,tmp_quadlet); 
    314      
     317 
    315318    readGlobalReg(DICE_REGISTER_GLOBAL_VERSION, &tmp_quadlet); 
    316319    debugOutput(DEBUG_LEVEL_VERBOSE,"  Version          : 0x%08X (%u.%u.%u.%u)\n", 
     
    321324        DICE_DRIVER_SPEC_VERSION_NUMBER_GET_D(tmp_quadlet) 
    322325        ); 
    323      
     326 
    324327    readGlobalReg(DICE_REGISTER_GLOBAL_CLOCKCAPABILITIES, &tmp_quadlet); 
    325328    debugOutput(DEBUG_LEVEL_VERBOSE,"  Clock caps       : 0x%08X\n",tmp_quadlet & 0x1FFF007F); 
     
    327330    diceNameVector names=getClockSourceNameString(); 
    328331    debugOutput(DEBUG_LEVEL_VERBOSE,"  Clock sources    :\n"); 
    329      
     332 
    330333    for ( diceNameVectorIterator it = names.begin(); 
    331334          it != names.end(); 
     
    334337        debugOutput(DEBUG_LEVEL_VERBOSE,"    %s\n", (*it).c_str()); 
    335338    } 
    336      
     339 
    337340    debugOutput(DEBUG_LEVEL_VERBOSE," TX param space:\n"); 
    338341    debugOutput(DEBUG_LEVEL_VERBOSE,"  Nb of xmit        : %1d\n", m_nb_tx); 
    339342    for (unsigned int i=0;i<m_nb_tx;i++) { 
    340343        debugOutput(DEBUG_LEVEL_VERBOSE,"  Transmitter %d:\n",i); 
    341          
     344 
    342345        readTxReg(i, DICE_REGISTER_TX_ISOC_BASE, &tmp_quadlet); 
    343346        debugOutput(DEBUG_LEVEL_VERBOSE,"   ISO channel       : %3d\n", tmp_quadlet); 
    344347        readTxReg(i, DICE_REGISTER_TX_SPEED_BASE, &tmp_quadlet); 
    345348        debugOutput(DEBUG_LEVEL_VERBOSE,"   ISO speed         : %3d\n", tmp_quadlet); 
    346          
     349 
    347350        readTxReg(i, DICE_REGISTER_TX_NB_AUDIO_BASE, &tmp_quadlet); 
    348351        debugOutput(DEBUG_LEVEL_VERBOSE,"   Nb audio channels : %3d\n", tmp_quadlet); 
    349352        readTxReg(i, DICE_REGISTER_TX_MIDI_BASE, &tmp_quadlet); 
    350353        debugOutput(DEBUG_LEVEL_VERBOSE,"   Nb midi channels  : %3d\n", tmp_quadlet); 
    351          
     354 
    352355        readTxReg(i, DICE_REGISTER_TX_AC3_CAPABILITIES_BASE, &tmp_quadlet); 
    353356        debugOutput(DEBUG_LEVEL_VERBOSE,"   AC3 caps          : 0x%08X\n", tmp_quadlet); 
    354357        readTxReg(i, DICE_REGISTER_TX_AC3_ENABLE_BASE, &tmp_quadlet); 
    355358        debugOutput(DEBUG_LEVEL_VERBOSE,"   AC3 enable        : 0x%08X\n", tmp_quadlet); 
    356          
     359 
    357360        diceNameVector channel_names=getTxNameString(i); 
    358361        debugOutput(DEBUG_LEVEL_VERBOSE,"   Channel names     :\n"); 
     
    364367        } 
    365368    } 
    366      
     369 
    367370    debugOutput(DEBUG_LEVEL_VERBOSE," RX param space:\n"); 
    368371    debugOutput(DEBUG_LEVEL_VERBOSE,"  Nb of recv        : %1d\n", m_nb_tx); 
    369372    for (unsigned int i=0;i<m_nb_rx;i++) { 
    370373        debugOutput(DEBUG_LEVEL_VERBOSE,"  Receiver %d:\n",i); 
    371          
     374 
    372375        readTxReg(i, DICE_REGISTER_RX_ISOC_BASE, &tmp_quadlet); 
    373376        debugOutput(DEBUG_LEVEL_VERBOSE,"   ISO channel       : %3d\n", tmp_quadlet); 
    374377        readTxReg(i, DICE_REGISTER_RX_SEQ_START_BASE, &tmp_quadlet); 
    375378        debugOutput(DEBUG_LEVEL_VERBOSE,"   Sequence start    : %3d\n", tmp_quadlet); 
    376          
     379 
    377380        readTxReg(i, DICE_REGISTER_RX_NB_AUDIO_BASE, &tmp_quadlet); 
    378381        debugOutput(DEBUG_LEVEL_VERBOSE,"   Nb audio channels : %3d\n", tmp_quadlet); 
    379382        readTxReg(i, DICE_REGISTER_RX_MIDI_BASE, &tmp_quadlet); 
    380383        debugOutput(DEBUG_LEVEL_VERBOSE,"   Nb midi channels  : %3d\n", tmp_quadlet); 
    381          
     384 
    382385        readTxReg(i, DICE_REGISTER_RX_AC3_CAPABILITIES_BASE, &tmp_quadlet); 
    383386        debugOutput(DEBUG_LEVEL_VERBOSE,"   AC3 caps          : 0x%08X\n", tmp_quadlet); 
    384387        readTxReg(i, DICE_REGISTER_RX_AC3_ENABLE_BASE, &tmp_quadlet); 
    385388        debugOutput(DEBUG_LEVEL_VERBOSE,"   AC3 enable        : 0x%08X\n", tmp_quadlet); 
    386          
     389 
    387390        diceNameVector channel_names=getRxNameString(i); 
    388391        debugOutput(DEBUG_LEVEL_VERBOSE,"   Channel names     :\n"); 
     
    421424        fb_quadlet_t nb_midi; 
    422425        unsigned int nb_channels=0; 
    423          
     426 
    424427        if(!readTxReg(i, DICE_REGISTER_TX_NB_AUDIO_BASE, &nb_audio)) { 
    425428            debugError("Could not read DICE_REGISTER_TX_NB_AUDIO_BASE register for ATX%u",i); 
     
    430433            continue; 
    431434        } 
    432          
     435 
    433436        // request the channel names 
    434437        diceNameVector names_audio=getTxNameString(i); 
    435          
     438 
    436439        if (names_audio.size() != nb_audio) { 
    437440            debugWarning("The audio channel name vector is incorrect, using default names\n"); 
    438441            names_audio.clear(); 
    439              
     442 
    440443            for (unsigned int j=0;j<nb_audio;j++) { 
    441444                std::ostringstream newname; 
     
    444447            } 
    445448        } 
    446          
     449 
    447450        nb_channels=nb_audio; 
    448451        if(nb_midi) nb_channels += 1; // midi-muxed counts as one 
    449          
     452 
    450453        // construct the MIDI names 
    451454        diceNameVector names_midi; 
     
    455458            names_midi.push_back(newname.str()); 
    456459        } 
    457          
     460 
    458461        // construct the streamprocessor 
    459462        Streaming::AmdtpReceiveStreamProcessor *p; 
     
    478481 
    479482            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", 
    481484                    channelInfo.name.c_str()); 
    482485                continue; 
    483486            } 
    484487        } 
    485          
     488 
    486489        // add midi ports to the processor 
    487490        for (unsigned int j=0;j<nb_midi;j++) { 
     
    493496 
    494497            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", 
    496499                    channelInfo.name.c_str()); 
    497500                continue; 
    498501            } 
    499502        } 
    500          
     503 
    501504        // add the SP to the vector 
    502505        m_receiveProcessors.push_back(p); 
    503506    } 
    504      
     507 
    505508    // prepare transmit SP's 
    506509    for (unsigned int i=0;i<m_nb_rx;i++) { 
     
    508511        fb_quadlet_t nb_midi; 
    509512        unsigned int nb_channels=0; 
    510          
     513 
    511514        if(!readTxReg(i, DICE_REGISTER_RX_NB_AUDIO_BASE, &nb_audio)) { 
    512515            debugError("Could not read DICE_REGISTER_RX_NB_AUDIO_BASE register for ARX%u",i); 
     
    517520            continue; 
    518521        } 
    519          
     522 
    520523        // request the channel names 
    521524        diceNameVector names_audio=getRxNameString(i); 
    522          
     525 
    523526        if (names_audio.size() != nb_audio) { 
    524527            debugWarning("The audio channel name vector is incorrect, using default names\n"); 
    525528            names_audio.clear(); 
    526              
     529 
    527530            for (unsigned int j=0;j<nb_audio;j++) { 
    528531                std::ostringstream newname; 
     
    531534            } 
    532535        } 
    533          
     536 
    534537        nb_channels=nb_audio; 
    535538        if(nb_midi) nb_channels += 1; // midi-muxed counts as one 
    536          
     539 
    537540        // construct the MIDI names 
    538541        diceNameVector names_midi; 
     
    542545            names_midi.push_back(newname.str()); 
    543546        } 
    544          
     547 
    545548        // construct the streamprocessor 
    546549        Streaming::AmdtpTransmitStreamProcessor *p; 
     
    565568 
    566569            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", 
    568571                    channelInfo.name.c_str()); 
    569572                continue; 
    570573            } 
    571574        } 
    572          
     575 
    573576        // add midi ports to the processor 
    574577        for (unsigned int j=0;j<nb_midi;j++) { 
     
    580583 
    581584            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", 
    583586                    channelInfo.name.c_str()); 
    584587                continue; 
    585588            } 
    586589        } 
    587          
     590 
    588591        m_transmitProcessors.push_back(p); 
    589592    } 
     
    596599    Streaming::StreamProcessor *processor, 
    597600    Streaming::Port::E_Direction direction) { 
    598      
     601 
    599602    std::string id=std::string("dev?"); 
    600603    if(!getOption("id", id)) { 
     
    609612        portname << "c"; 
    610613    } 
    611      
     614 
    612615    portname << "_" << channelInfo->name; 
    613616 
     
    655658DiceAvDevice::lock() { 
    656659    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", 
    659662        m_model->vendor_name, m_model->model_name, m_nodeId); 
    660          
     663 
    661664    // get a notifier to handle device notifications 
    662665    nodeaddr_t notify_address; 
     
    665668                        DICE_NOTIFIER_BLOCK_LENGTH, 
    666669                        DICE_NOTIFIER_BLOCK_LENGTH); 
    667      
     670 
    668671    if (notify_address == 0xFFFFFFFFFFFFFFFFLLU) { 
    669672        debugError("Could not find free ARM block for notification\n"); 
    670673        return false; 
    671674    } 
    672      
     675 
    673676    m_notifier=new DiceAvDevice::DiceNotifier(this, notify_address); 
    674      
     677 
    675678    if(!m_notifier) { 
    676679        debugError("Could not allocate notifier\n"); 
    677680        return false; 
    678681    } 
    679      
     682 
    680683    if (!m_p1394Service->registerARMHandler(m_notifier)) { 
    681684        debugError("Could not register notifier\n"); 
     
    686689 
    687690    // register this notifier 
    688     fb_nodeaddr_t addr = DICE_REGISTER_BASE  
     691    fb_nodeaddr_t addr = DICE_REGISTER_BASE 
    689692                       + m_global_reg_offset 
    690693                       + DICE_REGISTER_GLOBAL_OWNER; 
     
    696699        return false; 
    697700    } 
    698      
     701 
    699702    fb_nodeaddr_t swap_value = ((0xFFC0) | m_p1394Service->getLocalNodeId()); 
    700703    swap_value = swap_value << 48; 
    701704    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, 
    704707                                       swap_value, &result )) { 
    705708        debugWarning("Could not register ourselves as device owner\n"); 
    706709    } 
    707      
     710 
    708711    if (result != DICE_OWNER_NO_OWNER) { 
    709712        debugWarning("Could not register ourselves as device owner, unexpected register value: 0x%016llX\n", result); 
     
    717720DiceAvDevice::unlock() { 
    718721    fb_octlet_t result; 
    719      
     722 
    720723    if(!m_notifier) { 
    721724        debugWarning("Request to unlock, but no notifier present!\n"); 
    722725        return false; 
    723726    } 
    724      
    725     fb_nodeaddr_t addr = DICE_REGISTER_BASE  
     727 
     728    fb_nodeaddr_t addr = DICE_REGISTER_BASE 
    726729                       + m_global_reg_offset 
    727730                       + DICE_REGISTER_GLOBAL_OWNER; 
     
    733736        return false; 
    734737    } 
    735      
     738 
    736739    fb_nodeaddr_t compare_value = ((0xFFC0) | m_p1394Service->getLocalNodeId()); 
    737     compare_value <<= 48;  
     740    compare_value <<= 48; 
    738741    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, 
    741744                                       DICE_OWNER_NO_OWNER, &result )) { 
    742745        debugWarning("Could not unregister ourselves as device owner\n"); 
    743746    } 
    744      
     747 
    745748    m_p1394Service->unregisterARMHandler(m_notifier); 
    746749    delete m_notifier; 
     
    788791        int n=i; 
    789792        Streaming::StreamProcessor *p=m_receiveProcessors.at(n); 
    790          
     793 
    791794        // allocate ISO channel 
    792795        int isochannel=allocateIsoChannel(p->getMaxPacketSize()); 
     
    796799        } 
    797800        p->setChannel(isochannel); 
    798          
     801 
    799802        fb_quadlet_t reg_isoch; 
    800803        // check value of ISO_CHANNEL register 
     
    811814            return false; 
    812815        } 
    813          
     816 
    814817        // write value of ISO_CHANNEL register 
    815818        reg_isoch=isochannel; 
     
    820823            return false; 
    821824        } 
    822          
     825 
    823826        return true; 
    824          
     827 
    825828    } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) { 
    826829        int n=i-m_receiveProcessors.size(); 
    827830        Streaming::StreamProcessor *p=m_transmitProcessors.at(n); 
    828          
     831 
    829832        // allocate ISO channel 
    830833        int isochannel=allocateIsoChannel(p->getMaxPacketSize()); 
     
    834837        } 
    835838        p->setChannel(isochannel); 
    836          
     839 
    837840        fb_quadlet_t reg_isoch; 
    838841        // check value of ISO_CHANNEL register 
     
    849852            return false; 
    850853        } 
    851          
     854 
    852855        // write value of ISO_CHANNEL register 
    853856        reg_isoch=isochannel; 
     
    858861            return false; 
    859862        } 
    860          
     863 
    861864        return true; 
    862865    } 
    863      
     866 
    864867    debugError("SP index %d out of range!\n",i); 
    865      
     868 
    866869    return false; 
    867870} 
     
    879882        Streaming::StreamProcessor *p=m_receiveProcessors.at(n); 
    880883        unsigned int isochannel=p->getChannel(); 
    881          
     884 
    882885        fb_quadlet_t reg_isoch; 
    883886        // check value of ISO_CHANNEL register 
     
    890893            return false; 
    891894        } 
    892          
     895 
    893896        // write value of ISO_CHANNEL register 
    894897        reg_isoch=0xFFFFFFFFUL; 
     
    897900            return false; 
    898901        } 
    899          
     902 
    900903        // deallocate ISO channel 
    901904        if(!deallocateIsoChannel(isochannel)) { 
     
    903906            return false; 
    904907        } 
    905          
     908 
    906909        p->setChannel(-1); 
    907910        return true; 
    908          
     911 
    909912    } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) { 
    910913        int n=i-m_receiveProcessors.size(); 
    911914        Streaming::StreamProcessor *p=m_transmitProcessors.at(n); 
    912          
     915 
    913916        unsigned int isochannel=p->getChannel(); 
    914          
     917 
    915918        fb_quadlet_t reg_isoch; 
    916919        // check value of ISO_CHANNEL register 
     
    923926            return false; 
    924927        } 
    925          
     928 
    926929        // write value of ISO_CHANNEL register 
    927930        reg_isoch=0xFFFFFFFFUL; 
     
    930933            return false; 
    931934        } 
    932          
     935 
    933936        // deallocate ISO channel 
    934937        if(!deallocateIsoChannel(isochannel)) { 
     
    936939            return false; 
    937940        } 
    938          
     941 
    939942        p->setChannel(-1); 
    940943        return true; 
    941944    } 
    942      
     945 
    943946    debugError("SP index %d out of range!\n",i); 
    944      
     947 
    945948    return false; 
    946949} 
     
    951954int DiceAvDevice::allocateIsoChannel(unsigned int packet_size) { 
    952955    unsigned int bandwidth=8+packet_size; 
    953      
     956 
    954957    int ch=m_p1394Service->allocateIsoChannelGeneric(bandwidth); 
    955          
     958 
    956959    debugOutput(DEBUG_LEVEL_VERBOSE, "allocated channel %d, bandwidth %d\n", 
    957960        ch, bandwidth); 
    958      
     961 
    959962    return ch; 
    960963} 
     
    979982    fb_quadlet_t result; 
    980983    readGlobalReg(DICE_REGISTER_GLOBAL_ENABLE, &result); 
    981     // I don't know what exactly is 'enable',  
     984    // I don't know what exactly is 'enable', 
    982985    // but disable is definately == 0 
    983986    return (result != DICE_ISOSTREAMING_DISABLE); 
     
    10071010    diceNameVector names; 
    10081011    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, 
    10111014                        (fb_quadlet_t *)namestring, DICE_TX_NAMES_SIZE)) { 
    10121015        debugError("Could not read TX name string \n"); 
    10131016        return names; 
    10141017    } 
    1015      
     1018 
    10161019    namestring[DICE_TX_NAMES_SIZE]='\0'; 
    10171020    return splitNameString(std::string(namestring)); 
     
    10221025    diceNameVector names; 
    10231026    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, 
    10261029                        (fb_quadlet_t *)namestring, DICE_RX_NAMES_SIZE)) { 
    10271030        debugError("Could not read RX name string \n"); 
    10281031        return names; 
    10291032    } 
    1030      
     1033 
    10311034    namestring[DICE_RX_NAMES_SIZE]='\0'; 
    10321035    return splitNameString(std::string(namestring)); 
     
    10371040    diceNameVector names; 
    10381041    char namestring[DICE_CLOCKSOURCENAMES_SIZE+1]; 
    1039      
    1040     if (!readGlobalRegBlock(DICE_REGISTER_GLOBAL_CLOCKSOURCENAMES,  
     1042 
     1043    if (!readGlobalRegBlock(DICE_REGISTER_GLOBAL_CLOCKSOURCENAMES, 
    10411044                        (fb_quadlet_t *)namestring, DICE_CLOCKSOURCENAMES_SIZE)) { 
    10421045        debugError("Could not read CLOCKSOURCE name string \n"); 
    10431046        return names; 
    10441047    } 
    1045      
     1048 
    10461049    namestring[DICE_CLOCKSOURCENAMES_SIZE]='\0'; 
    10471050    return splitNameString(std::string(namestring)); 
     
    10511054DiceAvDevice::getDeviceNickName() { 
    10521055    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, 
    10551058                        (fb_quadlet_t *)namestring, DICE_NICK_NAME_SIZE)) { 
    10561059        debugError("Could not read nickname string \n"); 
    10571060        return std::string("(unknown)"); 
    10581061    } 
    1059      
     1062 
    10601063    namestring[DICE_NICK_NAME_SIZE]='\0'; 
    10611064    return std::string(namestring); 
     
    10961099    } 
    10971100    m_global_reg_offset*=4; 
    1098      
     1101 
    10991102    if(!readReg(DICE_REGISTER_GLOBAL_PAR_SPACE_SZ, &m_global_reg_size)) { 
    11001103        debugError("Could not initialize m_global_reg_size\n"); 
     
    11021105    } 
    11031106    m_global_reg_size*=4; 
    1104      
     1107 
    11051108    if(!readReg(DICE_REGISTER_TX_PAR_SPACE_OFF, &m_tx_reg_offset)) { 
    11061109        debugError("Could not initialize m_tx_reg_offset\n"); 
     
    11081111    } 
    11091112    m_tx_reg_offset*=4; 
    1110      
     1113 
    11111114    if(!readReg(DICE_REGISTER_TX_PAR_SPACE_SZ, &m_tx_reg_size)) { 
    11121115        debugError("Could not initialize m_tx_reg_size\n"); 
     
    11141117    } 
    11151118    m_tx_reg_size*=4; 
    1116      
     1119 
    11171120    if(!readReg(DICE_REGISTER_RX_PAR_SPACE_OFF, &m_rx_reg_offset)) { 
    11181121        debugError("Could not initialize m_rx_reg_offset\n"); 
     
    11201123    } 
    11211124    m_rx_reg_offset*=4; 
    1122      
     1125 
    11231126    if(!readReg(DICE_REGISTER_RX_PAR_SPACE_SZ, &m_rx_reg_size)) { 
    11241127        debugError("Could not initialize m_rx_reg_size\n"); 
     
    11261129    } 
    11271130    m_rx_reg_size*=4; 
    1128      
     1131 
    11291132    if(!readReg(DICE_REGISTER_UNUSED1_SPACE_OFF, &m_unused1_reg_offset)) { 
    11301133        debugError("Could not initialize m_unused1_reg_offset\n"); 
     
    11321135    } 
    11331136    m_unused1_reg_offset*=4; 
    1134      
     1137 
    11351138    if(!readReg(DICE_REGISTER_UNUSED1_SPACE_SZ, &m_unused1_reg_size)) { 
    11361139        debugError("Could not initialize m_unused1_reg_size\n"); 
     
    11381141    } 
    11391142    m_unused1_reg_size*=4; 
    1140      
     1143 
    11411144    if(!readReg(DICE_REGISTER_UNUSED2_SPACE_OFF, &m_unused2_reg_offset)) { 
    11421145        debugError("Could not initialize m_unused2_reg_offset\n"); 
     
    11441147    } 
    11451148    m_unused2_reg_offset*=4; 
    1146      
     1149 
    11471150    if(!readReg(DICE_REGISTER_UNUSED2_SPACE_SZ, &m_unused2_reg_size)) { 
    11481151        debugError("Could not initialize m_unused2_reg_size\n"); 
     
    11601163    } 
    11611164    m_tx_size*=4; 
    1162      
     1165 
    11631166    if(!readReg(m_tx_reg_offset + DICE_REGISTER_RX_NB_RX, &m_nb_rx)) { 
    11641167        debugError("Could not initialize m_nb_rx\n"); 
     
    11701173    } 
    11711174    m_rx_size*=4; 
    1172      
     1175 
    11731176    debugOutput(DEBUG_LEVEL_VERBOSE,"DICE Parameter Space info:\n"); 
    11741177    debugOutput(DEBUG_LEVEL_VERBOSE," Global  : offset=%04X size=%04d\n", m_global_reg_offset, m_global_reg_size); 
     
    11791182    debugOutput(DEBUG_LEVEL_VERBOSE," UNUSED1 : offset=%04X size=%04d\n", m_unused1_reg_offset, m_unused1_reg_size); 
    11801183    debugOutput(DEBUG_LEVEL_VERBOSE," UNUSED2 : offset=%04X size=%04d\n", m_unused2_reg_offset, m_unused2_reg_size); 
    1181      
     1184 
    11821185    return true; 
    11831186} 
     
    11861189DiceAvDevice::readReg(fb_nodeaddr_t offset, fb_quadlet_t *result) { 
    11871190    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading base register offset 0x%08llX\n", offset); 
    1188      
     1191 
    11891192    if(offset >= DICE_INVALID_OFFSET) { 
    11901193        debugError("invalid offset: 0x%016llX\n", offset); 
    11911194        return false; 
    11921195    } 
    1193      
     1196 
    11941197    fb_nodeaddr_t addr=DICE_REGISTER_BASE + offset; 
    11951198    fb_nodeid_t nodeId=m_nodeId | 0xFFC0; 
    1196      
     1199 
    11971200    if(!m_p1394Service->read_quadlet( nodeId, addr, result ) ) { 
    11981201        debugError("Could not read from node 0x%04X addr 0x%012X\n", nodeId, addr); 
    11991202        return false; 
    12001203    } 
    1201      
     1204 
    12021205    *result=ntohl(*result); 
    1203      
     1206 
    12041207    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Read result: 0x%08X\n", *result); 
    1205     
     1208 
    12061209    return true; 
    12071210} 
     
    12091212bool 
    12101213DiceAvDevice::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", 
    12121215        offset, data); 
    1213      
     1216 
    12141217    if(offset >= DICE_INVALID_OFFSET) { 
    12151218        debugError("invalid offset: 0x%016llX\n", offset); 
    12161219        return false; 
    12171220    } 
    1218      
     1221 
    12191222    fb_nodeaddr_t addr=DICE_REGISTER_BASE + offset; 
    12201223    fb_nodeid_t nodeId=m_nodeId | 0xFFC0; 
    1221      
     1224 
    12221225    if(!m_p1394Service->write_quadlet( nodeId, addr, htonl(data) ) ) { 
    12231226        debugError("Could not write to node 0x%04X addr 0x%012X\n", nodeId, addr); 
     
    12271230} 
    12281231 
    1229 bool  
     1232bool 
    12301233DiceAvDevice::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", 
    12321235        offset, length); 
    1233      
     1236 
    12341237    if(offset >= DICE_INVALID_OFFSET) { 
    12351238        debugError("invalid offset: 0x%016llX\n", offset); 
    12361239        return false; 
    12371240    } 
    1238      
     1241 
    12391242    fb_nodeaddr_t addr=DICE_REGISTER_BASE + offset; 
    12401243    fb_nodeid_t nodeId=m_nodeId | 0xFFC0; 
    1241      
     1244 
    12421245    if(!m_p1394Service->read( nodeId, addr, length/4, data ) ) { 
    12431246        debugError("Could not read from node 0x%04X addr 0x%012llX\n", nodeId, addr); 
    12441247        return false; 
    12451248    } 
    1246      
     1249 
    12471250    for(unsigned int i=0;i<length/4;i++) { 
    12481251        *(data+i)=ntohl(*(data+i)); 
    12491252    } 
    1250      
     1253 
    12511254    return true; 
    12521255} 
    12531256 
    1254 bool  
     1257bool 
    12551258DiceAvDevice::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", 
    12571260        offset, length); 
    1258      
     1261 
    12591262    if(offset >= DICE_INVALID_OFFSET) { 
    12601263        debugError("invalid offset: 0x%016llX\n", offset); 
    12611264        return false; 
    12621265    } 
    1263      
     1266 
    12641267    fb_nodeaddr_t addr=DICE_REGISTER_BASE + offset; 
    12651268    fb_nodeid_t nodeId=m_nodeId | 0xFFC0; 
    1266      
     1269 
    12671270    fb_quadlet_t data_out[length/4]; 
    1268      
     1271 
    12691272    for(unsigned int i=0;i<length/4;i++) { 
    12701273        data_out[i]=ntohl(*(data+i)); 
    12711274    } 
    1272      
     1275 
    12731276    if(!m_p1394Service->write( nodeId, addr, length/4, data_out ) ) { 
    12741277        debugError("Could not write to node 0x%04X addr 0x%012llX\n", nodeId, addr); 
    12751278        return false; 
    12761279    } 
    1277      
     1280 
    12781281    return true; 
    12791282} 
     
    12891292bool 
    12901293DiceAvDevice::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", 
    12921295        offset, data); 
    12931296 
     
    12961299} 
    12971300 
    1298 bool  
     1301bool 
    12991302DiceAvDevice::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", 
    13011304        offset, length); 
    13021305 
     
    13051308} 
    13061309 
    1307 bool  
     1310bool 
    13081311DiceAvDevice::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", 
    13101313        offset, length); 
    13111314 
     
    13141317} 
    13151318 
    1316 fb_nodeaddr_t  
     1319fb_nodeaddr_t 
    13171320DiceAvDevice::globalOffsetGen(fb_nodeaddr_t offset, size_t length) { 
    13181321 
     
    13281331        return DICE_INVALID_OFFSET; 
    13291332    } 
    1330      
     1333 
    13311334    return offset; 
    13321335} 
     
    13351338DiceAvDevice::readTxReg(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *result) { 
    13361339    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading tx %d register offset 0x%04llX\n", i, offset); 
    1337      
     1340 
    13381341    fb_nodeaddr_t offset_tx=txOffsetGen(i, offset, sizeof(fb_quadlet_t)); 
    13391342    return readReg(m_tx_reg_offset + offset_tx, result); 
     
    13491352} 
    13501353 
    1351 bool  
     1354bool 
    13521355DiceAvDevice::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", 
    13541357        offset, length); 
    1355      
     1358 
    13561359    fb_nodeaddr_t offset_tx=txOffsetGen(i, offset, length); 
    13571360    return readRegBlock(m_tx_reg_offset + offset_tx, data, length); 
    13581361} 
    13591362 
    1360 bool  
     1363bool 
    13611364DiceAvDevice::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", 
    13631366        offset, length); 
    13641367 
     
    13671370} 
    13681371 
    1369 fb_nodeaddr_t  
     1372fb_nodeaddr_t 
    13701373DiceAvDevice::txOffsetGen(unsigned int i, fb_nodeaddr_t offset, size_t length) { 
    13711374    // registry offsets should always be smaller than 0x7FFFFFFF 
     
    14021405DiceAvDevice::readRxReg(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *result) { 
    14031406    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Reading rx %d register offset 0x%04llX\n", i, offset); 
    1404      
     1407 
    14051408    fb_nodeaddr_t offset_rx=rxOffsetGen(i, offset, sizeof(fb_quadlet_t)); 
    14061409    return readReg(m_rx_reg_offset + offset_rx, result); 
     
    14091412bool 
    14101413DiceAvDevice::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", 
    14121415        offset, data); 
    1413          
     1416 
    14141417    fb_nodeaddr_t offset_rx=rxOffsetGen(i, offset, sizeof(fb_quadlet_t)); 
    14151418    return writeReg(m_rx_reg_offset + offset_rx, data); 
    14161419} 
    14171420 
    1418 bool  
     1421bool 
    14191422DiceAvDevice::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", 
    14211424        offset, length); 
    1422      
     1425 
    14231426    fb_nodeaddr_t offset_rx=rxOffsetGen(i, offset, length); 
    14241427    return readRegBlock(m_rx_reg_offset + offset_rx, data, length); 
    14251428} 
    14261429 
    1427 bool  
     1430bool 
    14281431DiceAvDevice::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", 
    14301433        offset, length); 
    14311434 
     
    14341437} 
    14351438 
    1436 fb_nodeaddr_t  
     1439fb_nodeaddr_t 
    14371440DiceAvDevice::rxOffsetGen(unsigned int i, fb_nodeaddr_t offset, size_t length) { 
    14381441    // registry offsets should always be smaller than 0x7FFFFFFF 
     
    14691472 
    14701473DiceAvDevice::DiceNotifier::DiceNotifier(DiceAvDevice *d, nodeaddr_t start) 
    1471  : ARMHandler(start, DICE_NOTIFIER_BLOCK_LENGTH,  
     1474 : ARMHandler(start, DICE_NOTIFIER_BLOCK_LENGTH, 
    14721475              RAW1394_ARM_READ | RAW1394_ARM_WRITE | RAW1394_ARM_LOCK, 
    14731476              RAW1394_ARM_WRITE, 0) 
     
    14771480} 
    14781481 
    1479 DiceAvDevice::DiceNotifier::~DiceNotifier()  
     1482DiceAvDevice::DiceNotifier::~DiceNotifier() 
    14801483{ 
    14811484 
  • trunk/libffado/src/dice/dice_avdevice.h

    r436 r445  
    1 /* dice_avdevice.h 
    2  * Copyright (C) 2007 by Pieter Palmers 
     1/* 
     2 * Copyright (C) 2005-2007 by Pieter Palmers 
    33 * 
    4  * This file is part of FreeBob. 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    56 * 
    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, 
    1114 * 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. 
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     16 * Lesser General Public License for more details. 
    1417 * 
    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. 
     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 
    1922 */ 
     23 
    2024#ifndef DICEDEVICE_H 
    2125#define DICEDEVICE_H 
     
    6973 
    7074    bool prepare(); 
    71      
     75 
    7276    bool lock(); 
    7377    bool unlock(); 
    74      
     78 
    7579    bool startStreamByIndex(int i); 
    7680    bool stopStreamByIndex(int i); 
    77      
     81 
    7882    bool enableStreaming(); 
    7983    bool disableStreaming(); 
    80      
     84 
    8185protected: 
    8286    struct VendorModelEntry *m_model; 
    83      
     87 
    8488    // streaming stuff 
    8589    typedef std::vector< Streaming::StreamProcessor * > StreamProcessorVector; 
    8690    StreamProcessorVector m_receiveProcessors; 
    8791    StreamProcessorVector m_transmitProcessors; 
    88      
     92 
    8993private: // streaming & port helpers 
    9094    enum EPortTypes { 
     
    9296        ePT_MIDI, 
    9397    }; 
    94      
     98 
    9599    typedef struct { 
    96100        std::string name; 
     
    98102        unsigned int streamPosition; 
    99103        unsigned int streamLocation; 
    100     } diceChannelInfo;  
    101      
    102     bool addChannelToProcessor( diceChannelInfo *,  
    103                               Streaming::StreamProcessor *,  
     104    } diceChannelInfo; 
     105 
     106    bool addChannelToProcessor( diceChannelInfo *, 
     107                              Streaming::StreamProcessor *, 
    104108                              Streaming::Port::E_Direction direction); 
    105      
     109 
    106110    int allocateIsoChannel(unsigned int packet_size); 
    107111    bool deallocateIsoChannel(int channel); 
    108      
     112 
    109113private: // helper functions 
    110114    bool enableIsoStreaming(); 
    111115    bool disableIsoStreaming(); 
    112116    bool isIsoStreamingEnabled(); 
    113      
     117 
    114118    bool maskedCheckZeroGlobalReg(fb_nodeaddr_t offset, fb_quadlet_t mask); 
    115119    bool maskedCheckNotZeroGlobalReg(fb_nodeaddr_t offset, fb_quadlet_t mask); 
    116      
     120 
    117121    typedef std::vector< std::string > diceNameVector; 
    118122    typedef std::vector< std::string >::iterator diceNameVectorIterator; 
     
    122126    diceNameVector getClockSourceNameString(); 
    123127    std::string getDeviceNickName(); 
    124      
     128 
    125129private: // register I/O routines 
    126130    bool initIoFunctions(); 
     
    130134    bool readRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t); 
    131135    bool writeRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t); 
    132      
     136 
    133137    bool readGlobalReg(fb_nodeaddr_t, fb_quadlet_t *); 
    134138    bool writeGlobalReg(fb_nodeaddr_t, fb_quadlet_t); 
     
    136140    bool writeGlobalRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t); 
    137141    fb_nodeaddr_t globalOffsetGen(fb_nodeaddr_t, size_t); 
    138      
     142 
    139143    bool readTxReg(unsigned int i, fb_nodeaddr_t, fb_quadlet_t *); 
    140144    bool writeTxReg(unsigned int i, fb_nodeaddr_t, fb_quadlet_t); 
     
    142146    bool writeTxRegBlock(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length); 
    143147    fb_nodeaddr_t txOffsetGen(unsigned int, fb_nodeaddr_t, size_t); 
    144      
     148 
    145149    bool readRxReg(unsigned int i, fb_nodeaddr_t, fb_quadlet_t *); 
    146150    bool writeRxReg(unsigned int i, fb_nodeaddr_t, fb_quadlet_t); 
     
    148152    bool writeRxRegBlock(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length); 
    149153    fb_nodeaddr_t rxOffsetGen(unsigned int, fb_nodeaddr_t, size_t); 
    150      
     154 
    151155    fb_quadlet_t m_global_reg_offset; 
    152156    fb_quadlet_t m_global_reg_size; 
     
    159163    fb_quadlet_t m_unused2_reg_offset; 
    160164    fb_quadlet_t m_unused2_reg_size; 
    161      
     165 
    162166    fb_quadlet_t m_nb_tx; 
    163167    fb_quadlet_t m_tx_size; 
    164168    fb_quadlet_t m_nb_rx; 
    165169    fb_quadlet_t m_rx_size; 
    166      
     170 
    167171private: 
    168172    // notification 
    169173    DiceNotifier *m_notifier; 
    170      
     174 
    171175    /** 
    172      * this class reacts on the DICE device writing to the  
     176     * this class reacts on the DICE device writing to the 
    173177     * hosts notify address 
    174178     */ 
     
    180184        DiceNotifier(DiceAvDevice *, nodeaddr_t start); 
    181185        virtual ~DiceNotifier(); 
    182          
     186 
    183187    private: 
    184188        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, 
    1114 * 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. 
     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 
    1922 */ 
     23 
    2024#ifndef DICEDEFINES_H 
    2125#define DICEDEFINES_H 
     
    2327#define DICE_VER_1_0_4_0 
    2428// #define DICE_VER_1_0_7_0 
    25  
    2629 
    2730#define DICE_INVALID_OFFSET                  0xFFFFF00000000000ULL 
     
    138141// the format of the user messages 
    139142// 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 
    143146//  movements)." 
    144147 
     
    161164#define DICE_NOTIFY_USER_GET_MESSAGE(x) \ 
    162165                ( ((x) >> 24 ) & 0xFF ) 
    163                  
     166 
    164167//   NICK_NAME register 
    165168 
  • trunk/libffado/src/fbtypes.h

    r336 r445  
    11/* fbtypes.h 
    2  * Copyright (C) 2005 by Daniel Wagner 
     2 * Copyright (C) 2005-2007 by by Daniel Wagner 
    33 * 
    4  * This file is part of FreeBoB. 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    56 * 
    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, 
    1114 * 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. 
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     16 * Lesser General Public License for more details. 
    1417 * 
    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. 
     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 
    1922 */ 
    20   
     23 
    2124#ifndef FBTYPES_H 
    2225#define FBTYPES_H 
    23   
     26 
    2427#include <libraw1394/raw1394.h> 
    25   
     28 
    2629typedef quadlet_t   fb_quadlet_t; 
    2730typedef byte_t      fb_byte_t; 
     
    3235class DeviceManager; 
    3336 
    34 struct freebob_handle { 
     37struct ffado_handle { 
    3538    DeviceManager*   m_deviceManager; 
    3639}; 
  • 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 
    34 * 
    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 
    59 * 
    610 * This library is free software; you can redistribute it and/or 
    711 * 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; 
    1013 * 
    1114 * This library is distributed in the hope that it will be useful, 
     
    2225#include "config.h" 
    2326 
    24 #include "libfreebob/freebob.h" 
     27#include "libffado/ffado.h" 
    2528 
    2629#include "debugmodule/debugmodule.h" 
     
    3639 
    3740DECLARE_GLOBAL_DEBUG_MODULE; 
    38 IMPL_GLOBAL_DEBUG_MODULE( FreeBoB, DEBUG_LEVEL_VERBOSE ); 
     41IMPL_GLOBAL_DEBUG_MODULE( FFADO, DEBUG_LEVEL_VERBOSE ); 
    3942 
    4043#ifdef __cplusplus 
     
    4245#endif 
    4346 
    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 
    4750 
    4851static void exitfunc(void) __attribute__((destructor)); 
     
    5861 
    5962const char* 
    60 freebob_get_version() { 
     63ffado_get_version() { 
    6164    return PACKAGE_STRING; 
    6265} 
     
    6467 
    6568int 
    66 freebob_get_api_version() { 
    67     return FREEBOB_API_VERSION; 
     69ffado_get_api_version() { 
     70    return FFADO_API_VERSION; 
    6871} 
    6972 
    70 freebob_handle_t 
    71 freebob_new_handle( int port ) 
     73ffado_handle_t 
     74ffado_new_handle( int port ) 
    7275{ 
    73     freebob_handle_t handle = new struct freebob_handle; 
     76    ffado_handle_t handle = new struct ffado_handle; 
    7477    if (! handle ) { 
    7578        debugFatal( "Could not allocate memory for new handle\n" ); 
     
    9396 
    9497int 
    95 freebob_destroy_handle( freebob_handle_t freebob_handle ) 
     98ffado_destroy_handle( ffado_handle_t ffado_handle ) 
    9699{ 
    97     delete freebob_handle->m_deviceManager; 
    98     delete freebob_handle; 
     100    delete ffado_handle->m_deviceManager; 
     101    delete ffado_handle; 
    99102    return 0; 
    100103} 
    101104 
    102105int 
    103 freebob_discover_devices( freebob_handle_t freebob_handle, int verbose ) 
     106ffado_discover_devices( ffado_handle_t ffado_handle, int verbose ) 
    104107{ 
    105108    if (verbose) { 
    106         freebob_handle->m_deviceManager->setVerboseLevel(DEBUG_LEVEL_VERBOSE); 
     109        ffado_handle->m_deviceManager->setVerboseLevel(DEBUG_LEVEL_VERBOSE); 
    107110   } 
    108     return freebob_handle->m_deviceManager->discover()? 0 : -1; 
     111    return ffado_handle->m_deviceManager->discover()? 0 : -1; 
    109112} 
    110113 
    111114int 
    112 freebob_node_is_valid_freebob_device( freebob_handle_t freebob_handle, int node_id ) 
     115ffado_node_is_valid_ffado_device( ffado_handle_t ffado_handle, int node_id ) 
    113116{ 
    114     return freebob_handle->m_deviceManager->isValidNode( node_id ); 
     117    return ffado_handle->m_deviceManager->isValidNode( node_id ); 
    115118} 
    116119 
    117120int 
    118 freebob_get_nb_devices_on_bus( freebob_handle_t freebob_handle ) 
     121ffado_get_nb_devices_on_bus( ffado_handle_t ffado_handle ) 
    119122{ 
    120     return freebob_handle->m_deviceManager->getNbDevices(); 
     123    return ffado_handle->m_deviceManager->getNbDevices(); 
    121124} 
    122125 
    123126int 
    124 freebob_get_device_node_id( freebob_handle_t freebob_handle, int device_nr ) 
     127ffado_get_device_node_id( ffado_handle_t ffado_handle, int device_nr ) 
    125128{ 
    126     return freebob_handle->m_deviceManager->getDeviceNodeId(device_nr); 
     129    return ffado_handle->m_deviceManager->getDeviceNodeId(device_nr); 
    127130} 
    128131 
    129132int 
    130 freebob_set_samplerate( freebob_handle_t freebob_handle, int node_id, int samplerate ) 
     133ffado_set_samplerate( ffado_handle_t ffado_handle, int node_id, int samplerate ) 
    131134{ 
    132     IAvDevice* avDevice = freebob_handle->m_deviceManager->getAvDevice( node_id ); 
     135    IAvDevice* avDevice = ffado_handle->m_deviceManager->getAvDevice( node_id ); 
    133136    if ( avDevice ) { 
    134137        if ( avDevice->setSamplingFrequency( parseSampleRate( samplerate ) ) ) { 
    135             return freebob_handle->m_deviceManager->discover()? 0 : -1; 
     138            return ffado_handle->m_deviceManager->discover()? 0 : -1; 
    136139        } 
    137140    } 
     
    139142} 
    140143 
    141 void freebob_sleep_after_avc_command( int time ) 
     144void ffado_sleep_after_avc_command( int time ) 
    142145{ 
    143146    AVCCommand::setSleepAfterAVCCommand( time ); 
  • trunk/libffado/src/ffado_streaming.cpp

    r442 r445  
    1 /* $Id$ */ 
    2  
    31/* 
    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" 
    3729#include "devicemanager.h" 
    3830#include "iavdevice.h" 
     
    5345using namespace Streaming; 
    5446 
    55 struct _freebob_device 
     47struct _ffado_device 
    5648{ 
    5749    DeviceManager * m_deviceManager; 
    5850    StreamProcessorManager *processorManager; 
    5951 
    60     freebob_options_t options; 
    61     freebob_device_info_t device_info; 
    62 };  
    63  
    64 freebob_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 
     56ffado_device_t *ffado_streaming_init (ffado_device_info_t *device_info, ffado_options_t options) { 
    6557    unsigned int i=0; 
    6658 
    67     struct _freebob_device *dev = new struct _freebob_device; 
    68  
    69     debugFatal("%s built %s %s\n", freebob_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__); 
    7062 
    7163    if(!dev) { 
     
    8375            return 0; 
    8476    } 
    85      
     77 
    8678    dev->m_deviceManager->setVerboseLevel(DEBUG_LEVEL_VERBOSE); 
    8779    if ( !dev->m_deviceManager->initialize( dev->options.port ) ) { 
     
    9385 
    9486    // create a processor manager to manage the actual stream 
    95     // processors       
     87    // processors 
    9688    dev->processorManager = new StreamProcessorManager(dev->options.period_size,dev->options.nb_buffers); 
    9789    if(!dev->processorManager) { 
     
    10193            return 0; 
    10294    } 
    103      
     95 
    10496    dev->processorManager->setThreadParameters(dev->options.realtime, dev->options.packetizer_priority); 
    105      
     97 
    10698    dev->processorManager->setVerboseLevel(DEBUG_LEVEL_VERBOSE); 
    10799    if(!dev->processorManager->init()) { 
     
    112104            return 0; 
    113105    } 
    114      
     106 
    115107    // set slave mode option 
    116108    bool slaveMode=(dev->options.slave_mode != 0); 
     
    125117            debugWarning("Failed to set snoop mode option\n"); 
    126118    } 
    127      
     119 
    128120    // discover the devices on the bus 
    129121    if(!dev->m_deviceManager->discover()) { 
     
    134126            return 0; 
    135127    } 
    136      
     128 
    137129    // are there devices on the bus? 
    138130    if(dev->m_deviceManager->getAvDeviceCount()==0) { 
     
    143135            return 0; 
    144136    } 
    145      
     137 
    146138    // iterate over the found devices 
    147139    // add the stream processors of the devices to the managers 
     
    151143 
    152144        debugOutput(DEBUG_LEVEL_VERBOSE, "Locking device (%p)\n", device); 
    153          
     145 
    154146        if (!device->lock()) { 
    155147            debugWarning("Could not lock device, skipping device (%p)!\n", device); 
    156148            continue; 
    157149        } 
    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", 
    160152                    dev->options.sample_rate, device); 
    161                      
     153 
    162154        // Set the device's sampling rate to that requested 
    163155        // FIXME: does this really belong here?  If so we need to handle errors. 
    164156        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", 
    166158                        dev->options.sample_rate, device); 
    167          
     159 
    168160            // try again: 
    169161            if (!device->setSamplingFrequency(parseSampleRate(dev->options.sample_rate))) { 
     
    188180        } 
    189181    } 
    190      
     182 
    191183    // set the sync source 
    192184    if (!dev->processorManager->setSyncSource(dev->m_deviceManager->getSyncSource())) { 
     
    201193} 
    202194 
    203 int freebob_streaming_prepare(freebob_device_t *dev) { 
     195int ffado_streaming_prepare(ffado_device_t *dev) { 
    204196    debugOutput(DEBUG_LEVEL_VERBOSE, "Preparing...\n"); 
    205          
     197 
    206198    if (!dev->processorManager->prepare()) { 
    207199        debugFatal("Could not prepare streaming...\n"); 
     
    212204} 
    213205 
    214 void freebob_streaming_finish(freebob_device_t *dev) { 
     206void ffado_streaming_finish(ffado_device_t *dev) { 
    215207    unsigned int i=0; 
    216      
     208 
    217209    assert(dev); 
    218      
     210 
    219211    // iterate over the found devices 
    220212    for(i=0;i<dev->m_deviceManager->getAvDeviceCount();i++) { 
     
    228220        } 
    229221    } 
    230      
     222 
    231223    delete dev->processorManager; 
    232224    delete dev->m_deviceManager; 
     
    236228} 
    237229 
    238 int freebob_streaming_start(freebob_device_t *dev) { 
     230int ffado_streaming_start(ffado_device_t *dev) { 
    239231    unsigned int i=0; 
    240232    debugOutput(DEBUG_LEVEL_VERBOSE,"------------- Start -------------\n"); 
    241      
     233 
    242234    // create the connections for all devices 
    243235    // iterate over the found devices 
     
    246238        IAvDevice *device=dev->m_deviceManager->getAvDeviceByIndex(i); 
    247239        assert(device); 
    248      
     240 
    249241        int j=0; 
    250242        for(j=0; j<device->getStreamCount();j++) { 
     
    265257        return 0; 
    266258    } else { 
    267         freebob_streaming_stop(dev); 
    268         return -1; 
    269     } 
    270 } 
    271  
    272 int freebob_streaming_stop(freebob_device_t *dev) { 
     259        ffado_streaming_stop(dev); 
     260        return -1; 
     261    } 
     262} 
     263 
     264int ffado_streaming_stop(ffado_device_t *dev) { 
    273265    unsigned int i; 
    274266    debugOutput(DEBUG_LEVEL_VERBOSE,"------------- Stop -------------\n"); 
     
    286278            debugWarning("Could not disable streaming on device %d!\n",i); 
    287279        } 
    288          
     280 
    289281        int j=0; 
    290282        for(j=0; j<device->getStreamCount();j++) { 
     
    302294} 
    303295 
    304 int freebob_streaming_reset(freebob_device_t *dev) { 
     296int ffado_streaming_reset(ffado_device_t *dev) { 
    305297    debugOutput(DEBUG_LEVEL_VERBOSE,"------------- Reset -------------\n"); 
    306298 
     
    310302} 
    311303 
    312 int freebob_streaming_wait(freebob_device_t *dev) { 
     304int ffado_streaming_wait(ffado_device_t *dev) { 
    313305    static int periods=0; 
    314306    static int periods_print=0; 
    315307    static int xruns=0; 
    316      
     308 
    317309    periods++; 
    318310    if(periods>periods_print) { 
    319         debugOutputShort(DEBUG_LEVEL_VERBOSE, "\nfreebob_streaming_wait\n"); 
     311        debugOutputShort(DEBUG_LEVEL_VERBOSE, "\nffado_streaming_wait\n"); 
    320312        debugOutputShort(DEBUG_LEVEL_VERBOSE, "============================================\n"); 
    321313        debugOutputShort(DEBUG_LEVEL_VERBOSE, "Xruns: %d\n",xruns); 
     
    325317        periods_print+=100; 
    326318    } 
    327      
     319 
    328320    if(dev->processorManager->waitForPeriod()) { 
    329321        return dev->options.period_size; 
    330322    } else { 
    331323        debugWarning("XRUN detected\n"); 
    332          
     324 
    333325        // do xrun recovery 
    334326        dev->processorManager->handleXrun(); 
     
    338330} 
    339331 
    340 int freebob_streaming_transfer_capture_buffers(freebob_device_t *dev) { 
     332int ffado_streaming_transfer_capture_buffers(ffado_device_t *dev) { 
    341333    return dev->processorManager->transfer(StreamProcessor::E_Receive); 
    342334} 
    343335 
    344 int freebob_streaming_transfer_playback_buffers(freebob_device_t *dev) { 
     336int ffado_streaming_transfer_playback_buffers(ffado_device_t *dev) { 
    345337    return dev->processorManager->transfer(StreamProcessor::E_Transmit); 
    346338} 
    347339 
    348 int freebob_streaming_transfer_buffers(freebob_device_t *dev) { 
     340int ffado_streaming_transfer_buffers(ffado_device_t *dev) { 
    349341    return dev->processorManager->transfer(); 
    350342} 
    351343 
    352344 
    353 int freebob_streaming_write(freebob_device_t *dev, int i, freebob_sample_t *buffer, int nsamples) { 
     345int ffado_streaming_write(ffado_device_t *dev, int i, ffado_sample_t *buffer, int nsamples) { 
    354346    Port *p=dev->processorManager->getPortByIndex(i, Port::E_Playback); 
    355     // use an assert here performancewise,  
     347    // use an assert here performancewise, 
    356348    // it should already have failed before, if not correct 
    357     assert(p);  
    358          
     349    assert(p); 
     350 
    359351    return p->writeEvents((void *)buffer, nsamples); 
    360352} 
    361353 
    362 int freebob_streaming_read(freebob_device_t *dev, int i, freebob_sample_t *buffer, int nsamples) { 
     354int ffado_streaming_read(ffado_device_t *dev, int i, ffado_sample_t *buffer, int nsamples) { 
    363355    Port *p=dev->processorManager->getPortByIndex(i, Port::E_Capture); 
    364     // use an assert here performancewise,  
     356    // use an assert here performancewise, 
    365357    // it should already have failed before, if not correct 
    366     assert(p);  
    367          
     358    assert(p); 
     359 
    368360    return p->readEvents((void *)buffer, nsamples); 
    369361} 
    370362 
    371 int freebob_streaming_get_nb_capture_streams(freebob_device_t *dev) { 
     363int ffado_streaming_get_nb_capture_streams(ffado_device_t *dev) { 
    372364    return dev->processorManager->getPortCount(Port::E_Capture); 
    373365} 
    374366 
    375 int freebob_streaming_get_nb_playback_streams(freebob_device_t *dev) { 
     367int ffado_streaming_get_nb_playback_streams(ffado_device_t *dev) { 
    376368    return dev->processorManager->getPortCount(Port::E_Playback); 
    377369} 
    378370 
    379 int freebob_streaming_get_capture_stream_name(freebob_device_t *dev, int i, char* buffer, size_t buffersize) { 
     371int ffado_streaming_get_capture_stream_name(ffado_device_t *dev, int i, char* buffer, size_t buffersize) { 
    380372    Port *p=dev->processorManager->getPortByIndex(i, Port::E_Capture); 
    381373    if(!p) { 
     
    391383} 
    392384 
    393 int freebob_streaming_get_playback_stream_name(freebob_device_t *dev, int i, char* buffer, size_t buffersize) { 
     385int ffado_streaming_get_playback_stream_name(ffado_device_t *dev, int i, char* buffer, size_t buffersize) { 
    394386    Port *p=dev->processorManager->getPortByIndex(i, Port::E_Playback); 
    395387    if(!p) { 
     
    405397} 
    406398 
    407 freebob_streaming_stream_type freebob_streaming_get_capture_stream_type(freebob_device_t *dev, int i) { 
     399ffado_streaming_stream_type ffado_streaming_get_capture_stream_type(ffado_device_t *dev, int i) { 
    408400    Port *p=dev->processorManager->getPortByIndex(i, Port::E_Capture); 
    409401    if(!p) { 
    410402        debugWarning("Could not get capture port at index %d\n",i); 
    411         return freebob_stream_type_invalid; 
     403        return ffado_stream_type_invalid; 
    412404    } 
    413405    switch(p->getPortType()) { 
    414406    case Port::E_Audio: 
    415         return freebob_stream_type_audio; 
     407        return ffado_stream_type_audio; 
    416408    case Port::E_Midi: 
    417         return freebob_stream_type_midi; 
     409        return ffado_stream_type_midi; 
    418410    case Port::E_Control: 
    419         return freebob_stream_type_control; 
     411        return ffado_stream_type_control; 
    420412    default: 
    421         return freebob_stream_type_unknown; 
    422     } 
    423 } 
    424  
    425 freebob_streaming_stream_type freebob_streaming_get_playback_stream_type(freebob_device_t *dev, int i) { 
     413        return ffado_stream_type_unknown; 
     414    } 
     415} 
     416 
     417ffado_streaming_stream_type ffado_streaming_get_playback_stream_type(ffado_device_t *dev, int i) { 
    426418    Port *p=dev->processorManager->getPortByIndex(i, Port::E_Playback); 
    427419    if(!p) { 
    428420        debugWarning("Could not get playback port at index %d\n",i); 
    429         return freebob_stream_type_invalid; 
     421        return ffado_stream_type_invalid; 
    430422    } 
    431423    switch(p->getPortType()) { 
    432424    case Port::E_Audio: 
    433         return freebob_stream_type_audio; 
     425        return ffado_stream_type_audio; 
    434426    case Port::E_Midi: 
    435         return freebob_stream_type_midi; 
     427        return ffado_stream_type_midi; 
    436428    case Port::E_Control: 
    437         return freebob_stream_type_control; 
     429        return ffado_stream_type_control; 
    438430    default: 
    439         return freebob_stream_type_unknown; 
    440     } 
    441 } 
    442  
    443 int freebob_streaming_set_stream_buffer_type(freebob_device_t *dev, int i,  
    444     freebob_streaming_buffer_type t, enum Port::E_Direction direction) { 
     431        return ffado_stream_type_unknown; 
     432    } 
     433} 
     434 
     435int ffado_streaming_set_stream_buffer_type(ffado_device_t *dev, int i, 
     436    ffado_streaming_buffer_type t, enum Port::E_Direction direction) { 
    445437 
    446438    Port *p=dev->processorManager->getPortByIndex(i, direction); 
     
    450442        return -1; 
    451443    } 
    452          
     444 
    453445    switch(t) { 
    454     case freebob_buffer_type_int24: 
     446    case ffado_buffer_type_int24: 
    455447        if (!p->setDataType(Port::E_Int24)) { 
    456448            debugWarning("%s: Could not set data type to Int24\n",p->getName().c_str()); 
     
    462454        } 
    463455        break; 
    464     case freebob_buffer_type_float: 
     456    case ffado_buffer_type_float: 
    465457        if (!p->setDataType(Port::E_Float)) { 
    466458            debugWarning("%s: Could not set data type to Float\n",p->getName().c_str()); 
     
    472464        } 
    473465        break; 
    474     case freebob_buffer_type_midi: 
     466    case ffado_buffer_type_midi: 
    475467        if (!p->setDataType(Port::E_MidiEvent)) { 
    476468            debugWarning("%s: Could not set data type to MidiEvent\n",p->getName().c_str()); 
     
    490482} 
    491483 
    492 int freebob_streaming_set_playback_buffer_type(freebob_device_t *dev, int i, freebob_streaming_buffer_type t) { 
    493     return freebob_streaming_set_stream_buffer_type(dev, i, t, Port::E_Playback); 
    494 } 
    495  
    496 int freebob_streaming_set_capture_buffer_type(freebob_device_t *dev, int i, freebob_streaming_buffer_type t) { 
    497     return freebob_streaming_set_stream_buffer_type(dev, i, t, Port::E_Capture); 
    498 } 
    499  
    500 int freebob_streaming_stream_onoff(freebob_device_t *dev, int i,  
     484int 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 
     488int 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 
     492int ffado_streaming_stream_onoff(ffado_device_t *dev, int i, 
    501493    int on, enum Port::E_Direction direction) { 
    502494    Port *p=dev->processorManager->getPortByIndex(i, direction); 
     
    514506} 
    515507 
    516 int freebob_streaming_playback_stream_onoff(freebob_device_t *dev, int number, int on) { 
    517     return freebob_streaming_stream_onoff(dev, number, on, Port::E_Playback); 
    518 } 
    519  
    520 int freebob_streaming_capture_stream_onoff(freebob_device_t *dev, int number, int on) { 
    521     return freebob_streaming_stream_onoff(dev, number, on, Port::E_Capture); 
     508int 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 
     512int 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); 
    522514} 
    523515 
    524516// TODO: the way port buffers are set in the C api doesn't satisfy me 
    525 int freebob_streaming_set_capture_stream_buffer(freebob_device_t *dev, int i, char *buff) { 
     517int ffado_streaming_set_capture_stream_buffer(ffado_device_t *dev, int i, char *buff) { 
    526518        Port *p=dev->processorManager->getPortByIndex(i, Port::E_Capture); 
    527          
    528         // use an assert here performancewise,  
     519 
     520        // use an assert here performancewise, 
    529521        // it should already have failed before, if not correct 
    530         assert(p);  
    531          
     522        assert(p); 
     523 
    532524        p->useExternalBuffer(true); 
    533525        p->setExternalBufferAddress((void *)buff); 
     
    537529} 
    538530 
    539 int freebob_streaming_set_playback_stream_buffer(freebob_device_t *dev, int i, char *buff) { 
     531int ffado_streaming_set_playback_stream_buffer(ffado_device_t *dev, int i, char *buff) { 
    540532        Port *p=dev->processorManager->getPortByIndex(i, Port::E_Playback); 
    541         // use an assert here performancewise,  
     533        // use an assert here performancewise, 
    542534        // it should already have failed before, if not correct 
    543         assert(p);  
    544          
     535        assert(p); 
     536 
    545537        p->useExternalBuffer(true); 
    546538        p->setExternalBufferAddress((void *)buff); 
  • trunk/libffado/src/iavdevice.cpp

    r436 r445  
    1 /* iavdevice.h 
    2  * Copyright (C) 2006 by Daniel Wagner 
    3  * Copyright (C) 2007 by Pieter Palmers 
     1/* 
     2 * Copyright (C) 2005-2007 by Daniel Wagner 
     3 * Copyright (C) 2005-2007 by Pieter Palmers 
    44 * 
    5  * This file is part of FreeBoB. 
     5 * This file is part of FFADO 
     6 * FFADO = Free Firewire (pro-)audio drivers for linux 
    67 * 
    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, 
    1215 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    14  * GNU General Public License for more details. 
     16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     17 * Lesser General Public License for more details. 
    1518 * 
    16  * You should have received a copy of the GNU General Public License 
    17  * along with FreeBoB; if not, write to the Free Software 
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
    19  * MA 02111-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 
    2023 */ 
    2124 
     
    4043{ 
    4144    addOption(Util::OptionContainer::Option("id",std::string("dev?"))); 
    42      
     45 
    4346    std::ostringstream nodestr; 
    4447    nodestr << "node" << nodeId; 
    4548    setOscBase(nodestr.str()); 
    4649    ConfigRom& c = getConfigRom(); 
    47      
     50 
    4851    addChildOscNode(&c); 
    4952} 
     
    6871 
    6972void 
    70 IAvDevice::setVerboseLevel(int l)  
     73IAvDevice::setVerboseLevel(int l) 
    7174{ 
    7275    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, 
    1115 * 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. 
     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 
    1923 */ 
    2024 
     
    3539@brief Base class for device support 
    3640 
    37  This class should be subclassed to implement freebob support  
     41 This class should be subclassed to implement ffado support 
    3842 for a specific device. 
    3943 
    4044*/ 
    41 class IAvDevice  
     45class IAvDevice 
    4246    : public Util::OptionContainer, 
    4347      public OSC::OscNode 
    4448{ 
    4549public: 
    46        IAvDevice( std::auto_ptr< ConfigRom >( configRom ), 
     50    IAvDevice( std::auto_ptr< ConfigRom >( configRom ), 
    4751                    Ieee1394Service& ieee1394service, 
    4852                    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 device 
    57          *  
    58         * @return true if the device was discovered successfuly 
    59         */ 
    60        virtual bool discover() = 0; 
    61          
    62        /** 
    63         * @brief Set the samping frequency 
    64          * @param samplingFrequency  
    65         * @return true if successful 
    66         */ 
    67        virtual bool setSamplingFrequency( ESamplingFrequency samplingFrequency ) = 0; 
    68        /** 
    69         * @brief get the samplingfrequency as an integer 
    70         * @return the sampling frequency as integer 
    71         */ 
    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 
    7478    /** 
    7579     * @brief This is called by the device manager to give the device a unique ID. 
     
    8791     * 
    8892     * @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 
    9094     *       device list. Therefore it is dependant on the order 
    9195     *       in which the devices are detected. The side-effect 
     
    9397     *       and history (e.g. busresets etc). This makes that 
    9498     *       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 
    96100     *       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 
    100104     * @return true if successful 
    101105     */ 
    102106    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 device 
    114        
    115         * This is called by the streaming layer before we start manipulating 
    116         * 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 not 
    122         */ 
    123        virtual bool lock() = 0; 
    124          
    125         /**  
    126         * @brief Unlock the device 
    127        
    128         * This is called by the streaming layer after we finish manipulating 
    129         * 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 not 
    135         */ 
    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    /** 
    139143     * @brief Enable streaming on all 'started' streams 
    140144     * 
     
    146150     */ 
    147151    virtual bool enableStreaming(); 
    148      
    149     /**  
     152 
     153    /** 
    150154     * @brief Disable streaming on all streams 
    151155     * 
     
    158162    virtual bool disableStreaming(); 
    159163 
    160         /**  
    161         * @brief Prepare the device 
    162        
    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 streamprocessors 
    168         * based upon the device's current configuration. Normally 
    169         * the streaming layer will not change the device's configuration 
    170         * after calling this function. 
    171        
    172         * @return true if successful, false if not 
    173         */ 
    174        virtual bool prepare() = 0; 
    175          
    176        /** 
    177         * @brief Returns the number of ISO streams implemented/used by this device 
    178        
    179         * Most likely this is 2 streams, i.e. one transmit stream and one 
    180          * 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 source 
    184         *   for the device. 
    185        
    186         * @note you have to have a StreamProcessor for every stream. I.e. 
    187         *       getStreamProcessorByIndex(i) should return a valid StreamProcessor 
    188         *       for i=0 to i=getStreamCount()-1 
    189        
    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 i 
    196        
    197         * @note a streamprocessor returned by getStreamProcessorByIndex(i) 
    198         *       cannot be the same object as one returned by 
    199         *       getStreamProcessorByIndex(j) if i isn't equal to j 
    200         * @note you cannot have two streamprocessors handling the same ISO 
    201         *       channel (on the same port) 
    202        
    203         * @param i : Stream index 
    204         * @pre @ref i smaller than getStreamCount() 
    205         * @return a StreamProcessor object if successful, NULL otherwise 
    206         */ 
    207        virtual Streaming::StreamProcessor *getStreamProcessorByIndex(int i) = 0; 
    208          
    209         /**  
    210         * @brief starts the stream with index i 
    211        
    212         * This function is called by the streaming layer when this stream should 
    213          * 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 the 
    218         * Ieee1394Service object that is passed in the constructor. 
    219        
    220         * @param i : Stream index 
    221         * @pre @ref i smaller than getStreamCount() 
    222         * @return true if successful, false if not 
    223         */ 
    224        virtual bool startStreamByIndex(int i) = 0; 
    225          
    226         /**  
    227         * @brief stops the stream with index @ref i 
    228        
    229         * @param i : Stream index 
    230         * @pre @ref i smaller than getStreamCount() 
    231         * @return true if successful, false if not 
    232         */ 
    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; 
    234238 
    235239    /** 
  • trunk/libffado/src/libavc/avc_connect.cpp

    r413 r445  
    1 /* avc_connect.cpp 
    2  * Copyright (C) 2005 by Daniel Wagner 
     1/* 
     2 * Copyright (C) 2005-2007 by Daniel Wagner 
    33 * 
    4  * This file is part of FreeBoB. 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    56 * 
    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, 
    1114 * 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. 
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     16 * Lesser General Public License for more details. 
    1417 * 
    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. 
     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 
    1922 */ 
    2023 
  • trunk/libffado/src/libavc/avc_connect.h

    r375 r445  
    1 /* avc_connect.h 
    2  * Copyright (C) 2005 by Daniel Wagner 
     1/* 
     2 * Copyright (C) 2005-2007 by Daniel Wagner 
    33 * 
    4  * This file is part of FreeBoB. 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    56 * 
    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, 
    1114 * 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. 
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     16 * Lesser General Public License for more details. 
    1417 * 
    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. 
     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 
    1922 */ 
    2023 
    21 #ifndef AVCConnect_h 
    22 #define AVCConnect_h 
     24#ifndef AVCCONNECT_H 
     25#define AVCCONNECT_H 
    2326 
    2427#include "avc_generic.h" 
     
    3639 
    3740    virtual const char* getCmdName() const 
    38        { return "ConnectCmd"; } 
     41    { return "ConnectCmd"; } 
    3942}; 
    4043 
    4144 
    42 #endif // AVCConnect_h 
     45#endif // AVCCONNECT_H 
  • trunk/libffado/src/libavc/avc_definitions.cpp

    r415 r445  
    1 /* avc_defintions.cpp 
    2  * Copyright (C) 2005 by Daniel Wagner 
     1/* 
     2 * Copyright (C) 2005-2007 by Daniel Wagner 
    33 * 
    4  * This file is part of FreeBoB. 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    56 * 
    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, 
    1114 * 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. 
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     16 * Lesser General Public License for more details. 
    1417 * 
    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. 
     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 
    1922 */ 
    2023 
  • trunk/libffado/src/libavc/avc_definitions.h

    r415 r445  
    1 /* avc_definitions.h 
    2  * Copyright (C) 2005 by Daniel Wagner 
     1/* 
     2 * Copyright (C) 2005-2007 by Daniel Wagner 
    33 * 
    4  * This file is part of FreeBoB. 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    56 * 
    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, 
    1114 * 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. 
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     16 * Lesser General Public License for more details. 
    1417 * 
    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. 
     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 
    1922 */ 
    2023 
    21 #ifndef AVCDefinitions_h 
    22 #define AVCDefinitions_h 
     24#ifndef AVDDEFINITIONS_H 
     25#define AVDDEFINITIONS_H 
    2326 
    2427#include <libavc1394/avc1394.h> 
     
    7073typedef byte_t control_selector_t; 
    7174typedef byte_t control_data_length_t; 
     75typedef uint16_t control_data_ext_length_t; 
     76typedef uint16_t mixer_level_t; 
     77typedef byte_t mixer_programmable_state_t; 
    7278typedef byte_t input_fb_plug_number_t; 
    7379typedef byte_t input_audio_channel_number_t; 
     
    99105/** 
    100106 * \brief Convert from ESamplingFrequency to an integer 
    101  * @param freq  
    102  * @return  
     107 * @param freq 
     108 * @return 
    103109 */ 
    104110int convertESamplingFrequency(ESamplingFrequency freq); 
    105111/** 
    106112 * \brief Convert from integer to ESamplingFrequency 
    107  * @param sampleRate  
    108  * @return  
     113 * @param sampleRate 
     114 * @return 
    109115 */ 
    110116ESamplingFrequency parseSampleRate( int sampleRate ); 
     
    123129#define AVC1394_SUBUNIT_ID_RESERVED 0x06 
    124130 
    125 #endif // AVCDefinitions_h 
     131#endif // AVDDEFINITIONS_H 
  • trunk/libffado/src/libavc/avc_extended_cmd_generic.cpp

    r413 r445  
    1 /* avc_extended_cmd_generic.cpp 
    2  * Copyright (C) 2005 by Daniel Wagner 
     1/* 
     2 * Copyright (C) 2005-2007 by Daniel Wagner 
    33 * 
    4  * This file is part of FreeBoB. 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    56 * 
    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, 
    1114 * 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. 
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     16 * Lesser General Public License for more details. 
    1417 * 
    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. 
     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 
    1922 */ 
    2023 
     
    461464 
    462465PlugAddressSpecificData::PlugAddressSpecificData( EPlugDirection plugDirection, 
    463                                                  EPlugAddressMode plugAddressMode, 
    464                                                  UnitPlugSpecificDataPlugAddress& unitPlugAddress ) 
     466                          EPlugAddressMode plugAddressMode, 
     467                          UnitPlugSpecificDataPlugAddress& unitPlugAddress ) 
    465468    : m_plugDirection( plugDirection ) 
    466469    , m_addressMode( plugAddressMode ) 
     
    470473 
    471474PlugAddressSpecificData::PlugAddressSpecificData( EPlugDirection plugDirection, 
    472                                                  EPlugAddressMode plugAddressMode, 
    473                                                  SubunitPlugSpecificDataPlugAddress& subUnitPlugAddress ) 
     475                          EPlugAddressMode plugAddressMode, 
     476                          SubunitPlugSpecificDataPlugAddress& subUnitPlugAddress ) 
    474477    : m_plugDirection( plugDirection ) 
    475478    , m_addressMode( plugAddressMode ) 
     
    479482 
    480483PlugAddressSpecificData::PlugAddressSpecificData( EPlugDirection plugDirection, 
    481                                                  EPlugAddressMode plugAddressMode, 
    482                                                  FunctionBlockPlugSpecificDataPlugAddress& functionBlockPlugAddress ) 
     484                          EPlugAddressMode plugAddressMode, 
     485                          FunctionBlockPlugSpecificDataPlugAddress& functionBlockPlugAddress ) 
    483486    : m_plugDirection( plugDirection ) 
    484487    , 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, 
    1114 * 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. 
     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 
    1922 */ 
    2023 
     
    3841        ePT_ExternalPlug     = 0x01, 
    3942        ePT_AsynchronousPlug = 0x02, 
    40        ePT_Unknown          = 0xff, 
     43    ePT_Unknown          = 0xff, 
    4144    }; 
    4245 
     
    205208        ePD_Input     = 0x00, 
    206209        ePD_Output    = 0x01, 
    207        ePD_Undefined = 0xff, 
     210    ePD_Undefined = 0xff, 
    208211    }; 
    209212 
     
    212215        ePAM_Subunit       = 0x01, 
    213216        ePAM_FunctionBlock = 0x02, 
    214        ePAM_Undefined     = 0xff, 
     217    ePAM_Undefined     = 0xff, 
    215218    }; 
    216219 
     
    259262 
    260263    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 ); 
    271274    PlugAddressSpecificData( const  PlugAddressSpecificData& pa ); 
    272275 
  • trunk/libffado/src/libavc/avc_extended_plug_info.cpp

    r413 r445  
    1 /* avc_extended_plug_info.cpp 
    2  * Copyright (C) 2005 by Daniel Wagner 
     1/* 
     2 * Copyright (C) 2005-2007 by Daniel Wagner 
    33 * 
    4  * This file is part of FreeBoB. 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    56 * 
    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, 
    1114 * 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. 
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     16 * Lesser General Public License for more details. 
    1417 * 
    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. 
     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 
    1922 */ 
    2023 
  • 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, 
    1114 * 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. 
     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 
    1922 */ 
    2023 
     
    285288public: 
    286289    enum ESubFunction { 
    287        eSF_ExtendedPlugInfoCmd                  = AVC1394_PLUG_INFO_SUBFUNCTION_EXTENDED_PLUG_INFO_CMD, 
     290    eSF_ExtendedPlugInfoCmd                  = AVC1394_PLUG_INFO_SUBFUNCTION_EXTENDED_PLUG_INFO_CMD, 
    288291        eSF_NotUsed                              = AVC1394_PLUG_INFO_SUBFUNCTION_SERIAL_BUS_NOT_USED, 
    289292    }; 
     
    301304    bool setInfoType( const ExtendedPlugInfoInfoType& infoType ); 
    302305    ExtendedPlugInfoInfoType* getInfoType() 
    303        { return m_infoType; } 
     306    { return m_infoType; } 
    304307 
    305308    virtual const char* getCmdName() const 
    306        { return "ExtendedPlugInfoCmd"; } 
     309    { return "ExtendedPlugInfoCmd"; } 
    307310 
    308311protected: 
  • 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, 
    1114 * 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. 
     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 
    1922 */ 
    2023 
     
    3841           << ", midi channels: " << info.m_midiChannels << ")"; 
    3942*/ 
    40        stream << "  NbChannels " << (int)info.m_numberOfChannels << ", Format " << (int)info.m_streamFormat; 
     43     stream << "  NbChannels " << (int)info.m_numberOfChannels << ", Format " << (int)info.m_streamFormat; 
    4144    return stream; 
    4245} 
     
    120123{ 
    121124    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   
    131134 
    132135    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, 
    1114 * 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. 
     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 
    1922 */ 
    2023 
    21 #ifndef AVCExtendedStreamFormat_h 
    22 #define AVCExtendedStreamFormat_h 
     24#ifndef AVCEXTENDEDSTREAMFROMAT_H 
     25#define AVCEXTENDEDSTREAMFROMAT_H 
    2326 
    2427#include "avc_generic.h" 
     
    274277 
    275278    virtual const char* getCmdName() const 
    276        { return "ExtendedStreamFormatCmd"; } 
     279    { return "ExtendedStreamFormatCmd"; } 
    277280 
    278281protected: 
     
    284287}; 
    285288 
    286 #endif // AVCExtendedStreamFormat_h 
     289#endif // AVCEXTENDEDSTREAMFROMAT_H 
  • trunk/libffado/src/libavc/avc_extended_subunit_info.cpp

    r413 r445  
    1 /* avc_extended_subunit_info.cpp 
    2  * Copyright (C) 2006 by Daniel Wagner 
     1/* 
     2 * Copyright (C) 2005-2007 by Daniel Wagner 
    33 * 
    4  * This file is part of FreeBoB. 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    56 * 
    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, 
    1114 * 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. 
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     16 * Lesser General Public License for more details. 
    1417 * 
    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. 
     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 
    1922 */ 
    2023 
  • trunk/libffado/src/libavc/avc_extended_subunit_info.h

    r378 r445  
    1 /* avc_extended_subunit_info.h 
    2  * Copyright (C) 2006 by Daniel Wagner 
     1/* 
     2 * Copyright (C) 2005-2007 by Daniel Wagner 
    33 * 
    4  * This file is part of FreeBoB. 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    56 * 
    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, 
    1114 * 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. 
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     16 * Lesser General Public License for more details. 
    1417 * 
    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. 
     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 
    1922 */ 
    2023 
     
    6669 
    6770    enum EProcessingType { 
    68        ePT_Unknown                 = 0x00, 
     71    ePT_Unknown                 = 0x00, 
    6972        ePT_Mixer                   = 0x01, 
    7073        ePT_Generic                 = 0x02, 
     
    9598 
    9699    virtual const char* getCmdName() const 
    97        { return "ExtendedSubunitInfoCmd"; } 
     100    { return "ExtendedSubunitInfoCmd"; } 
    98101 
    99102    page_t                m_page; 
  • trunk/libffado/src/libavc/avc_function_block.cpp

    r413 r445  
    1 /* avc_function_block.cpp 
    2  * Copyright (C) 2006 by Daniel Wagner 
     1/* 
     2 * Copyright (C) 2005-2007 by Daniel Wagner 
    33 * 
    4  * This file is part of FreeBoB. 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    56 * 
    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, 
    1114 * 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. 
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     16 * Lesser General Public License for more details. 
    1417 * 
    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. 
     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 
    1922 */ 
    2023 
     
    144147FunctionBlockProcessingEnhancedMixer::serialize( IOSSerialize& se ) 
    145148{ 
    146     bool bStatus; 
     149    int todo,done; 
     150    bool bStatus; 
     151    byte_t data_length_hi, data_length_lo; 
     152     
    147153    bStatus  = se.write( m_controlSelector, "FunctionBlockProcessingEnhancedMixer controlSelector" ); 
    148154    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    } 
    150203    return bStatus; 
    151204} 
     
    154207FunctionBlockProcessingEnhancedMixer::deserialize( IISDeserialize& de ) 
    155208{ 
    156     bool bStatus; 
     209    int todo; 
     210    bool bStatus=true; 
    157211    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 
    158216    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    } 
    159261 
    160262    return bStatus; 
     
    358460FunctionBlockProcessing::deserialize( IISDeserialize& de ) 
    359461{ 
     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     
    360477    bool bStatus; 
    361478    bStatus  = de.read( &m_selectorLength ); 
     
    364481    bStatus &= de.read( &m_outputAudioChannelNumber ); 
    365482 
    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     
    368488    switch( controlSelector ) { 
    369489    case eCSE_Processing_Mixer: 
     
    385505    } 
    386506 
     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 
    387515    return bStatus; 
    388516} 
  • 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, 
    1114 * 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. 
     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 
    1922 */ 
    2023 
     
    2629 
    2730#include <libavc1394/avc1394.h> 
     31#include <vector> 
     32using namespace std; 
    2833 
    2934class FunctionBlockFeatureVolume: public IBusData 
     
    7883    virtual FunctionBlockProcessingEnhancedMixer* clone() const; 
    7984 
    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; 
    8290}; 
    8391 
  • 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, 
    1114 * 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. 
     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 
    1922 */ 
    2023 
     
    3033 
    3134IMPL_DEBUG_MODULE( AVCCommand, AVCCommand, DEBUG_LEVEL_NORMAL ); 
     35IMPL_DEBUG_MODULE( IBusData, IBusData, DEBUG_LEVEL_VERBOSE ); 
    3236 
    3337int AVCCommand::m_time = 0; 
     
    227231        } 
    228232    } else { 
    229           debugWarning( "no response\n" ); 
     233       debugWarning( "no response\n" ); 
    230234    } 
    231235 
  • trunk/libffado/src/libavc/avc_generic.h

    r375 r445  
    1 /* avc_generic.h 
    2  * Copyright (C) 2005 by Daniel Wagner 
     1/* 
     2 * Copyright (C) 2005-2007 by Daniel Wagner 
    33 * 
    4  * This file is part of FreeBoB. 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    56 * 
    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, 
    1114 * 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. 
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     16 * Lesser General Public License for more details. 
    1417 * 
    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. 
     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 
    1922 */ 
    2023 
    21 #ifndef AVCGeneric_h 
    22 #define AVCGeneric_h 
     24#ifndef AVCGENERIC_H 
     25#define AVCGENERIC_H 
    2326 
    2427#include "avc_definitions.h" 
     
    4548 
    4649    virtual IBusData* clone() const = 0; 
     50     
     51protected: 
     52    DECLARE_DEBUG_MODULE; 
    4753}; 
    4854 
     
    106112    bool setVerbose( int verboseLevel ); 
    107113    int getVerboseLevel(); 
    108      
     114 
    109115    virtual const char* getCmdName() const = 0; 
    110116 
     
    113119protected: 
    114120    void showFcpFrame( const unsigned char* buf, 
    115                       unsigned short frameSize ) const; 
     121               unsigned short frameSize ) const; 
    116122 
    117123protected: 
     
    133139    ECommandType m_commandType; 
    134140    static int   m_time; 
    135      
     141 
    136142    DECLARE_DEBUG_MODULE; 
    137143}; 
     
    141147const char* responseToString( AVCCommand::EResponse eResponse ); 
    142148 
    143 #endif // AVCGeneric_h 
     149#endif // AVCGENERIC_H 
  • trunk/libffado/src/libavc/avc_plug_info.cpp

    r413 r445  
    1 /* avc_plug_info.cpp 
    2  * Copyright (C) 2005 by Daniel Wagner 
     1/* 
     2 * Copyright (C) 2005-2007 by Daniel Wagner 
    33 * 
    4  * This file is part of FreeBoB. 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    56 * 
    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, 
    1114 * 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. 
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     16 * Lesser General Public License for more details. 
    1417 * 
    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. 
     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 
    1922 */ 
    2023 
  • trunk/libffado/src/libavc/avc_plug_info.h

    r375 r445  
    1 /* avc_plug_info.h 
    2  * Copyright (C) 2005 by Daniel Wagner 
     1/* 
     2 * Copyright (C) 2005-2007 by Daniel Wagner 
    33 * 
    4  * This file is part of FreeBoB. 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    56 * 
    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, 
    1114 * 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. 
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     16 * Lesser General Public License for more details. 
    1417 * 
    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. 
     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 
    1922 */ 
    2023 
    21 #ifndef AVCPlugInfo_h 
    22 #define AVCPlugInfo_h 
     24#ifndef AVCPLUGINFO_H 
     25#define AVCPLUGINFO_H 
    2326 
    2427#include "avc_generic.h" 
     
    4346 
    4447    PlugInfoCmd( Ieee1394Service& ieee1394service, 
    45                 ESubFunction eSubFunction = eSF_SerialBusIsochronousAndExternalPlug ); 
     48        ESubFunction eSubFunction = eSF_SerialBusIsochronousAndExternalPlug ); 
    4649    PlugInfoCmd( const PlugInfoCmd& rhs ); 
    4750    virtual ~PlugInfoCmd(); 
     
    5154 
    5255    virtual const char* getCmdName() const 
    53        { return "PlugInfoCmd"; } 
     56    { return "PlugInfoCmd"; } 
    5457 
    5558    nr_of_plugs_t m_serialBusIsochronousInputPlugs; 
     
    7073 
    7174 
    72 #endif // AVCPlugInfo_h 
     75#endif // AVCPLUGINFO_H 
  • trunk/libffado/src/libavc/avc_serialize.cpp

    r365 r445  
    1 /* avc_serialize.cpp 
    2  * Copyright (C) 2005,07 by Daniel Wagner 
     1/* 
     2 * Copyright (C) 2005-2007 by Daniel Wagner 
    33 * 
    4  * This file is part of FreeBoB. 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    56 * 
    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, 
    1114 * 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. 
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     16 * Lesser General Public License for more details. 
    1417 * 
    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. 
     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 
    1922 */ 
    2023 
     
    2629#include <netinet/in.h> 
    2730 
     31IMPL_DEBUG_MODULE( CoutSerializer, CoutSerializer, DEBUG_LEVEL_NORMAL ); 
     32 
    2833bool 
    2934CoutSerializer::write( byte_t d, const char* name ) 
    3035{ 
    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 ); 
    3237    m_cnt += sizeof( byte_t ); 
    3338 
     
    3843CoutSerializer::write( quadlet_t d, const char* name ) 
    3944{ 
    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 ); 
    4146    m_cnt += sizeof( quadlet_t ); 
    4247    return true; 
  • trunk/libffado/src/libavc/avc_serialize.h

    r365 r445  
    1 /* avc_serialize.h 
    2  * Copyright (C) 2005,07 by Daniel Wagner 
     1/* 
     2 * Copyright (C) 2005-2007 by Daniel Wagner 
    33 * 
    4  * This file is part of FreeBoB. 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    56 * 
    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, 
    1114 * 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. 
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     16 * Lesser General Public License for more details. 
    1417 * 
    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. 
     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 
    1922 */ 
    2023 
    21 #ifndef Serialize_h 
    22 #define Serialize_h 
     24#ifndef SERIALIZE_H 
     25#define SERIALIZE_H 
     26 
     27#include "debugmodule/debugmodule.h" 
    2328 
    2429#include <libraw1394/raw1394.h> // byte_t and quadlet_t declaration 
     
    6267private: 
    6368    unsigned int m_cnt; 
     69    DECLARE_DEBUG_MODULE; 
    6470 
    6571}; 
     
    97103 
    98104    int getNrOfProducesBytes() const 
    99        { return m_curPos - m_buffer; } 
     105    { return m_curPos - m_buffer; } 
    100106 
    101107protected: 
     
    135141}; 
    136142 
    137 #endif // Serialize_h 
     143#endif // SERIALIZE_H 
    138144 
  • 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, 
    1114 * 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. 
     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 
    1922 */ 
    2023 
  • trunk/libffado/src/libavc/avc_signal_source.h

    r375 r445  
    1 /* avc_signal_source.h 
    2  * Copyright (C) 2005 by Daniel Wagner 
     1/* 
     2 * Copyright (C) 2005-2007 by Daniel Wagner 
    33 * 
    4  * This file is part of FreeBoB. 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    56 * 
    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, 
    1114 * 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. 
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     16 * Lesser General Public License for more details. 
    1417 * 
    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. 
     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 
    1922 */ 
    2023 
    21 #ifndef AVCSignalSource_h 
    22 #define AVCSignalSource_h 
     24#ifndef AVCSIGNALSOURCE_H 
     25#define AVCSIGNALSOURCE_H 
    2326 
    2427#include "avc_generic.h" 
     
    7376 
    7477    virtual const char* getCmdName() const 
    75        { return "SignalSourceCmd"; } 
     78    { return "SignalSourceCmd"; } 
    7679 
    7780    bool setSignalSource( SignalUnitAddress& signalAddress ); 
     
    9699 
    97100 
    98 #endif // AVCSignalSource_h 
     101#endif // AVCSIGNALSOURCE_H 
  • trunk/libffado/src/libavc/avc_subunit_info.cpp

    r413 r445  
    1 /* avc_subunit_info.cpp 
    2  * Copyright (C) 2005 by Daniel Wagner 
     1/* 
     2 * Copyright (C) 2005-2007 by Daniel Wagner 
    33 * 
    4  * This file is part of FreeBoB. 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    56 * 
    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, 
    1114 * 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. 
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     16 * Lesser General Public License for more details. 
    1417 * 
    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. 
     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 
    1922 */ 
    2023 
  • trunk/libffado/src/libavc/avc_subunit_info.h

    r375 r445  
    1 /* avc_subunit_info.h 
    2  * Copyright (C) 2005 by Daniel Wagner 
     1/* 
     2 * Copyright (C) 2005-2007 by Daniel Wagner 
    33 * 
    4  * This file is part of FreeBoB. 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    56 * 
    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, 
    1114 * 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. 
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     16 * Lesser General Public License for more details. 
    1417 * 
    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. 
     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 
    1922 */ 
    2023 
    21 #ifndef AVCSubUnitInfo_h 
    22 #define AVCSubUnitInfo_h 
     24#ifndef AVCSUBUNITINFO_H 
     25#define AVCSUBUNITINFO_H 
    2326 
    2427#include "avc_generic.h" 
     
    3942 
    4043    virtual const char* getCmdName() const 
    41        { return "SubUnitInfoCmd"; } 
     44    { return "SubUnitInfoCmd"; } 
    4245 
    4346    bool clear(); 
     
    4952 
    5053    enum { 
    51        eMaxSubunitsPerPage = 4, 
    52        eMaxSubunitsPerUnit = 32, 
     54    eMaxSubunitsPerPage = 4, 
     55    eMaxSubunitsPerUnit = 32, 
    5356    }; 
    5457 
    5558    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; 
    5861    }; 
    5962 
     
    6164 
    6265    short getMaxNoOfPages() 
    63        { return eMaxSubunitsPerUnit / eMaxSubunitsPerPage; } 
     66    { return eMaxSubunitsPerUnit / eMaxSubunitsPerPage; } 
    6467 
    6568 
    6669    short            m_nrOfValidEntries; 
    6770    short getNrOfValidEntries() 
    68        { return m_nrOfValidEntries; } 
     71    { return m_nrOfValidEntries; } 
    6972 
    7073}; 
    7174 
    7275 
    73 #endif // AVCSubUnitInfo_h 
     76#endif // AVCSUBUNITINFO_H 
  • trunk/libffado/src/libavc/avc_unit_info.cpp

    r413 r445  
    1 /* avc_unit_info.cpp 
    2  * Copyright (C) 2005 by Daniel Wagner 
     1/* 
     2 * Copyright (C) 2005-2007 by Daniel Wagner 
    33 * 
    4  * This file is part of FreeBoB. 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    56 * 
    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, 
    1114 * 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. 
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     16 * Lesser General Public License for more details. 
    1417 * 
    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. 
     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 
    1922 */ 
    2023 
  • trunk/libffado/src/libavc/avc_unit_info.h

    r375 r445  
    1 /* avc_unit_info.h 
    2  * Copyright (C) 2005 by Daniel Wagner 
     1/* 
     2 * Copyright (C) 2005-2007 by Daniel Wagner 
    33 * 
    4  * This file is part of FreeBoB. 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    56 * 
    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, 
    1114 * 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. 
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     16 * Lesser General Public License for more details. 
    1417 * 
    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. 
     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 
    1922 */ 
    2023 
    21 #ifndef AVCUnitInfo_h 
    22 #define AVCUnitInfo_h 
     24#ifndef AVCUNITINFO_H 
     25#define AVCUNITINFO_H 
    2326 
    2427#include "avc_generic.h" 
     
    5659 
    5760    virtual const char* getCmdName() const 
    58        { return "UnitInfoCmd"; } 
     61    { return "UnitInfoCmd"; } 
    5962 
    6063    reserved_t  m_reserved; 
     
    6669 
    6770 
    68 #endif // AVCUnitInfo_h 
     71#endif // AVCUNITINFO_H 
  • trunk/libffado/src/libieee1394/ARMHandler.cpp

    r414 r445  
    1 /* $Id$ */ 
    2  
    31/* 
    4  *   FreeBob Streaming API 
    5  *   FreeBob = Firewire (pro-)audio for linux 
     2 * Copyright (C) 2005-2007 by Pieter Palmers 
    63 * 
    7  *   http://freebob.sf.net 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    86 * 
    9  *   Copyright (C) 2007 Pieter Palmers <pieterpalmers@users.sourceforge.net> 
     7 * FFADO is based upon FreeBoB 
    108 * 
    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; 
    1512 * 
    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. 
     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. 
    2017 * 
    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 
    2722 */ 
    2823 
     
    3530 * @param initial_value  pointer to buffer containing (if necessary) initial value 
    3631 *                    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 
    3934 *                    following flags - ARM_READ, ARM_WRITE, ARM_LOCK 
    4035 * @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 
    4237 *                    following flags - ARM_READ, ARM_WRITE, ARM_LOCK 
    4338 * @param client_transactions identifies for which type of request you want 
     
    4540 *                    for those requests no response will be generated, but 
    4641 *                    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 
    4843 *                    following flags - ARM_READ, ARM_WRITE, ARM_LOCK 
    4944 *                    For each bit set here, notification_options and 
     
    10196//         byte_t          *buffer; 
    10297// } *raw1394_arm_request_t; 
    103 //  
     98// 
    10499// typedef struct raw1394_arm_response { 
    105100//         int             response_code; 
     
    107102//         byte_t          *buffer; 
    108103// } *raw1394_arm_response_t; 
    109 //  
     104// 
    110105// typedef struct raw1394_arm_request_response { 
    111106//         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 */ 
    224 
    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__ 
    3027 
    3128#include "../debugmodule/debugmodule.h" 
     
    3734/** 
    3835 * @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 
    4138 * address range mapping, i.e. implementing handlers 
    4239 * that react to reads/writes of certain addresses 
    4340 * in 1394 memory space 
    44  *  
     41 * 
    4542 * see the _arm_ functions in raw1394.h for more insight 
    46  *  
     43 * 
    4744 */ 
    48   
     45 
    4946class ARMHandler { 
    5047friend class Ieee1394Service; 
     
    5754               unsigned int client_transactions 
    5855              ); 
    59      
     56 
    6057    virtual ~ARMHandler(); 
    6158 
     
    6562 
    6663    struct raw1394_arm_response *getResponse() {return &m_response;}; 
    67      
     64 
    6865    nodeaddr_t getStart() {return m_start;}; 
    6966    nodeaddr_t getLength() {return m_length;}; 
     
    7168    unsigned int getNotificationOptions() {return m_notification_options;}; 
    7269    unsigned int getClientTransactions() {return m_client_transactions;}; 
    73      
     70 
    7471    byte_t *getBuffer() {return m_buffer;}; 
    75      
     72 
    7673private: 
    7774    nodeaddr_t m_start; 
     
    8279 
    8380    byte_t *m_buffer; 
    84      
     81 
    8582    struct raw1394_arm_response m_response; 
    86      
     83 
    8784    void printBufferBytes( unsigned int level, size_t length, byte_t* buffer ) const; 
    8885    void printRequest(struct raw1394_arm_request *arm_req); 
    89      
     86 
    9087protected: 
    9188 
    92      
     89 
    9390    DECLARE_DEBUG_MODULE; 
    9491 
    9592}; 
    9693 
    97 #endif /* __FREEBOB_ARMHANDLER__ */ 
     94#endif /* __FFADO_ARMHANDLER__ */ 
    9895 
    9996 
  • 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 
    35 * 
    4  * This file is part of FreeBoB. 
     6 * This file is part of FFADO 
     7 * FFADO = Free Firewire (pro-)audio drivers for linux 
    58 * 
    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, 
    1116 * 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. 
     17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     18 * Lesser General Public License for more details. 
    1419 * 
    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. 
     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 
    1924 */ 
    2025 
     
    159164                len ); 
    160165 
    161        while ((buf + len - 1) == '\0') { 
     166    while ((buf + len - 1) == '\0') { 
    162167            len--; 
    163168        } 
    164169        // \todo XXX seems a bit strage to do this but the nodemgr.c code does 
    165170        // 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'; 
    168173 
    169174 
     
    178183                ( void* )CSR1212_TEXTUAL_DESCRIPTOR_LEAF_DATA( m_modelNameKv ), 
    179184                len ); 
    180        while ((buf + len - 1) == '\0') { 
     185    while ((buf + len - 1) == '\0') { 
    181186            len--; 
    182187        } 
    183188        // \todo XXX for edirol fa-66 it seems somehow broken. see above 
    184189        // todo as well. 
    185        buf[len++] = ' '; 
    186        buf[len] = '\0'; 
     190    buf[len++] = ' '; 
     191    buf[len] = '\0'; 
    187192 
    188193        debugOutput( DEBUG_LEVEL_VERBOSE, "Model name: '%s'\n", buf); 
     
    217222{ 
    218223    struct config_csr_info* csr_info = (struct config_csr_info*) private_data; 
    219      
     224 
    220225    if ( !csr_info->service->read( csr_info->nodeId, 
    221226                                   addr, 
     
    249254    debugOutput( DEBUG_LEVEL_VERBOSE, "process unit directory:\n" ); 
    250255    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) { 
    254259                    debugOutput( DEBUG_LEVEL_VERBOSE, 
    255260                                 "\tvendor_id = 0x%08x\n", 
    256261                                 kv->value.immediate); 
    257262                    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: 
    262267                debugOutput( DEBUG_LEVEL_VERBOSE, 
    263268                             "\tmodel_id = 0x%08x\n", 
    264269                             kv->value.immediate); 
    265270                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: 
    269274                debugOutput( DEBUG_LEVEL_VERBOSE, 
    270275                             "\tspecifier_id = 0x%08x\n", 
    271276                             kv->value.immediate); 
    272277                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: 
    276281                debugOutput( DEBUG_LEVEL_VERBOSE, 
    277282                             "\tversion = 0x%08x\n", 
     
    284289                    } 
    285290                } 
    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); 
    299304                            m_vendorNameKv = kv; 
    300                            break; 
    301  
    302                        case CSR1212_KV_ID_MODEL: 
     305                break; 
     306 
     307            case CSR1212_KV_ID_MODEL: 
    303308                            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 is 
    314                     * 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; 
    324329    } 
    325330} 
     
    334339 
    335340    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: 
    338343                debugOutput( DEBUG_LEVEL_VERBOSE, 
    339344                             "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: 
    343348                debugOutput( DEBUG_LEVEL_VERBOSE, 
    344349                             "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) 
    359364                    { 
    360365                        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; 
    367372    } 
    368373 
     
    578583ConfigRom::processOscMessage(OSC::OscMessage *m) { 
    579584    OSC::OscResponse r=OSC::OscResponse(OSC::OscResponse::eUnhandled); 
    580      
     585 
    581586    unsigned int nbArgs=m->nbArguments(); 
    582587    if (nbArgs>=1) { 
     
    584589        if(arg0.isString()) { // commands 
    585590            string cmd=arg0.getString(); 
    586              
     591 
    587592            debugOutput( DEBUG_LEVEL_VERBOSE, "(%p) CMD? %s\n", this, cmd.c_str()); 
    588593            if(cmd == "params") { 
     
    623628        } 
    624629    } 
    625      
     630 
    626631    return r; 
    627632 
  • 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 
    35 * 
    4  * This file is part of FreeBoB. 
     6 * This file is part of FFADO 
     7 * FFADO = Free Firewire (pro-)audio drivers for linux 
    58 * 
    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, 
    1116 * 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. 
     17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     18 * Lesser General Public License for more details. 
    1419 * 
    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. 
     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 
    1924 */ 
    2025 
     
    5661 
    5762    bool isIsoResourseManager() const 
    58        { return m_isIsoResourceManager; } 
     63    { return m_isIsoResourceManager; } 
    5964    bool isCycleMasterCapable() const 
    6065        { return m_isCycleMasterCapable; } 
     
    7075 
    7176    fb_quadlet_t getNodeVendorId() const 
    72        { return m_nodeVendorId; } 
     77    { return m_nodeVendorId; } 
    7378 
    7479    bool updatedNodeId(); 
     
    7883 
    7984    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 ); 
    8388 
    8489 protected: 
  • trunk/libffado/src/libieee1394/IEC61883.cpp

    r424 r445  
    1 /* $Id$ */ 
    2  
    31/* 
    4  *   FreeBob Streaming API 
    5  *   FreeBob = Firewire (pro-)audio for linux 
     2 * Copyright (C) 2005-2007 by Pieter Palmers 
    63 * 
    7  *   http://freebob.sf.net 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    86 * 
    9  *   Copyright (C) 2007 Pieter Palmers <pieterpalmers@users.sourceforge.net> 
     7 * FFADO is based upon FreeBoB 
    108 * 
    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; 
    1512 * 
    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. 
     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. 
    2017 * 
    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 
    2622 */ 
    2723 
  • trunk/libffado/src/libieee1394/IEC61883.h

    r424 r445  
    1 /* $Id$ */ 
    2  
    31/* 
    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__ 
    3026 
    3127#include "../debugmodule/debugmodule.h" 
    3228 
    3329/* 
    34  * This is shamelessly stolen from iec61883-private,  
     30 * This is shamelessly stolen from iec61883-private, 
    3531 * but I need these functions! 
    3632 * FIXME: this will only work until somebody decides to change 
     
    4541 **/ 
    4642 
    47 /* maximum number of PCRs allowed within the standard  
     43/* maximum number of PCRs allowed within the standard 
    4844 * MPR/PCR addresses defined in IEC-61883. 
    4945 * This refers to the number of output or input PCRs-- 
     
    147143 * @a: The CSR offset address (relative to base) of the register to read. 
    148144 * @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 
    151147 * suceess or -1 for error (errno available). 
    152148 **/ 
     
    155151 
    156152 
    157 /**  
     153/** 
    158154 * iec61883_plug_set - Write a node's plug register. 
    159155 * @h: A raw1394 handle. 
     
    204200}; 
    205201 
    206 #endif /* __FREEBOB_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, 
    1215 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    14  * GNU General Public License for more details. 
    15  * 
    16  * You should have received a copy of the GNU General Public License 
    17  * along with FreeBoB; if not, write to the Free Software 
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
    19  * MA 02111-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 
    2023 */ 
     24 
    2125#include "ieee1394service.h" 
    2226#include "ARMHandler.h" 
     
    4246{ 
    4347    pthread_mutex_init( &m_mutex, 0 ); 
    44      
     48 
    4549    for (unsigned int i=0; i<64; i++) { 
    4650        m_channels[i].channel=-1; 
     
    7377        raw1394_destroy_handle( m_handle ); 
    7478    } 
    75      
     79 
    7680    if ( m_resetHandle ) { 
    7781        raw1394_destroy_handle( m_resetHandle ); 
     
    117121    m_default_arm_handler = raw1394_set_arm_tag_handler( m_resetHandle, 
    118122                                   this->armHandlerLowLevel ); 
    119      
     123 
    120124    startRHThread(); 
    121125 
     
    230234} 
    231235 
    232 bool  
     236bool 
    233237Ieee1394Service::lockCompareSwap64(  fb_nodeid_t nodeId, 
    234238                        fb_nodeaddr_t addr, 
     
    244248    fb_octlet_t buffer; 
    245249    if(!read_octlet( nodeId, addr,&buffer )) { 
    246         debugOutput(DEBUG_LEVEL_VERBOSE,"Could not read owner register\n"); 
     250        debugWarning("Could not read register\n"); 
    247251    } 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 
    257255    #endif 
    258      
     256 
    259257    // do endiannes swapping 
    260258    compare_value=byteSwap_octlet(compare_value); 
    261259    swap_value=byteSwap_octlet(swap_value); 
    262      
     260 
    263261    int retval=raw1394_lock64(m_handle, nodeId, addr, RAW1394_EXTCODE_COMPARE_SWAP, 
    264262                          swap_value, compare_value, result); 
    265      
     263 
    266264    #ifdef DEBUG 
    267265    if(!read_octlet( nodeId, addr,&buffer )) { 
    268         debugOutput(DEBUG_LEVEL_VERBOSE,"Could not read owner register\n"); 
     266        debugWarning("Could not read register\n"); 
    269267    } else { 
    270         debugOutput(DEBUG_LEVEL_VERBOSE,"Owner register after = 0x%016llX\n", buffer); 
     268        debugOutput(DEBUG_LEVEL_VERBOSE,"after = 0x%016llX\n", buffer); 
    271269    } 
    272270    #endif 
    273      
     271 
    274272    *result=byteSwap_octlet(*result); 
    275      
     273 
    276274    return (retval == 0); 
    277275} 
     
    286284        buf[i] = ntohl( buf[i] ); 
    287285    } 
    288  
    289     #ifdef DEBUG 
    290     debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, "  pre avc1394_transaction_block2\n" ); 
    291     printBuffer( DEBUG_LEVEL_VERY_VERBOSE, len, buf ); 
    292     #endif 
    293286 
    294287    fb_quadlet_t* result = 
     
    300293                                    10 ); 
    301294 
    302     #ifdef DEBUG 
    303     debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, "  post avc1394_transaction_block2\n" ); 
    304     printBuffer( DEBUG_LEVEL_VERY_VERBOSE, *resp_len, result ); 
    305     #endif 
    306  
    307295    for ( unsigned int i = 0; i < *resp_len; ++i ) { 
    308296        result[i] = htonl( result[i] ); 
     
    389377        h, h->getStart(), h->getLength()); 
    390378 
    391     int err=raw1394_arm_register(m_resetHandle, h->getStart(),  
     379    int err=raw1394_arm_register(m_resetHandle, h->getStart(), 
    392380                         h->getLength(), h->getBuffer(), (octlet_t)h, 
    393381                         h->getAccessRights(), 
     
    399387        return false; 
    400388    } 
    401      
     389 
    402390    m_armHandlers.push_back( h ); 
    403391 
     
    406394 
    407395bool 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", 
    409397        h, h->getStart()); 
    410      
     398 
    411399    for ( arm_handler_vec_t::iterator it = m_armHandlers.begin(); 
    412400          it != m_armHandlers.end(); 
     
    439427    debugOutput(DEBUG_LEVEL_VERBOSE, "Finding free ARM block of %d bytes, from 0x%016llX in steps of %d bytes\n", 
    440428        length, start, step); 
    441          
     429 
    442430    int cnt=0; 
    443431    const int maxcnt=10; 
     
    446434        // try to register 
    447435        err=raw1394_arm_register(m_resetHandle, start, length, 0, 0, 0, 0, 0); 
    448          
     436 
    449437        if (err) { 
    450438            debugOutput(DEBUG_LEVEL_VERBOSE, " -> cannot use 0x%016llX\n", start); 
     
    466454} 
    467455 
    468 int  
    469 Ieee1394Service::armHandlerLowLevel(raw1394handle_t handle,  
     456int 
     457Ieee1394Service::armHandlerLowLevel(raw1394handle_t handle, 
    470458                     unsigned long arm_tag, 
    471459                     byte_t request_type, unsigned int requested_length, 
     
    493481            raw1394_arm_request_t arm_req=arm_req_resp->request; 
    494482            raw1394_arm_response_t arm_resp=arm_req_resp->response; 
    495              
     483 
    496484            debugOutput(DEBUG_LEVEL_VERBOSE,"ARM handler for address 0x%016llX called\n", 
    497485                (*it)->getStart()); 
    498486            debugOutput(DEBUG_LEVEL_VERBOSE," request type   : 0x%02X\n",request_type); 
    499487            debugOutput(DEBUG_LEVEL_VERBOSE," request length : %04d\n",requested_length); 
    500              
     488 
    501489            switch(request_type) { 
    502490                case RAW1394_ARM_READ: 
     
    583571{ 
    584572    debugOutput(DEBUG_LEVEL_VERBOSE, "Removing busreset handler (%p)\n", functor); 
    585      
     573 
    586574    for ( reset_handler_vec_t::iterator it = m_busResetHandlers.begin(); 
    587575          it != m_busResetHandlers.end(); 
     
    603591 * or an allocated channel number. 
    604592 * 
    605  * Does not perform anything other than registering the channel and the  
     593 * Does not perform anything other than registering the channel and the 
    606594 * bandwidth at the IRM 
    607595 * 
    608596 * Also allocates the necessary bandwidth (in ISO allocation units). 
    609  *  
     597 * 
    610598 * FIXME: As in libiec61883, channel 63 is not requested; this is either a 
    611599 * bug or it's omitted since that's the channel preferred by video devices. 
     
    616604signed int Ieee1394Service::allocateIsoChannelGeneric(unsigned int bandwidth) { 
    617605    debugOutput(DEBUG_LEVEL_VERBOSE, "Allocating ISO channel using generic method...\n" ); 
    618      
     606 
    619607    struct ChannelInfo cinfo; 
    620608 
     
    627615        if (raw1394_bandwidth_modify(m_handle, bandwidth, RAW1394_MODIFY_ALLOC) < 0) { 
    628616            debugFatal("Could not allocate bandwidth of %d\n", bandwidth); 
    629              
     617 
    630618            raw1394_channel_modify (m_handle, c, RAW1394_MODIFY_FREE); 
    631619            return -1; 
     
    634622            cinfo.bandwidth=bandwidth; 
    635623            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 
    637630            if (registerIsoChannel(c, cinfo)) { 
    638631                return c; 
     
    667660 
    668661signed int Ieee1394Service::allocateIsoChannelCMP( 
    669     nodeid_t xmit_node, int xmit_plug,  
     662    nodeid_t xmit_node, int xmit_plug, 
    670663    nodeid_t recv_node, int recv_plug 
    671664    ) { 
    672665 
    673666    debugOutput(DEBUG_LEVEL_VERBOSE, "Allocating ISO channel using IEC61883 CMP...\n" ); 
    674      
     667 
    675668    struct ChannelInfo cinfo; 
    676      
     669 
    677670    int c = -1; 
    678671    int bandwidth=1; 
    679      
     672 
    680673    // do connection management: make connection 
    681674    c = iec61883_cmp_connect( 
     
    697690    cinfo.bandwidth=bandwidth; 
    698691    cinfo.alloctype=AllocCMP; 
    699      
     692 
    700693    cinfo.xmit_node=xmit_node; 
    701694    cinfo.xmit_plug=xmit_plug; 
    702695    cinfo.recv_node=recv_node; 
    703696    cinfo.recv_plug=recv_plug; 
    704          
     697 
    705698    if (registerIsoChannel(c, cinfo)) { 
    706699        return c; 
     
    711704 
    712705/** 
    713  * Deallocates an iso channel.  Silently ignores a request to deallocate  
     706 * Deallocates an iso channel.  Silently ignores a request to deallocate 
    714707 * a negative channel number. 
    715708 * 
     
    717710 * and uses the appropriate method to deallocate. Also frees the bandwidth 
    718711 * that was reserved along with this channel. 
    719  *  
     712 * 
    720713 * @param c channel number 
    721714 * @return true if successful 
     
    723716bool Ieee1394Service::freeIsoChannel(signed int c) { 
    724717    debugOutput(DEBUG_LEVEL_VERBOSE, "Freeing ISO channel %d...\n", c ); 
    725      
     718 
    726719    if (c < 0 || c > 63) { 
    727720        debugWarning("Invalid channel number: %d\n", c); 
    728721        return false; 
    729722    } 
    730      
     723 
    731724    switch (m_channels[c].alloctype) { 
    732725        default: 
    733726            debugError(" BUG: invalid allocation type!\n"); 
    734727            return false; 
    735              
    736         case AllocFree:  
     728 
     729        case AllocFree: 
    737730            debugWarning(" Channel %d not registered\n", c); 
    738731            return false; 
    739              
     732 
    740733        case AllocGeneric: 
    741734            debugOutput(DEBUG_LEVEL_VERBOSE, " allocated using generic routine...\n" ); 
     
    751744                return false; 
    752745            return true; 
    753              
     746 
    754747        case AllocCMP: 
    755748            debugOutput(DEBUG_LEVEL_VERBOSE, " allocated using IEC61883 CMP...\n" ); 
    756749            debugOutput(DEBUG_LEVEL_VERBOSE, " performing IEC61883 CMP disconnect...\n" ); 
    757750            if(iec61883_cmp_disconnect( 
    758                     m_handle,  
     751                    m_handle, 
    759752                    m_channels[c].xmit_node | 0xffc0, 
    760753                    m_channels[c].xmit_plug, 
     
    769762            return true; 
    770763    } 
    771      
     764 
    772765    // unreachable 
    773766    debugError("BUG: unreachable code reached!\n"); 
    774      
     767 
    775768    return false; 
    776769} 
     
    788781                m_channels[c].channel, m_channels[c].bandwidth); 
    789782        } 
    790          
     783 
    791784        memcpy(&m_channels[c], &cinfo, sizeof(struct ChannelInfo)); 
    792          
     785 
    793786    } else return false; 
    794787    return true; 
     
    806799            return false; 
    807800        } 
    808          
     801 
    809802        m_channels[c].channel=-1; 
    810803        m_channels[c].bandwidth=-1; 
     
    814807        m_channels[c].recv_node=0xFFFF; 
    815808        m_channels[c].recv_plug=-1; 
    816          
     809 
    817810    } else return false; 
    818811    return true; 
     
    822815 * Returns the current value of the `bandwidth available' register on 
    823816 * the IRM, or -1 on error. 
    824  * @return  
     817 * @return 
    825818 */ 
    826819signed int Ieee1394Service::getAvailableBandwidth() { 
     
    836829 
    837830void 
    838 Ieee1394Service::setVerboseLevel(int l)  
     831Ieee1394Service::setVerboseLevel(int l) 
    839832{ 
    840833    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, 
    1215 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    14  * GNU General Public License for more details. 
    15  * 
    16  * You should have received a copy of the GNU General Public License 
    17  * along with FreeBoB; if not, write to the Free Software 
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
    19  * MA 02111-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 
    2023 */ 
    2124 
    22 #ifndef FREEBOBIEEE1394SERVICE_H 
    23 #define FREEBOBIEEE1394SERVICE_H 
     25#ifndef FFADO_IEEE1394SERVICE_H 
     26#define FFADO_IEEE1394SERVICE_H 
    2427 
    2528#include "fbtypes.h" 
     
    4548 
    4649    int getPort() 
    47        { return m_port; } 
     50    { return m_port; } 
    4851   /** 
    4952    * @brief get number of nodes on the bus 
     
    5760    */ 
    5861    int getNodeCount(); 
    59      
     62 
    6063   /** 
    6164    * @brief get the node id of the local node 
     
    6770    */ 
    6871    nodeid_t getLocalNodeId(); 
    69      
     72 
    7073   /** 
    7174    * @brief send async read request to a node and wait for response. 
     
    7780    * @param length amount of data to read in quadlets 
    7881    * @param buffer pointer to buffer where data will be saved 
    79      
     82 
    8083    * @return true on success or false on failure (sets errno) 
    8184    */ 
    8285    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 ); 
    8689 
    8790    bool read_quadlet( fb_nodeid_t nodeId, 
     
    106109    */ 
    107110    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 ); 
    111114 
    112115    bool write_quadlet( fb_nodeid_t nodeId, 
     
    143146                                    fb_quadlet_t* buf, 
    144147                                    int len, 
    145                                    unsigned int* resp_len ); 
     148                    unsigned int* resp_len ); 
    146149 
    147150    bool transactionBlockClose(); 
     
    153156    bool addBusResetHandler( Functor* functor ); 
    154157    bool remBusResetHandler( Functor* functor ); 
    155      
     158 
    156159    /** 
    157160     * @brief register an AddressRangeMapping Handler 
     
    169172     */ 
    170173    bool unregisterARMHandler( ARMHandler *h ); 
    171      
     174 
    172175    nodeaddr_t findFreeARMBlock( nodeaddr_t start, size_t length, size_t step ); 
    173176 
     
    176179    signed int getAvailableBandwidth(); 
    177180    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, 
    179182                                     nodeid_t recv_node, int recv_plug); 
    180183    bool freeIsoChannel(signed int channel); 
    181      
     184 
    182185private: 
    183186    enum EAllocType { 
     
    196199        int recv_plug; 
    197200    }; 
    198      
     201 
    199202    // the info for the channels we manage 
    200203    struct ChannelInfo m_channels[64]; 
    201      
     204 
    202205    bool unregisterIsoChannel(unsigned int c); 
    203206    bool registerIsoChannel(unsigned int c, struct ChannelInfo cinfo); 
     
    211214    void printBuffer( unsigned int level, size_t length, fb_quadlet_t* buffer ) const; 
    212215    void printBufferBytes( unsigned int level, size_t length, byte_t* buffer ) const; 
    213      
     216 
    214217    static int resetHandlerLowLevel( raw1394handle_t handle, 
    215218                    unsigned int generation ); 
    216219    bool resetHandler( unsigned int generation ); 
    217      
     220 
    218221    static int armHandlerLowLevel(raw1394handle_t handle, unsigned long arm_tag, 
    219222                     byte_t request_type, unsigned int requested_length, 
    220                      void *data);  
     223                     void *data); 
    221224    bool armHandler(  unsigned long arm_tag, 
    222225                     byte_t request_type, unsigned int requested_length, 
     
    234237    typedef std::vector< Functor* > reset_handler_vec_t; 
    235238    reset_handler_vec_t m_busResetHandlers; 
    236      
     239 
    237240    // ARM stuff 
    238241    arm_tag_handler_t m_default_arm_handler; 
    239      
     242 
    240243    typedef std::vector< ARMHandler * > arm_handler_vec_t; 
    241244    arm_handler_vec_t m_armHandlers; 
    242      
     245 
    243246    fb_octlet_t byteSwap_octlet(fb_octlet_t value); 
    244      
     247 
    245248public: 
    246249    void setVerboseLevel(int l); 
     
    249252}; 
    250253 
    251 #endif 
     254#endif // FFADO_IEEE1394SERVICE_H 
  • trunk/libffado/src/libosc/OscArgument.cpp

    r432 r445  
    1 /* $Id$ */ 
    2  
    31/* 
    4  *   FreeBob Streaming API 
    5  *   FreeBob = Firewire (pro-)audio for linux 
     2 * Copyright (C) 2005-2007 by Pieter Palmers 
    63 * 
    7  *   http://freebob.sf.net 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    86 * 
    9  *   Copyright (C) 2007 Pieter Palmers <pieterpalmers@users.sourceforge.net> 
     7 * FFADO is based upon FreeBoB 
    108 * 
    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; 
    1512 * 
    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. 
     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. 
    2017 * 
    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  * 
     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 
    2522 */ 
    2623 
     
    3128IMPL_DEBUG_MODULE( OscArgument, OscArgument, DEBUG_LEVEL_VERBOSE ); 
    3229 
    33 OscArgument::OscArgument(int32_t i)  
     30OscArgument::OscArgument(int32_t i) 
    3431    : m_isInt(true) 
    3532    , m_intVal(i) 
     
    4239{} 
    4340 
    44 OscArgument::OscArgument(int64_t i)  
     41OscArgument::OscArgument(int64_t i) 
    4542    : m_isInt(false) 
    4643    , m_intVal(0) 
     
    5350{} 
    5451 
    55 OscArgument::OscArgument(float f)  
     52OscArgument::OscArgument(float f) 
    5653    : m_isInt(false) 
    5754    , m_intVal(0) 
     
    6461{} 
    6562 
    66 OscArgument::OscArgument(string s)  
     63OscArgument::OscArgument(string s) 
    6764    : m_isInt(false) 
    6865    , 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 */ 
    223 
    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__ 
    2826 
    2927#include "../debugmodule/debugmodule.h" 
     
    4442    OscArgument(string); 
    4543    virtual ~OscArgument(); 
    46      
     44 
    4745    bool operator == ( const OscArgument& rhs ); 
    48      
     46 
    4947    int32_t getInt() { return m_intVal;}; 
    5048    bool isInt() { return m_isInt;}; 
     
    5553    string& getString() { return m_stringVal;}; 
    5654    bool isString() { return m_isString;}; 
    57      
     55 
    5856    void print(); 
    59      
     57 
    6058protected: 
    6159    bool m_isInt; 
    6260    int32_t m_intVal; 
    63      
     61 
    6462    bool m_isInt64; 
    6563    int64_t m_int64Val; 
    66      
     64 
    6765    bool m_isFloat; 
    6866    float m_floatVal; 
    69      
     67 
    7068    bool m_isString; 
    7169    string m_stringVal; 
     
    7876} // end of namespace OSC 
    7977 
    80 #endif /* __FREEBOB_OSCARGUMENT__ */ 
     78#endif /* __FFADO_OSCARGUMENT__ */ 
    8179 
    8280 
  • trunk/libffado/src/libosc/OscMessage.cpp

    r432 r445  
    1 /* $Id$ */ 
    2  
    31/* 
    4  *   FreeBob Streaming API 
    5  *   FreeBob = Firewire (pro-)audio for linux 
     2 * Copyright (C) 2005-2007 by Pieter Palmers 
    63 * 
    7  *   http://freebob.sf.net 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    86 * 
    9  *   Copyright (C) 2007 Pieter Palmers <pieterpalmers@users.sourceforge.net> 
     7 * FFADO is based upon FreeBoB 
    108 * 
    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; 
    1512 * 
    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. 
     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. 
    2017 * 
    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 
    2722 */ 
    2823 
     
    6257                addArgument((int64_t)(argv[i]->h)); 
    6358                break; 
    64              
     59 
    6560            /* unsupported types */ 
    6661            /** OSC binary blob type. Accessed using the lo_blob_*() functions. */ 
     
    8681            case LO_INFINITUM: 
    8782            default: 
    88                 debugOutput(DEBUG_LEVEL_NORMAL,  
     83                debugOutput(DEBUG_LEVEL_NORMAL, 
    8984                            "unsupported osc type: %c\n", lo_type(types[i])); 
    9085        } 
  • 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 */ 
    223 
    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__ 
    3026 
    3127#include <string> 
     
    4743    OscMessage(string path, const char* types, lo_arg** argv, int argc); 
    4844    virtual ~OscMessage(); 
    49      
     45 
    5046    lo_message makeLoMessage(); 
    51      
     47 
    5248    void addArgument(int32_t v); 
    5349    void addArgument(int64_t v); 
    5450    void addArgument(float v); 
    5551    void addArgument(string v); 
    56      
     52 
    5753    OscArgument& getArgument(unsigned int idx); 
    5854    unsigned int nbArguments(); 
    59      
     55 
    6056    void setPath(string v); 
    6157    string getPath() {return m_Path;}; 
    6258    void print(); 
    63      
     59 
    6460protected: 
    6561    typedef std::vector< OscArgument > OscArgumentVector; 
     
    7571} // end of namespace OSC 
    7672 
    77 #endif /* __FREEBOB_OSCMESSAGE__ */ 
     73#endif /* __FFADO_OSCMESSAGE__ */ 
    7874 
    7975 
  • trunk/libffado/src/libosc/OscNode.cpp

    r436 r445  
    1 /* $Id$ */ 
    2  
    31/* 
    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 
    2522 */ 
    2623 
     
    8077{ 
    8178    debugOutput( DEBUG_LEVEL_VERBOSE, "(%p) MSG: %s\n",this, path.c_str()); 
    82      
     79 
    8380    // delete leading slash 
    8481    if(path.find_first_of('/')==0) path=path.substr(1,path.size()); 
    85      
     82 
    8683    // delete trailing slash 
    8784    if(path.find_last_of('/')==path.size()-1) path=path.substr(0,path.size()-1); 
    88      
     85 
    8986    // continue processing 
    9087    int firstsep=path.find_first_of('/'); 
     
    9289    if (firstsep == -1) { 
    9390        OscResponse retVal; 
    94          
     91 
    9592        // process the message 
    9693        retVal=processOscMessage(m); 
    97          
     94 
    9895        if(retVal.isHandled()) { 
    9996            return retVal; // completely handled 
     
    121118        } 
    122119        debugOutput( DEBUG_LEVEL_VERBOSE, "Child node %s not found \n",newbase.c_str()); 
    123          
     120 
    124121        return OscResponse(OscResponse::eError); 
    125122    } 
     
    160157} 
    161158 
    162 OscMessage  
     159OscMessage 
    163160OscNode::oscListChildren(OscMessage m) { 
    164      
     161 
    165162    for ( OscNodeVectorIterator it = m_ChildNodes.begin(); 
    166163      it != m_ChildNodes.end(); 
     
    179176{ 
    180177    assert(n); 
    181      
     178 
    182179    debugOutput( DEBUG_LEVEL_VERBOSE, "Adding child node %s\n",n->getOscBase().c_str()); 
    183180    for ( OscNodeVectorIterator it = m_ChildNodes.begin(); 
     
    186183    { 
    187184        if(*it == n) { 
    188             debugOutput( DEBUG_LEVEL_VERBOSE,  
     185            debugOutput( DEBUG_LEVEL_VERBOSE, 
    189186                "Child node %s already registered\n", 
    190187                n->getOscBase().c_str()); 
     
    202199 * you would add it using this function, by 
    203200 *  addChildOscNode(n, "/base/level1/level2") 
    204  *  
    205  * @param n  
    206  * @param   
    207  * @return  
     201 * 
     202 * @param n 
     203 * @param 
     204 * @return 
    208205 */ 
    209206bool 
     
    211208{ 
    212209    debugOutput( DEBUG_LEVEL_VERBOSE, "add node to: %s\n",path.c_str()); 
    213      
     210 
    214211    // delete leading slashes 
    215212    if(path.find_first_of('/')==0) path=path.substr(1,path.size()); 
    216      
     213 
    217214    // delete trailing slashes 
    218215    if(path.find_last_of('/')==path.size()-1) path=path.substr(0,path.size()-1); 
    219      
     216 
    220217    // continue processing 
    221218    int firstsep=path.find_first_of('/'); 
     
    243240        } 
    244241        debugOutput( DEBUG_LEVEL_VERBOSE, "node %s not found, creating auto-node\n",newbase.c_str()); 
    245          
     242 
    246243        OscNode *autoNode=new OscNode(newbase,true); 
    247          
     244 
    248245        // add the auto-node to this node 
    249246        m_ChildNodes.push_back(autoNode); 
    250          
     247 
    251248        // add the child to the node 
    252249        return autoNode->addChildOscNode(n,newpath); 
     
    255252} 
    256253 
    257 bool  
     254bool 
    258255OscNode::removeChildOscNode(OscNode *n) 
    259256{ 
     
    276273 
    277274    debugOutput( DEBUG_LEVEL_VERBOSE, "Child node %s not found \n",n->getOscBase().c_str()); 
    278      
     275 
    279276    return false; //not found 
    280277} 
    281278 
    282 void  
     279void 
    283280OscNode::printOscNode() 
    284281{ 
     
    286283} 
    287284 
    288 void  
     285void 
    289286OscNode::printOscNode(string path) 
    290287{ 
  • 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 */ 
    223 
    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__ 
    2826 
    2927#include "../debugmodule/debugmodule.h" 
     
    5553 
    5654    string getOscBase() {return m_oscBase;}; 
    57      
     55 
    5856    void setOscNodeAutoDelete(bool b) {m_oscAutoDelete=b;}; 
    5957    bool doOscNodeAutoDelete() {return m_oscAutoDelete;}; 
    60      
     58 
    6159    void printOscNode(string path); 
    6260    void printOscNode(); 
    63      
     61 
    6462    virtual OscResponse processOscMessage(OscMessage *m); 
    6563    virtual OscResponse processOscMessage(string path, OscMessage *m); 
    66      
     64 
    6765protected: 
    6866    void setOscBase(string s) {m_oscBase=s;}; 
     
    7169    OscResponse processOscMessageDefault(OscMessage *m, OscResponse); 
    7270    OscMessage oscListChildren(OscMessage); 
    73      
     71 
    7472    string m_oscBase; 
    7573    bool m_oscAutoDelete; 
    76      
     74 
    7775    typedef vector< OscNode * > OscNodeVector; 
    7876    typedef vector< OscNode * >::iterator OscNodeVectorIterator; 
     
    8886} // end of namespace OSC 
    8987 
    90 #endif /* __FREEBOB_OSCNODE__ */ 
     88#endif /* __FFADO_OSCNODE__ */ 
    9189 
    9290 
  • trunk/libffado/src/libosc/OscResponse.cpp

    r432 r445  
    1 /* $Id$ */ 
    2  
    31/* 
    4  *   FreeBob Streaming API 
    5  *   FreeBob = Firewire (pro-)audio for linux 
     2 * Copyright (C) 2005-2007 by Pieter Palmers 
    63 * 
    7  *   http://freebob.sf.net 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    86 * 
    9  *   Copyright (C) 2007 Pieter Palmers <pieterpalmers@users.sourceforge.net> 
     7 * FFADO is based upon FreeBoB 
    108 * 
    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; 
    1512 * 
    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. 
     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. 
    2017 * 
    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  * 
     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 
    2522 */ 
    2623 
  • 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 */ 
    223 
    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__ 
    2826 
    2927#include "OscMessage.h" 
     
    4745    OscResponse(OscMessage); 
    4846    virtual ~OscResponse(); 
    49      
     47 
    5048    OscMessage& getMessage() {return m_message;}; 
    51      
     49 
    5250    bool isError() {return m_type==eError;}; 
    5351    bool isHandled() {return (m_type != eError) && (m_type != eUnhandled);}; 
     
    5856    enum EType m_type; 
    5957    OscMessage m_message; 
    60      
     58 
    6159protected: 
    6260    DECLARE_DEBUG_MODULE; 
     
    6664} // end of namespace OSC 
    6765 
    68 #endif /* __FREEBOB_OSCRESPONSE__ */ 
     66#endif /* __FFADO_OSCRESPONSE__ */ 
    6967 
    7068 
  • trunk/libffado/src/libosc/OscServer.cpp

    r436 r445  
    1 /* $Id$ */ 
    2  
    31/* 
    4  *   FreeBob Streaming API 
    5  *   FreeBob = Firewire (pro-)audio for linux 
     2 * Copyright (C) 2005-2007 by Pieter Palmers 
    63 * 
    7  *   http://freebob.sf.net 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    86 * 
    9  *   Copyright (C) 2007 Pieter Palmers <pieterpalmers@users.sourceforge.net> 
     7 * FFADO is based upon FreeBoB 
    108 * 
    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; 
    1512 * 
    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. 
     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. 
    2017 * 
    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  * 
     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 
    2522 */ 
    2623 
     
    8683        return false; 
    8784    } 
    88      
     85 
    8986    m_server = lo_server_thread_new(m_port.c_str(), error_cb); 
    90      
     87 
    9188    if (m_server == NULL) { 
    9289        debugWarning("Could not start OSC server on port %s, trying other port...\n", m_port.c_str()); 
     
    9693            return false; 
    9794        } 
    98         debugWarning("Started OSC server at %s\n",  
     95        debugWarning("Started OSC server at %s\n", 
    9996                    lo_server_get_url(lo_server_thread_get_server(m_server))); 
    10097    } else { 
    10198        debugOutput(DEBUG_LEVEL_VERBOSE, 
    102                     "Started OSC server at %s\n",  
     99                    "Started OSC server at %s\n", 
    103100                    lo_server_get_url(lo_server_thread_get_server(m_server))); 
    104101    } 
    105      
     102 
    106103    // For debugging, print all incoming OSC messages 
    107104    lo_server_thread_add_method(m_server, NULL, NULL, generic_cb, this); 
     
    134131    OscServer *server=reinterpret_cast<OscServer *>(user_data); 
    135132    assert(server); 
    136      
     133 
    137134    debugOutput(DEBUG_LEVEL_VERBOSE, "Message on: %s\n", path); 
    138135 
     
    144141    // construct the message 
    145142    OscMessage m = OscMessage(path, types, argv, argc); 
    146      
     143 
    147144#ifdef DEBUG 
    148145    if (getDebugLevel()>=DEBUG_LEVEL_VERY_VERBOSE) { 
     
    162159            // send response 
    163160            lo_address addr = lo_message_get_source(msg); 
    164              
     161 
    165162            lo_message lo_msg; 
    166163            lo_msg=r.getMessage().makeLoMessage(); 
    167              
     164 
    168165            debugOutput(DEBUG_LEVEL_VERBOSE, " Sending response to %s\n",lo_address_get_url(addr)); 
    169              
     166 
    170167            #ifdef DEBUG 
    171168                if(getDebugLevel()>=DEBUG_LEVEL_VERY_VERBOSE) r.getMessage().print(); 
    172169            #endif 
    173              
     170 
    174171            if (lo_send_message(addr, "/response", lo_msg) < 0) { 
    175172                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 */ 
    223 
    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__ 
    3026 
    3127#include <lo/lo.h> 
     
    4642    OscServer(string port); 
    4743    virtual ~OscServer(); 
    48      
     44 
    4945    bool init(); 
    5046    bool start(); 
    5147    bool stop(); 
    52      
     48 
    5349    bool registerAtRootNode(OscNode *); 
    5450    bool unregisterAtRootNode(OscNode *); 
    5551 
    5652private: 
    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); 
    5854    static int  generic_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg, void* user_data); 
    59      
     55 
    6056protected: 
    6157    string             m_port; 
    6258    lo_server_thread   m_server; 
    63      
     59 
    6460    OscNode * m_rootNode; 
    6561 
     
    7369} // end of namespace OSC 
    7470 
    75 #endif /* __FREEBOB_OSCSERVER__ */ 
     71#endif /* __FFADO_OSCSERVER__ */ 
    7672 
    7773 
  • 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, 
    1115 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    1216 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     
    1418 * 
    1519 * You should have received a copy of the GNU General Public License 
    16  * along with FreeBoB; if not, write to the Free Software 
     20 * along with FFADO; if not, write to the Free Software 
    1721 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
    1822 * MA 02111-1307 USA. 
    1923 */ 
    20  
    2124 
    2225#include "OscServer.h" 
     
    3639#define TEST_SHOULD_RETURN_FALSE(test) \ 
    3740    (test ? printf( "'" #test "' should return true\n") && false : true ) 
    38      
     41 
    3942static int run=0; 
    4043 
     
    5053    bool result=true; 
    5154    OscMessage m=OscMessage(); 
    52      
     55 
    5356    m.addArgument((float)1.1); 
    5457    m.addArgument("teststring"); 
    5558    m.addArgument(1); 
    5659    m.print(); 
    57      
     60 
    5861    result &= TEST_SHOULD_RETURN_TRUE(m.nbArguments()==3); 
    5962    result &= TEST_SHOULD_RETURN_TRUE(m.getArgument(0).getFloat()==(float)1.1); 
    6063    result &= TEST_SHOULD_RETURN_TRUE(m.getArgument(1).getString()==string("teststring")); 
    6164    result &= TEST_SHOULD_RETURN_TRUE(m.getArgument(2).getInt()==1); 
    62      
     65 
    6366    return result; 
    6467} 
     
    6972    bool result=true; 
    7073    OscMessage m=OscMessage(); 
    71      
     74 
    7275    OscNode n1=OscNode("base1"); 
    7376    OscNode n2=OscNode("child1"); 
     
    7578    OscNode n4=OscNode("subchild1"); 
    7679    OscNode n5=OscNode("subchild2"); 
    77      
     80 
    7881    OscNode n6=OscNode("subsubchild1"); 
    7982    OscNode n7=OscNode("subsubchild2"); 
    80      
     83 
    8184    OscNode n8=OscNode("auto1"); 
    8285    OscNode n9=OscNode("auto2"); 
    83      
     86 
    8487    n1.addChildOscNode(&n2); 
    8588    n1.addChildOscNode(&n3); 
    8689    n2.addChildOscNode(&n4); 
    8790    n2.addChildOscNode(&n5); 
    88      
     91 
    8992    n1.addChildOscNode(&n6,"base1/child1/"); 
    9093    n1.addChildOscNode(&n7,"base1/child1/"); 
    91      
     94 
    9295    n1.addChildOscNode(&n8,"auto1/test/"); 
    9396    n1.addChildOscNode(&n9,"auto1/test2/"); 
    94      
     97 
    9598    n1.printOscNode(); 
    96      
     99 
    97100    result &= TEST_SHOULD_RETURN_FALSE(n1.processOscMessage("base1",&m).isError()); 
    98101    result &= TEST_SHOULD_RETURN_FALSE(n1.processOscMessage("base1/child1",&m).isError()); 
     
    102105    result &= TEST_SHOULD_RETURN_FALSE(n1.processOscMessage("base1/child2",&m).isError()); 
    103106    result &= TEST_SHOULD_RETURN_TRUE(n1.processOscMessage("base1/child2/subchild1",&m).isError()); 
    104      
     107 
    105108    return result; 
    106109} 
     
    108111//////////////////////////////// 
    109112 
    110 class OscTestNode  
     113class OscTestNode 
    111114    : public OscNode 
    112115{ 
     
    124127test_OscServer_T1() { 
    125128    bool result=true; 
    126      
     129 
    127130    OscServer s=OscServer("17820"); 
    128      
     131 
    129132    if (!s.init()) { 
    130133        printf("failed to init server"); 
    131134        return false; 
    132135    } 
    133      
     136 
    134137    OscNode n1=OscNode("base1"); 
    135138    OscNode n2=OscNode("child1"); 
     
    137140    OscNode n4=OscNode("subchild1"); 
    138141    OscNode n5=OscNode("subchild2"); 
    139      
     142 
    140143    OscNode n6=OscNode("subsubchild1"); 
    141144    OscNode n7=OscNode("subsubchild2"); 
    142      
     145 
    143146    OscNode n8=OscNode("auto1"); 
    144147    OscNode n9=OscNode("auto2"); 
    145      
     148 
    146149    n1.addChildOscNode(&n2); 
    147150    n1.addChildOscNode(&n3); 
    148151    n2.addChildOscNode(&n4); 
    149152    n2.addChildOscNode(&n5); 
    150      
     153 
    151154    n1.addChildOscNode(&n6,"base1/child1/"); 
    152155    n1.addChildOscNode(&n7,"base1/child1/"); 
    153      
     156 
    154157    n1.addChildOscNode(&n8,"auto1/test/"); 
    155158    n1.addChildOscNode(&n9,"auto1/test2/"); 
    156      
     159 
    157160    OscTestNode n10=OscTestNode("base2"); 
    158      
     161 
    159162    if (!s.registerAtRootNode(&n1)) { 
    160163        printf("failed to register base1 at server"); 
     
    165168        return false; 
    166169    } 
    167      
     170 
    168171    if (!s.start()) { 
    169172        printf("failed to start server"); 
    170173        return false; 
    171174    } 
    172      
     175 
    173176    printf("server started\n"); 
    174177    printf("press ctrl-c to stop it & continue\n"); 
    175      
     178 
    176179    signal (SIGINT, sighandler); 
    177      
     180 
    178181    run=1; 
    179182    while(run) { 
     
    183186    } 
    184187    signal (SIGINT, SIG_DFL); 
    185      
     188 
    186189    if (!s.stop()) { 
    187190        printf("failed to stop server"); 
    188191        return false; 
    189192    } 
    190      
     193 
    191194    if (!s.unregisterAtRootNode(&n1)) { 
    192195        printf("failed to unregister base1 at server"); 
     
    197200        return false; 
    198201    } 
    199      
     202 
    200203    return result; 
    201204} 
  • 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 */ 
    223 
    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  */ 
    2824#include "AmdtpPort.h" 
    2925#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 */ 
    223 
    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__ 
    3026 
    3127/** 
     
    4339 
    4440 The AMDTP/AM824/IEC61883-6 port that represents audio. 
    45   
     41 
    4642*/ 
    47 class AmdtpAudioPort  
    48        : public AudioPort, public AmdtpPortInfo 
     43class AmdtpAudioPort 
     44    : public AudioPort, public AmdtpPortInfo 
    4945{ 
    5046 
    5147public: 
    5248 
    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    {}; 
    6157 
    62        virtual ~AmdtpAudioPort() {}; 
    63   
     58    virtual ~AmdtpAudioPort() {}; 
     59 
    6460protected: 
    6561 
     
    7066 
    7167 The AMDTP/AM824/IEC61883-6 port that represents midi. 
    72   
     68 
    7369*/ 
    74 class AmdtpMidiPort  
    75        : public MidiPort, public AmdtpPortInfo 
     70class AmdtpMidiPort 
     71    : public MidiPort, public AmdtpPortInfo 
    7672{ 
    7773 
    7874public: 
    7975 
    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    {}; 
    8884 
    8985 
    90        virtual ~AmdtpMidiPort() {}; 
     86    virtual ~AmdtpMidiPort() {}; 
    9187 
    9288protected: 
    93          
     89 
    9490}; 
    9591 
    9692} // end of namespace Streaming 
    9793 
    98 #endif /* __FREEBOB_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 */ 
    223 
    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  */ 
    2824#include "AmdtpPortInfo.h" 
    2925#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 */ 
    223 
    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__ 
    3026 
    3127#include "../debugmodule/debugmodule.h" 
     
    3733 
    3834 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 
    4036 to this port. 
    41   
     37 
    4238*/ 
    4339class AmdtpPortInfo { 
     
    4541public: 
    4642    /** 
    47      * Sometimes a channel can have multiple formats, depending on the  
     43     * Sometimes a channel can have multiple formats, depending on the 
    4844     * 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.) 
    5046     * 
    5147     * This kind of enum allows to discriminate these formats when decoding 
    5248     * If all channels always have the same format, you won't be needing this 
    5349     */ 
    54        enum E_Formats { 
    55                E_MBLA, ///< multibit linear audio 
    56                E_Midi, ///< midi 
    57                E_SPDIF,///< IEC.... format 
    58        }; 
     50    enum E_Formats { 
     51        E_MBLA, ///< multibit linear audio 
     52        E_Midi, ///< midi 
     53        E_SPDIF,///< IEC.... format 
     54    }; 
    5955 
    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() {}; 
    6460 
    6561 
    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;}; 
    7066 
    7167protected: 
     
    8076} // end of namespace Streaming 
    8177 
    82 #endif /* __FREEBOB_AMDTPPORTINFO__ */ 
     78#endif /* __FFADO_AMDTPPORTINFO__ */ 
  • trunk/libffado/src/libstreaming/AmdtpSlaveStreamProcessor.cpp

    r435 r445  
    1 /* $Id$ */ 
    2  
    31/* 
    4  *   FreeBob Streaming API 
    5  *   FreeBob = Firewire (pro-)audio for linux 
     2 * Copyright (C) 2005-2007 by Pieter Palmers 
    63 * 
    7  *   http://freebob.sf.net 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    86 * 
    9  *   Copyright (C) 2005,2006,2007 Pieter Palmers <pieterpalmers@users.sourceforge.net> 
     7 * FFADO is based upon FreeBoB. 
    108 * 
    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; 
    1512 * 
    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. 
     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. 
    2017 * 
    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 
    2722 */ 
     23 
    2824#include "AmdtpSlaveStreamProcessor.h" 
    2925 
     
    5349enum raw1394_iso_disposition 
    5450AmdtpSlaveTransmitStreamProcessor::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 
    5854    struct iec61883_packet *packet = (struct iec61883_packet *) data; 
    5955    if (cycle<0) return RAW1394_ISO_OK; 
    60      
     56 
    6157    m_last_cycle=cycle; 
    62      
     58 
    6359    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Xmit handler for cycle %d, (running=%d, enabled=%d,%d)\n", 
    6460        cycle, m_running, m_disabled, m_is_disabled); 
    65      
     61 
    6662#ifdef DEBUG 
    6763    if(dropped>0) { 
     
    6965    } 
    7066#endif 
    71      
     67 
    7268    // calculate & preset common values 
    73      
     69 
    7470    /* Our node ID can change after a bus reset, so it is best to fetch 
    7571     * our node ID for each packet. */ 
     
    8480    packet->eoh1 = 2; 
    8581    packet->fmt = IEC61883_FMT_AMDTP; 
    86      
     82 
    8783    *tag = IEC61883_TAG_WITH_CIP; 
    8884    *sy = 0; 
    89      
     85 
    9086    // determine if we want to send a packet or not 
    9187    // note that we can't use getCycleTimer directly here, 
    9288    // 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 
    9490    // on 'cycle', not 'now'. 
    9591    unsigned int ctr=m_handler->getCycleTimer(); 
    9692    int now_cycles = (int)CYCLE_TIMER_GET_CYCLES(ctr); 
    97      
     93 
    9894    // the difference between the cycle this 
    9995    // packet is intended for and 'now' 
    10096    int cycle_diff = diffCycles(cycle, now_cycles); 
    101      
     97 
    10298#ifdef DEBUG 
    10399    if(m_running && (cycle_diff < 0)) { 
     
    114110        debugOutput(DEBUG_LEVEL_VERBOSE, "Xmit StreamProcessor %p started running at cycle %d\n",this, cycle); 
    115111        m_running=true; 
    116          
     112 
    117113        uint32_t ticks_to_advance = TICKS_PER_CYCLE * TRANSMIT_ADVANCE_CYCLES; 
    118          
     114 
    119115        // if cycle lies cycle_diff cycles in the future, the 
    120116        // timestamp for it corresponds to 
    121117        // now+cycle_diff * TICKS_PER_CYCLE 
    122118        ticks_to_advance += cycle_diff * TICKS_PER_CYCLE; 
    123      
     119 
    124120        // determine the 'now' time in ticks 
    125121        uint32_t cycle_timer=CYCLE_TIMER_TO_TICKS(ctr); 
    126          
     122 
    127123        cycle_timer = addTicks(cycle_timer, ticks_to_advance); 
    128124        m_data_buffer->setBufferHeadTimestamp(cycle_timer); 
    129125    } 
    130      
     126 
    131127    uint64_t ts_head, fc; 
    132128    if (!m_disabled && m_is_disabled) { // this means that we are trying to enable 
    133129        // check if we are on or past the enable point 
    134130        int cycles_past_enable=diffCycles(cycle, m_cycle_to_enable_at); 
    135          
     131 
    136132        if (cycles_past_enable >= 0) { 
    137133            m_is_disabled=false; 
    138              
     134 
    139135            debugOutput(DEBUG_LEVEL_VERBOSE,"Enabling StreamProcessor %p at %u\n", this, cycle); 
    140              
     136 
    141137            // initialize the buffer head & tail 
    142138            m_SyncSource->m_data_buffer->getBufferHeadTimestamp(&ts_head, &fc); // thread safe 
    143              
     139 
    144140            // the number of cycles the sync source lags (> 0) 
    145141            // or leads (< 0) 
    146142            int sync_lag_cycles=diffCycles(cycle, m_SyncSource->getLastCycle()); 
    147              
     143 
    148144            // account for the cycle lag between sync SP and this SP 
    149145            // the last update of the sync source's timestamps was sync_lag_cycles 
    150146            // 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 
    152148            // frame that is sent on cycle CT to have a timestamp T1. 
    153149            // ts_head however is for cycle CT-sync_lag_cycles, and lies 
     
    155151            // T1. 
    156152            ts_head = addTicks(ts_head, (sync_lag_cycles) * TICKS_PER_CYCLE); 
    157              
     153 
    158154            ts_head = substractTicks(ts_head, TICKS_PER_CYCLE); 
    159              
     155 
    160156            // account for the number of cycles we are too late to enable 
    161157            ts_head = addTicks(ts_head, cycles_past_enable * TICKS_PER_CYCLE); 
    162              
     158 
    163159            // account for one extra packet of frames 
    164             ts_head = substractTicks(ts_head,  
     160            ts_head = substractTicks(ts_head, 
    165161                        (uint32_t)((float)m_syt_interval * m_SyncSource->m_data_buffer->getRate())); 
    166162 
     
    181177    } else if (m_disabled && !m_is_disabled) { 
    182178        // 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", 
    184180                    this, cycle); 
    185181        m_is_disabled=true; 
    186182    } 
    187      
     183 
    188184    // the base timestamp is the one of the next sample in the buffer 
    189185    m_data_buffer->getBufferHeadTimestamp(&ts_head, &fc); // thread safe 
     
    191187    // we send a packet some cycles in advance, to avoid the 
    192188    // following situation: 
    193     // suppose we are only a few ticks away from  
     189    // suppose we are only a few ticks away from 
    194190    // the moment to send this packet. therefore we decide 
    195191    // not to send the packet, but send it in the next cycle. 
    196192    // 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 
    198194    // packet is sent, unless TRANSFER_DELAY > 3072. 
    199195    // this means that we need at least one cycle of extra buffering. 
    200196    uint32_t ticks_to_advance = TICKS_PER_CYCLE * TRANSMIT_ADVANCE_CYCLES; 
    201      
     197 
    202198    // if cycle lies cycle_diff cycles in the future, we should 
    203199    // queue this packet cycle_diff * TICKS_PER_CYCLE earlier than 
     
    207203    // determine the 'now' time in ticks 
    208204    uint32_t cycle_timer=CYCLE_TIMER_TO_TICKS(ctr); 
    209      
     205 
    210206    cycle_timer = addTicks(cycle_timer, ticks_to_advance); 
    211      
     207 
    212208    // time until the packet is to be sent (if > 0: send packet) 
    213209    int32_t until_next=diffTicks(ts_head, cycle_timer); 
     
    218214        // add the transmit transfer delay to construct the playout time (=SYT timestamp) 
    219215        uint32_t ts_packet=addTicks(ts_head, TRANSMIT_TRANSFER_DELAY); 
    220      
     216 
    221217        // if we are disabled, send a silent packet 
    222218        // and advance the buffer head timestamp 
    223219        if(m_is_disabled) { 
    224              
     220 
    225221            transmitSilenceBlock((char *)(data+8), m_syt_interval, 0); 
    226222            m_dbc += fillDataPacketHeader(packet, length, ts_packet); 
    227              
     223 
    228224            debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "XMIT SYNC: CY=%04u TSH=%011llu TSP=%011lu\n", 
    229225                cycle, ts_head, ts_packet); 
     
    232228            uint32_t ts_step=(uint32_t)((float)(m_syt_interval) 
    233229                             *m_SyncSource->m_data_buffer->getRate()); 
    234              
     230 
    235231            // the next buffer head timestamp 
    236232            ts_head=addTicks(ts_head,ts_step); 
    237233            m_data_buffer->setBufferHeadTimestamp(ts_head); 
    238              
     234 
    239235            // defer to make sure we get to be enabled asap 
    240236            return RAW1394_ISO_DEFER; 
    241              
     237 
    242238        } else { // enabled & packet due, read from the buffer 
    243239            if (m_data_buffer->readFrames(m_syt_interval, (char *)(data + 8))) { 
    244240                m_dbc += fillDataPacketHeader(packet, length, ts_packet); 
    245                  
     241 
    246242                // process all ports that should be handled on a per-packet base 
    247243                // this is MIDI for AMDTP (due to the need of DBC) 
     
    249245                    debugWarning("Problem encoding Packet Ports\n"); 
    250246                } 
    251                  
     247 
    252248                debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "XMIT DATA: CY=%04u TSH=%011llu TSP=%011lu\n", 
    253249                    cycle, ts_head, ts_packet); 
    254                  
     250 
    255251                return RAW1394_ISO_OK; 
    256                  
     252 
    257253            } else if (now_cycles<cycle) { 
    258254                // we can still postpone the queueing of the packets 
    259255                // because the ISO transmit packet buffer is not empty yet 
    260256                return RAW1394_ISO_AGAIN; 
    261                  
     257 
    262258            } else { // there is no more data in the ringbuffer 
    263259                // compose a silent packet, we should always 
     
    265261                transmitSilenceBlock((char *)(data+8), m_syt_interval, 0); 
    266262                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", 
    269265                        now_cycles, cycle, TICKS_TO_CYCLES(ts_packet)); 
    270266                // signal underrun 
     
    274270                m_disabled=true; 
    275271                m_is_disabled=true; 
    276                  
     272 
    277273                return RAW1394_ISO_DEFER; 
    278274            } 
    279275        } 
    280          
     276 
    281277    } else { // no packet due, send no-data packet 
    282278        debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "XMIT NONE: CY=%04u TSH=%011llu\n", 
    283279                cycle, ts_head); 
    284                  
     280 
    285281        m_dbc += fillNoDataPacketHeader(packet, length); 
    286282        return RAW1394_ISO_DEFER; 
    287283    } 
    288      
     284 
    289285    // we shouldn't get here 
    290286    return RAW1394_ISO_ERROR; 
     
    298294{} 
    299295 
    300 AmdtpSlaveReceiveStreamProcessor::~AmdtpSlaveReceiveStreamProcessor()  
     296AmdtpSlaveReceiveStreamProcessor::~AmdtpSlaveReceiveStreamProcessor() 
    301297{} 
    302298 
    303 enum raw1394_iso_disposition  
    304 AmdtpSlaveReceiveStreamProcessor::putPacket(unsigned char *data, unsigned int length,  
    305                   unsigned char channel, unsigned char tag, unsigned char sy,  
     299enum raw1394_iso_disposition 
     300AmdtpSlaveReceiveStreamProcessor::putPacket(unsigned char *data, unsigned int length, 
     301                  unsigned char channel, unsigned char tag, unsigned char sy, 
    306302                  unsigned int cycle, unsigned int dropped) { 
    307      
     303 
    308304    enum raw1394_iso_disposition retval=RAW1394_ISO_OK; 
    309305    m_last_cycle=cycle; 
    310      
     306 
    311307    struct iec61883_packet *packet = (struct iec61883_packet *) data; 
    312308    assert(packet); 
     
    318314 
    319315    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), 
    321317        CYCLE_TIMER_GET_CYCLES(ntohs(packet->syt)), CYCLE_TIMER_GET_OFFSET(ntohs(packet->syt)), 
    322318        m_running,m_disabled,m_is_disabled); 
    323319 
    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", 
    326322        channel, packet->fdf, 
    327323        packet->syt, 
    328324        packet->dbs, 
    329325        packet->dbc, 
    330         packet->fmt,  
     326        packet->fmt, 
    331327        length); 
    332328 
     
    336332        // check if we are on or past the enable point 
    337333        int cycles_past_enable=diffCycles(cycle, m_cycle_to_enable_at); 
    338          
     334 
    339335        if (cycles_past_enable >= 0) { 
    340336            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", 
    342338                this, cycle, ntohs(packet->syt)); 
    343339            // the previous timestamp is the one we need to start with 
     
    358354 
    359355    // 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) 
    362358       && (packet->fmt == 0x10) 
    363        && (packet->dbs>0)  
     359       && (packet->dbs>0) 
    364360       && (length>=2*sizeof(quadlet_t))) { 
    365         
     361 
    366362        unsigned int nevents=((length / sizeof (quadlet_t)) - 2)/packet->dbs; 
    367363 
     
    370366 
    371367        //=> 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), 
    373369                                        cycle, m_handler->getCycleTimer()); 
    374370 
    375371        debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "RECV: CY=%04u TS=%011llu\n", 
    376372                cycle, m_last_timestamp); 
    377          
     373 
    378374        // we have to keep in mind that there are also 
    379375        // some packets buffered by the ISO layer, 
     
    385381        debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"STMP: %lluticks | buff=%d, syt_interval=%d, tpf=%f\n", 
    386382            m_last_timestamp, m_handler->getWakeupInterval(),m_syt_interval,m_ticks_per_frame); 
    387          
     383 
    388384        //=> signal that we're running (if we are) 
    389385        if(!m_running && nevents && m_last_timestamp2 && m_last_timestamp) { 
     
    399395            // estimate as to when a period might be ready. i.e. it will not 
    400396            // 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 
    403399            // SYT_INTERVAL * rate later 
    404400            uint64_t ts=addTicks(m_last_timestamp, 
     
    408404            // the buffer by the next packet. 
    409405            m_data_buffer->setBufferTailTimestamp(ts); 
    410              
     406 
    411407            return RAW1394_ISO_DEFER; 
    412408        } 
    413          
     409 
    414410        #ifdef DEBUG_OFF 
    415         if((cycle % 1000) == 0)  
     411        if((cycle % 1000) == 0) 
    416412        { 
    417413            uint32_t syt = (uint32_t)ntohs(packet->syt); 
    418414            uint32_t now=m_handler->getCycleTimer(); 
    419415            uint32_t now_ticks=CYCLE_TIMER_TO_TICKS(now); 
    420              
     416 
    421417            uint32_t test_ts=sytRecvToFullTicks(syt, cycle, now); 
    422418 
     
    432428        } 
    433429        #endif 
    434          
     430 
    435431        //=> process the packet 
    436432        // 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)) { 
    438434            retval=RAW1394_ISO_OK; 
    439              
     435 
    440436            // process all ports that should be handled on a per-packet base 
    441437            // this is MIDI for AMDTP (due to the need of DBC) 
     
    444440                retval=RAW1394_ISO_DEFER; 
    445441            } 
    446              
     442 
    447443        } 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", 
    450446                 cycle, m_data_buffer->getFrameCounter(), m_handler->getPacketCount()); 
    451              
     447 
    452448            m_xruns++; 
    453              
     449 
    454450            // disable the processing, will be re-enabled when 
    455451            // 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 */ 
    223 
    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__ 
    3026 
    3127/** 
     
    4642#define IEC61883_STREAM_TYPE_MBLA   0x06 
    4743 
    48 #define IEC61883_AM824_LABEL_MASK                      0xFF000000 
    49 #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)) 
    5147 
    52 #define IEC61883_AM824_LABEL_MIDI_NO_DATA      0x80  
    53 #define IEC61883_AM824_LABEL_MIDI_1X           0x81  
    54 #define IEC61883_AM824_LABEL_MIDI_2X           0x82 
    55 #define IEC61883_AM824_LABEL_MIDI_3X           0x83 
     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 
    5652 
    5753namespace Streaming { 
     
    5955class AmdtpSlaveReceiveStreamProcessor; 
    6056 
    61 class AmdtpSlaveTransmitStreamProcessor  
     57class AmdtpSlaveTransmitStreamProcessor 
    6258    : public AmdtpTransmitStreamProcessor 
    6359{ 
     
    6864    virtual ~AmdtpSlaveTransmitStreamProcessor(); 
    6965 
    70     enum raw1394_iso_disposition  
     66    enum raw1394_iso_disposition 
    7167            getPacket(unsigned char *data, unsigned int *length, 
    7268                    unsigned char *tag, unsigned char *sy, 
     
    7571}; 
    7672 
    77 class AmdtpSlaveReceiveStreamProcessor  
     73class AmdtpSlaveReceiveStreamProcessor 
    7874    : public AmdtpReceiveStreamProcessor 
    7975{ 
     
    8480    virtual ~AmdtpSlaveReceiveStreamProcessor(); 
    8581 
    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, 
    8884                    unsigned int cycle, unsigned int dropped); 
    8985 
     
    9389} // end of namespace Streaming 
    9490 
    95 #endif /* __FREEBOB_AMDTPSLAVESTREAMPROCESSOR__ */ 
     91#endif /* __FFADO_AMDTPSLAVESTREAMPROCESSOR__ */ 
    9692 
  • trunk/libffado/src/libstreaming/AmdtpStreamProcessor.cpp

    r435 r445  
    1 /* $Id$ */ 
    2  
    31/* 
    4  *   FreeBob Streaming API 
    5  *   FreeBob = Firewire (pro-)audio for linux 
     2 * Copyright (C) 2005-2007 by Pieter Palmers 
    63 * 
    7  *   http://freebob.sf.net 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    86 * 
    9  *   Copyright (C) 2005,2006,2007 Pieter Palmers <pieterpalmers@users.sourceforge.net> 
     7 * FFADO is based upon FreeBoB. 
    108 * 
    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; 
    1512 * 
    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. 
     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. 
    2017 * 
    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 
    2722 */ 
     23 
    2824#include "AmdtpStreamProcessor.h" 
    2925#include "Port.h" 
     
    5955 
    6056/** 
    61  * @return  
     57 * @return 
    6258 */ 
    6359bool AmdtpTransmitStreamProcessor::init() { 
    6460 
    65        debugOutput( DEBUG_LEVEL_VERBOSE, "Initializing (%p)...\n"); 
    66        // call the parent init 
    67         // this has to be done before allocating the buffers,  
    68        // because this sets the buffersizes from the processormanager 
    69        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; 
    7571} 
    7672 
    7773void AmdtpTransmitStreamProcessor::setVerboseLevel(int l) { 
    78        setDebugLevel(l); 
    79        TransmitStreamProcessor::setVerboseLevel(l); 
     74    setDebugLevel(l); 
     75    TransmitStreamProcessor::setVerboseLevel(l); 
    8076} 
    8177 
    8278enum raw1394_iso_disposition 
    8379AmdtpTransmitStreamProcessor::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 
    8783    struct iec61883_packet *packet = (struct iec61883_packet *) data; 
    8884    if (cycle<0) return RAW1394_ISO_OK; 
    89      
     85 
    9086    m_last_cycle=cycle; 
    91      
     87 
    9288    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"Xmit handler for cycle %d, (running=%d, enabled=%d,%d)\n", 
    9389        cycle, m_running, m_disabled, m_is_disabled); 
    94      
     90 
    9591#ifdef DEBUG 
    9692    if(dropped>0) { 
     
    9894    } 
    9995#endif 
    100      
     96 
    10197    // calculate & preset common values 
    102      
     98 
    10399    /* Our node ID can change after a bus reset, so it is best to fetch 
    104100     * our node ID for each packet. */ 
     
    113109    packet->eoh1 = 2; 
    114110    packet->fmt = IEC61883_FMT_AMDTP; 
    115      
     111 
    116112    *tag = IEC61883_TAG_WITH_CIP; 
    117113    *sy = 0; 
    118      
     114 
    119115    // determine if we want to send a packet or not 
    120116    // note that we can't use getCycleTimer directly here, 
    121117    // 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 
    123119    // on 'cycle', not 'now'. 
    124120    unsigned int ctr=m_handler->getCycleTimer(); 
    125121    int now_cycles = (int)CYCLE_TIMER_GET_CYCLES(ctr); 
    126      
     122 
    127123    // the difference between the cycle this 
    128124    // packet is intended for and 'now' 
    129125    int cycle_diff = diffCycles(cycle, now_cycles); 
    130      
     126 
    131127#ifdef DEBUG 
    132128    if(m_running && (cycle_diff < 0)) { 
     
    144140            m_running=true; 
    145141    } 
    146      
     142 
    147143    uint64_t ts_head, fc; 
    148144    if (!m_disabled && m_is_disabled) { // this means that we are trying to enable 
    149145        // check if we are on or past the enable point 
    150146        int cycles_past_enable=diffCycles(cycle, m_cycle_to_enable_at); 
    151          
     147 
    152148        if (cycles_past_enable >= 0) { 
    153149            m_is_disabled=false; 
    154              
     150 
    155151            debugOutput(DEBUG_LEVEL_VERBOSE,"Enabling StreamProcessor %p at %u\n", this, cycle); 
    156              
     152 
    157153            // initialize the buffer head & tail 
    158154            m_SyncSource->m_data_buffer->getBufferHeadTimestamp(&ts_head, &fc); // thread safe 
    159              
     155 
    160156            // the number of cycles the sync source lags (> 0) 
    161157            // or leads (< 0) 
    162158            int sync_lag_cycles=diffCycles(cycle, m_SyncSource->getLastCycle()); 
    163              
     159 
    164160            // account for the cycle lag between sync SP and this SP 
    165161            // the last update of the sync source's timestamps was sync_lag_cycles 
    166162            // 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 
    168164            // frame that is sent on cycle CT to have a timestamp T1. 
    169165            // ts_head however is for cycle CT-sync_lag_cycles, and lies 
     
    171167            // T1. 
    172168            ts_head = addTicks(ts_head, (sync_lag_cycles) * TICKS_PER_CYCLE); 
    173              
     169 
    174170            ts_head = substractTicks(ts_head, TICKS_PER_CYCLE); 
    175              
     171 
    176172            // account for the number of cycles we are too late to enable 
    177173            ts_head = addTicks(ts_head, cycles_past_enable * TICKS_PER_CYCLE); 
    178              
     174 
    179175            // account for one extra packet of frames 
    180             ts_head = substractTicks(ts_head,  
     176            ts_head = substractTicks(ts_head, 
    181177                        (uint32_t)((float)m_syt_interval * m_SyncSource->m_data_buffer->getRate())); 
    182178 
     
    197193    } else if (m_disabled && !m_is_disabled) { 
    198194        // 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", 
    200196                    this, cycle); 
    201197        m_is_disabled=true; 
    202198    } 
    203      
     199 
    204200    // the base timestamp is the one of the next sample in the buffer 
    205201    m_data_buffer->getBufferHeadTimestamp(&ts_head, &fc); // thread safe 
     
    207203    // we send a packet some cycles in advance, to avoid the 
    208204    // following situation: 
    209     // suppose we are only a few ticks away from  
     205    // suppose we are only a few ticks away from 
    210206    // the moment to send this packet. therefore we decide 
    211207    // not to send the packet, but send it in the next cycle. 
    212208    // 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 
    214210    // packet is sent, unless TRANSFER_DELAY > 3072. 
    215211    // this means that we need at least one cycle of extra buffering. 
    216212    uint32_t ticks_to_advance = TICKS_PER_CYCLE * TRANSMIT_ADVANCE_CYCLES; 
    217      
     213 
    218214    // if cycle lies cycle_diff cycles in the future, we should 
    219215    // queue this packet cycle_diff * TICKS_PER_CYCLE earlier than 
     
    223219    // determine the 'now' time in ticks 
    224220    uint32_t cycle_timer=CYCLE_TIMER_TO_TICKS(ctr); 
    225      
     221 
    226222    cycle_timer = addTicks(cycle_timer, ticks_to_advance); 
    227      
     223 
    228224    // time until the packet is to be sent (if > 0: send packet) 
    229225    int32_t until_next=diffTicks(ts_head, cycle_timer); 
     
    234230        // add the transmit transfer delay to construct the playout time (=SYT timestamp) 
    235231        uint32_t ts_packet=addTicks(ts_head, TRANSMIT_TRANSFER_DELAY); 
    236      
     232 
    237233        // if we are disabled, send a silent packet 
    238234        // and advance the buffer head timestamp 
    239235        if(m_is_disabled) { 
    240              
     236 
    241237//             transmitSilenceBlock((char *)(data+8), m_syt_interval, 0); 
    242238//             m_dbc += fillDataPacketHeader(packet, length, ts_packet); 
    243 //              
     239// 
    244240//             debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "XMIT SYNC: CY=%04u TSH=%011llu TSP=%011lu\n", 
    245241//                 cycle, ts_head, ts_packet); 
    246 //  
     242// 
    247243//             // update the base timestamp 
    248244//             uint32_t ts_step=(uint32_t)((float)(m_syt_interval) 
    249245//                              *m_SyncSource->m_data_buffer->getRate()); 
    250 //              
     246// 
    251247//             // the next buffer head timestamp 
    252248//             ts_head=addTicks(ts_head,ts_step); 
    253249//             m_data_buffer->setBufferHeadTimestamp(ts_head); 
    254 //              
     250// 
    255251            // no-data 
    256252            debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "XMIT SYNC: CY=%04u NONE\n", cycle); 
     
    258254            // defer to make sure we get to be enabled asap 
    259255            return RAW1394_ISO_DEFER; 
    260              
     256 
    261257        } else { // enabled & packet due, read from the buffer 
    262258            if (m_data_buffer->readFrames(m_syt_interval, (char *)(data + 8))) { 
    263259                m_dbc += fillDataPacketHeader(packet, length, ts_packet); 
    264                  
     260 
    265261                // process all ports that should be handled on a per-packet base 
    266262                // this is MIDI for AMDTP (due to the need of DBC) 
     
    268264                    debugWarning("Problem encoding Packet Ports\n"); 
    269265                } 
    270                  
     266 
    271267                debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "XMIT DATA: CY=%04u TSH=%011llu TSP=%011lu\n", 
    272268                    cycle, ts_head, ts_packet); 
    273                  
     269 
    274270                return RAW1394_ISO_OK; 
    275                  
     271 
    276272            } else if (now_cycles<cycle) { 
    277273                // we can still postpone the queueing of the packets 
    278274                // because the ISO transmit packet buffer is not empty yet 
    279275                return RAW1394_ISO_AGAIN; 
    280                  
     276 
    281277            } else { // there is no more data in the ringbuffer 
    282278                // compose a silent packet, we should always 
     
    284280                transmitSilenceBlock((char *)(data+8), m_syt_interval, 0); 
    285281                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", 
    288284                        now_cycles, cycle, TICKS_TO_CYCLES(ts_packet)); 
    289285                // signal underrun 
     
    293289                m_disabled=true; 
    294290                m_is_disabled=true; 
    295                  
     291 
    296292                return RAW1394_ISO_DEFER; 
    297293            } 
    298294        } 
    299          
     295 
    300296    } else { // no packet due, send no-data packet 
    301297        debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "XMIT NONE: CY=%04u TSH=%011llu\n", 
    302298                cycle, ts_head); 
    303                  
     299 
    304300        m_dbc += fillNoDataPacketHeader(packet, length); 
    305301        return RAW1394_ISO_DEFER; 
    306302    } 
    307      
     303 
    308304    // we shouldn't get here 
    309305    return RAW1394_ISO_ERROR; 
     
    314310        struct iec61883_packet *packet, unsigned int* length, 
    315311        uint32_t ts) { 
    316      
     312 
    317313    packet->fdf = m_fdf; 
    318314 
     
    320316    uint16_t timestamp_SYT = TICKS_TO_SYT(ts); 
    321317    packet->syt = ntohs(timestamp_SYT); 
    322      
     318 
    323319    *length = m_syt_interval*sizeof(quadlet_t)*m_dimension + 8; 
    324320 
     
    328324unsigned int AmdtpTransmitStreamProcessor::fillNoDataPacketHeader( 
    329325        struct iec61883_packet *packet, unsigned int* length) { 
    330      
     326 
    331327    // no-data packets have syt=0xFFFF 
    332328    // and have the usual amount of events as dummy data (?) 
    333329    packet->fdf = IEC61883_FDF_NODATA; 
    334330    packet->syt = 0xffff; 
    335      
    336     // FIXME: either make this a setting or choose  
     331 
     332    // FIXME: either make this a setting or choose 
    337333    bool send_payload=true; 
    338334    if(send_payload) { 
     
    355351 
    356352    debugOutput( DEBUG_LEVEL_VERBOSE, "Prefill transmit buffers...\n"); 
    357      
     353 
    358354    if(!transferSilence(m_ringbuffer_size_frames)) { 
    359355        debugFatal("Could not prefill transmit stream\n"); 
     
    372368    m_PacketStat.reset(); 
    373369    m_WakeupStat.reset(); 
    374      
     370 
    375371    // we have to make sure that the buffer HEAD timestamp 
    376372    // lies in the future for every possible buffer fill case. 
    377373    int offset=(int)(m_ringbuffer_size_frames*m_ticks_per_frame); 
    378      
     374 
    379375    m_data_buffer->setTickOffset(offset); 
    380      
     376 
    381377    // reset all non-device specific stuff 
    382378    // i.e. the iso stream and the associated ports 
     
    385381        return false; 
    386382    } 
    387      
     383 
    388384    // we should prefill the event buffer 
    389385    if (!prefill()) { 
    390386        debugFatal("Could not prefill buffers\n"); 
    391         return false;     
    392     } 
    393      
     387        return false; 
     388    } 
     389 
    394390    return true; 
    395391} 
     
    401397 
    402398    debugOutput( DEBUG_LEVEL_VERBOSE, "Preparing (%p)...\n", this); 
    403      
     399 
    404400    // prepare all non-device specific stuff 
    405401    // i.e. the iso stream and the associated ports 
     
    408404        return false; 
    409405    } 
    410      
     406 
    411407    switch (m_framerate) { 
    412408    case 32000: 
     
    440436        break; 
    441437    } 
    442      
     438 
    443439    iec61883_cip_init ( 
    444         &m_cip_status,  
    445         IEC61883_FMT_AMDTP,  
     440        &m_cip_status, 
     441        IEC61883_FMT_AMDTP, 
    446442        m_fdf, 
    447         m_framerate,  
    448         m_dimension,  
     443        m_framerate, 
     444        m_dimension, 
    449445        m_syt_interval); 
    450446 
    451447    // prepare the framerate estimate 
    452448    m_ticks_per_frame = (TICKS_PER_SECOND*1.0) / ((float)m_framerate); 
    453      
    454        // initialize internal buffer 
     449 
     450    // initialize internal buffer 
    455451    m_ringbuffer_size_frames=m_nb_buffers * m_period; 
    456452 
    457     assert(m_data_buffer);     
     453    assert(m_data_buffer); 
    458454    m_data_buffer->setBufferSize(m_ringbuffer_size_frames); 
    459455    m_data_buffer->setEventSize(sizeof(quadlet_t)); 
    460456    m_data_buffer->setEventsPerFrame(m_dimension); 
    461      
     457 
    462458    m_data_buffer->setUpdatePeriod(m_period); 
    463459    m_data_buffer->setNominalRate(m_ticks_per_frame); 
    464      
     460 
    465461    m_data_buffer->setWrapValue(128L*TICKS_PER_SECOND); 
    466      
     462 
    467463    m_data_buffer->prepare(); 
    468464 
     
    479475            return false; 
    480476        } 
    481          
    482          
     477 
     478 
    483479        switch ((*it)->getPortType()) { 
    484480            case Port::E_Audio: 
     
    497493                    return false; 
    498494                } 
    499                  
     495 
    500496                if(!(*it)->setDataType(Port::E_Float)) { 
    501497                    debugFatal("Could not set data type"); 
    502498                    return false; 
    503499                } 
    504                  
    505                  
     500 
     501 
    506502                break; 
    507503            case Port::E_Midi: 
     
    510506                    return false; 
    511507                } 
    512                  
     508 
    513509                // we use a timing unit of 10ns 
    514510                // this makes sure that for the max syt interval 
     
    527523                    return false; 
    528524                } 
    529                  
     525 
    530526                // buffertype and datatype are dependant on the API 
    531527                debugWarning("---------------- ! Doing hardcoded test setup ! --------------\n"); 
     
    546542    } 
    547543 
    548     // the API specific settings of the ports should already be set,  
     544    // the API specific settings of the ports should already be set, 
    549545    // as this is called from the processorManager->prepare() 
    550546    // so we can init the ports 
     
    585581    debugOutput(DEBUG_LEVEL_VERBOSE,"Preparing to enable...\n"); 
    586582 
    587     // for the transmit SP, we have to initialize the  
     583    // for the transmit SP, we have to initialize the 
    588584    // buffer timestamp to something sane, because this timestamp 
    589585    // is used when it is SyncSource 
    590      
     586 
    591587    // the time we initialize to will determine the time at which 
    592588    // the first sample in the buffer will be sent, so we should 
    593589    // make it at least 'time_to_enable_at' 
    594      
     590 
    595591    uint64_t now=m_handler->getCycleTimer(); 
    596592    unsigned int now_secs=CYCLE_TIMER_GET_SECS(now); 
    597      
     593 
    598594    // check if a wraparound on the secs will happen between 
    599595    // now and the time we start 
    600596    int until_enable=(int)time_to_enable_at - (int)CYCLE_TIMER_GET_CYCLES(now); 
    601      
     597 
    602598    if(until_enable>4000) { 
    603599        // wraparound on CYCLE_TIMER_GET_CYCLES(now) 
     
    616612    uint64_t ts_head= now_secs*TICKS_PER_SECOND; 
    617613    ts_head+=time_to_enable_at*TICKS_PER_CYCLE; 
    618      
     614 
    619615    // we also add the nb of cycles we transmit in advance 
    620616    ts_head=addTicks(ts_head, TRANSMIT_ADVANCE_CYCLES*TICKS_PER_CYCLE); 
    621      
     617 
    622618    m_data_buffer->setBufferTailTimestamp(ts_head); 
    623619 
     
    633629bool AmdtpTransmitStreamProcessor::transferSilence(unsigned int nframes) { 
    634630    bool retval; 
    635      
     631 
    636632    char *dummybuffer=(char *)calloc(sizeof(quadlet_t),nframes*m_dimension); 
    637      
     633 
    638634    transmitSilenceBlock(dummybuffer, nframes, 0); 
    639635 
    640636    // 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)) { 
    642638        retval=true; 
    643639    } else { 
     
    647643 
    648644    free(dummybuffer); 
    649      
     645 
    650646    return retval; 
    651647} 
     
    653649bool AmdtpTransmitStreamProcessor::putFrames(unsigned int nbframes, int64_t ts) { 
    654650    m_PeriodStat.mark(m_data_buffer->getBufferFill()); 
    655      
     651 
    656652    debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "AmdtpTransmitStreamProcessor::putFrames(%d, %llu)\n", nbframes, ts); 
    657      
     653 
    658654    // transfer the data 
    659655    m_data_buffer->blockProcessWriteFrames(nbframes, ts); 
     
    663659    return true; 
    664660} 
    665 /*  
     661/* 
    666662 * write received events to the stream ringbuffers. 
    667663 */ 
    668664 
    669 bool AmdtpTransmitStreamProcessor::processWriteBlock(char *data,  
     665bool AmdtpTransmitStreamProcessor::processWriteBlock(char *data, 
    670666                       unsigned int nevents, unsigned int offset) 
    671667{ 
     
    678674 
    679675        if((*it)->isDisabled()) {continue;}; 
    680          
     676 
    681677        //FIXME: make this into a static_cast when not DEBUG? 
    682678 
     
    701697} 
    702698 
    703 int AmdtpTransmitStreamProcessor::transmitSilenceBlock(char *data,  
     699int AmdtpTransmitStreamProcessor::transmitSilenceBlock(char *data, 
    704700                       unsigned int nevents, unsigned int offset) 
    705701{ 
     
    745741    bool ok=true; 
    746742    char byte; 
    747      
     743 
    748744    quadlet_t *target_event=NULL; 
    749745    unsigned int j; 
    750      
     746 
    751747    for ( PortVectorIterator it = m_PacketPorts.begin(); 
    752748          it != m_PacketPorts.end(); 
     
    761757        assert(pinfo->getFormat()==AmdtpPortInfo::E_Midi); 
    762758#endif 
    763          
     759 
    764760        AmdtpMidiPort *mp=static_cast<AmdtpMidiPort *>(*it); 
    765          
     761 
    766762        // we encode this directly (no function call) due to the high frequency 
    767763        /* idea: 
    768764        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, 
    770766        we'll start at the right event for the midi port. 
    771767        => if we increment j with 8, we stay at the right event. 
    772768        */ 
    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 
    774770        //        predict how much loops will be present here 
    775771        // first prefill the buffer with NO_DATA's on all time muxed channels 
    776          
     772 
    777773        for(j = (dbc & 0x07)+mp->getLocation(); j < nevents; j += 8) { 
    778          
     774 
    779775            target_event=(quadlet_t *)(data + ((j * m_dimension) + mp->getPosition())); 
    780              
     776 
    781777            if(mp->canRead()) { // we can send a byte 
    782778                mp->readEvent(&byte); 
     
    784780                    IEC61883_AM824_SET_LABEL((byte)<<16, 
    785781                                             IEC61883_AM824_LABEL_MIDI_1X)); 
    786             } else {  
     782            } else { 
    787783                // can't send a byte, either because there is no byte, 
    788784                // or because this would exceed the maximum rate 
     
    793789 
    794790    } 
    795          
     791 
    796792    return ok; 
    797793} 
    798794 
    799795 
    800 int AmdtpTransmitStreamProcessor::encodePortToMBLAEvents(AmdtpAudioPort *p, quadlet_t *data,  
     796int AmdtpTransmitStreamProcessor::encodePortToMBLAEvents(AmdtpAudioPort *p, quadlet_t *data, 
    801797                       unsigned int offset, unsigned int nevents) 
    802798{ 
     
    833829                buffer+=offset; 
    834830 
    835                 for(j = 0; j < nevents; j += 1) { // decode max nsamples                
    836      
     831                for(j = 0; j < nevents; j += 1) { // decode max nsamples 
     832 
    837833                    // don't care for overflow 
    838834                    float v = *buffer * multiplier;  // v: -231 .. 231 
    839835                    unsigned int tmp = ((int)v); 
    840836                    *target_event = htonl((tmp >> 8) | 0x40000000); 
    841                      
     837 
    842838                    buffer++; 
    843839                    target_event += m_dimension; 
     
    849845    return 0; 
    850846} 
    851 int AmdtpTransmitStreamProcessor::encodeSilencePortToMBLAEvents(AmdtpAudioPort *p, quadlet_t *data,  
     847int AmdtpTransmitStreamProcessor::encodeSilencePortToMBLAEvents(AmdtpAudioPort *p, quadlet_t *data, 
    852848                       unsigned int offset, unsigned int nevents) 
    853849{ 
     
    888884 
    889885    // call the parent init 
    890     // this has to be done before allocating the buffers,  
     886    // this has to be done before allocating the buffers, 
    891887    // because this sets the buffersizes from the processormanager 
    892888    if(!ReceiveStreamProcessor::init()) { 
     
    898894} 
    899895 
    900 enum raw1394_iso_disposition  
    901 AmdtpReceiveStreamProcessor::putPacket(unsigned char *data, unsigned int length,  
    902                   unsigned char channel, unsigned char tag, unsigned char sy,  
     896enum raw1394_iso_disposition 
     897AmdtpReceiveStreamProcessor::putPacket(unsigned char *data, unsigned int length, 
     898                  unsigned char channel, unsigned char tag, unsigned char sy, 
    903899                  unsigned int cycle, unsigned int dropped) { 
    904      
     900 
    905901    enum raw1394_iso_disposition retval=RAW1394_ISO_OK; 
    906902    m_last_cycle=cycle; 
    907      
     903 
    908904    struct iec61883_packet *packet = (struct iec61883_packet *) data; 
    909905    assert(packet); 
     
    915911 
    916912    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), 
    918914        CYCLE_TIMER_GET_CYCLES(ntohs(packet->syt)), CYCLE_TIMER_GET_OFFSET(ntohs(packet->syt)), 
    919915        m_running,m_disabled,m_is_disabled); 
    920916 
    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", 
    923919        channel, packet->fdf, 
    924920        packet->syt, 
    925921        packet->dbs, 
    926922        packet->dbc, 
    927         packet->fmt,  
     923        packet->fmt, 
    928924        length); 
    929925 
     
    932928        // check if we are on or past the enable point 
    933929        int cycles_past_enable=diffCycles(cycle, m_cycle_to_enable_at); 
    934          
     930 
    935931        if (cycles_past_enable >= 0) { 
    936932            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", 
    938934                this, cycle, ntohs(packet->syt)); 
    939935            // the previous timestamp is the one we need to start with 
     
    954950 
    955951    // 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) 
    958954       && (packet->fmt == 0x10) 
    959        && (packet->dbs>0)  
     955       && (packet->dbs>0) 
    960956       && (length>=2*sizeof(quadlet_t))) { 
    961         
     957 
    962958        unsigned int nevents=((length / sizeof (quadlet_t)) - 2)/packet->dbs; 
    963959 
     
    966962 
    967963        //=> 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), 
    969965                                        cycle, m_handler->getCycleTimer()); 
    970966 
    971967        debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "RECV: CY=%04u TS=%011llu\n", 
    972968                cycle, m_last_timestamp); 
    973          
     969 
    974970        // we have to keep in mind that there are also 
    975971        // some packets buffered by the ISO layer, 
     
    981977        debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"STMP: %lluticks | buff=%d, syt_interval=%d, tpf=%f\n", 
    982978            m_last_timestamp, m_handler->getWakeupInterval(),m_syt_interval,m_ticks_per_frame); 
    983          
     979 
    984980        //=> signal that we're running (if we are) 
    985981        if(!m_running && nevents && m_last_timestamp2 && m_last_timestamp) { 
     
    995991            // estimate as to when a period might be ready. i.e. it will not 
    996992            // 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 
    999995            // SYT_INTERVAL * rate later 
    1000996            uint64_t ts=addTicks(m_last_timestamp, 
     
    10041000            // the buffer by the next packet. 
    10051001            m_data_buffer->setBufferTailTimestamp(ts); 
    1006              
     1002 
    10071003            return RAW1394_ISO_DEFER; 
    10081004        } 
    1009          
     1005 
    10101006        #ifdef DEBUG_OFF 
    10111007        if((cycle % 1000) == 0) { 
     
    10131009            uint32_t now=m_handler->getCycleTimer(); 
    10141010            uint32_t now_ticks=CYCLE_TIMER_TO_TICKS(now); 
    1015              
     1011 
    10161012            uint32_t test_ts=sytRecvToFullTicks(syt, cycle, now); 
    10171013 
     
    10271023        } 
    10281024        #endif 
    1029          
     1025 
    10301026        //=> process the packet 
    10311027        // 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)) { 
    10331029            retval=RAW1394_ISO_OK; 
    1034              
     1030 
    10351031            // process all ports that should be handled on a per-packet base 
    10361032            // this is MIDI for AMDTP (due to the need of DBC) 
     
    10391035                retval=RAW1394_ISO_DEFER; 
    10401036            } 
    1041              
     1037 
    10421038        } 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", 
    10451041                 cycle, m_data_buffer->getFrameCounter(), m_handler->getPacketCount()); 
    1046              
     1042 
    10471043            m_xruns++; 
    1048              
     1044 
    10491045            // disable the processing, will be re-enabled when 
    10501046            // the xrun is handled 
     
    10711067 
    10721068void AmdtpReceiveStreamProcessor::setVerboseLevel(int l) { 
    1073        setDebugLevel(l); 
    1074        ReceiveStreamProcessor::setVerboseLevel(l); 
     1069    setDebugLevel(l); 
     1070    ReceiveStreamProcessor::setVerboseLevel(l); 
    10751071} 
    10761072 
     
    11011097 
    11021098    debugOutput( DEBUG_LEVEL_VERBOSE, "Preparing (%p)...\n", this); 
    1103          
    1104        // prepare all non-device specific stuff 
    1105        // i.e. the iso stream and the associated ports 
    1106        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   
    11351131 
    11361132    // prepare the framerate estimate 
     
    11391135    debugOutput(DEBUG_LEVEL_VERBOSE,"Initializing remote ticks/frame to %f\n",m_ticks_per_frame); 
    11401136 
    1141        // initialize internal buffer 
     1137    // initialize internal buffer 
    11421138    unsigned int ringbuffer_size_frames=m_nb_buffers * m_period; 
    1143      
    1144     assert(m_data_buffer);     
     1139 
     1140    assert(m_data_buffer); 
    11451141    m_data_buffer->setBufferSize(ringbuffer_size_frames); 
    11461142    m_data_buffer->setEventSize(sizeof(quadlet_t)); 
    11471143    m_data_buffer->setEventsPerFrame(m_dimension); 
    1148          
     1144 
    11491145    // the buffer is written every syt_interval 
    11501146    m_data_buffer->setUpdatePeriod(m_syt_interval); 
    11511147    m_data_buffer->setNominalRate(m_ticks_per_frame); 
    1152      
     1148 
    11531149    m_data_buffer->setWrapValue(128L*TICKS_PER_SECOND); 
    1154      
     1150 
    11551151    m_data_buffer->prepare(); 
    11561152 
    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 buffered 
    1160        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 API 
    1177                                debugWarning("---------------- ! Doing hardcoded dummy setup ! --------------\n"); 
    1178                                // buffertype and datatype are dependant on the API 
    1179                                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 API 
    1198                                // buffertype and datatype are dependant on the API 
    1199                                debugWarning("---------------- ! Doing hardcoded test setup ! --------------\n"); 
    1200                                // buffertype and datatype are dependant on the API 
    1201                                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 ports 
    1219        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   
    12281224 
    12291225    debugOutput( DEBUG_LEVEL_VERBOSE, "Prepared for:\n"); 
     
    12341230    debugOutput( DEBUG_LEVEL_VERBOSE, " Port: %d, Channel: %d\n", 
    12351231             m_port,m_channel); 
    1236      
     1232 
    12371233    return true; 
    12381234 
     
    12641260 * \brief write received events to the stream ringbuffers. 
    12651261 */ 
    1266 bool AmdtpReceiveStreamProcessor::processReadBlock(char *data,  
    1267                                           unsigned int nevents, unsigned int offset) 
     1262bool AmdtpReceiveStreamProcessor::processReadBlock(char *data, 
     1263                       unsigned int nevents, unsigned int offset) 
    12681264{ 
    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(); 
    12741270          it != m_PeriodPorts.end(); 
    12751271          ++it ) 
     
    12781274        if((*it)->isDisabled()) {continue;}; 
    12791275 
    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 unimplemented 
    1293                        break; 
    1294         /* for this processor, midi is a packet based port  
    1295                case AmdtpPortInfo::E_Midi: 
    1296                        break;*/ 
    1297                default: // ignore 
    1298                        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       
    13001296    } 
    13011297    return no_problem; 
     
    13131309bool AmdtpReceiveStreamProcessor::decodePacketPorts(quadlet_t *data, unsigned int nevents, unsigned int dbc) 
    13141310{ 
    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(); 
    13211317          it != m_PacketPorts.end(); 
    13221318          ++it ) 
    1323        
     1319   
    13241320 
    13251321#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 mbla 
    1330                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); 
    13311327#endif 
    1332                AmdtpMidiPort *mp=static_cast<AmdtpMidiPort *>(*it); 
    1333                  
    1334                // we decode this directly (no function call) due to the high frequency 
    1335                /* 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 here 
    1343                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 ringbuffer 
    1348                        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 
     1358int AmdtpReceiveStreamProcessor::decodeMBLAEventsToPort(AmdtpAudioPort *p, quadlet_t *data, 
     1359                       unsigned int offset, unsigned int nevents) 
    13641360{ 
    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 nsamples 
    1386                                        *(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 int 
    1405                                        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; 
    14171413} 
    14181414 
  • trunk/libffado/src/libstreaming/AmdtpStreamProcessor.h

    r424 r445  
    1 /* $Id$ */ 
    2  
    31/* 
    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 
    2722 */ 
    28 #ifndef __FREEBOB_AMDTPSTREAMPROCESSOR__ 
    29 #define __FREEBOB_AMDTPSTREAMPROCESSOR__ 
     23 
     24#ifndef __FFADO_AMDTPSTREAMPROCESSOR__ 
     25#define __FFADO_AMDTPSTREAMPROCESSOR__ 
    3026 
    3127/** 
     
    4642#define IEC61883_STREAM_TYPE_MBLA   0x06 
    4743 
    48 #define IEC61883_AM824_LABEL_MASK                      0xFF000000 
    49 #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      0x80  
    53 #define IEC61883_AM824_LABEL_MIDI_1X           0x81  
    54 #define IEC61883_AM824_LABEL_MIDI_2X           0x82 
    55 #define IEC61883_AM824_LABEL_MIDI_3X           0x83 
     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)) 
     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 
    5652 
    5753namespace Streaming { 
     
    6561\brief The Base Class for an AMDTP transmit stream processor 
    6662 
    67  This class implements a TransmitStreamProcessor that multiplexes Ports  
     63 This class implements a TransmitStreamProcessor that multiplexes Ports 
    6864 into AMDTP streams. 
    69   
     65 
    7066*/ 
    71 class AmdtpTransmitStreamProcessor  
    72        : public TransmitStreamProcessor 
     67class AmdtpTransmitStreamProcessor 
     68    : public TransmitStreamProcessor 
    7369{ 
    7470 
     
    7874     * @param port 1394 port 
    7975     * @param framerate frame rate 
    80      * @param dimension number of substreams in the ISO stream  
     76     * @param dimension number of substreams in the ISO stream 
    8177     *                  (midi-muxed is only one stream) 
    8278     */ 
     
    8581    virtual ~AmdtpTransmitStreamProcessor(); 
    8682 
    87     enum raw1394_iso_disposition  
     83    enum raw1394_iso_disposition 
    8884            getPacket(unsigned char *data, unsigned int *length, 
    8985                    unsigned char *tag, unsigned char *sy, 
     
    9389    bool reset(); 
    9490    bool prepare(); 
    95      
     91 
    9692    bool prepareForStop(); 
    9793    bool prepareForStart(); 
    98      
     94 
    9995    bool prepareForEnable(uint64_t time_to_enable_at); 
    100      
     96 
    10197    bool putFrames(unsigned int nbframes, int64_t ts); ///< transfer the buffer contents from the client 
    10298 
     
    104100    // this period takes m_period/m_framerate seconds of time 
    105101    // 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 
    108104    // however, if we only count the number of used packets 
    109105    // it is m_period / m_syt_interval 
    110106    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 
    114110    int getMinimalSyncDelay(); 
    115      
     111 
    116112    void setVerboseLevel(int l); 
    117      
     113 
    118114protected: 
    119115    bool processWriteBlock(char *data, unsigned int nevents, unsigned int offset); 
    120116 
    121117    struct iec61883_cip m_cip_status; 
    122      
     118 
    123119    int m_dimension; 
    124120    unsigned int m_syt_interval; 
    125121 
    126122    int m_fdf; 
    127      
     123 
    128124    bool prefill(); 
    129      
     125 
    130126    unsigned int fillNoDataPacketHeader(struct iec61883_packet *packet, unsigned int* length); 
    131127    unsigned int fillDataPacketHeader(struct iec61883_packet *packet, unsigned int* length, uint32_t ts); 
    132      
    133      
     128 
     129 
    134130    bool transferSilence(unsigned int size); 
    135131 
    136     int transmitBlock(char *data, unsigned int nevents,  
     132    int transmitBlock(char *data, unsigned int nevents, 
    137133                        unsigned int offset); 
    138                          
     134 
    139135    bool encodePacketPorts(quadlet_t *data, unsigned int nevents, unsigned int dbc); 
    140136    int encodePortToMBLAEvents(AmdtpAudioPort *, quadlet_t *data, 
    141137                                unsigned int offset, unsigned int nevents); 
    142      
    143     int transmitSilenceBlock(char *data, unsigned int nevents,  
     138 
     139    int transmitSilenceBlock(char *data, unsigned int nevents, 
    144140                        unsigned int offset); 
    145141    int encodeSilencePortToMBLAEvents(AmdtpAudioPort *, quadlet_t *data, 
    146142                                unsigned int offset, unsigned int nevents); 
    147143    void updatePreparedState(); 
    148      
     144 
    149145    unsigned long m_last_timestamp; 
    150146 
    151147    unsigned int m_dbc; 
    152      
     148 
    153149    unsigned int m_ringbuffer_size_frames; 
    154150 
     
    159155\brief The Base Class for an AMDTP receive stream processor 
    160156 
    161  This class implements a ReceiveStreamProcessor that demultiplexes  
     157 This class implements a ReceiveStreamProcessor that demultiplexes 
    162158 AMDTP streams into Ports. 
    163   
     159 
    164160*/ 
    165 class AmdtpReceiveStreamProcessor  
    166        : public ReceiveStreamProcessor 
     161class AmdtpReceiveStreamProcessor 
     162    : public ReceiveStreamProcessor 
    167163{ 
    168164 
     
    172168     * @param port 1394 port 
    173169     * @param framerate frame rate 
    174      * @param dimension number of substreams in the ISO stream  
     170     * @param dimension number of substreams in the ISO stream 
    175171     *                  (midi-muxed is only one stream) 
    176172     */ 
    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 
    190186    bool prepareForStop(); 
    191187    bool prepareForStart(); 
    192          
     188 
    193189    bool getFrames(unsigned int nbframes); ///< transfer the buffer contents to the client 
    194190 
     
    196192    // this period takes m_period/m_framerate seconds of time 
    197193    // 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 
    200196    // however, if we only count the number of used packets 
    201197    // 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);}; 
    205201 
    206202    void dumpInfo(); 
    207      
     203 
    208204    int getMinimalSyncDelay(); 
    209          
     205 
    210206    void setVerboseLevel(int l); 
    211              
     207 
    212208protected: 
    213209 
     
    215211 
    216212    bool decodePacketPorts(quadlet_t *data, unsigned int nevents, unsigned int dbc); 
    217      
     213 
    218214    int decodeMBLAEventsToPort(AmdtpAudioPort *, quadlet_t *data, unsigned int offset, unsigned int nevents); 
    219215    void updatePreparedState(); 
     
    221217    int m_dimension; 
    222218    unsigned int m_syt_interval; 
    223      
     219 
    224220    uint64_t m_last_timestamp; /// last timestamp (in ticks) 
    225221    uint64_t m_last_timestamp2; /// last timestamp (in ticks) 
    226222    uint64_t m_last_timestamp_at_period_ticks; 
    227      
     223 
    228224    DECLARE_DEBUG_MODULE; 
    229225 
     
    233229} // end of namespace Streaming 
    234230 
    235 #endif /* __FREEBOB_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 
    121#ifndef _IEC61883_CIP_PRIVATE_H 
    222#define _IEC61883_CIP_PRIVATE_H 
     
    2141 
    2242struct 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; 
    2747 
    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; 
    3353 
    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; 
    3858 
    39        uint16_t syt      : 16; 
     59    uint16_t syt      : 16; 
    4060 
    41        unsigned char data[0]; 
     61    unsigned char data[0]; 
    4262}; 
    4363 
     
    4565 
    4666struct 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; 
    5171 
    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; 
    5777 
    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; 
    6282 
    63        uint16_t syt      : 16; 
     83    uint16_t syt      : 16; 
    6484 
    65        unsigned char data[0]; 
     85    unsigned char data[0]; 
    6686}; 
    6787 
     
    84104 
    85105#define IEC61883_FDF_NODATA   0xFF 
    86                  
     106 
    87107/* AM824 format definitions. */ 
    88108#define IEC61883_FDF_AM824 0x00 
     
    104124#define IEC60958_LABEL   0x0 
    105125#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. */ 
    107127#define IEC60958_PAC_RSV 0x2 /* Preamble Code 'RESERVED' */ 
    108128#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. */ 
    110130#define IEC60958_PAC_W   0x0 /* Preamble Code 'W': start of channel 2. */ 
    111131#define IEC60958_DATA_VALID   0 /* When cleared means data is valid. */ 
     
    113133 
    114134struct iec61883_fraction { 
    115        int integer; 
    116        int numerator; 
    117        int denominator; 
     135    int integer; 
     136    int numerator; 
     137    int denominator; 
    118138}; 
    119139 
    120140struct 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; 
    134154}; 
    135155 
    136156void 
    137157iec61883_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); 
     159void 
    140160iec61883_cip_set_transmission_mode(struct iec61883_cip *ptz, int mode); 
    141161 
    142 int  
     162int 
    143163iec61883_cip_get_max_packet_size(struct iec61883_cip *ptz); 
    144164 
    145165int 
    146166iec61883_cip_fill_header(int node_id, struct iec61883_cip *cip, 
    147                struct iec61883_packet *packet); 
     167        struct iec61883_packet *packet); 
    148168 
    149169int 
    150170iec61883_cip_fill_header_nodata(int node_id, struct iec61883_cip *cip, 
    151                struct iec61883_packet *packet); 
     171        struct iec61883_packet *packet); 
    152172 
    153173#ifdef __cplusplus 
  • trunk/libffado/src/libstreaming/cycletimer.h

    r411 r445  
    1 /* $Id$ */ 
    2  
    31/* 
    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 
    2924/* Definitions and utility macro's to handle the ISO cycle timer */ 
    3025 
     
    5247                                   (CYCLE_TIMER_GET_CYCLES(x) * TICKS_PER_CYCLE ) +\ 
    5348                                   (CYCLE_TIMER_GET_OFFSET(x)            )) 
    54                                     
     49 
    5550// non-efficient versions, to be avoided in critical code 
    5651#define TICKS_TO_SECS(x) ((x)/TICKS_PER_SECOND) 
     
    6156                                 | ((TICKS_TO_CYCLES(x) & 0x1FFF) << 12) \ 
    6257                                 | ((TICKS_TO_OFFSET(x) & 0xFFF))) 
    63                                   
     58 
    6459#define TICKS_TO_SYT(x)         (((TICKS_TO_CYCLES(x) & 0xF) << 12) \ 
    6560                                 | ((TICKS_TO_OFFSET(x) & 0xFFF))) 
     
    114109        if (x < 0) { 
    115110            debugWarning("insufficient wrapping: %lld\n",x); 
    116              
     111 
    117112            debugWarning("correcting...\n"); 
    118113            while (x < 0) { 
    119114                x += TICKS_PER_SECOND * 128L; 
    120                  
     115 
    121116                if (x < 0) { 
    122117                    debugWarning(" insufficient wrapping: %lld\n",x); 
     
    134129 * 
    135130 * 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 
    137132 * to the minimum value of the cycle timer, in ticks (= 0). 
    138133 * 
     
    141136 */ 
    142137static inline uint32_t wrapAtMinMaxTicks(int64_t x) { 
    143      
     138 
    144139    if (x < 0) { 
    145140        x += TICKS_PER_SECOND * 128L; 
     
    166161 * such that it respects wrapping. 
    167162 * 
    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 
    169164 * negative and very large. However the real difference is 
    170165 * not large. It can be calculated by unwrapping x and then 
    171166 * calculating x-y. 
    172167 * 
    173  * @param x First timestamp  
     168 * @param x First timestamp 
    174169 * @param y Second timestamp 
    175170 * @return the difference x-y, unwrapped 
     
    177172static inline int32_t diffTicks(uint32_t x, uint32_t y) { 
    178173    int64_t diff=(int64_t)x - (int64_t)y; 
    179      
     174 
    180175    // the maximal difference we allow (64secs) 
    181176    const int64_t max=TICKS_PER_SECOND*64L; 
    182      
     177 
    183178    if(diff > max) { 
    184179        // this means that y has wrapped, but 
     
    194189        diff += TICKS_PER_SECOND*128L; 
    195190    } 
    196      
     191 
    197192    return (int32_t)diff; 
    198      
     193 
    199194} 
    200195 
     
    205200 * wrapping the result if necessary. 
    206201 * 
    207  * @param x First timestamp  
     202 * @param x First timestamp 
    208203 * @param y Second timestamp 
    209204 * @return the sum x+y, wrapped 
     
    221216 * wrapping the result if necessary. 
    222217 * 
    223  * @param x First timestamp  
     218 * @param x First timestamp 
    224219 * @param y Second timestamp 
    225220 * @return the difference x-y, wrapped 
     
    238233 * @param rcv_cycle The cycle this timestamp was received on 
    239234 * @param ctr_now The current value of the cycle timer ('now') 
    240  * @return  
     235 * @return 
    241236 */ 
    242237static inline uint32_t sytRecvToFullTicks(uint32_t syt_timestamp, unsigned int rcv_cycle, uint32_t ctr_now) { 
    243238    uint32_t timestamp; 
    244      
     239 
    245240    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"SYT=%08X CY=%04X CTR=%08X\n", 
    246241        syt_timestamp,rcv_cycle,ctr_now); 
    247          
     242 
    248243    // reconstruct the full cycle 
    249244    uint32_t cc_cycles=CYCLE_TIMER_GET_CYCLES(ctr_now); 
    250245    uint32_t cc_seconds=CYCLE_TIMER_GET_SECS(ctr_now); 
    251      
     246 
    252247    // 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 
    254249    // was received 
    255250    if (rcv_cycle>cc_cycles) { 
     
    262257        } 
    263258    } 
    264      
     259 
    265260    // reconstruct the top part of the timestamp using the current cycle number 
    266261    uint32_t rcv_cycle_masked=rcv_cycle & 0xF; 
    267262    uint32_t syt_cycle=CYCLE_TIMER_GET_CYCLES(syt_timestamp); 
    268      
     263 
    269264    // if this is true, wraparound has occurred, undo this wraparound 
    270265    if(syt_cycle<rcv_cycle_masked) syt_cycle += 0x10; 
    271      
     266 
    272267    // this is the difference in cycles wrt the cycle the 
    273268    // timestamp was received 
    274269    uint32_t delta_cycles=syt_cycle-rcv_cycle_masked; 
    275      
     270 
    276271    // reconstruct the cycle part of the timestamp 
    277272    uint32_t new_cycles=rcv_cycle + delta_cycles; 
    278      
     273 
    279274    // if the cycles cause a wraparound of the cycle timer, 
    280275    // perform this wraparound 
     
    286281            "Detected wraparound: %d + %d = %d\n", 
    287282            rcv_cycle,delta_cycles,new_cycles); 
    288          
     283 
    289284        new_cycles-=8000; // wrap around 
    290285#ifdef DEBUG 
     
    297292        timestamp += TICKS_PER_SECOND; 
    298293    } 
    299      
     294 
    300295    timestamp += CYCLE_TIMER_GET_OFFSET(syt_timestamp); 
    301      
     296 
    302297    timestamp = addTicks(timestamp, cc_seconds * TICKS_PER_SECOND); 
    303      
     298 
    304299    #ifdef DEBUG 
    305300        if(( TICKS_TO_CYCLE_TIMER(timestamp) & 0xFFFF) != syt_timestamp) { 
     
    309304        } 
    310305    #endif 
    311      
     306 
    312307    return timestamp; 
    313308} 
     
    317312 * 
    318313 * 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, 
    320315 * wraparound is present if rcv_cycle > current_cycle. In the xmit 
    321316 * version this is when current_cycle > xmt_cycle. 
     
    324319 * @param xmt_cycle The cycle this timestamp was received on 
    325320 * @param ctr_now The current value of the cycle timer ('now') 
    326  * @return  
     321 * @return 
    327322 */ 
    328323static inline uint32_t sytXmitToFullTicks(uint32_t syt_timestamp, unsigned int xmt_cycle, uint32_t ctr_now) { 
    329324    uint32_t timestamp; 
    330      
     325 
    331326    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"SYT=%08X CY=%04X CTR=%08X\n", 
    332327        syt_timestamp,xmt_cycle,ctr_now); 
    333          
     328 
    334329    // reconstruct the full cycle 
    335330    uint32_t cc_cycles=CYCLE_TIMER_GET_CYCLES(ctr_now); 
    336331    uint32_t cc_seconds=CYCLE_TIMER_GET_SECS(ctr_now); 
    337      
     332 
    338333    // 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 
    340335    // is to be transmitted 
    341336    if (xmt_cycle<cc_cycles) { 
     
    348343        } 
    349344    } 
    350      
     345 
    351346    // reconstruct the top part of the timestamp using the current cycle number 
    352347    uint32_t xmt_cycle_masked=xmt_cycle & 0xF; 
    353348    uint32_t syt_cycle=CYCLE_TIMER_GET_CYCLES(syt_timestamp); 
    354      
     349 
    355350    // if this is true, wraparound has occurred, undo this wraparound 
    356351    if(syt_cycle<xmt_cycle_masked) syt_cycle += 0x10; 
    357      
     352 
    358353    // this is the difference in cycles wrt the cycle the 
    359354    // timestamp was received 
    360355    uint32_t delta_cycles=syt_cycle-xmt_cycle_masked; 
    361      
     356 
    362357    // reconstruct the cycle part of the timestamp 
    363358    uint32_t new_cycles=xmt_cycle + delta_cycles; 
    364      
     359 
    365360    // if the cycles cause a wraparound of the cycle timer, 
    366361    // perform this wraparound 
     
    372367            "Detected wraparound: %d + %d = %d\n", 
    373368            xmt_cycle,delta_cycles,new_cycles); 
    374          
     369 
    375370        new_cycles-=8000; // wrap around 
    376371#ifdef DEBUG 
     
    383378        timestamp += TICKS_PER_SECOND; 
    384379    } 
    385      
     380 
    386381    timestamp += CYCLE_TIMER_GET_OFFSET(syt_timestamp); 
    387      
     382 
    388383    timestamp = addTicks(timestamp, cc_seconds * TICKS_PER_SECOND); 
    389      
     384 
    390385    #ifdef DEBUG 
    391386        if(( TICKS_TO_CYCLE_TIMER(timestamp) & 0xFFFF) != syt_timestamp) { 
     
    395390        } 
    396391    #endif 
    397      
     392 
    398393    return timestamp; 
    399394} 
     
    407402 * See diffTicks 
    408403 * 
    409  * @param x First cycle value  
     404 * @param x First cycle value 
    410405 * @param y Second cycle value 
    411406 * @return the difference x-y, unwrapped 
     
    413408static inline int diffCycles(unsigned int x, unsigned int y) { 
    414409    int diff = x - y; 
    415      
     410 
    416411    // the maximal difference we allow (64secs) 
    417412    const int max=CYCLES_PER_SECOND/2; 
    418      
     413 
    419414    if(diff > max) { 
    420415        diff -= CYCLES_PER_SECOND; 
     
    422417        diff += CYCLES_PER_SECOND; 
    423418    } 
    424      
     419 
    425420    return diff; 
    426421} 
  • trunk/libffado/src/libstreaming/IsoHandler.cpp

    r419 r445  
    1 /* $Id$ */ 
    2  
    31/* 
    4  *   FreeBob Streaming API 
    5  *   FreeBob = Firewire (pro-)audio for linux 
     2 * Copyright (C) 2005-2007 by Pieter Palmers 
    63 * 
    7  *   http://freebob.sf.net 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    86 * 
    9  *   Copyright (C) 2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> 
     7 * FFADO is based upon FreeBoB. 
    108 * 
    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; 
    1512 * 
    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. 
     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. 
    2017 * 
    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 
    2722 */ 
    2823 
     
    5752 
    5853/* the C callbacks */ 
    59 enum raw1394_iso_disposition  
     54enum raw1394_iso_disposition 
    6055IsoXmitHandler::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 
     66enum raw1394_iso_disposition 
     67IsoRecvHandler::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); 
    8176} 
    8277 
    8378int 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); 
    9085} 
    9186 
     
    9388/* Base class implementation */ 
    9489IsoHandler::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), 
    9691   m_buf_packets(400), m_max_packet_size(1024), m_irq_interval(-1), 
    9792   m_packetcount(0), m_dropped(0), m_Client(0), 
     
    10196 
    10297IsoHandler::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), 
    106101   m_packetcount(0), m_dropped(0), m_Client(0), 
    107102   m_State(E_Created) 
     
    121116            stop(); 
    122117        } 
    123          
     118 
    124119        raw1394_destroy_handle(m_handle); 
    125120    } 
    126      
     121 
    127122    if(m_handle_util) raw1394_destroy_handle(m_handle_util); 
    128123 
     
    134129    if(m_handle) { 
    135130        if(raw1394_loop_iterate(m_handle)) { 
    136             debugOutput( DEBUG_LEVEL_VERBOSE,  
     131            debugOutput( DEBUG_LEVEL_VERBOSE, 
    137132                 "IsoHandler (%p): Failed to iterate handler: %s\n", 
    138133                 this,strerror(errno)); 
     
    142137        } 
    143138    } else { 
    144         return false;  
     139        return false; 
    145140    } 
    146141} 
     
    156151        return false; 
    157152    } 
    158      
     153 
    159154    // the main handle for the ISO traffic 
    160155    m_handle = raw1394_new_handle_on_port( m_port ); 
     
    169164    } 
    170165    raw1394_set_userdata(m_handle, static_cast<void *>(this)); 
    171      
     166 
    172167    // a second handle for utility stuff 
    173168    m_handle_util = raw1394_new_handle_on_port( m_port ); 
     
    179174            debugError("Are ieee1394 and raw1394 drivers loaded?\n"); 
    180175        } 
    181          
     176 
    182177        raw1394_destroy_handle(m_handle); 
    183178        return false; 
    184179    } 
    185180    raw1394_set_userdata(m_handle_util, static_cast<void *>(this)); 
    186          
     181 
    187182    // bus reset handling 
    188183    if(raw1394_busreset_notify (m_handle, RAW1394_NOTIFY_ON)) { 
     
    209204    // update the internal state 
    210205    m_State=E_Initialized; 
    211      
     206 
    212207    return true; 
    213208} 
     
    222217        return false; 
    223218    } 
    224      
     219 
    225220    // Don't call until libraw1394's raw1394_new_handle() function has been 
    226221    // fixed to correctly initialise the iso_packet_infos field.  Bug is 
     
    228223 
    229224//     raw1394_iso_shutdown(m_handle); 
    230      
     225 
    231226    m_State = E_Prepared; 
    232      
     227 
    233228    return true; 
    234229} 
     
    237232{ 
    238233    debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 
    239      
     234 
    240235    // check the state 
    241236    if(m_State != E_Prepared) { 
     
    252247{ 
    253248    debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 
    254      
     249 
    255250    // check state 
    256251    if(m_State != E_Running) { 
     
    258253        return false; 
    259254    } 
    260      
     255 
    261256    // this is put here to try and avoid the 
    262257    // Runaway context problem 
    263258    // don't know if it will help though. 
    264259    raw1394_iso_xmit_sync(m_handle); 
    265      
     260 
    266261    raw1394_iso_stop(m_handle); 
    267      
     262 
    268263    m_State=E_Prepared; 
    269      
     264 
    270265    return true; 
    271266} 
     
    276271 * @return ? 
    277272 */ 
    278   
     273 
    279274int IsoHandler::handleBusReset(unsigned int generation) { 
    280275    debugOutput( DEBUG_LEVEL_VERBOSE, "bus reset...\n"); 
    281      
    282      
     276 
     277 
    283278    return 0; 
    284279} 
     
    293288    // the new api should be realtime safe. 
    294289    // 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 
    297292    int err; 
    298293    uint32_t cycle_timer; 
     
    314309    // the new api should be realtime safe. 
    315310    // 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 
    318313    int err; 
    319314    uint32_t cycle_timer; 
     
    351346 
    352347    if (m_Client) { 
    353             debugFatal( "Generic IsoHandlers can have only one client\n");      
     348            debugFatal( "Generic IsoHandlers can have only one client\n"); 
    354349            return false; 
    355350    } 
     
    369364 
    370365    if(stream != m_Client) { 
    371             debugFatal( "no client registered\n");      
     366            debugFatal( "no client registered\n"); 
    372367            return false; 
    373368    } 
    374369 
    375370    m_Client->clearHandler(); 
    376      
     371 
    377372    m_Client=0; 
    378373    return true; 
     
    387382    debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 
    388383} 
    389 IsoRecvHandler::IsoRecvHandler(int port, unsigned int buf_packets,  
     384IsoRecvHandler::IsoRecvHandler(int port, unsigned int buf_packets, 
    390385                               unsigned int max_packet_size, int irq) 
    391386                : IsoHandler(port, buf_packets,max_packet_size,irq) 
     
    411406 
    412407enum 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, 
    415410                    unsigned int cycle, unsigned int dropped) { 
    416411 
     
    424419        return m_Client->putPacket(data, length, channel, tag, sy, cycle, dropped); 
    425420    } 
    426      
     421 
    427422    return RAW1394_ISO_OK; 
    428423} 
     
    430425bool IsoRecvHandler::prepare() 
    431426{ 
    432      
     427 
    433428    // prepare the generic IsoHandler 
    434429    if(!IsoHandler::prepare()) { 
     
    443438 
    444439    if(m_irq_interval > 1) { 
    445         if(raw1394_iso_recv_init(m_handle,    
     440        if(raw1394_iso_recv_init(m_handle, 
    446441                                iso_receive_handler, 
    447442                                m_buf_packets, 
     
    452447            debugFatal("Could not do receive initialisation!\n" ); 
    453448            debugFatal("  %s\n",strerror(errno)); 
    454      
     449 
    455450            return false; 
    456451        } 
    457452    } else { 
    458         if(raw1394_iso_recv_init(m_handle,    
     453        if(raw1394_iso_recv_init(m_handle, 
    459454                                iso_receive_handler, 
    460455                                m_buf_packets, 
     
    465460            debugFatal("Could not do receive initialisation!\n" ); 
    466461            debugFatal("  %s\n",strerror(errno)); 
    467      
     462 
    468463            return false; 
    469         }     
     464        } 
    470465    } 
    471466    return true; 
     
    475470{ 
    476471    debugOutput( DEBUG_LEVEL_VERBOSE, "start on cycle %d\n", cycle); 
    477      
     472 
    478473    // start the generic IsoHandler 
    479474    if(!IsoHandler::start(cycle)) { 
    480475        return false; 
    481476    } 
    482      
     477 
    483478    if(raw1394_iso_recv_start(m_handle, cycle, -1, 0)) { 
    484479        debugFatal("Could not start receive handler (%s)\n",strerror(errno)); 
     
    490485int IsoRecvHandler::handleBusReset(unsigned int generation) { 
    491486    debugOutput( DEBUG_LEVEL_VERBOSE, "handle bus reset...\n"); 
    492      
     487 
    493488    //TODO: implement busreset 
    494      
     489 
    495490    // pass on the busreset signal 
    496491    if(IsoHandler::handleBusReset(generation)) { 
     
    508503 
    509504} 
    510 IsoXmitHandler::IsoXmitHandler(int port, unsigned int buf_packets,  
     505IsoXmitHandler::IsoXmitHandler(int port, unsigned int buf_packets, 
    511506                               unsigned int max_packet_size, int irq) 
    512507                : IsoHandler(port, buf_packets, max_packet_size,irq), 
     
    516511 
    517512} 
    518 IsoXmitHandler::IsoXmitHandler(int port, unsigned int buf_packets,  
     513IsoXmitHandler::IsoXmitHandler(int port, unsigned int buf_packets, 
    519514                               unsigned int max_packet_size, int irq, 
    520515                               enum raw1394_iso_speed speed) 
     
    575570{ 
    576571    debugOutput( DEBUG_LEVEL_VERBOSE, "start on cycle %d\n", cycle); 
    577      
     572 
    578573    if(!(IsoHandler::start(cycle))) { 
    579574        return false; 
    580575    } 
    581      
     576 
    582577    if(raw1394_iso_xmit_start(m_handle, cycle, m_prebuffers)) { 
    583578        debugFatal("Could not start xmit handler (%s)\n",strerror(errno)); 
     
    608603    debugOutput( DEBUG_LEVEL_VERBOSE, "bus reset...\n"); 
    609604    //TODO: implement busreset 
    610      
     605 
    611606    // pass on the busreset signal 
    612607    if(IsoHandler::handleBusReset(generation)) { 
    613608            return -1; 
    614609    } 
    615      
     610 
    616611    return 0; 
    617612} 
     
    622617#if 0 
    623618IsoRecvHandler::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} 
     623IsoRecvHandler::IsoRecvHandler(int port, unsigned int buf_packets, 
    629624                               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"); 
    633628 
    634629} 
     
    640635// raw1394_destroy_handle() (in the base class destructor) will do any iso 
    641636// system shutdown required. 
    642        raw1394_iso_shutdown(m_handle); 
     637    raw1394_iso_shutdown(m_handle); 
    643638 
    644639} 
     
    646641bool 
    647642IsoRecvHandler::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, 
    659654                                         iso_receive_handler, 
    660655                                         m_buf_packets, 
    661656                                         m_max_packet_size, 
    662657                                         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 
     667enum 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; 
    681676} 
    682677 
     
    686681int IsoRecvHandler::registerStream(IsoRecvStream *stream) 
    687682{ 
    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; 
    695690 
    696691} 
     
    698693int IsoRecvHandler::unregisterStream(IsoRecvStream *stream) 
    699694{ 
    700        assert(stream); 
    701        debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 
     695    assert(stream); 
     696    debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 
    702697 
    703698    for ( IsoRecvStreamVectorIterator it = m_Clients.begin(); 
     
    706701    { 
    707702        IsoRecvStream* s = *it; 
    708         if ( s == stream ) {  
    709                        unListen(s->getChannel()); 
     703        if ( s == stream ) { 
     704            unListen(s->getChannel()); 
    710705            m_Clients.erase(it); 
    711                        return 0; 
     706            return 0; 
    712707        } 
    713708    } 
    714709 
    715        return -1; //not found 
     710    return -1; //not found 
    716711 
    717712} 
    718713 
    719714void 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); 
    724719 
    725720} 
    726721 
    727722void 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); 
    732727 
    733728} 
     
    735730int IsoRecvHandler::start(int cycle) 
    736731{ 
    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); 
    739734} 
    740735#endif 
  • trunk/libffado/src/libstreaming/IsoHandler.h

    r419 r445  
    1 /* $Id$ */ 
    2  
    31/* 
    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 
    2722 */ 
    28 #ifndef __FREEBOB_ISOHANDLER__ 
    29 #define __FREEBOB_ISOHANDLER__ 
     23 
     24#ifndef __FFADO_ISOHANDLER__ 
     25#define __FFADO_ISOHANDLER__ 
    3026 
    3127#include "../debugmodule/debugmodule.h" 
     
    5147{ 
    5248    protected: 
    53      
     49 
    5450    public: 
    55          
     51 
    5652        enum EHandlerType { 
    5753                EHT_Receive, 
     
    6965        virtual bool start(int cycle); 
    7066        virtual bool stop(); 
    71          
     67 
    7268        bool iterate(); 
    73          
     69 
    7470        void setVerboseLevel(int l); 
    7571 
     
    112108        unsigned int    m_max_packet_size; 
    113109        int             m_irq_interval; 
    114          
     110 
    115111        int m_packetcount; 
    116112        int m_dropped; 
     
    135131            E_Error 
    136132        }; 
    137          
     133 
    138134        enum EHandlerStates m_State; 
    139135 
     
    141137 
    142138/*! 
    143 \brief ISO receive handler class (not multichannel)  
     139\brief ISO receive handler class (not multichannel) 
    144140*/ 
    145141 
    146 class IsoRecvHandler : public IsoHandler  
     142class IsoRecvHandler : public IsoHandler 
    147143{ 
    148144 
     
    153149 
    154150        bool init(); 
    155      
     151 
    156152        enum EHandlerType getType() { return EHT_Receive;}; 
    157153 
     
    164160 
    165161    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, 
    168164                            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, 
    170166                            unsigned int dropped); 
    171167 
    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, 
    175171                          unsigned int cycle, unsigned int dropped); 
    176172 
     
    181177*/ 
    182178 
    183 class IsoXmitHandler  : public IsoHandler  
     179class IsoXmitHandler  : public IsoHandler 
    184180{ 
    185181    public: 
    186182        IsoXmitHandler(int port); 
    187         IsoXmitHandler(int port, unsigned int buf_packets,  
     183        IsoXmitHandler(int port, unsigned int buf_packets, 
    188184                        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, 
    191187                        enum raw1394_iso_speed speed); 
    192188        virtual ~IsoXmitHandler(); 
    193189 
    194190        bool init(); 
    195          
     191 
    196192        enum EHandlerType getType() { return EHT_Transmit;}; 
    197193 
     
    211207                        unsigned char *tag, unsigned char *sy, 
    212208                        int cycle, unsigned int dropped); 
    213         enum raw1394_iso_disposition   
     209        enum raw1394_iso_disposition 
    214210                getPacket(unsigned char *data, unsigned int *length, 
    215211                        unsigned char *tag, unsigned char *sy, 
     
    217213 
    218214        enum raw1394_iso_speed m_speed; 
    219          
     215 
    220216        unsigned int m_prebuffers; 
    221217 
     
    224220} 
    225221 
    226 #endif /* __FREEBOB_ISOHANDLER__  */ 
    227  
    228  
    229  
     222#endif /* __FFADO_ISOHANDLER__  */ 
     223 
     224 
     225 
  • trunk/libffado/src/libstreaming/IsoHandlerManager.cpp

    r419 r445  
    1 /* $Id$ */ 
    2  
    31/* 
    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 
    2722 */ 
    2823 
     
    7368 
    7469    m_isoManagerThread=new Util::PosixThread( 
    75         this,  
     70        this, 
    7671        m_realtime, prio, 
    7772        PTHREAD_CANCEL_DEFERRED); 
     
    111106{ 
    112107//     updateCycleTimers(); 
    113      
     108 
    114109    if(!iterate()) { 
    115110        debugFatal("Could not iterate the isoManager\n"); 
    116111        return false; 
    117     }     
    118      
     112    } 
     113 
    119114    return true; 
    120115} 
     
    128123bool IsoHandlerManager::iterate() 
    129124{ 
    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; 
    162157 
    163158} 
     
    167162    debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 
    168163    assert(handler); 
    169      
     164 
    170165    m_IsoHandlers.push_back(handler); 
    171      
     166 
    172167    handler->setVerboseLevel(getDebugLevel()); 
    173168 
    174169    // rebuild the fd map for poll()'ing. 
    175     return rebuildFdMap();      
     170    return rebuildFdMap(); 
    176171 
    177172} 
     
    179174bool IsoHandlerManager::unregisterHandler(IsoHandler *handler) 
    180175{ 
    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 list 
    190                        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 found 
     176    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 
    198193 
    199194} 
    200195 
    201196bool 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 handlers 
    209        m_poll_nfds=m_IsoHandlers.size(); 
    210  
    211        // allocate the fd array 
    212        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 map 
    219        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; 
    229224} 
    230225 
    231226void IsoHandlerManager::disablePolling(IsoStream *stream) { 
    232227    int i=0; 
    233      
     228 
    234229    debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "Disable polling on stream %p\n",stream); 
    235230 
     
    243238            debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "polling disabled\n"); 
    244239        } 
    245          
     240 
    246241        i++; 
    247242    } 
     
    250245void IsoHandlerManager::enablePolling(IsoStream *stream) { 
    251246    int i=0; 
    252      
     247 
    253248    debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "Enable polling on stream %p\n",stream); 
    254      
     249 
    255250    for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin(); 
    256251        it != m_IsoHandlers.end(); 
     
    262257            debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "polling enabled\n"); 
    263258        } 
    264          
     259 
    265260        i++; 
    266261    } 
     
    279274 * 
    280275 * \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 
    282277 *        multichannel receive 
    283278 */ 
    284279bool IsoHandlerManager::registerStream(IsoStream *stream) 
    285280{ 
    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 handler 
    290        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 used 
    302        pruneHandlers(); 
    303  
    304        // allocate a handler for this stream 
    305        if (stream->getType()==IsoStream::EST_Receive) { 
    306                // setup the optimal parameters for the raw1394 ISO buffering 
    307                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 
    309304#if 1 
    310                // hardware interrupts occur when one DMA block is full, and the size of one DMA 
    311                 // 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 interrupts 
    315                //       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 the 
    322                // 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; 
    328323#else 
    329                // hardware interrupts occur when one DMA block is full, and the size of one DMA 
    330                // block = PAGE_SIZE. Setting the max_packet_size enables control over the IRQ 
    331                // frequency, as the controller uses max_packet_size, and not the effective size 
    332                // when writing to the DMA buffer. 
    333                  
    334                // configure it such that we have an irq for every PACKETS_PER_INTERRUPT packets 
    335                unsigned int irq_interval=PACKETS_PER_INTERRUPT; 
    336                  
    337                // unless the period size doesn't allow this 
    338                if ((packets_per_period/MINIMUM_INTERRUPTS_PER_PERIOD) < irq_interval) { 
    339                        irq_interval=1; 
    340                
    341                  
    342                // FIXME: test 
    343                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 the 
    352                // 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(); 
    355350 
    356351#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 handler 
    362                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 handler 
    375                if(!h->init()) { 
    376                        debugFatal("Could not initialize receive handler\n"); 
    377                        return false; 
    378                
    379  
    380                // register the stream with the handler 
    381                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 manager 
    387                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 buffering 
    396                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(); 
    397392 
    398393#if 1 
    399                // hardware interrupts occur when one DMA block is full, and the size of one DMA 
    400                 // 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 period 
    403                //       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 the 
    410                // 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; 
    416411#else 
    417                // hardware interrupts occur when one DMA block is full, and the size of one DMA 
    418                // block = PAGE_SIZE. Setting the max_packet_size enables control over the IRQ 
    419                // frequency, as the controller uses max_packet_size, and not the effective size 
    420                // when writing to the DMA buffer. 
    421                  
    422                // configure it such that we have an irq for every PACKETS_PER_INTERRUPT packets 
    423                unsigned int irq_interval=PACKETS_PER_INTERRUPT; 
    424                  
    425                // unless the period size doesn't allow this 
    426                if ((packets_per_period/MINIMUM_INTERRUPTS_PER_PERIOD) < irq_interval) { 
    427                        irq_interval=1; 
    428                
    429                  
    430                // FIXME: test 
    431                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 the 
    440                // 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(); 
    443438#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 buffer 
    446                // full, so we have to make sure that we have enough events in our 
    447                // event buffers 
    448                  
    449                // every irq_interval packets an interrupt will occur. that is when 
    450                // buffers get transfered, meaning that we should have at least some 
    451                // margin here 
    452                int buffers=irq_interval * 2; 
    453  
    454                // half a period. the xmit handler will take care of this 
    455 //             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 handler 
    461                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 handler 
    474                if(!h->init()) { 
    475                        debugFatal("Could not initialize transmit handler\n"); 
    476                        return false; 
    477                
    478  
    479                // register the stream with the handler 
    480                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 manager 
    486                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; 
    498493} 
    499494 
    500495bool IsoHandlerManager::unregisterStream(IsoStream *stream) 
    501496{ 
    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 anymore 
    506        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 used 
    521        pruneHandlers(); 
    522  
    523        // remove the stream from the registered streams list 
    524        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 found 
     497    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 
    537532 
    538533} 
     
    577572{ 
    578573    bool retval=true; 
    579      
    580     debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 
    581      
     574 
     575    debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 
     576 
    582577    // check state 
    583578    if(m_State != E_Created) { 
     
    585580        return false; 
    586581    } 
    587      
     582 
    588583    for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin(); 
    589584          it != m_IsoHandlers.end(); 
     
    611606bool IsoHandlerManager::startHandlers(int cycle) { 
    612607    bool retval=true; 
    613      
    614     debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 
    615      
     608 
     609    debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 
     610 
    616611    // check state 
    617612    if(m_State != E_Prepared) { 
     
    619614        return false; 
    620615    } 
    621      
     616 
    622617    for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin(); 
    623618        it != m_IsoHandlers.end(); 
     
    630625        } 
    631626    } 
    632      
     627 
    633628    debugOutput( DEBUG_LEVEL_VERBOSE, "Starting ISO iterator thread...\n"); 
    634629 
    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 
    636631    //       starting the streams. 
    637632    // start the iso runner thread 
    638633    m_isoManagerThread->Start(); 
    639      
     634 
    640635    if (retval) { 
    641636        m_State=E_Running; 
     
    649644bool IsoHandlerManager::stopHandlers() { 
    650645    debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 
    651      
     646 
    652647    // check state 
    653648    if(m_State != E_Running) { 
     
    655650        return false; 
    656651    } 
    657      
     652 
    658653    bool retval=true; 
    659      
     654 
    660655    debugOutput( DEBUG_LEVEL_VERBOSE, "Stopping ISO iterator thread...\n"); 
    661656    m_isoManagerThread->Stop(); 
    662      
     657 
    663658    for ( IsoHandlerVectorIterator it = m_IsoHandlers.begin(); 
    664659        it != m_IsoHandlers.end(); 
     
    671666        } 
    672667    } 
    673      
     668 
    674669    if (retval) { 
    675670        m_State=E_Prepared; 
     
    677672        m_State=E_Error; 
    678673    } 
    679      
     674 
    680675    return retval; 
    681676} 
     
    683678bool IsoHandlerManager::reset() { 
    684679    debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 
    685      
     680 
    686681    // check state 
    687682    if(m_State == E_Error) { 
     
    689684        return false; 
    690685    } 
    691      
     686 
    692687    // if not in an error condition, reset means stop the handlers 
    693688    return stopHandlers(); 
     
    708703void IsoHandlerManager::dumpInfo() { 
    709704    int i=0; 
    710      
     705 
    711706    debugOutputShort( DEBUG_LEVEL_NORMAL, "Dumping IsoHandlerManager Stream handler information...\n"); 
    712707    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 */ 
    223 
    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__ 
    3026 
    3127#include "../debugmodule/debugmodule.h" 
     
    8985        bool unregisterStream(IsoStream *); ///< unregister an iso stream from the manager 
    9086 
    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 
    9490 
    9591        bool reset(); ///< reset the ISO manager and all streams 
    9692 
    9793        bool prepare(); ///< prepare the ISO manager and all streams 
    98          
     94 
    9995        bool init(); 
    100          
     96 
    10197        void disablePolling(IsoStream *); ///< disables polling on a stream 
    10298        void enablePolling(IsoStream *); ///< enables polling on a stream 
     
    106102        bool Execute(); // note that this is called in we while(running) loop 
    107103        bool Init(); 
    108          
     104 
    109105    // the state machine 
    110106    private: 
     
    115111            E_Error 
    116112        }; 
    117          
     113 
    118114        enum EHandlerStates m_State; 
    119          
     115 
    120116    private: 
    121117        /// iterate all child handlers 
     
    124120    private: 
    125121        // 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 
    127123        // multichannel receive) 
    128124 
     
    152148        unsigned int m_priority; 
    153149        Util::PosixThread *m_isoManagerThread; 
    154          
    155          
     150 
     151 
    156152        // debug stuff 
    157153        DECLARE_DEBUG_MODULE; 
     
    161157} 
    162158 
    163 #endif /* __FREEBOB_ISOHANDLERMANAGER__  */ 
     159#endif /* __FFADO_ISOHANDLERMANAGER__  */ 
    164160 
    165161 
  • trunk/libffado/src/libstreaming/IsoStream.cpp

    r419 r445  
    1 /* $Id$ */ 
    2  
    31/* 
    4  *   FreeBob Streaming API 
    5  *   FreeBob = Firewire (pro-)audio for linux 
     2 * Copyright (C) 2005-2007 by Pieter Palmers 
    63 * 
    7  *   http://freebob.sf.net 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    86 * 
    9  *   Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> 
     7 * FFADO is based upon FreeBoB. 
    108 * 
    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; 
    1512 * 
    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. 
     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. 
    2017 * 
    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 
    2722 */ 
    2823 
     
    3530IMPL_DEBUG_MODULE( IsoStream, IsoStream, DEBUG_LEVEL_NORMAL ); 
    3631 
    37 enum raw1394_iso_disposition  
    38 IsoStream::putPacket(unsigned char *data, unsigned int length,  
    39                      unsigned char channel, unsigned char tag, unsigned char sy,  
     32enum raw1394_iso_disposition 
     33IsoStream::putPacket(unsigned char *data, unsigned int length, 
     34                     unsigned char channel, unsigned char tag, unsigned char sy, 
    4035                     unsigned int cycle, unsigned int dropped) { 
    4136 
     
    4742} 
    4843 
    49 enum raw1394_iso_disposition  
     44enum raw1394_iso_disposition 
    5045IsoStream::getPacket(unsigned char *data, unsigned int *length, 
    5146                     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 */ 
    223 
    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__ 
    3026 
    3127#include <libraw1394/raw1394.h> 
     
    5551        }; 
    5652 
    57         IsoStream(enum EStreamType type)  
     53        IsoStream(enum EStreamType type) 
    5854                    : m_type(type), m_channel(-1), m_port(0), m_handler(0) 
    5955        {}; 
    60         IsoStream(enum EStreamType type, int port)  
     56        IsoStream(enum EStreamType type, int port) 
    6157                    : m_type(type), m_channel(-1), m_port(port), m_handler(0) 
    6258        {}; 
    6359        virtual ~IsoStream() 
    6460        {}; 
    65      
     61 
    6662        virtual void setVerboseLevel(int l) { setDebugLevel( l ); }; 
    6763 
     
    7571        virtual unsigned int getPacketsPerPeriod() {return 1;}; 
    7672        virtual unsigned int getMaxPacketSize() {return 1024;}; //FIXME: arbitrary 
    77          
     73 
    7874        virtual bool init(); 
    7975 
    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, 
    8379                            unsigned int cycle, unsigned int dropped); 
    84         virtual enum raw1394_iso_disposition  
     80        virtual enum raw1394_iso_disposition 
    8581                getPacket(unsigned char *data, unsigned int *length, 
    8682                        unsigned char *tag, unsigned char *sy, 
     
    9086 
    9187        int getNodeId(); 
    92          
     88 
    9389        virtual bool reset(); 
    94         virtual bool prepare();         
    95      
     90        virtual bool prepare(); 
     91 
    9692    protected: 
    9793 
     
    104100 
    105101        IsoHandler *m_handler; 
    106          
     102 
    107103        DECLARE_DEBUG_MODULE; 
    108104 
     
    111107} 
    112108 
    113 #endif /* __FREEBOB_ISOSTREAM__ */ 
     109#endif /* __FFADO_ISOSTREAM__ */ 
    114110 
    115111 
  • trunk/libffado/src/libstreaming/MotuPort.cpp

    r419 r445  
    1 /* $Id$ */ 
    2  
    31/* 
    4  *   FreeBob Streaming API 
    5  *   FreeBob = Firewire (pro-)audio for linux 
     2 * Copyright (C) 2005-2007 by Jonathan Woithe 
     3 * Copyright (C) 2005-2007 by Pieter Palmers 
    64 * 
    7  *   http://freebob.sf.net 
     5 * This file is part of FFADO 
     6 * FFADO = Free Firewire (pro-)audio drivers for linux 
    87 * 
    9  *   Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> 
     8 * FFADO is based upon FreeBoB. 
    109 * 
    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; 
    1513 * 
    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. 
     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. 
    2018 * 
    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 
    2723 */ 
    2824 
  • 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 */ 
    224 
    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__ 
    3027 
    3128/** 
     
    4441 
    4542*/ 
    46 class MotuAudioPort  
    47        : public AudioPort, public MotuPortInfo 
     43class MotuAudioPort 
     44    : public AudioPort, public MotuPortInfo 
    4845{ 
    4946 
    5047public: 
    5148 
    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 nescessary 
    58        {}; 
     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    {}; 
    5956 
    60        virtual ~MotuAudioPort() {}; 
    61   
     57    virtual ~MotuAudioPort() {}; 
     58 
    6259protected: 
    6360 
     
    6966 
    7067*/ 
    71 class MotuMidiPort  
    72        : public MidiPort, public MotuPortInfo 
     68class MotuMidiPort 
     69    : public MidiPort, public MotuPortInfo 
    7370{ 
    7471 
    7572public: 
    7673 
    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 nescessary 
    82        {}; 
     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    {}; 
    8380 
    8481 
    85        virtual ~MotuMidiPort() {}; 
     82    virtual ~MotuMidiPort() {}; 
    8683 
    8784protected: 
    88          
     85 
    8986}; 
    9087 
     
    9491 
    9592*/ 
    96 class MotuControlPort  
    97        : public ControlPort, public MotuPortInfo 
     93class MotuControlPort 
     94    : public ControlPort, public MotuPortInfo 
    9895{ 
    9996 
    10097public: 
    10198 
    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    {}; 
    108105 
    109106 
    110        virtual ~MotuControlPort() {}; 
     107    virtual ~MotuControlPort() {}; 
    111108 
    112109protected: 
    113          
     110 
    114111}; 
    115112 
    116113} // end of namespace Streaming 
    117114 
    118 #endif /* __FREEBOB_MOTUPORT__ */ 
     115#endif /* __FFADO_MOTUPORT__ */ 
    119116 
  • 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 */ 
    224 
    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  */ 
    2825#include "MotuPortInfo.h" 
    2926#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 */ 
    224 
    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__ 
    3027 
    3128#include "../debugmodule/debugmodule.h" 
     
    3633\brief Class containing the stream information for a Motu channel 
    3734 
    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 
    4037 
    4138*/ 
     
    4441public: 
    4542    /** 
    46      * Sometimes a channel can have multiple formats, depending on the  
     43     * Sometimes a channel can have multiple formats, depending on the 
    4744     * 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.) 
    4946     * 
    5047     * This kind of enum allows to discriminate these formats when decoding 
    5148     * If all channels always have the same format, you won't be needing this 
    5249     */ 
    53 //     enum E_Formats { 
    54 //             E_MBLA,     // Multibit linear audio 
    55 //             E_Midi,     // MIDI 
    56 //     }; 
    57      
    58        /** 
    59         * Initialize Motu portinfo 
    60         * should not be called directly, is inherited by motu ports 
    61        
    62         * the position parameter is an example 
    63         * the name parameter is mandatory 
    64        
    65         * @param name Port name 
    66         * @param position Start position of port's data in iso event 
    67         * @param format Format of data in iso event 
    68         * @param size Size in bits of port's data in iso event 
    69          * @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() {}; 
    7572 
    7673 
    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;}; 
    8077 
    8178protected: 
     
    8986} // end of namespace Streaming 
    9087 
    91 #endif /* __FREEBOB_MOTUPORTINFO__ */ 
     88#endif /* __FFADO_MOTUPORTINFO__ */ 
  • trunk/libffado/src/libstreaming/MotuStreamProcessor.cpp

    r430 r445  
    1 /* $Id$ */ 
    2  
    31/* 
    4  *   FreeBob Streaming API 
    5  *   FreeBob = Firewire (pro-)audio for linux 
     2 * Copyright (C) 2005-2007 by Jonathan Woithe 
     3 * Copyright (C) 2005-2007 by Pieter Palmers 
    64 * 
    7  *   http://freebob.sf.net 
     5 * This file is part of FFADO 
     6 * FFADO = Free Firewire (pro-)audio drivers for linux 
    87 * 
    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. 
    119 * 
    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; 
    1613 * 
    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. 
     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. 
    2118 * 
    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 
    2823 */ 
     24 
    2925#include "MotuStreamProcessor.h" 
    3026#include "Port.h" 
     
    6157uint32_t ts_sec = CYCLE_TIMER_GET_SECS(ct_now); 
    6258  // 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 
    6460  // in advance of the cycle timer (reasons unknown at this stage).  In addition, 
    6561  // iso buffering can delay the arrival of packets for quite a number of cycles 
     
    8278/* transmit */ 
    8379MotuTransmitStreamProcessor::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) { 
    8884} 
    8985 
     
    9490bool MotuTransmitStreamProcessor::init() { 
    9591 
    96        debugOutput( DEBUG_LEVEL_VERBOSE, "Initializing (%p)...\n"); 
    97        // call the parent init 
    98         // this has to be done before allocating the buffers,  
    99        // because this sets the buffersizes from the processormanager 
    100        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; 
    106102} 
    107103 
    108104void MotuTransmitStreamProcessor::setVerboseLevel(int l) { 
    109        setDebugLevel(l); // sets the debug level of the current object 
    110        TransmitStreamProcessor::setVerboseLevel(l); // also set the level of the base class 
     105    setDebugLevel(l); // sets the debug level of the current object 
     106    TransmitStreamProcessor::setVerboseLevel(l); // also set the level of the base class 
    111107} 
    112108 
     
    114110enum raw1394_iso_disposition 
    115111MotuTransmitStreamProcessor::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) { 
    118114 
    119115// FIXME: the actual delays in the system need to be worked out so 
     
    121117    uint64_t ts_head, fc; 
    122118 
    123        quadlet_t *quadlet = (quadlet_t *)data; 
    124        signed int i; 
    125          
     119    quadlet_t *quadlet = (quadlet_t *)data; 
     120    signed int i; 
     121 
    126122    m_last_cycle=cycle; 
    127      
     123 
    128124    // determine if we want to send a packet or not 
    129125    // note that we can't use getCycleTimer directly here, 
    130126    // 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 
    132128    // on 'cycle', not 'now'. 
    133129    unsigned int ctr=m_handler->getCycleTimer(); 
    134130    int now_cycles = (int)CYCLE_TIMER_GET_CYCLES(ctr); 
    135      
     131 
    136132    // the difference between the cycle this 
    137133    // packet is intended for and 'now' 
    138134    int cycle_diff = diffCycles(cycle, now_cycles); 
    139      
    140        // Signal that streaming is still active 
    141        m_streaming_active = 1; 
     135 
     136    // Signal that streaming is still active 
     137    m_streaming_active = 1; 
    142138 
    143139    // as long as the cycle parameter is not in sync with 
     
    154150        if ((unsigned int)cycle == m_cycle_to_enable_at) { 
    155151            m_is_disabled=false; 
    156              
     152 
    157153            debugOutput(DEBUG_LEVEL_VERBOSE,"Enabling StreamProcessor %p at %u\n", this, cycle); 
    158              
     154 
    159155            // initialize the buffer head & tail 
    160156            m_SyncSource->m_data_buffer->getBufferHeadTimestamp(&ts_head, &fc); // thread safe 
    161              
     157 
    162158            // the number of cycles the sync source lags (> 0) 
    163159            // or leads (< 0) 
    164160            int sync_lag_cycles=diffCycles(cycle, m_SyncSource->getLastCycle()); 
    165              
     161 
    166162            // account for the cycle lag between sync SP and this SP 
    167163            // the last update of the sync source's timestamps was sync_lag_cycles 
    168164            // 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 
    170166            // frame that is sent on cycle CT to have a timestamp T1. 
    171167            // ts_head however is for cycle CT-sync_lag_cycles, and lies 
     
    173169            // T1. 
    174170            ts_head = addTicks(ts_head, sync_lag_cycles * TICKS_PER_CYCLE); 
    175              
     171 
    176172            m_data_buffer->setBufferTailTimestamp(ts_head); 
    177              
     173 
    178174            #ifdef DEBUG 
    179175            if ((unsigned int)m_data_buffer->getFrameCounter() != m_data_buffer->getBufferSize()) { 
     
    190186    } else if (m_disabled && !m_is_disabled) { 
    191187        // 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", 
    193189                    this, cycle); 
    194190        m_is_disabled=true; 
    195191    } 
    196192 
    197        // Do housekeeping expected for all packets sent to the MOTU, even 
    198        // for packets containing no audio data. 
    199        *sy = 0x00; 
    200        *tag = 1;      // All MOTU packets have a CIP-like header 
     193    // 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 
    201197 
    202198 
    203199    // the base timestamp is the one of the next sample in the buffer 
    204200    m_data_buffer->getBufferHeadTimestamp(&ts_head, &fc); // thread safe 
    205      
     201 
    206202    int64_t timestamp = ts_head; 
    207203 
    208204    // we send a packet some cycles in advance, to avoid the 
    209205    // following situation: 
    210     // suppose we are only a few ticks away from  
     206    // suppose we are only a few ticks away from 
    211207    // the moment to send this packet. therefore we decide 
    212208    // not to send the packet, but send it in the next cycle. 
    213209    // 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 
    215211    // packet is sent, unless TRANSFER_DELAY > 3072. 
    216212    // this means that we need at least one cycle of extra buffering. 
    217213    uint64_t ticks_to_advance = TICKS_PER_CYCLE * TRANSMIT_ADVANCE_CYCLES; 
    218      
     214 
    219215    // if cycle lies cycle_diff cycles in the future, we should 
    220216    // queue this packet cycle_diff * TICKS_PER_CYCLE earlier than 
     
    224220    // determine the 'now' time in ticks 
    225221    uint64_t cycle_timer=CYCLE_TIMER_TO_TICKS(ctr); 
    226      
     222 
    227223    // time until the packet is to be sent (if > 0: send packet) 
    228224    int32_t until_next=diffTicks(timestamp, cycle_timer + ticks_to_advance); 
    229      
    230        // Size of a single data frame in quadlets 
    231        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 
    233229    // don't process the stream when it is not enabled, not running 
    234230    // or when the next sample is not due yet. 
    235231    if((until_next>0) || m_is_disabled || !m_running) { 
    236232        // 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 
    240236        // present.  For data-less packets the dbc is the same as the previously 
    241237        // transmitted block. 
     
    245241        quadlet++; 
    246242        *length = 8; 
    247          
     243 
    248244        #warning high-pitched sound protection removed! 
    249245        // In the disabled state simply zero all data sent to the MOTU.  If 
     
    252248        // some reason.  This is not completely sufficient, however (zeroed 
    253249        // packets must also be sent on iso closedown). 
    254      
     250 
    255251        // FIXME: Currently we simply send empty packets to the MOTU when 
    256252        // 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 
    258254        // for the moment for reference. 
    259255        // FIXME: Currently we don't read the buffer at all during closedown. 
     
    263259//if (!m_is_disabled && m_running) 
    264260//  return RAW1394_ISO_OK; 
    265 //else  
     261//else 
    266262        return RAW1394_ISO_DEFER; 
    267263    } 
    268264 
    269        // The number of events expected by the MOTU is solely dependent on 
    270        // the current sample rate.  An 'event' is one sample from all channels 
    271        // 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); 
    273269 
    274270    // add the transmit transfer delay to construct the playout time 
    275271    uint64_t ts=addTicks(timestamp, TRANSMIT_TRANSFER_DELAY); 
    276      
     272 
    277273    if (m_data_buffer->readFrames(n_events, (char *)(data + 8))) { 
    278      
     274 
    279275        // Increment the dbc (data block count).  This is only done if the 
    280276        // packet will contain events - that is, we are due to send some 
     
    286282        if (m_tx_dbc > 0xff) 
    287283            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 
    291287        // present.  For data-less packets the dbc is the same as the previously 
    292288        // transmitted block. 
     
    301297        // I assume that it is in ticks, and wraps as the cycle timer 
    302298        #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) typecast 
    312                // 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. 
    313309 
    314310float 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); 
    320316if (cycle==0) { 
    321317  debugOutput(DEBUG_LEVEL_VERBOSE,"%d %d %d\n", 
     
    325321} 
    326322#if TESTTONE 
    327                        // FIXME: remove this hacked in 1 kHz test signal to 
    328                        // analog-1 when testing is complete.  Note that the tone is 
    329                        // *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           
    341337#endif 
    342338 
    343                
    344  
    345                // Process all ports that should be handled on a per-packet base 
    346                 // 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 control 
    349                // data isn't time specific I would also include it in the period 
    350                // based processing 
    351          
    352                // FIXME: m_tx_dbc probably needs to be initialised to a non-zero 
    353                // value somehow so MIDI sync is possible.  For now we ignore 
    354                // 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       
    358354 
    359355        return RAW1394_ISO_OK; 
    360          
     356 
    361357    } else if (now_cycles<cycle) { 
    362358        // we can still postpone the queueing of the packets 
     
    364360    } else { // there is no more data in the ringbuffer 
    365361 
    366         debugWarning("Transmit buffer underrun (now %d, queue %d, target %d)\n",  
     362        debugWarning("Transmit buffer underrun (now %d, queue %d, target %d)\n", 
    367363                 now_cycles, cycle, TICKS_TO_CYCLES(ts)); 
    368364 
     
    377373        // compose a no-data packet, we should always 
    378374        // send a valid packet 
    379          
     375 
    380376        // 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 
    384380        // present.  For data-less packets the dbc is the same as the previously 
    385381        // transmitted block. 
     
    403399 
    404400bool MotuTransmitStreamProcessor::prefill() { 
    405         // this is needed because otherwise there is no data to be  
    406        // sent when the streaming starts 
    407      
    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; 
    416412} 
    417413 
    418414bool MotuTransmitStreamProcessor::reset() { 
    419415 
    420        debugOutput( DEBUG_LEVEL_VERBOSE, "Resetting...\n"); 
     416    debugOutput( DEBUG_LEVEL_VERBOSE, "Resetting...\n"); 
    421417 
    422418    // we have to make sure that the buffer HEAD timestamp 
    423419    // lies in the future for every possible buffer fill case. 
    424420    int offset=(int)(m_data_buffer->getBufferSize()*m_ticks_per_frame); 
    425      
     421 
    426422    m_data_buffer->setTickOffset(offset); 
    427      
    428        // reset all non-device specific stuff 
    429        // i.e. the iso stream and the associated ports 
    430        if (!TransmitStreamProcessor::reset()) { 
    431                debugFatal("Could not do base class reset\n"); 
    432                return false; 
    433        
    434  
    435        // we should prefill the event buffer 
    436        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; 
    442438} 
    443439 
    444440bool MotuTransmitStreamProcessor::prepare() { 
    445      
    446        debugOutput( DEBUG_LEVEL_VERBOSE, "Preparing...\n"); 
    447      
    448        // prepare all non-device specific stuff 
    449        // i.e. the iso stream and the associated ports 
    450        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 buffer 
    462        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; 
    463459 
    464460    // allocate the internal buffer 
    465461    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); 
    469465    m_data_buffer->setBufferSize(ringbuffer_size_frames); 
    470466    m_data_buffer->setEventSize(m_event_size); 
    471467    m_data_buffer->setEventsPerFrame(1); 
    472      
     468 
    473469    m_data_buffer->setUpdatePeriod(m_period); 
    474470    m_data_buffer->setNominalRate(m_ticks_per_frame); 
    475      
     471 
    476472    // FIXME: check if the timestamp wraps at one second 
    477473    m_data_buffer->setWrapValue(128L*TICKS_PER_SECOND); 
    478      
     474 
    479475    m_data_buffer->prepare(); 
    480476 
    481        // Set the parameters of ports we can: we want the audio ports to be 
    482        // 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.  See 
    514                        // 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 before 
    531        // this routine is called, therefore we can init&prepare the ports 
    532        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; 
    543539} 
    544540 
    545541bool MotuTransmitStreamProcessor::prepareForStop() { 
    546542 
    547        // If the stream is disabled or isn't running there's no need to 
    548        // 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 the 
    551        // transmit callback hasn't been called since a closedown was 
    552        // requested when this function was last called.  This effectively 
    553        // signifies that the streaming thread has been exitted due to an 
    554        // xrun in either the receive or transmit handlers.  In this case 
    555        // there's no point in waiting for the closedown count to hit zero 
    556         // 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 handler 
    558        // proceed as best it can. 
    559        // 
    560        // The ability to detect the lack of streaming also prevents the 
    561        // "wait for stop" in the stream processor manager's stop() method 
    562        // from hitting its timeout which in turn seems to increase the 
    563        // 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.  Set 
    569                // the closedown count to the number of zero packets which 
    570                // will be sent to the MOTU before closing off the iso 
    571                // streams.  FIXME: 128 packets (each containing 8 frames at 
    572                // 48 kHz) is the experimentally-determined figure for 48 
    573                // kHz with a period size of 1024.  It seems that at least 
    574                // one period of zero samples need to be sent to allow for 
    575                 // inter-thread communication occuring on period boundaries.  
    576                // This needs to be confirmed for other rates and period 
    577                // 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 next 
    583                // iteration through this function there's no point in 
    584                 // 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 packets 
    591        // (initiated by a previous call to this function) have been sent to 
    592        // 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; 
    594590} 
    595591 
    596592bool MotuTransmitStreamProcessor::prepareForStart() { 
    597593// 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 
    599595// 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-enabled 
    606         // 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; 
    611607} 
    612608 
     
    615611    debugOutput(DEBUG_LEVEL_VERBOSE,"Preparing to enable...\n"); 
    616612 
    617     // for the transmit SP, we have to initialize the  
     613    // for the transmit SP, we have to initialize the 
    618614    // buffer timestamp to something sane, because this timestamp 
    619615    // is used when it is SyncSource 
    620      
     616 
    621617    // the time we initialize to will determine the time at which 
    622618    // the first sample in the buffer will be sent, so we should 
    623619    // make it at least 'time_to_enable_at' 
    624      
     620 
    625621    uint64_t now=m_handler->getCycleTimer(); 
    626622    unsigned int now_secs=CYCLE_TIMER_GET_SECS(now); 
    627      
     623 
    628624    // check if a wraparound on the secs will happen between 
    629625    // now and the time we start 
     
    633629        if (now_secs>=128) now_secs=0; 
    634630    } 
    635      
     631 
    636632//    uint64_t ts_head= now_secs*TICKS_PER_SECOND; 
    637633    uint64_t ts_head = time_to_enable_at*TICKS_PER_CYCLE; 
    638      
     634 
    639635    // we also add the nb of cycles we transmit in advance 
    640636    ts_head=addTicks(ts_head, TRANSMIT_ADVANCE_CYCLES*TICKS_PER_CYCLE); 
    641      
     637 
    642638    m_data_buffer->setBufferTailTimestamp(ts_head); 
    643639 
     
    652648bool MotuTransmitStreamProcessor::transferSilence(unsigned int size) { 
    653649    bool retval; 
    654      
    655        // This function should tranfer 'size' frames of 'silence' to the event buffer 
    656        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); 
    659655 
    660656    // 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)) { 
    662658        retval=true; 
    663659    } else { 
     
    666662    } 
    667663 
    668        free(dummybuffer); 
    669  
    670        return retval; 
     664    free(dummybuffer); 
     665 
     666    return retval; 
    671667} 
    672668 
    673669bool MotuTransmitStreamProcessor::putFrames(unsigned int nbframes, int64_t ts) { 
    674670    m_PeriodStat.mark(m_data_buffer->getBufferFill()); 
    675      
     671 
    676672    debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "MotuTransmitStreamProcessor::putFrames(%d, %llu)\n", nbframes, ts); 
    677      
     673 
    678674    // transfer the data 
    679675    m_data_buffer->blockProcessWriteFrames(nbframes, ts); 
     
    684680} 
    685681 
    686 /*  
     682/* 
    687683 * write received events to the stream ringbuffers. 
    688684 */ 
    689685 
    690 bool MotuTransmitStreamProcessor::processWriteBlock(char *data,  
     686bool MotuTransmitStreamProcessor::processWriteBlock(char *data, 
    691687                       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 until 
    696        // 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 it 
    705                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 process 
    719                //      case MotuPortInfo::E_Midi: 
    720                //              break; 
    721  
    722                default: // ignore 
    723                        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 
     725int MotuTransmitStreamProcessor::transmitSilenceBlock(char *data, 
    730726                       unsigned int nevents, unsigned int offset) { 
    731        // This is the same as the non-silence version, except that is 
    732        // 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 process 
    751                //      case MotuPortInfo::E_Midi: 
    752                //              break; 
    753  
    754                default: // ignore 
    755                        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; 
    759755} 
    760756 
     
    767763 * @return true if all successfull 
    768764 */ 
    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 be 
    775        // aligned; use of an unaligned quadlet_t may cause issues on 
    776        // certain architectures.  Besides, the target for MIDI data going 
    777        // directly to the MOTU isn't structured in quadlets anyway; it is a 
    778        // 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 data 
    790                // 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 is 
    799                                // sent using a 3-byte sequence starting at 
    800                                // the port's position.  For now we'll 
    801                                // always send in the first event of a 
    802                                // packet, but this might need refinement 
    803                                // 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,  
     765bool 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 
     818int MotuTransmitStreamProcessor::encodePortToMotuEvents(MotuAudioPort *p, quadlet_t *data, 
    823819                       unsigned int offset, unsigned int nevents) { 
    824820// Encodes nevents worth of data from the given port into the given buffer.  The 
     
    836832// utilised. 
    837833 
    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 certain 
    842        // architectures.  Besides, the target (data going directly to the MOTU) 
    843        // isn't structured in quadlets anyway; it mainly consists of packed 
    844        // 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 single 
    857                                // channel, so the number of frames is the same as the 
    858                                // number of quadlets to offset (assuming the port buffer 
    859                                // uses one quadlet per sample, which is the case currently). 
    860                                buffer+=offset; 
    861  
    862                                for(j = 0; j < nevents; j += 1) { // Decode nsamples 
    863                                        *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 
     893int MotuTransmitStreamProcessor::encodeSilencePortToMotuEvents(MotuAudioPort *p, quadlet_t *data, 
    898894                       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: 
    904900        case Port::E_Int24: 
    905901        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; 
    914910} 
    915911 
    916912/* --------------------- RECEIVE ----------------------- */ 
    917913 
    918 MotuReceiveStreamProcessor::MotuReceiveStreamProcessor(int port, int framerate,  
    919        unsigned int event_size) 
     914MotuReceiveStreamProcessor::MotuReceiveStreamProcessor(int port, int framerate, 
     915    unsigned int event_size) 
    920916    : ReceiveStreamProcessor(port, framerate), m_event_size(event_size), 
    921        m_closedown_active(0) { 
     917    m_closedown_active(0) { 
    922918 
    923919} 
     
    929925bool MotuReceiveStreamProcessor::init() { 
    930926 
    931        // call the parent init 
    932         // this has to be done before allocating the buffers,  
    933        // because this sets the buffersizes from the processormanager 
    934        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 by 
    943        //             enforcing that the roundtrip latency is constant: 
    944        // Detect missed receive cycles 
    945        // FIXME: it would be nice to advance the rx buffer by the amount of 
    946        // frames missed.  However, since the MOTU transmits more frames per 
    947        // cycle than the average and "catches up" with periodic empty 
    948        // cycles it's not trivial to work out precisely how many frames 
    949        // were missed.  Ultimately I think we need to do so if sync is to 
    950        // 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 
     948enum raw1394_iso_disposition 
     949MotuReceiveStreamProcessor::putPacket(unsigned char *data, unsigned int length, 
     950                  unsigned char channel, unsigned char tag, unsigned char sy, 
    955951                  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() 
    960956    m_last_cycle=cycle; 
    961957 
     
    965961        if (cycle == m_cycle_to_enable_at) { 
    966962            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", 
    968964                this, cycle); 
    969                  
     965 
    970966            // the previous timestamp is the one we need to start with 
    971967            // because we're going to update the buffer again this loop 
     
    988984        m_is_disabled=true; 
    989985    } 
    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-like 
    995                // header followed by a number of events (8 for 1x rates, 16 
    996                // 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_size 
    999                unsigned int fdf_size = get_bits(ntohl(quadlet[1]), 23, 8) == 0x22 ? 32:0; // Event unit size in bits 
    1000  
    1001                // Don't even attempt to process a packet if it isn't what 
    1002                // we expect from a MOTU.  Yes, an FDF value of 32 bears 
    1003                // little relationship to the actual data (24 bit integer) 
    1004                // sent by the MOTU - it's one of those areas where MOTU 
    1005                // 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 packets 
    1011                unsigned int event_length = (fdf_size * dbs) / 8;       // Event size in bytes 
    1012                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 
    10141010        //=> store the previous timestamp 
    10151011        m_last_timestamp2=m_last_timestamp; 
    10161012 
    10171013        //=> 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)), 
    10191015//                                        cycle, m_handler->getCycleTimer()); 
    10201016//*** 
     
    10281024m_last_timestamp = sphRecvToFullTicks(first_sph, m_handler->getCycleTimer()); 
    10291025 
    1030                // Signal that we're running 
     1026        // Signal that we're running 
    10311027        if(!m_running && n_events && m_last_timestamp2 && m_last_timestamp) { 
    10321028            debugOutput(DEBUG_LEVEL_VERBOSE,"Receive StreamProcessor %p started running at %d\n", this, cycle); 
     
    10411037            // estimate as to when a period might be ready. i.e. it will not 
    10421038            // 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 
    10451041            // SYT_INTERVAL * rate later 
    10461042            float frame_size=m_framerate<=48000?8:(m_framerate<=96000?16:32); 
     
    10561052            m_data_buffer->setBufferTailTimestamp(ts); 
    10571053//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 
    10591055            return RAW1394_ISO_DEFER; 
    10601056        } 
    10611057 
    1062                debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "put packet...\n"); 
     1058        debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "put packet...\n"); 
    10631059//debugOutput(DEBUG_LEVEL_VERBOSE,"enabled: %p, last ts=%lld, ts2=%lld\n",m_data_buffer, m_last_timestamp, m_last_timestamp2); 
    10641060 
    10651061        //=> process the packet 
    10661062        // 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)) { 
    10681064            retval=RAW1394_ISO_OK; 
    1069              
     1065 
    10701066            int dbc = get_bits(ntohl(quadlet[0]), 8, 8); 
    1071              
     1067 
    10721068            // process all ports that should be handled on a per-packet base 
    10731069            // this is MIDI for AMDTP (due to the need of DBC) 
     
    10761072                retval=RAW1394_ISO_DEFER; 
    10771073            } 
    1078              
     1074 
    10791075        } 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", 
    10821078                 cycle, m_data_buffer->getFrameCounter(), m_handler->getPacketCount()); 
    1083              
     1079 
    10841080            m_xruns++; 
    1085              
     1081 
    10861082            // disable the processing, will be re-enabled when 
    10871083            // the xrun is handled 
     
    10931089    } 
    10941090 
    1095        return retval; 
     1091    return retval; 
    10961092} 
    10971093 
     
    11001096// ISO buffering 
    11011097int 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 
    11041100    return (int)(m_handler->getWakeupInterval() * n_events * m_ticks_per_frame); 
    11051101} 
     
    11071103bool MotuReceiveStreamProcessor::reset() { 
    11081104 
    1109        debugOutput( DEBUG_LEVEL_VERBOSE, "Resetting...\n"); 
     1105    debugOutput( DEBUG_LEVEL_VERBOSE, "Resetting...\n"); 
    11101106 
    11111107    m_data_buffer->setTickOffset(0); 
    11121108 
    1113        // reset all non-device specific stuff 
    1114        // i.e. the iso stream and the associated ports 
    1115        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; 
    11211117} 
    11221118 
    11231119bool MotuReceiveStreamProcessor::prepare() { 
    11241120 
    1125        // prepare all non-device specific stuff 
    1126        // i.e. the iso stream and the associated ports 
    1127        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"); 
    11371133 
    11381134    // setup any specific stuff here 
    11391135    // 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 
    11421138    // prepare the framerate estimate 
    11431139    m_ticks_per_frame = (TICKS_PER_SECOND*1.0) / ((float)m_framerate); 
    1144          
    1145        // initialize internal buffer 
    1146        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); 
    11511147    m_data_buffer->setBufferSize(ringbuffer_size_frames); 
    11521148    m_data_buffer->setEventSize(m_event_size); 
    1153     m_data_buffer->setEventsPerFrame(1);        
    1154      
     1149    m_data_buffer->setEventsPerFrame(1); 
     1150 
    11551151// JMW: The rx buffer receives a new timestamp once per received frame so I think the 
    11561152// buffer update period is events_per_frame, not events per period. 
     
    11581154    m_data_buffer->setUpdatePeriod(events_per_frame); 
    11591155    m_data_buffer->setNominalRate(m_ticks_per_frame); 
    1160      
     1156 
    11611157    m_data_buffer->setWrapValue(128L*TICKS_PER_SECOND); 
    1162      
     1158 
    11631159    m_data_buffer->prepare(); 
    11641160 
    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 buffered 
    1168        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.  See 
    1200                                // 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 before 
    1216        // this routine is called, therefore we can init&prepare the ports 
    1217        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; 
    12281224 
    12291225} 
     
    12321228bool MotuReceiveStreamProcessor::prepareForStop() { 
    12331229 
    1234        // A MOTU receive stream can stop at any time.  However, signify 
    1235        // that stopping is in progress because other streams (notably the 
    1236        // transmit stream) may keep going for some time and cause an 
    1237        // overflow in the receive buffers.  If a closedown is in progress 
    1238        // the receive handler simply throws all incoming data away so 
    1239        // 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; 
    12421238} 
    12431239 
     
    12471243// xrun recovery.  Initialisations which should be done once should be 
    12481244// 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-enabled 
    1254         // 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; 
    12591255} 
    12601256 
     
    12741270 * \brief write received events to the port ringbuffers. 
    12751271 */ 
    1276 bool MotuReceiveStreamProcessor::processReadBlock(char *data,  
    1277                                           unsigned int nevents, unsigned int offset) 
     1272bool MotuReceiveStreamProcessor::processReadBlock(char *data, 
     1273                       unsigned int nevents, unsigned int offset) 
    12781274{ 
    1279        bool no_problem=true; 
    1280        for ( PortVectorIterator it = m_PeriodPorts.begin(); 
     1275    bool no_problem=true; 
     1276    for ( PortVectorIterator it = m_PeriodPorts.begin(); 
    12811277          it != m_PeriodPorts.end(); 
    12821278          ++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 process 
    1297                //      case MotuPortInfo::E_Midi: 
    1298                //              break; 
    1299  
    1300                default: // ignore 
    1301                        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; 
    13051301} 
    13061302 
     
    13131309 * @return true if all successfull 
    13141310 */ 
    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 be 
    1320        // aligned; use of an unaligned quadlet_t may cause issues on 
    1321        // certain architectures.  Besides, the source for MIDI data going 
    1322        // directly to the MOTU isn't structured in quadlets anyway; it is a 
    1323        // 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 data 
    1335                 // 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 the 
    1345                                // packet.  MOTU MIDI data is sent using a 
    1346                                // 3-byte sequence starting at the port's 
    1347                                // position.  It's thought that there can never 
    1348                                // be more than one MIDI byte per packet, but 
    1349                                // for completeness we'll check the entire packet 
    1350                                // 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) 
     1311bool 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 
     1370signed int MotuReceiveStreamProcessor::decodeMotuEventsToPort(MotuAudioPort *p, 
     1371        quadlet_t *data, unsigned int offset, unsigned int nevents) 
    13761372{ 
    1377        unsigned int j=0; 
    1378  
    1379        // Use char here since a port's source address won't necessarily be 
    1380        // aligned; use of an unaligned quadlet_t may cause issues on 
    1381        // certain architectures.  Besides, the source (data coming directly 
    1382        // from the MOTU) isn't structured in quadlets anyway; it mainly 
    1383        // 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 single 
    1397                                // channel, so the number of frames is the same as the 
    1398                                // number of quadlets to offset (assuming the port buffer 
    1399                                // uses one quadlet per sample, which is the case currently). 
    1400                                buffer+=offset; 
    1401  
    1402                                for(j = 0; j < nevents; j += 1) { // Decode nsamples 
    1403                                        *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 data 
    1407                                        // 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 int 
    1430                                        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; 
    14421438} 
    14431439 
    14441440signed int MotuReceiveStreamProcessor::setEventSize(unsigned int size) { 
    1445        m_event_size = size; 
    1446        return 0; 
     1441    m_event_size = size; 
     1442    return 0; 
    14471443} 
    14481444 
     
    14521448// data packet in bytes. 
    14531449// 
    1454        return m_event_size; 
     1450    return m_event_size; 
    14551451} 
    14561452 
    14571453void MotuReceiveStreamProcessor::setVerboseLevel(int l) { 
    1458        setDebugLevel(l); 
    1459        ReceiveStreamProcessor::setVerboseLevel(l); 
     1454    setDebugLevel(l); 
     1455    ReceiveStreamProcessor::setVerboseLevel(l); 
    14601456} 
    14611457 
  • 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 */ 
    224 
    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__ 
    3127#include <assert.h> 
    3228 
     
    4844{ 
    4945public: 
    50          
    51         MotuTransmitStreamProcessor(int port, int framerate,  
    52                 unsigned int event_size); 
    5346 
    54         virtual ~MotuTransmitStreamProcessor(); 
     47    MotuTransmitStreamProcessor(int port, int framerate, 
     48        unsigned int event_size); 
    5549 
    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(); 
    6051 
    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); 
    6456 
    65         bool prepareForStop(); 
    66         bool prepareForStart(); 
    67          
     57    bool init(); 
     58    bool reset(); 
     59    bool prepare(); 
     60 
     61    bool prepareForStop(); 
     62    bool prepareForStart(); 
     63 
    6864    bool prepareForEnable(uint64_t time_to_enable_at); 
    69      
     65 
    7066    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 buffers 
    73        // 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);}; 
    7672 
    7773    int getMinimalSyncDelay(); 
    7874 
    79        void setVerboseLevel(int l); 
     75    void setVerboseLevel(int l); 
    8076 
    8177protected: 
    82        /* 
    83         * An iso packet mostly consists of multiple events.  m_event_size 
    84         * 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; 
    8783 
    88        // Keep track of transmission data block count 
    89        unsigned int m_tx_dbc; 
     84    // Keep track of transmission data block count 
     85    unsigned int m_tx_dbc; 
    9086 
    91        // Used to keep track of the close-down zeroing of output data 
    92        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; 
    9490 
    9591    bool prefill(); 
    96      
    97        bool transferSilence(unsigned int size); 
     92 
     93    bool transferSilence(unsigned int size); 
    9894 
    9995    bool processWriteBlock(char *data, unsigned int nevents, unsigned int offset); 
    10096 
    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); 
    110106 
    111107    DECLARE_DEBUG_MODULE; 
     
    118114 */ 
    119115class MotuReceiveStreamProcessor 
    120     : public ReceiveStreamProcessor  
     116    : public ReceiveStreamProcessor 
    121117{ 
    122118 
    123119public: 
    124120 
    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 
    132128    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(); 
    137133 
    138134    // these two are important to calculate the optimal 
    139135    // ISO DMA buffers size 
    140136    // 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 
    144140    int getMinimalSyncDelay(); 
    145141 
    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); 
    150143 
    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(); 
    153149 
    154150protected: 
    155151 
    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); 
    160153 
    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); 
    166156 
    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 
    168164        // is junked. 
    169165        signed int m_closedown_active; 
    170          
     166 
    171167    uint64_t m_last_timestamp; /// last timestamp (in ticks) 
    172168    uint64_t m_last_timestamp2; /// last timestamp (in ticks) 
    173169    uint64_t m_last_timestamp_at_period_ticks; 
    174      
     170 
    175171    DECLARE_DEBUG_MODULE; 
    176172 
     
    179175} // end of namespace Streaming 
    180176 
    181 #endif /* __FREEBOB_MOTUSTREAMPROCESSOR__ */ 
     177#endif /* __FFADO_MOTUSTREAMPROCESSOR__ */ 
    182178 
    183179 
  • trunk/libffado/src/libstreaming/Port.cpp

    r419 r445  
    1 /* $Id$ */ 
    2  
    31/* 
    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 
    2722 */ 
    2823 
    2924#include "Port.h" 
    30  #include <stdlib.h> 
     25#include <stdlib.h> 
    3126#include <assert.h> 
    3227 
    33  
    3428namespace Streaming { 
    3529 
    3630IMPL_DEBUG_MODULE( Port, Port, DEBUG_LEVEL_NORMAL ); 
    3731 
    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          
     32Port::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 
    5953{ 
    6054 
     
    6963 */ 
    7064bool 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 anything 
    85                        } 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 it 
    109          
    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; 
    111105} 
    112106 
    113107bool 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; 
    118112}; 
    119113 
    120114 
    121115void Port::setVerboseLevel(int l) { 
    122        setDebugLevel(l); 
     116    setDebugLevel(l); 
    123117} 
    124118 
    125119bool 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; 
    136130} 
    137131 
    138132bool 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; 
    147141 
    148142} 
    149143 
    150144unsigned 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   
    161155} 
    162156 
    163157bool 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 checks 
    171        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; 
    194188} 
    195189 
    196190bool 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 checks 
    204        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; 
    226220 
    227221} 
    228222 
    229223bool 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 checks 
    237        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; 
    258252 
    259253} 
     
    261255bool Port::useExternalBuffer(bool b) { 
    262256 
    263        // If called on an initialised stream but the request isn't for a change silently 
    264        // 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; 
    277271} 
    278272 
     
    281275 * Get the buffer address (being the external or the internal one). 
    282276 * 
    283  * @param buff  
     277 * @param buff 
    284278 */ 
    285279void *Port::getBufferAddress() { 
    286        assert(m_BufferType==E_PointerBuffer); 
    287        return m_buffer; 
     280    assert(m_BufferType==E_PointerBuffer); 
     281    return m_buffer; 
    288282}; 
    289283 
     
    292286 * only call this when specifying an external buffer before init() 
    293287 * 
    294  * @param buff  
     288 * @param buff 
    295289 */ 
    296290void 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; 
    300294}; 
    301295 
    302296// buffer handling api's for ringbuffers 
    303297bool 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); 
    310304} 
    311305 
    312306bool 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); 
    319313} 
    320314 
    321315int 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; 
    340336 
    341337} 
    342338 
    343339int 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; 
    361359} 
    362360 
    363361/* rate control */ 
    364362bool 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 counter 
    381                        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 ratecontrol 
    400        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 rate 
    433                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 
     405bool 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; 
    442440} 
    443441 
    444442/// Enable the port. (this can be called anytime) 
    445 void  
     443void 
    446444Port::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()); 
    455446    m_disabled=false; 
    456447}; 
    457448 
     449/// Disable the port. (this can be called anytime) 
     450void 
     451Port::disable() { 
     452    debugOutput(DEBUG_LEVEL_VERBOSE, "Disabling port %s...\n",m_Name.c_str()); 
     453    m_disabled=false; 
     454}; 
     455 
    458456 
    459457/* Private functions */ 
    460458 
    461459bool 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; 
    481479} 
    482480 
    483481void 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   
    491489} 
    492490 
    493491bool 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; 
    513511} 
    514512 
    515513void 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  
    31/* 
    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 
    2722 */ 
    28 #ifndef __FREEBOB_PORT__ 
    29 #define __FREEBOB_PORT__ 
     23 
     24#ifndef __FFADO_PORT__ 
     25#define __FFADO_PORT__ 
    3026 
    3127#include <stdint.h> 
     
    4339 layer and the datatype-specific layer. You can define port types by subclassing 
    4440 the base port class. 
    45   
     41 
    4642 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: 
    4844 1) the stream composition information from the AvDevice 
    4945 2) the streaming API setup (buffer type, data type, ...) 
    50   
     46 
    5147 \note There are not much virtual functions here because of the high frequency of 
    5248       calling. We try to do everything with a base class getter, and a child class 
    5349       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 
    5551       the ports. i.e. by design you should make sure that the static_cast will be 
    5652       OK. 
    57         
     53 
    5854 \todo rework the implementation into something more beautifull 
    5955*/ 
     
    6157 
    6258public: 
    63        friend class PortManager; 
    64          
    65        /* 
    66         * IMPORTANT: if you add something to any of these enum's, be sure to 
    67         *            check the code where they are used. 
    68         */ 
    69           
    70        /*! 
    71        \brief Specifies the buffer type for ports 
    72          
    73        A PointerBuffer uses the getBufferAddress() and setBufferAddres() interface 
    74        A Ringbuffer uses the read/write interface 
    75        */ 
    76        enum E_BufferType { 
    77                 E_PointerBuffer,  
    78                E_RingBuffer 
    79        }; 
    80          
    81        /*! 
    82        \brief Specifies the signalling type for ports 
    83        */ 
    84        enum E_SignalType { 
    85                E_PacketSignalled, ///< the port is to be processed for every packet 
    86                E_PeriodSignalled, ///< the port is to be processed after a period of frames 
    87 //             E_SampleSignalled ///< the port is to be processed after each frame (sample) 
    88        }; 
    89  
    90        /*! 
    91        \brief The datatype of the port buffer 
    92        */ 
    93        enum E_DataType { 
    94                E_Float, 
    95                E_Int24, 
    96                E_MidiEvent, 
    97                E_Default, 
    98        }; 
    99  
    100        /*! 
    101        \brief The port type 
    102        */ 
    103        enum E_PortType { 
    104                E_Audio, 
    105                E_Midi, 
    106                E_Control, 
    107        }; 
    108  
    109        /*! 
    110        \brief The port direction 
    111        */ 
    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 port 
    132        */ 
    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 bytes 
    143        
    144         */ 
    145        unsigned int getEventSize(); 
    146  
    147        /** 
    148         * \brief sets the event type for the port buffer 
    149        
    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 buffer 
    158        
    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 port 
    164          
    165        /** 
    166         * \brief sets the buffer type for the port 
    167        
    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 port 
    173  
    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 buffer 
    179        
    180         * counted in number of E_DataType units (events), not in bytes 
    181        
    182         */ 
    183        unsigned int getBufferSize() {return m_buffersize;}; 
    184          
    185        /** 
    186         * \brief sets the size of the port buffer 
    187        
    188         * counted in number of E_DataType units, not in bytes 
    189        
    190         * if there is an external buffer assigned, it should 
    191         * be large enough 
    192         * if there is an internal buffer, it will be resized 
    193        
    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 ratecontrol 
    210        
    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 buffer 
    216         *  (2) we are allowed to send an event in this slot 
    217        
    218         * Setting the rate works is done with the slot_interval and the event_interval 
    219          * parameters. On every call to canRead(), a counter is decremented with  
    220         * slot_interval. If the counter drops below 0, canRead() returns true and resets 
    221         * the counter to event_interval. 
    222        
    223         * e.g. for AMDTP midi, we are only allowed to send a midi byte every 320us 
    224         *      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 them 
    229         *      to your needs. In the AMDTP case for example, when the SYT interval is 32 
    230         *      (when the samplerate is 192kHz for example) there are 4 midi slots in 
    231          *      each packet, making the slot time interval 125us/4 = 31.25us.  
    232         *      The event time interval stays the same (320us). We can however set the 
    233         *      slot_interval to 3125 and the event_interval to 32000, as we can choose 
    234         *      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 use 
    237         * average rate control. This means that on average there will be a delay of 
    238         * event_interval between two events, but that sometimes there can be a smaller 
    239         * delay. This mode fixes the average rate of the stream. 
    240         * If average is false, there will always be a minimal delay of event_interval 
    241         * 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 ports 
    247         * \note use before calling init() 
    248        
    249         * @param use set this to true to use rate control 
    250         * @param slot_interval the interval between slots 
    251         * @param event_interval the interval between events 
    252         * @param average use average rate control 
    253         * @return true if rate control was enabled/disabled successfully 
    254         */ 
    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 slot 
    264         */ 
    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 interface 
    271        bool writeEvent(void *event); ///< write one event 
    272        bool readEvent(void *event); ///< read one event 
    273        int writeEvents(void *event, unsigned int nevents); ///< write multiple events 
    274        int readEvents(void *event, unsigned int nevents); ///< read multiple events 
    275  
    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); 
    277273 
    278274protected: 
    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(); 
    310306 
    311307    DECLARE_DEBUG_MODULE; 
     
    322318public: 
    323319 
    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() {}; 
    329325 
    330326protected: 
    331327 
    332    
     328 
    333329}; 
    334330 
     
    342338public: 
    343339 
    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() {}; 
    348344 
    349345 
     
    362358public: 
    363359 
    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() {}; 
    368364 
    369365 
     
    375371} 
    376372 
    377 #endif /* __FREEBOB_PORT__ */ 
    378  
    379  
     373#endif /* __FFADO_PORT__ */ 
     374 
     375 
  • trunk/libffado/src/libstreaming/PortManager.cpp

    r419 r445  
    1 /* $Id$ */ 
    2  
    31/* 
    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 
    2722 */ 
    2823 
     
    4136 
    4237PortManager::~PortManager() { 
    43 //     deleteAllPorts(); 
     38//     deleteAllPorts(); 
    4439} 
    4540 
    4641// 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 found 
    61 //  
     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// 
    6257// } 
    6358 
    6459/** 
    65  *  
    66  * @param port  
    67  * @return  
     60 * 
     61 * @param port 
     62 * @return 
    6863 */ 
    6964bool PortManager::addPort(Port *port) 
    7065{ 
    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; 
    7772} 
    7873 
    7974bool PortManager::deletePort(Port *port) 
    8075{ 
    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 found 
     76    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 
    9893 
    9994} 
     
    10196void PortManager::deleteAllPorts() 
    10297{ 
    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; 
    114109 
    115110} 
    116111 
    117112int 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; 
    129124} 
    130125 
    131126int 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; 
    137132} 
    138133 
    139134Port * PortManager::getPortAtIdx(unsigned int index) { 
    140135 
    141        return m_Ports.at(index); 
     136    return m_Ports.at(index); 
    142137 
    143138} 
     
    145140void PortManager::setVerboseLevel(int i) { 
    146141 
    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   
    155150 
    156151} 
     
    158153 
    159154bool 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; 
    172167} 
    173168 
    174169bool 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; 
    187182} 
    188183 
    189184bool PortManager::preparePorts() { 
    190        debugOutput( DEBUG_LEVEL_VERBOSE, "preparing ports\n"); 
    191          
    192        // clear the cache lists 
    193        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 lists 
    206                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 */ 
    223 
    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__ 
    3026 
    3127#include "../debugmodule/debugmodule.h" 
     
    4339 
    4440 Contains helper classes that allow the easy maintaining of Port collections. 
    45   
     41 
    4642*/ 
    4743class PortManager { 
     
    4945public: 
    5046 
    51        PortManager(); 
    52        virtual ~PortManager(); 
     47    PortManager(); 
     48    virtual ~PortManager(); 
    5349 
    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(); 
    5753 
    58        int getPortCount(enum Port::E_PortType); 
    59        int getPortCount(); 
     54    int getPortCount(enum Port::E_PortType); 
     55    int getPortCount(); 
    6056 
    61 //     virtual bool setPortBuffersize(unsigned int newsize); 
     57//     virtual bool setPortBuffersize(unsigned int newsize); 
    6258 
    63        Port *getPortAtIdx(unsigned int index); 
     59    Port *getPortAtIdx(unsigned int index); 
    6460 
    65        virtual bool resetPorts(); 
    66         virtual bool initPorts();        
    67         virtual bool preparePorts();     
     61    virtual bool resetPorts(); 
     62    virtual bool initPorts(); 
     63    virtual bool preparePorts(); 
    6864 
    69        virtual void setVerboseLevel(int l); 
     65     virtual void setVerboseLevel(int l); 
    7066 
    7167protected: 
    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; 
    7672 
    7773    DECLARE_DEBUG_MODULE; 
     
    8177} 
    8278 
    83 #endif /* __FREEBOB_PORTMANAGER__ */ 
     79#endif /* __FFADO_PORTMANAGER__ */ 
    8480 
    8581 
  • trunk/libffado/src/libstreaming/StreamProcessor.cpp

    r428 r445  
    1 /* $Id$ */ 
    2  
    31/* 
    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 
    2722 */ 
    2823 
     
    4136IMPL_DEBUG_MODULE( TransmitStreamProcessor, TransmitStreamProcessor, DEBUG_LEVEL_VERBOSE ); 
    4237 
    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) 
     38StreamProcessor::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) 
    5853{ 
    5954    // create the timestamped buffer and register ourselves as its client 
     
    7065    debugOutputShort( DEBUG_LEVEL_NORMAL, " StreamProcessor information\n"); 
    7166    debugOutputShort( DEBUG_LEVEL_NORMAL, "  Iso stream info:\n"); 
    72      
     67 
    7368    IsoStream::dumpInfo(); 
    7469    debugOutputShort( DEBUG_LEVEL_NORMAL, "  StreamProcessor info:\n"); 
     
    7974    debugOutputShort( DEBUG_LEVEL_NORMAL, "  Enabled               : %s\n", m_disabled ? "No" : "Yes"); 
    8075    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", 
    8378        24576000.0/m_SyncSource->m_data_buffer->getRate(), 
    8479        24576000.0/m_data_buffer->getRate() 
    8580        ); 
    86      
     81 
    8782    m_data_buffer->dumpInfo(); 
    88      
     83 
    8984//     m_PeriodStat.dumpInfo(); 
    9085//     m_PacketStat.dumpInfo(); 
     
    9691{ 
    9792    debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "enter...\n"); 
    98      
     93 
    9994    m_data_buffer->init(); 
    100      
     95 
    10196    return IsoStream::init(); 
    10297} 
     
    115110        return false; 
    116111    } 
    117      
     112 
    118113    resetXrunCounter(); 
    119114 
     
    130125    } 
    131126    return true; 
    132          
     127 
    133128} 
    134129 
     
    150145bool StreamProcessor::prepare() { 
    151146 
    152        debugOutput( DEBUG_LEVEL_VERBOSE, "Preparing...\n"); 
    153          
    154        // init the ports 
    155          
    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 them 
    168        PortManager::preparePorts(); 
    169  
    170        // reset the iso stream 
    171        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; 
    174169 
    175170} 
     
    192187    // FIXME: time_to_enable_at will be in 'time' not cycles 
    193188    m_cycle_to_enable_at=time_to_enable_at; 
    194      
     189 
    195190    if(!m_running) { 
    196191            debugWarning("The StreamProcessor is not running yet, enable() might not be a good idea.\n"); 
     
    200195    uint64_t now_cycles=CYCLE_TIMER_GET_CYCLES(m_handler->getCycleTimer()); 
    201196    const int64_t max=(int64_t)(CYCLES_PER_SECOND/2); 
    202      
     197 
    203198    int64_t diff=(int64_t)m_cycle_to_enable_at-(int64_t)now_cycles; 
    204      
     199 
    205200    if (diff > max) { 
    206201        diff-=TICKS_PER_SECOND; 
     
    208203        diff+=TICKS_PER_SECOND; 
    209204    } 
    210      
     205 
    211206    if (diff<0) { 
    212207        debugWarning("Request to enable streamprocessor %lld cycles ago (now=%llu, cy=%llu).\n", 
     
    231226int64_t StreamProcessor::getTimeUntilNextPeriodSignalUsecs() { 
    232227    uint64_t time_at_period=getTimeAtPeriod(); 
    233      
     228 
    234229    // we delay the period signal with the sync delay 
    235230    // this makes that the period signals lag a little compared to reality 
     
    243238 
    244239    uint64_t cycle_timer=m_handler->getCycleTimerTicks(); 
    245      
     240 
    246241    // calculate the time until the next period 
    247242    int32_t until_next=diffTicks(time_at_period,cycle_timer); 
    248      
     243 
    249244    debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "=> TAP=%11llu, CTR=%11llu, UTN=%11lld\n", 
    250245        time_at_period, cycle_timer, until_next 
    251246        ); 
    252      
     247 
    253248    // now convert to usecs 
    254249    // don't use the mapping function because it only works 
     
    267262 */ 
    268263void StreamProcessor::resetXrunCounter() { 
    269        ZERO_ATOMIC((SInt32 *)&m_xruns); 
     264    ZERO_ATOMIC((SInt32 *)&m_xruns); 
    270265} 
    271266 
    272267void 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 
     274ReceiveStreamProcessor::ReceiveStreamProcessor(int port, int framerate) 
     275    : StreamProcessor(IsoStream::EST_Receive, port, framerate) { 
    281276 
    282277} 
     
    287282 
    288283void ReceiveStreamProcessor::setVerboseLevel(int l) { 
    289        setDebugLevel(l); 
    290        StreamProcessor::setVerboseLevel(l); 
     284    setDebugLevel(l); 
     285    StreamProcessor::setVerboseLevel(l); 
    291286 
    292287} 
     
    294289uint64_t ReceiveStreamProcessor::getTimeAtPeriod() { 
    295290    uint64_t next_period_boundary=m_data_buffer->getTimestampFromHead(m_period); 
    296      
     291 
    297292    #ifdef DEBUG 
    298293    uint64_t ts,fc; 
    299294    m_data_buffer->getBufferTailTimestamp(&ts,&fc); 
    300      
     295 
    301296    debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "=> NPD=%11lld, LTS=%11llu, FC=%5u, TPF=%f\n", 
    302297        next_period_boundary, ts, fc, m_ticks_per_frame 
    303298        ); 
    304299    #endif 
    305      
     300 
    306301    return next_period_boundary; 
    307302} 
     
    311306} 
    312307 
    313 TransmitStreamProcessor::TransmitStreamProcessor( int port, int framerate)  
    314        : StreamProcessor(IsoStream::EST_Transmit, port, framerate) { 
     308TransmitStreamProcessor::TransmitStreamProcessor( int port, int framerate) 
     309    : StreamProcessor(IsoStream::EST_Transmit, port, framerate) { 
    315310 
    316311} 
     
    321316 
    322317void TransmitStreamProcessor::setVerboseLevel(int l) { 
    323        setDebugLevel(l); 
    324        StreamProcessor::setVerboseLevel(l); 
     318    setDebugLevel(l); 
     319    StreamProcessor::setVerboseLevel(l); 
    325320 
    326321} 
     
    332327    uint64_t ts,fc; 
    333328    m_data_buffer->getBufferTailTimestamp(&ts,&fc); 
    334      
     329 
    335330    debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "=> NPD=%11lld, LTS=%11llu, FC=%5u, TPF=%f\n", 
    336331        next_period_boundary, ts, fc, m_ticks_per_frame 
    337332        ); 
    338333    #endif 
    339      
     334 
    340335    return next_period_boundary; 
    341336} 
  • trunk/libffado/src/libstreaming/StreamProcessor.h

    r424 r445  
    1 /* $Id$ */ 
    2  
    31/* 
    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 
    2722 */ 
    28 #ifndef __FREEBOB_STREAMPROCESSOR__ 
    29 #define __FREEBOB_STREAMPROCESSOR__ 
     23 
     24#ifndef __FFADO_STREAMPROCESSOR__ 
     25#define __FFADO_STREAMPROCESSOR__ 
    3026 
    3127#include "../debugmodule/debugmodule.h" 
     
    4743\brief Class providing a generic interface for Stream Processors 
    4844 
    49  A stream processor multiplexes or demultiplexes an ISO stream into a  
     45 A stream processor multiplexes or demultiplexes an ISO stream into a 
    5046 collection of ports. This class should be subclassed, and the relevant 
    5147 functions should be overloaded. 
    52   
     48 
    5349*/ 
    54 class StreamProcessor : public IsoStream,  
    55                         public PortManager,  
     50class StreamProcessor : public IsoStream, 
     51                        public PortManager, 
    5652                        public Util::TimestampedBufferClient, 
    5753                        public Util::OptionContainer { 
     
    6864    virtual ~StreamProcessor(); 
    6965 
    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, 
    7369                        unsigned int cycle, unsigned int dropped) = 0; 
    74     virtual enum raw1394_iso_disposition  
     70    virtual enum raw1394_iso_disposition 
    7571            getPacket(unsigned char *data, unsigned int *length, 
    7672                    unsigned char *tag, unsigned char *sy, 
     
    8076 
    8177    bool xrunOccurred() { return (m_xruns>0);}; 
    82      
     78 
    8379    // move to private? 
    8480    void resetXrunCounter(); 
    8581 
    8682    bool isRunning(); ///< returns true if there is some stream data processed 
    87      
     83 
    8884    virtual bool prepareForEnable(uint64_t time_to_enable_at); 
    8985    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 
    9389    bool isEnabled() {return !m_is_disabled;}; 
    9490 
     
    116112    void setManager(StreamProcessorManager *manager) {m_manager=manager;}; 
    117113    void clearManager() {m_manager=0;}; 
    118      
     114 
    119115protected: 
    120116    unsigned int m_nb_buffers; ///< cached from manager->getNbBuffers(), the number of periods to buffer 
     
    126122 
    127123    StreamProcessorManager *m_manager; 
    128      
     124 
    129125    bool m_running; 
    130126    bool m_disabled; 
    131127    bool m_is_disabled; 
    132128    unsigned int m_cycle_to_enable_at; 
    133      
     129 
    134130    StreamStatistics m_PacketStat; 
    135131    StreamStatistics m_PeriodStat; 
    136      
     132 
    137133    StreamStatistics m_WakeupStat; 
    138      
     134 
    139135 
    140136    DECLARE_DEBUG_MODULE; 
    141      
     137 
    142138    // frame counter & sync stuff 
    143139    public: 
     
    145141         * @brief Can this StreamProcessor handle a transfer of nframes frames? 
    146142         * 
    147          * this function indicates if the streamprocessor can handle a transfer of  
     143         * this function indicates if the streamprocessor can handle a transfer of 
    148144         * nframes frames. It is used to detect underruns-to-be. 
    149145         * 
     
    153149         */ 
    154150        virtual bool canClientTransferFrames(unsigned int nframes) = 0; 
    155          
     151 
    156152        /** 
    157153         * \brief return the time until the next period boundary should be signaled (in microseconds) 
    158154         * 
    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 
    161157         * determine when a buffer transfer can be made. When this value is 
    162158         * smaller than 0, a period boundary is assumed to be crossed, hence a 
     
    180176 
    181177        /** 
    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) 
    183179         * 
    184180         * The same as getTimeUntilNextPeriodSignalUsecs() but in internal units. 
     
    189185 
    190186        uint64_t getTimeNow(); 
    191          
    192          
     187 
     188 
    193189        /** 
    194190         * Returns the sync delay. This is the time a syncsource 
     
    202198         */ 
    203199        void setSyncDelay(int d) {m_sync_delay=d;}; 
    204          
     200 
    205201        /** 
    206202         * Returns the minimal sync delay a SP needs 
     
    215211 
    216212        int getBufferFill(); 
    217          
     213 
    218214    protected: 
    219215        StreamProcessor *m_SyncSource; 
     
    233229 
    234230public: 
    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;}; 
    247243        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); 
    253249 
    254250    uint64_t getTimeAtPeriod(); 
     
    269265 
    270266public: 
    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;}; 
    281277        virtual bool getFrames(unsigned int nbframes) {return false;}; 
    282278 
    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); 
    288284 
    289285    uint64_t getTimeAtPeriod(); 
     
    300296} 
    301297 
    302 #endif /* __FREEBOB_STREAMPROCESSOR__ */ 
    303  
    304  
     298#endif /* __FFADO_STREAMPROCESSOR__ */ 
     299 
     300 
  • trunk/libffado/src/libstreaming/StreamProcessorManager.cpp

    r435 r445  
    1 /* $Id$ */ 
    2  
    31/* 
    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 
    2722 */ 
    2823 
     
    6055 
    6156StreamProcessorManager::~StreamProcessorManager() { 
    62        if (m_isoManager) delete m_isoManager; 
    63          
     57    if (m_isoManager) delete m_isoManager; 
     58 
    6459} 
    6560 
     
    7267 * and be sure that the processors are also ->init()'ed 
    7368 * 
    74  * @param processor  
     69 * @param processor 
    7570 * @return true if successfull 
    7671 */ 
    7772bool StreamProcessorManager::registerProcessor(StreamProcessor *processor) 
    7873{ 
    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 level 
    85                  
    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 level 
    95                  
    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; 
    106101} 
    107102 
    108103bool StreamProcessorManager::unregisterProcessor(StreamProcessor *processor) 
    109104{ 
    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 found 
     105    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 
    161156 
    162157} 
     
    175170bool StreamProcessorManager::init() 
    176171{ 
    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 level 
    187        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; 
    197192} 
    198193 
    199194bool StreamProcessorManager::prepare() { 
    200195 
    201        debugOutput( DEBUG_LEVEL_VERBOSE, "Preparing...\n"); 
    202          
     196    debugOutput( DEBUG_LEVEL_VERBOSE, "Preparing...\n"); 
     197 
    203198    m_is_slave=false; 
    204199    if(!getOption("snoopMode", m_is_slave)) { 
     
    219214            } 
    220215    } 
    221      
     216 
    222217    for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); 
    223218        it != m_TransmitProcessors.end(); 
     
    234229        it != m_ReceiveProcessors.end(); 
    235230        ++it ) { 
    236          
     231 
    237232        if(!(*it)->setSyncSource(m_SyncSource)) { 
    238233            debugFatal(  " could not set sync source (%p)...\n",(*it)); 
     
    267262    } 
    268263 
    269     // if there are no stream processors registered,  
     264    // if there are no stream processors registered, 
    270265    // fail 
    271266    if (m_ReceiveProcessors.size() + m_TransmitProcessors.size() == 0) { 
     
    274269    } 
    275270 
    276        return true; 
     271    return true; 
    277272} 
    278273 
     
    287282        wait_cycles--; 
    288283        notRunning=false; 
    289          
     284 
    290285        for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 
    291286                it != m_ReceiveProcessors.end(); 
     
    299294            if(!(*it)->isRunning()) notRunning=true; 
    300295        } 
    301          
     296 
    302297        // EXPERIMENT: 
    303298        // the only stream that should be running is the sync 
     
    305300        // when to signal buffers. Maybe we get an xrun at startup, 
    306301        // 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 
    310305        // will not start up (e.g. the bounce device), because 
    311306        // 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 
    314309        // to start up 
    315310//         if(!m_SyncSource->isRunning()) notRunning=true; 
    316          
     311 
    317312        usleep(1000); 
    318313        debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "Running check: %d\n",notRunning); 
     
    327322            if(!(*it)->isRunning()) { 
    328323                debugFatal(" receive stream %p not running\n",*it); 
    329             } else {    
     324            } else { 
    330325                debugFatal(" receive stream %p running\n",*it); 
    331326            } 
     
    337332            if(!(*it)->isRunning()) { 
    338333                debugFatal(" transmit stream %p not running\n",*it); 
    339             } else {    
     334            } else { 
    340335                debugFatal(" transmit stream %p running\n",*it); 
    341336            } 
     
    344339    } 
    345340 
    346     // we want to make sure that everything is running well,  
     341    // we want to make sure that everything is running well, 
    347342    // so wait for a while 
    348343    usleep(USECS_PER_CYCLE * CYCLES_TO_SLEEP_AFTER_RUN_SIGNAL); 
    349344 
    350345    debugOutput( DEBUG_LEVEL_VERBOSE, " StreamProcessor streams running...\n"); 
    351      
     346 
    352347    debugOutput( DEBUG_LEVEL_VERBOSE, "Finding minimal sync delay...\n"); 
    353348 
     
    360355        if(min_delay>max_of_min_delay) max_of_min_delay=min_delay; 
    361356    } 
    362      
     357 
    363358    for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); 
    364359            it != m_TransmitProcessors.end(); 
     
    367362        if(min_delay>max_of_min_delay) max_of_min_delay=min_delay; 
    368363    } 
    369      
     364 
    370365    debugOutput( DEBUG_LEVEL_VERBOSE, "  %d ticks\n", max_of_min_delay); 
    371366    m_SyncSource->setSyncDelay(max_of_min_delay); 
    372      
    373      
     367 
     368 
    374369    debugOutput( DEBUG_LEVEL_VERBOSE, "Resetting StreamProcessors...\n"); 
    375370    // now we reset the frame counters 
     
    379374        (*it)->reset(); 
    380375    } 
    381      
     376 
    382377    for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); 
    383378            it != m_TransmitProcessors.end(); 
     
    385380        (*it)->reset(); 
    386381    } 
    387          
     382 
    388383    debugOutput( DEBUG_LEVEL_VERBOSE, "Enabling StreamProcessors...\n"); 
    389      
     384 
    390385    uint64_t now=m_SyncSource->getTimeNow(); // fixme: should be in usecs, not ticks 
    391      
     386 
    392387    // FIXME: this should not be in cycles, but in 'time' 
    393388    unsigned int enable_at=TICKS_TO_CYCLES(now)+ENABLE_DELAY_CYCLES; 
     
    403398 
    404399bool 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"); 
    444439        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 synchonized 
    456        if (!syncStartAll()) { 
    457                debugFatal("Could not syncStartAll...\n"); 
    458                return false; 
    459        
    460          
    461        // dump the iso stream information when in verbose mode 
    462        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 
    468463} 
    469464 
    470465bool 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, some 
    476        // (like the MOTU) need to do a few things before it's safe to turn off the iso 
    477        // handling. 
    478        int wait_cycles=PREPARE_TIMEOUT_MSEC; // two seconds ought to be sufficient 
    479        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"); 
    506501    // 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 
    531526} 
    532527 
     
    547542    debugOutput( DEBUG_LEVEL_VERBOSE, "  Enable...\n"); 
    548543    m_SyncSource->enable(time_to_enable_at); 
    549      
     544 
    550545    debugOutput( DEBUG_LEVEL_VERBOSE, " Other StreamProcessors...\n"); 
    551      
     546 
    552547    // we prepare the streamprocessors for enable 
    553548    for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 
     
    572567    for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 
    573568            it != m_ReceiveProcessors.end(); 
    574             ++it ) {            
     569            ++it ) { 
    575570        if(*it != m_SyncSource) { 
    576571            debugOutput( DEBUG_LEVEL_VERBOSE, " Enable Receive SP (%p)...\n",*it); 
     
    597592        wait_cycles--; 
    598593        notEnabled=false; 
    599          
     594 
    600595        for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 
    601596                it != m_ReceiveProcessors.end(); 
     
    611606        usleep(1000); // one cycle 
    612607    } 
    613      
     608 
    614609    if(!wait_cycles) { // timout has occurred 
    615610        debugFatal("One or more streams couldn't be enabled (timeout):\n"); 
    616                      
     611 
    617612        for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 
    618613                it != m_ReceiveProcessors.end(); 
     
    620615            if(!(*it)->isEnabled()) { 
    621616                    debugFatal(" receive stream %p not enabled\n",*it); 
    622             } else {    
     617            } else { 
    623618                    debugFatal(" receive stream %p enabled\n",*it); 
    624619            } 
    625620        } 
    626      
     621 
    627622        for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); 
    628623                it != m_TransmitProcessors.end(); 
     
    630625            if(!(*it)->isEnabled()) { 
    631626                    debugFatal(" transmit stream %p not enabled\n",*it); 
    632             } else {    
     627            } else { 
    633628                    debugFatal(" transmit stream %p enabled\n",*it); 
    634629            } 
     
    636631        return false; 
    637632    } 
    638      
     633 
    639634    debugOutput( DEBUG_LEVEL_VERBOSE, " => all StreamProcessors enabled...\n"); 
    640635 
     
    682677        wait_cycles--; 
    683678        enabled=false; 
    684          
     679 
    685680        for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 
    686681                it != m_ReceiveProcessors.end(); 
     
    696691        usleep(1000); // one cycle 
    697692    } 
    698      
     693 
    699694    if(!wait_cycles) { // timout has occurred 
    700695        debugFatal("One or more streams couldn't be disabled (timeout):\n"); 
    701                      
     696 
    702697        for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 
    703698                it != m_ReceiveProcessors.end(); 
     
    705700            if(!(*it)->isEnabled()) { 
    706701                    debugFatal(" receive stream %p not enabled\n",*it); 
    707             } else {    
     702            } else { 
    708703                    debugFatal(" receive stream %p enabled\n",*it); 
    709704            } 
    710705        } 
    711      
     706 
    712707        for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); 
    713708                it != m_TransmitProcessors.end(); 
     
    715710            if(!(*it)->isEnabled()) { 
    716711                    debugFatal(" transmit stream %p not enabled\n",*it); 
    717             } else {    
     712            } else { 
    718713                    debugFatal(" transmit stream %p enabled\n",*it); 
    719714            } 
     
    721716        return false; 
    722717    } 
    723      
     718 
    724719    debugOutput( DEBUG_LEVEL_VERBOSE, " => all StreamProcessors disabled...\n"); 
    725          
     720 
    726721    return true; 
    727722} 
     
    736731bool StreamProcessorManager::handleXrun() { 
    737732 
    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 packets 
    743         *    note: the isomanager does keep on delivering/requesting them 
    744         * 2) Bringing all buffers & streamprocessors into a know state 
    745         *    - Clear all capture buffers 
    746         *    - Put nb_periods*period_size of null frames into the playback buffers 
    747         * 3) Re-enable the SP's 
    748         */ 
    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"); 
    750745        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 synchonized 
    757        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; 
    765760} 
    766761 
     
    769764 * 
    770765 * 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. 
    772767 * 
    773768 * @return true if the period is ready, false if an xrun occurred 
     
    776771    int time_till_next_period; 
    777772    bool xrun_occurred=false; 
    778         
     773 
    779774    debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "enter...\n"); 
    780775 
    781776    assert(m_SyncSource); 
    782      
     777 
    783778    time_till_next_period=m_SyncSource->getTimeUntilNextPeriodSignalUsecs(); 
    784      
     779 
    785780    while(time_till_next_period > 0) { 
    786781        debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "waiting for %d usecs...\n", time_till_next_period); 
    787      
     782 
    788783        // wait for the period 
    789784        usleep(time_till_next_period); 
    790          
     785 
    791786        // check for underruns on the ISO side, 
    792787        // those should make us bail out of the wait loop 
     
    807802        time_till_next_period=m_SyncSource->getTimeUntilNextPeriodSignalUsecs(); 
    808803    } 
    809      
     804 
    810805    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 
    814809    m_delayed_usecs=time_till_next_period; 
    815      
     810 
    816811    // 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 
    818813    // cycles making that we modify a receiving stream's buffer 
    819814    // before we get to writing. 
     
    821816    //       and the receive processors should have done their transfer. 
    822817    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", 
    824819        m_time_of_transfer); 
    825      
     820 
    826821#ifdef DEBUG 
    827822    int rcv_bf=0, xmt_bf=0; 
     
    836831        xmt_bf = (*it)->getBufferFill(); 
    837832    } 
    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", 
    839834        m_time_of_transfer,rcv_bf,xmt_bf,rcv_bf+xmt_bf); 
    840      
     835 
    841836#endif 
    842837 
    843838    xrun_occurred=false; 
    844      
     839 
    845840    // check if xruns occurred on the Iso side. 
    846841    // also check if xruns will occur should we transfer() now 
    847      
     842 
    848843    for ( StreamProcessorVectorIterator it = m_ReceiveProcessors.begin(); 
    849844          it != m_ReceiveProcessors.end(); 
     
    851846        // a xrun has occurred on the Iso side 
    852847        xrun_occurred |= (*it)->xrunOccurred(); 
    853          
     848 
    854849        // if this is true, a xrun will occur 
    855850        xrun_occurred |= !((*it)->canClientTransferFrames(m_period)); 
    856          
     851 
    857852#ifdef DEBUG 
    858853        if ((*it)->xrunOccurred()) { 
     
    865860        } 
    866861#endif 
    867          
     862 
    868863    } 
    869864    for ( StreamProcessorVectorIterator it = m_TransmitProcessors.begin(); 
     
    872867        // a xrun has occurred on the Iso side 
    873868        xrun_occurred |= (*it)->xrunOccurred(); 
    874          
     869 
    875870        // if this is true, a xrun will occur 
    876871        xrun_occurred |= !((*it)->canClientTransferFrames(m_period)); 
    877          
     872 
    878873#ifdef DEBUG 
    879874        if ((*it)->xrunOccurred()) { 
     
    883878            debugWarning("Xrun on XMIT SP %p due to buffer xrun\n",*it); 
    884879        } 
    885 #endif         
    886     } 
    887      
     880#endif 
     881    } 
     882 
    888883    m_nbperiods++; 
    889      
     884 
    890885    // now we can signal the client that we are (should be) ready 
    891886    return !xrun_occurred; 
     
    900895 */ 
    901896bool StreamProcessorManager::transfer() { 
    902      
     897 
    903898    debugOutput( DEBUG_LEVEL_VERBOSE, "Transferring period...\n"); 
    904899 
     
    920915bool StreamProcessorManager::transfer(enum StreamProcessor::EProcessorType t) { 
    921916    debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "Transferring period...\n"); 
    922      
     917 
    923918    // a static cast could make sure that there is no performance 
    924919    // penalty for the virtual functions (to be checked) 
     
    927922                it != m_ReceiveProcessors.end(); 
    928923                ++it ) { 
    929                  
     924 
    930925            if(!(*it)->getFrames(m_period)) { 
    931926                    debugOutput(DEBUG_LEVEL_VERBOSE,"could not getFrames(%u, %11llu) from stream processor (%p)", 
     
    939934                it != m_TransmitProcessors.end(); 
    940935                ++it ) { 
    941                  
     936 
    942937            if(!(*it)->putFrames(m_period, (int64_t)m_time_of_transfer)) { 
    943938                debugOutput(DEBUG_LEVEL_VERBOSE, "could not putFrames(%u,%llu) to stream processor (%p)", 
     
    953948 
    954949void 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"); 
    976971 
    977972} 
    978973 
    979974void 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   
    997992} 
    998993 
    999994 
    1000995int 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; 
    10171012} 
    10181013 
    10191014int 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; 
    10361031} 
    10371032 
     
    10391034 
    10401035Port* 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; 
    10661061} 
    10671062 
  • 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 */ 
    223 
    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__ 
    3026 
    3127#include "debugmodule/debugmodule.h" 
     
    4945/*! 
    5046\brief Manages a collection of StreamProcessors and provides a synchronisation interface 
    51   
     47 
    5248*/ 
    5349class StreamProcessorManager : public Util::OptionContainer { 
    5450    friend class StreamProcessor; 
    55      
     51 
    5652public: 
    5753 
     
    6460    bool start(); 
    6561    bool stop(); 
    66      
     62 
    6763    bool syncStartAll(); 
    6864 
     
    9187    bool transfer(); ///< transfer the buffer contents from/to client 
    9288    bool transfer(enum StreamProcessor::EProcessorType); ///< transfer the buffer contents from/to client (single processor type) 
    93      
     89 
    9490    int getDelayedUsecs() {return m_delayed_usecs;}; 
    9591    bool xrunOccurred(); 
    9692    int getXrunCount() {return m_xruns;}; 
    97      
     93 
    9894private: 
    9995    int m_delayed_usecs; 
     
    10298    // for the transmit SP's 
    10399    uint64_t m_time_of_transfer; 
    104      
     100 
    105101public: 
    106102    bool handleXrun(); ///< reset the streams & buffers after xrun 
     
    113109private: // slaving support 
    114110    bool m_is_slave; 
    115      
     111 
    116112    // the sync source stuff 
    117113private: 
    118114    StreamProcessor *m_SyncSource; 
    119      
     115 
    120116public: 
    121117    bool setSyncSource(StreamProcessor *s); 
     
    125121 
    126122    // thread sync primitives 
    127     bool m_xrun_happened;  
     123    bool m_xrun_happened; 
    128124 
    129125    bool m_thread_realtime; 
     
    137133    unsigned int m_period; 
    138134    unsigned int m_xruns; 
    139      
     135 
    140136    IsoHandlerManager *m_isoManager; 
    141137 
     
    148144} 
    149145 
    150 #endif /* __FREEBOB_STREAMPROCESSORMANAGER__ */ 
     146#endif /* __FFADO_STREAMPROCESSORMANAGER__ */ 
    151147 
    152148 
  • trunk/libffado/src/libutil/Atomic.h

    r254 r445  
    11/* 
    2 Modifications for Freebob (C) 2006 Pieter Palmers 
     2Modifications for FFADO by Pieter Palmers 
    33 
    44Copied from the jackd/jackdmp sources 
     
    66a jackd backend. 
    77 
    8 Copyright (C) 2004-2006 Grame   
     8Copyright (C) 2004-2006 Grame 
    99 
    1010This program is free software; you can redistribute it and/or modify 
     
    2424*/ 
    2525 
    26 #ifndef __FreebobAtomic__ 
    27 #define __FreebobAtomic__ 
     26#ifndef __FFADOATOMIC__ 
     27#define __FFADOATOMIC__ 
    2828 
    2929typedef unsigned short UInt16; 
     
    4040    register int result; 
    4141    asm volatile ( 
    42         "# 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 
     42        "# 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 
    4848        //  stores the new value at addr 
    49         "      bne-    1f          \n" 
     49        "    bne-    1f          \n" 
    5050        "   li      %0, 1       \n" 
    51         "      b               2f          \n" 
     51        "    b        2f          \n" 
    5252        "1:                     \n" 
    5353        "   li      %0, 0       \n" 
    5454        "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        ); 
    5959    return result; 
    6060} 
     
    6262#endif 
    6363 
    64 #if defined(__i386__) || defined(__x86_64__)  
     64#if defined(__i386__) || defined(__x86_64__) 
    6565 
    6666#ifdef __SMP__ 
    67 #      define LOCK "lock ; " 
     67#    define LOCK "lock ; " 
    6868#else 
    69 #      define LOCK "" 
     69#    define LOCK "" 
    7070#endif 
    7171 
     
    7777        LOCK "cmpxchg %2, (%1) \n\t" 
    7878        "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        ); 
    8282    return ret; 
    8383} 
     
    9696    register UInt32 tmp; 
    9797    asm volatile ( 
    98         "# 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 
     98        "# 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 
    104104        //  stores the new value at addr 
    105         "      bne-    1f          \n" 
     105        "    bne-    1f          \n" 
    106106        "   li      %0, 1       \n" 
    107         "      b               2f          \n" 
     107        "    b        2f          \n" 
    108108        "1:                     \n" 
    109109        "   li      %0, 0       \n" 
    110110        "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        ); 
    114114    return result; 
    115115} 
     
    117117#endif 
    118118 
    119 #if defined(__i386__) || defined(__x86_64__)  
     119#if defined(__i386__) || defined(__x86_64__) 
    120120 
    121121#ifdef __SMP__ 
    122 #      define LOCK "lock ; " 
     122#    define LOCK "lock ; " 
    123123#else 
    124 #      define LOCK "" 
     124#    define LOCK "" 
    125125#endif 
    126126 
     
    132132        LOCK "cmpxchg %2, (%1) \n\t" 
    133133        "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        ); 
    137137    return ret; 
    138138} 
     
    187187} 
    188188 
     189#endif // __FFADO_ATOMIC__ 
    189190 
    190 #endif 
    191  
  • trunk/libffado/src/libutil/cycles.h

    r384 r445  
    11/* cycles.h 
    22 
    3 FreeBob Streaming API 
    4 FreeBob = Firewire (pro-)audio for linux 
     3FFADO Streaming API 
     4FFADO = Firewire (pro-)audio for linux 
    55 
    6 http://freebob.sf.net 
     6http://ffado.sf.net 
    77 
    88Based upon cycles.h from the jackdmp package. 
     
    1111  Copyright (C) 2001 Paul Davis 
    1212  Code derived from various headers from the Linux kernel 
    13    
     13 
    1414This program is free software; you can redistribute it and/or modify 
    1515it under the terms of the GNU General Public License as published by 
     
    2828*/ 
    2929 
    30 #ifndef __freebob_cycles_h__ 
    31 #define __freebob_cycles_h__ 
     30#ifndef __FFADO_CYCLES_H__ 
     31#define __FFADO_CYCLES_H__ 
    3232 
    3333/* 
     
    4343 * that we reschedule before that wraps. Scheduling at least every 
    4444 * 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. 
    4646 */ 
    4747 
     
    5252/* PowerPC */ 
    5353 
    54 #define CPU_FTR_601                    0x00000100 
     54#define CPU_FTR_601            0x00000100 
    5555 
    5656typedef unsigned long cycles_t; 
     
    6565 
    6666    __asm__ __volatile__( 
    67         "98:   mftb %0\n" 
     67        "98:    mftb %0\n" 
    6868        "99:\n" 
    6969        ".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" 
    7474        ".previous" 
    7575    : "=r" (ret) : "i" (CPU_FTR_601)); 
     
    100100#endif 
    101101 
    102 #endif /* __freebob_cycles_h__ */ 
     102#endif // __FFADO_CYCLES_H__ 
  • trunk/libffado/src/libutil/DelayLockedLoop.cpp

    r419 r445  
    1 /* $Id$ */ 
    2  
    31/* 
    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 
    2722 */ 
    2823 
     
    4136 * @param coeffs coefficients to use 
    4237 */ 
    43 DelayLockedLoop::DelayLockedLoop(unsigned int order, float *coeffs)  
     38DelayLockedLoop::DelayLockedLoop(unsigned int order, float *coeffs) 
    4439{ 
    4540    unsigned int i; 
    46      
     41 
    4742    m_order=order; 
    4843    if (m_order==0) m_order=1; 
    49      
     44 
    5045    m_coeffs=new float[order]; 
    5146    m_nodes=new float[order]; 
    52      
     47 
    5348    for (i=0;i<order;i++) { 
    5449        m_coeffs[i]=coeffs[i]; 
     
    6863{ 
    6964    unsigned int i; 
    70      
     65 
    7166    m_order=order; 
    7267    if (m_order==0) m_order=1; 
    73      
     68 
    7469    m_coeffs=new float[order]; 
    7570    m_nodes=new float[order]; 
    76      
     71 
    7772    for (i=0;i<order;i++) { 
    7873        m_coeffs[i]=0.0; 
     
    8883DelayLockedLoop::DelayLockedLoop() { 
    8984    m_order=1; 
    90      
     85 
    9186    m_coeffs=new float[1]; 
    9287    m_coeffs[0]=0.0; 
    93      
     88 
    9489    m_nodes=new float[1]; 
    9590    m_nodes[0]=0.0; 
     
    9994    if(m_coeffs) delete[] m_coeffs; 
    10095    if(m_nodes) delete[] m_nodes; 
    101      
    102 } 
    103      
     96 
     97} 
     98 
    10499/** 
    105100 * Returns the coefficient with index i 
     
    110105 * @return value of the coefficient 
    111106 */ 
    112 float  
     107float 
    113108DelayLockedLoop::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]; 
    118112    } else { 
    119113        return 0.0; 
     
    124118 * 
    125119 * i should be smaller than the DLL order 
    126  *  
     120 * 
    127121 * @param i index of the coefficient 
    128122 * @param c value of the coefficient 
     
    130124void 
    131125DelayLockedLoop::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; 
    136129    } 
    137130} 
     
    142135 * 
    143136 * i should be smaller than the DLL order 
    144  *  
     137 * 
    145138 * 
    146139 * @param i index of the integrator 
     
    149142void 
    150143DelayLockedLoop::setIntegrator(unsigned int i, float c) { 
    151      
     144 
    152145    if (i<m_order) { 
    153146        m_nodes[i]=c; 
     
    156149 
    157150/** 
    158  * Clears the internal state of the DLL,  
     151 * Clears the internal state of the DLL, 
    159152 * meaning that it will set all internal nodes to 0.0 
    160153 */ 
    161 void  
     154void 
    162155DelayLockedLoop::reset() { 
    163      
     156 
    164157    unsigned int i; 
    165158    for (i=0;i<m_order;i++) { 
    166159        m_nodes[i]=0.0; 
    167160    } 
    168      
     161 
    169162} 
    170163 
     
    173166 * @return DLL order 
    174167 */ 
    175 unsigned int  
     168unsigned int 
    176169DelayLockedLoop::getOrder() { 
    177170    return m_order; 
     
    190183 * @param coeffs coefficients to use 
    191184 */ 
    192 void  
     185void 
    193186DelayLockedLoop::setOrder(unsigned int order, float* coeffs) { 
    194187    unsigned int i; 
    195      
     188 
    196189    reset(); 
    197      
     190 
    198191    m_order=order; 
    199192    if (m_order==0) m_order=1; 
    200      
     193 
    201194    if(m_coeffs) delete[] m_coeffs; 
    202195    m_coeffs=new float[order]; 
    203      
     196 
    204197    if(m_nodes) delete[] m_nodes; 
    205198    m_nodes=new float[order]; 
    206      
     199 
    207200    for (i=0;i<order;i++) { 
    208201        m_coeffs[i]=coeffs[i]; 
     
    221214 * @param order new order for the DLL 
    222215 */ 
    223 void  
     216void 
    224217DelayLockedLoop::setOrder(unsigned int order) { 
    225218    unsigned int i; 
    226      
     219 
    227220    reset(); 
    228      
     221 
    229222    m_order=order; 
    230      
     223 
    231224    if (m_order==0) m_order=1; 
    232      
     225 
    233226    if(m_coeffs) delete[] m_coeffs; 
    234227    m_coeffs=new float[order]; 
    235      
     228 
    236229    if(m_nodes) delete[] m_nodes; 
    237230    m_nodes=new float[order]; 
    238      
     231 
    239232    for (i=0;i<order;i++) { 
    240233        m_coeffs[i]=0.0; 
     
    243236 
    244237} 
    245      
     238 
    246239/** 
    247240 * Put a new value in the loop, updating all internal nodes and 
     
    250243 * @param v new value 
    251244 */ 
    252 void  
     245void 
    253246DelayLockedLoop::put(float v) { 
    254247 
     
    256249    // to make use of pipeline-ing and out of order execution 
    257250    // except for very high order loops, then we do it looped 
    258      
     251 
    259252    // error = newval - output 
    260253    m_error=v-m_nodes[0]; 
     
    262255    // update the output value 
    263256    m_nodes[0]+=m_error*m_coeffs[0]; 
    264      
     257 
    265258    if(m_order==1) return; // we are done 
    266      
     259 
    267260    // add the output of the second integrator 
    268261    m_nodes[0]+=m_nodes[1]; 
    269      
     262 
    270263    // update the second integrator 
    271264    m_nodes[1]+=m_error*m_coeffs[1]; 
    272      
     265 
    273266    if(m_order==2) return; // we are done 
    274      
     267 
    275268    // if the order is even higher, we are using a loop 
    276269    unsigned int i; 
     
    278271        // add the i-th integrator value 
    279272        m_nodes[i-1] += m_nodes[i]; 
    280          
     273 
    281274        // update the i-th integrator 
    282275        m_nodes[i] = m_coeffs[i] * m_error; 
    283276    } 
    284      
     277 
    285278    return; 
    286279} 
    287280 
    288281/** 
    289  * Get the output value of the DLL  
     282 * Get the output value of the DLL 
    290283 * 
    291284 * @return current output value 
    292285 */ 
    293 float  
     286float 
    294287DelayLockedLoop::get() { 
    295288    return m_nodes[0]; 
     
    301294 * @return current error signal value 
    302295 */ 
    303 float  
     296float 
    304297DelayLockedLoop::getError() { 
    305298    return m_error; 
    306299} 
    307300 
    308 } // end of namespace FreeBobUtil 
     301} // 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 */ 
    223 
    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__ 
    3026 
    3127namespace Util { 
     
    3531public: 
    3632 
    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 
    4339    float getCoefficient(unsigned int i); 
    4440    void setCoefficient(unsigned int i, float c); 
    45      
     41 
    4642    void setIntegrator(unsigned int i, float c); 
    47      
     43 
    4844    void reset(); 
    49      
     45 
    5046    unsigned int getOrder(); 
    5147    void setOrder(unsigned int i); 
    5248    void setOrder(unsigned int order, float* coeffs); 
    53      
     49 
    5450    void put(float v); 
    5551    float get(); 
    5652    float getError(); 
    57      
     53 
    5854protected: 
    5955 
     
    6561}; 
    6662 
    67 } // end of namespace FreeBobUtil 
     63} // end of namespace FFADOUtil 
    6864 
    69 #endif /* __FREEBOB_DELAYLOCKEDLOOP__ */ 
     65#endif /* __FFADO_DELAYLOCKEDLOOP__ */ 
    7066 
    7167 
  • trunk/libffado/src/libutil/OptionContainer.cpp

    r419 r445  
    1 /* $Id$ */ 
    2  
    31/* 
    4  *   FreeBob Streaming API 
    5  *   FreeBob = Firewire (pro-)audio for linux 
     2 * Copyright (C) 2005-2007 by Pieter Palmers 
    63 * 
    7  *   http://freebob.sf.net 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    86 * 
    9  *   Copyright (C) 2007 Pieter Palmers <pieterpalmers@users.sourceforge.net> 
     7 * FFADO is based upon FreeBoB. 
    108 * 
    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; 
    1512 * 
    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. 
     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. 
    2017 * 
    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 
    2722 */ 
    2823 
     
    3631IMPL_DEBUG_MODULE( OptionContainer, OptionContainer, DEBUG_LEVEL_NORMAL ); 
    3732 
    38 OptionContainer::Option::Option()  
     33OptionContainer::Option::Option() 
    3934    : m_Name(""), 
    4035    m_stringValue(""), 
     
    4641{} 
    4742 
    48 OptionContainer::Option::Option(std::string n)  
     43OptionContainer::Option::Option(std::string n) 
    4944    : m_Name(n), 
    5045    m_stringValue(""), 
     
    5651{} 
    5752 
    58 OptionContainer::Option::Option(std::string n, std::string v)  
     53OptionContainer::Option::Option(std::string n, std::string v) 
    5954    : m_Name(n), 
    6055    m_stringValue(v), 
     
    6661{} 
    6762 
    68 OptionContainer::Option::Option(std::string n, bool v)  
     63OptionContainer::Option::Option(std::string n, bool v) 
    6964    : m_Name(n), 
    7065    m_stringValue(""), 
     
    7671{} 
    7772 
    78 OptionContainer::Option::Option(std::string n, double v)  
     73OptionContainer::Option::Option(std::string n, double v) 
    7974    : m_Name(n), 
    8075    m_stringValue(""), 
     
    8681{} 
    8782 
    88 OptionContainer::Option::Option(std::string n, int64_t v)  
     83OptionContainer::Option::Option(std::string n, int64_t v) 
    8984    : m_Name(n), 
    9085    m_stringValue(""), 
     
    9691{} 
    9792 
    98 OptionContainer::Option::Option(std::string n, uint64_t v)  
     93OptionContainer::Option::Option(std::string n, uint64_t v) 
    9994    : m_Name(n), 
    10095    m_stringValue(""), 
     
    135130    Option op=Option(); 
    136131    Glib::ustring tmpstr; 
    137      
     132 
    138133    result  = deser.read( basePath + "m_Name", tmpstr ); 
    139134    op.m_Name = tmpstr; 
     
    341336        return false; 
    342337    } 
    343      
     338 
    344339    m_Options.push_back(o); 
    345      
     340 
    346341    return true; 
    347342} 
     
    449444        std::ostringstream strstrm; 
    450445        strstrm << basePath << "/" << "Option" << i; 
    451          
     446 
    452447        Option pOption = Option::deserialize( strstrm.str() + "/", 
    453448                                              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 */ 
    223 
    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__ 
    2826 
    2927#include "../debugmodule/debugmodule.h" 
     
    4846            EUInt = 5, 
    4947        }; 
    50      
     48 
    5149    public: 
    5250        Option(); 
     
    5755        Option(std::string, int64_t); 
    5856        Option(std::string, uint64_t); 
    59          
     57 
    6058        ~Option() {}; 
    61      
     59 
    6260        std::string getName() {return m_Name;}; 
    6361        enum EType getType() {return m_Type;}; 
    64      
     62 
    6563        void set(std::string v); 
    6664        void set(bool v); 
     
    6866        void set(int64_t v); 
    6967        void set(uint64_t v); 
    70      
     68 
    7169        std::string getString() {return m_stringValue;}; 
    7270        bool getBool() {return m_boolValue;}; 
     
    7472        int64_t getInt() {return m_intValue;}; 
    7573        uint64_t getUInt() {return m_uintValue;}; 
    76      
     74 
    7775    public: // serialization support 
    7876        bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; 
     
    8179    private: 
    8280        std::string m_Name; 
    83          
     81 
    8482        std::string m_stringValue; 
    85          
     83 
    8684        bool        m_boolValue; 
    8785        double      m_doubleValue; 
    8886        int64_t     m_intValue; 
    8987        uint64_t    m_uintValue; 
    90          
     88 
    9189        enum EType  m_Type; 
    9290    }; 
     
    9694    OptionContainer(); 
    9795    virtual ~OptionContainer(); 
    98      
     96 
    9997    bool setOption(std::string name, std::string v); 
    10098    bool setOption(std::string name, bool v); 
     
    108106    bool setOption(std::string name, int8_t v); 
    109107    bool setOption(std::string name, uint8_t v); 
    110      
     108 
    111109    bool getOption(std::string name, std::string &v); 
    112110    bool getOption(std::string name, bool &v); 
     
    121119    bool getOption(std::string name, int8_t &v); 
    122120    bool getOption(std::string name, uint8_t &v); 
    123      
     121 
    124122    Option::EType getOptionType(std::string name); 
    125      
     123 
    126124    bool hasOption(std::string name); 
    127      
     125 
    128126    int countOptions() {return m_Options.size();}; 
    129127 
     
    131129    bool setOption(Option o); 
    132130    Option getOption(std::string name); 
    133      
     131 
    134132    bool hasOption(Option o); 
    135      
     133 
    136134    bool addOption(Option o); 
    137      
     135 
    138136    bool removeOption(Option o); 
    139137    bool removeOption(std::string name); 
    140      
     138 
    141139    void clearOptions() {m_Options.clear();}; 
    142      
     140 
    143141public: // provide an iterator interface 
    144142 
     
    148146        return(m_Options.begin()); 
    149147    } 
    150          
     148 
    151149    iterator end() 
    152150    { 
     
    155153 
    156154protected: // serialization support 
    157     bool serializeOptions( Glib::ustring basePath,  
     155    bool serializeOptions( Glib::ustring basePath, 
    158156                           Util::IOSerialize& ser) const; 
    159157    static bool deserializeOptions( Glib::ustring basePath, 
     
    164162    int findOption(Option o); 
    165163    int findOption(std::string name); 
    166      
     164 
    167165    typedef std::vector< Option > OptionVector; 
    168166    typedef std::vector< Option >::iterator OptionVectorIterator; 
    169167    OptionVector m_Options; 
    170      
     168 
    171169protected: 
    172170    DECLARE_DEBUG_MODULE; 
     
    176174} // end of namespace Util 
    177175 
    178 #endif /* __FREEBOB_OPTIONCONTAINER__ */ 
     176#endif /* __FFADO_OPTIONCONTAINER__ */ 
    179177 
    180178 
  • trunk/libffado/src/libutil/PacketBuffer.cpp

    r419 r445  
    1 /* $Id$ */ 
    2  
    31/* 
    4  *   FreeBob Streaming API 
    5  *   FreeBob = Firewire (pro-)audio for linux 
     2 * Copyright (C) 2005-2007 by Pieter Palmers 
    63 * 
    7  *   http://freebob.sf.net 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    86 * 
    9  *   Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> 
     7 * FFADO is based upon FreeBoB. 
    108 * 
    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; 
    1512 * 
    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. 
     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. 
    2017 * 
    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 
    2722 */ 
    2823 
     
    3732 
    3833PacketBuffer::~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); 
    4237} 
    4338 
    4439int PacketBuffer::initialize() { 
    45        debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 
     40    debugOutput( DEBUG_LEVEL_VERBOSE, "enter...\n"); 
    4641 
    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); 
    5045 
    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   
    5651 
    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   
    6257 
    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"); 
    6964 
    70        return 0; 
     65    return 0; 
    7166} 
    7267 
    7368void 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   
    8378} 
    8479 
    8580int PacketBuffer::addPacket(quadlet_t *packet, int packet_len) { 
    8681 
    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); 
    8984 
    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); 
    9388 
    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)) { 
    9691 
    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); 
    10095 
    101        } else return -1; 
    102        return 0; 
     96    } else return -1; 
     97    return 0; 
    10398 
    10499} 
     
    106101int PacketBuffer::getNextPacket(quadlet_t *packet, int max_packet_len) { 
    107102 
    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; 
    110105 
    111        debugOutput( DEBUG_LEVEL_VERY_VERBOSE, 
    112                     "getNextPacket\n"); 
     106    debugOutput( DEBUG_LEVEL_VERY_VERBOSE, 
     107                 "getNextPacket\n"); 
    113108 
    114        if(max_packet_len<m_headersize) return -2; 
     109    if(max_packet_len<m_headersize) return -2; 
    115110 
    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   
    119114 
    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   
    123118 
    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; 
    125120 
    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   
    129124 
    130        return bytes/sizeof(quadlet_t)+m_headersize; 
     125    return bytes/sizeof(quadlet_t)+m_headersize; 
    131126} 
    132127 
    133128int PacketBuffer::getBufferFillPackets() { 
    134129 
    135        return freebob_ringbuffer_read_space(len_buffer)/sizeof(unsigned int); 
     130    return ffado_ringbuffer_read_space(len_buffer)/sizeof(unsigned int); 
    136131} 
    137132 
     
    139134int PacketBuffer::getBufferFillPayload() { 
    140135 
    141        return freebob_ringbuffer_read_space(payload_buffer)/sizeof(quadlet_t); 
     136    return ffado_ringbuffer_read_space(payload_buffer)/sizeof(quadlet_t); 
    142137} 
    143138 
  • 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 */ 
    223 
    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__ 
    3026 
    3127#include "../debugmodule/debugmodule.h" 
     
    3935public: 
    4036 
    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    {}; 
    4541 
    46        virtual ~PacketBuffer(); 
    47        void setVerboseLevel(int l) { setDebugLevel( l ); }; 
     42    virtual ~PacketBuffer(); 
     43    void setVerboseLevel(int l) { setDebugLevel( l ); }; 
    4844 
    49        int initialize(); 
     45    int initialize(); 
    5046 
    51        void flush(); 
     47    void flush(); 
    5248 
    53        int addPacket(quadlet_t *packet, int packet_len); 
     49    int addPacket(quadlet_t *packet, int packet_len); 
    5450 
    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(); 
    5854 
    5955protected: 
    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; 
    6359 
    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 
    6864    DECLARE_DEBUG_MODULE; 
    6965 
     
    7268} 
    7369 
    74 #endif /* __FREEBOB_PACKETBUFFER__ */ 
     70#endif /* __FFADO_PACKETBUFFER__ */ 
    7571 
    7672 
  • trunk/libffado/src/libutil/PosixThread.cpp

    r419 r445  
    11/* 
    2 Modifications for Freebob (C) 2006, Pieter Palmers 
     2Modifications for FFADO by Pieter Palmers 
    33 
    44Copied from the jackd/jackdmp sources 
     
    66a jackd backend. 
    77 
    8 Copyright (C) 2001 Paul Davis  
     8Copyright (C) 2001 Paul Davis 
    99Copyright (C) 2004-2006 Grame 
    1010 
     
    5454 
    5555    // If Init succeed start the thread loop 
    56        bool res = true; 
     56    bool res = true; 
    5757    while (obj->fRunning && res) { 
    5858        res = runnable->Execute(); 
    59                //pthread_testcancel(); 
     59        //pthread_testcancel(); 
    6060    } 
    6161 
     
    6767{ 
    6868    int res; 
    69        fRunning = true; 
     69    fRunning = true; 
    7070 
    7171    if (fRealTime) { 
     
    121121            return -1; 
    122122        } 
    123          
     123 
    124124        return 0; 
    125125    } 
     
    142142{ 
    143143    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; 
    146146        fRunning = false; // Request for the thread to stop 
    147                pthread_join(fThread, &status); 
     147        pthread_join(fThread, &status); 
    148148        return 0; 
    149149    } else { 
  • trunk/libffado/src/libutil/PosixThread.h

    r419 r445  
    11/* 
    2 Modifications for Freebob (C) 2006, Pieter Palmers 
     2Modifications for FFADO by Pieter Palmers 
    33 
    44Copied from the jackd/jackdmp sources 
     
    2525*/ 
    2626 
    27 #ifndef __POSIXTHREAD__ 
    28 #define __POSIXTHREAD__ 
     27#ifndef __FFADO_POSIXTHREAD__ 
     28#define __FFADO_POSIXTHREAD__ 
    2929 
    3030#include "Thread.h" 
     
    4646        int fPriority; 
    4747        bool fRealTime; 
    48                volatile bool fRunning; 
     48        volatile bool fRunning; 
    4949        int fCancellation; 
    5050 
     
    6868        virtual int Start(); 
    6969        virtual int Kill(); 
    70                virtual int Stop(); 
     70        virtual int Stop(); 
    7171 
    7272        virtual int AcquireRealTime(); 
     
    7676        pthread_t GetThreadID(); 
    7777 
    78        protected: 
     78    protected: 
    7979 
    8080}; 
     
    8383 
    8484 
    85 #endif 
     85#endif // __FFADO_POSIXTHREAD__ 
  • trunk/libffado/src/libutil/ringbuffer.c

    r386 r445  
    11/* 
    2   Modifications for FreeBoB by Pieter Palmers 
     2  Modifications for FFADO by Pieter Palmers 
    33     
    44  Copied from the jackd sources 
     
    3939   actual buffer size is rounded up to the next power of two.  */ 
    4040 
    41 freebob_ringbuffer_t * 
    42 freebob_ringbuffer_create (size_t sz) 
     41ffado_ringbuffer_t * 
     42ffado_ringbuffer_create (size_t sz) 
    4343{ 
    4444  int power_of_two; 
    45   freebob_ringbuffer_t *rb; 
    46  
    47   rb = malloc (sizeof (freebob_ringbuffer_t)); 
     45  ffado_ringbuffer_t *rb; 
     46 
     47  rb = malloc (sizeof (ffado_ringbuffer_t)); 
    4848 
    4949  for (power_of_two = 1; 1 << power_of_two < sz; power_of_two++); 
     
    6363 
    6464void 
    65 freebob_ringbuffer_free (freebob_ringbuffer_t * rb) 
     65ffado_ringbuffer_free (ffado_ringbuffer_t * rb) 
    6666{ 
    6767#ifdef USE_MLOCK 
     
    7676 
    7777int 
    78 freebob_ringbuffer_mlock (freebob_ringbuffer_t * rb) 
     78ffado_ringbuffer_mlock (ffado_ringbuffer_t * rb) 
    7979{ 
    8080#ifdef USE_MLOCK 
     
    9191 
    9292void 
    93 freebob_ringbuffer_reset (freebob_ringbuffer_t * rb) 
     93ffado_ringbuffer_reset (ffado_ringbuffer_t * rb) 
    9494{ 
    9595  rb->read_ptr = 0; 
     
    102102 
    103103size_t 
    104 freebob_ringbuffer_read_space (const freebob_ringbuffer_t * rb) 
     104ffado_ringbuffer_read_space (const ffado_ringbuffer_t * rb) 
    105105{ 
    106106  size_t w, r; 
     
    121121 
    122122size_t 
    123 freebob_ringbuffer_write_space (const freebob_ringbuffer_t * rb) 
     123ffado_ringbuffer_write_space (const ffado_ringbuffer_t * rb) 
    124124{ 
    125125  size_t w, r; 
     
    141141 
    142142size_t 
    143 freebob_ringbuffer_read (freebob_ringbuffer_t * rb, char *dest, size_t cnt) 
     143ffado_ringbuffer_read (ffado_ringbuffer_t * rb, char *dest, size_t cnt) 
    144144{ 
    145145  size_t free_cnt; 
     
    148148  size_t n1, n2; 
    149149 
    150   if ((free_cnt = freebob_ringbuffer_read_space (rb)) == 0) { 
     150  if ((free_cnt = ffado_ringbuffer_read_space (rb)) == 0) { 
    151151    return 0; 
    152152  } 
     
    182182 
    183183size_t 
    184 freebob_ringbuffer_peek (freebob_ringbuffer_t * rb, char *dest, size_t cnt) 
     184ffado_ringbuffer_peek (ffado_ringbuffer_t * rb, char *dest, size_t cnt) 
    185185{ 
    186186  size_t free_cnt; 
     
    192192  tmp_read_ptr = rb->read_ptr; 
    193193 
    194   if ((free_cnt = freebob_ringbuffer_read_space (rb)) == 0) { 
     194  if ((free_cnt = ffado_ringbuffer_read_space (rb)) == 0) { 
    195195    return 0; 
    196196  } 
     
    226226 
    227227size_t 
    228 freebob_ringbuffer_write (freebob_ringbuffer_t * rb, const char *src, size_t cnt) 
     228ffado_ringbuffer_write (ffado_ringbuffer_t * rb, const char *src, size_t cnt) 
    229229{ 
    230230  size_t free_cnt; 
     
    233233  size_t n1, n2; 
    234234 
    235   if ((free_cnt = freebob_ringbuffer_write_space (rb)) == 0) { 
     235  if ((free_cnt = ffado_ringbuffer_write_space (rb)) == 0) { 
    236236    return 0; 
    237237  } 
     
    265265 
    266266void 
    267 freebob_ringbuffer_read_advance (freebob_ringbuffer_t * rb, size_t cnt) 
     267ffado_ringbuffer_read_advance (ffado_ringbuffer_t * rb, size_t cnt) 
    268268{ 
    269269  rb->read_ptr += cnt; 
     
    274274 
    275275void 
    276 freebob_ringbuffer_write_advance (freebob_ringbuffer_t * rb, size_t cnt) 
     276ffado_ringbuffer_write_advance (ffado_ringbuffer_t * rb, size_t cnt) 
    277277{ 
    278278  rb->write_ptr += cnt; 
     
    286286 
    287287void 
    288 freebob_ringbuffer_get_read_vector (const freebob_ringbuffer_t * rb, 
    289                                  freebob_ringbuffer_data_t * vec) 
     288ffado_ringbuffer_get_read_vector (const ffado_ringbuffer_t * rb, 
     289                                 ffado_ringbuffer_data_t * vec) 
    290290{ 
    291291  size_t free_cnt; 
     
    330330 
    331331void 
    332 freebob_ringbuffer_get_write_vector (const freebob_ringbuffer_t * rb, 
    333                                   freebob_ringbuffer_data_t * vec) 
     332ffado_ringbuffer_get_write_vector (const ffado_ringbuffer_t * rb, 
     333                                  ffado_ringbuffer_data_t * vec) 
    334334{ 
    335335  size_t free_cnt; 
  • trunk/libffado/src/libutil/ringbuffer.h

    r386 r445  
    33  function names changed in order to avoid naming problems when using this in 
    44  a jackd backend. 
    5    
    6   Modifications for FreeBoB by Pieter Palmers 
    7      
     5 
     6  Modifications for FFADO by Pieter Palmers 
     7 
    88    Copyright (C) 2000 Paul Davis 
    99    Copyright (C) 2003 Rohan Drape 
    10      
     10 
    1111    This program is free software; you can redistribute it and/or modify 
    1212    it under the terms of the GNU Lesser General Public License as published by 
    1313    the Free Software Foundation; either version 2.1 of the License, or 
    1414    (at your option) any later version. 
    15      
     15 
    1616    This program is distributed in the hope that it will be useful, 
    1717    but WITHOUT ANY WARRANTY; without even the implied warranty of 
    1818    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1919    GNU Lesser General Public License for more details. 
    20      
     20 
    2121    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 
    2323    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
    2424 
    2525*/ 
    2626 
    27 #ifndef _RINGBUFFER_H 
    28 #define _RINGBUFFER_H 
     27#ifndef _FFADO_RINGBUFFER_H 
     28#define _FFADO_RINGBUFFER_H 
    2929 
    3030#ifdef __cplusplus 
     
    4545 */ 
    4646 
    47 typedef struct   
     47typedef struct 
    4848{ 
    4949  char  *buf; 
    5050  size_t len; 
    51 }  
    52 freebob_ringbuffer_data_t ; 
     51} 
     52ffado_ringbuffer_data_t ; 
    5353 
    5454typedef struct 
    5555{ 
    56   char          *buf; 
     56  char        *buf; 
    5757  volatile size_t write_ptr; 
    5858  volatile size_t read_ptr; 
    59   size_t         size; 
    60   size_t         size_mask; 
    61   int            mlocked; 
    62 }  
    63 freebob_ringbuffer_t ; 
     59  size_t      size; 
     60  size_t      size_mask; 
     61  int          mlocked; 
     62} 
     63ffado_ringbuffer_t ; 
    6464 
    6565/** 
    6666 * Allocates a ringbuffer data structure of a specified size. The 
    67  * caller must arrange for a call to freebob_ringbuffer_free() to release 
     67 * caller must arrange for a call to ffado_ringbuffer_free() to release 
    6868 * the memory associated with the ringbuffer. 
    6969 * 
    7070 * @param sz the ringbuffer size in bytes. 
    7171 * 
    72  * @return a pointer to a new freebob_ringbuffer_t, if successful; NULL 
     72 * @return a pointer to a new ffado_ringbuffer_t, if successful; NULL 
    7373 * otherwise. 
    7474 */ 
    75 freebob_ringbuffer_t *freebob_ringbuffer_create(size_t sz); 
     75ffado_ringbuffer_t *ffado_ringbuffer_create(size_t sz); 
    7676 
    7777/** 
    7878 * Frees the ringbuffer data structure allocated by an earlier call to 
    79  * freebob_ringbuffer_create(). 
    80  * 
    81  * @param rb a pointer to the ringbuffer structure. 
    82  */ 
    83 void freebob_ringbuffer_free(freebob_ringbuffer_t *rb); 
     79 * ffado_ringbuffer_create(). 
     80 * 
     81 * @param rb a pointer to the ringbuffer structure. 
     82 */ 
     83void ffado_ringbuffer_free(ffado_ringbuffer_t *rb); 
    8484 
    8585/** 
    8686 * Fill a data structure with a description of the current readable 
    8787 * data held in the ringbuffer.  This description is returned in a two 
    88  * element array of freebob_ringbuffer_data_t.  Two elements are needed 
     88 * element array of ffado_ringbuffer_data_t.  Two elements are needed 
    8989 * because the data to be read may be split across the end of the 
    9090 * ringbuffer. 
     
    100100 * 
    101101 * @param rb a pointer to the ringbuffer structure. 
    102  * @param vec a pointer to a 2 element array of freebob_ringbuffer_data_t. 
    103  * 
    104  */ 
    105 void freebob_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 */ 
     105void ffado_ringbuffer_get_read_vector(const ffado_ringbuffer_t *rb, 
     106                     ffado_ringbuffer_data_t *vec); 
    107107 
    108108/** 
    109109 * Fill a data structure with a description of the current writable 
    110110 * space in the ringbuffer.  The description is returned in a two 
    111  * element array of freebob_ringbuffer_data_t.  Two elements are needed 
     111 * element array of ffado_ringbuffer_data_t.  Two elements are needed 
    112112 * because the space available for writing may be split across the end 
    113113 * of the ringbuffer. 
     
    123123 * 
    124124 * @param rb a pointer to the ringbuffer structure. 
    125  * @param vec a pointer to a 2 element array of freebob_ringbuffer_data_t. 
    126  */ 
    127 void freebob_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 */ 
     127void ffado_ringbuffer_get_write_vector(const ffado_ringbuffer_t *rb, 
     128                      ffado_ringbuffer_data_t *vec); 
    129129 
    130130/** 
     
    138138 * @return the number of bytes read, which may range from 0 to cnt. 
    139139 */ 
    140 size_t freebob_ringbuffer_read(freebob_ringbuffer_t *rb, char *dest, size_t cnt); 
    141  
    142 /** 
    143  * Read data from the ringbuffer. Opposed to freebob_ringbuffer_read() 
     140size_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() 
    144144 * this function does not move the read pointer. Thus it's 
    145145 * a convenient way to inspect data in the ringbuffer in a 
    146146 * continous fashion. The price is that the data is copied 
    147147 * into a user provided buffer. For "raw" non-copy inspection 
    148  * of the data in the ringbuffer use freebob_ringbuffer_get_read_vector(). 
     148 * of the data in the ringbuffer use ffado_ringbuffer_get_read_vector(). 
    149149 * 
    150150 * @param rb a pointer to the ringbuffer structure. 
     
    155155 * @return the number of bytes read, which may range from 0 to cnt. 
    156156 */ 
    157 size_t freebob_ringbuffer_peek(freebob_ringbuffer_t *rb, char *dest, size_t cnt); 
     157size_t ffado_ringbuffer_peek(ffado_ringbuffer_t *rb, char *dest, size_t cnt); 
    158158 
    159159/** 
     
    161161 * 
    162162 * After data have been read from the ringbuffer using the pointers 
    163  * returned by freebob_ringbuffer_get_read_vector(), use this function to 
     163 * returned by ffado_ringbuffer_get_read_vector(), use this function to 
    164164 * advance the buffer pointers, making that space available for future 
    165165 * write operations. 
     
    168168 * @param cnt the number of bytes read. 
    169169 */ 
    170 void freebob_ringbuffer_read_advance(freebob_ringbuffer_t *rb, size_t cnt); 
     170void ffado_ringbuffer_read_advance(ffado_ringbuffer_t *rb, size_t cnt); 
    171171 
    172172/** 
     
    177177 * @return the number of bytes available to read. 
    178178 */ 
    179 size_t freebob_ringbuffer_read_space(const freebob_ringbuffer_t *rb); 
     179size_t ffado_ringbuffer_read_space(const ffado_ringbuffer_t *rb); 
    180180 
    181181/** 
     
    186186 * @param rb a pointer to the ringbuffer structure. 
    187187 */ 
    188 int freebob_ringbuffer_mlock(freebob_ringbuffer_t *rb); 
     188int ffado_ringbuffer_mlock(ffado_ringbuffer_t *rb); 
    189189 
    190190/** 
     
    195195 * @param rb a pointer to the ringbuffer structure. 
    196196 */ 
    197 void freebob_ringbuffer_reset(freebob_ringbuffer_t *rb); 
     197void ffado_ringbuffer_reset(ffado_ringbuffer_t *rb); 
    198198 
    199199/** 
     
    206206 * @return the number of bytes write, which may range from 0 to cnt 
    207207 */ 
    208 size_t freebob_ringbuffer_write(freebob_ringbuffer_t *rb, const char *src, 
    209                             size_t cnt); 
     208size_t ffado_ringbuffer_write(ffado_ringbuffer_t *rb, const char *src, 
     209                 size_t cnt); 
    210210 
    211211/** 
     
    213213 * 
    214214 * After data have been written the ringbuffer using the pointers 
    215  * returned by freebob_ringbuffer_get_write_vector(), use this function 
     215 * returned by ffado_ringbuffer_get_write_vector(), use this function 
    216216 * to advance the buffer pointer, making the data available for future 
    217217 * read operations. 
     
    220220 * @param cnt the number of bytes written. 
    221221 */ 
    222 void freebob_ringbuffer_write_advance(freebob_ringbuffer_t *rb, size_t cnt); 
     222void ffado_ringbuffer_write_advance(ffado_ringbuffer_t *rb, size_t cnt); 
    223223 
    224224/** 
     
    229229 * @return the amount of free space (in bytes) available for writing. 
    230230 */ 
    231 size_t freebob_ringbuffer_write_space(const freebob_ringbuffer_t *rb); 
     231size_t ffado_ringbuffer_write_space(const ffado_ringbuffer_t *rb); 
    232232 
    233233 
     
    236236#endif 
    237237 
    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, 
    1114 * 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. 
     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 
    1922 */ 
    2023 
     
    4952{ 
    5053    try { 
    51         m_doc.create_root_node( "freebob_cache" ); 
     54        m_doc.create_root_node( "ffado_cache" ); 
    5255    } catch ( const exception& ex ) { 
    5356        cout << "Exception caught: " << ex.what(); 
     
    212215    } 
    213216    xmlpp::Node* pNode = pDoc->get_root_node(); 
    214      
     217 
    215218    xmlpp::NodeSet nodeSet = pNode->find( strMemberName ); 
    216219    for ( xmlpp::NodeSet::iterator it = nodeSet.begin(); 
  • trunk/libffado/src/libutil/serialize.h

    r372 r445  
    1 /* serialize.h 
    2  * Copyright (C) 2007 by Daniel Wagner 
     1/* 
     2 * Copyright (C) 2005-2007 by Daniel Wagner 
    33 * 
    4  * This file is part of FreeBoB. 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    56 * 
    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, 
    1114 * 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. 
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     16 * Lesser General Public License for more details. 
    1417 * 
    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. 
     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 
    1922 */ 
    2023 
  • trunk/libffado/src/libutil/StreamStatistics.cpp

    r419 r445  
    1 /* $Id$ */ 
    2  
    31/* 
    4  *   FreeBob Streaming API 
    5  *   FreeBob = Firewire (pro-)audio for linux 
     2 * Copyright (C) 2005-2007 by Pieter Palmers 
    63 * 
    7  *   http://freebob.sf.net 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    86 * 
    9  *   Copyright (C) 2005,2006,2007 Pieter Palmers <pieterpalmers@users.sourceforge.net> 
     7 * FFADO is based upon FreeBoB. 
    108 * 
    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; 
    1512 * 
    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. 
     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. 
    2017 * 
    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 
    2722 */ 
    2823 
  • trunk/libffado/src/libutil/StreamStatistics.h

    r419 r445  
    1 /* $Id$ */ 
    2  
    31/* 
    4  *   FreeBob Streaming API 
    5  *   FreeBob = Firewire (pro-)audio for linux 
     2 * Copyright (C) 2005-2007 by Pieter Palmers 
    63 * 
    7  *   http://freebob.sf.net 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    86 * 
    9  *   Copyright (C) 2005,2006,2007 Pieter Palmers <pieterpalmers@users.sourceforge.net> 
     7 * FFADO is based upon FreeBoB. 
    108 * 
    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; 
    1512 * 
    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. 
     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. 
    2017 * 
    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 
    2722 */ 
    2823 
    29 #ifndef FREEBOBSTREAMINGSTREAMSTATISTICS_H 
    30 #define FREEBOBSTREAMINGSTREAMSTATISTICS_H 
     24#ifndef FFADOSTREAMINGSTREAMSTATISTICS_H 
     25#define FFADOSTREAMINGSTREAMSTATISTICS_H 
    3126 
    3227#include <string> 
     
    4136 
    4237    void setName(std::string n) {m_name=n;}; 
    43      
     38 
    4439    void mark(int value); 
    45      
     40 
    4641    void dumpInfo(); 
    4742    void reset(); 
    4843 
    4944    std::string m_name; 
    50      
     45 
    5146    long m_count; 
    5247    float m_average; 
     
    5449    long m_max; 
    5550    long m_sum; 
    56      
     51 
    5752private: 
    58      
     53 
    5954}; 
    6055 
  • trunk/libffado/src/libutil/SystemTimeSource.cpp

    r419 r445  
    1 /* $Id$ */ 
    2  
    31/* 
    4  *   FreeBob Streaming API 
    5  *   FreeBob = Firewire (pro-)audio for linux 
     2 * Copyright (C) 2005-2007 by Pieter Palmers 
    63 * 
    7  *   http://freebob.sf.net 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    86 * 
    9  *   Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> 
     7 * FFADO is based upon FreeBoB. 
    108 * 
    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; 
    1512 * 
    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. 
     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. 
    2017 * 
    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 
    2722 */ 
    2823 
     
    4136 
    4237} 
    43      
    44 freebob_microsecs_t SystemTimeSource::getCurrentTime() { 
     38 
     39ffado_microsecs_t SystemTimeSource::getCurrentTime() { 
    4540    struct timeval tv; 
    4641    gettimeofday(&tv, NULL); 
    4742    return tv.tv_sec * 1000000ULL + tv.tv_usec; 
    48      
     43 
    4944//     return GetMicroSeconds(); 
    5045} 
    5146 
    52 freebob_microsecs_t SystemTimeSource::getCurrentTimeAsUsecs() { 
     47ffado_microsecs_t SystemTimeSource::getCurrentTimeAsUsecs() { 
    5348    return getCurrentTime(); 
    5449} 
  • 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 */ 
    223 
    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__ 
    3026 
    3127#include "../debugmodule/debugmodule.h" 
     
    3430namespace Util { 
    3531 
    36 class SystemTimeSource  
     32class SystemTimeSource 
    3733    : public Util::TimeSource 
    3834{ 
     
    4036public: 
    4137 
    42        SystemTimeSource(); 
    43        virtual ~SystemTimeSource(); 
    44          
     38    SystemTimeSource(); 
     39    virtual ~SystemTimeSource(); 
     40 
    4541    // implement the TimeSource interface 
    46     freebob_microsecs_t getCurrentTime(); 
    47     freebob_microsecs_t getCurrentTimeAsUsecs(); 
    48     inline freebob_microsecs_t unWrapTime(freebob_microsecs_t t) {return t;}; 
    49     inline freebob_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;}; 
    5046 
    5147protected: 
     
    5652} // end of namespace Util 
    5753 
    58 #endif /* __FREEBOB_SYSTEMTIMESOURCE__ */ 
     54#endif /* __FFADO_SYSTEMTIMESOURCE__ */ 
    5955 
    6056 
  • trunk/libffado/src/libutil/test-dll.cpp

    r419 r445  
    11/* 
    2  *   FreeBob Streaming API 
    3  *   FreeBob = Firewire (pro-)audio for linux 
     2 * Copyright (C) 2005-2007 by Pieter Palmers 
    43 * 
    5  *   http://freebob.sf.net 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    66 * 
    7  *   Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> 
     7 * FFADO is based upon FreeBoB. 
    88 * 
    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. 
    1317 * 
    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. 
    2622 */ 
    2723 
     
    3430    int i=0; 
    3531    int i2=0; 
    36      
     32 
    3733    #define MAX_TEST_ORDER 2 
    38      
     34 
    3935    #define NB_VALUES 12 
    4036    #define NB_LOOPS 50000 
    4137 
    4238    // this test is for a second order loop, 
    43      
     39 
    4440 
    4541    float omega=6.28*0.001; 
     
    4743    coeffs[0]=1.41*omega; 
    4844    coeffs[1]=omega*omega; 
    49      
     45 
    5046    DelayLockedLoop d1(1, coeffs); 
    51      
     47 
    5248    DelayLockedLoop d2(2, coeffs); 
    53      
     49 
    5450    // this sequence represents the average deviation of the sample period 
    5551    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}; 
    5652    float average=0.0; 
    57      
     53 
    5854    // these are the actual period times 
    5955    float ideal_values[NB_LOOPS]; 
    6056    float actual_values[NB_LOOPS]; 
    6157    float actual_values2[NB_LOOPS]; 
    62      
     58 
    6359    // we define a nominal sample time: 
    6460    float ts_nominal=1.0/48000.0; 
    6561    float period=100.0; 
    66      
     62 
    6763    // we calculate the deviated sample times 
    6864    for (i=0;i<NB_LOOPS;i++) { 
    6965        unsigned int idx=i % NB_VALUES; 
    70          
     66 
    7167        // this constructs time-between-samples type of data 
    7268        // for testing the first order loop 
    7369        actual_values[i]=period*ts_nominal*(1+deviation[idx]); 
    74          
     70 
    7571        // this is constructing an incrementing time line 
    7672        ideal_values[i]=0; 
    7773        if (i==0) ideal_values[i] = ts_nominal * period; 
    7874        else ideal_values[i] = ideal_values[i-1] + (ts_nominal * period); 
    79          
     75 
    8076        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 
    8379        // direction the deviation sequence takes. 
    84         average+=deviation[idx]*ts_nominal;  
     80        average+=deviation[idx]*ts_nominal; 
    8581    } 
    8682    average /= NB_LOOPS; 
    87      
     83 
    8884    d1.setIntegrator(0,period*ts_nominal); 
    89      
     85 
    9086    d2.setIntegrator(0,ideal_values[0]); 
    9187    d2.setIntegrator(1,ideal_values[0]); 
    92     
     88 
    9389    for(i=0;i<50;i++) { 
    9490        d1.put(actual_values[i]); 
    9591        printf("%06d: IN = %8.4fms - OUT = %8.4fms, error output=%e\n", i, actual_values[i]*1000, d1.get()*1000, d1.getError()); 
    9692    } 
    97      
     93 
    9894    printf("--------\n"); 
    9995    for(i2=0;i2<50;i2++) { 
     
    10197        printf("%06d: IN = %8.4fms - OUT = %8.4fms, error output=%e\n", i, actual_values2[i2]*1000, d2.get()*1000,  d2.getError()); 
    10298    } 
    103      
     99 
    104100    printf("========= CONVERGENCE =========\n"); 
    105101    for(;i<NB_LOOPS;i++) { 
    106102        d1.put(actual_values[i]); 
    107103    } 
    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, 
    110106        d1.getError(), 
    111107        ts_nominal * period*1000, 
    112108        (d1.get()-ts_nominal * period)/(ts_nominal * period)*100); 
    113      
     109 
    114110    printf("--------\n"); 
    115111    for(;i2<NB_LOOPS;i2++) { 
    116112        d2.put(actual_values2[i2]); 
    117113    } 
    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, 
    120116        d2.getError(), 
    121117        ideal_values[NB_LOOPS-1]*1000, 
    122118        (d2.get()-ideal_values[NB_LOOPS-1])/(ideal_values[NB_LOOPS-1])*100); 
    123        
    124      
     119 
     120 
    125121    printf("Average deviation: %f, period time = %fms\n",average, ts_nominal * period*1000); 
    126122 
  • trunk/libffado/src/libutil/Thread.h

    r419 r445  
    11/* 
    2 Modifications for Freebob (C) 2006, Pieter Palmers 
     2Modifications for FFADO by Pieter Palmers 
    33 
    44Copied from the jackd/jackdmp sources 
     
    7777        virtual int Start() = 0; 
    7878        virtual int Kill() = 0; 
    79                virtual int Stop() = 0; 
     79        virtual int Stop() = 0; 
    8080 
    8181        virtual int AcquireRealTime() = 0; 
     
    8787 
    8888        virtual pthread_t GetThreadID() = 0; 
    89          
     89 
    9090    protected: 
    91                DECLARE_DEBUG_MODULE; 
     91            DECLARE_DEBUG_MODULE; 
    9292 
    9393}; 
  • 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 
    43 
    5         http://freebob.sf.net 
     4    This file is part of FFADO 
     5    FFADO = Free Firewire (pro-)audio drivers for linux 
    66 
    7         Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> 
     7    FFADO is based upon FreeBoB. 
    88 
    9          
    109        Based upon JackTime.c from the jackdmp package. 
    1110        Original Copyright: 
     
    1312        Copyright (C) 2001-2003 Paul Davis 
    1413        Copyright (C) 2004-2006 Grame 
    15  
    1614 
    1715        This program is free software; you can redistribute it and/or modify 
  • trunk/libffado/src/libutil/Time.h

    r384 r445  
    11/* 
    2 Time.h 
    3 FreeBob Streaming API 
    4 FreeBob = Firewire (pro-)audio for linux 
     2    Copyright (C) 2005-2007 by Pieter Palmers 
    53 
    6 http://freebob.sf.net 
     4    This file is part of FFADO 
     5    FFADO = Free Firewire (pro-)audio drivers for linux 
    76 
    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. 
    128 
    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: 
    1511 
    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 
    2014 
    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
    2519 
    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. 
    2928 
    3029*/ 
     
    4342 */ 
    4443 
    45 typedef uint64_t freebob_microsecs_t; 
     44typedef uint64_t ffado_microsecs_t; 
    4645 
    4746 
     
    5453#include <unistd.h> 
    5554 
    56     static inline void FreebobSleep(long usec) { 
     55    static inline void FFADOSleep(long usec) { 
    5756        usleep(usec); 
    5857    } 
    5958 
    6059#ifdef GETCYCLE_TIME 
    61        #include "cycles.h" 
    62     extern freebob_microsecs_t __freebob_cpu_mhz; 
    63     extern freebob_microsecs_t GetMhz(); 
     60    #include "cycles.h" 
     61    extern ffado_microsecs_t __ffado_cpu_mhz; 
     62    extern ffado_microsecs_t GetMhz(); 
    6463    extern void InitTime(); 
    65     static inline freebob_microsecs_t GetMicroSeconds (void) { 
    66         return get_cycles() / __freebob_cpu_mhz; 
     64    static inline ffado_microsecs_t GetMicroSeconds (void) { 
     65        return get_cycles() / __ffado_cpu_mhz; 
    6766    } 
    6867#else 
    69        #include <time.h> 
     68    #include <time.h> 
    7069    extern void InitTime(); 
    71     static inline freebob_microsecs_t GetMicroSeconds (void) { 
     70    static inline ffado_microsecs_t GetMicroSeconds (void) { 
    7271        struct timespec ts; 
    7372        clock_gettime(CLOCK_MONOTONIC, &ts); 
    74         return (freebob_microsecs_t)ts.tv_sec * 1000000LL + ts.tv_nsec / 1000; 
     73        return (ffado_microsecs_t)ts.tv_sec * 1000000LL + ts.tv_nsec / 1000; 
    7574    } 
    7675#endif 
  • trunk/libffado/src/libutil/TimeSource.cpp

    r419 r445  
    1 /* $Id$ */ 
    2  
    31/* 
    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 */ 
    2923 
    3024#include "TimeSource.h" 
     
    5650 */ 
    5751void TimeSource::initSlaveTimeSource() { 
    58     freebob_microsecs_t my_time; 
    59     freebob_microsecs_t master_time; 
    60     freebob_microsecs_t my_time2; 
    61     freebob_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 
    6357    if (m_Master) { 
    6458        my_time=getCurrentTime(); 
    6559        master_time=m_Master->getCurrentTime(); 
    66          
     60 
    6761        struct timespec ts; 
    68          
     62 
    6963        // sleep for ten milliseconds 
    7064        ts.tv_sec=0; 
    7165        ts.tv_nsec=10000000L; 
    72          
     66 
    7367        nanosleep(&ts,NULL); 
    74          
     68 
    7569        my_time2=getCurrentTime(); 
    7670        master_time2=m_Master->getCurrentTime(); 
    77          
     71 
    7872        float diff_slave=my_time2-my_time; 
    7973        float diff_master=master_time2-master_time; 
    80          
     74 
    8175        m_slave_rate=diff_slave/diff_master; 
    82          
     76 
    8377        // average of the two offset estimates 
    84         m_slave_offset  = my_time-wrapTime((freebob_microsecs_t)(master_time*m_slave_rate)); 
    85         m_slave_offset += my_time2-wrapTime((freebob_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)); 
    8680        m_slave_offset /= 2; 
    87          
     81 
    8882        m_last_master_time=master_time2; 
    8983        m_last_time=my_time2; 
     
    9589        debugOutput(DEBUG_LEVEL_NORMAL,"init slave: slave rate=%f, slave_offset=%lu\n", 
    9690            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 
    10599 * on it's own timeline 
    106100 * 
    107101 * @return the mapped time point 
    108102 */ 
    109 freebob_microsecs_t TimeSource::mapMasterTime(freebob_microsecs_t master_time) { 
     103ffado_microsecs_t TimeSource::mapMasterTime(ffado_microsecs_t master_time) { 
    110104    if(m_Master) { 
    111105        // calculate the slave based upon the master 
    112106        // and the estimated rate 
    113          
     107 
    114108        // linear interpolation 
    115109        int delta_master=master_time-m_last_master_time; 
    116      
     110 
    117111        float offset=m_slave_rate * ((float)delta_master); 
    118          
    119         freebob_microsecs_t mapped=m_last_time+(int)offset; 
    120          
     112 
     113        ffado_microsecs_t mapped=m_last_time+(int)offset; 
     114 
    121115        debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"map time: master=%d, offset=%f, slave_base=%lu, pred_ticks=%lu\n", 
    122116            master_time, offset, m_last_time,mapped 
    123117            ); 
    124          
     118 
    125119        return wrapTime(mapped); 
    126          
     120 
    127121    } else { 
    128122        debugOutput( DEBUG_LEVEL_VERBOSE, "Requested map for non-slave TimeSource\n"); 
    129          
     123 
    130124        return master_time; 
    131125    } 
     
    140134    for ( TimeSourceVectorIterator it = m_Slaves.begin(); 
    141135          it != m_Slaves.end(); ++it ) { 
    142            
    143         // update the slave with the current  
     136 
     137        // update the slave with the current 
    144138        // master time 
    145139        if (!(*it)->updateTimeSource()) return false; 
    146140    } 
    147      
     141 
    148142    // this TimeSource has a master 
    149143    if(m_Master) { 
    150         freebob_microsecs_t my_time=getCurrentTime(); 
    151         freebob_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 
    154148        // measured at the same time, but that of course is 
    155149        // not really true. The DLL will have to filter this 
    156150        // out. 
    157          
     151 
    158152        // the difference in master time 
    159153        int64_t delta_master; 
     
    163157            delta_master=m_Master->unWrapTime(master_time)-m_last_master_time; 
    164158        } 
    165          
     159 
    166160        // the difference in slave time 
    167161        int64_t delta_slave; 
     
    171165            delta_slave=unWrapTime(my_time)-m_last_time; 
    172166        } 
    173          
     167 
    174168        // the estimated slave difference 
    175169        int delta_slave_est=(int)(m_slave_rate * ((double)delta_master)); 
    176          
     170 
    177171        // the measured & estimated rate 
    178172        double rate_meas=((double)delta_slave/(double)delta_master); 
    179173        double rate_est=((double)m_slave_rate); 
    180          
     174 
    181175        m_last_err=(rate_meas-rate_est); 
    182          
     176 
    183177        m_slave_rate += 0.01*m_last_err; 
    184          
     178 
    185179        debugOutput(DEBUG_LEVEL_VERBOSE,"update slave: master=%llu, master2=%llu, diff=%lld\n", 
    186180            master_time, m_last_master_time, delta_master); 
     
    191185            ); 
    192186 
    193          
     187 
    194188        m_last_master_time=master_time; 
    195          
     189 
    196190        int64_t tmp = delta_slave_est; 
    197191        tmp += m_last_time; 
    198          
     192 
    199193        m_last_time = tmp; 
    200          
    201  
    202              
     194 
     195 
     196 
    203197    } 
    204198 
     
    209203 * Sets the master TimeSource for this timesource. 
    210204 * 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 
    212206 * the master to a time point on it's own timeline 
    213207 * 
    214  * @param ts master TimeSource   
     208 * @param ts master TimeSource 
    215209 * @return true if successful 
    216210 */ 
     
    218212    if (m_Master==NULL) { 
    219213        m_Master=ts; 
    220          
     214 
    221215        // initialize ourselves. 
    222216        initSlaveTimeSource(); 
    223          
     217 
    224218        return true; 
    225219    } else return false; 
     
    238232 * Registers a slave timesource to this master. 
    239233 * 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 
    242236 * it's own timeline 
    243237 * 
     
    247241bool TimeSource::registerSlave(TimeSource *ts) { 
    248242    // TODO: we should check for circular master-slave relationships. 
    249      
     243 
    250244    debugOutput( DEBUG_LEVEL_VERBOSE, "Registering slave (%p)\n", ts); 
    251245    assert(ts); 
    252      
     246 
    253247    // inherit debug level 
    254     ts->setVerboseLevel(getDebugLevel());  
    255      
     248    ts->setVerboseLevel(getDebugLevel()); 
     249 
    256250    if(ts->setMaster(this)) { 
    257251        m_Slaves.push_back(ts); 
     
    275269          it != m_Slaves.end(); ++it ) { 
    276270 
    277         if ( *it == ts ) {  
     271        if ( *it == ts ) { 
    278272            m_Slaves.erase(it); 
    279273            ts->clearMaster(); 
     
    281275        } 
    282276    } 
    283      
     277 
    284278    debugOutput( DEBUG_LEVEL_VERBOSE, " TimeSource (%p) not found\n", ts); 
    285      
     279 
    286280    return false; 
    287281} 
     
    298292    for ( TimeSourceVectorIterator it = m_Slaves.begin(); 
    299293          it != m_Slaves.end(); ++it ) { 
    300          
     294 
    301295        (*it)->setVerboseLevel(l); 
    302296    } 
     
    313307    debugOutputShort( DEBUG_LEVEL_NORMAL, "  Last slave time  : %llu\n",m_last_time ); 
    314308 
    315     
     309 
    316310    for ( TimeSourceVectorIterator it = m_Slaves.begin(); 
    317311          it != m_Slaves.end(); ++it ) { 
    318          
     312 
    319313        (*it)->printTimeSourceInfo(); 
    320314    } 
  • 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 */ 
    223 
    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__ 
    3026 
    3127#include "../debugmodule/debugmodule.h" 
     
    3329#include <vector> 
    3430 
    35 typedef uint64_t freebob_microsecs_t; 
     31typedef uint64_t ffado_microsecs_t; 
    3632 
    3733namespace Util { 
     
    4440\brief The base class for all TimeSource's. 
    4541 
    46     Any object that can act as a source of timing  
     42    Any object that can act as a source of timing 
    4743    information should subclass this class and implement 
    4844    its virtual functions. 
    49      
     45 
    5046    A TimeSource can be slaved to another TimeSource, allowing 
    5147    the mapping of the master's time to the slave's time. 
     
    5854    virtual ~TimeSource(); 
    5955 
    60     virtual freebob_microsecs_t getCurrentTime()=0; 
    61     virtual freebob_microsecs_t getCurrentTimeAsUsecs()=0; 
    62     virtual freebob_microsecs_t unWrapTime(freebob_microsecs_t t)=0; 
    63     virtual freebob_microsecs_t wrapTime(freebob_microsecs_t t)=0; 
    64      
    65     freebob_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 
    6763    bool updateTimeSource(); 
    68      
     64 
    6965    bool registerSlave(TimeSource *ts); 
    7066    bool unregisterSlave(TimeSource *ts); 
    7167 
    7268    virtual void setVerboseLevel(int l); 
    73      
     69 
    7470    virtual void printTimeSourceInfo(); 
    75      
     71 
    7672protected: 
    7773 
     
    7975    bool setMaster(TimeSource *ts); 
    8076    void clearMaster(); 
    81      
     77 
    8278    void initSlaveTimeSource(); 
    83      
     79 
    8480    TimeSource * m_Master; 
    8581    TimeSourceVector m_Slaves; 
    86      
    87     freebob_microsecs_t m_last_master_time; 
    88     freebob_microsecs_t m_last_time; 
    89      
     82 
     83    ffado_microsecs_t m_last_master_time; 
     84    ffado_microsecs_t m_last_time; 
     85 
    9086    double m_slave_rate; 
    9187    int64_t m_slave_offset; 
    9288    double m_last_err; 
    93      
     89 
    9490    DECLARE_DEBUG_MODULE; 
    9591 
     
    9894} // end of namespace Util 
    9995 
    100 #endif /* __FREEBOB_TIMESOURCE__ */ 
     96#endif /* __FFADO_TIMESOURCE__ */ 
    10197 
    10298 
  • trunk/libffado/src/libutil/TimestampedBuffer.cpp

    r419 r445  
    22 
    33/* 
    4  *   FreeBob Streaming API 
    5  *   FreeBob = Firewire (pro-)audio for linux 
    6  * 
    7  *   http://freebob.sf.net 
     4 *   FFADO Streaming API 
     5 *   FFADO = Firewire (pro-)audio for linux 
     6 * 
     7 *   http://ffado.sf.net 
    88 * 
    99 *   Copyright (C) 2005,2006,2007 Pieter Palmers <pieterpalmers@users.sourceforge.net> 
     
    2323 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
    2424 * 
    25  *  
    26  * 
    27  */ 
    28   
     25 * 
     26 * 
     27 */ 
     28 
    2929#include "libutil/Atomic.h" 
    3030#include "libstreaming/cycletimer.h" 
     
    5454 
    5555TimestampedBuffer::~TimestampedBuffer() { 
    56     freebob_ringbuffer_free(m_event_buffer); 
     56    ffado_ringbuffer_free(m_event_buffer); 
    5757    free(m_cluster_buffer); 
    5858} 
     
    7171    m_nominal_rate=r; 
    7272    debugOutput(DEBUG_LEVEL_VERBOSE," nominal rate=%e set to %e\n", 
    73                                     m_nominal_rate, r);     
     73                                    m_nominal_rate, r); 
    7474    return true; 
    7575} 
     
    100100 
    101101/** 
    102  * \brief return the effective rate  
     102 * \brief return the effective rate 
    103103 * 
    104104 * Returns the effective rate calculated by the DLL. 
     
    109109    debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"getRate: %f/%f=%f\n", 
    110110        m_dll_e2,(float)m_update_period, m_dll_e2/((float) m_update_period)); 
    111      
     111 
    112112    return m_dll_e2/((float) m_update_period); 
    113113} 
     
    120120bool TimestampedBuffer::setEventSize(unsigned int s) { 
    121121    m_event_size=s; 
    122      
     122 
    123123    m_bytes_per_frame=m_event_size*m_events_per_frame; 
    124124    m_bytes_per_buffer=m_bytes_per_frame*m_buffer_size; 
    125      
     125 
    126126    return true; 
    127127} 
     
    134134bool TimestampedBuffer::setEventsPerFrame(unsigned int n) { 
    135135    m_events_per_frame=n; 
    136      
     136 
    137137    m_bytes_per_frame=m_event_size*m_events_per_frame; 
    138138    m_bytes_per_buffer=m_bytes_per_frame*m_buffer_size; 
    139      
     139 
    140140    return true; 
    141141} 
     
    155155 
    156156/** 
    157  * Sets the buffer offset in ticks.  
     157 * Sets the buffer offset in ticks. 
    158158 * 
    159159 * A positive value means that the buffer is 'delayed' for nticks ticks. 
    160160 * 
    161161 * @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. 
    163163 * @param nframes the number of ticks (positive = delay buffer) 
    164164 * @return true if successful 
     
    174174 * 
    175175 * 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 
    177177 * guaranteed to be consistent at all times due to threading issues. 
    178178 * 
    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 
    180180 * getFrameCounter, getBufferHeadTimestamp, getBufferTailTimestamp 
    181181 * functions 
     
    184184 */ 
    185185unsigned int TimestampedBuffer::getBufferFill() { 
    186     return freebob_ringbuffer_read_space(m_event_buffer)/(m_bytes_per_frame); 
     186    return ffado_ringbuffer_read_space(m_event_buffer)/(m_bytes_per_frame); 
    187187} 
    188188 
     
    204204 * Resets the TimestampedBuffer, clearing the buffers and counters. 
    205205 * (not true yet: Also resets the DLL to the nominal values.) 
    206  *  
     206 * 
    207207 * \note when this is called, you should make sure that the buffer 
    208208 *       tail timestamp gets set before continuing 
     
    211211 */ 
    212212bool TimestampedBuffer::reset() { 
    213     freebob_ringbuffer_reset(m_event_buffer); 
    214      
     213    ffado_ringbuffer_reset(m_event_buffer); 
     214 
    215215    resetFrameCounter(); 
    216      
     216 
    217217    return true; 
    218218} 
     
    220220/** 
    221221 * \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 
    224224 * initializes all data structures. 
    225  *  
     225 * 
    226226 * This should be called after parameters such as buffer size, event size etc.. are set, 
    227227 * and before any read/write operations are performed. 
    228  *  
     228 * 
    229229 * @return true if successful 
    230230 */ 
     
    233233    debugOutput(DEBUG_LEVEL_VERBOSE," Size=%u events, events/frame=%u, event size=%ubytes\n", 
    234234                                        m_buffer_size,m_events_per_frame,m_event_size); 
    235                                          
     235 
    236236    debugOutput(DEBUG_LEVEL_VERBOSE," update period %u\n", 
    237237                                    m_update_period); 
    238238    debugOutput(DEBUG_LEVEL_VERBOSE," nominal rate=%f\n", 
    239239                                    m_nominal_rate); 
    240                                      
     240 
    241241    debugOutput(DEBUG_LEVEL_VERBOSE," wrapping at %llu\n",m_wrap_at); 
    242242 
     
    247247    assert(m_nominal_rate != 0.0L); 
    248248    assert(m_update_period != 0); 
    249      
    250     if( !(m_event_buffer=freebob_ringbuffer_create( 
     249 
     250    if( !(m_event_buffer=ffado_ringbuffer_create( 
    251251            (m_events_per_frame * m_buffer_size) * m_event_size))) { 
    252252        debugFatal("Could not allocate memory event ringbuffer\n"); 
    253253        return false; 
    254254    } 
    255      
     255 
    256256    // allocate the temporary cluster buffer 
    257257    if( !(m_cluster_buffer=(char *)calloc(m_events_per_frame,m_event_size))) { 
    258258            debugFatal("Could not allocate temporary cluster buffer\n"); 
    259         freebob_ringbuffer_free(m_event_buffer); 
     259        ffado_ringbuffer_free(m_event_buffer); 
    260260        return false; 
    261261    } 
    262      
     262 
    263263    // init the DLL 
    264264    m_dll_e2=m_nominal_rate * (float)m_update_period; 
    265      
     265 
    266266    m_dll_b=((float)(0.877)); 
    267267    m_dll_c=((float)(0.384)); 
     
    272272/** 
    273273 * @brief Write frames to the buffer 
    274  *  
     274 * 
    275275 * Copies \ref nframes of frames from the buffer pointed to by \ref data to the 
    276276 * internal ringbuffer. The time of the last frame in the buffer is set to \ref ts. 
    277  *  
     277 * 
    278278 * @param nframes number of frames to copy 
    279279 * @param data pointer to the frame buffer 
     
    286286 
    287287    // add the data payload to the ringbuffer 
    288     if (freebob_ringbuffer_write(m_event_buffer,data,write_size) < write_size)  
     288    if (ffado_ringbuffer_write(m_event_buffer,data,write_size) < write_size) 
    289289    { 
    290290//         debugWarning("writeFrames buffer overrun\n"); 
    291291        return false; 
    292292    } 
    293      
     293 
    294294    incrementFrameCounter(nframes,ts); 
    295      
     295 
    296296    return true; 
    297297 
     
    299299/** 
    300300 * @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 
    303303 * to by \ref data. 
    304  *  
     304 * 
    305305 * @param nframes number of frames to copy 
    306306 * @param data pointer to the frame buffer 
     
    312312 
    313313    // get the data payload to the ringbuffer 
    314     if ((freebob_ringbuffer_read(m_event_buffer,data,read_size)) < read_size)  
     314    if ((ffado_ringbuffer_read(m_event_buffer,data,read_size)) < read_size) 
    315315    { 
    316316//         debugWarning("readFrames buffer underrun\n"); 
    317317        return false; 
    318318    } 
    319      
     319 
    320320    decrementFrameCounter(nframes); 
    321      
     321 
    322322    return true; 
    323323 
     
    326326/** 
    327327 * @brief Performs block processing write of frames 
    328  *  
     328 * 
    329329 * This function allows for zero-copy writing into the ringbuffer. 
    330330 * It calls the client's processWriteBlock function to write frames 
    331331 * into the internal buffer's data area, in a thread safe fashion. 
    332  *  
     332 * 
    333333 * It also updates the timestamp. 
    334  *  
     334 * 
    335335 * @param nbframes number of frames to process 
    336336 * @param ts timestamp of the last frame written to the buffer 
     
    342342    int xrun; 
    343343    unsigned int offset=0; 
    344      
    345     freebob_ringbuffer_data_t vec[2]; 
     344 
     345    ffado_ringbuffer_data_t vec[2]; 
    346346    // we received one period of frames 
    347347    // this is period_size*dimension of events 
     
    349349    unsigned int bytes2write=events2write*m_event_size; 
    350350 
    351     /* write events2write bytes to the ringbuffer  
     351    /* write events2write bytes to the ringbuffer 
    352352    *  first see if it can be done in one read. 
    353     *  if so, ok.  
     353    *  if so, ok. 
    354354    *  otherwise write up to a multiple of clusters directly to the buffer 
    355355    *  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 
    357357    *  Make sure that we cannot end up on a non-cluster aligned position! 
    358358    */ 
     
    361361    while(bytes2write>0) { 
    362362        int byteswritten=0; 
    363          
     363 
    364364        unsigned int frameswritten=(nbframes*cluster_size-bytes2write)/cluster_size; 
    365365        offset=frameswritten; 
    366          
    367         freebob_ringbuffer_get_write_vector(m_event_buffer, vec); 
    368              
     366 
     367        ffado_ringbuffer_get_write_vector(m_event_buffer, vec); 
     368 
    369369        if(vec[0].len==0) { // this indicates a full event buffer 
    370370            debugError("Event buffer overrun in buffer %p\n",this); 
    371371            break; 
    372372        } 
    373              
     373 
    374374        /* if we don't take care we will get stuck in an infinite loop 
    375375        * 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 
    377377        * smaller than one cluster 
    378378        * this can happen because the ringbuffer size is always a power of 2 
    379379        */ 
    380380        if(vec[0].len<cluster_size) { 
    381              
     381 
    382382            // encode to the temporary buffer 
    383383            xrun = m_Client->processWriteBlock(m_cluster_buffer, 1, offset); 
    384              
     384 
    385385            if(xrun<0) { 
    386386                // xrun detected 
     
    388388                return false; 
    389389            } 
    390                  
    391             // use the ringbuffer function to write one cluster  
     390 
     391            // use the ringbuffer function to write one cluster 
    392392            // the write function handles the wrap around. 
    393             freebob_ringbuffer_write(m_event_buffer, 
     393            ffado_ringbuffer_write(m_event_buffer, 
    394394                         m_cluster_buffer, 
    395395                         cluster_size); 
    396                  
     396 
    397397            // we advanced one cluster_size 
    398398            bytes2write-=cluster_size; 
    399                  
    400         } else { //  
    401              
     399 
     400        } else { // 
     401 
    402402            if(bytes2write>vec[0].len) { 
    403403                // align to a cluster boundary 
     
    406406                byteswritten=bytes2write; 
    407407            } 
    408                  
     408 
    409409            xrun = m_Client->processWriteBlock(vec[0].buf, 
    410410                         byteswritten/cluster_size, 
    411411                         offset); 
    412              
     412 
    413413            if(xrun<0) { 
    414414                    // xrun detected 
     
    417417            } 
    418418 
    419             freebob_ringbuffer_write_advance(m_event_buffer, byteswritten); 
     419            ffado_ringbuffer_write_advance(m_event_buffer, byteswritten); 
    420420            bytes2write -= byteswritten; 
    421421        } 
     
    425425 
    426426    } 
    427      
     427 
    428428    incrementFrameCounter(nbframes,ts); 
    429      
    430     return true; 
    431      
     429 
     430    return true; 
     431 
    432432} 
    433433 
    434434/** 
    435435 * @brief Performs block processing read of frames 
    436  *  
     436 * 
    437437 * This function allows for zero-copy reading from the ringbuffer. 
    438438 * 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 
    440440 * fashion. 
    441  *  
     441 * 
    442442 * @param nbframes number of frames to process 
    443443 * @return true if successful 
     
    446446 
    447447    debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "Reading %u from buffer (%p)...\n", nbframes, this); 
    448      
     448 
    449449    int xrun; 
    450450    unsigned int offset=0; 
    451      
    452     freebob_ringbuffer_data_t vec[2]; 
     451 
     452    ffado_ringbuffer_data_t vec[2]; 
    453453    // we received one period of frames on each connection 
    454454    // this is period_size*dimension of events 
     
    456456    unsigned int events2read=nbframes*m_events_per_frame; 
    457457    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. 
    461461    *  otherwise read up to a multiple of clusters directly from the buffer 
    462462    *  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 
    464464    *  Make sure that we cannot end up on a non-cluster aligned position! 
    465465    */ 
    466466    unsigned int cluster_size=m_events_per_frame*m_event_size; 
    467      
     467 
    468468    while(bytes2read>0) { 
    469469        unsigned int framesread=(nbframes*cluster_size-bytes2read)/cluster_size; 
     
    472472        int bytesread=0; 
    473473 
    474         freebob_ringbuffer_get_read_vector(m_event_buffer, vec); 
     474        ffado_ringbuffer_get_read_vector(m_event_buffer, vec); 
    475475 
    476476        if(vec[0].len==0) { // this indicates an empty event buffer 
     
    485485                */ 
    486486        if(vec[0].len<cluster_size) { 
    487             // use the ringbuffer function to read one cluster  
     487            // use the ringbuffer function to read one cluster 
    488488            // the read function handles wrap around 
    489             freebob_ringbuffer_read(m_event_buffer,m_cluster_buffer,cluster_size); 
     489            ffado_ringbuffer_read(m_event_buffer,m_cluster_buffer,cluster_size); 
    490490 
    491491            assert(m_Client); 
     
    501501            bytes2read-=cluster_size; 
    502502 
    503         } else { //  
     503        } else { // 
    504504 
    505505            if(bytes2read>vec[0].len) { 
     
    509509                bytesread=bytes2read; 
    510510            } 
    511              
     511 
    512512            assert(m_Client); 
    513513            xrun = m_Client->processReadBlock(vec[0].buf, bytesread/cluster_size, offset); 
     
    519519            } 
    520520 
    521             freebob_ringbuffer_read_advance(m_event_buffer, bytesread); 
     521            ffado_ringbuffer_read_advance(m_event_buffer, bytesread); 
    522522            bytes2read -= bytesread; 
    523523        } 
     
    528528 
    529529    decrementFrameCounter(nbframes); 
    530      
     530 
    531531    return true; 
    532532} 
     
    534534/** 
    535535 * @brief Sets the buffer tail timestamp. 
    536  *  
     536 * 
    537537 * 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 
    539539 * \ref new_timestamp. 
    540  *  
     540 * 
    541541 * This is thread safe. 
    542542 * 
    543543 * @note considers offsets 
    544  *  
    545  * @param new_timestamp  
     544 * 
     545 * @param new_timestamp 
    546546 */ 
    547547void TimestampedBuffer::setBufferTailTimestamp(uint64_t new_timestamp) { 
     
    550550    int64_t ts=new_timestamp; 
    551551    ts += m_tick_offset; 
    552      
     552 
    553553    if (ts >= (int64_t)m_wrap_at) { 
    554554        ts -= m_wrap_at; 
     
    556556        ts += m_wrap_at; 
    557557    } 
    558      
     558 
    559559#ifdef DEBUG 
    560560    if (new_timestamp >= m_wrap_at) { 
    561561        debugWarning("timestamp not wrapped: %llu\n",new_timestamp); 
    562     }     
     562    } 
    563563    if ((ts >= (int64_t)m_wrap_at) || (ts < 0 )) { 
    564564        debugWarning("ts not wrapped correctly: %lld\n",ts); 
     
    567567 
    568568    pthread_mutex_lock(&m_framecounter_lock); 
    569      
     569 
    570570    m_buffer_tail_timestamp = ts; 
    571      
     571 
    572572    m_dll_e2=m_update_period * m_nominal_rate; 
    573573    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 
    577577    debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "Set buffer tail timestamp for (%p) to %11llu => %11lld, NTS=%llu, DLL2=%f, RATE=%f\n", 
    578578                this, new_timestamp, ts, m_buffer_next_tail_timestamp, m_dll_e2, m_nominal_rate); 
     
    582582/** 
    583583 * @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 
    586586 * \ref new_timestamp. This does not consider offsets, because it's use is to 
    587587 * make sure the following is true after setBufferHeadTimestamp(x): 
    588588 *   x == getBufferHeadTimestamp() 
    589  *  
     589 * 
    590590 * This is thread safe. 
    591  *  
    592  * @param new_timestamp  
     591 * 
     592 * @param new_timestamp 
    593593 */ 
    594594void TimestampedBuffer::setBufferHeadTimestamp(uint64_t new_timestamp) { 
    595      
     595 
    596596#ifdef DEBUG 
    597597    if (new_timestamp >= m_wrap_at) { 
    598598        debugWarning("timestamp not wrapped: %llu\n",new_timestamp); 
    599     }     
     599    } 
    600600#endif 
    601601 
     
    603603 
    604604    pthread_mutex_lock(&m_framecounter_lock); 
    605      
     605 
    606606    // add the time 
    607607    ts += (int64_t)(m_nominal_rate * (float)m_framecounter); 
    608      
     608 
    609609    if (ts >= (int64_t)m_wrap_at) { 
    610610        ts -= m_wrap_at; 
     
    612612        ts += m_wrap_at; 
    613613    } 
    614      
     614 
    615615    m_buffer_tail_timestamp = ts; 
    616      
     616 
    617617    m_dll_e2=m_update_period * m_nominal_rate; 
    618618    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 
    622622    debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "Set buffer head timestamp for (%p) to %11llu => %11lld, NTS=%llu, DLL2=%f, RATE=%f\n", 
    623623                this, new_timestamp, ts, m_buffer_next_tail_timestamp, m_dll_e2, m_nominal_rate); 
     
    627627/** 
    628628 * \brief return the timestamp of the first frame in the buffer 
    629  *  
     629 * 
    630630 * 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 
    632632 * for which this timestamp is valid. 
    633633 * 
     
    644644/** 
    645645 * \brief return the timestamp of the last frame in the buffer 
    646  *  
     646 * 
    647647 * 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 
    649649 * value for which this timestamp is valid. 
    650650 * 
     
    662662 * @brief Get timestamp for a specific position from the buffer tail 
    663663 * 
    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 
    665665 * buffer tail 
    666666 * 
     
    672672    // ts(x) = m_buffer_tail_timestamp - 
    673673    //         (m_buffer_next_tail_timestamp - m_buffer_tail_timestamp)/(samples_between_updates)*(x) 
    674      
     674 
    675675    int64_t diff=m_buffer_next_tail_timestamp - m_buffer_tail_timestamp; 
    676676    if (diff < 0) diff += m_wrap_at; 
    677      
     677 
    678678    float rate=(float)diff / (float)m_update_period; 
    679      
     679 
    680680    int64_t timestamp; 
    681      
     681 
    682682    pthread_mutex_lock(&m_framecounter_lock); 
    683683 
     
    685685 
    686686    pthread_mutex_unlock(&m_framecounter_lock); 
    687      
     687 
    688688    if(timestamp >= (int64_t)m_wrap_at) { 
    689689        timestamp -= m_wrap_at; 
     
    691691        timestamp += m_wrap_at; 
    692692    } 
    693      
     693 
    694694    return (uint64_t)timestamp; 
    695695} 
     
    698698 * @brief Get timestamp for a specific position from the buffer head 
    699699 * 
    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 
    701701 * buffer head 
    702702 * 
     
    721721/** 
    722722 * Decrements the frame counter in a thread safe way. 
    723  *  
     723 * 
    724724 * @param nbframes number of frames to decrement 
    725725 */ 
     
    741741 */ 
    742742void TimestampedBuffer::incrementFrameCounter(int nbframes, uint64_t new_timestamp) { 
    743      
     743 
    744744    // add the offsets 
    745745    int64_t diff=m_buffer_next_tail_timestamp - m_buffer_tail_timestamp; 
    746746    if (diff < 0) diff += m_wrap_at; 
    747      
     747 
     748#ifdef DEBUG 
    748749    float rate=(float)diff / (float)m_update_period; 
    749          
     750#endif 
     751 
    750752    int64_t ts=new_timestamp; 
    751753    ts += (int64_t)m_tick_offset; 
    752      
     754 
    753755    if (ts >= (int64_t)m_wrap_at) { 
    754756        ts -= m_wrap_at; 
     
    756758        ts += m_wrap_at; 
    757759    } 
    758      
     760 
    759761    debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "Setting buffer tail timestamp for (%p) to %11llu => %11lld\n", 
    760762                this, new_timestamp, ts); 
    761      
     763 
    762764#ifdef DEBUG 
    763765    if (new_timestamp >= m_wrap_at) { 
    764766        debugWarning("timestamp not wrapped: %llu\n",new_timestamp); 
    765     }     
     767    } 
    766768    if ((ts >= (int64_t)m_wrap_at) || (ts < 0 )) { 
    767769        debugWarning("ts not wrapped correctly: %lld\n",ts); 
     
    771773    // update the DLL 
    772774    diff = ts-(int64_t)m_buffer_next_tail_timestamp; 
    773      
     775 
    774776#ifdef DEBUG 
    775777    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", 
    777779            this, diff, ts, m_buffer_next_tail_timestamp); 
    778780    } 
     
    782784    // diff = diff * nbframes/m_update_period 
    783785    // m_buffer_next_tail_timestamp = m_buffer_tail_timestamp + diff 
    784      
     786 
    785787    debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "(%p): diff=%lld ", 
    786788                this, diff); 
    787                      
     789 
    788790    // the maximal difference we can allow (64secs) 
    789791    const int64_t max=m_wrap_at/2; 
    790      
     792 
    791793    if(diff > max) { 
    792794        diff -= m_wrap_at; 
     
    794796        diff += m_wrap_at; 
    795797    } 
    796      
     798 
    797799    float err=diff; 
    798      
     800 
    799801    debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, "diff2=%lld err=%f\n", 
    800802                    diff, err); 
    801803    debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "B: FC=%10u, TS=%011llu, NTS=%011llu\n", 
    802804                    m_framecounter, m_buffer_tail_timestamp, m_buffer_next_tail_timestamp); 
    803      
     805 
    804806    pthread_mutex_lock(&m_framecounter_lock); 
    805807    m_framecounter += nbframes; 
    806      
     808 
    807809    m_buffer_tail_timestamp=m_buffer_next_tail_timestamp; 
    808810    m_buffer_next_tail_timestamp += (int64_t)(m_dll_b * err + m_dll_e2); 
    809      
     811 
    810812    m_dll_e2 += m_dll_c*err; 
    811      
     813 
    812814    debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "U: FC=%10u, TS=%011llu, NTS=%011llu\n", 
    813815                    m_framecounter, m_buffer_tail_timestamp, m_buffer_next_tail_timestamp); 
    814      
     816 
    815817    if (m_buffer_next_tail_timestamp >= m_wrap_at) { 
    816818        debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "Unwrapping next tail timestamp: %011llu", 
    817819                m_buffer_next_tail_timestamp); 
    818                  
     820 
    819821        m_buffer_next_tail_timestamp -= m_wrap_at; 
    820          
     822 
    821823        debugOutputShort(DEBUG_LEVEL_VERY_VERBOSE, " => %011llu\n", 
    822824                m_buffer_next_tail_timestamp); 
    823825 
    824826    } 
    825      
     827 
    826828    debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "A: TS=%011llu, NTS=%011llu, DLLe2=%f, RATE=%f\n", 
    827829                m_buffer_tail_timestamp, m_buffer_next_tail_timestamp, m_dll_e2, rate); 
    828      
     830 
    829831    pthread_mutex_unlock(&m_framecounter_lock); 
    830      
     832 
    831833    if(m_buffer_tail_timestamp>=m_wrap_at) { 
    832834        debugError("Wrapping failed for m_buffer_tail_timestamp! %011llu\n",m_buffer_tail_timestamp); 
    833835        debugOutput(DEBUG_LEVEL_VERY_VERBOSE, " IN=%011lld, TS=%011llu, NTS=%011llu\n", 
    834836                    ts, m_buffer_tail_timestamp, m_buffer_next_tail_timestamp); 
    835          
     837 
    836838    } 
    837839    if(m_buffer_next_tail_timestamp>=m_wrap_at) { 
     
    840842                    ts, m_buffer_tail_timestamp, m_buffer_next_tail_timestamp); 
    841843    } 
    842      
     844 
    843845    // this DLL allows the calculation of any sample timestamp relative to the buffer tail, 
    844846    // to the next period and beyond (through extrapolation) 
     
    846848    // ts(x) = m_buffer_tail_timestamp + 
    847849    //         (m_buffer_next_tail_timestamp - m_buffer_tail_timestamp)/(samples_between_updates)*x 
    848      
     850 
    849851} 
    850852 
     
    853855 */ 
    854856void TimestampedBuffer::dumpInfo() { 
    855      
     857 
    856858    uint64_t ts_head, fc; 
    857859    getBufferHeadTimestamp(&ts_head,&fc); 
    858      
     860 
     861#ifdef DEBUG 
    859862    int64_t diff=(int64_t)ts_head - (int64_t)m_buffer_tail_timestamp; 
     863#endif 
    860864 
    861865    debugOutputShort( DEBUG_LEVEL_NORMAL, "  TimestampedBuffer (%p) info:\n",this); 
  • trunk/libffado/src/libutil/TimestampedBuffer.h

    r419 r445  
    22 
    33/* 
    4  *   FreeBob Streaming API 
    5  *   FreeBob = Firewire (pro-)audio for linux 
    6  * 
    7  *   http://freebob.sf.net 
     4 *   FFADO Streaming API 
     5 *   FFADO = Firewire (pro-)audio for linux 
     6 * 
     7 *   http://ffado.sf.net 
    88 * 
    99 *   Copyright (C) 2005,2006,2007 Pieter Palmers <pieterpalmers@users.sourceforge.net> 
     
    2323 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
    2424 * 
    25  *  
     25 * 
    2626 * 
    2727 */ 
    28 #ifndef __FREEBOB_TIMESTAMPEDBUFFER__ 
    29 #define __FREEBOB_TIMESTAMPEDBUFFER__ 
     28#ifndef __FFADO_TIMESTAMPEDBUFFER__ 
     29#define __FFADO_TIMESTAMPEDBUFFER__ 
    3030 
    3131#include "../debugmodule/debugmodule.h" 
     
    3939 * \brief Class implementing a frame buffer that is time-aware 
    4040 * 
    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 
    4242 * are written to the buffer, the timestamp corresponding to the last frame 
    4343 * in the buffer is updated. This allows to calculate the timestamp of any 
     
    5050 * - event_size: the storage size of the events (in bytes) (setEventSize()) 
    5151 * 
    52  * The total size of the buffer (in bytes) is at least  
     52 * The total size of the buffer (in bytes) is at least 
    5353 * buff_size*events_per_frame*event_size. 
    5454 * 
     
    6363 * 
    6464 * 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 
    6666 * timestamps using (...). 
    6767 * 
    68  * There are two methods of reading and writing to the buffer.  
     68 * There are two methods of reading and writing to the buffer. 
    6969 * 
    7070 * The first method uses conventional readFrames() and writeFrames() functions. 
    7171 * 
    72  * The second method makes use of the TimestampedBufferClient interface. When a  
     72 * The second method makes use of the TimestampedBufferClient interface. When a 
    7373 * TimestampedBuffer is created, it is required that a TimestampedBufferClient is 
    7474 * registered. This client implements the processReadBlock and processWriteBlock 
    7575 * functions. These are block processing 'callbacks' that allow zero-copy processing 
    7676 * 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 
    7878 * TimestampedBuffer. 
    7979 * 
     
    8686    TimestampedBuffer(TimestampedBufferClient *); 
    8787    virtual ~TimestampedBuffer(); 
    88      
     88 
    8989    bool writeFrames(unsigned int nbframes, char *data, uint64_t ts); 
    9090    bool readFrames(unsigned int nbframes, char *data); 
    91      
     91 
    9292    bool blockProcessWriteFrames(unsigned int nbframes, int64_t ts); 
    9393    bool blockProcessReadFrames(unsigned int nbframes); 
    94      
     94 
    9595    bool init(); 
    9696    bool prepare(); 
    9797    bool reset(); 
    98      
     98 
    9999    bool setEventSize(unsigned int s); 
    100100    bool setEventsPerFrame(unsigned int s); 
    101101    bool setBufferSize(unsigned int s); 
    102102    unsigned int getBufferSize() {return m_buffer_size;}; 
    103      
     103 
    104104    bool setWrapValue(uint64_t w); 
    105      
     105 
    106106    unsigned int getBufferFill(); 
    107      
     107 
    108108    // timestamp stuff 
    109109    int getFrameCounter() {return m_framecounter;}; 
     
    111111    void getBufferHeadTimestamp(uint64_t *ts, uint64_t *fc); 
    112112    void getBufferTailTimestamp(uint64_t *ts, uint64_t *fc); 
    113      
     113 
    114114    void setBufferTailTimestamp(uint64_t new_timestamp); 
    115115    void setBufferHeadTimestamp(uint64_t new_timestamp); 
    116      
     116 
    117117    uint64_t getTimestampFromTail(int nframes); 
    118118    uint64_t getTimestampFromHead(int nframes); 
    119      
     119 
    120120    // buffer offset stuff 
    121121    /// return the tick offset value 
    122122    signed int getTickOffset() {return m_tick_offset;}; 
    123      
     123 
    124124    bool setFrameOffset(int nframes); 
    125125    bool setTickOffset(int nframes); 
    126      
     126 
    127127    // dll stuff 
    128128    bool setNominalRate(float r); 
    129129    float getRate(); 
    130      
     130 
    131131    bool setUpdatePeriod(unsigned int t); 
    132      
     132 
    133133    // misc stuff 
    134134    void dumpInfo(); 
     
    142142protected: 
    143143 
    144     freebob_ringbuffer_t * m_event_buffer; 
     144    ffado_ringbuffer_t * m_event_buffer; 
    145145    char* m_cluster_buffer; 
    146      
     146 
    147147    unsigned int m_event_size; // the size of one event 
    148148    unsigned int m_events_per_frame; // the number of events in a frame 
     
    150150    unsigned int m_bytes_per_frame; 
    151151    unsigned int m_bytes_per_buffer; 
    152      
     152 
    153153    uint64_t m_wrap_at; // value to wrap at 
    154      
     154 
    155155    TimestampedBufferClient *m_Client; 
    156156 
    157157    DECLARE_DEBUG_MODULE; 
    158      
     158 
    159159private: 
    160160    // the framecounter gives the number of frames in the buffer 
    161161    signed int m_framecounter; 
    162      
     162 
    163163    // the offset that define the timing of the buffer 
    164164    signed int m_tick_offset; 
    165      
     165 
    166166    // the buffer tail timestamp gives the timestamp of the last frame 
    167167    // that was put into the buffer 
    168168    uint64_t   m_buffer_tail_timestamp; 
    169169    uint64_t   m_buffer_next_tail_timestamp; 
    170      
     170 
    171171    // this mutex protects the access to the framecounter 
    172172    // and the buffer head timestamp. 
     
    177177    float m_dll_b; 
    178178    float m_dll_c; 
    179      
     179 
    180180    float m_nominal_rate; 
    181181    unsigned int m_update_period; 
     
    197197} // end of namespace Util 
    198198 
    199 #endif /* __FREEBOB_TIMESTAMPEDBUFFER__ */ 
    200  
    201  
     199#endif /* __FFADO_TIMESTAMPEDBUFFER__ */ 
     200 
     201 
  • trunk/libffado/src/libutil/unittests.cpp

    r435 r445  
    11/* unittests.cpp 
    2  * Copyright (C) 2006,07 by Daniel Wagner 
     2 * Copyright (C) 2005-2007 by by Daniel Wagner 
    33 * 
    4  * This file is part of FreeBoB. 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    56 * 
    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 
    710 * it under the terms of the GNU General Public License as published by 
    811 * the Free Software Foundation; either version 2 of the License, or 
    912 * (at your option) any later version. 
    10  * FreeBoB is distributed in the hope that it will be useful, 
     13 * FFADO is distributed in the hope that it will be useful, 
    1114 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    1215 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     
    1417 * 
    1518 * You should have received a copy of the GNU General Public License 
    16  * along with FreeBoB; if not, write to the Free Software 
     19 * along with FFADO; if not, write to the Free Software 
    1720 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
    1821 * MA 02111-1307 USA. 
     
    416419    testOC() {}; 
    417420    ~testOC() {}; 
    418      
     421 
    419422    bool test() { 
    420423        bool result=true; 
    421          
     424 
    422425        Option op1=Option(); 
    423426        result &= TEST_SHOULD_RETURN_FALSE(addOption(op1)); 
    424          
     427 
    425428        op1=Option("option1"); 
    426429        result &= TEST_SHOULD_RETURN_FALSE(addOption(op1)); 
     
    432435        result &= TEST_SHOULD_RETURN_FALSE(hasOption(op1)); 
    433436 
    434          
     437 
    435438        op1=Option("option1", (int64_t)1); 
    436439        result &= TEST_SHOULD_RETURN_TRUE(addOption(op1)); 
     
    440443        result &= TEST_SHOULD_RETURN_FALSE(hasOption(op1)); 
    441444 
    442          
     445 
    443446        op1=Option("option1", (int64_t)(-1)); 
    444447        result &= TEST_SHOULD_RETURN_TRUE(addOption(op1)); 
     
    447450        result &= TEST_SHOULD_RETURN_FALSE(addOption(op2)); 
    448451 
    449          
     452 
    450453        op2=Option("option2", (double)(1.75)); 
    451454        result &= TEST_SHOULD_RETURN_TRUE(addOption(op2)); 
     
    454457        result &= TEST_SHOULD_RETURN_TRUE(addOption(op3)); 
    455458 
    456          
     459 
    457460        result &= TEST_SHOULD_RETURN_TRUE(countOptions() == 3); 
    458461 
     
    466469        } 
    467470        result &= TEST_SHOULD_RETURN_TRUE(i==3); 
    468          
     471 
    469472        clearOptions(); 
    470473        return result; 
    471474    } 
    472      
     475 
    473476    void prepare() { 
    474477        Option op1=Option("option1", (int64_t)(-1)); 
     
    476479            printf( "prepare: could not add valid option (3)\n" ); 
    477480        } 
    478          
     481 
    479482        Option op2=Option("option2", (double)(1.75)); 
    480483        if(!addOption(op2)) { 
     
    494497    testOC oc; 
    495498    result &= TEST_SHOULD_RETURN_TRUE(oc.test()); 
    496      
     499 
    497500    // now manipulate it externally 
    498501    oc.prepare(); 
    499      
     502 
    500503    result &= TEST_SHOULD_RETURN_TRUE(oc.hasOption("option1")); 
    501504    result &= TEST_SHOULD_RETURN_TRUE(oc.hasOption("option2")); 
    502505    result &= TEST_SHOULD_RETURN_TRUE(oc.hasOption("option3")); 
    503506    result &= TEST_SHOULD_RETURN_FALSE(oc.hasOption("option4")); 
    504      
     507 
    505508    oc.setOption("option1", 1024); 
    506509    int tst; 
    507510    result &= TEST_SHOULD_RETURN_TRUE(oc.getOption("option1", tst)); 
    508511    result &= TEST_SHOULD_RETURN_TRUE(tst == 1024); 
    509      
     512 
    510513    return result; 
    511514} 
  • 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, 
    1222# but WITHOUT ANY WARRANTY; without even the implied warranty of 
    1323# 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 
    1728# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
    1829 
     
    2334        -I$(top_srcdir) -I$(top_srcdir)/src 
    2435 
    25 lib_LTLIBRARIES = libfreebob.la 
    26  
    27 libfreebob_la_LDFLAGS =                               \ 
     36lib_LTLIBRARIES = libffado.la 
     37 
     38libffado_la_LDFLAGS =                                 \ 
    2839        -version-info $(LT_VERSION) $(LIBRAW1394_LIBS)  \ 
    2940        $(LIBIEC61883_LIBS) $(LIBAVC1394_LIBS)          \ 
     
    3142        -lpthread -lrt 
    3243 
    33 libfreebob_la_LIBADD = -lrt 
     44libffado_la_LIBADD = -lrt 
    3445 
    3546noinst_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 \ 
    4051        devicemanager.h fbtypes.h iavdevice.h threads.h bebob/bebob_avdevice.h \ 
    4152        bebob/bebob_avdevice_subunit.h bebob/bebob_avplug.h bebob/bebob_dl_bcd.h bebob/bebob_dl_codes.h \ 
     
    6475 
    6576# common sources 
    66 libfreebob_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.cpp 
     77libffado_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 
    114125 
    115126# class specific sources 
    116127bebob_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.cpp 
     128           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 
    125136 
    126137motu_src = \ 
    127         motu/motu_avdevice.cpp \ 
    128         libstreaming/MotuPort.cpp \ 
    129         libstreaming/MotuPortInfo.cpp \ 
    130         libstreaming/MotuStreamProcessor.cpp 
     138           motu/motu_avdevice.cpp \ 
     139           libstreaming/MotuPort.cpp \ 
     140           libstreaming/MotuPortInfo.cpp \ 
     141           libstreaming/MotuStreamProcessor.cpp 
    131142 
    132143dice_src = \ 
    133         dice/dice_avdevice.cpp 
     144           dice/dice_avdevice.cpp 
    134145 
    135146bounce_src = \ 
    136         bounce/bounce_avdevice.cpp \ 
    137         bounce/bounce_slave_avdevice.cpp \ 
    138         libstreaming/AmdtpSlaveStreamProcessor.cpp 
     147           bounce/bounce_avdevice.cpp \ 
     148           bounce/bounce_slave_avdevice.cpp \ 
     149           libstreaming/AmdtpSlaveStreamProcessor.cpp 
    139150 
    140151metric_halo_src = \ 
    141         metrichalo/mh_avdevice.cpp 
     152           metrichalo/mh_avdevice.cpp 
    142153 
    143154rme_src = \ 
    144         rme/rme_avdevice.cpp 
     155           rme/rme_avdevice.cpp 
    145156 
    146157amdtp_src = \ 
    147         libstreaming/AmdtpPort.cpp \ 
    148         libstreaming/AmdtpPortInfo.cpp \ 
    149         libstreaming/AmdtpStreamProcessor.cpp 
     158           libstreaming/AmdtpPort.cpp \ 
     159           libstreaming/AmdtpPortInfo.cpp \ 
     160           libstreaming/AmdtpStreamProcessor.cpp 
    150161 
    151162# data 
     
    163174 
    164175#  class specific 
    165 bebob_bin = freebob-downloader freebob-sync 
    166  
    167 freebob_downloader_SOURCES = freebob-downloader.cpp 
    168 freebob_downloader_LDADD = $(top_builddir)/src/libfreebob.la 
    169  
    170 freebob_sync_SOURCES = freebob-sync.cpp 
    171 freebob_sync_LDADD = $(top_builddir)/src/libfreebob.la 
     176bebob_bin = bridgeco-downloader bebob-sync 
     177 
     178bridgeco_downloader_SOURCES = bridgeco-downloader.cpp 
     179bridgeco_downloader_LDADD = $(top_builddir)/src/libffado.la 
     180 
     181bebob_sync_SOURCES = bebob-sync.cpp 
     182bebob_sync_LDADD = $(top_builddir)/src/libffado.la 
    172183 
    173184# programs not intended for installation 
    174185# generic 
    175186noinst_PROGRAMS = test-dll test-debugmodule \ 
    176                   test-unittests-util test-unittests-osc \ 
    177                   test-ser 
     187                     test-unittests-util test-unittests-osc \ 
     188                     test-ser 
    178189 
    179190test_dll_SOURCES = libutil/test-dll.cpp 
    180 test_dll_LDADD = $(top_builddir)/src/libfreebob.la 
     191test_dll_LDADD = $(top_builddir)/src/libffado.la 
    181192 
    182193test_debugmodule_SOURCES = debugmodule/test_debugmodule.cpp 
    183 test_debugmodule_LDADD = $(top_builddir)/src/libfreebob.la 
     194test_debugmodule_LDADD = $(top_builddir)/src/libffado.la 
    184195 
    185196test_unittests_util_SOURCES = libutil/unittests.cpp 
    186 test_unittests_util_LDADD = $(top_builddir)/src/libfreebob.la 
     197test_unittests_util_LDADD = $(top_builddir)/src/libffado.la 
    187198 
    188199test_unittests_osc_SOURCES = libosc/unittests.cpp 
    189 test_unittests_osc_LDADD = $(top_builddir)/src/libfreebob.la 
     200test_unittests_osc_LDADD = $(top_builddir)/src/libffado.la 
    190201 
    191202test_ser_SOURCES = ser.cpp 
    192 test_ser_LDADD = $(top_builddir)/src/libfreebob.la 
     203test_ser_LDADD = $(top_builddir)/src/libffado.la 
    193204 
    194205# build customisation 
    195206 
    196207if BUILD_BEBOB 
    197 libfreebob_la_SOURCES += $(bebob_src) 
     208libffado_la_SOURCES += $(bebob_src) 
    198209bin_PROGRAMS += $(bebob_bin) 
    199210noinst_PROGRAMS += $(bebob_noinst) 
     
    202213 
    203214if BUILD_BOUNCE 
    204 libfreebob_la_SOURCES += $(bounce_src) 
     215libffado_la_SOURCES += $(bounce_src) 
    205216bin_PROGRAMS += $(bounce_bin) 
    206217noinst_PROGRAMS += $(bounce_noinst) 
     
    209220 
    210221if BUILD_DICE 
    211 libfreebob_la_SOURCES += $(dice_src) 
     222libffado_la_SOURCES += $(dice_src) 
    212223bin_PROGRAMS += $(dice_bin) 
    213224noinst_PROGRAMS += $(dice_noinst) 
     
    216227 
    217228if BUILD_MOTU 
    218 libfreebob_la_SOURCES += $(motu_src) 
     229libffado_la_SOURCES += $(motu_src) 
    219230bin_PROGRAMS += $(motu_bin) 
    220231noinst_PROGRAMS += $(motu_noinst) 
     
    223234 
    224235if BUILD_METRIC_HALO 
    225 libfreebob_la_SOURCES += $(metric_halo_src) 
     236libffado_la_SOURCES += $(metric_halo_src) 
    226237bin_PROGRAMS += $(metric_halo_bin) 
    227238noinst_PROGRAMS += $(metric_halo_noinst) 
     
    230241 
    231242if BUILD_RME 
    232 libfreebob_la_SOURCES += $(rme_src) 
     243libffado_la_SOURCES += $(rme_src) 
    233244bin_PROGRAMS += $(rme_bin) 
    234245noinst_PROGRAMS += $(rme_noinst) 
     
    237248 
    238249if BUILD_AMDTP 
    239 libfreebob_la_SOURCES += $(amdtp_src) 
     250libffado_la_SOURCES += $(amdtp_src) 
    240251bin_PROGRAMS += $(amdtp_bin) 
    241252noinst_PROGRAMS += $(amdtp_noinst) 
  • trunk/libffado/src/maudio/fw410.xml

    r303 r445  
    11<?xml version="1.0"?> 
    2 <FreeBoBConnectionInfo> 
     2<FFADOConnectionInfo> 
    33  <Device> 
    44    <NodeId>0</NodeId> 
     
    257257    </StreamFormats> 
    258258  </Device> 
    259 </FreeBoBConnectionInfo> 
     259</FFADOConnectionInfo> 
  • trunk/libffado/src/maudio/fwap.xml

    r339 r445  
    11<?xml version="1.0"?> 
    2 <FreeBoBConnectionInfo> 
     2<FFADOConnectionInfo> 
    33  <Device> 
    44    <NodeId>0</NodeId> 
     
    155155    </StreamFormats> 
    156156  </Device> 
    157 </FreeBoBConnectionInfo> 
     157</FFADOConnectionInfo> 
  • trunk/libffado/src/maudio/maudio_avdevice.cpp

    r436 r445  
    1 /* maudio_avdevice.cpp 
    2  * Copyright (C) 2006 by Daniel Wagner 
     1/* 
     2 * Copyright (C) 2005-2007 by Daniel Wagner 
    33 * 
    4  * This file is part of FreeBoB. 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    56 * 
    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, 
    1114 * 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. 
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     16 * Lesser General Public License for more details. 
    1417 * 
    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. 
     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 
    1922 */ 
     23 
    2024#include "maudio/maudio_avdevice.h" 
    2125#include "bebob/bebob_avdevice.h" 
     
    9195    { 
    9296        if ( ( supportedDeviceList[i].vendor_id == vendorId ) 
    93              && ( supportedDeviceList[i].model_id == modelId )  
     97             && ( supportedDeviceList[i].model_id == modelId ) 
    9498           ) 
    9599        { 
     
    103107                m_model->vendor_name, m_model->model_name); 
    104108    } else return false; 
    105      
     109 
    106110    return true; 
    107111} 
  • 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 
    34 * 
    4  * This file is part of FreeBoB. 
     5 * This file is part of FFADO 
     6 * FFADO = Free Firewire (pro-)audio drivers for linux 
    57 * 
    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, 
    1115 * 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. 
     16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     17 * Lesser General Public License for more details. 
    1418 * 
    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 * 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 
    1923 */ 
    2024 
     
    4347    unsigned int model_id; 
    4448    char *vendor_name; 
    45     char *model_name;  
     49    char *model_name; 
    4650    char *filename; 
    4751}; 
     
    5054public: 
    5155    AvDevice( std::auto_ptr<ConfigRom>( configRom ), 
    52              Ieee1394Service& ieee1394Service, 
     56          Ieee1394Service& ieee1394Service, 
    5357              int nodeId ); 
    5458    virtual ~AvDevice(); 
     
    5660    static bool probe( ConfigRom& configRom ); 
    5761    bool discover(); 
    58      
     62 
    5963    void showDevice(); 
    60      
     64 
    6165    bool setSamplingFrequency( ESamplingFrequency samplingFrequency ); 
    6266    int getSamplingFrequency( ); 
  • trunk/libffado/src/maudio/refdesign.xml

    r298 r445  
    11<?xml version="1.0"?> 
    2 <FreeBoBConnectionInfo> 
     2<FFADOConnectionInfo> 
    33  <Device> 
    44    <NodeId>1</NodeId> 
     
    190190    </StreamFormats> 
    191191  </Device> 
    192 </FreeBoBConnectionInfo> 
     192</FFADOConnectionInfo> 
  • trunk/libffado/src/metrichalo/mh_avdevice.cpp

    r436 r445  
    1 /* mh_avdevice.cpp 
    2  * Copyright (C) 2007 by Pieter Palmers 
     1/* 
     2 * Copyright (C) 2005-2007 by Pieter Palmers 
    33 * 
    4  * This file is part of FreeBob. 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    56 * 
    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, 
    1114 * 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. 
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     16 * Lesser General Public License for more details. 
    1417 * 
    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. 
     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 
    1922 */ 
    2023 
     
    5255    :  IAvDevice( configRom, ieee1394service, nodeId ) 
    5356    , m_model( NULL ) 
    54      
     57 
    5558{ 
    5659    debugOutput( DEBUG_LEVEL_VERBOSE, "Created MetricHalo::MHAvDevice (NodeID %d)\n", 
     
    7477    { 
    7578        if ( ( supportedDeviceList[i].vendor_id == vendorId ) 
    76              && ( supportedDeviceList[i].model_id == modelId )  
     79             && ( supportedDeviceList[i].model_id == modelId ) 
    7780           ) 
    7881        { 
     
    9598    { 
    9699        if ( ( supportedDeviceList[i].vendor_id == vendorId ) 
    97              && ( supportedDeviceList[i].model_id == modelId )  
     100             && ( supportedDeviceList[i].model_id == modelId ) 
    98101           ) 
    99102        { 
     
    111114} 
    112115 
    113 int  
     116int 
    114117MHAvDevice::getSamplingFrequency( ) { 
    115118    return 0; 
     
    150153} 
    151154 
    152 int  
     155int 
    153156MHAvDevice::getStreamCount() { 
    154157    return 0; 
  • trunk/libffado/src/metrichalo/mh_avdevice.h

    r436 r445  
    1 /* mh_avdevice.h 
    2  * Copyright (C) 2007 by Pieter Palmers 
     1/* 
     2 * Copyright (C) 2005-2007 by Pieter Palmers 
    33 * 
    4  * This file is part of FreeBob. 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    56 * 
    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, 
    1114 * 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. 
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     16 * Lesser General Public License for more details. 
    1417 * 
    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. 
     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 
    1922 */ 
    2023 
     
    4548public: 
    4649    MHAvDevice( std::auto_ptr<ConfigRom>( configRom ), 
    47              Ieee1394Service& ieee1394Service, 
    48                  int nodeId ); 
     50          Ieee1394Service& ieee1394Service, 
     51          int nodeId ); 
    4952    virtual ~MHAvDevice(); 
    5053 
     
    6972    signed int getIsoRecvChannel(void); 
    7073    signed int getIsoSendChannel(void); 
    71    
     74 
    7275protected: 
    7376    struct VendorModelEntry *m_model; 
  • trunk/libffado/src/motu/motu_avdevice.cpp

    r436 r445  
    1 /* motu_avdevice.cpp 
    2  * Copyright (C) 2006,2007 by Pieter Palmers 
    3  * Copyright (C) 2006 by Jonathan Woithe 
     1/* 
     2 * Copyright (C) 2005-2007 by Pieter Palmers 
     3 * Copyright (C) 2005-2007 by Jonathan Woithe 
    44 * 
    5  * This file is part of FreeBob. 
     5 * This file is part of FFADO 
     6 * FFADO = Free Firewire (pro-)audio drivers for linux 
    67 * 
    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, 
    1215 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    14  * GNU General Public License for more details. 
     16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     17 * Lesser General Public License for more details. 
    1518 * 
    16  * You should have received a copy of the GNU General Public License 
    17  * along with FreeBob; if not, write to the Free Software 
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
    19  * MA 02111-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 
    2023 */ 
     24 
    2125#include "motu/motu_avdevice.h" 
    2226 
     
    6266    , m_receiveProcessor ( 0 ) 
    6367    , m_transmitProcessor ( 0 ) 
    64      
     68 
    6569{ 
    6670    debugOutput( DEBUG_LEVEL_VERBOSE, "Created Motu::MotuDevice (NodeID %d)\n", 
     
    9599    { 
    96100        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 ) 
    100104           ) 
    101105        { 
     
    120124    { 
    121125        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 ) 
    125129           ) 
    126130        { 
     
    139143} 
    140144 
    141 int  
     145int 
    142146MotuDevice::getSamplingFrequency( ) { 
    143147/* 
    144148 * Retrieve the current sample rate from the MOTU device. 
    145149 */ 
    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; 
    166170} 
    167171 
     
    172176 * Set the MOTU device's samplerate. 
    173177 */ 
    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 rates 
    202                        if (m_motu_model == MOTUFW_MODEL_TRAVELER) { 
    203                                new_rate = MOTUFW_RATE_BASE_44100 | MOTUFW_RATE_MULTIPLIER_4X; 
    204                                cancel_adat = true; 
    205                        } else 
    206                                supported=false; 
    207                        break; 
    208                case eSF_192000Hz: 
    209                        // Currently only the Traveler supports 4x sample rates 
    210                        if (m_motu_model == MOTUFW_MODEL_TRAVELER) { 
    211                                new_rate = MOTUFW_RATE_BASE_48000 | MOTUFW_RATE_MULTIPLIER_4X; 
    212                                cancel_adat = true; 
    213                        } else 
    214                                supported=false; 
    215                        break; 
    216                default: 
    217                        supported=false; 
    218        
    219  
    220        // Update the clock control register.  FIXME: while this is now rather 
    221        // comprehensive there may still be a need to manipulate MOTUFW_REG_CLK_CTRL 
    222        // 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 has 
    227                // been selected) then do so before changing the sample rate.  At 
    228                // this stage it will be up to the user to re-enable the optical 
    229                // 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 seems 
    238                // to be set when this register is written to although the 
    239                // reason isn't currently known.  When we set it, it appears 
    240                // to prevent output being produced so we'll leave it unset 
    241                // until we work out what's going on.  Other systems write 
    242                // to MOTUFW_REG_CLK_CTRL multiple times, so that may be 
    243                // 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                                else 
    264                                        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; 
    288292} 
    289293 
     
    312316MotuDevice::prepare() { 
    313317 
    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 be 
    324        // refined somewhat since this is currently based on a rudimentary 
    325        // understanding of the iso protocol. 
    326        // Currently we assume the following. 
    327        //   * Ack/iso gap = 0.05 us 
    328        //   * DATA_PREFIX = 0.16 us 
    329        //   * DATA_END    = 0.26 us 
    330        // These numbers are the worst-case figures given in the ieee1394 
    331        // standard.  This gives approximately 0.5 us of overheads per 
    332        // packet - around 25 bandwidth allocation units (from the ieee1394 
    333        // standard 1 bandwidth allocation unit is 125/6144 us).  We further 
    334        // assume the MOTU is running at S400 (which it should be) so one 
    335        // allocation unit is equivalent to 1 transmitted byte; thus the 
    336        // bandwidth allocation required for the packets themselves is just 
    337        // the size of the packet.  We allocate based on the maximum packet 
    338        // size (1160 bytes at 192 kHz) so the sampling frequency can be 
    339        // 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 done 
    344        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 deallocate 
    355                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 the 
    368        // 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 processor 
    376        debugOutput(DEBUG_LEVEL_VERBOSE,"Adding ports to receive processor\n"); 
    377          
    378        char *buff; 
    379        Streaming::Port *p=NULL; 
    380          
    381        // retrieve the ID 
     318    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 
    382386    std::string id=std::string("dev?"); 
    383387    if(!getOption("id", id)) { 
    384388        debugWarning("Could not retrieve id parameter, defauling to 'dev?'\n"); 
    385389    } 
    386      
    387        // Add audio capture ports 
    388        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 each 
    393        // MIDI byte sent using a 3 byte sequence starting at byte 4 of the 
    394        // 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: 
    412416//    asprintf(&buff,"%s_cap_%s",id.c_str(),"myportnamehere"); 
    413417//    p=new Streaming::MotuControlPort( 
    414418//            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 
    417421//              // need to pass by extending MotuXXXPort and MotuPortInfo 
    418422//    ); 
     
    431435//    } 
    432436 
    433        // Do the same for the transmit processor 
    434        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 processor 
    445        debugOutput(DEBUG_LEVEL_VERBOSE,"Adding ports to transmit processor\n"); 
    446  
    447        // Add audio playback ports 
    448        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 each 
    453        // MIDI byte transmitted using a 3 byte sequence starting at byte 4 
    454        // 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: 
    472476//    asprintf(&buff,"%s_pbk_%s",id.c_str(),"myportnamehere"); 
    473 //     
     477// 
    474478//    p=new Streaming::MotuControlPort( 
    475479//            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 
    478482//              // need to pass by extending MotuXXXPort and MotuPortInfo 
    479483//    ); 
     
    490494//        } 
    491495//    } 
    492          
    493        return true; 
    494 } 
    495  
    496 int  
     496 
     497    return true; 
     498} 
     499 
     500int 
    497501MotuDevice::getStreamCount() { 
    498        return 2; // one receive, one transmit 
     502     return 2; // one receive, one transmit 
    499503} 
    500504 
    501505Streaming::StreamProcessor * 
    502506MotuDevice::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; 
    512516} 
    513517 
     
    517521quadlet_t isoctrl = ReadRegister(MOTUFW_REG_ISOCTRL); 
    518522 
    519        // NOTE: this assumes that you have two streams 
    520        switch (i) { 
    521        case 0: 
    522                // TODO: do the stuff that is nescessary to make the device 
    523                // receive a stream 
    524  
    525                 // Set the streamprocessor channel to the one obtained by  
    526                // the connection management 
    527                m_receiveProcessor->setChannel(m_iso_recv_channel); 
    528  
    529                // Mask out current transmit settings of the MOTU and replace 
    530                // with new ones.  Turn bit 24 on to enable changes to the 
    531                // MOTU's iso transmit settings when the iso control register 
    532                // 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 device 
    540                // transmit a stream 
    541  
    542                 // Set the streamprocessor channel to the one obtained by  
    543                // the connection management 
    544                m_transmitProcessor->setChannel(m_iso_send_channel); 
    545  
    546                // Mask out current receive settings of the MOTU and replace 
    547                // with new ones.  Turn bit 31 on to enable changes to the 
    548                // MOTU's iso receive settings when the iso control register 
    549                // 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 index 
    557                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; 
    561565} 
    562566 
     
    566570quadlet_t isoctrl = ReadRegister(MOTUFW_REG_ISOCTRL); 
    567571 
    568        // TODO: connection management: break connection 
    569        // cfr the start function 
    570  
    571        // NOTE: this assumes that you have two streams 
    572        switch (i) { 
    573        case 0: 
    574                // Turn bit 22 off to disable iso send by the MOTU.  Turn 
    575                // bit 23 on to enable changes to the MOTU's iso transmit 
    576                // 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.  Turn 
    583                // bit 31 on to enable changes to the MOTU's iso receive 
    584                // 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 index 
    591                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; 
    595599} 
    596600 
    597601signed int MotuDevice::getIsoRecvChannel(void) { 
    598        return m_iso_recv_channel; 
     602    return m_iso_recv_channel; 
    599603} 
    600604 
    601605signed int MotuDevice::getIsoSendChannel(void) { 
    602        return m_iso_send_channel; 
     606    return m_iso_send_channel; 
    603607} 
    604608 
    605609unsigned 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); 
    607611 
    608612debugOutput(DEBUG_LEVEL_VERBOSE, "optical mode: %x %x %x %x\n",dir, reg, reg & MOTUFW_OPTICAL_IN_MODE_MASK, 
    609613reg & MOTUFW_OPTICAL_OUT_MODE_MASK); 
    610614 
    611        if (dir == MOTUFW_DIR_IN) 
    612                return (reg & MOTUFW_OPTICAL_IN_MODE_MASK) >> 8; 
    613        else 
    614                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; 
    615619} 
    616620 
    617621signed 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 current 
    622         // optical port modes.  At this stage it's not completely understood  
    623        // what the "Optical control" register does, so the values it's set to 
    624        // 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                else 
    636                        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                else 
    644                        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); 
    651655} 
    652656 
     
    668672signed int size = 4+6+8*3; 
    669673 
    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 
    671675        // use 
    672676        if (sample_rate <= 96000) 
     
    674678 
    675679        // 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 
    679683        // 2 channels here for 1x or 2x sample rates regardless of the optical 
    680684        // mode. 
     
    692696                size += 4*3; 
    693697 
    694        // When 1x or 2x sample rate is active there are an additional 
    695        // 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; 
    699703 
    700704        // Finally round size up to the next quadlet boundary 
     
    704708 
    705709bool MotuDevice::addPort(Streaming::StreamProcessor *s_processor, 
    706   char *name, enum Streaming::Port::E_Direction direction,  
     710  char *name, enum Streaming::Port::E_Direction direction, 
    707711  int position, int size) { 
    708712/* 
    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. 
    710714 * This just saves the unnecessary replication of what is essentially 
    711715 * boilerplate code.  Note that the port name is freed by this function 
     
    714718Streaming::Port *p=NULL; 
    715719 
    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; 
    732736} 
    733737/* ======================================================================= */ 
    734738 
    735739bool MotuDevice::addDirPorts( 
    736   enum Streaming::Port::E_Direction direction,  
     740  enum Streaming::Port::E_Direction direction, 
    737741  unsigned int sample_rate, unsigned int optical_mode) { 
    738742/* 
     
    750754char *buff; 
    751755 
    752        // retrieve the ID 
     756    // retrieve the ID 
    753757    std::string id=std::string("dev?"); 
    754758    if(!getOption("id", id)) { 
     
    756760    } 
    757761 
    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 data 
    764        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 are 
    778        // 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) this 
    787        // 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                                else 
    797                                        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 long 
    805        // 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 long 
    815        // 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 long 
    825        // 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 the 
    835        // 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; 
    845849} 
    846850/* ======================================================================== */ 
     
    853857quadlet_t quadlet; 
    854858assert(m_p1394Service); 
    855          
     859 
    856860  quadlet = 0; 
    857861  // Note: 1394Service::read() expects a physical ID, not the node id 
  • trunk/libffado/src/motu/motu_avdevice.h

    r436 r445  
    1 /* motu_avdevice.h 
    2  * Copyright (C) 2006 by Pieter Palmers 
    3  * Copyright (C) 2006 Jonathan Woithe 
     1/* 
     2 * Copyright (C) 2005-2007 by Pieter Palmers 
     3 * Copyright (C) 2005-2007 by Jonathan Woithe 
    44 * 
    5  * This file is part of FreeBob. 
     5 * This file is part of FFADO 
     6 * FFADO = Free Firewire (pro-)audio drivers for linux 
    67 * 
    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, 
    1215 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    14  * GNU General Public License for more details. 
     16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     17 * Lesser General Public License for more details. 
    1518 * 
    16  * You should have received a copy of the GNU General Public License 
    17  * along with FreeBob; if not, write to the Free Software 
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
    19  * MA 02111-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 
    2023 */ 
    2124 
     
    4043#define MOTUFW_RATE_MULTIPLIER_MASK     (0x00000030) 
    4144 
    42 #define MOTUFW_OPTICAL_MODE_OFF                0x00 
    43 #define MOTUFW_OPTICAL_MODE_ADAT       0x01 
    44 #define MOTUFW_OPTICAL_MODE_TOSLINK    0x02 
    45 #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) 
    4851 
    49 #define MOTUFW_CLKSRC_MASK             0x00000007 
    50 #define MOTUFW_CLKSRC_INTERNAL         
    51 #define MOTUFW_CLKSRC_ADAT_OPTICAL     
    52 #define MOTUFW_CLKSRC_SPDIF_TOSLINK   
    53 #define MOTUFW_CLKSRC_SMTPE           
    54 #define MOTUFW_CLKSRC_WORDCLOCK               
    55 #define MOTUFW_CLKSRC_ADAT_9PIN               
    56 #define MOTUFW_CLKSRC_AES_EBU         
     52#define MOTUFW_CLKSRC_MASK        0x00000007 
     53#define MOTUFW_CLKSRC_INTERNAL       
     54#define MOTUFW_CLKSRC_ADAT_OPTICAL   
     55#define MOTUFW_CLKSRC_SPDIF_TOSLINK   
     56#define MOTUFW_CLKSRC_SMTPE       
     57#define MOTUFW_CLKSRC_WORDCLOCK       
     58#define MOTUFW_CLKSRC_ADAT_9PIN       
     59#define MOTUFW_CLKSRC_AES_EBU       
    5760 
    58 #define MOTUFW_DIR_IN                 
    59 #define MOTUFW_DIR_OUT                 
    60 #define MOTUFW_DIR_INOUT               (MOTUFW_DIR_IN | MOTUFW_DIR_OUT) 
     61#define MOTUFW_DIR_IN           
     62#define MOTUFW_DIR_OUT           
     63#define MOTUFW_DIR_INOUT        (MOTUFW_DIR_IN | MOTUFW_DIR_OUT) 
    6164 
    6265/* Device registers */ 
    63 #define MOTUFW_REG_ISOCTRL             0x0b00 
    64 #define MOTUFW_REG_OPTICAL_CTRL                0x0b10 
    65 #define MOTUFW_REG_CLK_CTRL            0x0b14 
     66#define MOTUFW_REG_ISOCTRL        0x0b00 
     67#define MOTUFW_REG_OPTICAL_CTRL        0x0b10 
     68#define MOTUFW_REG_CLK_CTRL        0x0b14 
    6669#define MOTUFW_REG_ROUTE_PORT_CONF      0x0c04 
    67 #define MOTUFW_REG_CLKSRC_NAME0                0x0c60 
     70#define MOTUFW_REG_CLKSRC_NAME0        0x0c60 
    6871 
    6972class ConfigRom; 
     
    9396    MotuDevice( std::auto_ptr<ConfigRom>( configRom ), 
    9497          Ieee1394Service& ieee1394Service, 
    95                  int nodeId ); 
     98          int nodeId ); 
    9699    virtual ~MotuDevice(); 
    97100 
     
    110113    bool lock(); 
    111114    bool unlock(); 
    112      
     115 
    113116    bool startStreamByIndex(int i); 
    114117    bool stopStreamByIndex(int i); 
     
    120123 
    121124    signed int getEventSize(unsigned int dir); 
    122    
     125 
    123126protected: 
    124127    signed int       m_motu_model; 
     
    126129    signed int m_iso_recv_channel, m_iso_send_channel; 
    127130    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; 
    131134 
    132135private: 
    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); 
    143146 
    144147}; 
  • trunk/libffado/src/rme/rme_avdevice.cpp

    r436 r445  
    1 /* rme_avdevice.cpp 
    2  * Copyright (C) 2006 by Jonathan Woithe 
    3  * Copyright (C) 2006,2007 by Pieter Palmers 
     1/* 
     2 * Copyright (C) 2005-2007 by Jonathan Woithe 
     3 * Copyright (C) 2005-2007 by Pieter Palmers 
    44 * 
    5  * This file is part of FreeBob. 
     5 * This file is part of FFADO 
     6 * FFADO = Free Firewire (pro-)audio drivers for linux 
    67 * 
    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, 
    1215 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    14  * GNU General Public License for more details. 
     16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     17 * Lesser General Public License for more details. 
    1518 * 
    16  * You should have received a copy of the GNU General Public License 
    17  * along with FreeBob; if not, write to the Free Software 
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
    19  * MA 02111-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 
    2023 */ 
     24 
    2125#warning RME support is currently useless (detection only) 
    2226 
  • trunk/libffado/src/rme/rme_avdevice.h

    r436 r445  
    1 /* rme_avdevice.h 
    2  * Copyright (C) 2006 Jonathan Woithe 
    3  * Copyright (C) 2006,2007 by Pieter Palmers 
     1/* 
     2 * Copyright (C) 2005-2007 by Jonathan Woithe 
     3 * Copyright (C) 2005-2007 by Pieter Palmers 
    44 * 
    5  * This file is part of FreeBob. 
     5 * This file is part of FFADO 
     6 * FFADO = Free Firewire (pro-)audio drivers for linux 
    67 * 
    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, 
    1215 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    14  * GNU General Public License for more details. 
     16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     17 * Lesser General Public License for more details. 
    1518 * 
    16  * You should have received a copy of the GNU General Public License 
    17  * along with FreeBob; if not, write to the Free Software 
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
    19  * MA 02111-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 
    2023 */ 
     24 
    2125#ifndef RMEDEVICE_H 
    2226#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 
    124#include "devicemanager.h" 
    225#include "libutil/serialize.h" 
     
    1437        return false; 
    1538    } 
    16      
     39 
    1740//     devMgr.setVerboseLevel(DEBUG_LEVEL_VERBOSE); 
    18      
     41 
    1942    if (!devMgr.discover( )) { 
    2043        std::cerr << "could not discover devices" << std::endl; 
     
    4265        port=atoi(argv[1]); 
    4366    } 
    44      
     67 
    4568    if ( !serialize( FileName, port ) ) { 
    4669        std::cerr << "serializing failed" << std::endl; 
  • trunk/libffado/src/threads.h

    r412 r445  
    1 /* threads.h 
    2  * Copyright (C) 2006 by Daniel Wagner 
     1/* 
     2 * Copyright (C) 2005-2007 by Daniel Wagner 
    33 * 
    4  * This file is part of FreeBoB. 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    56 * 
    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, 
    1114 * 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. 
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
     16 * Lesser General Public License for more details. 
    1417 * 
    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. 
     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 
    1922 */ 
    2023 
     
    4043{ 
    4144public: 
    42     MemberFunctor0( const CalleePtr& pCallee,  
    43             MemFunPtr pMemFun,  
     45    MemberFunctor0( const CalleePtr& pCallee, 
     46            MemFunPtr pMemFun, 
    4447            bool bDelete = true ) 
    4548        : m_pCallee( pCallee ) 
     
    4952        {} 
    5053 
    51     MemberFunctor0( const CalleePtr& pCallee,  
    52             MemFunPtr pMemFun,  
     54    MemberFunctor0( const CalleePtr& pCallee, 
     55            MemFunPtr pMemFun, 
    5356            sem_t* pSem, 
    5457            bool bDelete = true ) 
     
    6467    virtual void operator() () 
    6568        { 
    66             ( ( *m_pCallee ).*m_pMemFun )();  
     69            ( ( *m_pCallee ).*m_pMemFun )(); 
    6770            if ( m_pSem ) { 
    6871                sem_post( m_pSem); 
     
    8588{ 
    8689public: 
    87     MemberFunctor1( const CalleePtr& pCallee,  
    88             MemFunPtr pMemFun,  
     90    MemberFunctor1( const CalleePtr& pCallee, 
     91            MemFunPtr pMemFun, 
    8992            Parm0 parm0, 
    9093            bool bDelete = true) 
     
    9396        , m_parm0( parm0 ) 
    9497        , m_pSem( 0 ) 
    95         , m_bDelete( bDelete )  
     98        , m_bDelete( bDelete ) 
    9699        {} 
    97100 
    98     MemberFunctor1( const CalleePtr& pCallee,  
    99             MemFunPtr pMemFun,  
     101    MemberFunctor1( const CalleePtr& pCallee, 
     102            MemFunPtr pMemFun, 
    100103            Parm0 parm0, 
    101104            sem_t* pSem, 
     
    112115    virtual void operator() () 
    113116    { 
    114             ( ( *m_pCallee ).*m_pMemFun )( m_parm0 );  
     117            ( ( *m_pCallee ).*m_pMemFun )( m_parm0 ); 
    115118            if ( m_pSem ) { 
    116119                sem_post( m_pSem); 
  • trunk/libffado/support/jack/ffado_driver.c

    r444 r445  
    11/* 
    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 
    45 * 
    5  *   http://freebob.sf.net 
     6 *   http://ffado.sf.net 
    67 *   http://jackit.sf.net 
    78 * 
    8  *   Copyright (C) 2005 Pieter Palmers <pieterpalmers@users.sourceforge.net> 
     9 *   Copyright (C) 2005-2007 Pieter Palmers 
    910 * 
    1011 *   This program is free software; you can redistribute it and/or modify 
     
    4243#include <sysdeps/time.h> 
    4344 
    44 #include "freebob_driver.h" 
     45#include "ffado_driver.h" 
    4546 
    4647#define SAMPLE_MAX_24BIT  8388608.0f 
    4748#define SAMPLE_MAX_16BIT  32768.0f 
    4849 
    49 static int freebob_driver_stop (freebob_driver_t *driver); 
    50  
    51 #ifdef FREEBOB_DRIVER_WITH_MIDI 
    52         static freebob_driver_midi_handle_t *freebob_driver_midi_init(freebob_driver_t *driver); 
    53         static void freebob_driver_midi_finish (freebob_driver_midi_handle_t *m); 
    54         static int freebob_driver_midi_start (freebob_driver_midi_handle_t *m); 
    55         static int freebob_driver_midi_stop (freebob_driver_midi_handle_t *m); 
     50static 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); 
    5657#endif 
    5758 
     
    6061 
    6162static int 
    62 freebob_driver_attach (freebob_driver_t *driver) 
     63ffado_driver_attach (ffado_driver_t *driver) 
    6364{ 
    6465        char buf[64]; 
     
    7778         
    7879        driver->device_options.packetizer_priority=driver->engine->control->client_priority + 
    79                 FREEBOB_RT_PRIORITY_PACKETIZER_RELATIVE; 
     80                FFADO_RT_PRIORITY_PACKETIZER_RELATIVE; 
    8081        if (driver->device_options.packetizer_priority>98) { 
    8182                driver->device_options.packetizer_priority=98; 
    8283        } 
    8384 
    84         driver->dev=freebob_streaming_init(&driver->device_info,driver->device_options); 
     85        driver->dev=ffado_streaming_init(&driver->device_info,driver->device_options); 
    8586 
    8687        if(!driver->dev) { 
    87                 printError("Error creating freebob streaming device"); 
     88                printError("Error creating FFADO streaming device"); 
    8889                return -1; 
    8990        } 
    9091 
    91 #ifdef FREEBOB_DRIVER_WITH_MIDI 
    92         driver->midi_handle=freebob_driver_midi_init(driver); 
     92#ifdef FFADO_DRIVER_WITH_ASEQ_MIDI 
     93        driver->midi_handle=ffado_driver_midi_init(driver); 
    9394        if(!driver->midi_handle) { 
    9495                printError("-----------------------------------------------------------"); 
    9596                printError("Error creating midi device!"); 
    96                 printError("FreeBob will run without MIDI support."); 
     97                printError("The FireWire backend will run without MIDI support."); 
    9798                printError("Consult the above error messages to solve the problem. "); 
    9899                printError("-----------------------------------------------------------\n\n"); 
     
    110111        port_flags = JackPortIsOutput|JackPortIsPhysical|JackPortIsTerminal; 
    111112 
    112         driver->capture_nchannels=freebob_streaming_get_nb_capture_streams(driver->dev); 
     113        driver->capture_nchannels=ffado_streaming_get_nb_capture_streams(driver->dev); 
    113114 
    114115        for (chn = 0; chn < driver->capture_nchannels; chn++) { 
    115116                 
    116                 freebob_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); 
    117118                 
    118                 if(freebob_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) { 
    119120                        printMessage ("Don't register capture port %s", buf); 
    120121 
     
    133134                                jack_slist_append (driver->capture_ports, port); 
    134135                        // setup port parameters 
    135                         if(freebob_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)) { 
    136137                                printError(" cannot set port buffer type for %s", buf); 
    137138                        } 
    138                         if (freebob_streaming_set_capture_stream_buffer(driver->dev, chn, NULL)) { 
     139                        if (ffado_streaming_set_capture_stream_buffer(driver->dev, chn, NULL)) { 
    139140                                printError(" cannot configure initial port buffer for %s", buf); 
    140141                        } 
    141                         if(freebob_streaming_capture_stream_onoff(driver->dev, chn, 1)) { 
     142                        if(ffado_streaming_capture_stream_onoff(driver->dev, chn, 1)) { 
    142143                                printError(" cannot enable port %s", buf); 
    143144                        } 
     
    149150        port_flags = JackPortIsInput|JackPortIsPhysical|JackPortIsTerminal; 
    150151 
    151         driver->playback_nchannels=freebob_streaming_get_nb_playback_streams(driver->dev); 
     152        driver->playback_nchannels=ffado_streaming_get_nb_playback_streams(driver->dev); 
    152153 
    153154        for (chn = 0; chn < driver->playback_nchannels; chn++) { 
    154155 
    155                 freebob_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); 
    156157                 
    157                 if(freebob_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) { 
    158159                        printMessage ("Don't register playback port %s", buf); 
    159160 
     
    173174 
    174175                        // setup port parameters 
    175                         if(freebob_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)) { 
    176177                                printError(" cannot set port buffer type for %s", buf); 
    177178                        } 
    178                         if (freebob_streaming_set_playback_stream_buffer(driver->dev, chn, NULL)) { 
     179                        if (ffado_streaming_set_playback_stream_buffer(driver->dev, chn, NULL)) { 
    179180                                printError(" cannot configure initial port buffer for %s", buf); 
    180181                        } 
    181                         if(freebob_streaming_playback_stream_onoff(driver->dev, chn, 1)) { 
     182                        if(ffado_streaming_playback_stream_onoff(driver->dev, chn, 1)) { 
    182183                                printError(" cannot enable port %s", buf); 
    183184                        } 
     
    187188        } 
    188189 
    189         if(!freebob_streaming_prepare(driver->dev)) { 
     190        if(!ffado_streaming_prepare(driver->dev)) { 
    190191                printError("Could not prepare streaming device!"); 
    191192                return -1; 
     
    197198 
    198199static int  
    199 freebob_driver_detach (freebob_driver_t *driver) 
     200ffado_driver_detach (ffado_driver_t *driver) 
    200201{ 
    201202        JSList *node; 
     
    208209             node = jack_slist_next (node)) { 
    209210                // Don't try to unregister NULL entries added for non-audio 
    210                 // freebob ports by freebob_driver_attach(). 
     211                // ffado ports by ffado_driver_attach(). 
    211212                if (node->data != NULL) { 
    212213                        jack_port_unregister (driver->client, 
     
    220221        for (node = driver->playback_ports; node; 
    221222             node = jack_slist_next (node)) { 
    222                 jack_port_unregister (driver->client, 
     223        if (node->data != NULL) { 
     224                jack_port_unregister (driver->client, 
    223225                                      ((jack_port_t *) node->data)); 
     226        } 
    224227        } 
    225228 
     
    227230        driver->playback_ports = 0; 
    228231 
    229         freebob_streaming_finish(driver->dev); 
     232        ffado_streaming_finish(driver->dev); 
    230233        driver->dev=NULL; 
    231234 
    232 #ifdef FREEBOB_DRIVER_WITH_MIDI 
     235#ifdef FFADO_DRIVER_WITH_ASEQ_MIDI 
    233236        if(driver->midi_handle) { 
    234                 freebob_driver_midi_finish(driver->midi_handle);       
     237                ffado_driver_midi_finish(driver->midi_handle);         
    235238        } 
    236239        driver->midi_handle=NULL; 
     
    238241 
    239242        return 0; 
    240  
    241243} 
    242244 
    243245static inline void  
    244 freebob_driver_read_from_channel (freebob_driver_t *driver, 
     246ffado_driver_read_from_channel (ffado_driver_t *driver, 
    245247                               channel_t channel, 
    246248                               jack_default_audio_sample_t *dst, 
     
    248250{ 
    249251         
    250         freebob_sample_t buffer[nsamples]; 
     252        ffado_sample_t buffer[nsamples]; 
    251253        char *src=(char *)buffer; 
    252254         
    253         freebob_streaming_read(driver->dev, channel, buffer, nsamples); 
     255        ffado_streaming_read(driver->dev, channel, buffer, nsamples); 
    254256         
    255257        /* ALERT: signed sign-extension portability !!! */ 
     
    265267                *dst = x / SAMPLE_MAX_24BIT; 
    266268                dst++; 
    267                 src += sizeof(freebob_sample_t); 
     269                src += sizeof(ffado_sample_t); 
    268270        } 
    269271         
     
    271273 
    272274static int 
    273 freebob_driver_read (freebob_driver_t * driver, jack_nframes_t nframes) 
     275ffado_driver_read (ffado_driver_t * driver, jack_nframes_t nframes) 
    274276{ 
    275277        jack_default_audio_sample_t* buf; 
     
    278280        jack_port_t* port; 
    279281         
    280         freebob_sample_t nullbuffer[nframes]; 
    281  
    282         freebob_streaming_stream_type stream_type; 
     282        ffado_sample_t nullbuffer[nframes]; 
     283 
     284        ffado_streaming_stream_type stream_type; 
    283285         
    284286        printEnter(); 
    285287         
    286288        for (chn = 0, node = driver->capture_ports; node; node = jack_slist_next (node), chn++) { 
    287                 stream_type = freebob_streaming_get_capture_stream_type(driver->dev, chn); 
    288                 if(stream_type == freebob_stream_type_audio) { 
     289                stream_type = ffado_streaming_get_capture_stream_type(driver->dev, chn); 
     290                if(stream_type == ffado_stream_type_audio) { 
    289291                        port = (jack_port_t *) node->data; 
    290292 
     
    292294                        if(!buf) buf=(jack_default_audio_sample_t*)nullbuffer; 
    293295                                 
    294                         freebob_streaming_set_capture_stream_buffer(driver->dev, chn, (char *)(buf)); 
     296                        ffado_streaming_set_capture_stream_buffer(driver->dev, chn, (char *)(buf)); 
    295297                } 
    296298        } 
    297299 
    298300        // now transfer the buffers 
    299         freebob_streaming_transfer_capture_buffers(driver->dev); 
     301        ffado_streaming_transfer_capture_buffers(driver->dev); 
    300302         
    301303        printExit(); 
     
    306308 
    307309static inline void  
    308 freebob_driver_write_to_channel (freebob_driver_t *driver, 
     310ffado_driver_write_to_channel (ffado_driver_t *driver, 
    309311                              channel_t channel,  
    310312                              jack_default_audio_sample_t *buf,  
     
    312314{ 
    313315    long long y; 
    314         freebob_sample_t buffer[nsamples]; 
     316        ffado_sample_t buffer[nsamples]; 
    315317        unsigned int i=0;        
    316318    char *dst=(char *)buffer; 
     
    330332                memcpy (dst, (char *)&y + 5, 3); 
    331333#endif 
    332                 dst += sizeof(freebob_sample_t); 
     334                dst += sizeof(ffado_sample_t); 
    333335                buf++; 
    334336        } 
    335337         
    336         // write to the freebob streaming device 
    337         freebob_streaming_write(driver->dev, channel, buffer, nsamples); 
     338        // write to the ffado streaming device 
     339        ffado_streaming_write(driver->dev, channel, buffer, nsamples); 
    338340         
    339341} 
    340342 
    341343static int 
    342 freebob_driver_write (freebob_driver_t * driver, jack_nframes_t nframes) 
     344ffado_driver_write (ffado_driver_t * driver, jack_nframes_t nframes) 
    343345{ 
    344346        channel_t chn; 
     
    348350        jack_port_t *port; 
    349351 
    350         freebob_streaming_stream_type stream_type; 
    351  
    352         freebob_sample_t nullbuffer[nframes]; 
    353  
    354         memset(&nullbuffer,0,nframes*sizeof(freebob_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)); 
    355357 
    356358        printEnter(); 
     
    365367 
    366368        for (chn = 0, node = driver->playback_ports; node; node = jack_slist_next (node), chn++) { 
    367                 stream_type=freebob_streaming_get_playback_stream_type(driver->dev, chn); 
    368                 if(stream_type == freebob_stream_type_audio) { 
     369                stream_type=ffado_streaming_get_playback_stream_type(driver->dev, chn); 
     370                if(stream_type == ffado_stream_type_audio) { 
    369371                        port = (jack_port_t *) node->data; 
    370372 
     
    372374                        if(!buf) buf=(jack_default_audio_sample_t*)nullbuffer; 
    373375                                 
    374                         freebob_streaming_set_playback_stream_buffer(driver->dev, chn, (char *)(buf)); 
    375                 } 
    376         } 
    377  
    378         freebob_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); 
    379381 
    380382        printExit(); 
     
    385387//static inline jack_nframes_t  
    386388static jack_nframes_t  
    387 freebob_driver_wait (freebob_driver_t *driver, int extra_fd, int *status, 
     389ffado_driver_wait (ffado_driver_t *driver, int extra_fd, int *status, 
    388390                   float *delayed_usecs) 
    389391{ 
     
    408410// *status = -4; extra FD 
    409411 
    410         nframes=freebob_streaming_wait(driver->dev); 
     412        nframes=ffado_streaming_wait(driver->dev); 
    411413         
    412414        wait_ret = jack_get_microseconds (); 
     
    421423        // transfer the streaming buffers 
    422424        // we now do this in the read/write functions 
    423 //      freebob_streaming_transfer_buffers(driver->dev); 
     425//      ffado_streaming_transfer_buffers(driver->dev); 
    424426         
    425427        if (nframes < 0) { 
     
    443445 
    444446static int 
    445 freebob_driver_run_cycle (freebob_driver_t *driver) 
     447ffado_driver_run_cycle (ffado_driver_t *driver) 
    446448{ 
    447449        jack_engine_t *engine = driver->engine; 
     
    449451        float delayed_usecs=0.0; 
    450452 
    451         jack_nframes_t nframes = freebob_driver_wait (driver, -1, 
     453        jack_nframes_t nframes = ffado_driver_wait (driver, -1, 
    452454           &wait_status, &delayed_usecs); 
    453455         
     
    472474 */ 
    473475static int 
    474 freebob_driver_null_cycle (freebob_driver_t* driver, jack_nframes_t nframes) 
     476ffado_driver_null_cycle (ffado_driver_t* driver, jack_nframes_t nframes) 
    475477{ 
    476478        channel_t chn; 
     
    478480        snd_pcm_sframes_t nwritten; 
    479481 
    480         freebob_streaming_stream_type stream_type; 
     482        ffado_streaming_stream_type stream_type; 
    481483 
    482484        jack_default_audio_sample_t buff[nframes]; 
     
    497499 
    498500        for (chn = 0, node = driver->playback_ports; node; node = jack_slist_next (node), chn++) { 
    499                 stream_type=freebob_streaming_get_playback_stream_type(driver->dev, chn); 
    500  
    501                 if(stream_type == freebob_stream_type_audio) { 
    502                         freebob_streaming_set_playback_stream_buffer(driver->dev, chn, (char *)(buffer)); 
    503                 } 
    504         } 
    505  
    506         freebob_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); 
    507509         
    508510        // read & discard from input ports 
    509511        for (chn = 0, node = driver->capture_ports; node; node = jack_slist_next (node), chn++) { 
    510                 stream_type=freebob_streaming_get_capture_stream_type(driver->dev, chn); 
    511                 if(stream_type == freebob_stream_type_audio) { 
    512                         freebob_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)); 
    513515                } 
    514516        } 
    515517 
    516518        // now transfer the buffers 
    517         freebob_streaming_transfer_capture_buffers(driver->dev); 
     519        ffado_streaming_transfer_capture_buffers(driver->dev); 
    518520                 
    519521        printExit(); 
     
    522524 
    523525static int 
    524 freebob_driver_start (freebob_driver_t *driver) 
     526ffado_driver_start (ffado_driver_t *driver) 
    525527{ 
    526528        int retval=0; 
    527529 
    528 #ifdef FREEBOB_DRIVER_WITH_MIDI 
     530#ifdef FFADO_DRIVER_WITH_ASEQ_MIDI 
    529531        if(driver->midi_handle) { 
    530                 if((retval=freebob_driver_midi_start(driver->midi_handle))) { 
     532                if((retval=ffado_driver_midi_start(driver->midi_handle))) { 
    531533                        printError("Could not start MIDI threads"); 
    532534                        return retval; 
     
    535537#endif   
    536538 
    537         if((retval=freebob_streaming_start(driver->dev))) { 
     539        if((retval=ffado_streaming_start(driver->dev))) { 
    538540                printError("Could not start streaming threads"); 
    539 #ifdef FREEBOB_DRIVER_WITH_MIDI 
     541#ifdef FFADO_DRIVER_WITH_ASEQ_MIDI 
    540542                if(driver->midi_handle) { 
    541                         freebob_driver_midi_stop(driver->midi_handle); 
     543                        ffado_driver_midi_stop(driver->midi_handle); 
    542544                } 
    543545#endif   
     
    550552 
    551553static int 
    552 freebob_driver_stop (freebob_driver_t *driver) 
     554ffado_driver_stop (ffado_driver_t *driver) 
    553555{ 
    554556        int retval=0; 
    555557         
    556 #ifdef FREEBOB_DRIVER_WITH_MIDI 
     558#ifdef FFADO_DRIVER_WITH_ASEQ_MIDI 
    557559        if(driver->midi_handle) { 
    558                 if((retval=freebob_driver_midi_stop(driver->midi_handle))) { 
     560                if((retval=ffado_driver_midi_stop(driver->midi_handle))) { 
    559561                        printError("Could not stop MIDI threads"); 
    560562                        return retval; 
     
    562564        } 
    563565#endif   
    564         if((retval=freebob_streaming_stop(driver->dev))) { 
     566        if((retval=ffado_streaming_stop(driver->dev))) { 
    565567                printError("Could not stop streaming threads"); 
    566568                return retval; 
     
    572574 
    573575static int 
    574 freebob_driver_bufsize (freebob_driver_t* driver, jack_nframes_t nframes) 
     576ffado_driver_bufsize (ffado_driver_t* driver, jack_nframes_t nframes) 
    575577{ 
    576578        printError("Buffer size change requested but not supported!!!"); 
     
    591593typedef void (*JackDriverFinishFunction) (jack_driver_t *); 
    592594 
    593 freebob_driver_t * 
    594 freebob_driver_new (jack_client_t * client, 
     595ffado_driver_t * 
     596ffado_driver_new (jack_client_t * client, 
    595597                  char *name, 
    596                   freebob_jack_settings_t *params) 
    597 { 
    598         freebob_driver_t *driver; 
     598                  ffado_jack_settings_t *params) 
     599{ 
     600        ffado_driver_t *driver; 
    599601 
    600602        assert(params); 
    601603 
    602         if(freebob_get_api_version() != 2) { 
    603                 printError("Incompatible libfreebob version! (%s)", freebob_get_version()); 
     604        if(ffado_get_api_version() != 2) { 
     605                printError("Incompatible libffado version! (%s)", ffado_get_version()); 
    604606                return NULL; 
    605607        } 
    606608 
    607         printMessage("Starting Freebob backend (%s)", freebob_get_version()); 
    608  
    609         driver = calloc (1, sizeof (freebob_driver_t)); 
     609        printMessage("Starting Freebob backend (%s)", ffado_get_version()); 
     610 
     611        driver = calloc (1, sizeof (ffado_driver_t)); 
    610612 
    611613        /* Setup the jack interfaces */   
    612614        jack_driver_nt_init ((jack_driver_nt_t *) driver); 
    613615 
    614         driver->nt_attach    = (JackDriverNTAttachFunction)   freebob_driver_attach; 
    615         driver->nt_detach    = (JackDriverNTDetachFunction)   freebob_driver_detach; 
    616         driver->nt_start     = (JackDriverNTStartFunction)    freebob_driver_start; 
    617         driver->nt_stop      = (JackDriverNTStopFunction)     freebob_driver_stop; 
    618         driver->nt_run_cycle = (JackDriverNTRunCycleFunction) freebob_driver_run_cycle; 
    619         driver->null_cycle   = (JackDriverNullCycleFunction)  freebob_driver_null_cycle; 
    620         driver->write        = (JackDriverReadFunction)       freebob_driver_write; 
    621         driver->read         = (JackDriverReadFunction)       freebob_driver_read; 
    622         driver->nt_bufsize   = (JackDriverNTBufSizeFunction)  freebob_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; 
    623625         
    624626        /* copy command line parameter contents to the driver structure */ 
    625         memcpy(&driver->settings,params,sizeof(freebob_jack_settings_t)); 
     627        memcpy(&driver->settings,params,sizeof(ffado_jack_settings_t)); 
    626628         
    627629        /* prepare all parameters */ 
     
    646648 
    647649        if(!params->capture_ports) { 
    648                 driver->device_options.directions |= FREEBOB_IGNORE_CAPTURE; 
     650                driver->device_options.directions |= FFADO_IGNORE_CAPTURE; 
    649651        } 
    650652 
    651653        if(!params->playback_ports) { 
    652                 driver->device_options.directions |= FREEBOB_IGNORE_PLAYBACK; 
     654                driver->device_options.directions |= FFADO_IGNORE_PLAYBACK; 
    653655        } 
    654656 
     
    659661        debugPrint(DEBUG_LEVEL_STARTUP, "            sample rate: %d", driver->sample_rate); 
    660662 
    661         return (freebob_driver_t *) driver; 
     663        return (ffado_driver_t *) driver; 
    662664 
    663665} 
    664666 
    665667static void 
    666 freebob_driver_delete (freebob_driver_t *driver) 
     668ffado_driver_delete (ffado_driver_t *driver) 
    667669{ 
    668670        jack_driver_nt_finish ((jack_driver_nt_t *) driver); 
     
    670672} 
    671673 
    672 #ifdef FREEBOB_DRIVER_WITH_MIDI 
     674#ifdef FFADO_DRIVER_WITH_ASEQ_MIDI 
    673675/* 
    674676 * MIDI support 
     
    677679// the thread that will queue the midi events from the seq to the stream buffers 
    678680 
    679 void * freebob_driver_midi_queue_thread(void *arg) 
    680 { 
    681         freebob_driver_midi_handle_t *m=(freebob_driver_midi_handle_t *)arg; 
     681void * ffado_driver_midi_queue_thread(void *arg) 
     682{ 
     683        ffado_driver_midi_handle_t *m=(ffado_driver_midi_handle_t *)arg; 
    682684        assert(m); 
    683685        snd_seq_event_t *ev; 
     
    693695                while ((snd_seq_event_input(m->seq_handle, &ev) > 0)) { 
    694696                        // get the port this event is originated from 
    695                         freebob_midi_port_t *port=NULL; 
     697                        ffado_midi_port_t *port=NULL; 
    696698                        for (i=0;i<m->nb_output_ports;i++) { 
    697699                                if(m->output_ports[i]->seq_port_nr == ev->dest.port) { 
     
    719721         
    720722                        for(b=0;b<bytes_to_send;b++) { 
    721                                 freebob_sample_t tmp_event=work_buffer[b]; 
    722                                 if(freebob_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) { 
    723725                                        printError(" Midi send buffer overrun"); 
    724726                                } 
     
    734736 
    735737// the dequeue thread (maybe we need one thread per stream) 
    736 void *freebob_driver_midi_dequeue_thread (void *arg) { 
    737         freebob_driver_midi_handle_t *m=(freebob_driver_midi_handle_t *)arg; 
     738void *ffado_driver_midi_dequeue_thread (void *arg) { 
     739        ffado_driver_midi_handle_t *m=(ffado_driver_midi_handle_t *)arg; 
    738740 
    739741        int i; 
     
    750752                        unsigned int buff[64]; 
    751753         
    752                         freebob_midi_port_t *port=m->input_ports[i]; 
     754                        ffado_midi_port_t *port=m->input_ports[i]; 
    753755                 
    754756                        if(!port) { 
     
    757759                 
    758760                        do { 
    759                                 samples_read=freebob_streaming_read(m->dev, port->stream_nr, buff, 64); 
     761                                samples_read=ffado_streaming_read(m->dev, port->stream_nr, buff, 64); 
    760762                         
    761763                                for (s=0;s<samples_read;s++) { 
     
    779781} 
    780782 
    781 static freebob_driver_midi_handle_t *freebob_driver_midi_init(freebob_driver_t *driver) { 
     783static ffado_driver_midi_handle_t *ffado_driver_midi_init(ffado_driver_t *driver) { 
    782784//      int err; 
    783785 
     
    787789        int i=0; 
    788790 
    789         freebob_device_t *dev=driver->dev; 
     791        ffado_device_t *dev=driver->dev; 
    790792 
    791793        assert(dev); 
    792794 
    793         freebob_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)); 
    794796        if (!m) { 
    795797                printError("not enough memory to create midi structure"); 
     
    806808 
    807809        // find out the number of midi in/out ports we need to setup 
    808         nchannels=freebob_streaming_get_nb_capture_streams(dev); 
     810        nchannels=ffado_streaming_get_nb_capture_streams(dev); 
    809811 
    810812        m->nb_input_ports=0; 
    811813 
    812814        for (chn = 0; chn < nchannels; chn++) {  
    813                 if(freebob_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) { 
    814816                        m->nb_input_ports++; 
    815817                } 
    816818        } 
    817819 
    818         m->input_ports=calloc(m->nb_input_ports,sizeof(freebob_midi_port_t *)); 
     820        m->input_ports=calloc(m->nb_input_ports,sizeof(ffado_midi_port_t *)); 
    819821        if(!m->input_ports) { 
    820822                printError("not enough memory to create midi structure"); 
     
    825827        i=0; 
    826828        for (chn = 0; chn < nchannels; chn++) { 
    827                 if(freebob_streaming_get_capture_stream_type(dev, chn) == freebob_stream_type_midi) { 
    828                         m->input_ports[i]=calloc(1,sizeof(freebob_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)); 
    829831                        if(!m->input_ports[i]) { 
    830832                                // fixme 
     
    833835                        } 
    834836 
    835                         freebob_streaming_get_capture_stream_name(dev, chn, buf, sizeof(buf) - 1); 
     837                        ffado_streaming_get_capture_stream_name(dev, chn, buf, sizeof(buf) - 1); 
    836838                        printMessage("Register MIDI IN port %s", buf); 
    837839 
     
    852854                                        m->input_ports[i]->seq_port_nr=-1; 
    853855                                } else { 
    854                                         if(freebob_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)) { 
    855857                                                printError(" cannot set port buffer type for %s", buf); 
    856858                                                m->input_ports[i]->stream_nr=-1; 
    857859                                                m->input_ports[i]->seq_port_nr=-1; 
    858860                                        } 
    859                                         if(freebob_streaming_capture_stream_onoff(dev, chn, 1)) { 
     861                                        if(ffado_streaming_capture_stream_onoff(dev, chn, 1)) { 
    860862                                                printError(" cannot enable port %s", buf); 
    861863                                                m->input_ports[i]->stream_nr=-1; 
     
    871873 
    872874        // playback 
    873         nchannels=freebob_streaming_get_nb_playback_streams(dev); 
     875        nchannels=ffado_streaming_get_nb_playback_streams(dev); 
    874876 
    875877        m->nb_output_ports=0; 
    876878 
    877879        for (chn = 0; chn < nchannels; chn++) {  
    878                 if(freebob_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) { 
    879881                        m->nb_output_ports++; 
    880882                } 
    881883        } 
    882884 
    883         m->output_ports=calloc(m->nb_output_ports,sizeof(freebob_midi_port_t *)); 
     885        m->output_ports=calloc(m->nb_output_ports,sizeof(ffado_midi_port_t *)); 
    884886        if(!m->output_ports) { 
    885887                printError("not enough memory to create midi structure"); 
     
    894896        i=0; 
    895897        for (chn = 0; chn < nchannels; chn++) { 
    896                 if(freebob_streaming_get_playback_stream_type(dev, chn) == freebob_stream_type_midi) { 
    897                         m->output_ports[i]=calloc(1,sizeof(freebob_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)); 
    898900                        if(!m->output_ports[i]) { 
    899901                                // fixme 
     
    902904                        } 
    903905 
    904                         freebob_streaming_get_playback_stream_name(dev, chn, buf, sizeof(buf) - 1); 
     906                        ffado_streaming_get_playback_stream_name(dev, chn, buf, sizeof(buf) - 1); 
    905907                        printMessage("Register MIDI OUT port %s", buf); 
    906908 
     
    922924                                        m->output_ports[i]->seq_port_nr=-1; 
    923925                                } else { 
    924                                         if(freebob_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)) { 
    925927                                                printError(" cannot set port buffer type for %s", buf); 
    926928                                                m->input_ports[i]->stream_nr=-1; 
    927929                                                m->input_ports[i]->seq_port_nr=-1; 
    928930                                        } 
    929                                         if(freebob_streaming_playback_stream_onoff(dev, chn, 1)) { 
     931                                        if(ffado_streaming_playback_stream_onoff(dev, chn, 1)) { 
    930932                                                printError(" cannot enable port %s", buf); 
    931933                                                m->input_ports[i]->stream_nr=-1; 
     
    946948 
    947949static int 
    948 freebob_driver_midi_start (freebob_driver_midi_handle_t *m) 
     950ffado_driver_midi_start (ffado_driver_midi_handle_t *m) 
    949951{ 
    950952        assert(m); 
     
    954956        m->queue_thread_priority= 
    955957                m->driver->engine->control->client_priority + 
    956                 FREEBOB_RT_PRIORITY_MIDI_RELATIVE; 
     958                FFADO_RT_PRIORITY_MIDI_RELATIVE; 
    957959 
    958960        if (m->queue_thread_priority>98) { 
     
    966968        } 
    967969 
    968         if (jack_client_create_thread(NULL, &m->queue_thread, m->queue_thread_priority, m->queue_thread_realtime, freebob_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)) { 
    969971                printError(" cannot create midi queueing thread"); 
    970972                return -1; 
    971973        } 
    972974 
    973         if (jack_client_create_thread(NULL, &m->dequeue_thread, m->queue_thread_priority, m->queue_thread_realtime, freebob_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)) { 
    974976                printError(" cannot create midi dequeueing thread"); 
    975977                return -1; 
     
    979981 
    980982static int 
    981 freebob_driver_midi_stop (freebob_driver_midi_handle_t *m) 
     983ffado_driver_midi_stop (ffado_driver_midi_handle_t *m) 
    982984{ 
    983985        assert(m); 
     
    993995 
    994996static void 
    995 freebob_driver_midi_finish (freebob_driver_midi_handle_t *m) 
     997ffado_driver_midi_finish (ffado_driver_midi_handle_t *m) 
    996998{ 
    997999        assert(m); 
     
    10181020 */ 
    10191021 
    1020 const char driver_client_name[] = "freebob_pcm"; 
     1022const char driver_client_name[] = "firewire_pcm"; 
    10211023 
    10221024const jack_driver_desc_t * 
     
    10291031        desc = calloc (1, sizeof (jack_driver_desc_t)); 
    10301032 
    1031         strcpy (desc->name, "freebob"); 
     1033        strcpy (desc->name, "firewire"); 
    10321034        desc->nparams = 8; 
    10331035   
     
    11151117        const jack_driver_param_t * param; 
    11161118 
    1117         freebob_jack_settings_t cmlparams; 
     1119        ffado_jack_settings_t cmlparams; 
    11181120         
    11191121    char *device_name="hw:0";  
     
    11971199    jack_error("Freebob using Firewire port %d, node %d",cmlparams.port,cmlparams.node_id); 
    11981200     
    1199         driver=(jack_driver_t *)freebob_driver_new (client, "freebob_pcm", &cmlparams); 
     1201        driver=(jack_driver_t *)ffado_driver_new (client, "ffado_pcm", &cmlparams); 
    12001202 
    12011203        return driver; 
     
    12051207driver_finish (jack_driver_t *driver) 
    12061208{ 
    1207         freebob_driver_t *drv=(freebob_driver_t *) driver; 
     1209        ffado_driver_t *drv=(ffado_driver_t *) driver; 
    12081210        // If jack hasn't called the detach method, do it now.  As of jack 0.101.1 
    12091211        // the detach method was not being called explicitly on closedown, and  
    12101212        // we need it to at least deallocate the iso resources. 
    12111213        if (drv->dev != NULL) 
    1212                 freebob_driver_detach(drv); 
    1213         freebob_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.h 
    2  * 
    3  *   FreeBob Backend for Jack 
    4  *   FreeBob = Firewire (pro-)audio for linux 
    5  * 
    6  *   http://freebob.sf.net 
     1/* 
     2 *   FireWire Backend for Jack 
     3 *   using FFADO 
     4 *   FFADO = Firewire (pro-)audio for linux 
     5 * 
     6 *   http://ffado.sf.net 
    77 *   http://jackit.sf.net 
    88 * 
    9  *   Copyright (C) 2005 Pieter Palmers <pieterpalmers@users.sourceforge.net> 
     9 *   Copyright (C) 2005-2007 Pieter Palmers 
    1010 * 
    1111 *   This program is free software; you can redistribute it and/or modify 
     
    2929 */  
    3030  
    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> 
    3837 
    3938#include <jack/driver.h> 
     
    114113 
    115114// thread priority setup 
    116 #define FREEBOB_RT_PRIORITY_PACKETIZER_RELATIVE       5 
    117  
    118 #ifdef FREEBOB_DRIVER_WITH_MIDI 
     115#define FFADO_RT_PRIORITY_PACKETIZER_RELATIVE 5 
     116 
     117#ifdef FFADO_DRIVER_WITH_ASEQ_MIDI 
    119118 
    120119        #define ALSA_SEQ_BUFF_SIZE 1024 
     
    125124        // but I think it should be smaller than the packetizer thread in order not  
    126125        // to lose any packets 
    127         #define FREEBOB_RT_PRIORITY_MIDI_RELATIVE     4 
    128  
    129 #endif 
    130  
    131 typedef struct _freebob_driver freebob_driver_t; 
     126        #define FFADO_RT_PRIORITY_MIDI_RELATIVE       4 
     127 
     128#endif 
     129 
     130typedef struct _ffado_driver ffado_driver_t; 
    132131 
    133132/* 
     
    135134 */ 
    136135 
    137 typedef struct _freebob_jack_settings freebob_jack_settings_t; 
    138 struct _freebob_jack_settings { 
     136typedef struct _ffado_jack_settings ffado_jack_settings_t; 
     137struct _ffado_jack_settings { 
    139138    int period_size_set; 
    140139    jack_nframes_t period_size; 
     
    158157    int snoop_mode; 
    159158     
    160     freebob_handle_t fb_handle; 
     159    ffado_handle_t fb_handle; 
    161160}; 
    162161 
    163 #ifdef FREEBOB_DRIVER_WITH_MIDI 
    164  
     162#ifdef FFADO_DRIVER_WITH_ASEQ_MIDI 
    165163 
    166164typedef struct { 
     
    169167        snd_midi_event_t *parser; 
    170168        snd_seq_t *seq_handle; 
    171 } freebob_midi_port_t; 
    172  
    173 typedef struct _freebob_driver_midi_handle { 
    174         freebob_device_t *dev; 
    175         freebob_driver_t *driver; 
     169} ffado_midi_port_t; 
     170 
     171typedef struct _ffado_driver_midi_handle { 
     172        ffado_device_t *dev; 
     173        ffado_driver_t *driver; 
    176174 
    177175        snd_seq_t *seq_handle; 
     
    185183        int nb_output_ports; 
    186184 
    187         freebob_midi_port_t **input_ports; 
    188         freebob_midi_port_t **output_ports; 
    189  
    190         freebob_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; 
    191189        int *output_port_stream_map; 
    192190 
    193191 
    194 } freebob_driver_midi_handle_t; 
     192} ffado_driver_midi_handle_t; 
    195193 
    196194#endif 
     
    200198  
    201199 
    202 struct _freebob_driver 
     200struct _ffado_driver 
    203201{ 
    204202        JACK_DRIVER_NT_DECL 
     
    220218         
    221219        /* settings from the command line */ 
    222         freebob_jack_settings_t settings; 
     220        ffado_jack_settings_t settings; 
    223221         
    224222        /* the freebob virtual device */ 
    225         freebob_device_t *dev; 
     223        ffado_device_t *dev; 
    226224         
    227225    JSList                       *capture_ports; 
     
    231229    channel_t                     capture_nchannels; 
    232230         
    233         freebob_device_info_t device_info; 
    234         freebob_options_t device_options; 
    235  
    236 #ifdef FREEBOB_DRIVER_WITH_MIDI 
    237         freebob_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; 
    238236#endif 
    239237 
     
    242240 
    243241 
    244 #endif /* __JACK_FREEBOB_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 
    32# 
    4 # This file is part of FreeBoB. 
     3# Copyright (C) 2005-2007 by Daniel Wagner. 
     4# Copyright (C) 2005-2007 by Pieter Palmers. 
    55# 
    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, 
    1118# but WITHOUT ANY WARRANTY; without even the implied warranty of 
    1219# 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 
    1624# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
    1725 
    18 # SUBDIRS = streaming 
     26#SUBDIRS=streaming 
    1927 
    2028INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src $(LIBXML_CFLAGS) \ 
    2129        $(LIBAVC1394_CFLAGS) $(LIBXMLCPP_CFLAGS) 
    22          
     30 
    2331noinst_PROGRAMS = 
    2432 
    2533if BUILD_TESTS 
    26 noinst_PROGRAMS += test-freebob test-extplugcmd test-fw410 \ 
    27                test-volume test-mixer test-cycletimer test-sytmonitor \ 
    28                test-timestampedbuffer test-ieee1394service 
     34noinst_PROGRAMS += test-ffado test-extplugcmd test-fw410 \ 
     35            test-volume test-mixer test-cycletimer test-sytmonitor \ 
     36            test-timestampedbuffer test-ieee1394service 
    2937endif 
    3038 
    31 noinst_HEADERS =  
     39noinst_HEADERS = 
    3240 
    33 test_freebob_SOURCES = test-freebob.cpp 
    34 test_freebob_LDADD   = $(top_builddir)/src/libfreebob.la \ 
     41test_ffado_SOURCES = test-ffado.cpp 
     42test_ffado_LDADD   = $(top_builddir)/src/libffado.la \ 
    3543        $(LIBXML_LIBS) $(LIBAVC1394_LIBS) $(LIBIEC61883_LIBS) 
    3644 
    3745test_extplugcmd_SOURCES = test-extplugcmd.cpp 
    38 test_extplugcmd_LDADD = $(top_builddir)/src/libfreebob.la \ 
     46test_extplugcmd_LDADD = $(top_builddir)/src/libffado.la \ 
    3947        $(LIBAVC1394_LIBS) 
    4048 
    4149test_volume_SOURCES = test-volume.cpp 
    42 test_volume_LDADD = $(top_builddir)/src/libfreebob.la \ 
     50test_volume_LDADD = $(top_builddir)/src/libffado.la \ 
    4351        $(LIBAVC1394_LIBS) 
    4452 
    4553test_mixer_SOURCES = test-mixer.cpp 
    46 test_mixer_LDADD = $(top_builddir)/src/libfreebob.la \ 
     54test_mixer_LDADD = $(top_builddir)/src/libffado.la \ 
    4755        $(LIBAVC1394_LIBS) 
    4856 
     
    5159 
    5260test_ieee1394service_SOURCES = test-ieee1394service.cpp 
    53 test_ieee1394service_LDADD   = $(top_builddir)/src/libfreebob.la \ 
    54                                $(LIBAVC1394_LIBS) $(LIBIEC61883_LIBS) -lrom1394 
     61test_ieee1394service_LDADD   = $(top_builddir)/src/libffado.la \ 
     62                                  $(LIBAVC1394_LIBS) $(LIBIEC61883_LIBS) -lrom1394 
    5563 
    5664#TESTS_ENVIRONMENT 
    57 TEST = test-freebob 
     65TEST = test-ffado 
    5866 
    59 test_cycletimer_LDADD = $(top_builddir)/src/libfreebob.la $(LIBIEC61883_LIBS) \ 
     67test_cycletimer_LDADD = $(top_builddir)/src/libffado.la $(LIBIEC61883_LIBS) \ 
    6068        $(LIBRAW1394_LIBS) $(LIBAVC1394_LIBS) 
    6169test_cycletimer_SOURCES = test-cycletimer.cpp 
    6270 
    63 test_sytmonitor_LDADD = $(top_builddir)/src/libfreebob.la $(LIBIEC61883_LIBS) \ 
     71test_sytmonitor_LDADD = $(top_builddir)/src/libffado.la $(LIBIEC61883_LIBS) \ 
    6472        $(LIBRAW1394_LIBS) $(LIBAVC1394_LIBS) 
    6573test_sytmonitor_SOURCES = test-sytmonitor.cpp SytMonitor.cpp \ 
    66                           SytMonitor.h 
     74                             SytMonitor.h 
    6775 
    68 test_timestampedbuffer_LDADD = $(top_builddir)/src/libfreebob.la $(LIBIEC61883_LIBS) \ 
     76test_timestampedbuffer_LDADD = $(top_builddir)/src/libffado.la $(LIBIEC61883_LIBS) \ 
    6977        $(LIBRAW1394_LIBS) $(LIBAVC1394_LIBS) 
    7078test_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 
    125#include <libfreebob/freebob.h> 
    226#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 
    125#ifndef DEBUG_TOOLS_H 
    226#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 
    42# 
    5 # This file is part of FreeBoB. 
     3# Copyright (C) 2005-2007 by Daniel Wagner. 
     4# Copyright (C) 2005-2007 by Pieter Palmers. 
    65# 
    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, 
    1218# but WITHOUT ANY WARRANTY; without even the implied warranty of 
    1319# 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 
    1724# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
    1825 
     
    2330 
    2431teststreaming_SOURCES = teststreaming.c debugtools.c 
    25 teststreaming_LDADD   = $(top_builddir)/src/libfreebob.la \ 
     32teststreaming_LDADD   = $(top_builddir)/src/libffado.la \ 
    2633        $(LIBAVC1394_LIBS) $(LIBIEC61883_LIBS) 
    2734 
    2835teststreaming2_SOURCES = teststreaming2.c debugtools.c 
    29 teststreaming2_LDADD   = $(top_builddir)/src/libfreebob.la \ 
     36teststreaming2_LDADD   = $(top_builddir)/src/libffado.la \ 
    3037        $(LIBAVC1394_LIBS) $(LIBIEC61883_LIBS) 
    3138 
    3239teststreaming3_SOURCES = teststreaming3.c debugtools.c 
    33 teststreaming3_LDADD   = $(top_builddir)/src/libfreebob.la \ 
     40teststreaming3_LDADD   = $(top_builddir)/src/libffado.la \ 
    3441        $(LIBAVC1394_LIBS) $(LIBIEC61883_LIBS) 
    3542 
    3643testmidistreaming1_SOURCES = testmidistreaming1.c debugtools.c 
    37 testmidistreaming1_LDADD   = $(top_builddir)/src/libfreebob.la -lasound \ 
     44testmidistreaming1_LDADD   = $(top_builddir)/src/libffado.la -lasound \ 
    3845        $(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 */ 
    1923 
    2024#ifdef HAVE_CONFIG_H 
     
    4650static void sighandler (int sig) 
    4751{ 
    48        run = 0; 
     52    run = 0; 
    4953} 
    5054 
     
    5256{ 
    5357 
    54        int retval=0; 
    55        int i=0; 
    56        run=1; 
    57  
    58        signal (SIGINT, sighandler); 
    59        signal (SIGPIPE, sighandler); 
    60  
    61        printf("Freebob streaming test application\n"); 
    62        printf(" ISO handler tests\n"); 
    63  
    64        // also create a processor manager to manage the actual stream 
    65         // 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 themselves 
    74  
    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                           0 
    128                ); 
    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 runner 
    149        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"); 
    196200 
    197201 
  • 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 */ 
    1923 
    2024 
  • 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 
    1924/** 
    2025 * 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 */ 
    1923 
    2024 
  • 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 */ 
    1923 
    2024 
  • trunk/libffado/tests/SytMonitor.cpp

    r399 r445  
    1 /* $Id$ */ 
    2  
    31/* 
    4  *   FreeBob Streaming API 
    5  *   FreeBob = Firewire (pro-)audio for linux 
     2 * Copyright (C) 2005-2007 by Pieter Palmers 
    63 * 
    7  *   http://freebob.sf.net 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    86 * 
    9  *   Copyright (C) 2005,2006,2007 Pieter Palmers <pieterpalmers@users.sourceforge.net> 
     7 * FFADO is based upon FreeBoB 
    108 * 
    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. 
    1517 * 
    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. 
    2622 * 
    2723 */ 
     
    4137SytMonitor::SytMonitor(int port) 
    4238    : IsoStream(IsoStream::EST_Receive, port) { 
    43     m_cinfo_buffer=freebob_ringbuffer_create(16384*sizeof(struct cycle_info)); 
     39    m_cinfo_buffer=ffado_ringbuffer_create(16384*sizeof(struct cycle_info)); 
    4440 
    4541} 
    4642 
    4743SytMonitor::~SytMonitor() { 
    48        freebob_ringbuffer_free(m_cinfo_buffer); 
     44    ffado_ringbuffer_free(m_cinfo_buffer); 
    4945 
    5046} 
    5147 
    52 enum raw1394_iso_disposition  
    53 SytMonitor::putPacket(unsigned char *data, unsigned int length,  
    54                   unsigned char channel, unsigned char tag, unsigned char sy,  
     48enum raw1394_iso_disposition 
     49SytMonitor::putPacket(unsigned char *data, unsigned int length, 
     50                  unsigned char channel, unsigned char tag, unsigned char sy, 
    5551                  unsigned int cycle, unsigned int dropped) { 
    5652    enum raw1394_iso_disposition retval=RAW1394_ISO_OK; 
    57      
     53 
    5854    struct iec61883_packet *packet = (struct iec61883_packet *) data; 
    5955    unsigned int syt_timestamp=ntohs(packet->syt); 
    60      
     56 
    6157    if (syt_timestamp == 0xFFFF) { 
    6258        return RAW1394_ISO_OK; 
    6359    } 
    64      
     60 
    6561    uint32_t m_full_timestamp; 
    6662    uint32_t m_full_timestamp_ticks; 
    67      
     63 
    6864    debugOutput(DEBUG_LEVEL_VERBOSE,"%2u,%2u: CY=%4u, SYT=%08X (%3u secs + %4u cycles + %04u ticks)\n", 
    6965        m_port,channel, 
    7066        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), 
    7369        CYCLE_TIMER_GET_OFFSET(syt_timestamp) 
    74          
     70 
    7571        ); 
    76      
     72 
    7773    // reconstruct the full cycle 
    7874    unsigned int cc=m_handler->getCycleTimer(); 
    79      
     75 
    8076    unsigned int cc_cycles=CYCLE_TIMER_GET_CYCLES(cc); 
    81      
     77 
    8278    unsigned int cc_seconds=CYCLE_TIMER_GET_SECS(cc); 
    83      
    84      
     79 
     80 
    8581    // 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 
    8783    // was received 
    8884    if (cycle>cc_cycles) cc_seconds--; 
    89      
     85 
    9086    m_full_timestamp_ticks=sytRecvToFullTicks((uint32_t)syt_timestamp, cycle, cc); 
    9187    m_full_timestamp=TICKS_TO_CYCLE_TIMER(m_full_timestamp_ticks); 
    92      
     88 
    9389    struct cycle_info cif; 
    9490    cif.cycle=cycle; 
    9591    cif.seconds=cc_seconds; 
    96      
     92 
    9793    cif.syt=packet->syt; 
    9894    cif.full_syt=m_full_timestamp; 
    99      
     95 
    10096    // now we reconstruct the presentation time 
    10197    cif.pres_seconds = CYCLE_TIMER_GET_SECS(m_full_timestamp); 
     
    10399    cif.pres_offset  = CYCLE_TIMER_GET_OFFSET(m_full_timestamp); 
    104100    cif.pres_ticks   = m_full_timestamp_ticks; 
    105      
     101 
    106102    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", 
    108104        cif.pres_offset, syt_timestamp & 0xFFF, m_full_timestamp, syt_timestamp); 
    109105    } 
    110106    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", 
    112108            cif.pres_cycle &0xF, (syt_timestamp & 0xF000)>>12, m_full_timestamp, syt_timestamp); 
    113109    } 
    114      
     110 
    115111    putCycleInfo(&cif); 
    116112 
     
    119115 
    120116bool 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)) 
    130118        !=sizeof(struct cycle_info)) { 
    131119        return false; 
    132120    } 
    133121    return true; 
    134      
     122
     123 
     124bool 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 
    135131} 
    136132 
    137133bool SytMonitor::consumeNextCycleInfo() { 
    138134    struct cycle_info cif; 
    139     if(freebob_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)) 
    140136        !=sizeof(struct cycle_info)) { 
    141137        return false; 
     
    147143{ 
    148144    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)); 
    151147}; 
  • trunk/libffado/tests/SytMonitor.h

    r419 r445  
    1 /* $Id$ */ 
    2  
    31/* 
    4  *   FreeBob Streaming API 
    5  *   FreeBob = Firewire (pro-)audio for linux 
     2 * Copyright (C) 2005-2007 by Pieter Palmers 
    63 * 
    7  *   http://freebob.sf.net 
     4 * This file is part of FFADO 
     5 * FFADO = Free Firewire (pro-)audio drivers for linux 
    86 * 
    9  *   Copyright (C) 2007 Pieter Palmers <pieterpalmers@users.sourceforge.net> 
     7 * FFADO is based upon FreeBoB 
    108 * 
    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. 
    1517 * 
    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. 
    2622 * 
    2723 */ 
    28 #ifndef __FREEBOB_SYTMONITOR__ 
    29 #define __FREEBOB_SYTMONITOR__ 
     24 
     25#ifndef __FFADO_SYTMONITOR__ 
     26#define __FFADO_SYTMONITOR__ 
    3027#include "src/libstreaming/IsoStream.h" 
    3128#include "src/libstreaming/cip.h" 
     
    4643}; 
    4744 
    48 class SytMonitor  
     45class SytMonitor 
    4946    : public IsoStream 
    5047{ 
     
    5350        SytMonitor(int port); 
    5451        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 
    6562        bool readNextCycleInfo(struct cycle_info *cif); 
    6663        bool consumeNextCycleInfo(); 
    67          
     64 
    6865        bool putCycleInfo(struct cycle_info *cif); 
    69          
     66 
    7067        IsoHandler * getHandler() {return m_handler;}; 
    71          
    72         protected: 
    73            freebob_ringbuffer_t * m_cinfo_buffer; 
    74          
    75          
    76                 DECLARE_DEBUG_MODULE; 
    77                  
    78             
    7968 
     69    protected: 
     70        ffado_ringbuffer_t * m_cinfo_buffer; 
     71 
     72        DECLARE_DEBUG_MODULE; 
    8073}; 
    8174 
    8275 
    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 */ 
    1924 
    2025#ifdef HAVE_CONFIG_H 
     
    5156 
    5257struct 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; 
    5661}; 
    5762 
    5863uint64_t ctr_to_quadlet(struct CYCLE_TIMER_REGISTER x) { 
    5964    uint64_t retval=0; 
    60      
     65 
    6166    x.seconds &= 0x7F; 
    62      
     67 
    6368    x.cycles &= 0x1FFF; 
    6469    x.cycles %= 8000; 
    65      
     70 
    6671    x.offset &= 0xFFF; 
    6772    x.offset %= 3072; 
    68      
     73 
    6974    retval = (x.seconds << 25) + (x.cycles << 12) + (x.offset); 
    7075    return retval & 0xFFFFFFFF; 
     
    7378static void sighandler (int sig) 
    7479{ 
    75        run = 0; 
     80    run = 0; 
    7681} 
    7782 
    7883int do_cycletimer_test() { 
    79      
     84 
    8085    struct CYCLE_TIMER_REGISTER cycle_timer; 
    8186    uint32_t *cycle_timer_as_uint=(uint32_t *)&cycle_timer; 
    82      
     87 
    8388    uint32_t i=0; 
    8489    uint32_t targetval=0; 
    85      
     90 
    8691    int failures=0; 
    87      
    88      
     92 
     93 
    8994    // test 1 
    90     //  
    91      
     95    // 
     96 
    9297    *cycle_timer_as_uint=0; 
    9398    for (i=0;i<3072;i++) { 
    9499        cycle_timer.offset=i; 
    95100        targetval=CYCLE_TIMER_GET_OFFSET(ctr_to_quadlet(cycle_timer)); 
    96          
     101 
    97102        if(targetval != i) { 
    98103            debugOutput(DEBUG_LEVEL_NORMAL, "  test1 failed on i=%d (%08X), returns %d (%08X)\n",i,i,targetval,targetval); 
     
    100105        } 
    101106    } 
    102      
     107 
    103108    for (i=0;i<8000;i++) { 
    104109        cycle_timer.cycles=i; 
    105110        targetval=CYCLE_TIMER_GET_CYCLES(ctr_to_quadlet(cycle_timer)); 
    106          
     111 
    107112        if(targetval != i) { 
    108113            debugOutput(DEBUG_LEVEL_NORMAL, "  test2 failed on i=%d (%08X), returns %d (%08X)\n",i,i,targetval,targetval); 
     
    110115        } 
    111116    } 
    112      
     117 
    113118    for (i=0;i<128;i++) { 
    114119        cycle_timer.seconds=i; 
    115120        targetval=CYCLE_TIMER_GET_SECS(ctr_to_quadlet(cycle_timer)); 
    116          
     121 
    117122        if(targetval != i) { 
    118123            debugOutput(DEBUG_LEVEL_NORMAL, "  test3 failed on i=%d (%08X), returns %d (%08X)\n",i,i,targetval,targetval); 
     
    120125        } 
    121126    } 
    122      
    123      
     127 
     128 
    124129    // a value in ticks 
    125130    // should be: 10sec, 1380cy, 640ticks 
     
    128133    cycle_timer.cycles  = TICKS_TO_CYCLES(targetval); 
    129134    cycle_timer.offset  = TICKS_TO_OFFSET(targetval); 
    130      
     135 
    131136    if((cycle_timer.seconds != 10) | 
    132137        (cycle_timer.cycles != 1380) | 
     
    139144         debugOutput(DEBUG_LEVEL_NORMAL, "  test4 ok\n"); 
    140145    } 
    141      
     146 
    142147    i=TICKS_TO_CYCLE_TIMER(targetval); 
    143148    if (i != 0x14564280) { 
    144149         debugOutput(DEBUG_LEVEL_NORMAL, "  test5 failed: (0x%08X,0x14564280)\n", 
    145150            i); 
    146         failures++;    
     151        failures++; 
    147152    } else { 
    148153         debugOutput(DEBUG_LEVEL_NORMAL, "  test5 ok\n"); 
    149154    } 
    150      
     155 
    151156    targetval=CYCLE_TIMER_TO_TICKS(i); 
    152157    if (targetval!=250000000L) { 
    153158         debugOutput(DEBUG_LEVEL_NORMAL, "  test6 failed: (%u,250000000)\n", 
    154159            targetval); 
    155         failures++;    
     160        failures++; 
    156161    } else { 
    157162         debugOutput(DEBUG_LEVEL_NORMAL, "  test6 ok\n"); 
    158163    } 
    159      
     164 
    160165    int32_t subs; 
    161166    subs=diffTicks(10, 8); 
     
    163168         debugOutput(DEBUG_LEVEL_NORMAL, "  diffTicks(10, 8) != 2 : %ld\n", 
    164169            subs); 
    165         failures++;    
    166     } 
    167      
     170        failures++; 
     171    } 
     172 
    168173    subs=diffTicks(10, 12); 
    169174    if (subs != -2) { 
    170175         debugOutput(DEBUG_LEVEL_NORMAL, "  diffTicks(10, 12) != -2 : %ld\n", 
    171176            subs); 
    172         failures++;    
    173     } 
    174      
     177        failures++; 
     178    } 
     179 
    175180    subs=diffTicks(TICKS_PER_SECOND*128L + 10, 8); 
    176181    if (subs != 2) { 
    177182         debugOutput(DEBUG_LEVEL_NORMAL, "  diffTicks(TICKS_PER_SECOND*128L + 10, 8) != 2 : %ld\n", 
    178183            subs); 
    179         failures++;    
    180     } 
    181      
     184        failures++; 
     185    } 
     186 
    182187    subs=diffTicks(TICKS_PER_SECOND*128L + 10, 12); 
    183188    if (subs != -2) { 
    184189         debugOutput(DEBUG_LEVEL_NORMAL, "  diffTicks(TICKS_PER_SECOND*128L + 10, 12) != -2 : %ld\n", 
    185190            subs); 
    186         failures++;    
    187     } 
    188      
     191        failures++; 
     192    } 
     193 
    189194    subs=diffTicks(10, TICKS_PER_SECOND*128L + 8); 
    190195    if (subs != 2) { 
    191196         debugOutput(DEBUG_LEVEL_NORMAL, "  diffTicks(10, TICKS_PER_SECOND*128L + 8) != 2 : %ld\n", 
    192197            subs); 
    193         failures++;    
    194     } 
    195      
     198        failures++; 
     199    } 
     200 
    196201    subs=diffTicks(10, TICKS_PER_SECOND*128L + 12); 
    197202    if (subs != -2) { 
     
    200205        failures++; 
    201206    } 
    202      
     207 
    203208    //--------- 
    204209    // now = 10sec, 1380cy, 640ticks 
    205      
     210 
    206211    uint32_t st=sytRecvToFullTicks(0x1234, 1000, 0x14564280); 
    207212    if (st != 248860212LLU) { 
    208213         debugOutput(DEBUG_LEVEL_NORMAL, "  sytToRecvFullTicks(0x1234, 1000, 0x14564280) != 248860212 : %011lu\n", 
    209214            st); 
    210         failures++;    
    211     } 
    212      
     215        failures++; 
     216    } 
     217 
    213218    st=sytRecvToFullTicks(0xB2B6, 7000, TICKS_TO_CYCLE_TIMER(3118082282LU)); 
    214219    if (st != 3118089910LLU) { 
    215220         debugOutput(DEBUG_LEVEL_NORMAL, "  sytToRecvFullTicks(0x1234, 1000, %08X) != 3118089910 : %011lu\n", 
    216221            TICKS_TO_CYCLE_TIMER(3118082282LU), st); 
    217         failures++;    
    218     } 
    219      
     222        failures++; 
     223    } 
     224 
    220225    st=sytXmitToFullTicks(0xC4EA, 3000, TICKS_TO_CYCLE_TIMER(2958285668LU)); 
    221226    if (st != 2958349546LLU) { 
    222227         debugOutput(DEBUG_LEVEL_NORMAL, "  sytToXmitFullTicks(0x1234, 1000, %08X) != 2958349546 : %011lu\n", 
    223228            TICKS_TO_CYCLE_TIMER(2958285668LU), st); 
    224         failures++;    
    225     } 
    226      
     229        failures++; 
     230    } 
     231 
    227232    if (failures) { 
    228233        debugOutput(DEBUG_LEVEL_NORMAL, " %d failures\n",failures); 
     
    237242{ 
    238243 
    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 
    244249    IsoStream *s=NULL; 
    245250#endif 
    246 #ifdef TEST_PORT_1      
     251#ifdef TEST_PORT_1 
    247252    IsoStream *s2=NULL; 
    248253#endif 
     
    251256#endif 
    252257 
    253        signal (SIGINT, sighandler); 
    254        signal (SIGPIPE, sighandler); 
    255  
    256        debugOutput(DEBUG_LEVEL_NORMAL, "Freebob Cycle 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 do 
    285        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 do 
    309        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 do 
    333        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) { 
    368373        sleep(1); 
    369374        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 
    402407    delete m_isoManager; 
    403408 
    404409finish: 
    405        debugOutput(DEBUG_LEVEL_NORMAL, "Bye...\n"); 
     410    debugOutput(DEBUG_LEVEL_NORMAL, "Bye...\n"); 
    406411 
    407412  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 
    710 * it under the terms of the GNU General Public License as published by 
    811 * the Free Software Foundation; either version 2 of the License, or 
    912 * (at your option) any later version. 
    10  * FreeBoB is distributed in the hope that it will be useful, 
     13 * FFADO is distributed in the hope that it will be useful, 
    1114 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    1215 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     
    1417 * 
    1518 * You should have received a copy of the GNU General Public License 
    16  * along with FreeBoB; if not, write to the Free Software 
     19 * along with FFADO; if not, write to the Free Software 
    1720 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
    1821 * MA 02111-1307 USA. 
     22 * 
    1923 */ 
    2024 
     
    3438//////////////////////////////////////////////// 
    3539const char *argp_program_version = "test-extplugcmd 0.2"; 
    36 const char *argp_program_bug_address = "<freebob-devel@lists.sf.net>"; 
     40const char *argp_program_bug_address = "<ffado-devel@lists.sf.net>"; 
    3741static char doc[] = "test-extplugcmd -- tests some extended plug info commands on a BeBoB device"; 
    3842static char args_doc[] = "NODE_ID"; 
     
    206210    int node_id = strtol(arguments.args[0], &tail, 0); 
    207211    if (errno) { 
    208        perror("argument parsing failed:"); 
    209        return -1; 
     212    perror("argument parsing failed:"); 
     213    return -1; 
    210214    } 
    211215    Ieee1394Service ieee1394service; 
  • trunk/libffado/tests/test-ffado.cpp

    r443 r445  
    1 /* test-freebob.c 
    2  * Copyright (C) 2005 by Daniel Wagner 
    3  * Copyright (C) 2007 by Pieter Palmers 
     1/* 
     2 * Copyright (C) 2005-2007 by by Daniel Wagner 
     3 * Copyright (C) 2005-2007 by by Pieter Palmers 
    44 * 
    5  * This file is part of FreeBoB. 
     5 * This file is part of FFADO 
     6 * FFADO = Free Firewire (pro-)audio drivers for linux 
    67 * 
    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 
    811 * it under the terms of the GNU General Public License as published by 
    912 * the Free Software Foundation; either version 2 of the License, or 
    1013 * (at your option) any later version. 
    11  * FreeBoB is distributed in the hope that it will be useful, 
     14 * FFADO is distributed in the hope that it will be useful, 
    1215 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    1316 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     
    1518 * 
    1619 * You should have received a copy of the GNU General Public License 
    17  * along with FreeBoB; if not, write to the Free Software 
     20 * along with FFADO; if not, write to the Free Software 
    1821 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
    1922 * MA 02111-1307 USA. 
     
    2629#include <config.h> 
    2730 
    28 #include "libfreebob/freebob.h" 
     31#include "libffado/ffado.h" 
    2932 
    3033#include "debugmodule/debugmodule.h" 
     
    6063string osc_value; 
    6164 
    62 int osc_path_response_handler(const char *path, const char *types, lo_arg **argv, int argc,  
     65int osc_path_response_handler(const char *path, const char *types, lo_arg **argv, int argc, 
    6366    void *data, void *user_data); 
    64      
    65 int osc_param_response_handler(const char *path, const char *types, lo_arg **argv, int argc,  
     67 
     68int osc_param_response_handler(const char *path, const char *types, lo_arg **argv, int argc, 
    6669    void *data, void *user_data); 
    67      
    68 int osc_data_response_handler(const char *path, const char *types, lo_arg **argv, int argc,  
     70 
     71int osc_data_response_handler(const char *path, const char *types, lo_arg **argv, int argc, 
    6972    void *data, void *user_data); 
    70      
     73 
    7174void osc_error_handler(int num, const char *msg, const char *path); 
    7275 
     
    8386 
    8487// Program documentation. 
    85 static char doc[] = "FreeBoB -- a driver for Firewire Audio devices (test application)\n\n" 
     88static char doc[] = "FFADO -- a driver for Firewire Audio devices (test application)\n\n" 
    8689                    "OPERATION: Discover\n" 
    8790                    "           SetSamplerate\n" 
     
    99102    int   node_id; 
    100103    int   node_id_set; 
    101     char* args[2];   
     104    char* args[2]; 
    102105}; 
    103106 
     
    134137            arguments->verbose = strtol( arg, &tail, 0 ); 
    135138            if ( errno ) { 
    136                 debugError(  "Could not parse 'verbose' argument\n" ); 
     139                fprintf( stderr,  "Could not parse 'verbose' argument\n" ); 
    137140                return ARGP_ERR_UNKNOWN; 
    138141            } 
     
    143146            arguments->port = strtol( arg, &tail, 0 ); 
    144147            if ( errno ) { 
    145                 debugError(  "Could not parse 'port' argument\n" ); 
     148                fprintf( stderr,  "Could not parse 'port' argument\n" ); 
    146149                return ARGP_ERR_UNKNOWN; 
    147150            } 
    148151        } else { 
    149152            if ( errno ) { 
    150                 debugError( "Could not parse 'port' argumen\n" ); 
     153                fprintf( stderr, "Could not parse 'port' argumen\n" ); 
    151154                return ARGP_ERR_UNKNOWN; 
    152155            } 
     
    157160            arguments->node_id = strtol( arg, &tail, 0 ); 
    158161            if ( errno ) { 
    159                 debugError(  "Could not parse 'node' argument\n" ); 
     162                fprintf( stderr,  "Could not parse 'node' argument\n" ); 
    160163                return ARGP_ERR_UNKNOWN; 
    161164            } 
     
    163166        } else { 
    164167            if ( errno ) { 
    165                 debugError( "Could not parse 'node' argumen\n" ); 
     168                fprintf( stderr, "Could not parse 'node' argumen\n" ); 
    166169                return ARGP_ERR_UNKNOWN; 
    167170            } 
     
    197200    // Default values. 
    198201    arguments.silent      = 0; 
    199     arguments.verbose     = DEBUG_LEVEL_NORMAL
     202    arguments.verbose     = 0
    200203    arguments.port        = 0; 
    201204    arguments.node_id     = 0; 
     
    207210    // be reflected in `arguments'. 
    208211    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" ); 
    210213        return -1; 
    211214    } 
    212215 
    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 
    219220    if ( strcmp( arguments.args[0], "Discover" ) == 0 ) { 
    220221        DeviceManager *m_deviceManager = new DeviceManager(); 
    221222        if ( !m_deviceManager ) { 
    222             debugError( "Could not allocate device manager\n" ); 
     223            fprintf( stderr, "Could not allocate device manager\n" ); 
    223224            return -1; 
    224225        } 
    225226        if ( !m_deviceManager->initialize( arguments.port ) ) { 
    226             debugError( "Could not initialize device manager\n" ); 
     227            fprintf( stderr, "Could not initialize device manager\n" ); 
    227228            delete m_deviceManager; 
    228229            return -1; 
    229230        } 
    230  
    231         m_deviceManager->setVerboseLevel(arguments.verbose); 
     231        if ( arguments.verbose ) { 
     232            m_deviceManager->setVerboseLevel(arguments.verbose); 
     233        } 
    232234        if ( !m_deviceManager->discover() ) { 
    233             debugError( "Could not discover devices\n" ); 
     235            fprintf( stderr, "Could not discover devices\n" ); 
    234236            delete m_deviceManager; 
    235237            return -1; 
    236238        } 
    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          
    250239        delete m_deviceManager; 
    251240        return 0; 
     
    254243        int samplerate = strtol( arguments.args[1], &tail, 0 ); 
    255244        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 
    260249        DeviceManager *m_deviceManager = new DeviceManager(); 
    261250        if ( !m_deviceManager ) { 
    262             debugError( "Could not allocate device manager\n" ); 
     251            fprintf( stderr, "Could not allocate device manager\n" ); 
    263252            return -1; 
    264253        } 
    265254        if ( !m_deviceManager->initialize( arguments.port ) ) { 
    266             debugError( "Could not initialize device manager\n" ); 
     255            fprintf( stderr, "Could not initialize device manager\n" ); 
    267256            delete m_deviceManager; 
    268257            return -1; 
    269258        } 
    270          
    271         m_deviceManager->setVerboseLevel(arguments.verbose); 
     259        if ( arguments.verbose ) { 
     260            m_deviceManager->setVerboseLevel(arguments.verbose); 
     261        } 
    272262        if ( !m_deviceManager->discover() ) { 
    273             debugError( "Could not discover devices\n" ); 
     263            fprintf( stderr, "Could not discover devices\n" ); 
    274264            delete m_deviceManager; 
    275265            return -1; 
    276266        } 
    277      
     267 
    278268        if(arguments.node_id_set) { 
    279269            IAvDevice* avDevice = m_deviceManager->getAvDevice( arguments.node_id ); 
    280270            if ( avDevice ) { 
    281                 if ( avDevice->setSampleRate( parseSampleRate( samplerate ) ) ) { 
     271                if ( avDevice->setSamplingFrequency( parseSampleRate( samplerate ) ) ) { 
    282272                    m_deviceManager->discover(); 
    283273                } else { 
    284                     debugError( "Could not set samplerate\n" ); 
     274                    fprintf( stderr, "Could not set samplerate\n" ); 
    285275                } 
    286276            } 
    287277        } else { 
    288278            int i=0; 
    289                  
     279 
    290280            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 
    293283            for(i=0;i<devices_on_bus;i++) { 
    294284                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); 
    296286                IAvDevice* avDevice = m_deviceManager->getAvDevice( node_id ); 
    297287                if ( avDevice ) { 
    298                     if ( !avDevice->setSampleRate( parseSampleRate( samplerate ) ) ) { 
    299                         debugError( "Could not set samplerate\n" ); 
     288                    if ( !avDevice->setSamplingFrequency( parseSampleRate( samplerate ) ) ) { 
     289                        fprintf( stderr, "Could not set samplerate\n" ); 
    300290                    } 
    301291                } 
     
    307297        // list osc space by using OSC messages 
    308298        // a server is assumed to be present 
    309          
     299 
    310300        /* start a new server. 
    311301        when sending a message from this context, the response 
     
    314304        lo_server s = lo_server_new(NULL, osc_error_handler); 
    315305        lo_address t = lo_address_new(NULL, "17820"); 
    316          
     306 
    317307        list_osc_paths(s, t, "/"); 
    318          
     308 
    319309        lo_address_free(t); 
    320310        lo_server_free(s); 
    321          
     311 
    322312    } else if ( strcmp( arguments.args[0], "OscServer" ) == 0 ) { 
    323313        DeviceManager *m_deviceManager = new DeviceManager(); 
    324314        if ( !m_deviceManager ) { 
    325             debugError( "Could not allocate device manager\n" ); 
     315            fprintf( stderr, "Could not allocate device manager\n" ); 
    326316            return -1; 
    327317        } 
    328318        if ( !m_deviceManager->initialize( arguments.port ) ) { 
    329             debugError( "Could not initialize device manager\n" ); 
     319            fprintf( stderr, "Could not initialize device manager\n" ); 
    330320            delete m_deviceManager; 
    331321            return -1; 
    332322        } 
    333          
    334         m_deviceManager->setVerboseLevel(arguments.verbose); 
     323        if ( arguments.verbose ) { 
     324            m_deviceManager->setVerboseLevel(arguments.verbose); 
     325        } 
    335326        if ( !m_deviceManager->discover() ) { 
    336             debugError( "Could not discover devices\n" ); 
     327            fprintf( stderr, "Could not discover devices\n" ); 
    337328            delete m_deviceManager; 
    338329            return -1; 
    339330        } 
    340331 
    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 
    344335        signal (SIGINT, sighandler); 
    345          
     336 
    346337        run=1; 
    347338        while(run) { 
     
    351342        } 
    352343        signal (SIGINT, SIG_DFL); 
    353          
    354         debugOutput(DEBUG_LEVEL_NORMAL, "server stopped\n"); 
     344 
     345        printf("server stopped\n"); 
    355346        delete m_deviceManager; 
    356347        return 0; 
    357          
     348 
    358349    } else { 
    359         debugOutput(DEBUG_LEVEL_NORMAL, "unknown operation\n" ); 
     350        printf( "unknown operation\n" ); 
    360351    } 
    361352 
     
    364355void list_osc_paths(lo_server s, lo_address t, const char *path) { 
    365356    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 
    369360    osc_paths.clear(); 
    370361    lo_server_add_method(s, "/response", NULL, osc_path_response_handler, NULL); 
    371362 
    372363    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)); 
    374365    } 
    375366 
    376367    if (lo_server_recv_noblock(s, 1000) == 0) { 
    377         debugOutput(DEBUG_LEVEL_NORMAL, "timeout\n"); 
     368        printf("timeout\n"); 
    378369        return; 
    379370    } 
    380      
     371 
    381372    lo_server_del_method(s, "/response", NULL); 
    382      
     373 
    383374    list_osc_params(s, t, path); 
    384      
     375 
    385376    my_paths=osc_paths; 
    386377    for ( vector<string>::iterator it = my_paths.begin(); 
     
    397388void list_osc_params(lo_server s, lo_address t, const char *path) { 
    398389    vector<string> my_paths; 
    399     debugOutput(DEBUG_LEVEL_NORMAL, "params for: %s\n", path); 
    400      
     390    printf("params for: %s\n", path); 
     391 
    401392    osc_params.clear(); 
    402393    lo_server_add_method(s, "/response", NULL, osc_param_response_handler, NULL); 
    403394 
    404395    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 
    408399    if (lo_server_recv_noblock(s, 1000) == 0) { 
    409         debugOutput(DEBUG_LEVEL_NORMAL, "timeout\n"); 
     400        printf("timeout\n"); 
    410401        return; 
    411402    } 
    412      
     403 
    413404    lo_server_del_method(s, "/response", NULL); 
    414      
     405 
    415406    vector<string> my_params=osc_params; 
    416      
     407 
    417408    for ( vector<string>::iterator it = my_params.begin(); 
    418409            it != my_params.end(); 
     
    420411    { 
    421412        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()); 
    423414    } 
    424415 
     
    429420 
    430421    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 
    434425    if (lo_server_recv_noblock(s, 1000) == 0) { 
    435426        return string("timeout"); 
    436427    } 
    437      
     428 
    438429    lo_server_del_method(s, "/response", NULL); 
    439430    return osc_value; 
     
    442433void osc_error_handler(int num, const char *msg, const char *path) 
    443434{ 
    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); 
    445436} 
    446437 
     
    455446                break; 
    456447            default: 
    457                 debugOutput(DEBUG_LEVEL_NORMAL, "unexpected data type in response message\n"); 
     448                printf("unexpected data type in response message\n"); 
    458449        } 
    459450    } 
     
    471462                break; 
    472463            default: 
    473                 debugOutput(DEBUG_LEVEL_NORMAL, "unexpected data type in response message\n"); 
     464                printf("unexpected data type in response message\n"); 
    474465        } 
    475466    } 
     
    481472{ 
    482473    std::ostringstream str; 
    483      
     474 
    484475    if(argc==1) { 
    485476        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 
    710 * it under the terms of the GNU General Public License as published by 
    811 * the Free Software Foundation; either version 2 of the License, or 
    912 * (at your option) any later version. 
    10  * FreeBoB is distributed in the hope that it will be useful, 
     13 * FFADO is distributed in the hope that it will be useful, 
    1114 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    1215 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     
    1417 * 
    1518 * You should have received a copy of the GNU General Public License 
    16  * along with FreeBoB; if not, write to the Free Software 
     19 * along with FFADO; if not, write to the Free Software 
    1720 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
    1821 * MA 02111-1307 USA. 
     22 * 
    1923 */ 
    2024 
     
    3236//////////////////////////////////////////////// 
    3337const char *argp_program_version = "test-fw410 0.1"; 
    34 const char *argp_program_bug_address = "<freebob-devel@lists.sf.net>"; 
     38const char *argp_program_bug_address = "<ffado-devel@lists.sf.net>"; 
    3539static char doc[] = "test-fw410 -- test program to get the fw410 streaming"; 
    3640static char args_doc[] = "NODE_ID"; 
     
    115119    int iNodeId = strtol(arguments.args[0], &tail, 0); 
    116120    if (errno) { 
    117        perror("argument parsing failed:"); 
    118        return -1; 
     121    perror("argument parsing failed:"); 
     122    return -1; 
    119123    } 
    120124 
     
    158162        Connection* pCons = &cons[i]; 
    159163 
    160         // the bandwith calculation fails, so its better to use  
     164        // the bandwith calculation fails, so its better to use 
    161165        // some default values. 
    162166        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 */ 
    1924 
    2025#ifdef HAVE_CONFIG_H 
     
    6469    signal (SIGPIPE, sighandler); 
    6570 
    66     printf("Freebob Ieee1394Service test application\n"); 
    67      
     71    printf("FFADO Ieee1394Service test application\n"); 
     72 
    6873    Ieee1394Service *m_service=NULL; 
    6974 
    7075    m_service=new Ieee1394Service(); 
    7176    m_service->initialize(2); 
    72      
     77 
    7378    MyFunctor *test_busreset=new MyFunctor(); 
    74      
     79 
    7580    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 
    7984    nodeaddr_t addr =  m_service->findFreeARMBlock(0x0000FFFFE0000000ULL, 4, 4 ); 
    80      
     85 
    8186    ARMHandler *test_arm=new ARMHandler(addr, 
    8287                         4, 
     
    8489                         RAW1394_ARM_READ | RAW1394_ARM_WRITE | RAW1394_ARM_LOCK, 
    8590                         0); 
    86      
     91 
    8792    printf(" adding (%p) as arm handler\n", test_arm); 
    88      
     93 
    8994    if (!m_service->registerARMHandler(test_arm)) { 
    9095        printf("  failed\n"); 
    9196    } 
    92      
     97 
    9398    addr =  m_service->findFreeARMBlock(0x0000FFFFE0000000ULL, 4, 4 ); 
    94                           
     99 
    95100    ARMHandler *test_arm2=new ARMHandler(addr, 
    96101                         4, 
     
    100105 
    101106    printf(" adding (%p) as arm handler\n", test_arm2); 
    102      
     107 
    103108    if (!m_service->registerARMHandler(test_arm2)) { 
    104109        printf("  failed\n"); 
    105110    } 
    106      
     111 
    107112    while(run) { 
    108113        fflush(stderr); 
     
    115120    delete test_arm; 
    116121    delete test_arm2; 
    117      
     122 
    118123    printf("Bye...\n"); 
    119124 
  • 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 */ 
    2024 
    2125#include "libavc/avc_function_block.h" 
     
    5054        ieee1394service.setVerboseLevel( DEBUG_LEVEL_VERY_VERBOSE ); 
    5155    } 
    52      
     56 
    5357    if ( !fbCmd.fire() ) { 
    5458        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 */ 
    1923 
    2024#ifdef HAVE_CONFIG_H 
     
    5155int run; 
    5256// Program documentation. 
    53 static char doc[] = "FreeBoB -- SYT monitor application\n\n"; 
     57static char doc[] = "FFADO -- SYT monitor application\n\n"; 
    5458 
    5559// A description of the arguments we accept. 
     
    109113        case 'R': 
    110114        arguments->realtime = true; 
    111             break;          
     115            break; 
    112116        case 'r': 
    113117            if (arg) { 
     
    118122            } 
    119123            } 
    120             break;                  
     124            break; 
    121125        case ARGP_KEY_ARG: 
    122126            if (state->arg_num >= 128) { 
     
    124128            argp_usage( state ); 
    125129            } 
    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, 
    129133            &arguments->args[state->arg_num].channel) != 2) { 
    130134        fprintf( stderr,  "Could not parse port-channel specification ('%s')\n", arg); 
    131              
     135 
    132136            } else { 
    133137            printf("Adding Port %d, Channel %d to list...\n", 
     
    166170    struct sched_param params; 
    167171    uint64_t last_print_time=0; 
    168      
     172 
    169173    SystemTimeSource masterTimeSource; 
    170      
     174 
    171175    IsoHandlerManager *m_isoManager=NULL; 
    172      
     176 
    173177    SytMonitor *monitors[128]; 
    174178    int64_t stream_offset_ticks[128]; 
     
    189193        goto finish; 
    190194    } 
    191      
     195 
    192196    memset(&stream_offset_ticks, 0, sizeof(int64_t) * 128); 
    193      
     197 
    194198    run=1; 
    195      
     199 
    196200    run_realtime=arguments.realtime; 
    197201    realtime_prio=arguments.rtprio; 
     
    200204    signal (SIGPIPE, sighandler); 
    201205 
    202     debugOutput(DEBUG_LEVEL_NORMAL, "Freebob SYT monitor\n"); 
    203      
     206    debugOutput(DEBUG_LEVEL_NORMAL, "FFADO SYT monitor\n"); 
     207 
    204208    m_isoManager=new IsoHandlerManager(); 
    205      
     209 
    206210    if(!m_isoManager) { 
    207211        debugOutput(DEBUG_LEVEL_NORMAL, "Could not create IsoHandlerManager\n"); 
    208212        goto finish; 
    209213    } 
    210          
     214 
    211215    m_isoManager->setVerboseLevel(DEBUG_LEVEL_VERBOSE); 
    212              
     216 
    213217    if(!m_isoManager->init()) { 
    214218        debugOutput(DEBUG_LEVEL_NORMAL, "Could not init() IsoHandlerManager\n"); 
     
    219223        for (i=0;i<arguments.nb_combos;i++) { 
    220224            debugOutput(DEBUG_LEVEL_NORMAL, "Registering SytMonitor %d\n",i); 
    221          
     225 
    222226            // add a stream to the manager so that it has something to do 
    223227            monitors[i]=new SytMonitor(arguments.args[i].port); 
    224              
     228 
    225229            if (!monitors[i]) { 
    226230                debugOutput(DEBUG_LEVEL_NORMAL, "Could not create SytMonitor %d\n", i); 
    227231                goto finish; 
    228             }   
    229          
     232            } 
     233 
    230234            monitors[i]->setVerboseLevel(DEBUG_LEVEL_VERBOSE); 
    231          
     235 
    232236            if (!monitors[i]->init()) { 
    233237                debugOutput(DEBUG_LEVEL_NORMAL, "Could not init SytMonitor %d\n", i); 
    234238                goto finish; 
    235239            } 
    236          
     240 
    237241            monitors[i]->setChannel(arguments.args[i].channel); 
    238              
     242 
    239243            if(!m_isoManager->registerStream(monitors[i])) { 
    240244                debugOutput(DEBUG_LEVEL_NORMAL, "Could not register SytMonitor %d with isoManager\n", i); 
     
    258262                goto finish; 
    259263        } 
    260          
     264 
    261265        if (arguments.realtime) { 
    262266            // get rt priority for this thread too. 
     
    266270            } 
    267271        } 
    268      
     272 
    269273        // do the actual work 
    270274        nb_iter=0; 
    271          
     275 
    272276        while(run) { 
    273277        debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"--- Iterate ---\n"); 
    274          
     278 
    275279//         if(!m_isoManager->iterate()) { 
    276280//             debugFatal("Could not iterate the isoManager\n"); 
    277281//             return false; 
    278282//         } 
    279          
     283 
    280284        if(!masterTimeSource.updateTimeSource()) { 
    281285            debugFatal("Could not update the masterTimeSource\n"); 
    282286            return false; 
    283287        } 
    284          
     288 
    285289        debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"--- Process ---\n"); 
    286290        // process the cycle info's 
     
    288292            int master_guard=0; 
    289293            struct cycle_info master_cif; 
    290              
     294 
    291295            bool advance_master=true; 
    292              
     296 
    293297            while (advance_master && monitors[0]->readNextCycleInfo(&master_cif)) { 
    294298                advance_master=true; 
    295              
     299 
    296300                master_guard++; 
    297301                if(master_guard>1000) { 
    298302                    debugWarning("Guard passed on master sync!\n"); 
    299303                    break; 
    300                 }             
     304                } 
    301305                // we try to match the packets received on equal cycles 
    302                  
     306 
    303307                // unwrap the seconds counter 
    304308                if (master_cif.seconds==0) master_cif.seconds+=128; 
    305                  
     309 
    306310                debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"MASTER: [%2d: %04us %04uc, %04X]\n", 
    307311                    0,master_cif.seconds,master_cif.cycle,master_cif.syt); 
    308                  
     312 
    309313                for (i=1;i<arguments.nb_combos;i++) { 
    310314                    struct cycle_info cif; 
    311315                    int slave_guard=0; 
    312316                    bool read_slave=monitors[i]->readNextCycleInfo(&cif); 
    313                      
     317 
    314318                    while(read_slave) { 
    315319                        slave_guard++; 
     
    326330                                i,cif.seconds, cif.cycle,cif.syt); 
    327331                            monitors[i]->consumeNextCycleInfo(); 
    328                              
     332 
    329333                            // we have a match ;) 
    330334                            if ((cif.syt != 0xFFFF) && (master_cif.syt != 0xFFFF)) { 
     
    338342                            // average out the offset 
    339343                                int64_t err=(((uint64_t)master_cif.pres_ticks) - ((uint64_t)cif.pres_ticks)); 
    340                                  
     344 
    341345                                debugOutput(DEBUG_LEVEL_NORMAL,"Diff for %d at cycle %04d: %6lld (MTS: %11llu | STS: %11llu\n", 
    342346                                    i,cif.cycle,err, master_cif.pres_ticks, cif.pres_ticks); 
    343                                  
     347 
    344348                                err = err - stream_offset_ticks[i]; 
    345                                  
     349 
    346350                                if(err>50000 || err < -50000) { 
    347351                                    debugOutput(DEBUG_LEVEL_NORMAL, 
    348352                                        " Large Diff: %dticks, delta=%d; avg=%d\n", 
    349353                                        err,(((int)master_cif.pres_ticks) - ((int)cif.pres_ticks)),stream_offset_ticks[i]); 
    350                                      
     354 
    351355                                    debugOutput(DEBUG_LEVEL_NORMAL, 
    352356                                        "  Master   : %04X -> %10u (%04us %04uc %04ut)\n", 
    353                                         master_cif.syt, master_cif.pres_ticks,  
     357                                        master_cif.syt, master_cif.pres_ticks, 
    354358                                        master_cif.pres_seconds, master_cif.pres_cycle, master_cif.pres_offset 
    355359                                        ); 
     
    359363                                        master_cif.syt, CYCLE_TIMER_GET_CYCLES(master_cif.syt), 
    360364                                        CYCLE_TIMER_GET_OFFSET(master_cif.syt)); 
    361                                          
     365 
    362366                                    debugOutput(DEBUG_LEVEL_NORMAL, 
    363367                                        "  Current  : %04X -> %10u (%04us %04uc %04ut)\n", 
    364                                         cif.syt, cif.pres_ticks,  
     368                                        cif.syt, cif.pres_ticks, 
    365369                                        cif.pres_seconds, cif.pres_cycle, cif.pres_offset 
    366370                                        ); 
     
    372376                                    debugOutput(DEBUG_LEVEL_NORMAL,"\n"); 
    373377                                } 
    374                                  
     378 
    375379                                stream_offset_ticks[i] += err/1000; 
    376                                      
     380 
    377381                                debugOutput(DEBUG_LEVEL_VERY_VERBOSE," Difference: %dticks\n", 
    378382                                        (((int)master_cif.pres_ticks) - ((int)cif.pres_ticks))); 
    379383                            } 
    380                              
     384 
    381385                            break; 
    382386                        } 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) 
    385389                                && (cif.cycle < master_cif.cycle))) { 
    386                                  
     390 
    387391                                debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"  LAGS : [%2d: %04us %04uc, %04X]\n", 
    388392                                    i,cif.seconds, cif.cycle,cif.syt); 
    389393                                // the stream lags behind 
    390                                  
     394 
    391395                                // advance the read pointer 
    392                                 // this will always succeed, otherwise we wouldn't be  
     396                                // this will always succeed, otherwise we wouldn't be 
    393397                                // in this while() 
    394398                                monitors[i]->consumeNextCycleInfo(); 
     
    396400                                debugOutput(DEBUG_LEVEL_VERY_VERBOSE,"  LEADS: [%2d: %04us %04uc, %04X]\n", 
    397401                                    i,cif.seconds, cif.cycle,cif.syt); 
    398                              
     402 
    399403                                // the stream is too far ahead, 
    400404                                // don't do anything 
     
    418422            } 
    419423        } 
    420          
     424 
    421425            // show info every x iterations 
    422             if (masterTimeSource.getCurrentTimeAsUsecs()  
     426            if (masterTimeSource.getCurrentTimeAsUsecs() 
    423427                - last_print_time > 1000000L) { 
    424                  
     428 
    425429                m_isoManager->dumpInfo(); 
    426430                for (i=0;i<arguments.nb_combos;i++) { 
     
    432436                last_print_time=masterTimeSource.getCurrentTimeAsUsecs(); 
    433437            } 
    434              
     438 
    435439            // 125us/packet, so sleep for a while 
    436440            usleep(100); 
     
    442446            goto finish; 
    443447        } 
    444          
     448 
    445449        // unregister monitors 
    446450        for (i=0;i<arguments.nb_combos;i++) { 
    447451        debugOutput(DEBUG_LEVEL_NORMAL, "Unregistering SytMonitor %d\n",i); 
    448          
     452 
    449453        if(!m_isoManager->unregisterStream(monitors[i])) { 
    450454            debugOutput(DEBUG_LEVEL_NORMAL, "Could not unregister SytMonitor %d\n",i); 
     
    453457            delete monitors[i]; 
    454458    } 
    455          
     459 
    456460    delete m_isoManager; 
    457461 
  • 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 */ 
    1923 
    2024#ifdef HAVE_CONFIG_H 
     
    4145using namespace Util; 
    4246 
    43 class TimestampedBufferTestClient  
     47class TimestampedBufferTestClient 
    4448    : public TimestampedBufferClient { 
    4549public: 
    4650    bool processReadBlock(char *data, unsigned int nevents, unsigned int offset) {return true;}; 
    4751    bool processWriteBlock(char *data, unsigned int nevents, unsigned int offset) {return true;}; 
    48      
     52 
    4953    void setVerboseLevel(int l) {setDebugLevel(l);}; 
    5054private: 
     
    5862int run; 
    5963// Program documentation. 
    60 static char doc[] = "FreeBoB -- Timestamped buffer test\n\n"; 
     64static char doc[] = "FFADO -- Timestamped buffer test\n\n"; 
    6165 
    6266// A description of the arguments we accept. 
     
    212216                } 
    213217            } 
    214             break;                         
     218            break; 
    215219       default: 
    216220            return ARGP_ERR_UNKNOWN; 
     
    230234int main(int argc, char *argv[]) 
    231235{ 
    232      
     236 
    233237    TimestampedBuffer *t=NULL; 
    234238    TimestampedBufferTestClient *c=NULL; 
    235      
     239 
    236240    struct arguments arguments; 
    237241 
     
    245249    arguments.buffersize = 1024; 
    246250    arguments.start_at_cycle = 0; 
    247      
     251 
    248252    // Parse our arguments; every option seen by `parse_opt' will 
    249253    // be reflected in `arguments'. 
     
    252256        exit(1); 
    253257    } 
    254      
     258 
    255259    setDebugLevel(arguments.verbose); 
    256      
     260 
    257261    run=1; 
    258262 
    259263    signal (SIGINT, sighandler); 
    260264    signal (SIGPIPE, sighandler); 
    261      
     265 
    262266    c=new TimestampedBufferTestClient(); 
    263      
     267 
    264268    if(!c) { 
    265269        debugOutput(DEBUG_LEVEL_NORMAL, "Could not create TimestampedBufferTestClient\n"); 
     
    267271    } 
    268272    c->setVerboseLevel(arguments.verbose); 
    269      
     273 
    270274    t=new TimestampedBuffer(c); 
    271      
     275 
    272276    if(!t) { 
    273277        debugOutput(DEBUG_LEVEL_NORMAL, "Could not create TimestampedBuffer\n"); 
     
    278282 
    279283    t->init(); 
    280      
    281     // Setup the buffer  
     284 
     285    // Setup the buffer 
    282286    t->setBufferSize(arguments.buffersize); 
    283287    t->setEventSize(sizeof(int)); 
     
    286290    t->setUpdatePeriod(arguments.frames_per_packet); 
    287291    t->setNominalRate(arguments.rate); 
    288      
     292 
    289293    t->setWrapValue(arguments.wrap_at); 
    290      
     294 
    291295    t->setTickOffset(10000); 
    292      
     296 
    293297    t->prepare(); 
    294      
     298 
    295299    usleep(1000); 
    296      
     300 
    297301    debugOutput(DEBUG_LEVEL_NORMAL, "Start setBufferHeadTimestamp test...\n"); 
    298302    { 
     
    300304        uint64_t time=arguments.start_at_cycle*3072; 
    301305        int dummyframe_in[arguments.events_per_frame*arguments.frames_per_packet]; 
    302          
     306 
    303307        // initialize the timestamp 
    304308        uint64_t timestamp=time; 
     
    307311            timestamp %= arguments.wrap_at; 
    308312        } 
    309          
     313 
    310314        // account for the fact that there is offset, 
    311315        // and that setBufferHeadTimestamp doesn't take offset 
     
    315319            timestamp2-=arguments.wrap_at; 
    316320        } 
    317          
     321 
    318322        t->setBufferHeadTimestamp(timestamp2); 
    319          
     323 
    320324        timestamp += (uint64_t)(arguments.rate * arguments.frames_per_packet); 
    321325        if (timestamp >= arguments.wrap_at) { 
    322326            timestamp -= arguments.wrap_at; 
    323327        } 
    324          
     328 
    325329        // write some packets 
    326330        for (unsigned int i=0;i<20;i++) { 
     
    331335            } 
    332336        } 
    333      
     337 
    334338        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; 
    336340            cycle++) { 
    337341                uint64_t ts_head, fc_head; 
    338                  
     342 
    339343                t->setBufferHeadTimestamp(timestamp); 
    340344                t->getBufferHeadTimestamp(&ts_head, &fc_head); 
    341                  
     345 
    342346                if (timestamp != ts_head) { 
    343347                    debugError(" cycle %4u error: %011llu != %011llu\n", 
     
    345349                        pass=false; 
    346350                } 
    347                  
     351 
    348352                timestamp += (uint64_t)(arguments.rate * arguments.frames_per_packet); 
    349353                if (timestamp >= arguments.wrap_at) { 
    350354                    timestamp -= arguments.wrap_at; 
    351355                } 
    352              
     356 
    353357            // simulate the cycle timer clock in ticks 
    354358            time += 3072; 
     
    356360                time -= arguments.wrap_at; 
    357361            } 
    358              
     362 
    359363            // allow for the messagebuffer thread to catch up 
    360364            usleep(200); 
    361              
     365 
    362366            if(!run) break; 
    363367        } 
    364          
     368 
    365369        if(!pass) { 
    366370            debugError("Test failed, exiting...\n"); 
    367      
     371 
    368372            delete t; 
    369373            delete c; 
    370              
     374 
    371375            return -1; 
    372              
    373         } 
    374     } 
    375      
    376  
    377      
     376 
     377        } 
     378    } 
     379 
     380 
     381 
    378382    debugOutput(DEBUG_LEVEL_NORMAL, "Start read/write test...\n"); 
    379383    { 
    380384        int dummyframe_in[arguments.events_per_frame*arguments.frames_per_packet]; 
    381385        int dummyframe_out[arguments.events_per_frame*arguments.frames_per_packet]; 
    382      
     386 
    383387        for (unsigned int i=0;i<arguments.events_per_frame*arguments.frames_per_packet;i++) { 
    384388            dummyframe_in[i]=i; 
    385389        } 
    386          
     390 
    387391        uint64_t time=arguments.start_at_cycle*3072; 
    388          
     392 
    389393        // initialize the timestamp 
    390394        uint64_t timestamp=time; 
     
    394398        } 
    395399        t->setBufferTailTimestamp(timestamp); 
    396          
     400 
    397401        timestamp += (uint64_t)(arguments.rate * arguments.frames_per_packet); 
    398402        if (timestamp >= arguments.wrap_at) { 
    399403            timestamp -= arguments.wrap_at; 
    400404        } 
    401      
     405 
    402406        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; 
    404408            cycle++) { 
    405              
     409 
    406410            // simulate the rate adaptation 
    407411            int64_t diff=(time%arguments.wrap_at)-timestamp; 
    408              
     412 
    409413            if (diff>(int64_t)arguments.wrap_at/2) { 
    410414                diff -= arguments.wrap_at; 
     
    412416                diff += arguments.wrap_at; 
    413417            } 
    414              
     418 
    415419            debugOutput(DEBUG_LEVEL_NORMAL, "Simulating cycle %d @ time=%011llu, diff=%lld\n",cycle,time,diff); 
    416              
     420 
    417421            if(diff>0) { 
    418422                uint64_t ts_head, fc_head; 
    419423                uint64_t ts_tail, fc_tail; 
    420                  
     424 
    421425                // write one packet 
    422426                t->writeFrames(arguments.frames_per_packet, (char *)&dummyframe_in, timestamp); 
    423      
     427 
    424428                // read the buffer head timestamp 
    425429                t->getBufferHeadTimestamp(&ts_head, &fc_head); 
    426430                t->getBufferTailTimestamp(&ts_tail, &fc_tail); 
    427                 debugOutput(DEBUG_LEVEL_NORMAL,  
     431                debugOutput(DEBUG_LEVEL_NORMAL, 
    428432                        " TS after write: HEAD: %011llu, FC=%04u\n", 
    429433                        ts_head,fc_head); 
    430                 debugOutput(DEBUG_LEVEL_NORMAL,  
     434                debugOutput(DEBUG_LEVEL_NORMAL, 
    431435                        "                 TAIL: %011llu, FC=%04u\n", 
    432436                        ts_tail,fc_tail); 
    433      
     437 
    434438                // read one packet 
    435439                t->readFrames(arguments.frames_per_packet, (char *)&dummyframe_out); 
    436      
     440 
    437441                // read the buffer head timestamp 
    438442                t->getBufferHeadTimestamp(&ts_head, &fc_head); 
    439443                t->getBufferTailTimestamp(&ts_tail, &fc_tail); 
    440                 debugOutput(DEBUG_LEVEL_NORMAL,  
     444                debugOutput(DEBUG_LEVEL_NORMAL, 
    441445                        " TS after write: HEAD: %011llu, FC=%04u\n", 
    442446                        ts_head,fc_head); 
    443                 debugOutput(DEBUG_LEVEL_NORMAL,  
     447                debugOutput(DEBUG_LEVEL_NORMAL, 
    444448                        "                 TAIL: %011llu, FC=%04u\n", 
    445449                        ts_tail,fc_tail); 
    446      
     450 
    447451                // check 
    448452                bool pass=true; 
     
    453457                    debugOutput(DEBUG_LEVEL_NORMAL, "write/read check for cycle %d failed\n",cycle); 
    454458                } 
    455      
     459 
    456460                // update the timestamp 
    457461                timestamp += (uint64_t)(arguments.rate * arguments.frames_per_packet); 
     
    460464                } 
    461465            } 
    462      
     466 
    463467            // simulate the cycle timer clock in ticks 
    464468            time += 3072; 
     
    466470                time -= arguments.wrap_at; 
    467471            } 
    468              
     472 
    469473            // allow for the messagebuffer thread to catch up 
    470474            usleep(200); 
    471              
     475 
    472476            if(!run) break; 
    473477        } 
    474478    } 
    475      
     479 
    476480    // second run, now do block processing 
    477481    debugOutput(DEBUG_LEVEL_NORMAL, "Start block read test...\n"); 
     
    480484        int dummyframe_out_block[arguments.events_per_frame*arguments.frames_per_packet*blocksize]; 
    481485        int dummyframe_in[arguments.events_per_frame*arguments.frames_per_packet]; 
    482      
     486 
    483487        for (unsigned int i=0;i<arguments.events_per_frame*arguments.frames_per_packet;i++) { 
    484488            dummyframe_in[i]=i; 
    485489        } 
    486          
     490 
    487491        uint64_t time=arguments.start_at_cycle*3072; 
    488          
     492 
    489493        // initialize the timestamp 
    490494        uint64_t timestamp=time; 
     
    494498        } 
    495499        t->setBufferTailTimestamp(timestamp); 
    496          
     500 
    497501        timestamp += (uint64_t)(arguments.rate * arguments.frames_per_packet); 
    498502        if (timestamp >= arguments.wrap_at) { 
    499503            timestamp -= arguments.wrap_at; 
    500504        } 
    501      
     505 
    502506        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; 
    504508            cycle++) { 
    505              
     509 
    506510            // simulate the rate adaptation 
    507511            int64_t diff=(time%arguments.wrap_at)-timestamp; 
    508              
     512 
    509513            if (diff>(int64_t)arguments.wrap_at/2) { 
    510514                diff -= arguments.wrap_at; 
     
    512516                diff += arguments.wrap_at; 
    513517            } 
    514              
     518 
    515519            debugOutput(DEBUG_LEVEL_NORMAL, "Simulating cycle %d @ time=%011llu, diff=%lld\n",cycle,time,diff); 
    516              
     520 
    517521            if(diff>0) { 
    518522                uint64_t ts_head, fc_head; 
    519523                uint64_t ts_tail, fc_tail; 
    520                  
     524 
    521525                // write one packet 
    522526                t->writeFrames(arguments.frames_per_packet, (char *)&dummyframe_in, timestamp); 
    523      
     527 
    524528                // read the buffer head timestamp 
    525529                t->getBufferHeadTimestamp(&ts_head, &fc_head); 
    526530                t->getBufferTailTimestamp(&ts_tail, &fc_tail); 
    527                 debugOutput(DEBUG_LEVEL_NORMAL,  
     531                debugOutput(DEBUG_LEVEL_NORMAL, 
    528532                        " TS after write: HEAD: %011llu, FC=%04u\n", 
    529533                        ts_head,fc_head); 
    530                 debugOutput(DEBUG_LEVEL_NORMAL,  
     534                debugOutput(DEBUG_LEVEL_NORMAL, 
    531535                        "                 TAIL: %011llu, FC=%04u\n", 
    532536                        ts_tail,fc_tail); 
    533      
     537 
    534538                if (fc_head > blocksize) { 
    535539                    debugOutput(DEBUG_LEVEL_NORMAL,"Reading one block (%u frames)\n",blocksize); 
    536                      
     540 
    537541                    // read one block 
    538542                    t->readFrames(blocksize, (char *)&dummyframe_out_block); 
    539          
     543 
    540544                    // read the buffer head timestamp 
    541545                    t->getBufferHeadTimestamp(&ts_head, &fc_head); 
    542546                    t->getBufferTailTimestamp(&ts_tail, &fc_tail); 
    543                     debugOutput(DEBUG_LEVEL_NORMAL,  
     547                    debugOutput(DEBUG_LEVEL_NORMAL, 
    544548                            " TS after read: HEAD: %011llu, FC=%04u\n", 
    545549                            ts_head,fc_head); 
    546                     debugOutput(DEBUG_LEVEL_NORMAL,  
     550                    debugOutput(DEBUG_LEVEL_NORMAL, 
    547551                            "                TAIL: %011llu, FC=%04u\n", 
    548552                            ts_tail,fc_tail); 
    549553                } 
    550                  
     554 
    551555                // update the timestamp 
    552556                timestamp += (uint64_t)(arguments.rate * arguments.frames_per_packet); 
     
    555559                } 
    556560            } 
    557      
     561 
    558562            // simulate the cycle timer clock in ticks 
    559563            time += 3072; 
     
    561565                time -= arguments.wrap_at; 
    562566            } 
    563              
     567 
    564568            // allow for the messagebuffer thread to catch up 
    565569            usleep(200); 
    566              
     570 
    567571            if(!run) break; 
    568572        } 
     
    571575    delete t; 
    572576    delete c; 
    573          
     577 
    574578    return EXIT_SUCCESS; 
    575579} 
  • 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 */ 
    2023 
    2124#include "libavc/avc_function_block.h"