Esempio n. 1
0
DataManager::DataManager():mLogged(false)
{
    curl_global_init(CURL_GLOBAL_ALL);
    mCurl = curl_easy_init();
    pLogoCurl = curl_easy_init();
    start_dl_flag = false;

    user_id = NULL;
    password =NULL;

    songs_init(SongRndList, XIAMI_MAX_RND_NUM);
    songs_init(MySongs, XIAMI_MY_SONGS_PAGE);
    songs_init(apMyAlbums, XIAMI_MY_SONGS_PAGE);
    songs_init(MyArtists, XIAMI_MY_SONGS_PAGE);
    songs_init(MyRadios, XIAMI_MY_SONGS_PAGE);

    albums_init(albums_list, XIAMI_MY_SONGS_PAGE);
    
#ifdef LYRIC_DL_SUPPORT    
    // check the download directory, 
    struct stat st;
    if(stat(prefix, &st) != 0)
    {
        int status;
        status = mkdir(prefix, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
        if(status != 0)
            printf("mkdir failed\n");
    }
    // create a thread to download the lyric and logo
    pthread_t  dl_thread;       
    pthread_create(&dl_thread,  NULL,  &(DataManager::do_dl_thread), NULL);
#endif    
 }
Esempio n. 2
0
File: songs.c Progetto: paud/d2x-xl
void PlayLevelSong( int levelnum )
{
	int songnum;
	int n_tracks;
	int bD1Song = (gameData.missions.list[gameData.missions.nCurrentMission].descent_version == 1);

	Assert( levelnum != 0 );

	if ( !gameData.songs.bInitialized )
		songs_init();
	SongsStopAll();
	nCurrentLevelSong = levelnum;
	songnum = (levelnum > 0) ? levelnum - 1 : -levelnum;
	gameStates.sound.nCurrentSong = songnum;
	if (!RBAEnabled() && gameStates.sound.bRedbookEnabled && gameOpts->sound.bUseRedbook)
		reinit_redbook();
	if (force_rb_register) {
		RBARegisterCD();			//get new track list for new CD
		force_rb_register = 0;
	}
	if (gameStates.sound.bRedbookEnabled && RBAEnabled() && (n_tracks = RBAGetNumberOfTracks()) > 1) {
		//try to play redbook
		play_redbook_track(REDBOOK_FIRST_LEVEL_TRACK + (songnum % (n_tracks-REDBOOK_FIRST_LEVEL_TRACK+1)),1);
	}
	if (! gameStates.sound.bRedbookPlaying) {			//not playing redbook, so play midi
		songnum = gameData.songs.nLevelSongs [bD1Song] ? gameData.songs.nFirstLevelSong [bD1Song] + (songnum % gameData.songs.nLevelSongs [bD1Song]) : 0;
		gameStates.sound.nCurrentSong = songnum;
			DigiPlayMidiSong( 
				gameData.songs.info [songnum].filename, 
				gameData.songs.info [songnum].melodic_bank_file, 
				gameData.songs.info [songnum].drum_bank_file, 
				1, 
				bD1Song);
	}
}
Esempio n. 3
0
File: songs.c Progetto: paud/d2x-xl
void songs_play_song( int songnum, int repeat )
{
	#ifndef SHAREWARE
	//Assert(songnum != SONG_ENDLEVEL && songnum != SONG_ENDGAME);	//not in full version
	#endif

	if ( !gameData.songs.bInitialized )
		songs_init();

	//stop any music already playing
	if (!(gameStates.sound.bRedbookEnabled ? gameConfig.nRedbookVolume : gameConfig.nMidiVolume))
		return;
	SongsStopAll();

	//do we want any of these to be redbook songs?

	if (force_rb_register) {
		RBARegisterCD();			//get new track list for new CD
		force_rb_register = 0;
	}

	gameStates.sound.nCurrentSong = songnum;

	if (songnum == SONG_TITLE)
		play_redbook_track(REDBOOK_TITLE_TRACK,0);
	else if (songnum == SONG_CREDITS)
		play_redbook_track(REDBOOK_CREDITS_TRACK,0);

	if (!gameStates.sound.bRedbookPlaying) {		//not playing redbook, so play midi
		DigiPlayMidiSong(
			gameData.songs.info[songnum].filename, gameData.songs.info[songnum].melodic_bank_file, 
			gameData.songs.info[songnum].drum_bank_file, repeat, gameData.songs.nD1Songs && (songnum >= gameData.songs.nD2Songs) );
	}
}
Esempio n. 4
0
DataManager::DataManager():mLogged(false)
{
    unsigned int i;
    curl_global_init(CURL_GLOBAL_ALL);
    mCurl = curl_easy_init();
    pLogoCurl = curl_easy_init();
    start_dl_flag = false;

    user_id = (char *) malloc(1);
    password =(char *) malloc(1);

    songs_init(SongRndList, XIAMI_MAX_RND_NUM);
    for(i=0; i<XIAMI_BILLS_NUM; i++)
    {
        songs_init(BillSongList[i], XIAMI_BILL_SONG_NUM);
    }
    for(i=0; i<XIAMI_RADIO_NUM; i++)
    {
        songs_init(RadioSongList[i], XIAMI_RADIO_SONG_NUM);
    }
    songs_init(MySongs, XIAMI_MY_SONGS_PAGE);
    for(i=0; i<XIAMI_MY_SONGS_PAGE; i++)
    {
        MyAlbums[i].logo = (char *) malloc(1);
        MyAlbums[i].title = (char *) malloc(1);
        MyAlbums[i].id = 0;
        MyAlbums[i].songs_cnt = 0;
    }
    // check the download directory,
    struct stat st;
    if(stat(prefix, &st) != 0)
    {
        int status;
        status = mkdir(prefix, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
        if(status != 0)
            printf("mkdir failed\n");
    }
    // create a thread to download the lyric and logo
    pthread_t  dl_thread;
    pthread_create(&dl_thread,  NULL,  &(DataManager::do_dl_thread), NULL);
}
Esempio n. 5
0
void songs_play_level_song( int levelnum )
{
	int songnum;

	Assert( levelnum != 0 );

	if ( !Songs_initialized ) songs_init();

	if (levelnum < 0)	
		songnum = (-levelnum) % NUM_GAME_SONGS;
	else 
		songnum = (levelnum-1) % NUM_GAME_SONGS;
	
	songnum += SONG_LEVEL_MUSIC;
	digi_play_midi_song( Songs[songnum].filename, Songs[songnum].melodic_bank_file, Songs[songnum].drum_bank_file, 1 );
}
Esempio n. 6
0
void songs_play_song( int songnum, int repeat )
{
	songs_init();

	//stop any music already playing
	
	songs_stop_all();
	
	// The endgame track is the last track...
	if (songnum < SONG_ENDGAME)
		play_redbook_track(songnum + 2,0);
	else if (songnum == SONG_ENDGAME)
		play_redbook_track(REDBOOK_ENDGAME_TRACK,0);
	else if (songnum > SONG_ENDGAME)
		play_redbook_track(songnum + 1,0);
	
	if (!Redbook_playing)		//not playing redbook, so play midi
		digi_play_midi_song( Songs[songnum].filename, Songs[songnum].melodic_bank_file, Songs[songnum].drum_bank_file, repeat );
}
Esempio n. 7
0
void songs_play_level_song( int levelnum )
{
	int songnum;
	int n_tracks;

	Assert( levelnum != 0 );

	songs_init();

	songs_stop_all();
	
	if (cGameSongsAvailable < 1)
		return;

	current_song_level = levelnum;

	if (levelnum < 0)
		songnum = (-levelnum) % cGameSongsAvailable;
	else
		songnum = (levelnum-1) % cGameSongsAvailable;

	if (!RBAEnabled() && GameCfg.SndEnableRedbook)	// need this to determine if we currently have the official CD
		reinit_redbook();

	n_tracks = RBAGetNumberOfTracks();
	
	if (RBAEnabled() && GameCfg.SndEnableRedbook) {
		
		//try to play redbook
		
		play_redbook_track(REDBOOK_FIRST_LEVEL_TRACK + (songnum % (n_tracks-REDBOOK_FIRST_LEVEL_TRACK+1)),!songs_haved1_cd());
	}
	
	if (! Redbook_playing) {			//not playing redbook, so play midi
		songnum += SONG_LEVEL_MUSIC;
		digi_play_midi_song( Songs[songnum].filename, Songs[songnum].melodic_bank_file, Songs[songnum].drum_bank_file, 1 );
	}
}
Esempio n. 8
0
void songs_play_song( int songnum, int repeat )
{
	if ( !Songs_initialized ) songs_init();
	digi_play_midi_song( Songs[songnum].filename, Songs[songnum].melodic_bank_file, Songs[songnum].drum_bank_file, repeat );
}
Esempio n. 9
0
// play track given by levelnum (depending on the music type and it's playing behaviour) or increment/decrement current track number via offset value
int songs_play_level_song( int levelnum, int offset )
{
    int songnum;

    Assert( levelnum != 0 );

    songs_init();
    if (!Songs_initialized)
        return 0;

    songnum = (levelnum>0)?(levelnum-1):(-levelnum);

    switch (GameCfg.MusicType)
    {
    case MUSIC_TYPE_BUILTIN:
    {
        if (offset)
            return Song_playing;

        Song_playing = -1;
        if ((Num_bim_songs - SONG_FIRST_LEVEL_SONG) > 0)
        {
            songnum = SONG_FIRST_LEVEL_SONG + (songnum % (Num_bim_songs - SONG_FIRST_LEVEL_SONG));
#ifdef _WIN32
            if (GameArg.SndDisableSdlMixer)
            {
                if (digi_win32_play_midi_song( BIMSongs[songnum].filename, 1 )) // NOTE: If SDL_mixer active, this will still be called in mix_play_file in case file is hmp
                {
                    Song_playing = songnum;
                }
            }
#ifdef USE_SDLMIXER
            else
#endif
#endif
#ifdef USE_SDLMIXER
            {
                if (mix_play_file(BIMSongs[songnum].filename, 1, NULL))
                {
                    Song_playing = songnum;
                }
            }
#endif
        }
        break;
    }
    case MUSIC_TYPE_REDBOOK:
    {
        int n_tracks = RBAGetNumberOfTracks();
        int tracknum;

        if (!offset)
        {
            // we have just been told to play the same as we do already -> ignore
            if (Song_playing >= SONG_FIRST_LEVEL_SONG && songnum + SONG_FIRST_LEVEL_SONG == Song_playing)
                return Song_playing;

            tracknum = REDBOOK_FIRST_LEVEL_TRACK + ((n_tracks<=REDBOOK_FIRST_LEVEL_TRACK) ? 0 : (songnum % (n_tracks-REDBOOK_FIRST_LEVEL_TRACK)));
        }
        else
        {
            tracknum = Redbook_playing+offset;
            if (tracknum < REDBOOK_FIRST_LEVEL_TRACK)
                tracknum = n_tracks - (REDBOOK_FIRST_LEVEL_TRACK - tracknum) + 1;
            else if (tracknum > n_tracks)
                tracknum = REDBOOK_FIRST_LEVEL_TRACK + (tracknum - n_tracks) - 1;
        }

        Song_playing = -1;
        if (RBAEnabled() && (tracknum <= n_tracks))
        {
            if (RBAPlayTracks(tracknum, !songs_haved1_cd()?n_tracks:tracknum, songs_haved1_cd() ? redbook_repeat_func : redbook_first_song_func))
            {
                Song_playing = songnum + SONG_FIRST_LEVEL_SONG;
                Redbook_playing = tracknum;
            }
        }
        break;
    }
#ifdef USE_SDLMIXER
    case MUSIC_TYPE_CUSTOM:
    {
        if (GameCfg.CMLevelMusicPlayOrder == MUSIC_CM_PLAYORDER_RAND)
            GameCfg.CMLevelMusicTrack[0] = d_rand() % GameCfg.CMLevelMusicTrack[1]; // simply a random selection - no check if this song has already been played. But that's how I roll!
        else if (!offset)
        {
            if (GameCfg.CMLevelMusicPlayOrder == MUSIC_CM_PLAYORDER_CONT)
            {
                static int last_songnum = -1;

                if (Song_playing >= SONG_FIRST_LEVEL_SONG)
                    return Song_playing;

                // As soon as we start a new level, go to next track
                if (last_songnum != -1 && songnum != last_songnum)
                    ((GameCfg.CMLevelMusicTrack[0]+1>=GameCfg.CMLevelMusicTrack[1])?GameCfg.CMLevelMusicTrack[0]=0:GameCfg.CMLevelMusicTrack[0]++);
                last_songnum = songnum;
            }
            else if (GameCfg.CMLevelMusicPlayOrder == MUSIC_CM_PLAYORDER_LEVEL)
                GameCfg.CMLevelMusicTrack[0] = (songnum % GameCfg.CMLevelMusicTrack[1]);
        }
        else
        {
            GameCfg.CMLevelMusicTrack[0] += offset;
            if (GameCfg.CMLevelMusicTrack[0] < 0)
                GameCfg.CMLevelMusicTrack[0] = GameCfg.CMLevelMusicTrack[1] + GameCfg.CMLevelMusicTrack[0];
            if (GameCfg.CMLevelMusicTrack[0] + 1 > GameCfg.CMLevelMusicTrack[1])
                GameCfg.CMLevelMusicTrack[0] = GameCfg.CMLevelMusicTrack[0] - GameCfg.CMLevelMusicTrack[1];
        }

        Song_playing = -1;
        if (jukebox_play())
            Song_playing = songnum + SONG_FIRST_LEVEL_SONG;

        break;
    }
#endif
    default:
        Song_playing = -1;
        break;
    }

    // If we couldn't play the song, most likely because it wasn't specified, play no music.
    if (Song_playing == -1)
        songs_stop_all();

    return Song_playing;
}
Esempio n. 10
0
int songs_play_song( int songnum, int repeat )
{
    songs_init();
    if (!Songs_initialized)
        return 0;

    switch (GameCfg.MusicType)
    {
    case MUSIC_TYPE_BUILTIN:
    {
        // EXCEPTION: If SONG_ENDLEVEL is not available, continue playing level song.
        if (Song_playing >= SONG_FIRST_LEVEL_SONG && songnum == SONG_ENDLEVEL && !PHYSFSX_exists(BIMSongs[songnum].filename, 1))
            return Song_playing;

        Song_playing = -1;
#ifdef _WIN32
        if (GameArg.SndDisableSdlMixer)
        {
            if (digi_win32_play_midi_song( BIMSongs[songnum].filename, repeat )) // NOTE: If SDL_mixer active, this will still be called in mix_play_file in case file is hmp
            {
                Song_playing = songnum;
            }
        }
        else
#endif
#ifdef USE_SDLMIXER
        {
            if (mix_play_file(BIMSongs[songnum].filename, repeat, NULL))
            {
                Song_playing = songnum;
            }
        }
#endif
        break;
    }
    case MUSIC_TYPE_REDBOOK:
    {
        int num_tracks = RBAGetNumberOfTracks();

        Song_playing = -1;
        if ((songnum < SONG_ENDGAME) && (songnum + 2 <= num_tracks))
        {
            if (RBAPlayTracks(songnum + 2, songnum + 2, repeat ? redbook_repeat_func : NULL))
            {
                Redbook_playing = songnum + 2;
                Song_playing = songnum;
            }
        }
        else if ((songnum == SONG_ENDGAME) && (REDBOOK_ENDGAME_TRACK <= num_tracks)) // The endgame track is the last track
        {
            if (RBAPlayTracks(REDBOOK_ENDGAME_TRACK, REDBOOK_ENDGAME_TRACK, repeat ? redbook_repeat_func : NULL))
            {
                Redbook_playing = REDBOOK_ENDGAME_TRACK;
                Song_playing = songnum;
            }
        }
        else if ((songnum > SONG_ENDGAME) && (songnum + 1 <= num_tracks))
        {
            if (RBAPlayTracks(songnum + 1, songnum + 1, repeat ? redbook_repeat_func : NULL))
            {
                Redbook_playing = songnum + 1;
                Song_playing = songnum;
            }
        }
        break;
    }
#ifdef USE_SDLMIXER
    case MUSIC_TYPE_CUSTOM:
    {
        // EXCEPTION: If SONG_ENDLEVEL is undefined, continue playing level song.
        if (Song_playing >= SONG_FIRST_LEVEL_SONG && songnum == SONG_ENDLEVEL && !strlen(GameCfg.CMMiscMusic[songnum]))
            return Song_playing;

        Song_playing = -1;
        if (mix_play_file(GameCfg.CMMiscMusic[songnum], repeat, NULL))
            Song_playing = songnum;
        break;
    }
#endif
    default:
        Song_playing = -1;
        break;
    }

    // If we couldn't play the song, most likely because it wasn't specified, play no music.
    if (Song_playing == -1)
        songs_stop_all();

    return Song_playing;
}