#include "DVDAudio.h"
#include "DVDClock.h"
#include "DVDCodecs/DVDCodecs.h"
-#include "DVDPlayerAudio.h"
+#include "DVDCodecs/Audio/DVDAudioCodec.h"
#include "cores/AudioEngine/AEFactory.h"
#include "cores/AudioEngine/Interfaces/AEStream.h"
#include "settings/MediaSettings.h"
#include "system.h"
#include "cores/AudioEngine/Utils/AEAudioFormat.h"
+#include "cores/AudioEngine/Utils/AEUtil.h"
+#include "DVDClock.h"
+
#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
#include "config.h"
class CDVDCodecOption;
class CDVDCodecOptions;
+typedef struct stDVDAudioFrame
+{
+ uint8_t* data;
+ double pts;
+ double duration;
+ unsigned int size;
+
+ int channel_count;
+ int encoded_channel_count;
+ CAEChannelInfo channel_layout;
+ enum AEDataFormat data_format;
+ int bits_per_sample;
+ int sample_rate;
+ int encoded_sample_rate;
+ bool passthrough;
+} DVDAudioFrame;
+
class CDVDAudioCodec
{
public:
virtual int Decode(uint8_t* pData, int iSize) = 0;
/*
- * returns nr of bytes used or -1 on error
+ * returns nr of bytes in decode buffer
* the data is valid until the next Decode call
*/
virtual int GetData(uint8_t** dst) = 0;
/*
+ * the data is valid until the next Decode call
+ */
+ virtual void GetData(DVDAudioFrame &frame)
+ {
+ frame.size = GetData(&frame.data);
+ if(frame.size == 0u)
+ return;
+ frame.channel_layout = GetChannelMap();
+ frame.channel_count = GetChannels();
+ frame.encoded_channel_count = GetEncodedChannels();
+ frame.data_format = GetDataFormat();
+ frame.bits_per_sample = CAEUtil::DataFormatToBits(frame.data_format);
+ frame.sample_rate = GetSampleRate();
+ frame.encoded_sample_rate = GetEncodedSampleRate();
+ frame.passthrough = NeedPassthrough();
+ frame.pts = DVD_NOPTS_VALUE;
+ // compute duration.
+ int n = (frame.channel_count * frame.bits_per_sample * frame.sample_rate)>>3;
+ if (n)
+ frame.duration = ((double)frame.size * DVD_TIME_BASE) / n;
+ else
+ frame.duration = 0.0;
+ }
+
+ /*
* resets the decoder
*/
virtual void Reset() = 0;
m_decode.data += len;
m_decode.size -= len;
-
// get decoded data and the size of it
- audioframe.size = m_pAudioCodec->GetData(&audioframe.data);
- audioframe.pts = m_audioClock;
+ m_pAudioCodec->GetData(audioframe);
if (audioframe.size == 0)
continue;
- audioframe.channel_layout = m_pAudioCodec->GetChannelMap();
- audioframe.channel_count = m_pAudioCodec->GetChannels();
- audioframe.encoded_channel_count = m_pAudioCodec->GetEncodedChannels();
- audioframe.data_format = m_pAudioCodec->GetDataFormat();
- audioframe.bits_per_sample = CAEUtil::DataFormatToBits(audioframe.data_format);
- audioframe.sample_rate = m_pAudioCodec->GetSampleRate();
- audioframe.encoded_sample_rate = m_pAudioCodec->GetEncodedSampleRate();
- audioframe.passthrough = m_pAudioCodec->NeedPassthrough();
+ if (audioframe.pts == DVD_NOPTS_VALUE)
+ audioframe.pts = m_audioClock;
if (m_streaminfo.samplerate != audioframe.encoded_sample_rate)
{
}
}
- // compute duration.
- int n = (audioframe.channel_count * audioframe.bits_per_sample * audioframe.sample_rate)>>3;
- if (n > 0)
- {
- // safety check, if channels == 0, n will result in 0, and that will result in a nice devide exception
- audioframe.duration = ((double)audioframe.size * DVD_TIME_BASE) / n;
-
- // increase audioclock to after the packet
- m_audioClock += audioframe.duration;
- }
+ // increase audioclock to after the packet
+ m_audioClock += audioframe.duration;
if(audioframe.duration > 0)
m_duration = audioframe.duration;
#define DECODE_FLAG_ABORT 8
#define DECODE_FLAG_TIMEOUT 16
-typedef struct stDVDAudioFrame
-{
- uint8_t* data;
- double pts;
- double duration;
- unsigned int size;
-
- int channel_count;
- int encoded_channel_count;
- CAEChannelInfo channel_layout;
- enum AEDataFormat data_format;
- int bits_per_sample;
- int sample_rate;
- int encoded_sample_rate;
- bool passthrough;
-} DVDAudioFrame;
-
class CPTSInputQueue
{
private: