From e681a8f9e90625a291b442882add4072dc0c2d8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Sun, 27 Jan 2008 13:09:11 +0000 Subject: [PATCH] Another fix for problematic sound card setup... should have been part of the last commit. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23765 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/mediaplayer/SoundOutput.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/apps/mediaplayer/SoundOutput.cpp b/src/apps/mediaplayer/SoundOutput.cpp index bbf12b3132..02dcc99785 100644 --- a/src/apps/mediaplayer/SoundOutput.cpp +++ b/src/apps/mediaplayer/SoundOutput.cpp @@ -73,9 +73,12 @@ SoundOutput::Format() const bigtime_t SoundOutput::Latency() { + bigtime_t latency = 0; + if (InitCheck() >= B_OK) + latency += fSoundPlayer->Latency(); // Because of buffering, latency of SoundOutput is // slightly higher then the BSoundPlayer latency. - return fSoundPlayer->Latency() + min_c(1000, fBufferDuration / 4); + return latency + min_c(1000, fBufferDuration / 4); } @@ -99,10 +102,12 @@ SoundOutput::Play(const void *data, size_t size) ASSERT(size > 0 && size <= fBufferSize); acquire_sem(fBufferWriteable); memcpy(fBuffer, data, size); + size_t fillsize = fBufferSize - size; if (fillsize) memset(fBuffer + size, 0, fillsize); release_sem(fBufferReadable); + if (!fIsPlaying) { fSoundPlayer->SetHasData(true); fSoundPlayer->Start();