* 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:
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002 David Shipman,
|
* Copyright 2002 David Shipman,
|
||||||
* Copyright 2003-2007 Marcus Overhagen
|
* 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.
|
* 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
|
#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)
|
AudioMixer::AudioMixer(BMediaAddOn *addOn, bool isSystemMixer)
|
||||||
:
|
:
|
||||||
BMediaNode("Audio Mixer"),
|
BMediaNode("Audio Mixer"),
|
||||||
@@ -312,7 +316,7 @@ AudioMixer::HandleInputBuffer(BBuffer* buffer, bigtime_t lateness)
|
|||||||
if (RunMode() == B_DROP_DATA || RunMode() == B_DECREASE_PRECISION
|
if (RunMode() == B_DROP_DATA || RunMode() == B_DECREASE_PRECISION
|
||||||
|| RunMode() == B_INCREASE_LATENCY) {
|
|| RunMode() == B_INCREASE_LATENCY) {
|
||||||
debug_printf("sending notify\n");
|
debug_printf("sending notify\n");
|
||||||
|
|
||||||
// Build a media_source out of the header data
|
// Build a media_source out of the header data
|
||||||
media_source source = media_source::null;
|
media_source source = media_source::null;
|
||||||
source.port = buffer->Header()->source_port;
|
source.port = buffer->Header()->source_port;
|
||||||
@@ -944,13 +948,13 @@ AudioMixer::Connect(status_t error, const media_source &source,
|
|||||||
|
|
||||||
|
|
||||||
void
|
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");
|
TRACE("AudioMixer::Disconnect\n");
|
||||||
fCore->Lock();
|
fCore->Lock();
|
||||||
|
|
||||||
// Make sure that our connection is the one being disconnected
|
// Make sure that our connection is the one being disconnected
|
||||||
MixerOutput * output = fCore->Output();
|
MixerOutput* output = fCore->Output();
|
||||||
if (!output
|
if (!output
|
||||||
|| output->MediaOutput().node != Node()
|
|| output->MediaOutput().node != Node()
|
||||||
|| output->MediaOutput().source != what
|
|| output->MediaOutput().source != what
|
||||||
@@ -999,6 +1003,11 @@ AudioMixer::LateNoticeReceived(const media_source& what, bigtime_t howMuch,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
fInternalLatency += howMuch;
|
fInternalLatency += howMuch;
|
||||||
|
|
||||||
|
// At some point a too large latency can get annoying
|
||||||
|
if (fInternalLatency > kMaxLatency)
|
||||||
|
fInternalLatency = kMaxLatency;
|
||||||
|
|
||||||
fLastLateNotification = TimeSource()->Now();
|
fLastLateNotification = TimeSource()->Now();
|
||||||
|
|
||||||
debug_printf("AudioMixer: increasing internal latency to %Ld usec\n", fInternalLatency);
|
debug_printf("AudioMixer: increasing internal latency to %Ld usec\n", fInternalLatency);
|
||||||
|
|||||||
@@ -2,8 +2,9 @@
|
|||||||
* Copyright (c) 1998-99, Be Incorporated, All Rights Reserved.
|
* Copyright (c) 1998-99, Be Incorporated, All Rights Reserved.
|
||||||
* Distributed under the terms of the Be Sample Code license.
|
* Distributed under the terms of the Be Sample Code license.
|
||||||
*
|
*
|
||||||
* Copyright (c) 2000-2008, Ingo Weinhold <ingo_weinhold@gmx.de>,
|
* Copyright 2010, Axel Dörfler, axeld@pinc-software.de.
|
||||||
* Copyright (c) 2000-2008, Stephan Aßmus <superstippi@gmx.de>,
|
* Copyright 2000-2008, Ingo Weinhold <ingo_weinhold@gmx.de>,
|
||||||
|
* Copyright 2000-2008, Stephan Aßmus <[email protected]>,
|
||||||
* All Rights Reserved. Distributed under the terms of the MIT license.
|
* All Rights Reserved. Distributed under the terms of the MIT license.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -47,6 +48,10 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
const static bigtime_t kMaxLatency = 150000;
|
||||||
|
// 150 ms is the maximum latency we publish
|
||||||
|
|
||||||
|
|
||||||
#if DEBUG_TO_FILE
|
#if DEBUG_TO_FILE
|
||||||
static BMediaFile*
|
static BMediaFile*
|
||||||
init_media_file(media_format format, BMediaTrack** _track)
|
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) {
|
} else if (RunMode() == B_INCREASE_LATENCY) {
|
||||||
fInternalLatency += howMuch;
|
fInternalLatency += howMuch;
|
||||||
|
|
||||||
|
// At some point a too large latency can get annoying
|
||||||
|
if (fInternalLatency > kMaxLatency)
|
||||||
|
fInternalLatency = kMaxLatency;
|
||||||
|
|
||||||
SetEventLatency(fLatency + fInternalLatency);
|
SetEventLatency(fLatency + fInternalLatency);
|
||||||
} else {
|
} else {
|
||||||
size_t sampleSize
|
size_t sampleSize
|
||||||
|
|||||||
Reference in New Issue
Block a user