summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsamr7 <samr7@126591fb-c623-4b62-a76d-97a8e4f34109>2008-11-28 10:07:55 +0000
committersamr7 <samr7@126591fb-c623-4b62-a76d-97a8e4f34109>2008-11-28 10:07:55 +0000
commita3c1f8d92c3bc56993ac9d15a4a980a87cb154bb (patch)
treeb64de81a35447ecd4ee9bd542e41fbc58a4d5b49
parent3f4b82f065ae0e03010ee1124c78777fc83496ea (diff)
downloadnohands-a3c1f8d92c3bc56993ac9d15a4a980a87cb154bb.tar.gz
Improve signatures and error reporting for a few audio utility functions.
git-svn-id: http://nohands.svn.sourceforge.net/svnroot/nohands/trunk@47 126591fb-c623-4b62-a76d-97a8e4f34109
-rw-r--r--include/libhfp/soundio.h18
-rw-r--r--libhfp/soundio-util.cpp31
2 files changed, 36 insertions, 13 deletions
diff --git a/include/libhfp/soundio.h b/include/libhfp/soundio.h
index 99fb390..1ccc9b1 100644
--- a/include/libhfp/soundio.h
+++ b/include/libhfp/soundio.h
@@ -886,9 +886,14 @@ public:
* @c false to ignore data streaming upward.
* @param[in] dn Set to @c true to snoop audio data streaming downward,
* @c false to ignore data streaming downward.
+ * @param[out] error Error information structure. If this method
+ * fails and returns @c 0, and @em error is not 0, @em error
+ * will be filled out with information on the cause of the failure.
+ * Currently, the only reason for failure of this function is a memory
+ * allocation failure.
*
* @return A newly constructed snoop filter configured with the target
- * endpoint, or @c 0 on memory allocation failure.
+ * endpoint, or @c 0 on error
*
* @note The snoop filter does not perform any life cycle management on
* the specified slave endpoint. Clients are responsible for managing the
@@ -896,7 +901,8 @@ public:
* snoop filter before destroying the slave endpoint.
*/
extern SoundIoFilter *SoundIoCreateSnooper(SoundIo *target,
- bool up = true, bool dn = true);
+ bool up = true, bool dn = true,
+ ErrorInfo *error = 0);
/**
@@ -952,6 +958,9 @@ public:
*
* @param[in] ei Pointer to dispatcher interface object for the environment.
* This is used for logging errors.
+ * @param[out] error Error information structure. If this method
+ * fails and returns @c 0, and @em error is not 0, @em error
+ * will be filled out with information on the cause of the failure.
*
* To use this filter:
* -# Instantaite it with this function.
@@ -965,9 +974,10 @@ public:
* configure it, see SoundIoSpeexProps and SoundIoFltSpeex::Configure().
*
* @return A newly constructed, unconfigured SoundIoFltSpeex object,
- * or NULL on error.
+ * or @c 0 on error.
*/
-SoundIoFltSpeex *SoundIoFltCreateSpeex(DispatchInterface *ei);
+extern SoundIoFltSpeex *SoundIoFltCreateSpeex(DispatchInterface *ei,
+ ErrorInfo *error = 0);
/**
diff --git a/libhfp/soundio-util.cpp b/libhfp/soundio-util.cpp
index 6137497..0d1bf3b 100644
--- a/libhfp/soundio-util.cpp
+++ b/libhfp/soundio-util.cpp
@@ -588,14 +588,13 @@ SoundIoCreateFileHandler(DispatchInterface *ei,
error->SetNoMem();
}
}
- return siop;
#endif
- if (error)
+ if (!siop && error && !error->IsSet())
error->Set(LIBHFP_ERROR_SUBSYS_SOUNDIO,
LIBHFP_ERROR_SOUNDIO_NOT_SUPPORTED,
"Support for libaudiofile omitted");
- return 0;
+ return siop;
}
@@ -756,11 +755,16 @@ public:
};
SoundIoFilter *
-SoundIoCreateSnooper(SoundIo *target, bool up, bool dn)
+SoundIoCreateSnooper(SoundIo *target, bool up, bool dn, ErrorInfo *error)
{
+ SoundIoFilter *fltp;
+
assert(target);
assert(up || dn);
- return new SoundIoSnooper(target, up, dn);
+ fltp = new SoundIoSnooper(target, up, dn);
+ if (!fltp && error)
+ error->SetNoMem();
+ return fltp;
}
@@ -997,13 +1001,22 @@ public:
};
#endif /* defined(USE_SPEEXDSP) */
-SoundIoFltSpeex *SoundIoFltCreateSpeex(DispatchInterface *ei)
+SoundIoFltSpeex *SoundIoFltCreateSpeex(DispatchInterface *ei,
+ ErrorInfo *error)
{
+ SoundIoFltSpeex *fltp;
+
#if defined(USE_SPEEXDSP)
- return new SoundIoFltSpeexImpl(ei);
-#else
- return 0;
+ fltp = new SoundIoFltSpeexImpl(ei);
+ if (!fltp && error)
+ error->SetNoMem();
#endif
+
+ if (!fltp && error && !error->IsSet())
+ error->Set(LIBHFP_ERROR_SUBSYS_SOUNDIO,
+ LIBHFP_ERROR_SOUNDIO_NOT_SUPPORTED,
+ "Support for speexdsp omitted");
+ return fltp;
}