当前位置: 首页>>代码示例>>C++>>正文


C++ DirectSoundCreate函数代码示例

本文整理汇总了C++中DirectSoundCreate函数的典型用法代码示例。如果您正苦于以下问题:C++ DirectSoundCreate函数的具体用法?C++ DirectSoundCreate怎么用?C++ DirectSoundCreate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了DirectSoundCreate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Detect

static int Detect()
{
	DX_Context ds;
    g_lpDSDevice = NULL;
    sysMemZero(g_pDSHandles, DSOUNDMAXBUFFER * sizeof(DS_handle));
    ds.lpGUID = NULL;

    if (RLX.Audio.WaveDeviceId)
    {
       ds.index = 0;
       ds.mode = 1;
       DirectSoundEnumerate((LPDSENUMCALLBACKA)DSEnumCallback, &ds);
    }

    if (SYS_DXTRACE(DirectSoundCreate(ds.lpGUID, &g_lpDSDevice, NULL)))
    {
       if (ds.lpGUID)
       {
			ds.lpGUID = NULL;
			RLX.Audio.WaveDeviceId = 0;
       }
	   if (SYS_DXTRACE(DirectSoundCreate(ds.lpGUID, &g_lpDSDevice, NULL)))
		   return -1;
    }
    return 0;
}
开发者ID:cbxbiker61,项目名称:nogravity,代码行数:26,代码来源:snd_ds6.cpp

示例2: gst_directsound_sink_open

static gboolean
gst_directsound_sink_open (GstAudioSink * asink)
{
  GstDirectSoundSink *dsoundsink;
  HRESULT hRes;

  dsoundsink = GST_DIRECTSOUND_SINK (asink);

  /* create and initialize a DirecSound object */
  if (FAILED (hRes = DirectSoundCreate (NULL, &dsoundsink->pDS, NULL))) {
    GST_ELEMENT_ERROR (dsoundsink, RESOURCE, OPEN_READ,
        ("gst_directsound_sink_open: DirectSoundCreate: %s",
            DXGetErrorString9 (hRes)), (NULL));
    return FALSE;
  }

  if (FAILED (hRes = IDirectSound_SetCooperativeLevel (dsoundsink->pDS,
              GetDesktopWindow (), DSSCL_PRIORITY))) {
    GST_ELEMENT_ERROR (dsoundsink, RESOURCE, OPEN_READ,
        ("gst_directsound_sink_open: IDirectSound_SetCooperativeLevel: %s",
            DXGetErrorString9 (hRes)), (NULL));
    return FALSE;
  }

  return TRUE;
}
开发者ID:BigBrother-International,项目名称:gst-plugins-good,代码行数:26,代码来源:gstdirectsoundsink.c

示例3: hr_ssprintf

CString DSound::Init()
{
	HRESULT hr;
	if( FAILED( hr = DirectSoundCreate(NULL, &m_pDS, NULL) ) )
		return hr_ssprintf( hr, "DirectSoundCreate" );

#ifndef _XBOX
	static bool bShownInfo = false;
	if( !bShownInfo )
	{
		bShownInfo = true;
		DirectSoundEnumerate( EnumCallback, 0 );

		DSCAPS Caps;
		Caps.dwSize = sizeof(Caps);
		HRESULT hr;
		if( FAILED(hr = m_pDS->GetCaps(&Caps)) )
		{
			LOG->Warn( hr_ssprintf(hr, "m_pDS->GetCaps failed") );
		}
		else
		{
			LOG->Info( "DirectSound sample rates: %i..%i %s", Caps.dwMinSecondarySampleRate, Caps.dwMaxSecondarySampleRate,
				(Caps.dwFlags & DSCAPS_CONTINUOUSRATE)?"(continuous)":"" );
		}
	}

	/* Try to set primary mixing privileges */
	hr = m_pDS->SetCooperativeLevel( GetDesktopWindow(), DSSCL_PRIORITY );
#endif

	SetPrimaryBufferMode();

	return "";
}
开发者ID:BitMax,项目名称:openitg,代码行数:35,代码来源:DSoundHelpers.cpp

