annotate data/fileio/test/UnsupportedFormat.cpp @ 1714:83cb6e9d769b

Attempt to cope with the fact that Windows Server (for CI builds) lacks certain codecs
author Chris Cannam
date Fri, 17 May 2019 11:05:10 +0100
parents
children 9ec3f123f1fb
rev   line source
Chris@1714 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@1714 2
Chris@1714 3 /*
Chris@1714 4 Sonic Visualiser
Chris@1714 5 An audio file viewer and annotation editor.
Chris@1714 6 Centre for Digital Music, Queen Mary, University of London.
Chris@1714 7
Chris@1714 8 This program is free software; you can redistribute it and/or
Chris@1714 9 modify it under the terms of the GNU General Public License as
Chris@1714 10 published by the Free Software Foundation; either version 2 of the
Chris@1714 11 License, or (at your option) any later version. See the file
Chris@1714 12 COPYING included with this distribution for more information.
Chris@1714 13 */
Chris@1714 14
Chris@1714 15 #include "UnsupportedFormat.h"
Chris@1714 16
Chris@1714 17 #ifdef Q_OS_WIN
Chris@1714 18 #include <windows.h>
Chris@1714 19 #endif
Chris@1714 20
Chris@1714 21 bool
Chris@1714 22 UnsupportedFormat::isLegitimatelyUnsupported(QString format)
Chris@1714 23 {
Chris@1714 24 #ifdef Q_OS_WIN
Chris@1714 25 // Our CI tests run on Windows Server, which annoyingly seems to
Chris@1714 26 // come without codecs for WMA and AAC
Chris@1714 27
Chris@1714 28 NTSTATUS(WINAPI *RtlGetVersion)(LPOSVERSIONINFOEXW);
Chris@1714 29 *(FARPROC*)&RtlGetVersion = GetProcAddress
Chris@1714 30 (GetModuleHandleA("ntdll"), "RtlGetVersion");
Chris@1714 31
Chris@1714 32 if (RtlGetVersion) {
Chris@1714 33
Chris@1714 34 OSVERSIONINFOEXW osInfo;
Chris@1714 35 osInfo.dwOSVersionInfoSize = sizeof(osInfo);
Chris@1714 36 RtlGetVersion(&osInfo);
Chris@1714 37
Chris@1714 38 if (osInfo.wProductType != VER_NT_WORKSTATION) {
Chris@1714 39 cerr << "NOTE: We appear to be running on Windows Server (wProductType = " << osInfo.wProductType << ") - assuming encumbered media codecs might not be installed and being lenient about them" << endl;
Chris@1714 40 return (format == "aac" ||
Chris@1714 41 format == "apple_lossless" ||
Chris@1714 42 format == "m4a" ||
Chris@1714 43 format == "wma");
Chris@1714 44 }
Chris@1714 45
Chris@1714 46 } else {
Chris@1714 47 cerr << "WARNING: Failed to find RtlGetVersion in NTDLL" << endl;
Chris@1714 48 }
Chris@1714 49
Chris@1714 50 return (format == "apple_lossless");
Chris@1714 51
Chris@1714 52 #else
Chris@1714 53 #ifdef Q_OS_MAC
Chris@1714 54 return (format == "wma");
Chris@1714 55 #else
Chris@1714 56 return (format == "aac" ||
Chris@1714 57 format == "apple_lossless" ||
Chris@1714 58 format == "m4a" ||
Chris@1714 59 format == "wma");
Chris@1714 60 #endif
Chris@1714 61 #endif
Chris@1714 62 }