0
0

Hi,

There is a big problem.
I play a piece of mp3 file and use FSOUND_Stream_SetSyncCallback and FSOUND_Stream_AddSyncPoint to be notified about the end of playing piece.
The problem is that when we play a piece of mp3 for a second time – callback is not called!

Important information – I tried to set up a sync point for small area – about 1000 samples and less.

Could you please fix it and upload a 3.76 version?

And please answer the question. FSOUND_Stream_AddSyncPoint return NULL if the file is decoded by me but played by FMOD (for example GSM or ADPCM), is it correct behavior?

Best Regards,
Dmitry Yakimov,
registered user.

  • You must to post comments
0
0

you are using the wrong function use FSOUND_Stream_SetEndCallback.

  • You must to post comments
0
0

Hi again,

I’m afraid that FSOUND_Stream_SetEndCallback won’t do because I play not the whole mp3 file, but just a short piece of a file, and the and of that piece is not equal to the end of a file.

In other words, FMOD do not call callback if I play a short piece of mp3 (1000 samples and less) and if this fragment is played for a second time.

p.s. I use a wince version of FMOD.

Best Regards,
Dmitry Yakimov

  • You must to post comments
0
0

There some news:
1. It is only on wince platform
2. No matter – how big is a fragment
3. I’ve built a test project for you. It should play a fragment in a loop but on wince it plays is only once. Please, PLEASE, could you be so kind to fix this bug? :)

Use TEST_START_MS and EST_STOP_MS to set up a fragment, in samples. Use TEST_MP3_FILE to set a file.

[code:rdg33t9c]
// TestFmod.cpp : Defines the entry point for the console application.
//

include "stdafx.h"

include "..\..\Lib\fmod\fmod.h"

include <windows.h>

define TEST_MP3_FILE "1.mp3"

define TEST_START_MS 50000

define TEST_STOP_MS 50001

bool playing;

FSOUND_STREAM *fmod_stream;
int fmod_channel;

FSOUND_SYNCPOINT *playregion_endpoint;
int playregion_endpoint_pos;

void ClearRegionEndPoint()
{
if(playregion_endpoint)
FSOUND_Stream_DeleteSyncPoint(playregion_endpoint);
playregion_endpoint = NULL;
playregion_endpoint_pos = -1;
}

signed char F_CALLBACKAPI end_callback(FSOUND_STREAM *stream, void *buff, int len, int param)
{
printf("end_callback\n");
playing = false;
return true;
}

signed char F_CALLBACKAPI sync_callback(FSOUND_STREAM *stream, void *buff, int len, int param)
{
printf("sync_callback at %d\n", len);
if(len == playregion_endpoint_pos)
{
printf("it’s ours!\n");
ClearRegionEndPoint();
printf("pausing... ");
playing = true;
if(!FSOUND_SetPaused(fmod_channel, true))
{
printf("\nfailed to FSOUND_SetPaused(true)");
return -1;
}
printf("ok\n");
printf("seek to %d ms... ", TEST_START_MS);
if(!FSOUND_Stream_SetTime(fmod_stream, TEST_START_MS))
{
printf("\nfailed to FSOUND_Stream_SetTime at %d ms", TEST_START_MS);
return -1;
}
printf("ok\n");
int freq = FSOUND_GetFrequency(fmod_channel);
int to_smp = (int)(((float)TEST_STOP_MS * freq) / 1000);
printf("set sync point to sample %d (%d ms at %d Hz)... ", to_smp, TEST_STOP_MS, freq);
playregion_endpoint = FSOUND_Stream_AddSyncPoint(fmod_stream, to_smp, "");
if(!playregion_endpoint)
{
printf("\nfailed to FSOUND_Stream_AddSyncPoint");
return -1;
}
playregion_endpoint_pos = to_smp;
printf("ok\n");
printf("unpausing... ");
playing = true;
if(!FSOUND_SetPaused(fmod_channel, false))
{
printf("\nfailed to FSOUND_SetPaused(false)");
return -1;
}
printf("ok\n");
}
return true;
}

