Don't wait indefinitely for WaveOut to close, and also fixed a stop-related bug.

This commit is contained in:
casey 2016-06-01 00:30:46 -07:00
parent 76445b658f
commit 916823000c
3 changed files with 9 additions and 7 deletions

View File

@ -150,7 +150,7 @@ void WaveOut::StartWaveOutThread() {
void WaveOut::StopWaveOutThread() {
if (this->threadHandle != NULL) {
PostThreadMessage(this->threadId, WM_QUIT, 0, 0);
WaitForSingleObject(this->threadHandle, INFINITE);
WaitForSingleObject(this->threadHandle, 5000);
this->threadHandle = NULL;
this->threadId = 0;
}

View File

@ -96,8 +96,6 @@ void Transport::Start(const std::string& url) {
void Transport::StartWithPlayer(Player* newPlayer) {
if (newPlayer) {
this->Stop(true); /* suppress the "Stopped" event */
{
boost::recursive_mutex::scoped_lock lock(this->stateMutex);
@ -106,6 +104,7 @@ void Transport::StartWithPlayer(Player* newPlayer) {
}
this->nextPlayer = NULL;
this->Stop(true); /* suppress the "Stopped" event */
newPlayer->PlaybackStarted.connect(this, &Transport::OnPlaybackStarted);
newPlayer->PlaybackAlmostEnded.connect(this, &Transport::OnPlaybackAlmostEnded);

View File

@ -90,15 +90,18 @@ void TransportWindow::Update() {
WINDOW *c = this->GetContent();
bool paused = (transport.GetPlaybackState() == Transport::PlaybackPaused);
bool stopped = (transport.GetPlaybackState() == Transport::PlaybackStopped);
int64 gb = COLOR_PAIR(this->focused
? BOX_COLOR_RED_ON_BLACK
: BOX_COLOR_GREEN_ON_BLACK);
int64 gb = COLOR_PAIR(BOX_COLOR_GREEN_ON_BLACK);
if (focused) {
gb = COLOR_PAIR(BOX_COLOR_RED_ON_BLACK);
}
/* playing SONG TITLE from ALBUM NAME */
std::string duration = "0";
if (transport.GetPlaybackState() == Transport::PlaybackStopped) {
if (stopped) {
wattron(c, gb);
wprintw(c, "playback is stopped");
wattroff(c, gb);