Index: /pjproject/branches/projects/aps-direct/build.symbian/pjmedia_audiodev.mmp
===================================================================
--- /pjproject/branches/projects/aps-direct/build.symbian/pjmedia_audiodev.mmp	(revision 2487)
+++ /pjproject/branches/projects/aps-direct/build.symbian/pjmedia_audiodev.mmp	(revision 2488)
@@ -13,4 +13,5 @@
 
 SOURCE		audiodev.c
+SOURCE		errno.c
 SOURCE		symb_aps_dev.cpp
 SOURCE		symb_mda_dev.cpp
Index: /pjproject/branches/projects/aps-direct/pjlib/include/pj/errno.h
===================================================================
--- /pjproject/branches/projects/aps-direct/pjlib/include/pj/errno.h	(revision 2487)
+++ /pjproject/branches/projects/aps-direct/pjlib/include/pj/errno.h	(revision 2488)
@@ -376,4 +376,5 @@
  *  - PJLIB_UTIL_ERRNO_START	(PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*3)
  *  - PJNATH_ERRNO_START	(PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*4)
+ *  - PJMEDIA_AUDIODEV_ERRNO_START (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*5)
  */
 
Index: /pjproject/branches/projects/aps-direct/pjmedia/build/pjmedia_audiodev.dsp
===================================================================
--- /pjproject/branches/projects/aps-direct/pjmedia/build/pjmedia_audiodev.dsp	(revision 2487)
+++ /pjproject/branches/projects/aps-direct/pjmedia/build/pjmedia_audiodev.dsp	(revision 2488)
@@ -98,4 +98,8 @@
 # Begin Source File
 
+SOURCE="..\src\pjmedia-audiodev\errno.c"
+# End Source File
+# Begin Source File
+
 SOURCE="..\src\pjmedia-audiodev\pa_dev.c"
 # End Source File
@@ -134,4 +138,8 @@
 SOURCE="..\include\pjmedia-audiodev\config.h"
 # End Source File
+# Begin Source File
+
+SOURCE="..\include\pjmedia-audiodev\errno.h"
+# End Source File
 # End Group
 # End Target
Index: /pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia-audiodev/audiodev.h
===================================================================
--- /pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia-audiodev/audiodev.h	(revision 2487)
+++ /pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia-audiodev/audiodev.h	(revision 2488)
@@ -26,4 +26,5 @@
  */
 #include <pjmedia-audiodev/config.h>
+#include <pjmedia-audiodev/errno.h>
 #include <pjmedia/port.h>
 #include <pj/pool.h>
