0
0

Hi, how are you.

I’m having a problem when i create a stream with NONBLOCKING flag.

My code:

[code:qxlmy9ss]FMOD_CREATESOUNDEXINFO sound_t;
memset( (void *)&sound_t, 0, sizeof(sound_t));
sound_t.cbsize = sizeof(sound_t);
sound_t.nonblockcallback = playsound;
sound_t.userdata = (void *)dsystem;

        sql_extract_data(dsystem);
        url = get_url(dsystem->dsound->id);
        rewrite_window(dsystem->main_window);

        ret = FMOD_System_CreateStream(dsystem->sound_system, url, FMOD_SOFTWARE | FMOD_MPEGSEARCH | FMOD_IGNORETAGS | FMOD_NONBLOCKING, &sound_t ,&dsystem->dsound->sound);[/code:qxlmy9ss]

[b:qxlmy9ss]playsound[/b:qxlmy9ss] is a callback that is called when createstream finishes:

[code:qxlmy9ss]FMOD_RESULT playsound(FMOD_SOUND *sound, FMOD_RESULT ret)
{
dlsystem dsystem = (dlsystem) sound_t.userdata;
printf("CALLBACK NONBLOCK\n");

ret = FMOD_System_PlaySound(dsystem->sound_system, FMOD_CHANNEL_FREE, sound, 0, &dsystem->dsound->channel);
if( ret != FMOD_OK ) {
    LOG("Playsound:", FMOD_ErrorString(ret));
}

LOG("Set playsound", 0);
return ret;

}[/code:qxlmy9ss]

Well, this works sometimes, but occasionally playsound returned this error:

[code:qxlmy9ss]Playsound: – Operation could not be performed because specified sound/DSP connection is not ready. [/code:qxlmy9ss]

I suposse that this happen because stream isn’t ready, no?
Is there any way to fix this? Maybe i do anything wrong?

Thanks a lot

  • You must to post comments
0
0

Thanks Peter for response.

I put the getopenstate call before the playsound call:

[code:5jwhg9nw]FMOD_OPENSTATE stream_state = FMOD_OPENSTATE_BUFFERING;
dlsystem dsystem = (dlsystem) sound_t.userdata;
unsigned int buffer;
FMOD_BOOL starving;
printf("CALLBACK NONBLOCK\n");

    //while( is_ready != FMOD_OK ) {
        FMOD_Sound_GetOpenState(sound, &stream_state, &buffer, &starving);
        fprintf(stdout, "Stream state:" \
                        "Buffered: %d\n" \
                        "Starving: %d\n" \
                        "State-> %d\n", buffer, starving, stream_state);


        ret = FMOD_System_PlaySound(dsystem->sound_system, FMOD_CHANNEL_FREE, sound, 0, &dsystem->dsound->channel);
        if( ret != FMOD_OK ) {
            LOG("Playsound:", FMOD_ErrorString(ret));
        }[/code:5jwhg9nw]

The enum:

[code:5jwhg9nw]typedef enum {
FMOD_OPENSTATE_READY,
FMOD_OPENSTATE_LOADING,
FMOD_OPENSTATE_ERROR,
FMOD_OPENSTATE_CONNECTING,
FMOD_OPENSTATE_BUFFERING,
FMOD_OPENSTATE_SEEKING,
FMOD_OPENSTATE_PLAYING,
FMOD_OPENSTATE_SETPOSITION,
FMOD_OPENSTATE_MAX
} FMOD_OPENSTATE;[/code:5jwhg9nw]

I suppose that it begins with value 0. (FMOD_OPENSTATE_READY = 0)

I see that when it works, GetOpenState returns "FMOD_OPENSTATE_BUFFERING" (value 4 in enum) in the FMOD_OPENSTATE var, and when it doesn’t works it returns "FMOD_OPENSTATE_ERROR"(value 2 in enum).

I’m a little confused. I thought that when it works, it should return " FMOD_OPENSTATE_READY". Is not true?

Is sufficient compare FMOD_OPENSTATE with FMOD_OPENSTATE_BUFFERING ?

Thanks

  • You must to post comments
0
0

You can poll Sound::getOpenState to determine when a sound is ready to play.

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.