diff --git a/src/contrib/aacdecoder/m4aAudioSource.cpp b/src/contrib/aacdecoder/m4aAudioSource.cpp index 61d734cd3..c60f0d602 100644 --- a/src/contrib/aacdecoder/m4aAudioSource.cpp +++ b/src/contrib/aacdecoder/m4aAudioSource.cpp @@ -124,6 +124,8 @@ bool M4ADecoder::Open(const utfchar* source) m_numSamples = mp4ff_num_samples(m_mp4file, m_mp4track); m_sampleId = 0; + this->sourcePath = source; + return true; } diff --git a/src/contrib/aacdecoder/m4aAudioSource.h b/src/contrib/aacdecoder/m4aAudioSource.h index 6c56fdd10..1835e98d9 100644 --- a/src/contrib/aacdecoder/m4aAudioSource.h +++ b/src/contrib/aacdecoder/m4aAudioSource.h @@ -34,4 +34,9 @@ public: bool SetState(unsigned long State); bool GetFormat(unsigned long * SampleRate, unsigned long * Channels); bool GetBuffer(float ** ppBuffer, unsigned long * NumSamples); + + const utfchar* GetSource() const { return sourcePath.c_str(); }; + +private: + utfstring sourcePath; }; diff --git a/src/contrib/apedecoder/APEDecoder.cpp b/src/contrib/apedecoder/APEDecoder.cpp index 1c78e2ad1..1a4f111ed 100644 --- a/src/contrib/apedecoder/APEDecoder.cpp +++ b/src/contrib/apedecoder/APEDecoder.cpp @@ -18,6 +18,9 @@ bool APEDecoder::Open(const utfchar* source) { return false; } + + this->sourcePath = source; + return true; } diff --git a/src/contrib/apedecoder/APEDecoder.h b/src/contrib/apedecoder/APEDecoder.h index 392a9c4ad..d3e35cf43 100644 --- a/src/contrib/apedecoder/APEDecoder.h +++ b/src/contrib/apedecoder/APEDecoder.h @@ -29,4 +29,9 @@ public: bool SetPosition(unsigned long * MS); bool SetState(unsigned long State); bool GetBuffer(float ** ppBuffer, unsigned long * NumSamples); + + const utfchar* GetSource() const { return sourcePath.c_str(); }; + +private: + utfstring sourcePath; }; diff --git a/src/contrib/cddadecoder/CDDAAudioSource.cpp b/src/contrib/cddadecoder/CDDAAudioSource.cpp index 304f68ebb..791a13382 100644 --- a/src/contrib/cddadecoder/CDDAAudioSource.cpp +++ b/src/contrib/cddadecoder/CDDAAudioSource.cpp @@ -82,6 +82,8 @@ bool CDDAAudioSource::Open(const utfchar* source) m_llLength = (m_nStopSector-m_nStartSector)*RAW_SECTOR_SIZE; + this->sourcePath = source; + return true; } diff --git a/src/contrib/cddadecoder/CDDAAudioSource.h b/src/contrib/cddadecoder/CDDAAudioSource.h index 942373e9e..65e9d6b23 100644 --- a/src/contrib/cddadecoder/CDDAAudioSource.h +++ b/src/contrib/cddadecoder/CDDAAudioSource.h @@ -35,4 +35,9 @@ public: bool SetState(unsigned long State); bool GetFormat(unsigned long * SampleRate, unsigned long * Channels); bool GetBuffer(float ** ppBuffer, unsigned long * NumSamples); + + const utfchar* GetSource() const { return sourcePath.c_str(); }; + +private: + utfstring sourcePath; }; diff --git a/src/contrib/mp3decoder/MP3Decoder.cpp b/src/contrib/mp3decoder/MP3Decoder.cpp index f72403dd1..df108b382 100644 --- a/src/contrib/mp3decoder/MP3Decoder.cpp +++ b/src/contrib/mp3decoder/MP3Decoder.cpp @@ -155,6 +155,8 @@ bool MP3Decoder::Open(const utfchar* sourcePath) return false; } + this->sourcePath = sourcePath; + return GetStreamData(); } diff --git a/src/contrib/mp3decoder/MP3Decoder.h b/src/contrib/mp3decoder/MP3Decoder.h index 66de3060d..438d73786 100644 --- a/src/contrib/mp3decoder/MP3Decoder.h +++ b/src/contrib/mp3decoder/MP3Decoder.h @@ -48,6 +48,11 @@ public: bool GetFormat(unsigned long * SampleRate, unsigned long * Channels); bool GetBuffer(float ** ppBuffer, unsigned long * NumSamples); + const utfchar* GetSource() const { return sourcePath.c_str(); }; + +private: + utfstring sourcePath; + // Stubs void LogConsoleMessage(LPTSTR szModuleName, LPTSTR szMessage) {}; // TODO: replace with sigslot }; diff --git a/src/contrib/oggdecoder/OGGDecoder.cpp b/src/contrib/oggdecoder/OGGDecoder.cpp index ec852e242..31cf02429 100644 --- a/src/contrib/oggdecoder/OGGDecoder.cpp +++ b/src/contrib/oggdecoder/OGGDecoder.cpp @@ -25,6 +25,8 @@ bool OGGDecoder::Open(const utfchar* source) vorbis_info * vi = ov_info(&m_vf, -1); m_Buffer = (float*)malloc(4096 * 4 * vi->channels); + this->sourcePath = source; + return(true); } diff --git a/src/contrib/oggdecoder/OGGDecoder.h b/src/contrib/oggdecoder/OGGDecoder.h index a2e5c4a02..276956961 100644 --- a/src/contrib/oggdecoder/OGGDecoder.h +++ b/src/contrib/oggdecoder/OGGDecoder.h @@ -25,4 +25,8 @@ public: bool GetLength(unsigned long * MS); public: bool SetPosition(unsigned long * MS); public: bool SetState(unsigned long State); public: bool GetBuffer(float ** ppBuffer, unsigned long * NumSamples); + +public: const utfchar* GetSource() const { return sourcePath.c_str(); }; + +private: utfstring sourcePath; }; diff --git a/src/core/audio/AudioPacketizer.h b/src/core/audio/AudioPacketizer.h index 93fca9b86..77ace1c5c 100644 --- a/src/core/audio/AudioPacketizer.h +++ b/src/core/audio/AudioPacketizer.h @@ -34,8 +34,8 @@ public: bool WriteData(float * Data, unsigned long Samples); bool Finished(void); - bool IsBufferAvailable(void); - bool GetBuffer(float * ToHere); + bool IsBufferAvailable(void); + bool GetBuffer(float * ToHere); bool Advance(unsigned long Packets = 1); bool Rewind(unsigned long Packets); diff --git a/src/core/audio/AudioStream.cpp b/src/core/audio/AudioStream.cpp index 87c80ee6f..feae92467 100644 --- a/src/core/audio/AudioStream.cpp +++ b/src/core/audio/AudioStream.cpp @@ -5,8 +5,12 @@ #include #include +#include "tstl.h" + using namespace musik::core::audio; +unsigned long AudioStream::streamsCreated = 0; + AudioStream::AudioStream(IAudioSource* source, IAudioOutput* output, Transport* owner) : audioSource(source) , transport(owner) @@ -26,6 +30,8 @@ AudioStream::AudioStream(IAudioSource* source, IAudioOutput* output, Transport* this->output->SetFormat(srate, this->channels); this->packetizer.SetPacketSize(this->output->GetBlockSize()); + + this->streamId = ++AudioStream::streamsCreated; } AudioStream::~AudioStream() @@ -241,9 +247,11 @@ bool AudioStream::SetPosition(unsigned long MS) return false; } -/* -bool AudioStream::GetVisData(float * ToHere, unsigned long ulNumSamples) +utfstring AudioStream::ToString() const { - return this->output->GetVisData(ToHere, ulNumSamples); -} -*/ + std::tstringstream ss; + + ss << this->streamId << " " << this->audioSource->GetSource(); + + return ss.str(); +} \ No newline at end of file diff --git a/src/core/audio/AudioStream.h b/src/core/audio/AudioStream.h index c2b486509..5345faf6e 100644 --- a/src/core/audio/AudioStream.h +++ b/src/core/audio/AudioStream.h @@ -53,6 +53,12 @@ private: unsigned long channels; private: boost::mutex mutex; +private: static unsigned long streamsCreated; +private: unsigned long streamId; + +public: unsigned long GetStreamId() const { return this->streamId; }; +public: utfstring ToString() const; + ///////////////////////////////////////// // Pending stuff diff --git a/src/core/audio/IAudioOutput.h b/src/core/audio/IAudioOutput.h index dafd1f93f..b2daa2467 100644 --- a/src/core/audio/IAudioOutput.h +++ b/src/core/audio/IAudioOutput.h @@ -41,10 +41,10 @@ class IAudioOutput { public: virtual void Destroy() = 0; -private: virtual bool Open(void) = 0; -private: virtual bool Close(void) = 0; -private: virtual bool Initialize(void) = 0; -private: virtual bool Shutdown(void) = 0; +private: virtual bool Open(void) = 0; +private: virtual bool Close(void) = 0; +private: virtual bool Initialize(void) = 0; +private: virtual bool Shutdown(void) = 0; public: virtual void SetCallback(IAudioCallback * pCallback) = 0; public: virtual bool SetFormat(unsigned long SampleRate, unsigned long Channels) = 0; diff --git a/src/core/audio/IAudioSource.h b/src/core/audio/IAudioSource.h index 9b15b566a..2b89260a2 100644 --- a/src/core/audio/IAudioSource.h +++ b/src/core/audio/IAudioSource.h @@ -15,6 +15,8 @@ public: virtual bool SetState(unsigned long State) = 0; public: virtual bool GetFormat(unsigned long * SampleRate, unsigned long * Channels) = 0; public: virtual bool GetBuffer(float ** ppBuffer, unsigned long * NumSamples) = 0; // return false to signal that we are done decoding. public: virtual bool Open(const utfchar* source) = 0; + +public: virtual const utfchar* GetSource() const = 0; }; class IAudioSourceSupplier diff --git a/src/core/audio/Transport.cpp b/src/core/audio/Transport.cpp index 30af76475..373722307 100644 --- a/src/core/audio/Transport.cpp +++ b/src/core/audio/Transport.cpp @@ -62,8 +62,6 @@ Transport::~Transport() delete this->openStreams[i]; } this->openStreams.clear(); - - this->openStreamSources.clear(); } void Transport::Start(const utfstring path) @@ -81,7 +79,6 @@ void Transport::Start(const utfstring path) if (audioStream->Start()) { this->openStreams.push_back(audioStream); - this->openStreamSources.push_back(path.c_str()); success = true; } @@ -115,8 +112,6 @@ void Transport::Stop(size_t idx) this->openStreams.erase(this->openStreams.begin() + idx); - this->openStreamSources.erase(this->openStreamSources.begin() + idx); - this->PlaybackStoppedOk(); } else @@ -155,12 +150,12 @@ AudioStreamOverview Transport::StreamsOverview() const { AudioStreamOverview overview; - for(std::vector::const_iterator it = this->openStreamSources.begin() - ;it != this->openStreamSources.end() + for(std::vector::const_iterator it = this->openStreams.begin() + ;it != this->openStreams.end() ;it++ ) { - overview.push_back(*it); + overview.push_back((*it)->ToString()); } return overview; @@ -214,7 +209,7 @@ void Transport::RemoveFinishedStreams() stream->Stop(); delete stream; this->openStreams.erase(this->openStreams.begin() + i); - this->openStreamSources.erase(this->openStreamSources.begin() + i); + --i; } } } diff --git a/src/core/audio/Transport.h b/src/core/audio/Transport.h index 79d85b423..4886813f7 100644 --- a/src/core/audio/Transport.h +++ b/src/core/audio/Transport.h @@ -64,9 +64,6 @@ public: void ChangeVolume(float volume); public: size_t NumOfStreams() const; public: AudioStreamOverview StreamsOverview() const; -//public: void RegisterSourceSupplier(const IAudioSourceSupplier* supplier); -//public: void RegisterOutputSupplier(const IAudioOutputSupplier* output); - private: AudioStream* CreateStream(const utfstring sourceString); private: void RemoveFinishedStreams(); @@ -76,9 +73,6 @@ private: typedef std::vector > Output private: OutputSupplierList registeredOutputSuppliers; private: std::vector openStreams; -private: std::vector openStreamSources; - // Streams in both vectors should be on the same index. This will suffice. For now. - // TODO: come up with a better data structure for streams & sources private: float currVolume; diff --git a/src/core/core.vcproj b/src/core/core.vcproj index 753255427..cc6378b01 100644 --- a/src/core/core.vcproj +++ b/src/core/core.vcproj @@ -509,6 +509,10 @@ RelativePath=".\audio\Transport.h" > + + diff --git a/src/square/ConsoleUI.cpp b/src/square/ConsoleUI.cpp index 793ca89e3..fa2ab364e 100644 --- a/src/square/ConsoleUI.cpp +++ b/src/square/ConsoleUI.cpp @@ -37,12 +37,11 @@ #include -#include "boost/algorithm/string.hpp" +#include -#include "core/PluginFactory.h" -#include "core/IPlugin.h" - -#include "AudioStream.h" +#include +#include +#include using namespace std; using namespace musik::square; @@ -165,11 +164,7 @@ void ConsoleUI::PlayFile(Args args) unsigned int delay = 0; if (args.size() > 2) { - if (convertString(delay, args[2])) - { - delay *= 1000; - } - else + if (!convertString(delay, args[2])) { delay = 0; } diff --git a/src/square/ConsoleUI.h b/src/square/ConsoleUI.h index 52e3cf9f3..75c70e8d8 100644 --- a/src/square/ConsoleUI.h +++ b/src/square/ConsoleUI.h @@ -41,7 +41,8 @@ #include -#include "Transport.h" +#include + #include "DummyAudioEventHandler.h" using namespace musik::core::audio; diff --git a/src/square/DummyAudioEventHandler.h b/src/square/DummyAudioEventHandler.h index f2f5b5b07..da6d0b9f0 100644 --- a/src/square/DummyAudioEventHandler.h +++ b/src/square/DummyAudioEventHandler.h @@ -37,8 +37,7 @@ #include -#include "sigslot/sigslot.h" -#include "tstl.h" +#include namespace musik { namespace square { diff --git a/src/square/player.vcproj b/src/square/player.vcproj index 5a7b7f324..e051245cd 100644 --- a/src/square/player.vcproj +++ b/src/square/player.vcproj @@ -42,7 +42,7 @@