@@ -602,28 +603,4 @@
 
 
-/* Audio subsystem not initialized */
-#define PJMEDIA_EAUD_INIT	-1
-
-/* Invalid audio device */
-#define PJMEDIA_EAUD_INVDEV	-1
-
-/* Found no devices */
-#define PJMEDIA_EAUD_NODEV	-1
-
-/* Unable to find default device */
-#define PJMEDIA_EAUD_NODEFDEV	-1
-
-/* Device not ready */
-#define PJMEDIA_EAUD_NOTREADY	-1
-
-/* Invalid audio capability or audio capability not supported */
-#define PJMEDIA_EAUD_INVCAP	-1
-
-/* Unknown system error */
-#define PJMEDIA_EAUD_SYSERR	-1
-
-/* Bad or invalid format */
-#define PJMEDIA_EAUD_BADFORMAT	-1
-
 /**
  * @}
Index: /pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia-audiodev/errno.h
===================================================================
--- /pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia-audiodev/errno.h	(revision 2488)
+++ /pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia-audiodev/errno.h	(revision 2488)
@@ -0,0 +1,188 @@
+/* $Id$ */
+/* 
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ */
+#ifndef __PJMEDIA_AUDIODEV_AUDIODEV_ERRNO_H__
+#define __PJMEDIA_AUDIODEV_AUDIODEV_ERRNO_H__
+
+/**
+ * @file errno.h Error Codes
+ * @brief Audiodev specific error codes.
+ */
+
+#include <pjmedia-audiodev/config.h>
+#include <pj/errno.h>
+
+/**
+ * @defgroup error_codes Error Codes
+ * @ingroup audio_device_api
+ * @brief Audio devive library specific error codes.
+ * @{
+ */
+
+
+PJ_BEGIN_DECL
+
+
+/**
+ * Start of error code relative to PJ_ERRNO_START_USER.
+ * This value is 420000.
+ */
+#define PJMEDIA_AUDIODEV_ERRNO_START \
+	    (PJ_ERRNO_START_USER + PJ_ERRNO_SPACE_SIZE*5)
+#define PJMEDIA_AUDIODEV_ERRNO_END   \
+	    (PJMEDIA_AUDIODEV_ERRNO_START + PJ_ERRNO_SPACE_SIZE - 1)
+
+
+/**
+ * Mapping from PortAudio error codes to pjmedia error space.
+ */
+#define PJMEDIA_AUDIODEV_PORTAUDIO_ERRNO_START \
+	    (PJMEDIA_AUDIODEV_ERRNO_END-10000)
+#define PJMEDIA_AUDIODEV_PORTAUDIO_ERRNO_END   \
+	    (PJMEDIA_AUDIODEV_PORTAUDIO_ERRNO_START + 10000 -1)
+/**
+ * Convert PortAudio error code to PJLIB error code.
+ * PortAudio error code range: 0 >= err >= -10000
+ */
+#define PJMEDIA_AUDIODEV_ERRNO_FROM_PORTAUDIO(err) \
+	    ((int)PJMEDIA_AUDIODEV_PORTAUDIO_ERRNO_START-err)
+
+/**
+ * Mapping from Windows multimedia WaveIn error codes.
+ */
+#define PJMEDIA_AUDIODEV_WMME_IN_ERROR_START	\
+	    (PJMEDIA_AUDIODEV_ERRNO_START + 30000)
+#define PJMEDIA_AUDIODEV_WMME_IN_ERROR_END	\
+	    (PJMEDIA_AUDIODEV_WMME_IN_ERROR_START + 1000 - 1)
+/**
+ * Convert WaveIn operation error codes to PJLIB error space.
+ */
+#define PJMEDIA_AUDIODEV_ERRNO_FROM_WMME_IN(err) \
+	    ((int)PJMEDIA_AUDIODEV_WMME_IN_ERROR_START+err)
+
+
+/**
+ * Mapping from Windows multimedia WaveOut error codes.
+ */
+#define PJMEDIA_AUDIODEV_WMME_OUT_ERROR_START	\
+	    (PJMEDIA_AUDIODEV_WMME_IN_ERROR_END + 1000)
+#define PJMEDIA_AUDIODEV_WMME_OUT_ERROR_END	\
+	    (PJMEDIA_AUDIODEV_WMME_OUT_ERROR_START + 1000)
+/**
+ * Convert WaveOut operation error codes to PJLIB error space.
+ */
+#define PJMEDIA_AUDIODEV_ERRNO_FROM_WMME_OUT(err) \
+	    ((int)PJMEDIA_AUDIODEV_WMME_OUT_ERROR_START+err)
+
+
+/************************************************************
+ * Audio Device API error codes
+ ***********************************************************/
+/**
+ * @hideinitializer
+ * General/unknown error.
+ */
+#define PJMEDIA_AUDIODEV_ERROR	(PJMEDIA_AUDIODEV_ERRNO_START+1) /* 420001 */
+
+/**
+ * @hideinitializer
+ * Unknown error from audio driver
+ */
+#define PJMEDIA_EAUD_SYSERR	(PJMEDIA_AUDIODEV_ERRNO_START+2) /* 420002 */
+
+/**
+ * @hideinitializer
+ * Audio subsystem not initialized
+ */
+#define PJMEDIA_EAUD_INIT	(PJMEDIA_AUDIODEV_ERRNO_START+3) /* 420003 */
+
+/**
+ * @hideinitializer
+ * Invalid audio device
+ */
+#define PJMEDIA_EAUD_INVDEV	(PJMEDIA_AUDIODEV_ERRNO_START+4) /* 420004 */
+
+/**
+ * @hideinitializer
+ * Found no devices
+ */
+#define PJMEDIA_EAUD_NODEV	(PJMEDIA_AUDIODEV_ERRNO_START+5) /* 420005 */
+
+/**
+ * @hideinitializer
+ * Unable to find default device
+ */
+#define PJMEDIA_EAUD_NODEFDEV	(PJMEDIA_AUDIODEV_ERRNO_START+6) /* 420006 */
+
+/**
+ * @hideinitializer
+ * Device not ready
+ */
+#define PJMEDIA_EAUD_NOTREADY	(PJMEDIA_AUDIODEV_ERRNO_START+7) /* 420007 */
+
+/**
+ * @hideinitializer
+ * The audio capability is invalid or not supported
+ */
+#define PJMEDIA_EAUD_INVCAP	(PJMEDIA_AUDIODEV_ERRNO_START+8) /* 420008 */
+
+/**
+ * @hideinitializer
+ * The operation is invalid or not supported
+ */
+#define PJMEDIA_EAUD_INVOP	(PJMEDIA_AUDIODEV_ERRNO_START+9) /* 420009 */
+
+/**
+ * @hideinitializer
+ * Bad or invalid audio device format
+ */
+#define PJMEDIA_EAUD_BADFORMAT	(PJMEDIA_AUDIODEV_ERRNO_START+10) /* 4200010 */
+
+/**
+ * @hideinitializer
+ * Invalid audio device sample format
+ */
+#define PJMEDIA_EAUD_SAMPFORMAT	(PJMEDIA_AUDIODEV_ERRNO_START+11) /* 4200011 */
+
+/**
+ * Get error message for the specified error code. Note that this
+ * function is only able to decode PJMEDIA Audiodev specific error code.
+ * Application should use pj_strerror(), which should be able to
+ * decode all error codes belonging to all subsystems (e.g. pjlib,
+ * pjmedia, pjsip, etc).
+ *
+ * @param status    The error code.
+ * @param buffer    The buffer where to put the error message.
+ * @param bufsize   Size of the buffer.
+ *
+ * @return	    The error message as NULL terminated string,
+ *                  wrapped with pj_str_t.
+ */
+PJ_DECL(pj_str_t) pjmedia_audiodev_strerror(pj_status_t status, char *buffer,
+					    pj_size_t bufsize);
+
+
+PJ_END_DECL
+
+/**
+ * @}
+ */
+
+
+#endif	/* __PJMEDIA_AUDIODEV_AUDIODEV_ERRNO_H__ */
+
Index: /pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia-audiodev/audiodev.c
===================================================================
--- /pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia-audiodev/audiodev.c	(revision 2487)
+++ /pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia-audiodev/audiodev.c	(revision 2488)
@@ -26,4 +26,6 @@
 #define THIS_FILE   "audiodev.c"
 