示例4: DS_IsPresent

static BOOL DS_IsPresent(void)
{
	if(DirectSoundCreate(NULL,&pSoundCard,NULL)!=DS_OK)
		return 0;
	SAFE_RELEASE(pSoundCard);
	return 1;
}
开发者ID:Jay-Jay-OPL,项目名称:ps2sdk-ports,代码行数:7,代码来源:drv_ds.c

示例5: Initialize

bool CDxSound::Initialize(HWND hWnd)
{
	//初始化DirectSound设备
	if(DS_OK!=DirectSoundCreate(NULL,&m_dsound,NULL))
		return false;
	if(DS_OK!=m_dsound->SetCooperativeLevel(hWnd,DSSCL_PRIORITY))
		return false;

	//建立主缓冲区
	DSBUFFERDESC dsbDesc;
	ZeroMemory(&dsbDesc,sizeof(dsbDesc));
	dsbDesc.dwSize=sizeof(DSBUFFERDESC);
	dsbDesc.dwFlags=DSBCAPS_CTRLVOLUME|DSBCAPS_CTRLPAN|DSBCAPS_PRIMARYBUFFER;
	dsbDesc.dwBufferBytes=0;
	dsbDesc.lpwfxFormat=NULL;
	if(DS_OK!=m_dsound->CreateSoundBuffer(&dsbDesc,&m_primaryBuffer,NULL))
		return false;
	
	//设备播放格式
	WAVEFORMATEX waveFormatEx;
	ZeroMemory(&waveFormatEx,sizeof(WAVEFORMATEX));
	waveFormatEx.wFormatTag=WAVE_FORMAT_PCM;
	waveFormatEx.nChannels=2;
	waveFormatEx.nSamplesPerSec=22050;
	waveFormatEx.nBlockAlign=4;
	waveFormatEx.nAvgBytesPerSec=
		waveFormatEx.nSamplesPerSec*waveFormatEx.nBlockAlign;
	waveFormatEx.wBitsPerSample=16;
	if(DS_OK!=m_primaryBuffer->SetFormat(&waveFormatEx))
		return false;

	return true;
}
开发者ID:zouv,项目名称:VGE_demo,代码行数:33,代码来源:Sound.cpp

示例6: HRESULT

bool Platform_Win32_Sound_DSound::Setup()
	{
	dsoundDLL_=LoadLibrary("dsound.dll");

	if (dsoundDLL_)
		{
		typedef HRESULT (WINAPI *DirectSoundCreateDefinition)(LPCGUID pcGuidDevice, LPDIRECTSOUND *ppDS, LPUNKNOWN pUnkOuter);
		DirectSoundCreateDefinition DirectSoundCreate=(DirectSoundCreateDefinition)GetProcAddress((HMODULE)dsoundDLL_, "DirectSoundCreate");


		HRESULT hr;
		hr = DirectSoundCreate(NULL, &directSound_, NULL);
		if (!SUCCEEDED(hr))
			{
			Platform::GetPlatform_OS()->OutputDebugText("Couldn't create DirectSound object\n");
			return false;
			}

		hr = directSound_->SetCooperativeLevel(windowHandle_, /* DSSCL_EXCLUSIVE*/ DSSCL_NORMAL);
		if (!SUCCEEDED(hr))
			{
			Platform::GetPlatform_OS()->OutputDebugText("Couldn't set cooperative level for DirectSound object\n");
			return false;
			}

		return true;
		}

	Platform::GetPlatform_OS()->OutputDebugText("Couldn't load dsound.dll\n");
	return false;
	}
开发者ID:RichardMarks,项目名称:Pixie,代码行数:31,代码来源:Platform_Win32_Sound_DSound.cpp

示例7: if

/*------------------------
	イニシャライズ
  -------------------------*/
