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


C++ IDirectSound_CreateSoundBuffer函数代码示例

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


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

示例1: createDSBuffer

int createDSBuffer(DWORD flags, int samples, int freq, int bits, int channels,
                   LPDIRECTSOUNDBUFFER *bufAddr)
{
    DSBUFFERDESC    bufd;
    WAVEFORMATEX    form;
    DWORD           dataBytes = samples * bits/8 * channels;

    // Prepare the buffer description.
    memset(&bufd, 0, sizeof(bufd));
    bufd.dwSize = sizeof(bufd);
    bufd.dwFlags = flags;
    bufd.dwBufferBytes = dataBytes;
    bufd.lpwfxFormat = &form;

    // Prepare the format description.
    memset(&form, 0, sizeof(form));
    form.wFormatTag = WAVE_FORMAT_PCM;
    form.nChannels = channels;
    form.nSamplesPerSec = freq;
    form.nBlockAlign = channels * bits/8;
    form.nAvgBytesPerSec = form.nSamplesPerSec * form.nBlockAlign;
    form.wBitsPerSample = bits;

    return IDirectSound_CreateSoundBuffer(dsound, &bufd, bufAddr, NULL);
}
开发者ID:cmbruns,项目名称:Doomsday-Engine,代码行数:25,代码来源:i_ds_eax.c

示例2: CreateChannel

//static	BOOL CreateChannel( char* Name, DSBUFFERDESC*	dsBD, Channel** chanelPtr)
static	BOOL CreateChannel(DSBUFFERDESC*	dsBD, Channel** chanelPtr)
{
	Channel* channel;

//	channel = malloc( sizeof( Channel ) );
	channel = geRam_Allocate( sizeof( Channel ) );
	if	( channel == NULL )
	{
		geErrorLog_Add(GE_ERR_OUT_OF_MEMORY, NULL);
		return( FALSE );
	}
	if(DS_OK != IDirectSound_CreateSoundBuffer(lpDirectSound, dsBD, &channel->buffer, NULL))
	{
		geErrorLog_Add(GE_ERR_CREATE_SOUND_BUFFER_FAILED, NULL);
		return FALSE;
	}
	if(DS_OK != IDirectSoundBuffer_GetFrequency(channel->buffer, &channel->BaseFreq) )
	{
		geErrorLog_Add(GE_ERR_DS_ERROR, NULL);
		return FALSE;
	}
	channel->next = NULL;
	channel->nextDup = NULL;
	channel->ID = 0;
	channel->cfg.Volume = 1.0f;
	channel->cfg.Pan = 0.0f;
	channel->cfg.Frequency = 0.0f;
//	channel->name = Name;

	*chanelPtr = channel;
	return( TRUE );
}
开发者ID:RealityFactory,项目名称:Genesis3D,代码行数:33,代码来源:Sound.c

示例3: CreateStaticSoundBuffer

//---------------------------------------------------------------------------
//
//---------------------------------------------------------------------------
LPDIRECTSOUNDBUFFER CreateStaticSoundBuffer(void* buffer, int ndata)
{

  LPDIRECTSOUNDBUFFER pDSB = NULL;;
  memset( &pcmwf, 0, sizeof (WAVEFORMATEX ));
  pcmwf.wFormatTag = WAVE_FORMAT_PCM;
  pcmwf.nChannels = 1;
  pcmwf.nSamplesPerSec = SR;
  pcmwf.nBlockAlign = 2;
  pcmwf.nAvgBytesPerSec = SR * 2;
  pcmwf.wBitsPerSample = bits;

	// --- start sound ---

	// Set up DSBUFFERDESC structure.
  memset(&dsbdesc, 0, sizeof (DSBUFFERDESC)); // Zero it out.
  dsbdesc.dwSize = sizeof (DSBUFFERDESC);
  dsbdesc.dwFlags = DSBCAPS_STATIC | DSBCAPS_CTRLFREQUENCY;// |  DSBCAPS_GETCURRENTPOSITION2;
/*
  #define DSBCAPS_CTRLFREQUENCY       0x00000020
#define DSBCAPS_CTRLPAN             0x00000040
#define DSBCAPS_CTRLVOLUME          0x00000080
  */
  dsbdesc.dwBufferBytes = ndata;
  dsbdesc.lpwfxFormat = &pcmwf;
  
  if(!SUCCEEDED(IDirectSound_CreateSoundBuffer(lpDirectSound,&dsbdesc, &(pDSB), NULL)))
  {
	  MessageBox(0,"ERROR BUFFER","ERROR BUFFER",MB_OK);
	  return NULL;

  }
  FillDSBufer(pDSB,buffer,ndata);
  return pDSB;
}
开发者ID:javisantana,项目名称:cubyshot,代码行数:38,代码来源:sound.c

