コード例 #1
0
int CMusikPlayer::_NetStreamStatusUpdate(MUSIKStream * pStream)
{
	int status = 0;
	CMusikSong & song = m_CurrentSong.SongCopy();
	FSOUND_Stream_Net_GetStatus((FSOUND_STREAM*)pStream->GetStreamOut()->STREAM(), &status, &m_NETSTREAM_read_percent, &m_NETSTREAM_bitrate, &m_NETSTREAM_flags);
	if(m_NETSTREAM_status != status)
	{
		m_NETSTREAM_status = status;
		switch(m_NETSTREAM_status)
		{
		case FSOUND_STREAM_NET_NOTCONNECTED:
			break;
		case FSOUND_STREAM_NET_CONNECTING:
		case FSOUND_STREAM_NET_BUFFERING:
		case FSOUND_STREAM_NET_READY:
            {
                MusikPlayerEvent ev_songchange(this,wxEVT_MUSIKPLAYER_SONG_CHANGED);
                ProcessEvent(ev_songchange);
            }
			break;
		case FSOUND_STREAM_NET_ERROR:
			wxMessageBox(_("ERROR: failed to open stream:")+ ConvA2W(FSOUND_Stream_Net_GetLastServerStatus()));
			break;

		}
	}
	if(song.MetaData.nBitrate != m_NETSTREAM_bitrate)
	{
		song.MetaData.nBitrate = m_NETSTREAM_bitrate;
		UpdateUI();
	}
	

	return status;
}
コード例 #2
0
int CMusikPlayer::_NetStreamStatusUpdate(MUSIKStream * pStream)
{
	int status = 0;
	CMusikSong & song = m_CurrentSong;
	FSOUND_Stream_Net_GetStatus((FSOUND_STREAM*)pStream->GetStreamOut()->STREAM(), &status, &m_NETSTREAM_read_percent, &m_NETSTREAM_bitrate, &m_NETSTREAM_flags);
	if(m_NETSTREAM_status != status)
	{
		m_NETSTREAM_status = status;
		switch(m_NETSTREAM_status)
		{
		case FSOUND_STREAM_NET_NOTCONNECTED:
			break;
		case FSOUND_STREAM_NET_CONNECTING:
		case FSOUND_STREAM_NET_BUFFERING:
		case FSOUND_STREAM_NET_READY:
			g_MusikFrame->m_pNowPlayingCtrl->UpdateInfo(song);
			break;
		case FSOUND_STREAM_NET_ERROR:
			wxMessageBox(_("ERROR: failed to open stream:")+ ConvA2W(FSOUND_Stream_Net_GetLastServerStatus()));
			break;

		}
	}
	if(song.MetaData.nBitrate != m_NETSTREAM_bitrate)
	{
		song.MetaData.nBitrate = m_NETSTREAM_bitrate;
		UpdateUI();
	}
	

	return status;
}
コード例 #3
0
MUSIKEngine::Error FMODStreamOut::GetNetStatus(MUSIKEngine::NetStatus *pStatus,int * pnPercentRead,int * pnBitrate)
{
    unsigned int flags = 0;
    int status = 0;
    MUSIKEngine::Error err =  StreamPointer && FSOUND_Stream_Net_GetStatus(StreamPointer,&status,pnPercentRead,pnBitrate,&flags) ? MUSIKEngine::errSuccess: MUSIKEngine::errUnknown;
    switch(status)
    {
    case FSOUND_STREAM_NET_NOTCONNECTED:
        *pStatus = MUSIKEngine::NETSTATUS_NOTCONNECTED;
        break;
    case FSOUND_STREAM_NET_CONNECTING:
        *pStatus = MUSIKEngine::NETSTATUS_CONNECTING;
        break;
    case FSOUND_STREAM_NET_BUFFERING:
        *pStatus = MUSIKEngine::NETSTATUS_BUFFERING;
        break;
    case FSOUND_STREAM_NET_READY:
        *pStatus = MUSIKEngine::NETSTATUS_READY;
        break;
    case FSOUND_STREAM_NET_ERROR:
    default:
        *pStatus = MUSIKEngine::NETSTATUS_ERROR;
        break;
    }
    return err;
}
コード例 #4
0
bool LLAudioStreamFMOD::stopStream()
{
	if (mInternetStream)
	{
		int read_percent = 0;
		int status = 0;
		int bitrate = 0;
		unsigned int flags = 0x0;
		FSOUND_Stream_Net_GetStatus(mInternetStream, &status, &read_percent, &bitrate, &flags);

		bool close = true;
		switch (status)
		{
		case FSOUND_STREAM_NET_CONNECTING:
			close = false;
			break;
		case FSOUND_STREAM_NET_NOTCONNECTED:
		case FSOUND_STREAM_NET_BUFFERING:
		case FSOUND_STREAM_NET_READY:
		case FSOUND_STREAM_NET_ERROR:
		default:
			close = true;
		}

		if (close)
		{
			FSOUND_Stream_Close(mInternetStream);
			mInternetStream = NULL;
			return true;
		}
		else
		{
			return false;
		}
	}
	else
	{
		return true;
	}
}
コード例 #5
0
ファイル: Main.cpp プロジェクト: samiam123/Voodoo
/*
[
    [DESCRIPTION]

    [PARAMETERS]
 
    [RETURN_VALUE]

    [REMARKS]

    [SEE_ALSO]
]
*/
int main(int argc, char *argv[])
{
    FSOUND_STREAM *stream;
    int read_percent = 0, i, driver = 0, channel = -1, status = 0, openstate, bitrate;
    unsigned int flags;
    char s[256] = "";
    char key;


    if (FSOUND_GetVersion() < FMOD_VERSION)
    {
        printf("Error : You are using the wrong DLL version!  You should be using FMOD %.02f\n", FMOD_VERSION);
        return 1;
    }

    if ((argc < 2) || (strnicmp(argv[1], "http:", 5)))
    {
        printf("-------------------------------------------------------------\n");
        printf("FMOD netstream example.\n");
        printf("Copyright (c) Firelight Technologies Pty, Ltd, 1999-2004.\n");
        printf("-------------------------------------------------------------\n");
        printf("Syntax:  netstream <url>\n");
        printf("Example: netstream http://www.fmod.org/stream.mp3\n\n");
        return 1;
    }

#if defined(WIN32) || defined(_WIN64) || defined(__CYGWIN32__) || defined(__WATCOMC__)
    FSOUND_SetOutput(FSOUND_OUTPUT_DSOUND);
#elif defined(__linux__)
    FSOUND_SetOutput(FSOUND_OUTPUT_OSS);
#endif

    // ==========================================================================================
    // SELECT DRIVER
    // ==========================================================================================
    printf("---------------------------------------------------------\n");    
    switch (FSOUND_GetOutput())
    {
        case FSOUND_OUTPUT_NOSOUND:    printf("NoSound");                    break;
        case FSOUND_OUTPUT_WINMM:      printf("Windows Multimedia Waveout"); break;
        case FSOUND_OUTPUT_DSOUND:     printf("Direct Sound");               break;
        case FSOUND_OUTPUT_A3D:        printf("A3D");                        break;
        case FSOUND_OUTPUT_OSS:        printf("Open Sound System");          break;
        case FSOUND_OUTPUT_ESD:        printf("Enlightenment Sound Daemon"); break;
        case FSOUND_OUTPUT_ALSA:       printf("ALSA");                       break;
    };
    printf(" Driver list\n");    
    printf("---------------------------------------------------------\n");    

    for (i=0; i < FSOUND_GetNumDrivers(); i++) 
    {
        printf("%d - %s\n", i+1, FSOUND_GetDriverName(i));
    }
    printf("---------------------------------------------------------\n");
    printf("Press a corresponding number or ESC to quit\n");

    do
    {
        key = getch();
        if (key == 27) exit(0);

        driver = key - '1';
    } while (driver < 0 || driver >= FSOUND_GetNumDrivers());

    FSOUND_SetDriver(driver);

    // ==========================================================================================
    // INITIALIZE
    // ==========================================================================================
    if (!FSOUND_Init(44100, 32, 0))
    {
        printf("Error!\n");
        printf("%s\n", FMOD_ErrorString(FSOUND_GetError()));
        FSOUND_Close();
        return 1;
    }

    /*
        Internet streams can work with a much smaller stream buffer than normal streams because they
        use another level of buffering on top of the stream buffer.
    */
    FSOUND_Stream_SetBufferSize(100);

    /*
        Here's where we set the size of the network buffer and some buffering parameters.
        In this case we want a network buffer of 64k, we want it to prebuffer 60% of that when we first
        connect, and we want it to rebuffer 80% of that whenever we encounter a buffer underrun.
    */
    FSOUND_Stream_Net_SetBufferProperties(64000, 60, 80);

    /*
        Open the stream using FSOUND_NONBLOCKING because the connect/buffer process might take a long time
    */
    stream = FSOUND_Stream_Open(argv[1], FSOUND_NORMAL | FSOUND_NONBLOCKING, 0, 0);
    if (!stream)
    {
        printf("Error!\n");
        printf("%s\n", FMOD_ErrorString(FSOUND_GetError()));
        FSOUND_Close();
        return 1;
    }

    printf("\nPress ESC to quit...\n\n");
  
    key = 0;
    do
    {
        if (kbhit())
        {
            key = getch();
        }

        /*
            Play the stream if it's not already playing
        */
        if (channel < 0)
        {
            channel = FSOUND_Stream_PlayEx(FSOUND_FREE, stream, NULL, TRUE);
            FSOUND_SetPaused(channel, FALSE);

            if (channel != -1)
            {
                FSOUND_Stream_Net_SetMetadataCallback(stream, metacallback, 0);
            }
        }

        openstate = FSOUND_Stream_GetOpenState(stream);
        if ((openstate == -1) || (openstate == -3))
        {
            printf("\nERROR: failed to open stream!\n");
            printf("SERVER: %s\n", FSOUND_Stream_Net_GetLastServerStatus());
            break;
        }

        FSOUND_Stream_Net_GetStatus(stream, &status, &read_percent, &bitrate, &flags);

        /*
            Show how much of the net buffer is used and what the status is
        */
        if (metanum)
        {
            printf("%s - %s\n", artist, title);
            metanum = 0;
        }
        s[0] = 0;
        strncat(s, bar, (read_percent >> 1) + (read_percent & 1));
        strncat(s, nobar, (100 - read_percent) >> 1);
        printf("|%s| %d%%  %s\r", s, read_percent, status_str[status]);

        Sleep(16);
    
    } while (key != 27);

    printf("\n");

    FSOUND_Stream_Close(stream);
    FSOUND_Close();

    return 0;
}