Skip to content

Commit f891c01

Browse files
committed
#75 xbox-host-ciのエラー対応
1 parent 5b0d4c0 commit f891c01

2 files changed

Lines changed: 43 additions & 5 deletions

File tree

.github/workflows/xbox-host-ci.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,19 @@ jobs:
5656
if errorlevel 1 exit /b 1
5757
raster_test.exe
5858
59-
- name: Build & run Windows platform tests (WIC/DirectWrite/MF/XAudio2)
59+
- name: Build & run Windows platform tests (WIC/DirectWrite/MF/XAudio2/stb/dr)
6060
shell: cmd
6161
working-directory: templates/xbox
6262
run: |
63-
cl /nologo /std:c++17 /EHsc /W3 /DNOMINMAX /Isrc ^
63+
rem /I. は third_party/ (stb_image, dr_mp3 等) の include 用。
64+
rem ImageDecoder/AudioDecoder はポータブルな第一経路 (AudioEngine::Decode が参照)。
65+
cl /nologo /std:c++17 /EHsc /W3 /DNOMINMAX /Isrc /I. ^
6466
tests\windows_platform_test.cpp ^
6567
src\platform\WicDecoder.cpp ^
6668
src\platform\TextRasterizer.cpp ^
6769
src\platform\AudioEngine.cpp ^
70+
src\platform\ImageDecoder.cpp ^
71+
src\platform\AudioDecoder.cpp ^
6872
/Fe:platform_test.exe ^
6973
ole32.lib uuid.lib windowscodecs.lib d2d1.lib dwrite.lib ^
7074
mfplat.lib mfreadwrite.lib mfuuid.lib xaudio2.lib shlwapi.lib

templates/xbox/tests/windows_platform_test.cpp

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
// windows-latest ランナーで実行して「Windows 上で実際に動く」ことを検証する。
44
//
55
// ビルド (Developer Command Prompt / CI):
6-
// cl /std:c++17 /EHsc /Isrc tests\windows_platform_test.cpp ^
6+
// cl /std:c++17 /EHsc /Isrc /I. tests\windows_platform_test.cpp ^
77
// src\platform\WicDecoder.cpp src\platform\TextRasterizer.cpp ^
88
// src\platform\AudioEngine.cpp ^
9+
// src\platform\ImageDecoder.cpp src\platform\AudioDecoder.cpp ^
910
// ole32.lib windowscodecs.lib d2d1.lib dwrite.lib ^
1011
// mfplat.lib mfreadwrite.lib mfuuid.lib xaudio2.lib shlwapi.lib
1112
//
@@ -16,6 +17,8 @@
1617
#endif
1718

1819
#include "../src/platform/WicDecoder.h"
20+
#include "../src/platform/ImageDecoder.h"
21+
#include "../src/platform/AudioDecoder.h"
1922
#include "../src/platform/TextRasterizer.h"
2023
#include "../src/platform/AudioEngine.h"
2124

@@ -89,6 +92,24 @@ static void TestWicDecode()
8992
CHECK(!next2d::DecodeImageWithWIC(garbage, bad));
9093
}
9194

95+
// --- ImageDecoder: 本番の第一経路 (stb_image。コンソールでも同一コード) --------
96+
static void TestImageDecoder()
97+
{
98+
std::vector<uint8_t> png(kTestPng, kTestPng + sizeof(kTestPng));
99+
next2d::DecodedImage img;
100+
CHECK(next2d::DecodeImage(png, img));
101+
CHECK(img.width == 2 && img.height == 2);
102+
CHECK(img.rgba.size() == 16);
103+
CHECK(img.rgba[0] == 255 && img.rgba[1] == 0 && img.rgba[2] == 0 && img.rgba[3] == 255);
104+
CHECK(img.rgba[4] == 0 && img.rgba[5] == 255 && img.rgba[6] == 0);
105+
CHECK(img.rgba[8] == 0 && img.rgba[9] == 0 && img.rgba[10] == 255);
106+
CHECK(img.rgba[15] == 128);
107+
108+
std::vector<uint8_t> garbage(32, 0xAB);
109+
next2d::DecodedImage bad;
110+
CHECK(!next2d::DecodeImage(garbage, bad));
111+
}
112+
92113
// --- DirectWrite: メトリクスとグリフラスタライズ (fillText の実体) ----------
93114
static void TestTextRasterizer()
94115
{
@@ -131,19 +152,31 @@ static void TestTextRasterizer()
131152
CHECK(!next2d::RasterizeTextWithDWrite("24px Segoe UI", L"", 0, 0, 0, empty));
132153
}
133154

134-
// --- Media Foundation: 音声デコード (decodeAudioData の実体) -----------------
155+
// --- 音声デコード (decodeAudioData の実体) -----------------------------------
156+
// AudioEngine::Decode は第一経路 dr_wav/dr_mp3/stb_vorbis (コンソールでも同一)、
157+
// フォールバックが Media Foundation。両経路を検証する。
135158
static void TestAudioDecode()
136159
{
137160
std::vector<uint8_t> wav(kTestWav, kTestWav + sizeof(kTestWav));
138161
next2d::PcmBuffer pcm;
139162
CHECK(next2d::AudioEngine::Decode(wav, pcm));
140163
CHECK(pcm.sample_rate == 48000);
141164
CHECK(pcm.channels == 1);
142-
CHECK(pcm.samples.size() >= 40); // 48 サンプル前後 (MF は端数調整あり)
165+
CHECK(pcm.samples.size() >= 40); // 48 サンプル前後
143166
// 振幅 0.5 の矩形波 → ピーク絶対値が 0.4〜0.6
144167
float peak = 0;
145168
for (float s : pcm.samples) peak = std::max(peak, std::fabs(s));
146169
CHECK(peak > 0.4f && peak < 0.6f);
170+
171+
// ポータブルデコーダ単体 (本番の第一経路) も直接検証
172+
next2d::PcmBuffer pcm2;
173+
CHECK(next2d::DecodeAudio(wav, pcm2));
174+
CHECK(pcm2.sample_rate == 48000 && pcm2.channels == 1);
175+
CHECK(pcm2.samples.size() >= 40);
176+
177+
std::vector<uint8_t> garbage(32, 0xAB);
178+
next2d::PcmBuffer bad;
179+
CHECK(!next2d::DecodeAudio(garbage, bad));
147180
}
148181

149182
// --- XAudio2: 初期化 (ヘッドレス CI では音声デバイスが無く失敗し得る → warn) --
@@ -175,6 +208,7 @@ int main()
175208
MFStartup(MF_VERSION);
176209

177210
TestWicDecode();
211+
TestImageDecoder();
178212
TestTextRasterizer();
179213
TestAudioDecode();
180214
TestAudioEngineInit();

0 commit comments

Comments
 (0)