當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。