From f08a3f42343b0bb2c303aea8bc80f2bb306cb3c3 Mon Sep 17 00:00:00 2001 From: Matt Flax Date: Thu, 13 Feb 2014 21:46:43 +1100 Subject: [PATCH] =?UTF-8?q?Added=20St=C3=A9phane=20review=20fixes=20:=20Re?= =?UTF-8?q?named=20JackIIODriver.C=20->=20JackIIODriver.cpp=20Renamed=20Ja?= =?UTF-8?q?ckIIODriver.H=20->=20JackIIODriver.h=20Added=20delete=20iio=5Fd?= =?UTF-8?q?river=20when=20failure=20is=20encountered=20when=20executing=20?= =?UTF-8?q?driver=5Finitialize.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- codeBlocks/jack2.cbp | 5 +- codeBlocks/jack2.layout | 303 +++++++++++++----- .../{JackIIODriver.C => JackIIODriver.cpp} | 11 +- .../iio/{JackIIODriver.H => JackIIODriver.h} | 0 linux/wscript | 4 +- 5 files changed, 228 insertions(+), 95 deletions(-) rename linux/iio/{JackIIODriver.C => JackIIODriver.cpp} (97%) rename linux/iio/{JackIIODriver.H => JackIIODriver.h} (100%) diff --git a/codeBlocks/jack2.cbp b/codeBlocks/jack2.cbp index 8d49beb2..93a26bb6 100644 --- a/codeBlocks/jack2.cbp +++ b/codeBlocks/jack2.cbp @@ -477,10 +477,9 @@ - - + + diff --git a/codeBlocks/jack2.layout b/codeBlocks/jack2.layout index ce7dad1b..cacfa18d 100644 --- a/codeBlocks/jack2.layout +++ b/codeBlocks/jack2.layout @@ -1,44 +1,39 @@ - + - + - + - + - + - + - + - + - - - - - - + - + - + - + - + - + @@ -46,24 +41,24 @@ - + - + - + - + - + - + - + - + @@ -71,19 +66,44 @@ - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -91,94 +111,124 @@ - + - + - + - + - + - + - + + + + + + + + + + + + + + + + - + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + @@ -186,59 +236,134 @@ + + + + + + + + + + - + - + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linux/iio/JackIIODriver.C b/linux/iio/JackIIODriver.cpp similarity index 97% rename from linux/iio/JackIIODriver.C rename to linux/iio/JackIIODriver.cpp index 4f934801..127af7be 100644 --- a/linux/iio/JackIIODriver.C +++ b/linux/iio/JackIIODriver.cpp @@ -17,7 +17,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include "JackIIODriver.H" +#include "JackIIODriver.h" #include "driver_interface.h" #include "JackEngineControl.h" #include "JackGraphManager.h" @@ -175,11 +175,13 @@ SERVER_EXPORT Jack::JackDriverClientInterface* driver_initialize(Jack::JackLocke // interrogate the available iio devices searching for the chip name if (iio_driver->iio.findDevicesByChipName(chipName)!=NO_ERROR) { // find all devices with a particular chip which are present. jack_error("\nThe iio driver found no devices by the name %s\n", chipName.c_str()); + delete iio_driver; return NULL; } if (iio_driver->iio.getDeviceCnt()<1) { // If there are no devices found by that chip name, then indicate. jack_error("\nThe iio driver found no devices by the name %s\n", chipName.c_str()); + delete iio_driver; return NULL; } @@ -194,6 +196,7 @@ SERVER_EXPORT Jack::JackDriverClientInterface* driver_initialize(Jack::JackLocke int ret=iio_driver->iio.getReadArray(periodSize, iio_driver->data); // resize the array to be able to read enough memory if (ret!=NO_ERROR) { jack_error("iio::getReadArray couldn't create the data buffer, indicating the problem."); + delete iio_driver; return NULL; } if (iio_driver->data.cols()>colCnt) // resize the data columns to match the specified number of columns (channels / channels per device) @@ -201,6 +204,7 @@ SERVER_EXPORT Jack::JackDriverClientInterface* driver_initialize(Jack::JackLocke ret=iio_driver->iio.open(periodCount, periodSize); // try to open all IIO devices if (ret!=NO_ERROR) + delete iio_driver; return NULL; Jack::JackDriverClientInterface* threaded_driver = new Jack::JackThreadedDriver(iio_driver); @@ -216,6 +220,11 @@ SERVER_EXPORT Jack::JackDriverClientInterface* driver_initialize(Jack::JackLocke } else jack_error("\nHave you run out of memory ? I tried to create Jack's standard threaded driver in memory but failed! The good news is that you had enough memory to create the IIO driver.\n"); + if (!threaded_driver) { // handle the case that the threaded_driver was not created succ. + delete iio_driver; + iio_driver=NULL; + } + return threaded_driver; } diff --git a/linux/iio/JackIIODriver.H b/linux/iio/JackIIODriver.h similarity index 100% rename from linux/iio/JackIIODriver.H rename to linux/iio/JackIIODriver.h diff --git a/linux/wscript b/linux/wscript index caf286a5..3e7f097d 100644 --- a/linux/wscript +++ b/linux/wscript @@ -19,7 +19,7 @@ def configure(conf): conf.env['BUILD_DRIVER_IIO'] += conf.is_defined('HAVE_EIGEN3') conf.check_cfg(package='sox', atleast_version='14.4.0', args='--cflags --libs', mandatory=False) conf.env['BUILD_DRIVER_IIO'] += conf.is_defined('HAVE_SOX') - + def create_jack_driver_obj(bld, target, sources, uselib = None): driver = bld(features = ['c', 'cxx', 'cxxshlib', 'cshlib']) @@ -82,7 +82,7 @@ def build(bld): 'firewire/JackFFADOMidiSendQueue.cpp' ] - iio_driver_src = ['iio/JackIIODriver.C'] + iio_driver_src = ['iio/JackIIODriver.cpp'] if bld.env['BUILD_DRIVER_ALSA'] == True: create_jack_driver_obj(bld, 'alsa', alsa_driver_src, ["ALSA"])