Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

output_ds3.cpp

Go to the documentation of this file.
00001 #include "output_ds3.hpp"
00002 #include "debug.hpp"
00003 
00004 
00006 
00007 DS3OutputContext::DS3OutputContext()
00008 {
00009   m_PrimaryBuffer = 0;
00010 }
00011 
00013 
00014 DS3OutputContext::~DS3OutputContext()
00015 {
00016   if (m_PrimaryBuffer) {
00017     m_PrimaryBuffer->Release();
00018     m_PrimaryBuffer = 0;
00019   }
00020 }
00021 
00023 
00024 bool
00025 DS3OutputContext::CreatePrimarySoundBuffer(IDirectSound* ds)
00026 {
00027   ADR_GUARD("DS3OutputContext::CreatePrimarySoundBuffer");
00028 
00029   // create a primary sound buffer
00030   #if DIRECTSOUND_VERSION >= 0x0700
00031     DSBUFFERDESC1 dsbd;
00032   #else
00033     DSBUFFERDESC dsbd;
00034   #endif
00035 
00036   dsbd.dwSize        = sizeof(dsbd);
00037   dsbd.dwFlags       = DSBCAPS_PRIMARYBUFFER;
00038   dsbd.dwBufferBytes = 0;     // primary buffers don't specify size
00039   dsbd.dwReserved    = 0;
00040   dsbd.lpwfxFormat   = NULL;  // primary buffers use SetFormat()
00041   HRESULT rv = ds->CreateSoundBuffer(
00042     (DSBUFFERDESC*)&dsbd,
00043     &m_PrimaryBuffer,
00044     NULL);
00045   if (FAILED(rv)) {
00046     ADR_LOG("CreateSoundBuffer failed");
00047     return false;
00048   }
00049 
00050   ADR_LOG("CreateSoundBuffer succeeded");
00051 
00052   // set our maximum output format to 44100, 16, stereo
00053   // we don't really care about this
00054   WAVEFORMATEX wf;
00055   memset(&wf, 0, sizeof(wf));
00056   wf.wFormatTag = WAVE_FORMAT_PCM; 
00057   wf.nChannels = 2; 
00058   wf.nSamplesPerSec = 44100; 
00059   wf.wBitsPerSample = 16; 
00060   wf.nBlockAlign = wf.nChannels * wf.wBitsPerSample / 8;
00061   wf.nAvgBytesPerSec = wf.nSamplesPerSec * wf.nBlockAlign;
00062 
00063   rv = m_PrimaryBuffer->SetFormat(&wf); 
00064   if (FAILED(rv)) {
00065     return false;
00066   }
00067 
00068   ADR_LOG("SetFormat succeeded");
00069 
00070   return true;
00071 }
00072 

Generated at Mon Jun 10 02:55:12 2002 for audiere by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001