Esempio n. 1
0
/*************************************************************************************************
 * roadmap_sound_play_list()
 * Playing the sound files in the list by calling the JNI layer
 * FreeMapNativeSoundManager_PlaySoundFile utility
 */
int roadmap_sound_play_list( const RoadMapSoundList list )
{
	if ( sgInitialized )
	{
		int listSize = roadmap_sound_list_count( list );
		const char *full_name;
		int i;

		for( i = 0; i < roadmap_sound_list_count(list); i++ )
		{
			const char *name = roadmap_sound_list_get ( list, i );
			// !!!! Resources are not supported !!!!
			// RoadMapSound sound = (RoadMapSound) roadmap_res_get (RES_SOUND, RES_NOCREATE, name);

			// AGA NOTE :: TODO :: Temporary solution. All the resources are extracted now.
			// The unnecessary sounds should be cleared/not extracted (?)
             if ( (list->flags & SOUND_LIST_BUFFERS) == 0 )
             {
                 full_name = get_full_name( name );
                 // Calling the JNI layer
                 FreeMapNativeSoundManager_PlayFile( full_name );
             }
             else
             {
                /*
                 * Temporary solution - write the buffer to the file for further playing
                 * AGA
                 */
    //            FreeMapNativeSoundManager_PlayFile( roadmap_sound_list_get ( list, i ) );
             //			   FreeMapNativeSoundManager_PlayBuffer( list->buf_list[i], list->buf_list_sizes[i] );
    //            free( list->buf_list[i] );
             }
	}
	}
	// Deallocation
	if ( (list->flags & SOUND_LIST_NO_FREE) == 0x0 )
	{
		free (list);
	}
	return 0;
}
int CRoadMapNativeSound::PlayList(const RoadMapSoundList list)
{
  m_AudioPlayers.ResetAndDestroy(); //  stop playing whatever is playing now
  m_NextPlaying = 0;
  m_NumReady = 0;
  
  int listSize = roadmap_sound_list_count(list);
  m_ListSize = listSize;  //  know how much we need to play
  for (int i = 0; i < roadmap_sound_list_count(list); i++) 
  {//TODO load resource 
     const char *name = roadmap_sound_list_get (list, i);
     RoadMapSound sound =
                    (RoadMapSound) roadmap_res_get (RES_SOUND, RES_NOCREATE, name);
    if (sound) {
		PlaySound (sound);
    } else {
		char sound_filename[MAX_SOUND_NAME];
        char path_prefix[16];
        snprintf( path_prefix, sizeof(path_prefix), "sound\\%s\\", roadmap_lang_get_system_lang() );
		if( roadmap_construct_res_path(
			sound_filename,
			sizeof(sound_filename),
			name,
			".mp3",
			path_prefix ) == KErrNone )
		{
			PlayFile( sound_filename );
		}
     }
  }
  
  if ( (list->flags & SOUND_LIST_NO_FREE) == false )
  {
    free (list);
  }
  return 0;
}