unsigned long ThreadBuscarArchivos::_ThreadBusqueda(void *pThis) { size_t i = 0; ThreadBuscarArchivos *This = reinterpret_cast<ThreadBuscarArchivos *>(pThis); This->_Mutex = CreateMutex(NULL, FALSE, TEXT("Mutex_ThreadBuscarArchivos")); // This->_Buscando = true; DWL::DWLString *TmpStr = NULL; // Inicio la VLC para el analisis DWL::DWLString PluginPath; PluginPath.sprintf(TEXT("--plugin-path=%s%s"), This->_PathApp(), PATHVLC_PLUGINS); ArgumentosVLC ArgsVLC; ArgsVLC.AgregarArgumento(This->_PathApp()); // Path de la aplicaciĆ³n ArgsVLC.AgregarArgumento(PluginPath()); // Path del directorio de plugins libvlc_instance_t *InstanciaVLC = libvlc_new(ArgsVLC.TotalArgumentos(), ArgsVLC()); // Inicio el FMOD para el analisis FMOD::System *InstanciaFMOD; FMOD_RESULT FmodErrorCode = FMOD_OK; FmodErrorCode = FMOD::System_Create(&InstanciaFMOD); // - Obtengo el path de los pluguins DWL::DWLString CodecsPath = This->_PathApp(); CodecsPath += TEXT("Plugins\\FMOD"); // - Paso el path de unicode a ascii char CodecsPathAscii[MAX_PATH + 1] = ""; WideCharToMultiByte(CP_OEMCP, WC_NO_BEST_FIT_CHARS, CodecsPath(), static_cast<int>(CodecsPath.Tam()) + 1, CodecsPathAscii, MAX_PATH + 1, NULL, NULL); FmodErrorCode = InstanciaFMOD->setPluginPath(CodecsPathAscii); // Inicio el sonido con 16 canales FmodErrorCode = InstanciaFMOD->init(16, FMOD_INIT_NORMAL, NULL); // Busco en todas las rutas for (i = 0; i < This->_PathsBuscar.size(); i++) This->_BusquedaRecursiva(This->_PathsBuscar[i].Path()); PostMessage(This->_hWndCP, MENSAJE_OBTENIENDO_DATOS_MEDIOS, static_cast<WPARAM>(This->_PathsEncontrados.size()), NULL); // Ya tengo todos los paths, ahora los escaneamos InformacionArchivoEx *Info = NULL; // libvlc_time_t TiempoTotal; // bool EsVideo; for (i = 0; i < This->_PathsEncontrados.size(); i++) { if (This->_Mutex) WaitForSingleObject(This->_Mutex, INFINITE); // This->_VentanaLog->AgregarMensaje(Log_BubaTronik, Log_Info, "Analizando :", This->_PathsEncontrados[i].Texto()); if (SendMessage(This->_hWndCP, MENSAJE_MEDIO_NO_EXISTE, reinterpret_cast<WPARAM>(This->_PathsEncontrados[i].Texto()), 0) == 1) { SOLO_DEBUG(DWL::DWLDebug::ImprimirDebug(This->_PathsEncontrados[i].Texto())); SOLO_DEBUG(DWL::DWLDebug::ImprimirDebug(TEXT("\n"))); Info = new InformacionArchivoEx; TmpStr = new DWL::DWLString(This->_PathsEncontrados[i].Texto()); PostMessage(This->_hWndCP, MENSAJE_MEDIO_ANALIZANDO, reinterpret_cast<WPARAM>(TmpStr), NULL); TMedio *TM = Info->ObtenerInfo(This->_PathsEncontrados[i].Texto(), This->_TipoArchivo, This->_Unidades, This->_PathsBuscar, InstanciaVLC, InstanciaFMOD); if (TM != NULL) PostMessage(This->_hWndCP, MENSAJE_MEDIO_ANALIZADO, reinterpret_cast<WPARAM>(TM), NULL); else PostMessage(This->_hWndCP, MENSAJE_MEDIO_INVALIDO, reinterpret_cast<WPARAM>(TM), NULL); delete Info; } if (This->_Cancelar == true) { if (This->_Mutex) ReleaseMutex(This->_Mutex); break; } if (This->_Mutex) ReleaseMutex(This->_Mutex); } // ReleaseMutex(This->_Mutex); // Termino la instancia de la VLC libvlc_release(InstanciaVLC); // Termino la instancia del FMOD InstanciaFMOD->close(); InstanciaFMOD->release(); // Cierro el mutex, y informo a la ventana del reproductor que ya se ha terminado if (This->_Mutex) CloseHandle(This->_Mutex); This->_Mutex = NULL; PostMessage(This->_hWndCP, MENSAJE_BUSCAR_ARCHIVOS_TERMINADO, NULL, NULL); // MessageBox(NULL, TEXT("Terminado"), TEXT("Terminado"), MB_OK); return 0; }
int main(int argc, char *argv[]) { FMOD::System *system = 0; FMOD::Sound *sound = 0; FMOD::Channel *channel = 0; FMOD_RESULT result; int count; bool playing = false; int key, numoutputplugins; unsigned int version; unsigned int handle; /* Create a System object and initialize. */ result = FMOD::System_Create(&system); ERRCHECK(result); result = system->getVersion(&version); ERRCHECK(result); if (version < FMOD_VERSION) { printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION); return 0; } /* Set the source directory for all of the FMOD plugins. */ #ifdef _WIN64 result = system->setPluginPath("../../api/plugins/64bit"); #else result = system->setPluginPath("../../api/plugins"); #endif ERRCHECK(result); /* Load up an extra plugin that is not normally used by FMOD. */ #ifdef _WIN64 result = system->loadPlugin("output_mp364.dll", 0, 0); #else result = system->loadPlugin("output_mp3.dll", 0, 0); #endif if (result == FMOD_ERR_FILE_NOTFOUND) { /* If it isn't in the same directory, try for the plugin directory. */ #ifdef _WIN64 result = system->loadPlugin("../plugin_dev/output_mp3/output_mp364.dll", 0, 0); #else result = system->loadPlugin("../plugin_dev/output_mp3/output_mp3.dll", 0, 0); #endif ERRCHECK(result); } /* Display plugins */ { int num; char name[256]; printf("Codec plugins\n"); printf("--------------\n"); result = system->getNumPlugins(FMOD_PLUGINTYPE_CODEC, &num); ERRCHECK(result); for (count = 0; count < num; count++) { result = system->getPluginHandle(FMOD_PLUGINTYPE_CODEC, count, &handle); ERRCHECK(result); result = system->getPluginInfo(handle, 0, name, 256, 0); ERRCHECK(result); printf("%2d - %-30s", count + 1, name); if (count % 2) { printf("\n"); } } printf("\n"); if (count % 2) { printf("\n"); } printf("DSP plugins\n"); printf("--------------\n"); result = system->getNumPlugins(FMOD_PLUGINTYPE_DSP, &num); ERRCHECK(result); for (count = 0; count < num; count++) { result = system->getPluginHandle(FMOD_PLUGINTYPE_DSP, count, &handle); ERRCHECK(result); result = system->getPluginInfo(handle, 0, name, 256, 0); ERRCHECK(result); printf("%2d - %-30s", count + 1, name); if (count % 2) { printf("\n"); } } printf("\n"); if (count % 2) { printf("\n"); } printf("Output plugins\n"); printf("--------------\n"); result = system->getNumPlugins(FMOD_PLUGINTYPE_OUTPUT, &numoutputplugins); ERRCHECK(result); for (count = 0; count < numoutputplugins; count++) { result = system->getPluginHandle(FMOD_PLUGINTYPE_OUTPUT, count, &handle); ERRCHECK(result); result = system->getPluginInfo(handle, 0, name, 256, 0); ERRCHECK(result); printf("%2d - %-30s", count + 1, name); if (count % 2) { printf("\n"); } } if (count % 2) { printf("\n"); } } /* System initialization */ printf("-----------------------------------------------------------------------\n"); // print driver names printf("Press a corresponding number for an OUTPUT PLUGIN to use or ESC to quit\n"); do { key = _getch(); } while (key != 27 && key < '1' && key > '0' + numoutputplugins); if (key == 27) { return 0; } result = system->getPluginHandle(FMOD_PLUGINTYPE_OUTPUT, key - '1', &handle); ERRCHECK(result); result = system->setOutputByPlugin(handle); ERRCHECK(result); int drivers; result = system->getNumDrivers(&drivers); ERRCHECK(result); result = system->init(32, FMOD_INIT_NORMAL, 0); ERRCHECK(result); result = system->createSound("../media/wave.mp3", FMOD_SOFTWARE | FMOD_CREATESTREAM, 0, &sound); ERRCHECK(result); printf("Press a key to play sound to output device.\n"); result = system->playSound(FMOD_CHANNEL_FREE, sound, 0, &channel); ERRCHECK(result); /* Main loop. */ do { unsigned int ms = 0; unsigned int lenms = 0; bool paused = false; int channelsplaying = 0; FMOD::Sound *currentsound = 0; system->update(); playing = false; result = channel->isPlaying(&playing); if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN)) { ERRCHECK(result); } result = channel->getPaused(&paused); if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN)) { ERRCHECK(result); } result = channel->getPosition(&ms, FMOD_TIMEUNIT_MS); if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN)) { ERRCHECK(result); } channel->getCurrentSound(¤tsound); if (currentsound) { result = currentsound->getLength(&lenms, FMOD_TIMEUNIT_MS); if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE) && (result != FMOD_ERR_CHANNEL_STOLEN)) { ERRCHECK(result); } } system->getChannelsPlaying(&channelsplaying); printf("Time %02d:%02d:%02d/%02d:%02d:%02d : %s : Channels Playing %2d\r", ms / 1000 / 60, ms / 1000 % 60, ms / 10 % 100, lenms / 1000 / 60, lenms / 1000 % 60, lenms / 10 % 100, paused ? "Paused " : playing ? "Playing" : "Stopped", channelsplaying); Sleep(5); if (_kbhit()) { key = _getch(); if (key == 27) { break; } } } while (playing); printf("\n"); /* Shut down */ result = sound->release(); ERRCHECK(result); result = system->close(); ERRCHECK(result); result = system->release(); ERRCHECK(result); return 0; }