Archived

This topic is now archived and is closed to further replies.

demonrealms

DirectSound...this is just crazy

Recommended Posts

Hey, What''s up weith this error? source code:
//lock buffer

if (FAILED(lpdsbuffer->Lock(0,1000,
	(void **)&audio_ptr_1, &audio_length_1,
	(void **)&audio_ptr_2, &audio_length_2,
	DSBLOCK_ENTIREBUFFER)))
{
	//report error

	report_error( "error.txt", "Lock(audio_buffer)" );
	//exit program

	return(0);
}
This is the error:
:\prj_learn\prj_learn.cpp(276) : error C2664: ''Lock'' : cannot convert parameter 4 from ''int *'' to ''unsigned long *''
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
What''s wrong? Heres the whole Game_Init() if you need it(it''s not that long)
int Game_Init(void *parms)
{
// this function is where you do all the initialization 

// for your game


// create directsound object and test for error

if (DirectSoundCreate(NULL,&lpds,NULL)!=DD_OK)
   return(0);

// set cooperation level to normal priority

if (lpds->SetCooperativeLevel(main_window_handle,DSSCL_NORMAL)!=DS_OK)
{
	ofstream datafile001( "status.txt", ios::app );
	datafile001 << "[directx->SetCooperationLevel.status=Failed]" << endl;
	datafile001.close();
    return(0);
}
memset(&pcmwf, 0, sizeof(WAVEFORMATEX));
pcmwf.wFormatTag         = WAVE_FORMAT_PCM;
pcmwf.wBitsPerSample     = 8;
pcmwf.nChannels          = 1;
pcmwf.nSamplesPerSec     = 11025;
pcmwf.nBlockAlign        = 1;

//set to the total data per

//block, in our case 1 channel times 1 byte per sample

//so 1 byte total, if it was stero then it would be two

//if stereo and 16bit it would be four

pcmwf.nAvgBytesPerSec =
                  pcmwf.nSamplesPerSec * pcmwf.nBlockAlign;
pcmwf.wBitsPerSample  = 8; //8-bits per sample

pcmwf.cbSize          = 0; //always 0

//set up directsound buffer descrtiption

memset(&dsbd, 0, sizeof(DSBUFFERDESC));
dsbd.dwSize = sizeof(DSBUFFERDESC);
dsbd.dwFlags = DSBCAPS_CTRLDEFAULT | DSBCAPS_STATIC|
               DSBCAPS_LOCSOFTWARE;
dsbd.dwBufferBytes = 22050; //enough for 2 seconds at

                            //a sample rate of 11025

dsbd.lpwfxFormat   = &pcmwf; //the WAVEFORMATEX struct


UCHAR *audio_ptr_1,  //used to retrive buffer memory

       *audio_ptr_2;
int audio_length_1, //length of each buffer section

    audio_length_2;
//create the biffer

if(FAILED(lpds->CreateSoundBuffer(&dsbd, &lpdsbuffer, NULL)))
{
	report_error("errors.txt", "CreateSoundBuffer");
	return(0);
}
//lock buffer

if (FAILED(lpdsbuffer->Lock(0,1000,
	(void **)&audio_ptr_1, &audio_length_1,
	(void **)&audio_ptr_2, &audio_length_2,
	DSBLOCK_ENTIREBUFFER)))
{
	//report error

	report_error( "error.txt", "Lock(audio_buffer)" );
	//exit program

	return(0);
}
// return success

return(1);

} // end Game_Init

Thanks in advance, -Sathenzar

Share this post


Link to post
Share on other sites
Geez, how much simpler could this error get? The function expects a unsigned long *, you''re passing it an int *. Change it to unsigned long, and the error will go away.

Share this post


Link to post
Share on other sites