/*
Streaming of sound data with Bluetooth to an other Bluetooth device.
We provide the complete sound data as a simple c array which
can be prepared e.g. in the following way
- Open any sound file in Audacity. Make sure that it contains 2 channels
- Select Tracks -> Resample and select 44100
- Export -> Export Audio -> Header Raw ; Signed 16 bit PCM
- Convert to c file e.g. with "xxd -i file_example_WAV_1MG.raw file_example_WAV_1MG.c"
- add the const qualifier to the array definition. E.g const unsigned char file_example_WAV_1MG_raw[] = {
Copyright (C) 2020 Phil Schatzmann
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 3 of the License, 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "BluetoothA2DPSource.h"
#include "StarWars30.h"
BluetoothA2DPSource a2dp_source;
//SoundData *data = new TwoChannelSoundData((Channels*)StarWars10_raw,StarWars10_raw_len/4);
SoundData *data = new OneChannelSoundData((int16_t*)StarWars30_raw, StarWars30_raw_len/2);
void setup() {
Serial.begin(115200);
Serial.println("Start");
a2dp_source.start("JABRA TALK");
}
void loop() {
if (a2dp_source.isConnected()==true) {
Serial.println("Connected!");
if (a2dp_source.hasSoundData()==true) {
Serial.println("Has sound!");
}
else {
Serial.println("No sound!");
a2dp_source.writeData(data);
}
}
else {
Serial.println("Not connected!");
}
delay(2000);
}
build -a X64 -p AppPkg\AppPkg.dsc -t VS2019 (特别注意, VS2019 必须大写)
之后就遇到了第一个错误:
“Socket.c
c:\buildbs\edk202008\StdLib\EfiSocketLib\Socket.c(573): error C2220: the following warning is treated as an error
c:\buildbs\edk202008\StdLib\EfiSocketLib\Socket.c(573): warning C4459: declaration of 'errno' hides global declaration
c:\buildbs\edk202008\StdLib\Include\errno.h(43): note: see declaration of 'errno'
c:\buildbs\edk202008\StdLib\EfiSocketLib\Socket.c(1337): warning C4459: declaration of 'errno' hides global declaration
c:\buildbs\edk202008\StdLib\Include\errno.h(43): note: see declaration of 'errno'
c:\buildbs\edk202008\StdLib\EfiSocketLib\Socket.c(1480): warning C4459: declaration of 'errno' hides global declaration
c:\buildbs\edk202008\StdLib\Include\errno.h(43): note: see declaration of 'errno'
c:\buildbs\edk202008\StdLib\EfiSocketLib\Socket.c(1892): warning C4459: declaration of 'errno' hides global declaration
c:\buildbs\edk202008\StdLib\Include\errno.h(43): note: see declaration of 'errno'
c:\buildbs\edk202008\StdLib\EfiSocketLib\Socket.c(2754): warning C4459: declaration of 'errno' hides global declaration
c:\buildbs\edk202008\StdLib\Include\errno.h(43): note: see declaration of 'errno'
c:\buildbs\edk202008\StdLib\EfiSocketLib\Socket.c(2974): warning C4459: declaration of 'errno' hides global declaration
c:\buildbs\edk202008\StdLib\Include\errno.h(43): note: see declaration of 'errno'
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.26.28801\bin\Hostx86\x64\cl.exe"' : return code '0x2'
Stop.”
解决方法是:在 StdLib.inc 末尾添加下面的内容:
# Temporarily restrict compiler warnings to those produced by VS2012.
# Code that fails when these flags are removed will have to be rewritten
# in order to pass. This may be as simple as renaming an object, but may
# require more significant changes.
MSFT:*_VS2015_*_CC_FLAGS = /Wv:11
MSFT:*_VS2015x86_*_CC_FLAGS = /Wv:11
MSFT:*_VS2015xASL_*_CC_FLAGS = /Wv:11
MSFT:*_VS2015x86xASL_*_CC_FLAGS = /Wv:11
#LABZ_Start
# Temporarily restrict compiler warnings to those produced by VS2012.
# Code that fails when these flags are removed will have to be rewritten
# in order to pass. This may be as simple as renaming an object, but may
# require more significant changes.
MSFT:*_VS2019_*_CC_FLAGS = /Wv:11
MSFT:*_VS2019x86_*_CC_FLAGS = /Wv:11
MSFT:*_VS2019xASL_*_CC_FLAGS = /Wv:11
MSFT:*_VS2019x86xASL_*_CC_FLAGS = /Wv:11
#LABZ_End
Force the linker to include all object files in the static library in the linked executable.
Syntax
/WHOLEARCHIVE /WHOLEARCHIVE:library
Arguments
library An optional pathname to a static library. The linker includes every object file from this library.
Remarks
The /WHOLEARCHIVE option forces the linker to include every object file from either a specified static library, or if no library is specified, from all static libraries specified to the LINK command. To specify the /WHOLEARCHIVE option for multiple libraries, you can use more than one /WHOLEARCHIVE switch on the linker command line. By default, the linker includes object files in the linked output only if they export symbols referenced by other object files in the executable. The /WHOLEARCHIVE option makes the linker treat all object files archived in a static library as if they were specified individually on the linker command line.
The /WHOLEARCHIVE option can be used to re-export all the symbols from a static library. This allows you to make sure that all of your library code, resources, and metadata are included when you create a component from more than one static library. If you see warning LNK4264 when you create a static library that contains Windows Runtime components for export, use the /WHOLEARCHIVE option when linking that library into another component or app.
The /WHOLEARCHIVE option was introduced in Visual Studio 2015 Update 2.