* We now limit the maximum latency in MediaPlayer and the audio mixer, as a

latency can easily get annoying if too high.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36200 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2010-04-12 20:53:15 +00:00
parent 8dd3060da4
commit d0085d25d1
2 changed files with 25 additions and 6 deletions

View File

@ -1,7 +1,7 @@
/*
* Copyright 2002 David Shipman,
* Copyright 2003-2007 Marcus Overhagen
* Copyright 2007-2009 Haiku Inc. All rights reserved.
* Copyright 2007-2010 Haiku Inc. All rights reserved.
*
* Distributed under the terms of the MIT License.
*/
@ -87,6 +87,10 @@ multi_audio_format_specialize(media_multi_audio_format *format,
#define FORMAT_USER_DATA_MAGIC_2 0x4af62b7d
const static bigtime_t kMaxLatency = 150000;
// 150 ms is the maximum latency we publish
AudioMixer::AudioMixer(BMediaAddOn *addOn, bool isSystemMixer)
:
BMediaNode("Audio Mixer"),
@ -312,7 +316,7 @@ AudioMixer::HandleInputBuffer(BBuffer* buffer, bigtime_t lateness)
if (RunMode() == B_DROP_DATA || RunMode() == B_DECREASE_PRECISION
|| RunMode() == B_INCREASE_LATENCY) {
debug_printf("sending notify\n");
// Build a media_source out of the header data
media_source source = media_source::null;
source.port = buffer->Header()->source_port;
@ -944,13 +948,13 @@ AudioMixer::Connect(status_t error, const media_source &source,
void
AudioMixer::Disconnect(const media_source &what, const media_destination &where)
AudioMixer::Disconnect(const media_source& what, const media_destination& where)
{
TRACE("AudioMixer::Disconnect\n");
fCore->Lock();
// Make sure that our connection is the one being disconnected
MixerOutput * output = fCore->Output();
MixerOutput* output = fCore->Output();
if (!output
|| output->MediaOutput().node != Node()
|| output->MediaOutput().source != what
@ -999,6 +1003,11 @@ AudioMixer::LateNoticeReceived(const media_source& what, bigtime_t howMuch,
return;
fInternalLatency += howMuch;
// At some point a too large latency can get annoying
if (fInternalLatency > kMaxLatency)
fInternalLatency = kMaxLatency;
fLastLateNotification = TimeSource()->Now();
debug_printf("AudioMixer: increasing internal latency to %Ld usec\n", fInternalLatency);

View File

@ -2,8 +2,9 @@
* Copyright (c) 1998-99, Be Incorporated, All Rights Reserved.
* Distributed under the terms of the Be Sample Code license.
*
* Copyright (c) 2000-2008, Ingo Weinhold <ingo_weinhold@gmx.de>,
* Copyright (c) 2000-2008, Stephan Aßmus <superstippi@gmx.de>,
* Copyright 2010, Axel Dörfler, axeld@pinc-software.de.
* Copyright 2000-2008, Ingo Weinhold <ingo_weinhold@gmx.de>,
* Copyright 2000-2008, Stephan Aßmus <superstippi@gmx.de>,
* All Rights Reserved. Distributed under the terms of the MIT license.
*/
@ -47,6 +48,10 @@
#endif
const static bigtime_t kMaxLatency = 150000;
// 150 ms is the maximum latency we publish
#if DEBUG_TO_FILE
static BMediaFile*
init_media_file(media_format format, BMediaTrack** _track)
@ -507,6 +512,11 @@ AudioProducer::LateNoticeReceived(const media_source& what, bigtime_t howMuch,
// ...
} else if (RunMode() == B_INCREASE_LATENCY) {
fInternalLatency += howMuch;
// At some point a too large latency can get annoying
if (fInternalLatency > kMaxLatency)
fInternalLatency = kMaxLatency;
SetEventLatency(fLatency + fInternalLatency);
} else {
size_t sampleSize