-
Notifications
You must be signed in to change notification settings - Fork 5
/
AESinkNULL.cpp
98 lines (82 loc) · 2.52 KB
/
AESinkNULL.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
* Copyright (C) 2010-2012 Team XBMC
* http://www.xbmc.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XBMC; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*
*/
#include "system.h"
#include "AESinkNULL.h"
#include <stdint.h>
#include <limits.h>
#include "guilib/LocalizeStrings.h"
#include "dialogs/GUIDialogKaiToast.h"
#include "Utils/AEUtil.h"
#include "utils/StdString.h"
#include "utils/log.h"
#include "utils/MathUtils.h"
#include "utils/TimeUtils.h"
#include "settings/GUISettings.h"
CAESinkNULL::CAESinkNULL() {
}
CAESinkNULL::~CAESinkNULL()
{
}
bool CAESinkNULL::Initialize(AEAudioFormat &format, std::string &device)
{
m_msPerFrame = 1000.0f / format.m_sampleRate;
m_ts = 0;
format.m_dataFormat = AE_IS_RAW(format.m_dataFormat) ? AE_FMT_S16NE : AE_FMT_FLOAT;
format.m_frames = format.m_sampleRate / 1000 * 500; /* 500ms */
format.m_frameSamples = format.m_channelLayout.Count();
format.m_frameSize = format.m_frameSamples * (CAEUtil::DataFormatToBits(format.m_dataFormat) >> 3);
#if 0
/* FIXME, CAUSES A DEADLOCK */
/* display failure notification */
CGUIDialogKaiToast::QueueNotification(
CGUIDialogKaiToast::Error,
g_localizeStrings.Get(34402),
g_localizeStrings.Get(34403),
TOAST_DISPLAY_TIME,
false
);
#endif
return true;
}
void CAESinkNULL::Deinitialize()
{
}
bool CAESinkNULL::IsCompatible(const AEAudioFormat format, const std::string device)
{
return false;
}
double CAESinkNULL::GetDelay()
{
return std::max(0.0, (double)(m_ts - CurrentHostCounter()) / 1000000.0f);
}
unsigned int CAESinkNULL::AddPackets(uint8_t *data, unsigned int frames, bool hasAudio)
{
float timeout = m_msPerFrame * frames;
m_ts = CurrentHostCounter() + MathUtils::round_int(timeout * 1000000.0f);
Sleep(MathUtils::round_int(timeout));
return frames;
}
void CAESinkNULL::Drain()
{
}
void CAESinkNULL::EnumerateDevices (AEDeviceList &devices, bool passthrough)
{
/* we never return any devices */
}