示例4: CreatePrimaryBuffer

/*
 * プライマリバッファを作成してフォーマットを設定する
 */
static BOOL CreatePrimaryBuffer()
{
	DSBUFFERDESC dsbd;
	LPDIRECTSOUNDBUFFER pDSPrimary;
	HRESULT hRet;

	ZeroMemory(&dsbd, sizeof(DSBUFFERDESC));
	dsbd.dwSize = sizeof(DSBUFFERDESC);
	dsbd.dwFlags = DSBCAPS_PRIMARYBUFFER;
	dsbd.dwBufferBytes = 0;
	dsbd.lpwfxFormat = NULL;

	/* プライマリバッファを作成する */
	hRet = IDirectSound_CreateSoundBuffer(pDS, &dsbd, &pDSPrimary, NULL);
	if(hRet != DS_OK)
		return FALSE;

	/* プライマリバッファのフォーマットを設定する */
	ZeroMemory(&wfPrimary, sizeof(WAVEFORMATEX));
	wfPrimary.wFormatTag = WAVE_FORMAT_PCM;
	wfPrimary.nChannels = CHANNELS;
	wfPrimary.nSamplesPerSec = SAMPLES_PER_SEC;
	wfPrimary.wBitsPerSample = BIT_DEPTH;
	wfPrimary.nBlockAlign = (WORD)(wfPrimary.wBitsPerSample / 8 *
							wfPrimary.nChannels);
	wfPrimary.nAvgBytesPerSec = wfPrimary.nSamplesPerSec *
								wfPrimary.nBlockAlign;
	hRet = IDirectSoundBuffer_SetFormat(pDSPrimary, &wfPrimary);

	/* プライマリバッファにはアクセスしないので解放してよい */
	IDirectSoundBuffer_Release(pDSPrimary);

	return hRet == DS_OK;
}
开发者ID:ktabata,项目名称:suika2,代码行数:37,代码来源:dsound.c

示例5: sizeof

IDirectSoundBuffer *DSLoadSoundBuffer(IDirectSound *pDS, LPCTSTR lpName)
{
    IDirectSoundBuffer *pDSB = NULL;
    DSBUFFERDESC dsBD = {0};
    BYTE *pbWaveData;

    if (DSGetWaveResource(NULL, lpName, &dsBD.lpwfxFormat, &pbWaveData, &dsBD.dwBufferBytes))
    {
        dsBD.dwSize = sizeof(dsBD);
        dsBD.dwFlags = DSBCAPS_STATIC | DSBCAPS_CTRLDEFAULT; // | DSBCAPS_GETCURRENTPOSITION2;

        if (SUCCEEDED(IDirectSound_CreateSoundBuffer(pDS, &dsBD, &pDSB, NULL)))
        {
            if (!DSFillSoundBuffer(pDSB, pbWaveData, dsBD.dwBufferBytes))
            {
                IDirectSoundBuffer_Release(pDSB);
                pDSB = NULL;
            }
        }
        else
        {
            pDSB = NULL;
        }
    }

    return pDSB;
}
开发者ID:bowlofstew,项目名称:ja2,代码行数:27,代码来源:dsutil.c

示例6: CreatePrimaryBuffer

