0
0

Hello everyone!

I’ve got a little (hopefully ๐Ÿ˜• ) problem with my application.
I’m trying to playback an audiostream, coming from a bluetooth connection (socket stream).

I made a little work around, so I can put my audio data into fmod with custom file callbacks!

My code is:
[code:y5s0qlbz]
void *F_CALLBACKAPI myopen(const char *name) {
return fdopen(sock, "r"); //opens a connection to the bluetooth socket
}

int F_CALLBACKAPI myread() {void *buf, int size, unsigned int handle) {
filepos += size;
return fread(buf, 1, size, (FILE *) handle); //Read some data from stream
}

int F_CALLBACKAPI myseek(unsigned int handle, int pos, signed char mode) {
if (mode == SEEK_END) {
filepos = HUGE_VALUE + pos;
}
if (mode == SEEK_SET) {
filepos = pos;
}
if (mode == SEEK_CUR) {
filepos += pos;
}
return 0; // Success
}

int F_CALLBACKAPI mytell(unsigned int handle) {
return filepos;
}

.......
// init and connection stuff

stream = FSOUND_Stream_Open("x", FSOUND_NORMAL, 0, 0);
channel = FSOUND_Stream_Play(FSOUND_FREE, stream);

[/code:y5s0qlbz]

When I’m starting the application, everything looks fine – it’s reading the size of the stream, etc. But then its getting strange – The program reads 4 bytes of packages from the bluetooth stream and tries all the time (after each package read) a SEEK_SET…

So my problem is now:
– the application calls all the time SEEK_SET
– the application just reads 4 byte packages (seems to be a bit small!)
– No Audio comes out from the speakers!

Please – Who has got some ideas? I really have to get this working for a student work…

thx for your help!!!

  • You must to post comments
0
0

Hi Brett! First THX for your help!!!!! ๐Ÿ˜‰

Yes, it’s mp3 data!

I did what you suggested and I found out, that the seeking seems to be the problem, cause it doesn’t work with an local filestream as well. But I really have no idea what I made wrong. Does anybody know what could be wrong with the seeking?? Probably I have to return some ERROR_CODES sometime? (I’m always returning 0 – which means success)

Thx to everyone, who can help!

  • You must to post comments
0
0

Hi Brett,

I tried your idea and used the methods supplied with the samples – but they don’t work either! The program just blocks, cause it cannot read (seek) the end of the file which it is trying to.

I cannot believe there isn’t a way to load in data coming from a socket Input stream! It sounds so simple – maybe there is a way to let fmod know which file format it should play, so it doesnt have to seek to the end of the file first?

PLEASE HELP ME! I really have to get this work!

THX To everyone

Rantanplan

  • You must to post comments
0
0

When I’m using the methods of the example it works – but as soon as I’m trying to change the myseek method to my own it doesn’t work anymore.

Probably you can post how you would try to receive and play data over a socket connection.

Thx

Rantanplan

  • You must to post comments
0
0

Somehow I think you are misunderstanding me. Have a look at [url:2aj8vquh]http://www.fmod.org/forum/viewtopic.php?t=1839&highlight=streaming+network[/url:2aj8vquh]
This topic is pretty the same I wanna do. You are describing some technique to hack the seeking problem. I tried your suggestions, but they don’t work.

You are also talking about “custom network streams”. So how can I setup such a stream?

thx for your help

Rantanplan

  • You must to post comments
0
0

[quote="Rantanplan":2bg5md2q] I tried your suggestions, but they don’t work.
[/quote:2bg5md2q]

  • You must to post comments
0
0

Please have a look at the code I posted on the top.
This is what I tried due to your idea in the other thread. Do you think this is allright?

Everything looks fine – it’s just that fmod does a reading of 4 Bytes of the mp3 Stream all the time instead of 414 Bytes, which it does with the file read from the disk. The data coming from the network is fine – I made a little debug output to a file and could playback it, after fmod has requested and received the small pieces of data.

any ideas?

  • You must to post comments
Showing 6 results
Your Answer

Please first to submit.