int _tmain(int argc, _TCHAR* argv[])
{
printf("init sound... ");
FSOUND_SetMixer(FSOUND_MIXER_QUALITY_AUTODETECT);
int retrycount = 0;
while (!FSOUND_Init(44100, 1, 0) && (retrycount < 10))
{
Sleep(100);
retrycount++;
}
if(retrycount >= 10)
{
printf("\nfailed to FSOUND_Init");
return -1;
}
printf("ok\n");

printf("open ‘%s’... ", TEST_MP3_FILE);
fmod_stream = FSOUND_Stream_Open(TEST_MP3_FILE, FSOUND_STEREO | FSOUND_SIGNED | FSOUND_16BITS, 0, 0);
if(!fmod_stream)
{
printf("\nfailed to FSOUND_Stream_Open(%s)", TEST_MP3_FILE);
return -1;
}
printf("ok\n");

printf("setting end callback... ");
if(!FSOUND_Stream_SetEndCallback(fmod_stream, end_callback, 0))
{
printf("\nfailed to FSOUND_Stream_SetEndCallback");
return -1;
}
printf("ok\n");

printf("playing paused... ");
fmod_channel = FSOUND_Stream_PlayEx(FSOUND_FREE, fmod_stream, NULL, true);
if(fmod_channel == -1)
{
printf("\nfailed to FSOUND_Stream_PlayEx paused");
return -1;
}
printf("ok\n");

printf("seek to %d ms... ", TEST_START_MS);
if(!FSOUND_Stream_SetTime(fmod_stream, TEST_START_MS))
{
printf("\nfailed to FSOUND_Stream_SetTime at %d ms", TEST_START_MS);
return -1;
}
printf("ok\n");

printf("set sync callback... ");
if(!FSOUND_Stream_SetSyncCallback(fmod_stream, sync_callback, 0))
{
printf("\nfailed to FSOUND_Stream_SetSyncCallback");
return -1;
}
printf("ok\n");

int freq = FSOUND_GetFrequency(fmod_channel);
int to_smp = (int)(((float)TEST_STOP_MS * freq) / 1000);

printf("set sync point to sample %d (%d ms at %d Hz)... ", to_smp, TEST_STOP_MS, freq);
playregion_endpoint = FSOUND_Stream_AddSyncPoint(fmod_stream, to_smp, "");
if(!playregion_endpoint)
{
printf("\nfailed to FSOUND_Stream_AddSyncPoint");
return -1;
}
playregion_endpoint_pos = to_smp;
printf("ok\n");

printf("unpausing... ");
playing = true;
if(!FSOUND_SetPaused(fmod_channel, false))
{
printf("\nfailed to FSOUND_SetPaused(false)");
return -1;
}
printf("ok\n");

printf("playing");
while(playing)
{
printf(".");
Sleep(10);
}
printf("STOP\n");
printf("ok\n");

/*
playregion_endpoint = FSOUND_Stream_AddSyncPoint(fmod_stream, to_smp, "");
if(!playregion_endpoint)
{
printf("failed to FSOUND_Stream_AddSyncPoint");
return -1;
}

{
                FSOUND_Stream_Close(m_fmod_stream);
        FSOUND_Stream_Stop(m_fmod_stream);
        FSOUND_Stream_Close(m_fmod_stream);
    if(ok)
        SetPosition(from_ms);
    if(ok)
        ok = FSOUND_Stream_SetSyncCallback(m_fmod_stream, sync_callback, (int)this) != false;
    if(ok)
    {
        m_playregion_endpoint = FSOUND_Stream_AddSyncPoint(m_fmod_stream, to_smp, &quot;&quot;);
        ok = m_playregion_endpoint != NULL;
    }
    if(ok)
    {
        m_playregion_endpoint_pos = to_smp;
        ok = FSOUND_SetPaused(m_fmod_channel, false) != false;
        FSOUND_Stream_SetTime(m_fmod_stream, ms);
m_total_time_ms = FSOUND_Stream_GetLengthMs(m_fmod_stream);

*/
FSOUND_Stream_Stop(fmod_stream);
FSOUND_Stream_Close(fmod_stream);
FSOUND_Close();
return 0;
}

[/code:rdg33t9c]

  • You must to post comments
0
0

Any news?

Best Regards,
Dmitry Yakimov

  • You must to post comments
0
0

Hi,

Could you confirm the bug?

Best Regards,
Dmitry Yakimov

  • You must to post comments
0
0

sorry we can’t look at this for about another week at the moment. Please write to support@fmod.org if you have urgent requests. forums posts are not put into the support priority system

  • You must to post comments
Showing 6 results
Your Answer

Please first to submit.