|
1 registered members (EW_bytes),
15,961
guests, and 6
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
snd_play() delay, ent_playsound() not threadsafe
#287124
08/30/09 09:12
08/30/09 09:12
|
Joined: Jul 2005
Posts: 1,930 Austria
Dark_samurai
OP
Serious User
|
OP
Serious User
Joined: Jul 2005
Posts: 1,930
Austria
|
Hi jcl! As you already know, I want to use the built in sound functions for my VoIP feature. Now I ran over two new problems and I need you knowledge to solve them: 1) For VoIP, my application records a stream during runtime and splits the recorded stream into small 20 ms packets. These are sent over the network and then played with snd_play(). This is working well, but I noticed small noises/delays between the calls. To explain the problem, try the following:
//Lite-C:
function main()
{
wait(1);
while(1)
{
SOUND* dummy_snd = snd_create("dummy.wav");
var sndhandle = snd_play(dummy_snd,100,0);
while(snd_playing(sndhandle)) {wait(1);}
snd_remove(dummy_snd);
wait(1);
}
}
dummy.wav is a tone. The output should be one long tone, but in reality between the snd_play() instructions small delays/noise can be heard. Get the soundfile here (use dummy.wav). What can I do against this delay/noise? 2) Using ent_playsound() in a thread causes a crash. But I would need ent_playsound() also to be threadsave so that I can make a 3d VoIP. What shell I do? Any possibility that this function gets threadsafe in one of the next updates? Thanks for your help!
ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)! get free version
|
|
|
Re: snd_play() delay, ent_playsound() not threadsafe
[Re: jcl]
#287301
08/31/09 10:16
08/31/09 10:16
|
Joined: Jul 2005
Posts: 1,930 Austria
Dark_samurai
OP
Serious User
|
OP
Serious User
Joined: Jul 2005
Posts: 1,930
Austria
|
Permanently deleting and creating a sound will cause the artifacts that you're hearing. Use the pds and pdsb pointers to directly create a sound buffer for your voice. How to get access to the pDS and pDSB pointers? Do you have any examples for that? AFAIK, DirectSound itself is threadsafe, but engine functions are not. So what shell I do to use 3d sound in a thread? Recreate the ent_playsound function with directsound, or is there any easier workaround?
ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)! get free version
|
|
|
Re: snd_play() delay, ent_playsound() not threadsafe
[Re: jcl]
#287325
08/31/09 12:11
08/31/09 12:11
|
Joined: Jul 2005
Posts: 1,930 Austria
Dark_samurai
OP
Serious User
|
OP
Serious User
Joined: Jul 2005
Posts: 1,930
Austria
|
Do you have any examples for that, because I never have worked with DirectSound before?
Do I have access to the DirectSound functions when I write an acknex plugin or do I need to include the DX SDK?
ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)! get free version
|
|
|
Re: snd_play() delay, ent_playsound() not threadsafe
[Re: jcl]
#287755
09/02/09 12:04
09/02/09 12:04
|
Joined: Jul 2005
Posts: 1,930 Austria
Dark_samurai
OP
Serious User
|
OP
Serious User
Joined: Jul 2005
Posts: 1,930
Austria
|
So what version of the DX SDK should be used and which one is used by the engine? March 2009?
Edit: Btw. because DirectSound was replaced through XAudio2, there are no samples anymore in the DX SDK...
Could you give me a short code snippet how to create a new buffer , copy data in it and play it?
Last edited by Dark_samurai; 09/02/09 13:53.
ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)! get free version
|
|
|
Re: snd_play() delay, ent_playsound() not threadsafe
[Re: Dark_samurai]
#287846
09/02/09 19:35
09/02/09 19:35
|
Joined: Dec 2006
Posts: 1,086 Queensland - Australia
Nidhogg
Serious User
|
Serious User
Joined: Dec 2006
Posts: 1,086
Queensland - Australia
|
So what version of the DX SDK should be used and which one is used by the engine? March 2009?
Edit: Btw. because DirectSound was replaced through XAudio2, there are no samples anymore in the DX SDK... I use the NOV-2007 DXSDK. It has samples using DX7 & 8 as well as voice management. It does however give an error about a pre-release X-Audio2 but just ignore it. The SDK still installs and works fine. If you can't find it let me know and I'll make it available for download. (I hope i'm allowed to do that) Could you give me a short code snippet how to create a new buffer , copy data in it and play it? I wouldn't mind an example also please. 
Windows XP SP3 Intel Dual Core CPU: E5200 @ 2.5GHz 4.00GB DDR3 Ram ASUS P5G41T-M LX PCIE x16 GeForce GTS 450 1Gb SB Audigy 4 Spyware Doctor with AntiVirus
|
|
|
Re: snd_play() delay, ent_playsound() not threadsafe
[Re: jcl]
#287970
09/03/09 13:35
09/03/09 13:35
|
Joined: Jul 2005
Posts: 1,930 Austria
Dark_samurai
OP
Serious User
|
OP
Serious User
Joined: Jul 2005
Posts: 1,930
Austria
|
I found a download to the April 2006 SDK. Now I try to get normal output working (not the 3d one):
LPDIRECTSOUND dsDSound = (LPDIRECTSOUND)ev->pds;
LPDIRECTSOUNDBUFFER dsBuffer;
DSBUFFERDESC dsBufferDesc;
WAVEFORMATEX waveform;
dsBufferDesc.dwFlags = DSBCAPS_STICKYFOCUS;
dsBufferDesc.dwBufferBytes = voip_bufsize;
init_waveformat(&waveform);
dsBufferDesc.lpwfxFormat = &waveform;
dsBufferDesc.dwSize = sizeof(dsBufferDesc);
dsDSound->CreateSoundBuffer(&dsBufferDesc,&dsBuffer,NULL); //This methode always returns E_INVALIDARG
I did everything exactly as it is explained in msdn, but of course it's not working... The CreateSoundBuffer methode always returns E_INVALIDARG. What am I doing wrong? This thing drives me crazy. PS: waveform is initialized with 16000Hz,16bit/sample,mono.
ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)! get free version
|
|
|
|