+#define DEFINE_CAP(name, info)	{name, info}
+
 /* Capability names */
 static struct cap_info
@@ -33,18 +35,18 @@
 } cap_infos[] = 
 {
-    {"ext-fmt",	    "Extended/non-PCM format"},
-    {"latency-in",  "Input latency/buffer size setting"},
-    {"latency-out", "Output latency/buffer size setting"},
-    {"vol-in",	    "Input volume setting"},
-    {"vol-out",	    "Output volume setting"},
-    {"meter-in",    "Input meter"},
-    {"meter-out",   "Output meter"},
-    {"route-in",    "Input routing"},
-    {"route-out",   "Output routing"},
-    {"aec",	    "Accoustic echo cancellation"},
-    {"aec-tail",    "Tail length setting for AEC"},
-    {"vad",	    "Voice activity detection"},
-    {"cng",	    "Comfort noise generation"},
-    {"plg",	    "Packet loss concealment"}
+    DEFINE_CAP("ext-fmt",     "Extended/non-PCM format"),
+    DEFINE_CAP("latency-in",  "Input latency/buffer size setting"),
+    DEFINE_CAP("latency-out", "Output latency/buffer size setting"),
+    DEFINE_CAP("vol-in",      "Input volume setting"),
+    DEFINE_CAP("vol-out",     "Output volume setting"),
+    DEFINE_CAP("meter-in",    "Input meter"),
+    DEFINE_CAP("meter-out",   "Output meter"),
+    DEFINE_CAP("route-in",    "Input routing"),
+    DEFINE_CAP("route-out",   "Output routing"),
+    DEFINE_CAP("aec",	      "Accoustic echo cancellation"),
+    DEFINE_CAP("aec-tail",    "Tail length setting for AEC"),
+    DEFINE_CAP("vad",	      "Voice activity detection"),
+    DEFINE_CAP("cng",	      "Comfort noise generation"),
+    DEFINE_CAP("plg",	      "Packet loss concealment")
 };
 
@@ -228,4 +230,10 @@
     }
 
+    /* Register error subsystem */
+    pj_register_strerror(PJMEDIA_AUDIODEV_ERRNO_START, 
+			 PJ_ERRNO_SPACE_SIZE, 
+			 &pjmedia_audiodev_strerror);
+
+    /* Init */
     aud_subsys.pf = pf;
     aud_subsys.drv_cnt = 0;
