Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit 0e3f5bde53430b96cd4f156aef6fdbf323f6bcdf 1 parent ff32e1a
Jean-Yves Avenard authored June 18, 2010
1  mythtv/libs/libmyth/audiooutput.h
@@ -49,6 +49,7 @@ class MPUBLIC AudioOutput : public VolumeBase, public OutputListeners
49 49
     virtual void SetTimecode(long long timecode) = 0;
50 50
     virtual bool IsPaused(void) const = 0;
51 51
     virtual void Pause(bool paused) = 0;
  52
+    virtual bool CanPassthrough(void) const = 0;
52 53
  
53 54
     // Wait for all data to finish playing
54 55
     virtual void Drain(void) = 0;
5  mythtv/libs/libmyth/audiooutputbase.cpp
@@ -848,7 +848,8 @@ bool AudioOutputBase::AddSamples(char *buffer, int samples, long long timecode)
848 848
     {
849 849
         // Convert to floats
850 850
         short *buf_ptr = (short*)buffer;
851  
-        for (int sample = 0; sample < samples * audio_channels; sample++)
  851
+        int numSamples = (samples * abps) / sizeof(short);
  852
+        for (int sample = 0; sample < numSamples; sample++)
852 853
         {
853 854
             src_in[sample] = (float)buf_ptr[sample] / (1.0 * 0x8000);
854 855
         }
@@ -861,7 +862,7 @@ bool AudioOutputBase::AddSamples(char *buffer, int samples, long long timecode)
861 862
                     QString("Error occurred while resampling audio: %1")
862 863
                     .arg(src_strerror(error)));
863 864
         src_float_to_short_array(src_data.data_out, (short int*)tmp_buff,
864  
-                                 src_data.output_frames_gen*audio_channels);
  865
+                            (src_data.output_frames_gen*abps)/sizeof(short));
865 866
 
866 867
         _AddSamples(tmp_buff, true, src_data.output_frames_gen, timecode);
867 868
     }
1  mythtv/libs/libmyth/audiooutputbase.h
@@ -57,6 +57,7 @@ class AudioOutputBase : public AudioOutput, public QThread
57 57
     virtual void SetTimecode(long long timecode);
58 58
     virtual bool IsPaused(void) const { return audio_actually_paused; }
59 59
     virtual void Pause(bool paused);
  60
+    virtual bool CanPassthrough(void) const { return !need_resampler; }
60 61
 
61 62
     // Wait for all data to finish playing
62 63
     virtual void Drain(void);
7  mythtv/libs/libmythtv/NuppelVideoPlayer.cpp
@@ -5134,6 +5134,13 @@ bool NuppelVideoPlayer::ToggleUpmix()
5134 5134
     return false;
5135 5135
 }
5136 5136
 
  5137
+bool NuppelVideoPlayer::CanPassthrough()
  5138
+{
  5139
+    if (audioOutput)
  5140
+        return audioOutput->CanPassthrough();
  5141
+    return false;
  5142
+}
  5143
+
5137 5144
 void NuppelVideoPlayer::Zoom(ZoomDirection direction)
5138 5145
 {
5139 5146
     if (videoOutput)
1  mythtv/libs/libmythtv/NuppelVideoPlayer.h
@@ -165,6 +165,7 @@ class MPUBLIC NuppelVideoPlayer : public CC608Reader, public CC708Reader
165 165
     void ToggleAspectOverride(AspectOverrideMode aspectMode = kAspect_Toggle);
166 166
     void ToggleAdjustFill(AdjustFillMode adjustfillMode = kAdjustFill_Toggle);
167 167
     bool ToggleUpmix(void);
  168
+    bool CanPassthrough(void);
168 169
 
169 170
     // Gets
170 171
     QSize   GetVideoBufferSize(void) const    { return video_dim; }
1  mythtv/libs/libmythtv/avformatdecoder.cpp
@@ -4639,6 +4639,7 @@ bool AvFormatDecoder::DoPassThrough(const AVCodecContext *ctx)
4639 4639
     else if (ctx->codec_id == CODEC_ID_DTS)
4640 4640
         passthru = allow_dts_passthru && !internal_vol;
4641 4641
 
  4642
+    passthru &= GetNVP()->CanPassthrough();
4642 4643
     passthru &= !transcoding && !disable_passthru;
4643 4644
     // Don't know any cards that support spdif clocked at < 44100
4644 4645
     // Some US cable transmissions have 2ch 32k AC-3 streams
5  mythtv/programs/mythtranscode/transcode.cpp
@@ -217,6 +217,11 @@ class AudioReencodeBuffer : public AudioOutput
217 217
         // Do nothing
218 218
         return false;
219 219
     }
  220
+    virtual bool CanPassthrough(void) const
  221
+    {
  222
+        // Do nothing
  223
+        return false;
  224
+    }
220 225
 
221 226
     virtual void SetSWVolume(int new_volume, bool save)
222 227
     {

0 notes on commit 0e3f5bd

Please sign in to comment.
Something went wrong with that request. Please try again.