Permalink
Browse files

Fix two potential audio issues when the resampler is required. In som…

…e very narrow conditions, it would only resample part of the data required ; and second, could try to resample native AC3 or DTS raw data: fox example playing 44.1kHz AC3 on a machine only accepting 48kHz over HDMI (like ion)

git-svn-id: http://svn.mythtv.org/svn/branches/release-0-23-fixes@25135 7dbf422c-18fa-0310-86e9-fd20926502f2
  • Loading branch information...
1 parent ff32e1a commit 0e3f5bde53430b96cd4f156aef6fdbf323f6bcdf @jyavenard jyavenard committed Jun 18, 2010
@@ -49,6 +49,7 @@ class MPUBLIC AudioOutput : public VolumeBase, public OutputListeners
virtual void SetTimecode(long long timecode) = 0;
virtual bool IsPaused(void) const = 0;
virtual void Pause(bool paused) = 0;
+ virtual bool CanPassthrough(void) const = 0;
// Wait for all data to finish playing
virtual void Drain(void) = 0;
@@ -848,7 +848,8 @@ bool AudioOutputBase::AddSamples(char *buffer, int samples, long long timecode)
{
// Convert to floats
short *buf_ptr = (short*)buffer;
- for (int sample = 0; sample < samples * audio_channels; sample++)
+ int numSamples = (samples * abps) / sizeof(short);
+ for (int sample = 0; sample < numSamples; sample++)
{
src_in[sample] = (float)buf_ptr[sample] / (1.0 * 0x8000);
}
@@ -861,7 +862,7 @@ bool AudioOutputBase::AddSamples(char *buffer, int samples, long long timecode)
QString("Error occurred while resampling audio: %1")
.arg(src_strerror(error)));
src_float_to_short_array(src_data.data_out, (short int*)tmp_buff,
- src_data.output_frames_gen*audio_channels);
+ (src_data.output_frames_gen*abps)/sizeof(short));
_AddSamples(tmp_buff, true, src_data.output_frames_gen, timecode);
}
@@ -57,6 +57,7 @@ class AudioOutputBase : public AudioOutput, public QThread
virtual void SetTimecode(long long timecode);
virtual bool IsPaused(void) const { return audio_actually_paused; }
virtual void Pause(bool paused);
+ virtual bool CanPassthrough(void) const { return !need_resampler; }
// Wait for all data to finish playing
virtual void Drain(void);
@@ -5134,6 +5134,13 @@ bool NuppelVideoPlayer::ToggleUpmix()
return false;
}
+bool NuppelVideoPlayer::CanPassthrough()
+{
+ if (audioOutput)
+ return audioOutput->CanPassthrough();
+ return false;
+}
+
void NuppelVideoPlayer::Zoom(ZoomDirection direction)
{
if (videoOutput)
@@ -165,6 +165,7 @@ class MPUBLIC NuppelVideoPlayer : public CC608Reader, public CC708Reader
void ToggleAspectOverride(AspectOverrideMode aspectMode = kAspect_Toggle);
void ToggleAdjustFill(AdjustFillMode adjustfillMode = kAdjustFill_Toggle);
bool ToggleUpmix(void);
+ bool CanPassthrough(void);
// Gets
QSize GetVideoBufferSize(void) const { return video_dim; }
@@ -4639,6 +4639,7 @@ bool AvFormatDecoder::DoPassThrough(const AVCodecContext *ctx)
else if (ctx->codec_id == CODEC_ID_DTS)
passthru = allow_dts_passthru && !internal_vol;
+ passthru &= GetNVP()->CanPassthrough();
passthru &= !transcoding && !disable_passthru;
// Don't know any cards that support spdif clocked at < 44100
// Some US cable transmissions have 2ch 32k AC-3 streams
@@ -217,6 +217,11 @@ class AudioReencodeBuffer : public AudioOutput
// Do nothing
return false;
}
+ virtual bool CanPassthrough(void) const
+ {
+ // Do nothing
+ return false;
+ }
virtual void SetSWVolume(int new_volume, bool save)
{

0 comments on commit 0e3f5bd

Please sign in to comment.