Index: /pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia-audiodev/errno.c
===================================================================
--- /pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia-audiodev/errno.c	(revision 2488)
+++ /pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia-audiodev/errno.c	(revision 2488)
@@ -0,0 +1,189 @@
+/* $Id$ */
+/* 
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ */
+#include <pjmedia-audiodev/errno.h>
+#include <pj/string.h>
+#include <pj/unicode.h>
+#if PJMEDIA_AUDIO_DEV_HAS_PORTAUDIO
+#   include <portaudio.h>
+#endif
+#if PJMEDIA_AUDIO_DEV_HAS_WMME
+#   ifdef _MSC_VER
+#	pragma warning(push, 3)
+#   endif
+#   include <windows.h>
+#   include <mmsystem.h>
+#   ifdef _MSC_VER
+#	pragma warning(pop)
+#   endif
+#endif
+
+/* PJMEDIA-Audiodev's own error codes/messages 
+ * MUST KEEP THIS ARRAY SORTED!!
+ * Message must be limited to 64 chars!
+ */
+
+#if defined(PJ_HAS_ERROR_STRING) && (PJ_HAS_ERROR_STRING != 0)
+
+static const struct 
+{
+    int code;
+    const char *msg;
+} err_str[] = 
+{
+    PJ_BUILD_ERR( PJMEDIA_AUDIODEV_ERROR,   "Unspecified audio device error" ),
+    PJ_BUILD_ERR( PJMEDIA_EAUD_SYSERR,	    "Unknown error from audio driver" ),
+    PJ_BUILD_ERR( PJMEDIA_EAUD_INIT,	    "Audio subsystem not initialized" ),
+    PJ_BUILD_ERR( PJMEDIA_EAUD_INVDEV,	    "Invalid audio device" ),
+    PJ_BUILD_ERR( PJMEDIA_EAUD_NODEV,	    "Found no audio devices" ),
+    PJ_BUILD_ERR( PJMEDIA_EAUD_NODEFDEV,    "Unable to find default audio device" ),
+    PJ_BUILD_ERR( PJMEDIA_EAUD_NOTREADY,    "Audio device not ready" ),
+    PJ_BUILD_ERR( PJMEDIA_EAUD_INVCAP,	    "Invalid or unsupported audio capability" ),
+    PJ_BUILD_ERR( PJMEDIA_EAUD_INVOP,	    "Invalid or unsupported audio device operation" ),
+    PJ_BUILD_ERR( PJMEDIA_EAUD_BADFORMAT,   "Bad or invalid audio device format" ),
+    PJ_BUILD_ERR( PJMEDIA_EAUD_SAMPFORMAT,  "Invalid audio device sample format")
+
+};
+
+#endif	/* PJ_HAS_ERROR_STRING */
+
+
+
+/*
+ * pjmedia_audiodev_strerror()
+ */
+PJ_DEF(pj_str_t) pjmedia_audiodev_strerror(pj_status_t statcode, 
+					   char *buf, pj_size_t bufsize )
+{
+    pj_str_t errstr;
+
+#if defined(PJ_HAS_ERROR_STRING) && (PJ_HAS_ERROR_STRING != 0)
+
+    /* See if the error comes from PortAudio. */
+#if PJMEDIA_AUDIO_DEV_HAS_PORTAUDIO
+    if (statcode >= PJMEDIA_AUDIODEV_PORTAUDIO_ERRNO_START &&
+	statcode <= PJMEDIA_AUDIODEV_PORTAUDIO_ERRNO_END)
+    {
+
+	//int pa_err = statcode - PJMEDIA_ERRNO_FROM_PORTAUDIO(0);
+	int pa_err = PJMEDIA_AUDIODEV_PORTAUDIO_ERRNO_START - statcode;
+	pj_str_t msg;
+	
+	msg.ptr = (char*)Pa_GetErrorText(pa_err);
+	msg.slen = pj_ansi_strlen(msg.ptr);
+
+	errstr.ptr = buf;
+	pj_strncpy_with_null(&errstr, &msg, bufsize);
+	return errstr;
+
+    } else 
+#endif	/* PJMEDIA_SOUND_IMPLEMENTATION */
+
+    /* See if the error comes from WMME */
+#if PJMEDIA_AUDIO_DEV_HAS_WMME
+    if ((statcode >= PJMEDIA_AUDIODEV_WMME_IN_ERROR_START &&
+	 statcode < PJMEDIA_AUDIODEV_WMME_IN_ERROR_END) ||
+	(statcode >= PJMEDIA_AUDIODEV_WMME_OUT_ERROR_START &&
+	 statcode < PJMEDIA_AUDIODEV_WMME_OUT_ERROR_END))
+    {
+	MMRESULT native_err, mr;
+	MMRESULT (WINAPI *waveGetErrText)(UINT mmrError, LPTSTR pszText, UINT cchText);
+	PJ_DECL_UNICODE_TEMP_BUF(wbuf, 80)
+
+	if (statcode >= PJMEDIA_AUDIODEV_WMME_IN_ERROR_START &&
+	    statcode <= PJMEDIA_AUDIODEV_WMME_IN_ERROR_END)
+	{
+	    native_err = statcode - PJMEDIA_AUDIODEV_WMME_IN_ERROR_START;
+	    waveGetErrText = &waveInGetErrorText;
+	} else {
+	    native_err = statcode - PJMEDIA_AUDIODEV_WMME_OUT_ERROR_START;
+	    waveGetErrText = &waveOutGetErrorText;
+	}
+
+#if PJ_NATIVE_STRING_IS_UNICODE
+	mr = (*waveGetErrText)(native_err, wbuf, PJ_ARRAY_SIZE(wbuf));
+	if (mr == MMSYSERR_NOERROR) {
+	    int len = wcslen(wbuf);
+	    pj_unicode_to_ansi(wbuf, len, buf, bufsize);
+	}
+#else
+	mr = (*waveGetErrText)(native_err, buf, bufsize);
+#endif
+
+	if (mr==MMSYSERR_NOERROR) {
+	    errstr.ptr = buf;
+	    errstr.slen = pj_ansi_strlen(buf);
+	    return errstr;
+	} else {
+	    pj_ansi_snprintf(buf, bufsize, "MMSYSTEM native error %d", 
+			     native_err);
+	    return pj_str(buf);
+	}
+
+    } else
+#endif
+
+    /* Audiodev error */
+    if (statcode >= PJMEDIA_AUDIODEV_ERRNO_START && 
+	statcode < PJMEDIA_AUDIODEV_ERRNO_END)
+    {
+	/* Find the error in the table.
+	 * Use binary search!
+	 */
+	int first = 0;
+	int n = PJ_ARRAY_SIZE(err_str);
+
+	while (n > 0) {
+	    int half = n/2;
+	    int mid = first + half;
+
+	    if (err_str[mid].code < statcode) {
+		first = mid+1;
+		n -= (half+1);
+	    } else if (err_str[mid].code > statcode) {
+		n = half;
+	    } else {
+		first = mid;
+		break;
+	    }
+	}
+
+
+	if (PJ_ARRAY_SIZE(err_str) && err_str[first].code == statcode) {
+	    pj_str_t msg;
+	    
+	    msg.ptr = (char*)err_str[first].msg;
+	    msg.slen = pj_ansi_strlen(err_str[first].msg);
+
+	    errstr.ptr = buf;
+	    pj_strncpy_with_null(&errstr, &msg, bufsize);
+	    return errstr;
+
+	} 
+    } 
+#endif	/* PJ_HAS_ERROR_STRING */
+
+    /* Error not found. */
+    errstr.ptr = buf;
+    errstr.slen = pj_ansi_snprintf(buf, bufsize, 
+				   "Unknown pjmedia-audiodev error %d",
+				   statcode);
+
+    return errstr;
+}
+
Index: /pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia-audiodev/pa_dev.c
===================================================================
--- /pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia-audiodev/pa_dev.c	(revision 2487)
+++ /pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia-audiodev/pa_dev.c	(revision 2488)
@@ -19,5 +19,4 @@
  */
 #include <pjmedia-audiodev/audiodev_imp.h>
