20
20
21
21
#include " ServiceBroker.h"
22
22
#include " RetroPlayerAudio.h"
23
- #include " RetroPlayerDefines.h"
24
23
#include " cores/AudioEngine/Interfaces/AE.h"
25
24
#include " cores/AudioEngine/Interfaces/AEStream.h"
26
25
#include " cores/AudioEngine/Utils/AEChannelInfo.h"
27
26
#include " cores/AudioEngine/Utils/AEUtil.h"
28
- #include " cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodec.h"
29
- #include " cores/VideoPlayer/DVDCodecs/DVDFactoryCodec.h"
30
- #include " cores/VideoPlayer/DVDDemuxers/DVDDemux.h"
31
- #include " cores/VideoPlayer/DVDClock.h"
32
- #include " cores/VideoPlayer/DVDStreamInfo.h"
33
- #include " cores/VideoPlayer/Process/ProcessInfo.h"
27
+ #include " cores/RetroPlayer/process/RPProcessInfo.h"
34
28
#include " threads/Thread.h"
35
29
#include " utils/log.h"
36
30
37
31
using namespace KODI ;
38
32
using namespace RETRO ;
39
33
40
- CRetroPlayerAudio::CRetroPlayerAudio (CProcessInfo & processInfo) :
34
+ CRetroPlayerAudio::CRetroPlayerAudio (CRPProcessInfo & processInfo) :
41
35
m_processInfo(processInfo),
42
36
m_pAudioStream(nullptr ),
43
37
m_bAudioEnabled(true )
@@ -101,70 +95,23 @@ bool CRetroPlayerAudio::OpenPCMStream(AEDataFormat format, unsigned int samplera
101
95
return false ;
102
96
}
103
97
98
+ m_processInfo.SetAudioChannels (audioFormat.m_channelLayout );
99
+ m_processInfo.SetAudioSampleRate (audioFormat.m_sampleRate );
100
+ m_processInfo.SetAudioBitsPerSample (CAEUtil::DataFormatToUsedBits (audioFormat.m_dataFormat ));
101
+
104
102
return true ;
105
103
}
106
104
107
105
bool CRetroPlayerAudio::OpenEncodedStream (AVCodecID codec, unsigned int samplerate, const CAEChannelInfo& channelLayout)
108
106
{
109
- CDemuxStreamAudio audioStream;
110
-
111
- // Stream
112
- audioStream.uniqueId = GAME_STREAM_AUDIO_ID;
113
- audioStream.codec = codec;
114
- audioStream.type = STREAM_AUDIO;
115
- audioStream.source = STREAM_SOURCE_DEMUX;
116
- audioStream.realtime = true ;
117
-
118
- // Audio
119
- audioStream.iChannels = channelLayout.Count ();
120
- audioStream.iSampleRate = samplerate;
121
- audioStream.iChannelLayout = CAEUtil::GetAVChannelLayout (channelLayout);
122
-
123
- CDVDStreamInfo hint (audioStream);
124
- m_pAudioCodec.reset (CDVDFactoryCodec::CreateAudioCodec (hint, m_processInfo, false , false , CAEStreamInfo::STREAM_TYPE_NULL));
125
-
126
- if (!m_pAudioCodec)
127
- {
128
- CLog::Log (LOGERROR, " RetroPlayerAudio: Failed to create audio codec (codec=%d, samplerate=%u)" , codec, samplerate);
129
- return false ;
130
- }
131
-
132
- return true ;
107
+ return true ; // ! @todo
133
108
}
134
109
135
110
void CRetroPlayerAudio::AddData (const uint8_t * data, unsigned int size)
136
111
{
137
112
if (m_bAudioEnabled)
138
113
{
139
- if (m_pAudioCodec)
140
- {
141
- DemuxPacket packet (const_cast <uint8_t *>(data), size, DVD_NOPTS_VALUE, DVD_NOPTS_VALUE);
142
- int consumed = m_pAudioCodec->AddData (packet);
143
- if (consumed < 0 )
144
- {
145
- CLog::Log (LOGERROR, " CRetroPlayerAudio::AddData - Decode Error (%d)" , consumed);
146
- m_pAudioCodec.reset ();
147
- return ;
148
- }
149
-
150
- DVDAudioFrame audioframe;
151
- m_pAudioCodec->GetData (audioframe);
152
-
153
- if (audioframe.nb_frames != 0 )
154
- {
155
- // Open audio stream if not already open
156
- if (!m_pAudioStream)
157
- {
158
- const AEAudioFormat& format = audioframe.format ;
159
- if (!OpenPCMStream (format.m_dataFormat , format.m_sampleRate , format.m_channelLayout ))
160
- m_pAudioCodec.reset ();
161
- }
162
-
163
- if (m_pAudioStream)
164
- m_pAudioStream->AddData (audioframe.data , 0 , audioframe.nb_frames );
165
- }
166
- }
167
- else if (m_pAudioStream)
114
+ if (m_pAudioStream)
168
115
{
169
116
const unsigned int frameSize = m_pAudioStream->GetChannelCount () * (CAEUtil::DataFormatToBits (m_pAudioStream->GetDataFormat ()) >> 3 );
170
117
m_pAudioStream->AddData (&data, 0 , size / frameSize);
@@ -174,11 +121,6 @@ void CRetroPlayerAudio::AddData(const uint8_t* data, unsigned int size)
174
121
175
122
void CRetroPlayerAudio::CloseStream ()
176
123
{
177
- if (m_pAudioCodec)
178
- {
179
- m_pAudioCodec->Dispose ();
180
- m_pAudioCodec.reset ();
181
- }
182
124
if (m_pAudioStream)
183
125
{
184
126
CServiceBroker::GetActiveAE ().FreeStream (m_pAudioStream);
0 commit comments