mirror of
https://github.com/clangen/musikcube.git
synced 2024-12-29 18:14:16 +00:00
- Added ID and ToString() to AudioStream to identify streams
- Added GetSource() to IAudioSource and decoders to help stream identification - Fixed problem where not all finished streams were removed properly in Transport - Fixed include paths & directives for square
This commit is contained in:
parent
f376961b6a
commit
65bf15f94b
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -18,6 +18,9 @@ bool APEDecoder::Open(const utfchar* source)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
this->sourcePath = source;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -82,6 +82,8 @@ bool CDDAAudioSource::Open(const utfchar* source)
|
||||
|
||||
m_llLength = (m_nStopSector-m_nStartSector)*RAW_SECTOR_SIZE;
|
||||
|
||||
this->sourcePath = source;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -155,6 +155,8 @@ bool MP3Decoder::Open(const utfchar* sourcePath)
|
||||
return false;
|
||||
}
|
||||
|
||||
this->sourcePath = sourcePath;
|
||||
|
||||
return GetStreamData();
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
};
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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);
|
||||
|
@ -5,8 +5,12 @@
|
||||
#include <core/audio/IAudioOutput.h>
|
||||
#include <core/audio/Transport.h>
|
||||
|
||||
#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();
|
||||
}
|
@ -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
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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<utfstring>::const_iterator it = this->openStreamSources.begin()
|
||||
;it != this->openStreamSources.end()
|
||||
for(std::vector<AudioStream*>::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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<boost::shared_ptr<IAudioOutputSupplier> > Output
|
||||
private: OutputSupplierList registeredOutputSuppliers;
|
||||
|
||||
private: std::vector<AudioStream*> openStreams;
|
||||
private: std::vector<utfstring> 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;
|
||||
|
||||
|
@ -509,6 +509,10 @@
|
||||
RelativePath=".\audio\Transport.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\audio\tstl.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
</Files>
|
||||
|
@ -37,12 +37,11 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "boost/algorithm/string.hpp"
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#include "core/PluginFactory.h"
|
||||
#include "core/IPlugin.h"
|
||||
|
||||
#include "AudioStream.h"
|
||||
#include <core/audio/AudioStream.h>
|
||||
#include <core/PluginFactory.h>
|
||||
#include <core/IPlugin.h>
|
||||
|
||||
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<unsigned int>(delay, args[2]))
|
||||
{
|
||||
delay *= 1000;
|
||||
}
|
||||
else
|
||||
if (!convertString<unsigned int>(delay, args[2]))
|
||||
{
|
||||
delay = 0;
|
||||
}
|
||||
|
@ -41,7 +41,8 @@
|
||||
|
||||
#include <boost/thread/mutex.hpp>
|
||||
|
||||
#include "Transport.h"
|
||||
#include <core/audio/Transport.h>
|
||||
|
||||
#include "DummyAudioEventHandler.h"
|
||||
|
||||
using namespace musik::core::audio;
|
||||
|
@ -37,8 +37,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "sigslot/sigslot.h"
|
||||
#include "tstl.h"
|
||||
#include <sigslot/sigslot.h>
|
||||
|
||||
namespace musik { namespace square {
|
||||
|
||||
|
@ -42,7 +42,7 @@
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../;../core/audio;../3rdparty/include"
|
||||
AdditionalIncludeDirectories="../;../3rdparty/include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
@ -123,7 +123,7 @@
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../;../core/audio;../3rdparty/include"
|
||||
AdditionalIncludeDirectories="../;../3rdparty/include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="2"
|
||||
|
@ -14,4 +14,4 @@
|
||||
|
||||
#include "vld/vld.h"
|
||||
|
||||
#include "tstl.h"
|
||||
#include "core/audio/tstl.h"
|
||||
|
Loading…
Reference in New Issue
Block a user