-#include <pjmedia/errno.h>
 #include <pj/assert.h>
 #include <pj/log.h>
@@ -25,4 +24,7 @@
 #include <pj/string.h>
 #include <portaudio.h>
+
+#if PJMEDIA_AUDIO_DEV_HAS_PORTAUDIO
+
 
 #define THIS_FILE	"pa_dev.c"
@@ -452,5 +454,5 @@
 			 pa_get_dev_count(f)));
 
-    return err ? PJMEDIA_ERRNO_FROM_PORTAUDIO(err) : PJ_SUCCESS;
+    return err ? PJMEDIA_AUDIODEV_ERRNO_FROM_PORTAUDIO(err) : PJ_SUCCESS;
 }
 
@@ -471,5 +473,5 @@
     pj_pool_release(pool);
     
-    return err ? PJMEDIA_ERRNO_FROM_PORTAUDIO(err) : PJ_SUCCESS;
+    return err ? PJMEDIA_AUDIODEV_ERRNO_FROM_PORTAUDIO(err) : PJ_SUCCESS;
 }
 
@@ -693,5 +695,5 @@
 	if (rec_id < 0) {
 	    /* No such device. */
-	    return PJMEDIA_ENOSNDREC;
+	    return PJMEDIA_EAUD_NODEFDEV;
 	}
     }
