Didier LINK wrote:

Le mercredi 24 janvier 2007 à 02:08 +0100, Jerome WAGNER a écrit :
Hello,

Hello all,

Yes I think you are right ; forcing the audio device in your case leads to a
bug.

select_audio_device is supposed override the deviceId when it is forced, but
I guess that the "const char *" stops this from working.

The "const" is not the main problem here, the pointer is not the same
after the function call and we need to copy the good string with strcpy.

Maybe you can try and patch it this way (making sure that when we get out of
select_audio_device, the deviceId has been changed)

See attached a little patch to solve this case. It works for me, can you
review it and commit to the svn if it looks good ?

I can begin to go further with the alsa support now ;)

Thanks.

Didier Link

Hi Didier,

While your code is correct, i don'r really see what was wrong with original code.... It was designed in such way as not to modify deviceId string, so it should work....

Vadim

------------------------------------------------------------------------

Index: wengophone-2.1/wifo/phapi/phmedia.c
===================================================================
--- wengophone-2.1/wifo/phapi/phmedia.c (révision 9392)
+++ wengophone-2.1/wifo/phapi/phmedia.c (copie de travail)
@@ -59,18 +59,23 @@
int ph_msession_start(struct ph_msession_s *s, const char *deviceid)
{
  int ret1,ret2 = -1;
+  char *devName;

+  devName = strdup(deviceid);
+
  DBG_MEDIA_ENGINE("MEDIA_ENGINE: entering ph_msession_start\n");

  g_mutex_lock(s->critsec_mstream_init);

-  ret1 = ph_msession_audio_start(s, deviceid);
+  ret1 = ph_msession_audio_start(s, devName);
#ifdef PHAPI_VIDEO_SUPPORT
  ret2 = ph_msession_video_start(s, deviceid);
#endif

  g_mutex_unlock(s->critsec_mstream_init);

+  free(devName);
+
  if (!ret1 && !ret2)
  {
    return 0;
Index: wengophone-2.1/wifo/phapi/phmedia-audio.c
===================================================================
--- wengophone-2.1/wifo/phapi/phmedia-audio.c   (révision 9392)
+++ wengophone-2.1/wifo/phapi/phmedia-audio.c   (copie de travail)
@@ -2081,7 +2081,17 @@

  if (forcedDeviceId)
  {
-    deviceId = forcedDeviceId;
+       // Ensure that the destination buffer has the good size sor strcpy
+       if (strlen(forcedDeviceId) > strlen(deviceId))
+       {
+ if ((realloc(deviceId, + strlen(forcedDeviceId) * sizeof(char))) == NULL)
+               {
+                       DBG_DYNA_AUDIO_DRV("error in realloc() ; 
phmedia-audio.c:2085\n");
+               }
+       }
+
+         strcpy(deviceId, forcedDeviceId);
  }

  if (!deviceId || !deviceId[0])
------------------------------------------------------------------------

_______________________________________________
Wengophone-devel mailing list
Wengophone-devel@lists.openwengo.com
http://dev.openwengo.com/mailman/listinfo/wengophone-devel

_______________________________________________
Wengophone-devel mailing list
Wengophone-devel@lists.openwengo.com
http://dev.openwengo.com/mailman/listinfo/wengophone-devel

Reply via email to