static HRESULT CreatePrimaryBuffer(void)
{
  DSBUFFERDESC dsbdesc;
// proff 07/23/98: Added WAVEFORMATEX and HRESULT
  WAVEFORMATEX wf;
  HRESULT result;

  memset(&dsbdesc, 0, sizeof(DSBUFFERDESC));
  dsbdesc.dwSize = sizeof(DSBUFFERDESC);
  dsbdesc.dwFlags = DSBCAPS_PRIMARYBUFFER; 

  memset(&wf, 0, sizeof(WAVEFORMATEX));
  if (snd_bits!=16)
    snd_bits=8;
// proff 07/23/98: Added wf
  wf.wFormatTag = WAVE_FORMAT_PCM;
  if (snd_stereo!=0)
    wf.nChannels = 2;
  else
    wf.nChannels = 1;
  wf.wBitsPerSample = snd_bits;
  wf.nSamplesPerSec = snd_freq;
  wf.nBlockAlign = wf.nChannels*wf.wBitsPerSample/8;
  wf.nAvgBytesPerSec = wf.nSamplesPerSec*wf.nBlockAlign;
    
  result=IDirectSound_CreateSoundBuffer(lpDS, &dsbdesc, &lpPrimaryDSB, NULL);
// proff 07/23/98: Added wf and result
  if (result == DS_OK)
    result=IDirectSoundBuffer_SetFormat(lpPrimaryDSB,&wf);
  if (result == DS_OK)
    result=IDirectSoundBuffer_Play(lpPrimaryDSB,0,0,DSBPLAY_LOOPING);
  return result;
}
开发者ID:dorienh,项目名称:smmu,代码行数:33,代码来源:i_sound.c

示例7: sizeof

IDirectSoundBuffer *DSLoad3DSoundBuffer(IDirectSound *pDS, LPCTSTR lpName)
{
    IDirectSoundBuffer *pDSB = NULL;
    DSBUFFERDESC dsBD = {0};
    BYTE *pbWaveData;
    void *pvBase;

    dsBD.dwSize = sizeof(dsBD);
    dsBD.dwFlags = DSBCAPS_STATIC | DSBCAPS_CTRL3D | DSBCAPS_CTRLVOLUME
                        | DSBCAPS_CTRLFREQUENCY | DSBCAPS_LOCSOFTWARE
                        | DSBCAPS_STICKYFOCUS;

    if (DSGetWaveResource(NULL, lpName, &dsBD.lpwfxFormat, &pbWaveData, &dsBD.dwBufferBytes))
    {
        if (SUCCEEDED(IDirectSound_CreateSoundBuffer(pDS, &dsBD, &pDSB, NULL)))
        {
            if (!DSFillSoundBuffer(pDSB, pbWaveData, dsBD.dwBufferBytes))
            {
                IDirectSoundBuffer_Release(pDSB);
                pDSB = NULL;
            }
        }
        else
        {
            pDSB = NULL;
        }
    } else if (DSGetWaveFile(NULL, lpName, &dsBD.lpwfxFormat, &pbWaveData,
                        &dsBD.dwBufferBytes, &pvBase))
    {
        if (SUCCEEDED(IDirectSound_CreateSoundBuffer(pDS, &dsBD, &pDSB, NULL)))
        {
            if (!DSFillSoundBuffer(pDSB, pbWaveData, dsBD.dwBufferBytes))
            {
                IDirectSoundBuffer_Release(pDSB);
                pDSB = NULL;
            }
        }
        else
        {
            pDSB = NULL;
        }
    UnmapViewOfFile (pvBase);
    }

    return pDSB;
}
开发者ID:fenglinnet,项目名称:ddongddongbae,代码行数:46,代码来源:Dsutil.cpp

示例8: 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

示例9: pest_open

