Fixed bug in dsound.c: handled case when lpGUID is NULL (common for primary devices). Thanks Yejun Yang

git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@1422 74dad513-b988-da41-8d7b-12977e46ad98
diff --git a/pjmedia/src/pjmedia/dsound.c b/pjmedia/src/pjmedia/dsound.c
index 3f71edc..dc51d97 100644
--- a/pjmedia/src/pjmedia/dsound.c
+++ b/pjmedia/src/pjmedia/dsound.c
@@ -51,6 +51,7 @@
 struct dsound_dev_info
 {
     pjmedia_snd_dev_info    info;
+    LPGUID		    lpGuid;
     GUID		    guid;
 };
 
@@ -158,7 +159,7 @@
     /*
      * Create DirectSound device.
      */
-    hr = DirectSoundCreate(&dev_info[dev_id].guid, &ds_strm->ds.play.lpDs, 
+    hr = DirectSoundCreate(dev_info[dev_id].lpGuid, &ds_strm->ds.play.lpDs, 
 			   NULL);
     if (FAILED(hr))
 	return PJ_RETURN_OS_ERROR(hr);
@@ -277,7 +278,7 @@
     /*
      * Creating recorder device.
      */
-    hr = DirectSoundCaptureCreate(&dev_info[dev_id].guid, 
+    hr = DirectSoundCaptureCreate(dev_info[dev_id].lpGuid, 
 				  &ds_strm->ds.capture.lpDs, NULL);
     if (FAILED(hr))
 	return PJ_RETURN_OS_ERROR(hr);
@@ -601,8 +602,11 @@
      * dev_info item, by looking at the GUID.
      */
     for (index=0; index<dev_count; ++index) {
-	if (pj_memcmp(&dev_info[index].guid, lpGuid, sizeof(GUID))==0)
+	if ((dev_info[index].lpGuid==NULL && lpGuid==NULL) ||
+	    pj_memcmp(&dev_info[index].guid, lpGuid, sizeof(GUID))==0)
+	{
 	    break;
+	}
     }
 
     if (index == dev_count)
@@ -616,7 +620,12 @@
 
     strncpy(dev_info[index].info.name, lpcstrDescription, max);
     dev_info[index].info.name[max-1] = '\0';
-    pj_memcpy(&dev_info[index].guid, lpGuid, sizeof(GUID));
+    if (lpGuid == NULL) {
+	dev_info[index].lpGuid = NULL;
+    } else {
+	pj_memcpy(&dev_info[index].guid, lpGuid, sizeof(GUID));
+	dev_info[index].lpGuid = &dev_info[index].guid;
+    }
     dev_info[index].info.default_samples_per_sec = 44100;
     
     /* Just assumed that device supports stereo capture/playback */