88#include " Decoders/iWaveDataProvider.h"
99#include " Decoders/WAV/WAVDataProvider.h"
1010#include " Utils.h"
11+ #include " Playlist.h"
1112
12- const char * PORTAMP_VERSION = " 0.99.9 " ;
13+ const char * PORTAMP_VERSION = " 1.0.0 " ;
1314
1415sConfig g_Config;
16+ clPlaylist g_Playlist;
1517
1618sConfig ReadConfigFromCommandLine ( int argc, char * argv[] )
1719{
@@ -20,7 +22,9 @@ sConfig ReadConfigFromCommandLine( int argc, char* argv[] )
2022 for ( int i = 1 ; i < argc; i++ )
2123 {
2224 if ( strstr ( argv[i], " --loop" ) == argv[i] ) Cfg.m_Loop = true ;
23- if ( strstr ( argv[i], " --wav-modplug" ) == argv[i] ) Cfg.m_UseModPlugToDecodeWAV = true ;
25+ else if ( strstr ( argv[i], " --wav-modplug" ) == argv[i] ) Cfg.m_UseModPlugToDecodeWAV = true ;
26+ else if ( strstr ( argv[i], " --verbose" ) == argv[i] ) Cfg.m_Verbose = true ;
27+ else g_Playlist.EnqueueTrack ( argv[i] );
2428 }
2529
2630 return Cfg;
@@ -32,7 +36,7 @@ void PrintBanner()
3236 printf ( " Copyright (C) 2015 Sergey Kosarevsky\n " );
3337 printf ( " https://github.com/corporateshark/PortAMP\n " );
3438 printf ( " \n " );
35- printf ( " portamp <filename > [--loop] [--wav-modplug]\n " );
39+ printf ( " portamp <filename1 > [<filename2> ...] [ --loop] [--wav-modplug] [--verbose ]\n " );
3640 printf ( " \n " );
3741}
3842
@@ -46,25 +50,36 @@ int main( int argc, char* argv[] )
4650
4751 g_Config = ReadConfigFromCommandLine ( argc, argv );
4852
49- const char * FileName = ( argc > 1 ) ? argv[ 1 ] : " test.ogg" ;
53+ if ( g_Playlist. IsEmpty () ) g_Playlist. EnqueueTrack ( " test.ogg" ) ;
5054
5155 auto AudioSubsystem = CreateAudioSubsystem_OpenAL ();
5256
5357 AudioSubsystem->Start ();
5458
55- auto TestBlob = ReadFileAsBlob ( FileName );
56- auto Provider = CreateWaveDataProvider ( FileName, TestBlob );
5759 auto Source = AudioSubsystem->CreateAudioSource ();
58- Source->BindDataProvider ( Provider );
59- Source->SetLooping ( g_Config.m_Loop );
60- Source->Play ();
60+ // allow seamless looping if there is only one track
61+ if ( g_Playlist.GetNumTracks () == 1 ) Source->SetLooping ( g_Config.m_Loop );
6162
62- while ( Source->IsPlaying () && !IsKeyPressed () )
63+ bool RequestingExit = false ;
64+
65+ while ( !g_Playlist.IsEmpty () && !RequestingExit )
6366 {
64- std::this_thread::sleep_for ( std::chrono::milliseconds (10 ) );
65- };
67+ auto FileName = g_Playlist.GetAndPopNextTrack ( g_Config.m_Loop );
68+ auto DataBlob = ReadFileAsBlob ( FileName.c_str () );
69+ auto Provider = CreateWaveDataProvider ( FileName.c_str (), DataBlob );
70+ Source->BindDataProvider ( Provider );
71+ Source->Play ();
72+
73+ while ( Source->IsPlaying () && !RequestingExit )
74+ {
75+ std::this_thread::sleep_for ( std::chrono::milliseconds (10 ) );
76+
77+ if ( IsKeyPressed () ) RequestingExit = true ;
78+ };
79+
80+ Source->Stop ();
81+ }
6682
67- Source->Stop ();
6883 Source = nullptr ;
6984
7085 AudioSubsystem->Stop ();
0 commit comments