Click here to Skip to main content
15,912,977 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: zip format Pin
Todd Smith11-Oct-02 11:37
Todd Smith11-Oct-02 11:37 
Generalmfc42u Pin
ns11-Oct-02 2:24
ns11-Oct-02 2:24 
GeneralRe: mfc42u Pin
includeh1011-Oct-02 2:34
includeh1011-Oct-02 2:34 
GeneralRe: mfc42u Pin
ns11-Oct-02 2:43
ns11-Oct-02 2:43 
GeneralRe: mfc42u Pin
Maximilien11-Oct-02 3:25
Maximilien11-Oct-02 3:25 
GeneralA dialog box related question Pin
ShahShehpori11-Oct-02 2:05
sussShahShehpori11-Oct-02 2:05 
GeneralRe: A dialog box related question Pin
Chris Hambleton11-Oct-02 2:30
Chris Hambleton11-Oct-02 2:30 
GeneralDirectSound question Pin
pankajdaga11-Oct-02 1:37
pankajdaga11-Oct-02 1:37 
Hi,

I was going through the DirectSound samples that come with DirectX SDK. In the file dsutil.cpp I came across the following function:

//--------------------------------------------------------------------------
// Name: CSoundManager::SetPrimaryBufferFormat()
// Desc: Set primary buffer to a specified format
// For example, to set the primary buffer format to 22kHz stereo, 16-bit
// then: dwPrimaryChannels = 2
// dwPrimaryFreq = 22050,
// dwPrimaryBitRate = 16
//--------------------------------------------------------------------------
HRESULT CSoundManager::SetPrimaryBufferFormat( DWORD dwPrimaryChannels,
DWORD dwPrimaryFreq,
DWORD dwPrimaryBitRate )
{
HRESULT hr;
LPDIRECTSOUNDBUFFER pDSBPrimary = NULL;

if( m_pDS == NULL )
return CO_E_NOTINITIALIZED;

// Get the primary buffer
DSBUFFERDESC dsbd;
ZeroMemory( &dsbd, sizeof(DSBUFFERDESC) );
dsbd.dwSize = sizeof(DSBUFFERDESC);
dsbd.dwFlags = DSBCAPS_PRIMARYBUFFER;
dsbd.dwBufferBytes = 0;
dsbd.lpwfxFormat = NULL;

if( FAILED( hr = m_pDS->CreateSoundBuffer( &dsbd, &pDSBPrimary, NULL ) ) )
return DXTRACE_ERR( TEXT("CreateSoundBuffer"), hr );

WAVEFORMATEX wfx;
ZeroMemory( &wfx, sizeof(WAVEFORMATEX) );
wfx.wFormatTag = WAVE_FORMAT_PCM;
wfx.nChannels = (WORD) dwPrimaryChannels;
wfx.nSamplesPerSec = dwPrimaryFreq;
wfx.wBitsPerSample = (WORD) dwPrimaryBitRate;
wfx.nBlockAlign = (WORD) (wfx.wBitsPerSample / 8 * wfx.nChannels);
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;

if( FAILED( hr = pDSBPrimary->SetFormat(&wfx) ) )
return DXTRACE_ERR( TEXT("SetFormat"), hr );

SAFE_RELEASE( pDSBPrimary );

return S_OK;
}

This is called after calling DirectSoundCreate8() and setting the CooperationLevel. Apparantly, this sets the format of the primary buffer. The question that I have is why is the primary buffer released after setting the format? Should we not keep a reference to the primary buffer? Or maybe I am not understanding something here.

Thanks for any help you might be able to provide.

Pankaj

Without struggle, there is no progress
GeneralRe: DirectSound question Pin
pankajdaga11-Oct-02 3:11
pankajdaga11-Oct-02 3:11 
GeneralAnother Problem DialogBox Pin
suresh_sathya11-Oct-02 1:31
suresh_sathya11-Oct-02 1:31 
GeneralRe: Another Problem DialogBox Pin
Rickard Andersson2011-Oct-02 1:57
Rickard Andersson2011-Oct-02 1:57 
GeneralRe: Another Problem DialogBox Pin
Jon Hulatt11-Oct-02 3:48
Jon Hulatt11-Oct-02 3:48 
GeneralMicrosoft RAS server Pin
_Yarrr_11-Oct-02 0:51
_Yarrr_11-Oct-02 0:51 
GeneralRe: Microsoft RAS server Pin
jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj11-Oct-02 5:01
jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj11-Oct-02 5:01 
GeneralResources in EXE Pin
candan11-Oct-02 0:09
professionalcandan11-Oct-02 0:09 
GeneralRe: Resources in EXE Pin
Pavel Klocek11-Oct-02 0:55
Pavel Klocek11-Oct-02 0:55 
GeneralRe: Resources in EXE Pin
candan13-Oct-02 14:31
professionalcandan13-Oct-02 14:31 
GeneralRe: Resources in EXE Pin
Gary R. Wheeler11-Oct-02 16:26
Gary R. Wheeler11-Oct-02 16:26 
Generalstatic member in dll Pin
Kainy11-Oct-02 0:05
Kainy11-Oct-02 0:05 
GeneralRe: static member in dll Pin
Stephane Rodriguez.11-Oct-02 0:19
Stephane Rodriguez.11-Oct-02 0:19 
GeneralRe: static member in dll Pin
Paul M Watt11-Oct-02 5:54
mentorPaul M Watt11-Oct-02 5:54 
GeneralDialog box Pin
suresh_sathya10-Oct-02 23:50
suresh_sathya10-Oct-02 23:50 
GeneralRe: Dialog box Pin
Rickard Andersson2010-Oct-02 23:59
Rickard Andersson2010-Oct-02 23:59 
GeneralRe: Dialog box Pin
suresh_sathya11-Oct-02 0:24
suresh_sathya11-Oct-02 0:24 
GeneralRe: Dialog box Pin
Jon Hulatt11-Oct-02 0:56
Jon Hulatt11-Oct-02 0:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.