annotate data/fileio/test/UnsupportedFormat.cpp @ 1878:231c6bcf0fa2

Comment only
author Chris Cannam
date Thu, 25 Jun 2020 09:30:17 +0100
parents a47a23c824ac
children
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@1715 21 #include <iostream>
Chris@1715 22
Chris@1714 23 bool
Chris@1714 24 UnsupportedFormat::isLegitimatelyUnsupported(QString format)
Chris@1714 25 {
Chris@1714 26 #ifdef Q_OS_WIN
Chris@1728 27
Chris@1728 28 if (sizeof(void *) == 4) {
Chris@1728 29 // Our 32-bit MinGW build lacks MediaFoundation support
Chris@1728 30 return (format == "aac" ||
Chris@1728 31 format == "apple_lossless" ||
Chris@1728 32 format == "m4a" ||
Chris@1728 33 format == "wma");
Chris@1728 34 }
Chris@1728 35
Chris@1714 36 // Our CI tests run on Windows Server, which annoyingly seems to
Chris@1714 37 // come without codecs for WMA and AAC
Chris@1714 38
Chris@1714 39 NTSTATUS(WINAPI *RtlGetVersion)(LPOSVERSIONINFOEXW);
Chris@1714 40 *(FARPROC*)&RtlGetVersion = GetProcAddress
Chris@1714 41 (GetModuleHandleA("ntdll"), "RtlGetVersion");
Chris@1714 42
Chris@1714 43 if (RtlGetVersion) {
Chris@1714 44
Chris@1714 45 OSVERSIONINFOEXW osInfo;
Chris@1714 46 osInfo.dwOSVersionInfoSize = sizeof(osInfo);
Chris@1714 47 RtlGetVersion(&osInfo);
Chris@1714 48
Chris@1714 49 if (osInfo.wProductType != VER_NT_WORKSTATION) {
Chris@1715 50 std::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" << std::endl;
Chris@1714 51 return (format == "aac" ||
Chris@1714 52 format == "apple_lossless" ||
Chris@1714 53 format == "m4a" ||
Chris@1714 54 format == "wma");
Chris@1714 55 }
Chris@1714 56
Chris@1714 57 } else {
Chris@1715 58 std::cerr << "WARNING: Failed to find RtlGetVersion in NTDLL"
Chris@1715 59 << std::endl;
Chris@1714 60 }
Chris@1728 61
Chris@1728 62 // If none of the above applies, then we should have everything
Chris@1728 63 // except this:
Chris@1714 64
Chris@1714 65 return (format == "apple_lossless");
Chris@1714 66
Chris@1714 67 #else
Chris@1714 68 #ifdef Q_OS_MAC
Chris@1714 69 return (format == "wma");
Chris@1714 70 #else
Chris@1714 71 return (format == "aac" ||
Chris@1714 72 format == "apple_lossless" ||
Chris@1714 73 format == "m4a" ||
Chris@1714 74 format == "wma");
Chris@1714 75 #endif
Chris@1714 76 #endif
Chris@1714 77 }