int pest_open( HWND win ){
	HMODULE lib;
	DIRECTSOUNDCREATE dsound_create;
	WAVEFORMATEX format;
	DSBUFFERDESC desc_primary, desc_secondary;

	lib = (HMODULE)LoadLibrary("dsound.dll");
	if(lib==NULL) return FALSE;

	dsound_create = (DIRECTSOUNDCREATE)GetProcAddress(lib, "DirectSoundCreate");
	if(dsound_create==NULL) return FALSE;
	FreeLibrary(lib);

	if( dsound_create( NULL, &dsound, NULL )!= DS_OK ) return FALSE;

	if( IDirectSound_SetCooperativeLevel( dsound, win, DSSCL_EXCLUSIVE | DSSCL_PRIORITY ) != DS_OK ) return FALSE;

	memset( &desc_primary, 0, sizeof(DSBUFFERDESC) );
	desc_primary.dwSize = sizeof(DSBUFFERDESC);
	desc_primary.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_STICKYFOCUS;
	
	if(IDirectSound_CreateSoundBuffer( dsound, &desc_primary, &primary, NULL )!=DS_OK) return FALSE;

	memset( &format, 0, sizeof(WAVEFORMATEX) );
	format.wFormatTag = WAVE_FORMAT_PCM;
	format.nChannels = 2;
	format.nSamplesPerSec = 44100;
	format.nAvgBytesPerSec = 44100 * 4;
	format.nBlockAlign = 4;
	format.wBitsPerSample = 16;

	if( IDirectSoundBuffer_SetFormat( primary, &format )!= DS_OK) return FALSE;

	memset( &desc_secondary, 0, sizeof(DSBUFFERDESC) );
	desc_secondary.dwSize = sizeof(DSBUFFERDESC);
	desc_secondary.dwFlags = DSBCAPS_GLOBALFOCUS | DSBCAPS_GETCURRENTPOSITION2;
	desc_secondary.lpwfxFormat = &format;
	desc_secondary.dwBufferBytes = 2*2*BUFFER_LEN;

	if(IDirectSound_CreateSoundBuffer( dsound, &desc_secondary, &secondary, NULL )!=DS_OK) return FALSE;

	InitializeCriticalSection(&critical);

	return TRUE;
}
开发者ID:imclab,项目名称:Open-World-Domination,代码行数:45,代码来源:dsound.c

示例10: DSoundRender_CompleteConnect

static HRESULT WINAPI DSoundRender_CompleteConnect(BaseRenderer * iface, IPin * pReceivePin)
{
    DSoundRenderImpl *This = impl_from_BaseRenderer(iface);
    const AM_MEDIA_TYPE * pmt = &This->renderer.pInputPin->pin.mtCurrent;
    HRESULT hr = S_OK;
    WAVEFORMATEX *format;
    DSBUFFERDESC buf_desc;

    TRACE("(%p)->(%p)\n", This, pReceivePin);
    dump_AM_MEDIA_TYPE(pmt);

    TRACE("MajorType %s\n", debugstr_guid(&pmt->majortype));
    TRACE("SubType %s\n", debugstr_guid(&pmt->subtype));
    TRACE("Format %s\n", debugstr_guid(&pmt->formattype));
    TRACE("Size %d\n", pmt->cbFormat);

    format = (WAVEFORMATEX*)pmt->pbFormat;

    This->buf_size = format->nAvgBytesPerSec;

    memset(&buf_desc,0,sizeof(DSBUFFERDESC));
    buf_desc.dwSize = sizeof(DSBUFFERDESC);
    buf_desc.dwFlags = DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLPAN |
                       DSBCAPS_CTRLFREQUENCY | DSBCAPS_GLOBALFOCUS |
                       DSBCAPS_GETCURRENTPOSITION2;
    buf_desc.dwBufferBytes = This->buf_size;
    buf_desc.lpwfxFormat = format;
    hr = IDirectSound_CreateSoundBuffer(This->dsound, &buf_desc, &This->dsbuffer, NULL);
    This->writepos = This->buf_size;
    if (FAILED(hr))
        ERR("Can't create sound buffer (%x)\n", hr);

    if (SUCCEEDED(hr))
    {
        hr = IDirectSoundBuffer_SetVolume(This->dsbuffer, This->volume);
        if (FAILED(hr))
            ERR("Can't set volume to %d (%x)\n", This->volume, hr);

        hr = IDirectSoundBuffer_SetPan(This->dsbuffer, This->pan);
        if (FAILED(hr))
            ERR("Can't set pan to %d (%x)\n", This->pan, hr);
        hr = S_OK;
    }

    if (FAILED(hr) && hr != VFW_E_ALREADY_CONNECTED)
    {
        if (This->dsbuffer)
            IDirectSoundBuffer_Release(This->dsbuffer);
        This->dsbuffer = NULL;
    }

    return hr;
}
开发者ID:reactos,项目名称:reactos,代码行数:53,代码来源:dsoundrender.c

