- Added ITransport interface

- Moved Transport.h/cpp -> GaplessTransport.h/cpp
- Moved all Transport-related source units to the core/audio/ directory
- Moved NonLibraryTrackHelper to core/support/
This commit is contained in:
casey 2016-06-11 22:21:31 -07:00
parent ad70ef988e
commit 85f63ce303
26 changed files with 189 additions and 357 deletions

View File

@ -3,6 +3,7 @@ set(CORE_SOURCES
./audio/Buffer.cpp
./audio/Player.cpp
./audio/Stream.cpp
./audio/GaplessTransport.cpp
./db/CachedStatement.cpp
./db/Connection.cpp
./db/ScopedTransaction.cpp
@ -18,10 +19,9 @@ set(CORE_SOURCES
./library/track/IndexerTrack.cpp
./library/track/LibraryTrack.cpp
./library/track/Track.cpp
./playback/NonLibraryTrackHelper.cpp
./playback/Transport.cpp
./plugin/PluginFactory.cpp
./support/Common.cpp
./support/NonLibraryTrackHelper.cpp
./support/Preferences.cpp
./support/ThreadHelper.cpp
./support/Version.cpp

View File

@ -35,7 +35,7 @@
#include "pch.hpp"
#include <core/debug.h>
#include <core/playback/Transport.h>
#include <core/audio/GaplessTransport.h>
#include <core/plugin/PluginFactory.h>
#include <algorithm>
#include <boost/thread.hpp>
@ -62,7 +62,7 @@ static void deletePlayer(Player* p) {
delete p;
}
Transport::Transport()
GaplessTransport::GaplessTransport()
: volume(1.0)
, state(PlaybackStopped)
, nextPlayer(NULL)
@ -70,15 +70,15 @@ Transport::Transport()
this->output = Player::CreateDefaultOutput();
}
Transport::~Transport() {
GaplessTransport::~GaplessTransport() {
}
Transport::PlaybackState Transport::GetPlaybackState() {
GaplessTransport::PlaybackState GaplessTransport::GetPlaybackState() {
boost::recursive_mutex::scoped_lock lock(this->stateMutex);
return this->state;
}
void Transport::PrepareNextTrack(const std::string& trackUrl) {
void GaplessTransport::PrepareNextTrack(const std::string& trackUrl) {
bool startNext = false;
{
boost::recursive_mutex::scoped_lock lock(this->stateMutex);
@ -91,7 +91,7 @@ void Transport::PrepareNextTrack(const std::string& trackUrl) {
}
}
void Transport::Start(const std::string& url) {
void GaplessTransport::Start(const std::string& url) {
musik::debug::info(TAG, "we were asked to start the track at " + url);
Player* newPlayer = new Player(url, this->output);
@ -100,7 +100,7 @@ void Transport::Start(const std::string& url) {
this->StartWithPlayer(newPlayer);
}
void Transport::StartWithPlayer(Player* newPlayer) {
void GaplessTransport::StartWithPlayer(Player* newPlayer) {
if (newPlayer) {
{
boost::recursive_mutex::scoped_lock lock(this->stateMutex);
@ -118,10 +118,10 @@ void Transport::StartWithPlayer(Player* newPlayer) {
this->Stop(true, !playingNext);
this->SetNextCanStart(false);
newPlayer->PlaybackStarted.connect(this, &Transport::OnPlaybackStarted);
newPlayer->PlaybackAlmostEnded.connect(this, &Transport::OnPlaybackAlmostEnded);
newPlayer->PlaybackFinished.connect(this, &Transport::OnPlaybackFinished);
newPlayer->PlaybackError.connect(this, &Transport::OnPlaybackError);
newPlayer->PlaybackStarted.connect(this, &GaplessTransport::OnPlaybackStarted);
newPlayer->PlaybackAlmostEnded.connect(this, &GaplessTransport::OnPlaybackAlmostEnded);
newPlayer->PlaybackFinished.connect(this, &GaplessTransport::OnPlaybackFinished);
newPlayer->PlaybackError.connect(this, &GaplessTransport::OnPlaybackError);
musik::debug::info(TAG, "play()");
@ -130,15 +130,15 @@ void Transport::StartWithPlayer(Player* newPlayer) {
newPlayer->Play();
}
this->RaiseStreamEvent(Transport::StreamScheduled, newPlayer);
this->RaiseStreamEvent(GaplessTransport::StreamScheduled, newPlayer);
}
}
void Transport::Stop() {
void GaplessTransport::Stop() {
this->Stop(false, true);
}
void Transport::Stop(bool suppressStopEvent, bool stopOutput) {
void GaplessTransport::Stop(bool suppressStopEvent, bool stopOutput) {
musik::debug::info(TAG, "stop");
/* if we stop the output, we kill all of the Players immediately.
@ -157,7 +157,7 @@ void Transport::Stop(bool suppressStopEvent, bool stopOutput) {
where this method is implicitly triggered via Player callback. however,
we should stop them immediately so they stop producing audio. */
std::for_each(toDelete.begin(), toDelete.end(), stopPlayer);
DEFER(&Transport::DeletePlayers, toDelete);
DEFER(&GaplessTransport::DeletePlayers, toDelete);
/* stopping the transport will stop any buffers that are currently in
flight. this makes the sound end immediately. */
@ -172,7 +172,7 @@ void Transport::Stop(bool suppressStopEvent, bool stopOutput) {
}
}
bool Transport::Pause() {
bool GaplessTransport::Pause() {
musik::debug::info(TAG, "pause");
size_t count = 0;
@ -192,7 +192,7 @@ bool Transport::Pause() {
return false;
}
bool Transport::Resume() {
bool GaplessTransport::Resume() {
musik::debug::info(TAG, "resume");
this->output->Resume();
@ -211,14 +211,14 @@ bool Transport::Resume() {
}
if (count) {
this->SetPlaybackState(Transport::PlaybackPlaying);
this->SetPlaybackState(GaplessTransport::PlaybackPlaying);
return true;
}
return false;
}
double Transport::Position() {
double GaplessTransport::Position() {
boost::recursive_mutex::scoped_lock lock(this->stateMutex);
if (!this->active.empty()) {
@ -228,7 +228,7 @@ double Transport::Position() {
return 0;
}
void Transport::SetPosition(double seconds) {
void GaplessTransport::SetPosition(double seconds) {
boost::recursive_mutex::scoped_lock lock(this->stateMutex);
if (!this->active.empty()) {
@ -237,11 +237,11 @@ void Transport::SetPosition(double seconds) {
}
}
double Transport::Volume() {
double GaplessTransport::Volume() {
return this->volume;
}
void Transport::SetVolume(double volume) {
void GaplessTransport::SetVolume(double volume) {
double oldVolume = this->volume;
volume = std::max(0.0, std::min(1.0, volume));
@ -260,7 +260,7 @@ void Transport::SetVolume(double volume) {
this->output->SetVolume(this->volume);
}
void Transport::RemoveActive(Player* player) {
void GaplessTransport::RemoveActive(Player* player) {
bool found = false;
{
@ -281,23 +281,23 @@ void Transport::RemoveActive(Player* player) {
}
}
void Transport::DeletePlayers(std::list<Player*> players) {
void GaplessTransport::DeletePlayers(std::list<Player*> players) {
std::for_each(players.begin(), players.end(), deletePlayer);
}
void Transport::SetNextCanStart(bool nextCanStart) {
void GaplessTransport::SetNextCanStart(bool nextCanStart) {
boost::recursive_mutex::scoped_lock lock(this->stateMutex);
this->nextCanStart = nextCanStart;
}
void Transport::OnPlaybackStarted(Player* player) {
this->RaiseStreamEvent(Transport::StreamPlaying, player);
this->SetPlaybackState(Transport::PlaybackPlaying);
void GaplessTransport::OnPlaybackStarted(Player* player) {
this->RaiseStreamEvent(GaplessTransport::StreamPlaying, player);
this->SetPlaybackState(GaplessTransport::PlaybackPlaying);
}
void Transport::OnPlaybackAlmostEnded(Player* player) {
void GaplessTransport::OnPlaybackAlmostEnded(Player* player) {
this->SetNextCanStart(true);
this->RaiseStreamEvent(Transport::StreamAlmostDone, player);
this->RaiseStreamEvent(GaplessTransport::StreamAlmostDone, player);
{
boost::recursive_mutex::scoped_lock lock(this->stateMutex);
@ -310,9 +310,9 @@ void Transport::OnPlaybackAlmostEnded(Player* player) {
}
}
void Transport::OnPlaybackFinished(Player* player) {
void GaplessTransport::OnPlaybackFinished(Player* player) {
this->SetNextCanStart(true);
this->RaiseStreamEvent(Transport::StreamFinished, player);
this->RaiseStreamEvent(GaplessTransport::StreamFinished, player);
bool stopped = false;
@ -341,17 +341,17 @@ void Transport::OnPlaybackFinished(Player* player) {
this->Stop();
}
DEFER(&Transport::RemoveActive, player);
DEFER(&GaplessTransport::RemoveActive, player);
}
void Transport::OnPlaybackError(Player* player) {
void GaplessTransport::OnPlaybackError(Player* player) {
this->SetNextCanStart(true);
this->RaiseStreamEvent(Transport::StreamError, player);
this->SetPlaybackState(Transport::PlaybackStopped);
DEFER(&Transport::RemoveActive, player);
this->RaiseStreamEvent(GaplessTransport::StreamError, player);
this->SetPlaybackState(GaplessTransport::PlaybackStopped);
DEFER(&GaplessTransport::RemoveActive, player);
}
void Transport::SetPlaybackState(int state) {
void GaplessTransport::SetPlaybackState(int state) {
bool changed = false;
{
@ -365,6 +365,6 @@ void Transport::SetPlaybackState(int state) {
}
}
void Transport::RaiseStreamEvent(int type, Player* player) {
void GaplessTransport::RaiseStreamEvent(int type, Player* player) {
this->StreamEvent(type, player->GetUrl());
}

View File

@ -35,6 +35,7 @@
#pragma once
#include <core/config.h>
#include <core/audio/ITransport.h>
#include <core/audio/Player.h>
#include <core/sdk/IOutput.h>
#include <boost/shared_ptr.hpp>
@ -44,45 +45,25 @@
namespace musik { namespace core { namespace audio {
class Transport : public sigslot::has_slots<> {
class GaplessTransport : public ITransport, public sigslot::has_slots<> {
public:
sigslot::signal2<int, std::string> StreamEvent;
sigslot::signal1<int> PlaybackEvent;
sigslot::signal0<> VolumeChanged;
sigslot::signal1<double> TimeChanged;
GaplessTransport();
virtual ~GaplessTransport();
typedef enum {
PlaybackStopped,
PlaybackPaused,
PlaybackPlaying
} PlaybackState;
virtual void PrepareNextTrack(const std::string& trackUrl);
typedef enum {
StreamScheduled = 0,
StreamPlaying = 1,
StreamAlmostDone = 4,
StreamFinished = 5,
StreamStopped = 6,
StreamError = -1
} StreamEventType;
virtual void Start(const std::string& trackUrl);
virtual void Stop();
virtual bool Pause();
virtual bool Resume();
Transport();
~Transport();
virtual double Position();
virtual void SetPosition(double seconds);
void PrepareNextTrack(const std::string& trackUrl);
virtual double Volume();
virtual void SetVolume(double volume);
void Start(const std::string& trackUrl);
void Stop();
bool Pause();
bool Resume();
double Position();
void SetPosition(double seconds);
double Volume();
void SetVolume(double volume);
PlaybackState GetPlaybackState();
virtual PlaybackState GetPlaybackState();
private:
void StartWithPlayer(Player* player);

82
src/core/audio/ITransport.h Executable file
View File

@ -0,0 +1,82 @@
//////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2007-2016 musikcube team
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the author nor the names of other contributors may
// be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include <core/config.h>
#include <sigslot/sigslot.h>
namespace musik { namespace core { namespace audio {
class ITransport {
public:
sigslot::signal2<int, std::string> StreamEvent;
sigslot::signal1<int> PlaybackEvent;
sigslot::signal0<> VolumeChanged;
sigslot::signal1<double> TimeChanged;
typedef enum {
PlaybackStopped,
PlaybackPaused,
PlaybackPlaying
} PlaybackState;
typedef enum {
StreamScheduled = 0,
StreamPlaying = 1,
StreamAlmostDone = 4,
StreamFinished = 5,
StreamStopped = 6,
StreamError = -1
} StreamEventType;
virtual ~ITransport() { }
virtual void PrepareNextTrack(const std::string& trackUrl) = 0;
virtual void Start(const std::string& trackUrl) = 0;
virtual void Stop() = 0;
virtual bool Pause() = 0;
virtual bool Resume() = 0;
virtual double Position() = 0;
virtual void SetPosition(double seconds) = 0;
virtual double Volume() = 0;
virtual void SetVolume(double volume) = 0;
virtual PlaybackState GetPlaybackState() = 0;
};
} } }

View File

@ -1,227 +0,0 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Name="audio"
ProjectGUID="{F38DCF32-C2DB-4222-A2F5-1CA1C6C39CAF}"
RootNamespace="audioengine"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)/bin/$(ConfigurationName)"
IntermediateDirectory="$(SolutionDir)/obj/$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../3rdparty/include/sigslot"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;AUDIOENGINE_EXPORTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
AdditionalDependencies="winmm.lib shlwapi.lib"
AdditionalLibraryDirectories=""
IgnoreDefaultLibraryNames=""
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)/bin/$(ConfigurationName)"
IntermediateDirectory="$(SolutionDir)/obj/$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../3rdparty/include/sigslot"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;AUDIOENGINE_EXPORTS"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
AdditionalDependencies="winmm.lib shlwapi.lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\AudioOutput.cpp"
>
</File>
<File
RelativePath=".\AudioPacketizer.cpp"
>
</File>
<File
RelativePath=".\AudioStream.cpp"
>
</File>
<File
RelativePath=".\StdAfx.cpp"
>
</File>
<File
RelativePath=".\Transport.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\AudioOutput.h"
>
</File>
<File
RelativePath=".\AudioPacketizer.h"
>
</File>
<File
RelativePath=".\AudioStream.h"
>
</File>
<File
RelativePath=".\CriticalSection.h"
>
</File>
<File
RelativePath=".\IAudioCallback.h"
>
</File>
<File
RelativePath=".\IAudioSource.h"
>
</File>
<File
RelativePath=".\StdAfx.h"
>
</File>
<File
RelativePath=".\Transport.h"
>
</File>
<File
RelativePath=".\tstl.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -84,6 +84,7 @@
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="audio\GaplessTransport.cpp" />
<ClCompile Include="debug.cpp" />
<ClCompile Include="io\DataStreamFactory.cpp" />
<ClCompile Include="io\LocalFileStream.cpp" />
@ -103,18 +104,19 @@
<ClCompile Include="db\Connection.cpp" />
<ClCompile Include="db\ScopedTransaction.cpp" />
<ClCompile Include="db\Statement.cpp" />
<ClCompile Include="playback\NonLibraryTrackHelper.cpp" />
<ClCompile Include="playback\Transport.cpp" />
<ClCompile Include="audio\Buffer.cpp" />
<ClCompile Include="audio\Player.cpp" />
<ClCompile Include="audio\Stream.cpp" />
<ClCompile Include="plugin\PluginFactory.cpp" />
<ClCompile Include="support\Common.cpp" />
<ClCompile Include="support\NonLibraryTrackHelper.cpp" />
<ClCompile Include="support\Preferences.cpp" />
<ClCompile Include="support\ThreadHelper.cpp" />
<ClCompile Include="support\Version.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="audio\GaplessTransport.h" />
<ClInclude Include="audio\ITransport.h" />
<ClInclude Include="debug.h" />
<ClInclude Include="io\DataStreamFactory.h" />
<ClInclude Include="io\LocalFileStream.h" />
@ -132,8 +134,6 @@
<ClInclude Include="library\track\Track.h" />
<ClInclude Include="pch.hpp" />
<ClInclude Include="config.h" />
<ClInclude Include="playback\NonLibraryTrackHelper.h" />
<ClInclude Include="playback\Transport.h" />
<ClInclude Include="plugin\PluginFactory.h" />
<ClInclude Include="sdk\config.h" />
<ClInclude Include="sdk\IAnalyzer.h" />
@ -157,6 +157,7 @@
<ClInclude Include="audio\Player.h" />
<ClInclude Include="audio\Stream.h" />
<ClInclude Include="support\Common.h" />
<ClInclude Include="support\NonLibraryTrackHelper.h" />
<ClInclude Include="support\Preferences.h" />
<ClInclude Include="support\ThreadHelper.h" />
<ClInclude Include="support\Version.h" />

View File

@ -29,9 +29,6 @@
<Filter Include="src\library\track">
<UniqueIdentifier>{a9c7acb5-36af-4bfc-bbf0-b26f2f482d26}</UniqueIdentifier>
</Filter>
<Filter Include="src\playback">
<UniqueIdentifier>{0e929af8-372d-4326-a4c6-796ec5c709d4}</UniqueIdentifier>
</Filter>
<Filter Include="src\plugin">
<UniqueIdentifier>{928fef19-2739-4485-83ae-1e18892247b0}</UniqueIdentifier>
</Filter>
@ -82,9 +79,6 @@
<ClCompile Include="support\Common.cpp">
<Filter>src\support</Filter>
</ClCompile>
<ClCompile Include="playback\Transport.cpp">
<Filter>src\playback</Filter>
</ClCompile>
<ClCompile Include="library\Indexer.cpp">
<Filter>src\library</Filter>
</ClCompile>
@ -106,9 +100,6 @@
<ClCompile Include="support\Version.cpp">
<Filter>src\support</Filter>
</ClCompile>
<ClCompile Include="playback\NonLibraryTrackHelper.cpp">
<Filter>src\playback</Filter>
</ClCompile>
<ClCompile Include="library\metadata\MetadataValue.cpp">
<Filter>src\library\metadata</Filter>
</ClCompile>
@ -118,6 +109,12 @@
<ClCompile Include="library\LocalLibrary.cpp">
<Filter>src\library</Filter>
</ClCompile>
<ClCompile Include="support\NonLibraryTrackHelper.cpp">
<Filter>src\support</Filter>
</ClCompile>
<ClCompile Include="audio\GaplessTransport.cpp">
<Filter>src\audio</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.hpp">
@ -192,9 +189,6 @@
<ClInclude Include="support\ThreadHelper.h">
<Filter>src\support</Filter>
</ClInclude>
<ClInclude Include="playback\Transport.h">
<Filter>src\playback</Filter>
</ClInclude>
<ClInclude Include="library\Indexer.h">
<Filter>src\library</Filter>
</ClInclude>
@ -216,9 +210,6 @@
<ClInclude Include="support\Version.h">
<Filter>src\support</Filter>
</ClInclude>
<ClInclude Include="playback\NonLibraryTrackHelper.h">
<Filter>src\playback</Filter>
</ClInclude>
<ClInclude Include="library\metadata\MetadataValue.h">
<Filter>src\library\metadata</Filter>
</ClInclude>
@ -255,5 +246,14 @@
<ClInclude Include="library\LocalLibraryConstants.h">
<Filter>src\library</Filter>
</ClInclude>
<ClInclude Include="support\NonLibraryTrackHelper.h">
<Filter>src\support</Filter>
</ClInclude>
<ClInclude Include="audio\ITransport.h">
<Filter>src\audio</Filter>
</ClInclude>
<ClInclude Include="audio\GaplessTransport.h">
<Filter>src\audio</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -34,7 +34,7 @@
#include "pch.hpp"
#include <core/playback/NonLibraryTrackHelper.h>
#include "NonLibraryTrackHelper.h"
#include <boost/bind.hpp>
#include <core/plugin/PluginFactory.h>
#include <core/sdk/IMetadataReader.h>

View File

@ -56,6 +56,7 @@
#include <core/plugin/PluginFactory.h>
#include <core/library/LibraryFactory.h>
#include <core/audio/GaplessTransport.h>
#include <boost/chrono.hpp>
#include <cstdio>
@ -237,7 +238,7 @@ int main(int argc, char* argv[])
{
Colors::Init();
Transport tp;
GaplessTransport tp;
tp.SetVolume(0.75);
PlaybackService playback(tp);

View File

@ -41,7 +41,6 @@
#include <app/window/TransportWindow.h>
#include <app/service/PlaybackService.h>
#include <core/playback/Transport.h>
#include <core/library/ILibrary.h>
#include <sigslot/sigslot.h>

View File

@ -45,7 +45,7 @@ using namespace musik::core::audio;
using namespace musik::box;
using namespace cursespp;
ConsoleLayout::ConsoleLayout(Transport& transport, LibraryPtr library)
ConsoleLayout::ConsoleLayout(ITransport& transport, LibraryPtr library)
: LayoutBase() {
this->logs.reset(new LogWindow(this));
this->output.reset(new OutputWindow(this));

View File

@ -44,7 +44,7 @@
#include <vector>
#include <core/playback/Transport.h>
#include <core/audio/ITransport.h>
#include <boost/shared_ptr.hpp>
namespace musik {
@ -52,7 +52,7 @@ namespace musik {
class ConsoleLayout : public cursespp::LayoutBase {
public:
ConsoleLayout(
musik::core::audio::Transport& transport,
musik::core::audio::ITransport& transport,
musik::core::LibraryPtr library);
~ConsoleLayout();

View File

@ -152,10 +152,10 @@ bool LibraryLayout::KeyPress(const std::string& key) {
/* copied from GlobalHotkeys. should probably be generalized
at some point. */
int state = this->transport.GetPlaybackState();
if (state == Transport::PlaybackPaused) {
if (state == ITransport::PlaybackPaused) {
this->transport.Resume();
}
else if (state == Transport::PlaybackPlaying) {
else if (state == ITransport::PlaybackPlaying) {
this->transport.Pause();
}
}

View File

@ -42,7 +42,6 @@
#include <app/window/TransportWindow.h>
#include <app/service/PlaybackService.h>
#include <core/playback/Transport.h>
#include <core/library/ILibrary.h>
#include <sigslot/sigslot.h>
@ -72,7 +71,7 @@ namespace musik {
void ChangeMainLayout(std::shared_ptr<cursespp::LayoutBase> newLayout);
PlaybackService& playback;
musik::core::audio::Transport& transport;
musik::core::audio::ITransport& transport;
musik::core::LibraryPtr library;
std::shared_ptr<BrowseLayout> browseLayout;
std::shared_ptr<TransportWindow> transportView;

View File

@ -41,7 +41,6 @@
#include <app/window/TransportWindow.h>
#include <app/service/PlaybackService.h>
#include <core/playback/Transport.h>
#include <core/library/ILibrary.h>
#include <sigslot/sigslot.h>

View File

@ -38,11 +38,11 @@
#include <cursespp/MessageQueue.h>
#include <cursespp/Message.h>
#include <core/playback/Transport.h>
#include <core/audio/ITransport.h>
#include <core/library/LocalLibraryConstants.h>
using musik::core::TrackPtr;
using musik::core::audio::Transport;
using musik::core::audio::ITransport;
using cursespp::IMessageTarget;
using cursespp::IMessage;
@ -56,7 +56,7 @@ using namespace musik::box;
#define MESSAGE_STREAM_EVENT 1000
#define MESSAGE_PLAYBACK_EVENT 1001
PlaybackService::PlaybackService(Transport& transport)
PlaybackService::PlaybackService(ITransport& transport)
: transport(transport) {
transport.StreamEvent.connect(this, &PlaybackService::OnStreamEvent);
transport.PlaybackEvent.connect(this, &PlaybackService::OnPlaybackEvent);
@ -68,7 +68,7 @@ void PlaybackService::ProcessMessage(IMessage &message) {
if (message.Type() == MESSAGE_STREAM_EVENT) {
int64 eventType = message.UserData1();
if (eventType == Transport::StreamAlmostDone) {
if (eventType == ITransport::StreamAlmostDone) {
if (this->playlist.size() > this->index + 1) {
if (this->nextIndex != this->index + 1) {
this->nextIndex = this->index + 1;
@ -76,7 +76,7 @@ void PlaybackService::ProcessMessage(IMessage &message) {
}
}
}
else if (eventType == Transport::StreamPlaying) {
else if (eventType == ITransport::StreamPlaying) {
if (this->nextIndex != NO_POSITION) {
this->index = this->nextIndex;
this->nextIndex = NO_POSITION;
@ -90,14 +90,14 @@ void PlaybackService::ProcessMessage(IMessage &message) {
else if (message.Type() == MESSAGE_PLAYBACK_EVENT) {
int64 eventType = message.UserData1();
if (eventType == Transport::PlaybackStopped) {
if (eventType == ITransport::PlaybackStopped) {
this->TrackChanged(NO_POSITION, TrackPtr());
}
}
}
bool PlaybackService::Next() {
if (transport.GetPlaybackState() == Transport::PlaybackStopped) {
if (transport.GetPlaybackState() == ITransport::PlaybackStopped) {
return false;
}
@ -110,7 +110,7 @@ bool PlaybackService::Next() {
}
bool PlaybackService::Previous() {
if (transport.GetPlaybackState() == Transport::PlaybackStopped) {
if (transport.GetPlaybackState() == ITransport::PlaybackStopped) {
return false;
}

View File

@ -39,7 +39,7 @@
#include <cursespp/IMessageTarget.h>
#include <core/library/track/Track.h>
#include <core/playback/Transport.h>
#include <core/audio/ITransport.h>
#include <boost/thread/recursive_mutex.hpp>
@ -49,12 +49,12 @@ namespace musik {
public:
sigslot::signal2<size_t, musik::core::TrackPtr> TrackChanged;
PlaybackService(musik::core::audio::Transport& transport);
PlaybackService(musik::core::audio::ITransport& transport);
virtual bool IsAcceptingMessages() { return true; }
virtual void ProcessMessage(cursespp::IMessage &message);
musik::core::audio::Transport& GetTransport() { return this->transport; }
musik::core::audio::ITransport& GetTransport() { return this->transport; }
void Play(std::vector<musik::core::TrackPtr>& tracks, size_t index);
void Play(size_t index);
@ -72,7 +72,7 @@ namespace musik {
void OnStreamEvent(int eventType, std::string uri);
void OnPlaybackEvent(int eventType);
musik::core::audio::Transport& transport;
musik::core::audio::ITransport& transport;
boost::recursive_mutex stateMutex;
std::vector<musik::core::TrackPtr> playlist;
size_t index, nextIndex;

View File

@ -36,7 +36,7 @@
#include "GlobalHotkeys.h"
using musik::core::LibraryPtr;
using musik::core::audio::Transport;
using musik::core::audio::ITransport;
using namespace musik::box;
GlobalHotkeys::GlobalHotkeys(PlaybackService& playback, LibraryPtr library)
@ -52,10 +52,10 @@ GlobalHotkeys::~GlobalHotkeys() {
bool GlobalHotkeys::Handle(const std::string& kn) {
if (kn == "^P") {
int state = this->transport.GetPlaybackState();
if (state == Transport::PlaybackPaused) {
if (state == ITransport::PlaybackPaused) {
this->transport.Resume();
}
else if (state == Transport::PlaybackPlaying) {
else if (state == ITransport::PlaybackPlaying) {
this->transport.Pause();
}
return true;

View File

@ -53,7 +53,7 @@ namespace musik {
private:
PlaybackService& playback;
musik::core::audio::Transport& transport;
musik::core::audio::ITransport& transport;
musik::core::LibraryPtr library;
};
}

View File

@ -36,8 +36,6 @@
#include "stdafx.h"
#include <core/playback/Transport.h>
namespace musik {
namespace box {
namespace text {

View File

@ -78,7 +78,7 @@ inline static void redrawContents(IWindow &window, const std::string& text) {
CommandWindow::CommandWindow(
IWindow *parent,
Transport& transport,
ITransport& transport,
LibraryPtr library,
OutputWindow& output,
LogWindow& logWindow)

View File

@ -37,8 +37,8 @@
#include <cursespp/curses_config.h>
#include <cursespp/Window.h>
#include <cursespp/IInput.h>
#include <core/playback/Transport.h>
#include <core/library/LibraryFactory.h>
#include <core/audio/ITransport.h>
#include "OutputWindow.h"
#include "LogWindow.h"
@ -55,7 +55,7 @@ namespace musik {
public:
CommandWindow(
cursespp::IWindow *parent,
musik::core::audio::Transport& transport,
musik::core::audio::ITransport& transport,
musik::core::LibraryPtr library,
OutputWindow& output,
LogWindow& logWindow);
@ -84,7 +84,7 @@ namespace musik {
OutputWindow* output;
LogWindow* logWindow;
musik::core::audio::Transport* transport;
musik::core::audio::ITransport* transport;
musik::core::LibraryPtr library;
bool paused;
};

View File

@ -42,7 +42,6 @@
#include <app/query/TrackListQueryBase.h>
#include <app/service/PlaybackService.h>
#include <core/playback/Transport.h>
#include <core/library/ILibrary.h>
namespace musik {

View File

@ -123,8 +123,8 @@ void TransportWindow::Update() {
this->Clear();
WINDOW *c = this->GetContent();
bool paused = (transport.GetPlaybackState() == Transport::PlaybackPaused);
bool stopped = (transport.GetPlaybackState() == Transport::PlaybackStopped);
bool paused = (transport.GetPlaybackState() == ITransport::PlaybackPaused);
bool stopped = (transport.GetPlaybackState() == ITransport::PlaybackStopped);
int64 gb = COLOR_PAIR(BOX_COLOR_GREEN_ON_BLACK);

View File

@ -67,7 +67,7 @@ namespace musik {
void OnTransportTimeChanged(double time);
bool paused, focused;
musik::core::audio::Transport& transport;
musik::core::audio::ITransport& transport;
musik::box::PlaybackService& playback;
musik::core::TrackPtr currentTrack;
};