0
0

Could somebody PLEASE stop me from going out of my mind? I still cannot get the file callback routines to work on wince (ipaq 3630 running PPC2002, and FMOD 3.7). Below is the entire code stub, it’s just a modified version of the stream2 sample program that comes with the FMOD download, and should compile if dumped into that project. The endcallback is called when the song is over, but no matter what I do the default file handling routines are always called.

I can’t see where the problems is, and would REALLY appreciate some help

thanks

julian

[code:7cuo18zx]//===============================================================================================
// Modified version of STREAM2 FMOD example program
//
//===============================================================================================

include <windows.h>

include <commctrl.h>

include "resource.h"

include "../common/common.h"

include "../../api/inc/fmod.h"

include "../../api/inc/fmod_errors.h"

define ID_EXIT 0x8801

define ID_STOP 0x8802

TCHAR szAppName[] = L"STREAM2";
TCHAR szAppTitle[] = L"FMOD – modified stream2";

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

FSOUND_STREAM *stream;

char s5[256];
char s6[256];
char s7[256];

unsigned int __cdecl myopen(const char *name)
{
sprintf(s6, "using CUSTOM routines");
return (unsigned int)fopen(name, "rb");
}

void __cdecl myclose(unsigned int handle)
{
fclose((FILE *)handle);
}

int __cdecl myread(void *buffer, int size, unsigned int handle)
{
return fread(buffer, 1, size, (FILE *)handle);
}

int __cdecl myseek(unsigned int handle, int pos, signed char mode)
{
return fseek((FILE *)handle, pos, mode);
}

int __cdecl mytell(unsigned int handle)
{
return ftell((FILE *)handle);
}

signed char __cdecl endcallback(FSOUND_STREAM *stream, void *buff, int len, int param)
{
// end of stream callback doesnt have a ‘buff’ value, if it doesnt it could be a synch point.
if (buff)
{
sprintf(s5, "endcallback = buff");
}
else
{
sprintf(s5, "endcallback = not-buff");
}

return TRUE;

}

int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
MSG msg;

hInst = hInstance;

if (!Common_InitInstance(nCmdShow))
{
    return FALSE;
}

while (GetMessage(&amp;msg, NULL, 0, 0)) 
{
    TranslateMessage(&amp;msg);
    DispatchMessage(&amp;msg);
}

return msg.wParam;

}

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
static int text_y = 0;
int retrycount = 0;
BOOL flag = FALSE;

switch (message) 
{
    case WM_CREATE :
    {
        Common_WM_CREATE(hWnd);

        sprintf(s5, &quot;endcallback = not_called&quot;);
        sprintf(s6, &quot;using default routines&quot;);

        // set file callbacks
        FSOUND_File_SetCallbacks(myopen, myclose, myread, myseek, mytell);

        while (!FSOUND_Init(22050, 48, FSOUND_INIT_GLOBALFOCUS) &amp;&amp; retrycount &lt; 10)
        {
            Sleep(100);
            retrycount++;
        }

        if (retrycount == 10)
        {
            Common_DisplayError();
            SendMessage(hWnd, WM_CLOSE, 0, 0);
            return 0;
        }
        else
        {

            stream = FSOUND_Stream_Open(&quot;\\My Documents\\frog.mp3&quot;, 0, 0, 0); 

            flag = FSOUND_Stream_SetEndCallback(stream,endcallback,0); 

            if (flag)
                sprintf(s7, &quot;set endcallback OK&quot;);


            // PLAY STREAM
            if (FSOUND_Stream_Play(FSOUND_FREE, stream) == -1)
            {
                Common_DisplayError();
                SendMessage(hWnd, WM_CLOSE, 0, 0);
                return 0;
            }
        }

        int y = 1;
        int bh = Common_GetButtonHeight(hWnd) + 1;
        Common_CreateButton(hWnd, L&quot;Exit&quot;, 0, y, -1, -1, ID_EXIT);
        Common_CreateButton(hWnd, L&quot;Stop&quot;, 120, 0, -1, -1, ID_STOP);
        text_y = y + (bh * 2);

        break;
    }

    case WM_COMMAND :
    {
        wmId    = LOWORD(wParam); 
        wmEvent = HIWORD(wParam); 

        switch (wmId)
        {
            case IDM_HELP_ABOUT :
                Common_About(hWnd);
                break;

            case ID_STOP :
                FSOUND_Stream_Stop(stream);
                break;

            case ID_EXIT :
            case IDM_FILE_EXIT :
                DestroyWindow(hWnd);
                break;

            default:
               return DefWindowProc(hWnd, message, wParam, lParam);
        }
        break;
    }

    case WM_TIMER :
    {
        Common_WM_TIMER(hWnd);
        break;
    }

    case WM_PAINT :
    {
        RECT rt;
        HDC hdc;
        PAINTSTRUCT ps;

        hdc = BeginPaint(hWnd, &amp;ps);
        GetClientRect(hWnd, &amp;rt);

        Common_SetTextY(text_y);
        Common_Printf(hdc, &amp;rt, s5);
        Common_Printf(hdc, &amp;rt, s6);
        Common_Printf(hdc, &amp;rt, s7);

        EndPaint(hWnd, &amp;ps);
        break;
    }

    case WM_CLOSE:
    case WM_DESTROY:
    {
        FSOUND_Stream_Close(stream);
        FSOUND_Close();

        Common_WM_CLOSE(hWnd);
        break;
    }
    default:
    {
        return DefWindowProc(hWnd, message, wParam, lParam);
    }

}
return 0;
}
[/code:7cuo18zx]

  • You must to post comments
0
0

in the spirit of community mindedness and all :)

i downloaded FMOD 3.71 and all is well. I believe the problem was a mis-match between the version of the DLL on the device, and that which it was being compiled for.

Now the example as coded above works perfectly should anybody be looking for a sample of custom file callbacks working on CE.

julian

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.