BurnFreestyleCD( ) is not working

vbimport

#1

Hi,

I am using Nero 6.3 version. I am using VC++ as the client to communicate with NEROCOM. I am able to create a Audio Disc but I am not able to create a Data disc. Please let me know the solution if you know. I am using BurnFreestyleCD () to create Data Disc. Here are the log messages…

Reading Directories
Creating Directories
Checking Discs
Writing to cache
caching of files started
caching of files completed
writing to Disc
Burn progress started @ 4x 600 kb/s
Writing tracks
Writing Lead in and Lead out
Write Error
could not perform End track

I came to know “Write Error” is posted when there is a mismatch in the Media type. But i am able to create a Data disc using Nero Application ( which we get when we purchase the software). So there might be some other problem in the code which i have written. Please see the code…

HRESULT CEngineIntFace::Burn_Data()
{

HRESULT	hr;
INeroFreestyleTrack *IFreeTrack;
INeroFreestyleTracks *IFreeTrks;
INeroFileSystemDescContainer *IFileDescCont;

INeroFiles *Ifls;	
BSTR bstrname=SysAllocString(L"asd");	
long res;
long speed;
CString sDriveName;
long val;

// Getting the Drives....has to be removed later coz we have already have GetDrives()
//	if(SUCCEEDED(hr))
{
	//	BSTR ArtistName;
	BSTR FileName = SysAllocString(OLESTR("E:\\xx.MP3"));
	hr = INero->GetDrives(NERO_MEDIA_CDR,&Idrives);
	Idrives->get_Count(&res);
	
	for(int i=0;i<res-1;i++)
	{
		Idrives->Item(i,&Idrv);
		Idrv->get_DeviceName(&bstrname);
		//
		Idrv->get_AvailableSpeeds(NERO_ACCESSTYPE_READ,NERO_MEDIA_CDRW,&Ispeeds);
		
		Idrv->get_ReadSpeeds(&Ispeeds);
		Ispeeds->get_Count(&val);
		Ispeeds->get_BaseSpeedKBs(&speed);
		
		sDriveName=(CString)bstrname;
		
	}
	
	// For Burning
	
	hr = CoCreateInstance( CLSID_NeroFolder, NULL, CLSCTX_INPROC_SERVER,
		IID_INeroFolder, (void**) &Ifold);
	
	if(!SUCCEEDED(hr))
	{
		return hr;
	}
	
	hr = CoCreateInstance( CLSID_NeroISOTrack, NULL, CLSCTX_INPROC_SERVER,
		IID_INeroISOTrack, (void**) &Itrk);

	hr = CoCreateInstance( CLSID_NeroFreestyleTrack,NULL,CLSCTX_INPROC_SERVER,
		IID_INeroFreestyleTrack, (void**) &IFreeTrack);

	hr = CoCreateInstance( CLSID_NeroFileSystemDescContainer,NULL,CLSCTX_INPROC_SERVER,
		IID_INeroFileSystemDescContainer, (void**) &IFileDescCont);
	
	hr = CoCreateInstance( CLSID_NeroFreestyleTracks,NULL,CLSCTX_INPROC_SERVER,
		IID_INeroFreestyleTracks, (void**) &IFreeTrks);
	
	if(!SUCCEEDED(hr))
	{

// return hr;
}

	hr = CoCreateInstance( CLSID_NeroFile, NULL, CLSCTX_INPROC_SERVER,
		IID_INeroFile, (void**) &Ifile);
	
	
	if(SUCCEEDED(hr))
	{	
		IFileDescCont->put_BurnOptions(NERO_BURN_OPTION_USE_JOLIET);
		IFreeTrack->put_Title(L"DataCD");
		IFreeTrack->put_Artist(L"Ashok");
		IFreeTrack->put_TrackType(NERO_FREESTYLE_TRACK_MODE1);
		IFreeTrks->Add(IFreeTrack);
		IFreeTrack->put_Filename(L"E:\\xx.txt");

		Ifile->put_SourceFilePath(L"E:\\xx.txt");
		Ifile->put_Name(L"xx.txt");

		hr = Itrk->put_Name(L"TestTrack");
		Itrk->put_RootFolder(Ifold);
	//	IFreeTrack->put_SourceType(1);

		Ifold->get_Files(&Ifls);
		Ifls->Add(Ifile);
		Ifls->get_Count(&res);
					
		
		pSink = new CSinkNeroDriveEvents();
		
		if ( NULL == pSink )
		{
			return 0 ;
		}
		
		pSink->AdviseSink(Idrv);

		hr = Idrv->BurnFreestyleCD(IFileDescCont,L"Pop Star",L"Title",0,Itrk,IFreeTrks,NULL,NERO_BURN_FLAG_WRITE,8,NERO_MEDIA_CD);
		Sleep(2000);

	//	m_INero->get_ErrorLog(&bstrname);
	//	CString ash = (CString)bstrname;
		
		Ifold->Release();
		Ifile->Release();
		Itrk->Release();	
		
	}
}

	
return S_OK;

}


#2

Could you please first try fixing all the put_xxx methods by passing them valid BSTRs instead of plain wide char strings? See if that changes anything.

Other than that, you have 4 consecutive CoCreateInstances and only one check for HRESULT. This has nothing to do with your error but it is advised that you use a proper error checking. Also, using some sort of smart pointers would help a lot, both improving readability as well as preventing hard-to-find interface reference counting errors.


#3

Dear Alex,

Thanx for your reply. As you said I have used BSTRs also but the result is the same and I have checked for all HRESULTs it is returning TRUE.

Thanks in advance,
Ashok


#4

Hi,

If I put Itrk->put_BurnOptions( NERO_BURN_OPTION_CREATE_ISO_FS) it does not give any “write error”. The log message says “Burn process is successful”. But the disc is empty when I open it.