I am writing a simple mp3 player which can play streaming songs ( using my own protocol, where simply i transfer files over tcp )
This is a part of the player code…
char* fileName = "tmp.mp3";
result = FMOD::System_Create(&f_system); // Create the main system object.
result = f_system->init(32, FMOD_INIT_NORMAL, 0); // Initialize FMOD.
result = f_system->createStream(fileName, FMOD_HARDWARE | FMOD_CREATESTREAM, 0, &f_sound);
result = f_system->playSound(FMOD_CHANNEL_FREE, f_sound, false, &f_channel);
printf("Now playing %s\n", fileName );
// user interaction...
The song plays for about 5 seconds, and stops. ( There are no buffer underflows as i am testing it out on my local machine )
This how i am simulating the file transfer
int rfd = open( "sweet child of mine.mp3", O_RDONLY );
int wfd = open( "tmp.mp3", O_CREAT | O_EXCL | O_RDWR, S_IRWXU | S_IRGRP | S_IROTH );
while( err )
err = read( rfd, buf, 65536 );
b = write( wfd, buf, err );
Any idea whats wrong with the code or the approach?
- shashank asked 9 years ago
I made the following change in the main loop…
// rest of the code... ( no code yet )
But even then the sound stops after a few seconds
I am pretty sure that there is nothing wrong with the read/writes to the
tmp.mp3 as any media player seems to play it just fine as it is being "streamed"
- shashank answered 9 years ago
Please login first to submit.