0
0

Hi,

I’m trying to make use of the File Callbacks and have become confused by what I’m seeing happen. I have read the documentation and searched the forum and have made an attempt to respect the warnings and also attempted to implement the seek operations properly*. However, I am not an expert in the c++ world and may have done things wrong. I have been working with FMOD for sometime now and have moved from basic file operations to user streams and now to this. Essentially I am replacing the file with a logical playlist object. This object determines which data from out of numerous fragments of audio files is to be read next. The callbacks attempt to work with this object.

Any help is greatly appreciated.

the gist of how I’ve implemented the callbacks is as follows…

[b:3qtqbc4d]fmod init[/b:3qtqbc4d]
-FSOUND_File_SetCallbacks(fsound_open,fsound_close,fsound_read,fsound_seek,fsound_tell);
-FSOUND_Init(44100,32,0);

-F_CALLBACKAPI is used in each callback declaration

[b:3qtqbc4d]play function[/b:3qtqbc4d]
stream = FSOUND_Stream_Open((char *) playlist, FSOUND_NORMAL,position,0);
channel = FSOUND_Stream_PlayEx(FSOUND_FREE, stream, NULL, true);
FSOUND_SetPan(channel,balance);
FSOUND_SetVolume(channel, volume);
FSOUND_SetPaused(FSOUND_ALL, false);

[b:3qtqbc4d]open_callback[/b:3qtqbc4d]
-init object
-store length
-return object handle cast as unsigned int* (as per doc)

[b:3qtqbc4d]read_callback[/b:3qtqbc4d]
-get "size" amount of data
-return amount retrieved

[b:3qtqbc4d]seek_callback[/b:3qtqbc4d]
-adjust position relative to mode
-SET: position is off beginning
-CUR: position is off current position
-END: position is off end position
-always return 0 (*I’m not handling invalid seek operations, maybe that’s the problem???? although from the logs I don’t think any seek attempts that I would consider invalid (beyond 0 or end of file I guess???)

[b:3qtqbc4d]tell_callback[/b:3qtqbc4d]
-return current position

[b:3qtqbc4d]close_callback[/b:3qtqbc4d]
-nothing (at the moment)

the basic logging below shows the callbacks in action. I’m not sure about much of what it’s doing at the beginning. Notably though, I see that it eventually starts to increment the position by 1 byte while consistently reading 4 bytes. This behaviour carries on at least until ~1000 reads which takes quite some time. All throughout this time, I receive no audio output.

[b:3qtqbc4d]Log[/b:3qtqbc4d]
opened playlist
seek END: 0 (<mode>: <offset>)
tell: 386321
seek SET: 0
seek SET: 0
seek END: -128
read: 3
seek END: -10
read: 3
seek SET: 0
read: 16
seek SET: 0
tell: 0
seek SET: 0
seek SET: 0
read: 24
seek SET: 0
tell: 0
read: 12
seek SET: 0
tell: 0
read: 8
read: 4
seek SET: 0
read: 4
seek SET: 0
tell: 0
read: 12
seek END: 0
tell: 386321
seek SET: 0
read: 4
seek SET: 1
read: 4
seek SET: 2
read: 4
seek SET: 3
read: 4
seek SET: 4

  • You must to post comments
0
0

Problem solved. :)

FYI for anyone new…

The problem:
FMOD was looking for a file format to read but I was only providing RAW data. In order to use RAW data I needed to specify "FSOUND_LOADRAW" when opening the stream. It stops FMOD from expecting the embedded audio format description in the "file". This flag is not applicable to the user stream callback (which I was using previous to this).

[quote:3di1js5n]stream = FSOUND_Stream_Open((char *) playlist, FSOUND_NORMAL,position,0); [/quote:3di1js5n]

should include the flag "FSOUND_LOADRAW"

stream = FSOUND_Stream_Open((char *) playlist, FSOUND_NORMAL | [b:3di1js5n]FSOUND_LOADRAW[/b:3di1js5n],position,0);

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.