STDMETHODIMP CFACE::Sound( LONG DSMODE ){ if ( DSMODE == dwSndMode ) return S_OK;
	// ログに記述
		LogBegin( "Sounds Initializer" );
		LogPut( CONTINUE , IDS_LOG_MODEOUT , DSMODE ); 

	// ハンドルチェック
		CHECK_HWND;
	// グラフィック定数範囲チェック
		CHECK_RANGE( DSMODE , 0 , 1 );

	// 使用しないモード
	if ( DSMODE == SOUNDDISABLE ) SoundRelease( ); 
	else{
		SoundRelease( );	// 全解放
		// DirectSound を作成する。
		if ( FAILED( DirectSoundCreate( NULL , &ObjDS , NULL ) ) )
			DSoundInitFailed;
		// 協調レベルを設定する
		if ( FAILED( ObjDS->SetCooperativeLevel( hWnd , DSSCL_NORMAL ) ) )
			DSoundInitFailed;
		// イベントの作成
		// at Half, at EndPos , FinallyHandler at Half
		for ( int i = 0 ; i < 3 ; i++ ) 
			hEvent[ i ] = CreateEvent( NULL , FALSE , FALSE , NULL );
	}
	dwSndMode = (BYTE)DSMODE;
	LogQuit( );
	return S_OK;
}
开发者ID:ginjih,项目名称:facelib,代码行数:32,代码来源:FACE_Sound.cpp

示例8: AudioManager

	DirectSound_AudioManager::DirectSound_AudioManager(void* backendId, bool threaded, float updateTime, chstr deviceName) :
		AudioManager(backendId, threaded, updateTime, deviceName)
	{
		this->name = XAL_AS_DIRECTSOUND;
		hlog::write(xal::logTag, "Initializing DirectSound.");
		HRESULT result = DirectSoundCreate(NULL, &this->dsDevice, NULL);
		if (FAILED(result))
		{
			this->dsDevice = NULL;
			hlog::error(xal::logTag, "Could not create device!");
			return;
		}
		result = this->dsDevice->SetCooperativeLevel((HWND)backendId, DSSCL_NORMAL);
		if (FAILED(result))
		{
			this->dsDevice->Release();
			this->dsDevice = NULL;
			hlog::error(xal::logTag, "Could not set cooperative level!");
			return;
		}
		this->dsCaps = new _DSCAPS();
		memset(this->dsCaps, 0, sizeof(_DSCAPS));
		this->dsCaps->dwSize = sizeof(_DSCAPS);
		result = this->dsDevice->GetCaps(this->dsCaps);
		if (result != DS_OK)
		{
			this->dsCaps->dwMaxSecondarySampleRate = 100000; // just in case. 100k is guaranteed to be always supported on all DS hardware
			hlog::error(xal::logTag, "Failed fetching DirectSound device caps");
		}
		else
		{
			hlog::writef(xal::logTag, "DirectSound device caps: { maxSampleRate = %u }", this->dsCaps->dwMaxSecondarySampleRate);
		}
		this->enabled = true;
	}
开发者ID:Tomcodon,项目名称:libxal,代码行数:35,代码来源:DirectSound_AudioManager.cpp

示例9: DirectSoundCreate

LPDIRECTSOUND CDXSound::Create( HWND hwnd, DWORD dwLevel )
{
	HRESULT hr;

	m_hWnd = hwnd;
	m_lpDS = NULL;
	
	hr = DirectSoundCreate( NULL, &m_lpDS, NULL );
	if( hr != DS_OK )
		return m_lpDS;

	hr = m_lpDS->SetCooperativeLevel( hwnd, dwLevel );//DSSCL_NORMAL );
	if ( hr != DS_OK ) 
	{
		m_lpDS->Release();
		m_lpDS = NULL;
	}
	else if ( !CreateBuffer() )
	{
		DestroyBuffer();
		m_lpDS->Release();
		m_lpDS = NULL;
	}
	return m_lpDS;
}
开发者ID:meesokim,项目名称:appleinpc,代码行数:25,代码来源:dxsound.cpp

示例10: DSW_InitOutputDevice

HRESULT DSW_InitOutputDevice( DSoundWrapper *dsw, LPGUID lpGUID )
{
// Create the DS object
	HRESULT hr = DirectSoundCreate( lpGUID, &dsw->dsw_pDirectSound, NULL );
	if( hr != DS_OK ) return hr;
	return hr;
}
开发者ID:andreipaga,项目名称:audacity,代码行数:7,代码来源:dsound_wrapper.c