@@ -700,5 +702,5 @@
     if (!paDevInfo) {
 	/* Assumed it is "No such device" error. */
-	return PJMEDIA_ESNDINDEVID;
+	return PJMEDIA_EAUD_INVDEV;
     }
 
@@ -710,5 +712,5 @@
 	sampleFormat = paInt32;
     else
-	return PJMEDIA_ESNDINSAMPLEFMT;
+	return PJMEDIA_EAUD_SAMPFORMAT;
     
     pool = pj_pool_create(pa->pf, "recstrm", 1024, 1024, NULL);
@@ -753,5 +755,5 @@
     if (err != paNoError) {
 	pj_pool_release(pool);
-	return PJMEDIA_ERRNO_FROM_PORTAUDIO(err);
+	return PJMEDIA_AUDIODEV_ERRNO_FROM_PORTAUDIO(err);
     }
 
@@ -798,5 +800,5 @@
 	if (play_id < 0) {
 	    /* No such device. */
-	    return PJMEDIA_ENOSNDPLAY;
+	    return PJMEDIA_EAUD_NODEFDEV;
 	}
     } 
@@ -805,5 +807,5 @@
     if (!paDevInfo) {
 	/* Assumed it is "No such device" error. */
-	return PJMEDIA_ESNDINDEVID;
+	return PJMEDIA_EAUD_INVDEV;
     }
 
@@ -815,5 +817,5 @@
 	sampleFormat = paInt32;
     else
-	return PJMEDIA_ESNDINSAMPLEFMT;
+	return PJMEDIA_EAUD_SAMPFORMAT;
     
     pool = pj_pool_create(pa->pf, "playstrm", 1024, 1024, NULL);
@@ -859,5 +861,5 @@
     if (err != paNoError) {
 	pj_pool_release(pool);
-	return PJMEDIA_ERRNO_FROM_PORTAUDIO(err);
+	return PJMEDIA_AUDIODEV_ERRNO_FROM_PORTAUDIO(err);
     }
 
@@ -910,5 +912,5 @@
 	if (rec_id < 0) {
 	    /* No such device. */
-	    return PJMEDIA_ENOSNDREC;
+	    return PJMEDIA_EAUD_NODEFDEV;
 	}
     }
@@ -917,5 +919,5 @@
     if (!paRecDevInfo) {
 	/* Assumed it is "No such device" error. */
-	return PJMEDIA_ESNDINDEVID;
+	return PJMEDIA_EAUD_INVDEV;
     }
 
@@ -925,5 +927,5 @@
 	if (play_id < 0) {
 	    /* No such device. */
-	    return PJMEDIA_ENOSNDPLAY;
+	    return PJMEDIA_EAUD_NODEFDEV;
 	}
     } 
@@ -932,5 +934,5 @@
     if (!paPlayDevInfo) {
 	/* Assumed it is "No such device" error. */
-	return PJMEDIA_ESNDINDEVID;
+	return PJMEDIA_EAUD_INVDEV;
     }
 
@@ -943,5 +945,5 @@
 	sampleFormat = paInt32;
     else
-	return PJMEDIA_ESNDINSAMPLEFMT;
+	return PJMEDIA_EAUD_SAMPFORMAT;
     
     pool = pj_pool_create(pa->pf, "sndstream", 1024, 1024, NULL);
@@ -1034,5 +1036,5 @@
     if (err != paNoError) {
 	pj_pool_release(pool);
-	return PJMEDIA_ERRNO_FROM_PORTAUDIO(err);
+	return PJMEDIA_AUDIODEV_ERRNO_FROM_PORTAUDIO(err);
     }
 
@@ -1143,5 +1145,5 @@
 	const PaStreamInfo *si = Pa_GetStreamInfo(strm->rec_strm);
 	if (!si)
-	    return PJ_EINVALIDOP;
+	    return PJMEDIA_EAUD_SYSERR;
 
 	*(unsigned*)pval = (unsigned)(si->inputLatency * 1000);
