unsafe public override bool RecordStart(Sound sound)
        {
            criticalSection.Enter();

            DirectCaptureSound captureSound = sound as DirectCaptureSound;

            if (captureSound == null)
            {
                criticalSection.Leave();
                DirectSoundWorld.Warning("Recording failed. Is sound a not for recording.");
                return(false);
            }

            captureSound.readPosition = 0;

            int hr = IDirectSoundCaptureBuffer.Start(captureSound.captureBuffer,
                                                     DSound.DSCBSTART_LOOPING);

            if (Wrapper.FAILED(hr))
            {
                criticalSection.Leave();
                DirectSoundWorld.Warning("IDirectSoundCaptureBuffer.Start", hr);
                return(false);
            }

            recordingSound = captureSound;

            criticalSection.Leave();

            return(true);
        }
        unsafe public override Sound SoundCreateDataBuffer(SoundMode mode, int channels,
                                                           int frequency, int bufferSize, DataReadDelegate dataReadCallback)
        {
            criticalSection.Enter();

            Sound sound;

            if ((int)(mode & SoundMode.Record) != 0)
            {
                DirectCaptureSound captureSound = new DirectCaptureSound(
                    mode, channels, frequency, bufferSize);
                if (captureSound.soundCapture == null)
                {
                    captureSound = null;
                }
                sound = captureSound;
            }
            else
            {
                sound = new DirectDataStreamSound(mode, channels, frequency,
                                                  bufferSize, dataReadCallback);
            }

            criticalSection.Leave();

            return(sound);
        }
        unsafe public override void RecordStop()
        {
            criticalSection.Enter();

            if (recordingSound != null)
            {
                int hr = IDirectSoundCaptureBuffer.Stop(recordingSound.captureBuffer);
                if (Wrapper.FAILED(hr))
                {
                    DirectSoundWorld.Warning("IDirectSoundCaptureBuffer.Stop", hr);
                }
                recordingSound = null;
            }

            criticalSection.Leave();
        }
예제 #4
0
		unsafe public override void RecordStop()
		{
			criticalSection.Enter();

			if( recordingSound != null )
			{
				int hr = IDirectSoundCaptureBuffer.Stop( recordingSound.captureBuffer );
				if( Wrapper.FAILED( hr ) )
					DirectSoundWorld.Warning( "IDirectSoundCaptureBuffer.Stop", hr );
				recordingSound = null;
			}

			criticalSection.Leave();
		}
예제 #5
0
		unsafe public override bool RecordStart( Sound sound )
		{
			criticalSection.Enter();

			DirectCaptureSound captureSound = sound as DirectCaptureSound;
			if( captureSound == null )
			{
				criticalSection.Leave();
				DirectSoundWorld.Warning( "Recording failed. Is sound a not for recording." );
				return false;
			}

			captureSound.readPosition = 0;

			int hr = IDirectSoundCaptureBuffer.Start( captureSound.captureBuffer,
				DSound.DSCBSTART_LOOPING );
			if( Wrapper.FAILED( hr ) )
			{
				criticalSection.Leave();
				DirectSoundWorld.Warning( "IDirectSoundCaptureBuffer.Start", hr );
				return false;
			}

			recordingSound = captureSound;

			criticalSection.Leave();

			return true;
		}
예제 #6
0
		unsafe public override Sound SoundCreateDataBuffer( SoundMode mode, int channels,
			int frequency, int bufferSize, DataReadDelegate dataReadCallback )
		{
			criticalSection.Enter();

			Sound sound;

			if( (int)( mode & SoundMode.Record ) != 0 )
			{
				DirectCaptureSound captureSound = new DirectCaptureSound(
					mode, channels, frequency, bufferSize );
				if( captureSound.soundCapture == null )
					captureSound = null;
				sound = captureSound;
			}
			else
			{
				sound = new DirectDataStreamSound( mode, channels, frequency,
					bufferSize, dataReadCallback );
			}

			criticalSection.Leave();

			return sound;
		}