示例11: CreateSecondaryBuffers

/*
 * セカンダリバッファを作成し、再生位置通知を有効にする
 */
static BOOL CreateSecondaryBuffers()
{
	DSBPOSITIONNOTIFY pn[4];
	DSBUFFERDESC dsbd;
	HRESULT hRet;
	int i;

	memset(&dsbd, 0, sizeof(DSBUFFERDESC));
	dsbd.dwSize = sizeof(DSBUFFERDESC);
	dsbd.dwFlags = DSBCAPS_CTRLPOSITIONNOTIFY |	 /* 再生位置通知を利用可能にする */
				   DSBCAPS_GETCURRENTPOSITION2 | /* GetCurrentPositon()で正確な再生位置を取得可能にする */
				   DSBCAPS_GLOBALFOCUS |         /* 非アクティブでも再生する */
				   DSBCAPS_CTRLVOLUME;           /* ボリュームを設定可能にする */
	dsbd.dwBufferBytes = BUF_BYTES;
	dsbd.lpwfxFormat = &wfPrimary;

	for(i=0; i<MIXER_STREAMS; i++)
	{
		// セカンダリバッファを作成する
		hRet = IDirectSound_CreateSoundBuffer(pDS, &dsbd, &pDSBuffer[i], NULL);
		if(hRet != DS_OK)
			return FALSE;

		// 再生位置通知を利用する準備を行う
		hRet = IDirectSoundBuffer_QueryInterface(pDSBuffer[i],
												 &IID_IDirectSoundNotify,
												 (VOID**)&pDSNotify[i]);
		if(hRet != S_OK)
			return FALSE;

		hNotifyEvent[i] = CreateEvent(NULL, FALSE, FALSE, NULL);
		if(hNotifyEvent[i] == NULL)
			return FALSE;

		// 通知位置を設定する
		pn[0].dwOffset = 0;
		pn[0].hEventNotify = hNotifyEvent[i];
		pn[1].dwOffset = AREA_BYTES;
		pn[1].hEventNotify = hNotifyEvent[i];
		pn[2].dwOffset = AREA_BYTES * 2;
		pn[2].hEventNotify = hNotifyEvent[i];
		pn[3].dwOffset = AREA_BYTES * 3;
		pn[3].hEventNotify = hNotifyEvent[i];
		hRet = IDirectSoundNotify_SetNotificationPositions(pDSNotify[i],
														   4,
														   pn);
		if(hRet != DS_OK)
			return FALSE;
    }

	InitializeCriticalSection(&StreamCritical);
	return TRUE;
}
开发者ID:ktabata,项目名称:suika2,代码行数:56,代码来源:dsound.c

示例12: gst_directsound_probe_supported_formats

