408 lines
14 KiB
C++
408 lines
14 KiB
C++
|
////////////////////////////////////////////////////////////////////////////////
|
|||
|
// Plainamp, Open source Winamp core
|
|||
|
//
|
|||
|
// Copyright <20> 2005 Sebastian Pipping <webmaster@hartwork.org>
|
|||
|
//
|
|||
|
// --> http://www.hartwork.org
|
|||
|
//
|
|||
|
// This source code is released under the GNU General Public License (GPL).
|
|||
|
// See GPL.txt for details. Any non-GPL usage is strictly forbidden.
|
|||
|
////////////////////////////////////////////////////////////////////////////////
|
|||
|
|
|||
|
|
|||
|
|
|||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
|||
|
// Usage instructions
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
// =======================================================================================
|
|||
|
// Plugins
|
|||
|
// ---------------------------------------------------------------------------------------
|
|||
|
// Plainamp setup > The output plugin must be manually loaded and activated the first time it's used.
|
|||
|
// After that the ini saves OutputPluginActive___out_wave_gpl.dll=1. Input plugins are automatically
|
|||
|
// found, loaded and activated.
|
|||
|
// =======================================================================================
|
|||
|
|
|||
|
|
|||
|
// =======================================================================================
|
|||
|
// The ini path szIniPath
|
|||
|
// ---------------------------------------------------------------------------------------
|
|||
|
/* We will get problems if the program can't find the ini settings. Plugins will not be loaded,
|
|||
|
or loadedand then unloaded before activated, or not working. */
|
|||
|
// =======================================================================================
|
|||
|
|
|||
|
///////////////////////////////////
|
|||
|
|
|||
|
|
|||
|
|
|||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
|||
|
// Include
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
#include <iostream>
|
|||
|
//#include "Unicode.h"
|
|||
|
//#include "Output.h"
|
|||
|
#include <windows.h>
|
|||
|
#include <string>
|
|||
|
|
|||
|
#include "Global.h" // Local
|
|||
|
#include "Font.h"
|
|||
|
#include "InputPlugin.h"
|
|||
|
#include "OutputPlugin.h"
|
|||
|
#include "VisPlugin.h"
|
|||
|
#include "DspPlugin.h"
|
|||
|
#include "GenPlugin.h"
|
|||
|
#include "Main.h"
|
|||
|
#include "Rebar.h"
|
|||
|
#include "Playlist.h"
|
|||
|
#include "Status.h"
|
|||
|
#include "PluginManager.h"
|
|||
|
#include "Prefs.h"
|
|||
|
#include "Config.h"
|
|||
|
#include "Emabox/Emabox.h"
|
|||
|
#include "Console.h"
|
|||
|
|
|||
|
#include "PlayerExport.h" // DLL Player
|
|||
|
/////////////////////////
|
|||
|
|
|||
|
|
|||
|
|
|||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
|||
|
// Declarations and definitions
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
|
|||
|
// -------------------------
|
|||
|
// Keys
|
|||
|
// ---------
|
|||
|
#define PLUS_ALT ( FVIRTKEY | FALT )
|
|||
|
#define PLUS_CONTROL ( FVIRTKEY | FCONTROL )
|
|||
|
#define PLUS_CONTROL_ALT ( FVIRTKEY | FCONTROL | FALT )
|
|||
|
#define PLUS_CONTROL_SHIFT ( FVIRTKEY | FCONTROL | FSHIFT )
|
|||
|
#define PLUS_SHIFT ( FVIRTKEY | FSHIFT )
|
|||
|
// -------------
|
|||
|
|
|||
|
|
|||
|
HINSTANCE g_hInstance = NULL; // extern
|
|||
|
HINSTANCE hInstance = NULL; // extern
|
|||
|
|
|||
|
TCHAR * szHomeDir = NULL; // extern
|
|||
|
int iHomeDirLen = 0; // extern
|
|||
|
|
|||
|
TCHAR * szPluginDir = NULL; // extern
|
|||
|
int iPluginDirLen = 0; // extern
|
|||
|
|
|||
|
|
|||
|
// -------------------------
|
|||
|
/* Read global settings from the ini file. They are read from the ini file through Config.h.
|
|||
|
Usage: ( &where to place it, the option name, public or private, default value) */
|
|||
|
// ---------
|
|||
|
TCHAR szCurDir[ MAX_PATH + 1 ] = TEXT( "" );
|
|||
|
ConfCurDir ccdCurDir( szCurDir, TEXT( "CurDir" ) );
|
|||
|
// -------------------------
|
|||
|
|
|||
|
bool bWarnPluginsMissing;
|
|||
|
ConfBool cbWarnPluginsMissing( &bWarnPluginsMissing, TEXT( "WarnPluginsMissing" ), CONF_MODE_PUBLIC, false );
|
|||
|
|
|||
|
bool bLoop;
|
|||
|
ConfBool cbLoop( &bLoop, TEXT( "Loop" ), CONF_MODE_PUBLIC, false );
|
|||
|
/////////////////////////
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
////////////////////////////////////////////////////////////////////////////////
|
|||
|
//
|
|||
|
////////////////////////////////////////////////////////////////////////////////
|
|||
|
//int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR lpCmdLine, int nCmdShow )
|
|||
|
void Player_Main(bool Console)
|
|||
|
{
|
|||
|
// =======================================================================================
|
|||
|
// Set variables
|
|||
|
//g_hInstance = hInstance;
|
|||
|
// =======================================================================================
|
|||
|
|
|||
|
//printf( "DLL > main_dll() opened\n" );
|
|||
|
|
|||
|
if (Console) Player_Console(true);
|
|||
|
|
|||
|
//MessageBox(0, "main() opened", "", 0);
|
|||
|
//printf( "main() opened\n" );
|
|||
|
wprintf( "DLL > main_dll() > Begin\n" );
|
|||
|
|
|||
|
|
|||
|
// =======================================================================================
|
|||
|
// Load full config from ini file
|
|||
|
//Conf::Init( hInstance );
|
|||
|
Conf::Init( );
|
|||
|
|
|||
|
// ---------------------------------------------------------------------------------------
|
|||
|
wprintf( "DLL > bLoop <%i>\n", bLoop);
|
|||
|
wprintf( "DLL > bWarnPluginsMissing <%i>\n", bWarnPluginsMissing);
|
|||
|
// ---------------------------------------------------------------------------------------
|
|||
|
|
|||
|
// =======================================================================================
|
|||
|
|
|||
|
|
|||
|
// =======================================================================================
|
|||
|
/* Get home dir. We use the TCHAR type for the dirname to insure us against foreign letters
|
|||
|
in the dirnames */
|
|||
|
szHomeDir = new TCHAR[ MAX_PATH + 1 ];
|
|||
|
iHomeDirLen = GetModuleFileName( NULL, szHomeDir, MAX_PATH );
|
|||
|
//if( !iHomeDirLen ) return 1;
|
|||
|
|
|||
|
// ---------------------------------------------------------------------------------------
|
|||
|
// Walk through the pathname and look for backslashes
|
|||
|
TCHAR * walk = szHomeDir + iHomeDirLen - 1;
|
|||
|
while( ( walk > szHomeDir ) && ( *walk != TEXT( '\\' ) ) ) walk--;
|
|||
|
// ---------------------------------------------------------------------------------------
|
|||
|
|
|||
|
walk++;
|
|||
|
*walk = TEXT( '\0' );
|
|||
|
iHomeDirLen = walk - szHomeDir;
|
|||
|
// =======================================================================================
|
|||
|
|
|||
|
|
|||
|
// =======================================================================================
|
|||
|
/* Get plugins dir. Notice to change the number 8 in two places below if the dir name
|
|||
|
is changed */
|
|||
|
szPluginDir = new TCHAR[ MAX_PATH + 1 ];
|
|||
|
memcpy( szPluginDir, szHomeDir, iHomeDirLen * sizeof( TCHAR ) );
|
|||
|
memcpy( szPluginDir + iHomeDirLen, TEXT( "PluginsMusic" ), 12 * sizeof( TCHAR ) );
|
|||
|
szPluginDir[ iHomeDirLen + 12 ] = TEXT( '\0' );
|
|||
|
wprintf("DLL > Plugindir: %s\n\n", szPluginDir);
|
|||
|
// =======================================================================================
|
|||
|
#ifndef NOGUI
|
|||
|
Font::Create();
|
|||
|
//Console::Append( TEXT( "Winmain.cpp called Font::Create()" ) );
|
|||
|
#endif
|
|||
|
|
|||
|
// =======================================================================================
|
|||
|
// The only thing this function currently does is creating the Playlist.
|
|||
|
// =======================================================================================
|
|||
|
BuildMainWindow();
|
|||
|
|
|||
|
//addfiletoplaylist("c:\\zelda\\demo37_01.ast");
|
|||
|
//addfiletoplaylist("c:\\zelda\\demo36_02.ast");
|
|||
|
//Console::Append( TEXT( "Winmain.cpp called BuildMainWindow()" ) );
|
|||
|
|
|||
|
//Prefs::Create(); // This creates windows preferences
|
|||
|
//Console::Append( TEXT( "Winmain.cpp called Prefs::Create()" ) );
|
|||
|
|
|||
|
// Show window
|
|||
|
|
|||
|
Plugin::FindAll<InputPlugin> ( szPluginDir, TEXT( "in_*.dll" ), true );
|
|||
|
Plugin::FindAll<OutputPlugin>( szPluginDir, TEXT( "out_*.dll" ), false );
|
|||
|
Plugin::FindAll<VisPlugin> ( szPluginDir, TEXT( "vis_*.dll" ), false );
|
|||
|
Plugin::FindAll<DspPlugin> ( szPluginDir, TEXT( "dsp_*.dll" ), false );
|
|||
|
Plugin::FindAll<GenPlugin> ( szPluginDir, TEXT( "gen_*.dll" ), true );
|
|||
|
|
|||
|
PluginManager::Fill();
|
|||
|
|
|||
|
wprintf( "Winmain.cpp > PluginManager::Fill()\n" );
|
|||
|
|
|||
|
// ---------------------------------------------------------------------------------------
|
|||
|
// Set volume. This must probably be done after the dll is loaded.
|
|||
|
GlobalVolume = Playback::Volume::Get();
|
|||
|
GlobalCurrentVolume = GlobalVolume;
|
|||
|
Output_SetVolume( GlobalVolume );
|
|||
|
wprintf("\n >>> Volume(%i)\n\n", GlobalVolume);
|
|||
|
// ---------------------------------------------------------------------------------------
|
|||
|
|
|||
|
|
|||
|
// =======================================================================================
|
|||
|
|
|||
|
// Check plugin presence
|
|||
|
// =======================================================================================
|
|||
|
|
|||
|
|
|||
|
// =======================================================================================
|
|||
|
|
|||
|
// Todo: all the rest...
|
|||
|
// ACCEL accels[] = {
|
|||
|
|
|||
|
// =======================================================================================
|
|||
|
|
|||
|
|
|||
|
|
|||
|
// =======================================================================================
|
|||
|
|
|||
|
//Playback::Play();
|
|||
|
//play_file("C:\\opening.hps");
|
|||
|
//play_file("C:\\Files\\Spel och spelfusk\\Console\\Gamecube\\Code\\Dolphin\\Binary\\win32\\evt_x_event_00.dsp");
|
|||
|
//printf("Winmain.cpp called Playback.cpp:Playback::Play()\n");
|
|||
|
|
|||
|
// =======================================================================================
|
|||
|
// ---- Set volume and get current location ----
|
|||
|
// Somehow we don't have access to active_input_plugin->plugin->GetLength() from here so
|
|||
|
// we have to call it in Playback::UpdateSeek() instead
|
|||
|
//Sleep(1000);
|
|||
|
|
|||
|
//Playback::UpdateSeek();
|
|||
|
//Output_SetVolume( 100 ); // volume is better set from the ini file
|
|||
|
// ---------------------------------------------------------------------------------------
|
|||
|
// =======================================================================================
|
|||
|
|
|||
|
|
|||
|
// =======================================================================================
|
|||
|
// Check the plugins
|
|||
|
if( input_plugins.empty() )
|
|||
|
{
|
|||
|
wprintf("\n***Warning: The input plugin is not working\n\n");
|
|||
|
}
|
|||
|
|
|||
|
if( !active_input_plugin || !active_input_plugin->plugin )
|
|||
|
{
|
|||
|
wprintf("The input plugin is not activated yet\n");
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
//const int ms_len = active_input_plugin->plugin->GetLength();
|
|||
|
//const int ms_cur = active_input_plugin->plugin->GetOutputTime();
|
|||
|
//wprintf("We are at <%i of %i>\n", ms_cur, ms_len);
|
|||
|
}
|
|||
|
// ---------------------------------------------------------------------------------------
|
|||
|
if( active_output_count > 0 )
|
|||
|
{
|
|||
|
// Minimum
|
|||
|
int res_temp;
|
|||
|
for( int i = 0; i < active_output_count; i++ )
|
|||
|
{
|
|||
|
res_temp = active_output_plugins[ i ]->plugin->GetOutputTime();
|
|||
|
}
|
|||
|
wprintf("Playback progress <%i>\n", res_temp);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
wprintf("\n***Warning: The output plugin is not working\n\n");
|
|||
|
}
|
|||
|
// =======================================================================================
|
|||
|
|
|||
|
|
|||
|
// =======================================================================================
|
|||
|
// Current playlist items
|
|||
|
wprintf("Size & index <%i> <%i>\n", playlist->GetSize(), playlist->GetCurIndex());
|
|||
|
// =======================================================================================
|
|||
|
|
|||
|
|
|||
|
// =======================================================================================
|
|||
|
//This worked
|
|||
|
//Sleep(2000);
|
|||
|
//Playback::Stop();
|
|||
|
//playlist->RemoveAll();
|
|||
|
//play_file("C:\\demo36_02.ast");
|
|||
|
// =======================================================================================
|
|||
|
|
|||
|
// =======================================================================================
|
|||
|
// Current playlist items
|
|||
|
wprintf("Size & index <%i> <%i>\n", playlist->GetSize(), playlist->GetCurIndex());
|
|||
|
// =======================================================================================
|
|||
|
|
|||
|
|
|||
|
// =======================================================================================
|
|||
|
// This worked
|
|||
|
//Sleep(5000);
|
|||
|
//Playback::Stop();
|
|||
|
//Playback::Play();
|
|||
|
// =======================================================================================
|
|||
|
|
|||
|
|
|||
|
// =======================================================================================
|
|||
|
|
|||
|
//bool bPlaying = false;
|
|||
|
//TCHAR * szFilename = TEXT("C:\Files\Spel och spelfusk\Console\Gamecube\Code\vgmstream (isolate ast)\Music\demo36_02.ast");
|
|||
|
|
|||
|
//bPlaying = OpenPlay( szFilename, 1 );
|
|||
|
//bPlaying = OpenPlay( szFilename, iIndex + 1 );
|
|||
|
//Console::Append( TEXT( "Playback.cpp:Playback::Play() called OpenPlay" ) );
|
|||
|
|
|||
|
// =======================================================================================
|
|||
|
|
|||
|
|
|||
|
// =======================================================================================
|
|||
|
// Start the timer
|
|||
|
if(!TimerCreated && bLoop) // Only create this the first time
|
|||
|
{
|
|||
|
wprintf("Created the timer\n");
|
|||
|
MakeTime();
|
|||
|
TimerCreated = true;
|
|||
|
}
|
|||
|
// =======================================================================================
|
|||
|
|
|||
|
wprintf( "DLL > main_dll() > End\n\n\n" );
|
|||
|
|
|||
|
//std::cin.get();
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
// =======================================================================================
|
|||
|
// Should I use this?
|
|||
|
void close()
|
|||
|
{
|
|||
|
|
|||
|
printf( "The Winmain.cpp message loop was reached\n" );
|
|||
|
|
|||
|
// Message loop
|
|||
|
//std::cin.get();
|
|||
|
|
|||
|
Playback::Stop(); // If we don't call this before we unload the dll we get a crash
|
|||
|
|
|||
|
printf("We are now past the message loop\n" );
|
|||
|
|
|||
|
//DestroyAcceleratorTable( hAccel );
|
|||
|
|
|||
|
|
|||
|
// =======================================================================================
|
|||
|
// Input
|
|||
|
vector <InputPlugin *>::iterator iter_input = input_plugins.begin();
|
|||
|
while( iter_input != input_plugins.end() )
|
|||
|
{
|
|||
|
( *iter_input )->Unload();
|
|||
|
iter_input++;
|
|||
|
}
|
|||
|
|
|||
|
// Output
|
|||
|
vector <OutputPlugin *>::iterator iter_output = output_plugins.begin();
|
|||
|
while( iter_output != output_plugins.end() )
|
|||
|
{
|
|||
|
( *iter_output )->Unload();
|
|||
|
iter_output++;
|
|||
|
}
|
|||
|
|
|||
|
// General
|
|||
|
vector <GenPlugin *>::iterator iter_gen = gen_plugins.begin();
|
|||
|
while( iter_gen != gen_plugins.end() )
|
|||
|
{
|
|||
|
( *iter_gen )->Unload();
|
|||
|
iter_gen++;
|
|||
|
}
|
|||
|
// =======================================================================================
|
|||
|
|
|||
|
|
|||
|
// TODO: create main::destroy
|
|||
|
// UnregisterClass( PA_CLASSNAME, g_hInstance );
|
|||
|
|
|||
|
//Prefs::Destroy();
|
|||
|
|
|||
|
//Font::Destroy();
|
|||
|
|
|||
|
/*
|
|||
|
delete [] szPluginDir;
|
|||
|
delete [] szHomeDir;
|
|||
|
*/
|
|||
|
|
|||
|
// ---------------------------------------------------------------------------------------
|
|||
|
// We don't save any changes
|
|||
|
//Conf::Write();
|
|||
|
|
|||
|
//printf("Winmain.cpp called Conf::Write(), the last function\n");
|
|||
|
// ---------------------------------------------------------------------------------------
|
|||
|
|
|||
|
//std::cin.get(); // Let use see all messages
|
|||
|
|
|||
|
//return 0;
|
|||
|
}
|
|||
|
// =======================================================================================
|