@@ -1150,10 +1152,10 @@
 	const PaStreamInfo *si = Pa_GetStreamInfo(strm->play_strm);
 	if (!si)
-	    return PJ_EINVALIDOP;
+	    return PJMEDIA_EAUD_SYSERR;
 
 	*(unsigned*)pval = (unsigned)(si->outputLatency * 1000);
 	return PJ_SUCCESS;
     } else {
-	return PJ_ENOTSUP;
+	return PJMEDIA_EAUD_INVCAP;
     }
 }
@@ -1170,5 +1172,5 @@
 
     /* Nothing is supported */
-    return PJ_ENOTSUP;
+    return PJMEDIA_EAUD_INVCAP;
 }
 
@@ -1193,5 +1195,5 @@
     PJ_LOG(5,(THIS_FILE, "Done, status=%d", err));
 
-    return err ? PJMEDIA_ERRNO_FROM_PORTAUDIO(err) : PJ_SUCCESS;
+    return err ? PJMEDIA_AUDIODEV_ERRNO_FROM_PORTAUDIO(err) : PJ_SUCCESS;
 }
 
@@ -1224,5 +1226,5 @@
     PJ_LOG(5,(THIS_FILE, "Done, status=%d", err));
 
-    return err ? PJMEDIA_ERRNO_FROM_PORTAUDIO(err) : PJ_SUCCESS;
+    return err ? PJMEDIA_AUDIODEV_ERRNO_FROM_PORTAUDIO(err) : PJ_SUCCESS;
 }
 
@@ -1255,5 +1257,7 @@
     pj_pool_release(stream->pool);
 
-    return err ? PJMEDIA_ERRNO_FROM_PORTAUDIO(err) : PJ_SUCCESS;
-}
-
+    return err ? PJMEDIA_AUDIODEV_ERRNO_FROM_PORTAUDIO(err) : PJ_SUCCESS;
+}
+
+#endif	/* PJMEDIA_AUDIO_DEV_HAS_PORTAUDIO */
+
Index: /pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia-audiodev/wmme_dev.c
===================================================================
--- /pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia-audiodev/wmme_dev.c	(revision 2487)
+++ /pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia-audiodev/wmme_dev.c	(revision 2488)
@@ -19,5 +19,4 @@
  */
 #include <pjmedia-audiodev/audiodev_imp.h>
-#include <pjmedia/errno.h>
 #include <pj/assert.h>
 #include <pj/log.h>
@@ -25,4 +24,7 @@
 #include <pj/string.h>
 #include <pj/unicode.h>
+
+#if PJMEDIA_AUDIO_DEV_HAS_WMME
+
 #ifdef _MSC_VER
 #   pragma warning(push, 3)
@@ -168,10 +170,4 @@
 };
 