static GstCaps *
gst_directsound_probe_supported_formats (GstDirectSoundSink * dsoundsink,
    const GstCaps * template_caps)
{
  HRESULT hRes;
  DSBUFFERDESC descSecondary;
  WAVEFORMATEX wfx;
  GstCaps *caps;

  caps = gst_caps_copy (template_caps);

  /* 
   * Check availability of digital output by trying to create an SPDIF buffer 
   */

  /* fill the WAVEFORMATEX structure with some standard AC3 over SPDIF params */
  memset (&wfx, 0, sizeof (wfx));
  wfx.cbSize = 0;
  wfx.wFormatTag = WAVE_FORMAT_DOLBY_AC3_SPDIF;
  wfx.nChannels = 2;
  wfx.nSamplesPerSec = 48000;
  wfx.wBitsPerSample = 16;
  wfx.nBlockAlign = 4;
  wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;

  // create a secondary directsound buffer 
  memset (&descSecondary, 0, sizeof (DSBUFFERDESC));
  descSecondary.dwSize = sizeof (DSBUFFERDESC);
  descSecondary.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_GLOBALFOCUS;
  descSecondary.dwBufferBytes = 6144;
  descSecondary.lpwfxFormat = &wfx;

  hRes = IDirectSound_CreateSoundBuffer (dsoundsink->pDS, &descSecondary,
      &dsoundsink->pDSBSecondary, NULL);
  if (FAILED (hRes)) {
    GST_INFO_OBJECT (dsoundsink, "AC3 passthrough not supported "
        "(IDirectSound_CreateSoundBuffer returned: %s)\n",
        DXGetErrorString9 (hRes));
    caps =
        gst_caps_subtract (caps, gst_caps_new_simple ("audio/x-iec958", NULL));
  } else {
    GST_INFO_OBJECT (dsoundsink, "AC3 passthrough supported");
    hRes = IDirectSoundBuffer_Release (dsoundsink->pDSBSecondary);
    if (FAILED (hRes)) {
      GST_DEBUG_OBJECT (dsoundsink,
          "(IDirectSoundBuffer_Release returned: %s)\n",
          DXGetErrorString9 (hRes));
    }
  }

  return caps;
}
开发者ID:mrchapp,项目名称:gst-plugins-good,代码行数:52,代码来源:gstdirectsoundsink.c

示例13: test_block_align

static HRESULT test_block_align(LPGUID lpGuid)
{
    HRESULT rc;
    LPDIRECTSOUND dso=NULL;
    LPDIRECTSOUNDBUFFER secondary=NULL;
    DSBUFFERDESC bufdesc;
    DSBCAPS dsbcaps;
    WAVEFORMATEX wfx;
    int ref;

    /* Create the DirectSound object */
    rc=DirectSoundCreate(lpGuid,&dso,NULL);
    ok(rc==DS_OK||rc==DSERR_NODRIVER||rc==DSERR_ALLOCATED,
       "DirectSoundCreate() failed: %s\n",DXGetErrorString8(rc));
    if (rc!=DS_OK)
        return rc;

    init_format(&wfx,WAVE_FORMAT_PCM,11025,16,2);
    ZeroMemory(&bufdesc, sizeof(bufdesc));
    bufdesc.dwSize=sizeof(bufdesc);
    bufdesc.dwFlags=DSBCAPS_GETCURRENTPOSITION2;
    bufdesc.dwBufferBytes=wfx.nAvgBytesPerSec + 1;
    bufdesc.lpwfxFormat=&wfx;
    rc=IDirectSound_CreateSoundBuffer(dso,&bufdesc,&secondary,NULL);
    ok(rc==DS_OK,"IDirectSound_CreateSoundBuffer() "
       "should have returned DS_OK, returned: %s\n",
       DXGetErrorString8(rc));

    if (rc==DS_OK && secondary!=NULL) {
        ZeroMemory(&dsbcaps, sizeof(dsbcaps));
        dsbcaps.dwSize = sizeof(dsbcaps);
        rc=IDirectSoundBuffer_GetCaps(secondary,&dsbcaps);
        ok(rc==DS_OK,"IDirectSoundBuffer_GetCaps() should have returned DS_OK, "
           "returned: %s\n", DXGetErrorString8(rc));
        if (rc==DS_OK)
            ok(dsbcaps.dwBufferBytes==(wfx.nAvgBytesPerSec + wfx.nBlockAlign),
               "Buffer size not a multiple of nBlockAlign: requested %ld, "
               "got %ld, should be %ld\n", bufdesc.dwBufferBytes,
               dsbcaps.dwBufferBytes, wfx.nAvgBytesPerSec + wfx.nBlockAlign);
        ref=IDirectSoundBuffer_Release(secondary);
        ok(ref==0,"IDirectSoundBuffer_Release() secondary has %d references, "
           "should have 0\n",ref);
    }

    ref=IDirectSound_Release(dso);
    ok(ref==0,"IDirectSound_Release() has %d references, should have 0\n",ref);
    if (ref!=0)
        return DSERR_GENERIC;

    return rc;
}
开发者ID:howard5888,项目名称:wineT,代码行数:51,代码来源:dsound.c

示例14: SSInit

