示例#1
0
        unsafe IDirectSoundBuffer *CreateBuffer(int needBufferSize)
        {
            uint creationFlags = 0;

            if ((int)(Mode & SoundMode.Mode3D) != 0)
            {
                creationFlags |= DSound.DSBCAPS_CTRL3D;
            }
            else
            {
                creationFlags |= DSound.DSBCAPS_CTRLPAN;
            }

            if ((int)(Mode & SoundMode.Software) != 0)
            {
                creationFlags |= DSound.DSBCAPS_LOCSOFTWARE;
            }

            creationFlags |= DSound.DSBCAPS_CTRLFREQUENCY;
            creationFlags |= DSound.DSBCAPS_CTRLVOLUME;
            creationFlags |= DSound.DSBCAPS_GETCURRENTPOSITION2;

            if ((creationFlags & DSound.DSBCAPS_CTRLFX) != 0)
            {
                //нельзя DuplicateSoundBuffer делать для DSBCAPS_CTRLFX
                //не забыть патом данные заливать во все буферы
                Log.Fatal("(creationFlags & DSBCAPS_CTRLFX) != 0.");
            }

            int hr;
            void */*IDirectSoundBuffer*/ soundBuffer;

            if (soundBuffers.Count == 0)
            {
                DSBUFFERDESC bufferDesc = new DSBUFFERDESC();
                //ZeroMemory( &bufferDesc, sizeof( DSBUFFERDESC ) );
                bufferDesc.dwSize          = (uint)sizeof(DSBUFFERDESC);
                bufferDesc.dwFlags         = creationFlags;
                bufferDesc.dwBufferBytes   = (uint)needBufferSize;
                bufferDesc.guid3DAlgorithm = DSound.DS3DALG_DEFAULT;
                bufferDesc.lpwfxFormat     = waveFormat;

                hr = IDirectSound8.CreateSoundBuffer(DirectSoundWorld.Instance.directSound,
                                                     ref bufferDesc, out soundBuffer, null);
                //hr = DirectSoundWorld.Instance.directSound->CreateSoundBuffer(
                //   &bufferDesc, &soundBuffer, NULL );

                if (Wrapper.FAILED(hr))
                {
                    DirectSoundWorld.Warning("CreateSoundBuffer", hr);
                    return(null);
                }

                //get bufferSize
                DSBCAPS bufferCaps = new DSBCAPS();
                //ZeroMemory( &bufferCaps, sizeof( DSBCAPS ) );
                bufferCaps.dwSize = (uint)sizeof(DSBCAPS);
                IDirectSoundBuffer.GetCaps(soundBuffer, ref bufferCaps);
                bufferSize = (int)bufferCaps.dwBufferBytes;
            }
            else
            {
                hr = IDirectSound8.DuplicateSoundBuffer(DirectSoundWorld.Instance.directSound,
                                                        (IDirectSoundBuffer *)soundBuffers[0].ToPointer(), out soundBuffer);
                if (Wrapper.FAILED(hr))
                {
                    DirectSoundWorld.Warning("DuplicateSoundBuffer", hr);
                    return(null);
                }
            }

            return((IDirectSoundBuffer *)soundBuffer);
        }
示例#2
0
		public unsafe static extern int GetCaps( void*/*IDirectSoundBuffer*/ _this,
			ref DSBCAPS pDSCaps );
示例#3
0
 public unsafe static extern int GetCaps(void */*IDirectSoundBuffer*/ _this,
                                         ref DSBCAPS pDSCaps);
示例#4
0
		unsafe IDirectSoundBuffer* CreateBuffer( int needBufferSize )
		{
			uint creationFlags = 0;

			if( (int)( Mode & SoundMode.Mode3D ) != 0 )
				creationFlags |= DSound.DSBCAPS_CTRL3D;
			else
				creationFlags |= DSound.DSBCAPS_CTRLPAN;

			if( (int)( Mode & SoundMode.Software ) != 0 )
				creationFlags |= DSound.DSBCAPS_LOCSOFTWARE;

			creationFlags |= DSound.DSBCAPS_CTRLFREQUENCY;
			creationFlags |= DSound.DSBCAPS_CTRLVOLUME;
			creationFlags |= DSound.DSBCAPS_GETCURRENTPOSITION2;

			if( ( creationFlags & DSound.DSBCAPS_CTRLFX ) != 0 )
			{
				//нельзя DuplicateSoundBuffer делать для DSBCAPS_CTRLFX
				//не забыть патом данные заливать во все буферы
				Log.Fatal( "(creationFlags & DSBCAPS_CTRLFX) != 0." );
			}

			int hr;
			void*/*IDirectSoundBuffer*/ soundBuffer;

			if( soundBuffers.Count == 0 )
			{
				DSBUFFERDESC bufferDesc = new DSBUFFERDESC();
				//ZeroMemory( &bufferDesc, sizeof( DSBUFFERDESC ) );
				bufferDesc.dwSize = (uint)sizeof( DSBUFFERDESC );
				bufferDesc.dwFlags = creationFlags;
				bufferDesc.dwBufferBytes = (uint)needBufferSize;
				bufferDesc.guid3DAlgorithm = DSound.DS3DALG_DEFAULT;
				bufferDesc.lpwfxFormat = waveFormat;

				hr = IDirectSound8.CreateSoundBuffer( DirectSoundWorld.Instance.directSound,
					ref bufferDesc, out soundBuffer, null );
				//hr = DirectSoundWorld.Instance.directSound->CreateSoundBuffer(
				//   &bufferDesc, &soundBuffer, NULL );

				if( Wrapper.FAILED( hr ) )
				{
					DirectSoundWorld.Warning( "CreateSoundBuffer", hr );
					return null;
				}

				//get bufferSize
				DSBCAPS bufferCaps = new DSBCAPS();
				//ZeroMemory( &bufferCaps, sizeof( DSBCAPS ) );
				bufferCaps.dwSize = (uint)sizeof( DSBCAPS );
				IDirectSoundBuffer.GetCaps( soundBuffer, ref bufferCaps );
				bufferSize = (int)bufferCaps.dwBufferBytes;
			}
			else
			{
				hr = IDirectSound8.DuplicateSoundBuffer( DirectSoundWorld.Instance.directSound,
					(IDirectSoundBuffer*)soundBuffers[ 0 ].ToPointer(), out soundBuffer );
				if( Wrapper.FAILED( hr ) )
				{
					DirectSoundWorld.Warning( "DuplicateSoundBuffer", hr );
					return null;
				}
			}

			return (IDirectSoundBuffer*)soundBuffer;
		}