mirror of
https://github.com/clangen/musikcube.git
synced 2025-02-06 03:39:50 +00:00
- Fixed waveout plugin to ensure all buffers are cleared before new ones
are accepted. - Started working on CTRL+UP, CTRL+DOWN library focusing.
This commit is contained in:
parent
fcfe17c49b
commit
3968e39f7f
@ -56,23 +56,22 @@ WaveOut::~WaveOut() {
|
||||
}
|
||||
|
||||
void WaveOut::Destroy() {
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(this->outputDeviceMutex);
|
||||
boost::recursive_mutex::scoped_lock lock1(this->bufferQueueMutex);
|
||||
boost::recursive_mutex::scoped_lock lock2(this->outputDeviceMutex);
|
||||
|
||||
/* reset playback immediately. this will invalidate all pending
|
||||
buffers */
|
||||
if (this->waveHandle != NULL) {
|
||||
waveOutReset(this->waveHandle);
|
||||
}
|
||||
/* reset playback immediately. this will invalidate all pending
|
||||
buffers */
|
||||
if (this->waveHandle != NULL) {
|
||||
waveOutReset(this->waveHandle);
|
||||
}
|
||||
|
||||
/* stop the thread so nothing else is processed */
|
||||
this->StopWaveOutThread();
|
||||
/* stop the thread so nothing else is processed */
|
||||
this->StopWaveOutThread();
|
||||
|
||||
/* close it down after the threadproc has finished */
|
||||
if (this->waveHandle != NULL) {
|
||||
waveOutClose(this->waveHandle);
|
||||
this->waveHandle = NULL;
|
||||
}
|
||||
/* close it down after the threadproc has finished */
|
||||
if (this->waveHandle != NULL) {
|
||||
waveOutClose(this->waveHandle);
|
||||
this->waveHandle = NULL;
|
||||
}
|
||||
|
||||
this->ClearBufferQueue();
|
||||
@ -99,12 +98,11 @@ void WaveOut::SetVolume(double volume) {
|
||||
}
|
||||
|
||||
void WaveOut::Stop() {
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(this->outputDeviceMutex);
|
||||
boost::recursive_mutex::scoped_lock lock1(this->bufferQueueMutex);
|
||||
boost::recursive_mutex::scoped_lock lock2(this->outputDeviceMutex);
|
||||
|
||||
if (this->waveHandle != NULL) {
|
||||
waveOutReset(this->waveHandle);
|
||||
}
|
||||
if (this->waveHandle != NULL) {
|
||||
waveOutReset(this->waveHandle);
|
||||
}
|
||||
|
||||
this->ClearBufferQueue();
|
||||
|
@ -42,11 +42,6 @@ namespace musik { namespace core { namespace audio {
|
||||
class Stream;
|
||||
typedef std::shared_ptr<Buffer> BufferPtr;
|
||||
|
||||
//////////////////////////////////////////
|
||||
///\brief
|
||||
///Buffer is the only implementation of the IBuffer and is used
|
||||
///in the audioengine to pass along the raw audio data
|
||||
//////////////////////////////////////////
|
||||
class Buffer : public IBuffer {
|
||||
private:
|
||||
Buffer(void);
|
||||
|
@ -119,8 +119,6 @@ void Transport::StartWithPlayer(Player* newPlayer) {
|
||||
void Transport::Stop() {
|
||||
musik::debug::info(TAG, "stop");
|
||||
|
||||
PlayerPtr player = NULL;
|
||||
|
||||
std::list<Player*> toDelete;
|
||||
|
||||
{
|
||||
@ -136,9 +134,7 @@ void Transport::Stop() {
|
||||
std::for_each(toDelete.begin(), toDelete.end(), deletePlayer);
|
||||
this->active.clear();
|
||||
|
||||
if (player) {
|
||||
this->SetPlaybackState(PlaybackStopped);
|
||||
}
|
||||
this->SetPlaybackState(PlaybackStopped);
|
||||
}
|
||||
|
||||
bool Transport::Pause() {
|
||||
|
@ -11,16 +11,13 @@ using namespace musik::core::library::constants;
|
||||
|
||||
#define CATEGORY_WIDTH 25
|
||||
#define TRANSPORT_HEIGHT 3
|
||||
#define DEFAULT_CATEGORY Track::ALBUM_ID
|
||||
#define DEFAULT_CATEGORY constants::Track::ALBUM_ID
|
||||
|
||||
using namespace musik::core;
|
||||
using namespace musik::core::audio;
|
||||
using namespace musik::core::library;
|
||||
using namespace musik::box;
|
||||
|
||||
using musik::core::LibraryPtr;
|
||||
using musik::core::audio::Transport;
|
||||
|
||||
using cursespp::LayoutBase;
|
||||
using cursespp::ListWindow;
|
||||
using cursespp::Screen;
|
||||
using namespace cursespp;
|
||||
|
||||
LibraryLayout::LibraryLayout(PlaybackService& playback, LibraryPtr library)
|
||||
: LayoutBase()
|
||||
@ -69,6 +66,10 @@ void LibraryLayout::InitializeWindows() {
|
||||
this->Layout();
|
||||
}
|
||||
|
||||
IWindowPtr LibraryLayout::GetFocus() {
|
||||
return this->focused ? this->focused : LayoutBase::GetFocus();
|
||||
}
|
||||
|
||||
void LibraryLayout::Show() {
|
||||
LayoutBase::Show();
|
||||
this->categoryList->Requery();
|
||||
@ -97,18 +98,28 @@ bool LibraryLayout::KeyPress(int64 ch) {
|
||||
std::string kn = keyname((int)ch);
|
||||
|
||||
if (kn == "ALT_1") {
|
||||
this->categoryList->SetFieldName(Track::ARTIST_ID);
|
||||
this->categoryList->SetFieldName(constants::Track::ARTIST_ID);
|
||||
return true;
|
||||
}
|
||||
else if (kn == "ALT_2") {
|
||||
this->categoryList->SetFieldName(Track::ALBUM_ID);
|
||||
this->categoryList->SetFieldName(constants::Track::ALBUM_ID);
|
||||
return true;
|
||||
}
|
||||
else if (kn == "ALT_3") {
|
||||
this->categoryList->SetFieldName(Track::GENRE_ID);
|
||||
return true;
|
||||
this->categoryList->SetFieldName(constants::Track::GENRE_ID);
|
||||
return true;
|
||||
}
|
||||
else if (ch == KEY_F(5)) {
|
||||
else if (kn == "CTL_DOWN") {
|
||||
this->focused = this->transportView;
|
||||
this->transportView->Focus();
|
||||
}
|
||||
else if (kn == "CTL_UP") {
|
||||
if (this->focused) {
|
||||
this->focused->Blur();
|
||||
this->focused.reset();
|
||||
}
|
||||
}
|
||||
else if (ch == KEY_END) {
|
||||
this->categoryList->Requery();
|
||||
return true;
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ namespace musik {
|
||||
virtual void Layout();
|
||||
virtual void Show();
|
||||
virtual bool LibraryLayout::KeyPress(int64 ch);
|
||||
virtual cursespp::IWindowPtr GetFocus();
|
||||
|
||||
private:
|
||||
void InitializeWindows();
|
||||
@ -43,6 +44,7 @@ namespace musik {
|
||||
std::shared_ptr<CategoryListView> categoryList;
|
||||
std::shared_ptr<TrackListView> trackList;
|
||||
std::shared_ptr<TransportWindow> transportView;
|
||||
cursespp::IWindowPtr focused;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ void MainLayout::Show() {
|
||||
}
|
||||
|
||||
void MainLayout::ProcessMessage(IMessage &message) {
|
||||
if (message.MessageType() == MESSAGE_TYPE_UPDATE) {
|
||||
if (message.Type() == MESSAGE_TYPE_UPDATE) {
|
||||
this->UpdateWindows();
|
||||
this->PostMessage(MESSAGE_TYPE_UPDATE, 0, 0, UPDATE_INTERVAL_MS);
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ void CategoryListView::OnQueryCompleted(QueryPtr query) {
|
||||
}
|
||||
|
||||
void CategoryListView::ProcessMessage(IMessage &message) {
|
||||
if (message.MessageType() == WINDOW_MESSAGE_QUERY_COMPLETED) {
|
||||
if (message.Type() == WINDOW_MESSAGE_QUERY_COMPLETED) {
|
||||
this->metadata = activeQuery->GetResult();
|
||||
activeQuery.reset();
|
||||
this->OnAdapterChanged();
|
||||
|
@ -67,7 +67,7 @@ bool TrackListView::KeyPress(int64 ch) {
|
||||
}
|
||||
|
||||
void TrackListView::ProcessMessage(IMessage &message) {
|
||||
if (message.MessageType() == WINDOW_MESSAGE_QUERY_COMPLETED) {
|
||||
if (message.Type() == WINDOW_MESSAGE_QUERY_COMPLETED) {
|
||||
if (this->query && this->query->GetStatus() == IQuery::Finished) {
|
||||
this->metadata = this->query->GetResult();
|
||||
this->query.reset();
|
||||
|
@ -44,7 +44,7 @@ TransportWindow::TransportWindow(LibraryPtr library, Transport& transport)
|
||||
this->transport->StreamEvent.connect(this, &TransportWindow::OnTransportStreamEvent);
|
||||
this->transport->VolumeChanged.connect(this, &TransportWindow::OnTransportVolumeChanged);
|
||||
this->transport->TimeChanged.connect(this, &TransportWindow::OnTransportTimeChanged);
|
||||
this->paused = false;
|
||||
this->paused = this->focused = false;
|
||||
}
|
||||
|
||||
TransportWindow::~TransportWindow() {
|
||||
@ -56,7 +56,7 @@ void TransportWindow::Show() {
|
||||
}
|
||||
|
||||
void TransportWindow::ProcessMessage(IMessage &message) {
|
||||
int type = message.MessageType();
|
||||
int type = message.Type();
|
||||
|
||||
if (type == REFRESH_TRANSPORT_READOUT) {
|
||||
this->Update();
|
||||
@ -87,38 +87,59 @@ void TransportWindow::OnQueryCompleted(QueryPtr query) {
|
||||
}
|
||||
}
|
||||
|
||||
void TransportWindow::Focus() {
|
||||
this->focused = true;
|
||||
DEBOUNCE_REFRESH(0)
|
||||
}
|
||||
|
||||
void TransportWindow::Blur() {
|
||||
this->focused = false;
|
||||
DEBOUNCE_REFRESH(0)
|
||||
}
|
||||
|
||||
void TransportWindow::Update() {
|
||||
this->Clear();
|
||||
WINDOW *c = this->GetContent();
|
||||
|
||||
bool paused = (transport->GetPlaybackState() == Transport::PlaybackPaused);
|
||||
int64 gb = COLOR_PAIR(BOX_COLOR_GREEN_ON_BLACK);
|
||||
|
||||
int64 gb = COLOR_PAIR(this->focused
|
||||
? BOX_COLOR_RED_ON_BLACK
|
||||
: BOX_COLOR_GREEN_ON_BLACK);
|
||||
|
||||
/* playing SONG TITLE from ALBUM NAME */
|
||||
std::string duration = "0";
|
||||
|
||||
std::string title, album, duration;
|
||||
|
||||
if (this->currentTrack) {
|
||||
title = this->currentTrack->GetValue(constants::Track::TITLE);
|
||||
album = this->currentTrack->GetValue(constants::Track::ALBUM);
|
||||
duration = this->currentTrack->GetValue(constants::Track::DURATION);
|
||||
if (transport->GetPlaybackState() == Transport::PlaybackStopped) {
|
||||
wattron(c, gb);
|
||||
wprintw(c, "playback is stopped");
|
||||
wattroff(c, gb);
|
||||
}
|
||||
else {
|
||||
std::string title, album;
|
||||
|
||||
title = title.size() ? title : "song title";
|
||||
album = album.size() ? album : "album name";
|
||||
duration = duration.size() ? duration : "0";
|
||||
if (this->currentTrack) {
|
||||
title = this->currentTrack->GetValue(constants::Track::TITLE);
|
||||
album = this->currentTrack->GetValue(constants::Track::ALBUM);
|
||||
duration = this->currentTrack->GetValue(constants::Track::DURATION);
|
||||
}
|
||||
|
||||
wprintw(c, "playing ");
|
||||
title = title.size() ? title : "song title";
|
||||
album = album.size() ? album : "album name";
|
||||
duration = duration.size() ? duration : "0";
|
||||
|
||||
wattron(c, gb);
|
||||
wprintw(c, title.c_str());
|
||||
wattroff(c, gb);
|
||||
wprintw(c, "playing ");
|
||||
|
||||
wprintw(c, " from ");
|
||||
wattron(c, gb);
|
||||
wprintw(c, title.c_str());
|
||||
wattroff(c, gb);
|
||||
|
||||
wattron(c, gb);
|
||||
wprintw(c, album.c_str());
|
||||
wattroff(c, gb);
|
||||
wprintw(c, " from ");
|
||||
|
||||
wattron(c, gb);
|
||||
wprintw(c, album.c_str());
|
||||
wattroff(c, gb);
|
||||
}
|
||||
|
||||
/* volume slider */
|
||||
|
||||
|
@ -19,7 +19,11 @@ namespace musik {
|
||||
~TransportWindow();
|
||||
|
||||
virtual void ProcessMessage(cursespp::IMessage &message);
|
||||
|
||||
virtual void Show();
|
||||
virtual void Focus();
|
||||
virtual void Blur();
|
||||
|
||||
void Update();
|
||||
|
||||
private:
|
||||
@ -28,7 +32,7 @@ namespace musik {
|
||||
void OnTransportTimeChanged(double time);
|
||||
void OnQueryCompleted(musik::core::QueryPtr query);
|
||||
|
||||
bool paused;
|
||||
bool paused, focused;
|
||||
musik::core::LibraryPtr library;
|
||||
musik::core::audio::Transport* transport;
|
||||
musik::core::TrackPtr currentTrack;
|
||||
|
@ -11,7 +11,7 @@ namespace cursespp {
|
||||
public:
|
||||
virtual ~IMessage() = 0 { }
|
||||
virtual IMessageTarget* Target() = 0;
|
||||
virtual int MessageType() = 0;
|
||||
virtual int Type() = 0;
|
||||
virtual int64 UserData1() = 0;
|
||||
virtual int64 UserData2() = 0;
|
||||
};
|
||||
|
@ -28,7 +28,7 @@ IMessageTarget* Message::Target() {
|
||||
return this->target;
|
||||
}
|
||||
|
||||
int Message::MessageType() {
|
||||
int Message::Type() {
|
||||
return this->messageType;
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ namespace cursespp {
|
||||
int64 data2);
|
||||
|
||||
virtual IMessageTarget* Target();
|
||||
virtual int MessageType();
|
||||
virtual int Type();
|
||||
virtual int64 UserData1();
|
||||
virtual int64 UserData2();
|
||||
|
||||
|
@ -67,7 +67,7 @@ void MessageQueue::Remove(IMessageTarget *target, int type) {
|
||||
IMessagePtr current = (*it)->message;
|
||||
|
||||
if (current->Target() == target) {
|
||||
if (type == -1 || type == current->MessageType()) {
|
||||
if (type == -1 || type == current->Type()) {
|
||||
delete (*it);
|
||||
it = this->queue.erase(it);
|
||||
continue;
|
||||
|
Loading…
x
Reference in New Issue
Block a user