BOOL SSInit(HWND hWnd, int channels, unsigned flags)
{
	LPDIRECTSOUNDBUFFER lpPrimaryBuffer;
	LPDIRECTSOUND lpDS;
	DSBUFFERDESC dsbd;

	if (SSMixer.lpds) return TRUE;

//	Perform Direct Sound Initialization
	if (DirectSoundCreate(NULL, &lpDS, NULL) != DS_OK) 
		return FALSE;

	SSMixer.lpds = lpDS;

	if (IDirectSound_SetCooperativeLevel(lpDS, hWnd, DSSCL_NORMAL) != DS_OK) {
		SSDestroy();
		return FALSE;
	}

//	Start Mixer
	memset(&dsbd, 0, sizeof(DSBUFFERDESC));
	dsbd.dwSize = sizeof(DSBUFFERDESC);
	dsbd.dwFlags = DSBCAPS_PRIMARYBUFFER;
	if (IDirectSound_CreateSoundBuffer(SSMixer.lpds, &dsbd, &lpPrimaryBuffer, NULL) == DS_OK) {
		if (IDirectSoundBuffer_Play(lpPrimaryBuffer, 0, 0, DSBPLAY_LOOPING) != DS_OK) {
			IDirectSoundBuffer_Release(lpPrimaryBuffer);
			SSDestroy();
			return FALSE;
		}
		IDirectSoundBuffer_Release(lpPrimaryBuffer);
	}
	else {
		SSDestroy();
		return FALSE;
	}


//	Finish initializing SSMixer.
	SSMixer.ch_cur = 0;
	SSMixer.ch_list = (SSoundBuffer *)malloc(sizeof(SSoundBuffer)*channels);
	if (!SSMixer.ch_list) return FALSE;
	
	memset(SSMixer.ch_list, 0, sizeof(SSoundBuffer)*channels);
	
	SSMixer.ch_num = channels;

//	Determine Sound technology and volume caps
	waveOutGetVolume((HWAVEOUT)WAVE_MAPPER, (LPDWORD)&SSMixer.old_master_vol);
//	waveOutSetVolume((HWAVEOUT)WAVE_MAPPER, 0x40004000);
	return TRUE;
}
开发者ID:btb,项目名称:d2x,代码行数:51,代码来源:ds.c

示例15: m1sdr_PlayStop

void m1sdr_PlayStop(void)
{
	DSBUFFERDESC	dsbuf;
	WAVEFORMATEX	format;

	waveLogStop();

	IDirectSoundBuffer_Stop(lpSecB);
	// this is a bit cheezity-hacky
	IDirectSoundBuffer_Release(lpSecB);

	memset(&format, 0, sizeof(format));
	format.wFormatTag = WAVE_FORMAT_PCM;
	format.nChannels = 2;
	format.wBitsPerSample = 16;
	format.nSamplesPerSec = nDSoundSamRate;
	format.nBlockAlign = 4;	// stereo 16-bit
	format.cbSize = 0;
  	format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;

        memset(&dsbuf, 0, sizeof(DSBUFFERDESC));
        dsbuf.dwSize = sizeof(DSBUFFERDESC);
	// we'll take default controls for this one
        dsbuf.dwFlags = DSBCAPS_GLOBALFOCUS | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY; 
        dsbuf.dwBufferBytes = cbLoopLen;
	dsbuf.lpwfxFormat = (LPWAVEFORMATEX)&format;
	
	if (DS_OK != IDirectSound_CreateSoundBuffer(lpDS, &dsbuf, &lpSecB, NULL))
	{
    	printf("Unable to create secondary buffer\n");
		return;
	}

	// zero out the buffer
	{
		LPVOID ptr; DWORD len;

		IDirectSoundBuffer_Lock(lpSecB, 0, 0, &ptr, &len, NULL, NULL, DSBLOCK_ENTIREBUFFER);
		ZeroMemory(ptr, len);
		IDirectSoundBuffer_Unlock(lpSecB, ptr, len, 0, 0);
	}
}
开发者ID:dreiss,项目名称:M1-Android,代码行数:42,代码来源:dsnd.cpp


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