示例11: DirectSoundInit

Boolean DirectSoundInit( MADDriverRec* WinMADDriver)
{
	OnOff					= false;
	
	WIN95BUFFERSIZE = WinMADDriver->BufSize;
	WIN95BUFFERSIZE *= 2L;								// double buffer system
	
	currentBuf 		= calloc( WIN95BUFFERSIZE, 1);
	
	hwnd = GetForegroundWindow();	//GetForegroundWindow();
	if( !hwnd) return false;
	
	if(DS_OK == DirectSoundCreate(NULL, &WinMADDriver->lpDirectSound, NULL))
	{
		if( !AppCreateWritePrimaryBuffer( WinMADDriver->lpDirectSound, &WinMADDriver->lpDirectSoundBuffer, hwnd, WinMADDriver))
		{
			WinMADDriver->lpDirectSound = 0L;
			return false;
		}
		if( !WinMADDriver->lpDirectSoundBuffer) return false;
		
		// Creation succeeded.
		WinMADDriver->lpDirectSound->lpVtbl->SetCooperativeLevel(WinMADDriver->lpDirectSound, hwnd, DSSCL_NORMAL);
		
		WinMADDriver->lpSwSamp = 0L;
		if( !LoadSamp(WinMADDriver->lpDirectSound, &WinMADDriver->lpSwSamp, 0L, WIN95BUFFERSIZE, DSBCAPS_LOCSOFTWARE, WinMADDriver))
		{
			//DEBUG debugger( "Error 2\n");		//DSBCAPS_LOCSOFTWARE
			WinMADDriver->lpDirectSound = 0L;
			return false;
		}
		
		if( !WinMADDriver->lpSwSamp) return false;
		
		WinMADDriver->lpSwSamp->lpVtbl->Play(WinMADDriver->lpSwSamp, 0, 0, DSBPLAY_LOOPING);
		
		///////////
		
		timeBeginPeriod(20);      /* set the minimum resolution */
		
		/*  Set up the callback event.  The callback function
		 *  MUST be in a FIXED CODE DLL!!! -> not in Win95
		 */
		 
		// debugger( "timeSetEvent\n");
		 
		gwID = timeSetEvent(	  40,   												/* how often                 */
													  40,   							/* timer resolution          */
													  TimeProc,  						/* callback function         */
													  (unsigned long) WinMADDriver,		/* info to pass to callback  */
													  TIME_PERIODIC); 					/* oneshot or periodic?      */
		
		if( gwID == 0) return false;
		else return true;
	}
	
	WinMADDriver->lpDirectSound = 0L;
	
	return false;
}
开发者ID:mctully,项目名称:tntbasic,代码行数:60,代码来源:Win-DirectSound.c

示例12: SB_Init

static BOOL SB_Init(void)
{
    HRESULT result;

    if (!lpdsound) {
        result = DirectSoundCreate(NULL,&lpdsound,NULL);
        if (result != DS_OK) {
            ERR("Unable to initialize Sound Subsystem err = %x !\n",result);
            return FALSE;
        }

        /* FIXME: To uncomment when :
           - SetCooperative level is correctly implemented
           - an always valid and non changing handle to a windows  (vga_hwnd) is available
             (this surely needs some work in vga.c)
        result = IDirectSound_SetCooperativeLevel(lpdsound,vga_hwnd,DSSCL_EXCLUSIVE|DSSCL_PRIORITY);
        if (result != DS_OK) {
            ERR("Can't set cooperative level !\n");
            return FALSE;
        }
        */

        /* Default format */
        wav_fmt.wFormatTag = WAVE_FORMAT_PCM;
        wav_fmt.nChannels = 1;
        wav_fmt.nSamplesPerSec = 22050;
        wav_fmt.nAvgBytesPerSec = 22050;
        wav_fmt.nBlockAlign = 1;
        wav_fmt.wBitsPerSample = 8;
        wav_fmt.cbSize = 0;

        memset(&buf_desc,0,sizeof(DSBUFFERDESC));
        buf_desc.dwSize = sizeof(DSBUFFERDESC);
        buf_desc.dwBufferBytes = DSBUFLEN;
        buf_desc.lpwfxFormat = &wav_fmt;
        result = IDirectSound_CreateSoundBuffer(lpdsound,&buf_desc,&lpdsbuf,NULL);
        if (result != DS_OK) {
            ERR("Can't create sound buffer !\n");
            return FALSE;
        }

        result = IDirectSoundBuffer_Play(lpdsbuf,0, 0, DSBPLAY_LOOPING);
        if (result != DS_OK) {
            ERR("Can't start playing !\n");
            return FALSE;
        }

        buf_off = 0;
        end_sound_loop = 0;
        SB_Thread = CreateThread(NULL, 0, SB_Poll, NULL, 0, NULL);
        TRACE("thread\n");
        if (!SB_Thread) {
            ERR("Can't create thread !\n");
            return FALSE;
        }
    }
    return TRUE;
}
开发者ID:Dimillian,项目名称:wine,代码行数:58,代码来源:soundblaster.c

