-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathXAudio2AudioPlayer.cc
123 lines (104 loc) · 2.79 KB
/
XAudio2AudioPlayer.cc
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
Copyright (c) 2015-2021 hkrn All rights reserved
This file is part of emapp component and it's licensed under Mozilla Public License. see LICENSE.md for more details.
*/
#include "XAudio2AudioPlayer.h"
#include "COMInline.h"
#include "emapp/Constants.h"
#include "emapp/Error.h"
#include "emapp/IEventPublisher.h"
#include "emapp/private/CommonInclude.h"
namespace nanoem {
namespace win32 {
XAudio2AudioPlayer::XAudio2AudioPlayer(IEventPublisher *eventPublisher)
: m_eventPublisher(eventPublisher)
{
}
XAudio2AudioPlayer::~XAudio2AudioPlayer()
{
}
bool
XAudio2AudioPlayer::initialize(nanoem_frame_index_t duration, nanoem_u32_t sampleRate, Error &error)
{
if (m_state.first == kInitialState) {
}
return false;
}
void
XAudio2AudioPlayer::expandDuration(nanoem_frame_index_t frameIndex)
{
Error error;
if (isPlaying()) {
internalTransitStateStopped(error);
}
if (isLoaded()) {
const Format &format = m_description.m_formatData;
const nanoem_rsize_t size = frameIndex *
static_cast<nanoem_rsize_t>(format.m_sampleRate / Constants::kHalfBaseFPS) *
static_cast<nanoem_rsize_t>(format.m_bytesPerPacket);
m_linearPCMSamples.resize(nanoem_rsize_t(size * 1.5));
}
error.notify(m_eventPublisher);
}
void
XAudio2AudioPlayer::destroy()
{
setState(kInitialState);
m_finished = false;
}
bool
XAudio2AudioPlayer::loadAllLinearPCMSamples(const nanoem_u8_t *data, size_t size, Error &error)
{
bool succeeded = false;
internalTransitStateStopped(error);
return succeeded;
}
void
XAudio2AudioPlayer::playPart(double, double)
{
}
void
XAudio2AudioPlayer::update()
{
const nanoem_u64_t offset = m_offset / m_description.m_formatData.m_bytesPerPacket;
m_lastRational = m_currentRational;
m_currentRational.m_numerator = offset;
}
void
XAudio2AudioPlayer::seek(const IAudioPlayer::Rational &value)
{
Error error;
value.m_numerator > 0 ? internalTransitStatePaused(error) : internalTransitStateStopped(error);
const Format &format = m_description.m_formatData;
const nanoem_u32_t denominator = format.m_sampleRate / Constants::kHalfBaseFPS;
m_offset = static_cast<nanoem_u64_t>(format.m_bytesPerPacket);
m_finished = false;
error.notify(m_eventPublisher);
}
void
XAudio2AudioPlayer::internalSetVolumeGain(float value, Error &error)
{
BX_UNUSED_2(value, error);
}
void
XAudio2AudioPlayer::internalTransitStateStarted(Error &error)
{
BX_UNUSED_1(error);
}
void
XAudio2AudioPlayer::internalTransitStatePaused(Error &error)
{
BX_UNUSED_1(error);
}
void
XAudio2AudioPlayer::internalTransitStateResumed(Error &error)
{
BX_UNUSED_1(error);
}
void
XAudio2AudioPlayer::internalTransitStateStopped(Error &error)
{
BX_UNUSED_1(error);
}
} /* namespace win32 */
} /* namespace nanoem */