-/* Utility: convert MMERROR to pj_status_t */
-PJ_INLINE(pj_status_t) CONVERT_MM_ERROR(MMRESULT mr)
-{
-    return PJ_RETURN_OS_ERROR(mr);
-}
-
 
 /****************************************************************************
@@ -548,5 +544,5 @@
 		     &wfx, (DWORD)wmme_strm->hEvent, 0, CALLBACK_EVENT);
     if (mr != MMSYSERR_NOERROR) {
-	return CONVERT_MM_ERROR(mr);
+	return PJMEDIA_AUDIODEV_ERRNO_FROM_WMME_OUT(mr);
     }
 
@@ -554,5 +550,5 @@
     mr = waveOutPause(wmme_strm->hWave.Out);
     if (mr != MMSYSERR_NOERROR) {
-	return CONVERT_MM_ERROR(mr);
+	return PJMEDIA_AUDIODEV_ERRNO_FROM_WMME_OUT(mr);
     }
 
@@ -570,10 +566,10 @@
 				  sizeof(WAVEHDR));
 	if (mr != MMSYSERR_NOERROR) {
-	    return CONVERT_MM_ERROR(mr); 
+	    return PJMEDIA_AUDIODEV_ERRNO_FROM_WMME_OUT(mr); 
 	}
 	mr = waveOutWrite(wmme_strm->hWave.Out, &(wmme_strm->WaveHdr[i]), 
 			  sizeof(WAVEHDR));
 	if (mr != MMSYSERR_NOERROR) {
-	    return CONVERT_MM_ERROR(mr);
+	    return PJMEDIA_AUDIODEV_ERRNO_FROM_WMME_OUT(mr);
 	}
     }
@@ -634,5 +630,5 @@
 		    &wfx, (DWORD)wmme_strm->hEvent, 0, CALLBACK_EVENT);
     if (mr != MMSYSERR_NOERROR) {
-	return CONVERT_MM_ERROR(mr);
+	return PJMEDIA_AUDIODEV_ERRNO_FROM_WMME_IN(mr);
     }
 
@@ -650,10 +646,10 @@
 				 sizeof(WAVEHDR));
 	if (mr != MMSYSERR_NOERROR) {
-	    return CONVERT_MM_ERROR(mr);
+	    return PJMEDIA_AUDIODEV_ERRNO_FROM_WMME_IN(mr);
 	}
 	mr = waveInAddBuffer(wmme_strm->hWave.In, &(wmme_strm->WaveHdr[i]), 
 			     sizeof(WAVEHDR));
 	if (mr != MMSYSERR_NOERROR) {
-	    return CONVERT_MM_ERROR(mr);
+	    return PJMEDIA_AUDIODEV_ERRNO_FROM_WMME_IN(mr);
 	}
     }
@@ -831,5 +827,5 @@
 				  sizeof(WAVEHDR));
 		if (mr != MMSYSERR_NOERROR) {
-		    status = CONVERT_MM_ERROR(mr);
+		    status = PJMEDIA_AUDIODEV_ERRNO_FROM_WMME_OUT(mr);
 		    break;
 		}
@@ -928,5 +924,5 @@
 				     sizeof(WAVEHDR));
 		if (mr != MMSYSERR_NOERROR) {
-		    status = CONVERT_MM_ERROR(mr);
+		    status = PJMEDIA_AUDIODEV_ERRNO_FROM_WMME_IN(mr);
 		    break;
 		}
@@ -1147,5 +1143,5 @@
 	mr = waveOutGetVolume(strm->play_strm.hWave.Out, &dwVol);
 	if (mr != MMSYSERR_NOERROR) {
-	    return CONVERT_MM_ERROR(mr);
+	    return PJMEDIA_AUDIODEV_ERRNO_FROM_WMME_OUT(mr);
 	}
 
@@ -1178,5 +1174,6 @@
 
 	mr = waveOutSetVolume(strm->play_strm.hWave.Out, dwVol);
-	return (mr==MMSYSERR_NOERROR)? PJ_SUCCESS : CONVERT_MM_ERROR(mr);
+	return (mr==MMSYSERR_NOERROR)? PJ_SUCCESS : 
+				PJMEDIA_AUDIODEV_ERRNO_FROM_WMME_OUT(mr);
     } else {
 	return PJ_ENOTSUP;
@@ -1196,5 +1193,5 @@
 	mr = waveOutRestart(stream->play_strm.hWave.Out);
 	if (mr != MMSYSERR_NOERROR) {
-	    return CONVERT_MM_ERROR(mr);
+	    return PJMEDIA_AUDIODEV_ERRNO_FROM_WMME_OUT(mr);
 	}
 	PJ_LOG(4,(THIS_FILE, "WMME playback stream started"));
@@ -1205,5 +1202,5 @@
 	mr = waveInStart(stream->rec_strm.hWave.In);
 	if (mr != MMSYSERR_NOERROR) {
-	    return CONVERT_MM_ERROR(mr);
+	    return PJMEDIA_AUDIODEV_ERRNO_FROM_WMME_IN(mr);
 	}
 	PJ_LOG(4,(THIS_FILE, "WMME capture stream started"));
@@ -1225,5 +1222,5 @@
 	mr = waveOutPause(stream->play_strm.hWave.Out);
 	if (mr != MMSYSERR_NOERROR) {
-	    return CONVERT_MM_ERROR(mr);
+	    return PJMEDIA_AUDIODEV_ERRNO_FROM_WMME_OUT(mr);
 	}
 	PJ_LOG(4,(THIS_FILE, "Stopped WMME playback stream"));
@@ -1234,5 +1231,5 @@
 	mr = waveInStop(stream->rec_strm.hWave.In);
 	if (mr != MMSYSERR_NOERROR) {
-	    return CONVERT_MM_ERROR(mr);
+	    return PJMEDIA_AUDIODEV_ERRNO_FROM_WMME_IN(mr);
 	}
 	PJ_LOG(4,(THIS_FILE, "Stopped WMME capture stream"));
@@ -1304,2 +1301,4 @@
 }
 
+#endif	/* PJMEDIA_AUDIO_DEV_HAS_WMME */
+