示例13: DirectSoundCreate

int audioStreamer_ds::Open(int iswrite, int srate, int nch, int bps, int sleep, int nbufs, int bufsize, GUID *device)
{
  // todo: use device
  m_sleep = sleep >= 0 ? sleep : 0;

  GUID zero={0,};
  if (!memcmp(device,&zero,sizeof(zero))) device=NULL;

  m_nch = nch;
  m_srate=srate;
  m_bps=bps;

  int fmt_align=(bps>>3)*nch;
  int fmt_mul=fmt_align*srate;
  WAVEFORMATEX wfx={
		WAVE_FORMAT_PCM,
		nch,
		srate,
		fmt_mul,
		fmt_align,
		bps,
		0
	};
  m_totalbufsize=nbufs*bufsize;

  if (iswrite)
  {
      DirectSoundCreate(device,&m_lpds,NULL);

      if (m_lpds)
      {
        HWND hWnd = GetForegroundWindow();
        if (hWnd == NULL) hWnd = GetDesktopWindow();
        m_lpds->SetCooperativeLevel(hWnd,DSSCL_PRIORITY);

        // create a secondary buffer for now
        DSBUFFERDESC ds={sizeof(ds),DSBCAPS_GETCURRENTPOSITION2|DSBCAPS_GLOBALFOCUS,m_totalbufsize,0,&wfx, };
        m_lpds->CreateSoundBuffer(&ds,&m_outbuf,NULL);
        
      }

  }
  else
  {
    DirectSoundCaptureCreate(device,&m_lpcap,NULL);
    if (m_lpcap)
    {
      DSCBUFFERDESC ds={sizeof(ds),0,m_totalbufsize,0,&wfx, };
      m_lpcap->CreateCaptureBuffer(&ds,&m_inbuf,NULL);
    }
  }

  m_bufsize=bufsize;


  return 0;
}
开发者ID:libninjam,项目名称:libninjam-win,代码行数:57,代码来源:audiostream_win32.cpp

示例14: DS_IsPresent

static BOOL DS_IsPresent(void)
{
	if(DirectSoundCreate(NULL,&pSoundCard,NULL)!=DS_OK)
		return 0;
	if (pSoundCard) {
		IDirectSound_Release(pSoundCard);
		pSoundCard = NULL;
	}
	return 1;
}
开发者ID:OS2World,项目名称:LIB-SDL-2014,代码行数:10,代码来源:drv_ds.c

示例15: func

      static BOOL CALLBACK func(LPGUID lpGuid, LPCSTR lpcstrDescription, LPCSTR lpcstrModule, LPVOID lpContext) {
        enum_callback *context = (enum_callback *)lpContext;

        if (_stricmp(context->name, lpcstrDescription) == 0) {
          context->hr = DirectSoundCreate(lpGuid, &dsound, NULL);
          return false;
        }

        return true;
      }
开发者ID:YueLinHo,项目名称:freepiano,代码行数:10,代码来源:output_dsound.cpp


注:本文中的DirectSoundCreate函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。