0
0

Hi,
I wanna rip a cd controlled from a GUI (select the track, start, see some feedback percentage …). To accomplish this it is nessecary that the riping process doesn’t block. I tried to use the nonblocking but this doesn’t work for me. After setting the FSOUND_Stream_SetSubStream(stream, track_num);
i always get a -2 as openstate.
Doesn’t fmod support the FSOUND_SetOutput(FSOUND_OUTPUT_NOSOUND_NONREALTIME); in comibination with NONBLOCKING stream open?
Is there possbily another solution/way?
Is my code wrong?

Any idea/help is welcome.
Kind regards
Lothar.

============ Code comes here =================
int cdrip(int track_num) {
char fnBuf[256];
char drive_letter[5] = “d:*j”;
FSOUND_STREAM *stream;
FSOUND_DSPUNIT *rawwrite_dsp;
int openstate = -1;
int retry = 100;
stream_ended = FALSE;
byteswritten = 0;

FSOUND_SetOutput(FSOUND_OUTPUT_NOSOUND_NONREALTIME);

if (!FSOUND_Init(44100, 32, 0)) {
throw_exception(“FSOUND_Init cdrip”);
return 1;
}

sprintf(fnBuf,”c:\CDDA\Track%i.wav”, track_num);
fp = fopen(fnBuf, “wb”);
if (!fp) {
throw_exception(“Couldn’t open file for writing”);
return 1;
}

fseek(fp, sizeof(WavHeader) + sizeof(FmtChunk) + sizeof(DataChunk), SEEK_SET);

rawwrite_dsp = FSOUND_DSP_Create(&DSP_RawWriteCallback, FSOUND_DSP_DEFAULTPRIORITY_USER, 0);
FSOUND_DSP_SetActive(rawwrite_dsp, TRUE);
stream = FSOUND_Stream_Open(drive_letter, FSOUND_NORMAL | FSOUND_NONBLOCKING, 0, 0);
if (!stream) {
throw_exception(“Couldn’t create CDDA stream”);
return 1;
}

FSOUND_Stream_SetEndCallback(stream, endcallback, 0);
FSOUND_Stream_SetSubStream(stream, track_num – 1);
do {
openstate = FSOUND_Stream_GetOpenState(stream);
if (openstate != 0)
Sleep(50);
} while (openstate != 0 || retry– == 0);
if (openstate != 0)
return 1;

FSOUND_Stream_Play(FSOUND_FREE, stream);
do {
FSOUND_Update();
} while (!stream_ended);

……
ready here, some cleanup etc.
…..
return 0;
}

  • You must to post comments
0
0

Check out the cddarip example – it probably does what you want to do. I don’t think FSOUND_NONBLOCKING is required in this case.

Cheers,

  • You must to post comments
0
0

Hi Andrew,

youre right with your answer when the software is running in an environment like cddarip. My environment is a bit different. I’m calling the C Code via JNI from a Java GUI application. And this call may not block as the GUI needs some feedback from the rip process (percentage etc.). BTW this works perferctly for i.e. playing a MP3 stream etc.

Does your answer mean that it isn’t possible to rip in NONBLOCKING mode?

Thanks in advance
Lothar

  • You must to post comments
0
0

The ripping process isn’t blocking in the cddarip example. It shows the percentage ripped as it’s ripping which sounds exactly like what you want to do. It’s exactly the same as playing a stream. I don’t see what’s causing the problem?

  • You must to post comments
0
0

Andrew, thanks a lot. Youre totally right.
I solved the problem by calling the FSOUND_Update function until the stream ended, by a sepearate Java thread. So everything works fine now.
Kind regards

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.