Skip to content

Commit 43ad35f

Browse files
committed
code fixes
1 parent 3de0bfe commit 43ad35f

12 files changed

+447
-411
lines changed

libs/openFrameworks/app/ofAppEGLWindow.cpp

+22-11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#ifdef __unix__
2+
13
#include "ofAppEGLWindow.h"
24

35
#include "ofGraphics.h" // used in runAppViaInfiniteLoop()
@@ -28,6 +30,13 @@
2830

2931
#include <string.h> // strlen
3032

33+
using std::string;
34+
using std::map;
35+
using std::make_shared;
36+
using std::shared_ptr;
37+
using std::endl;
38+
using std::queue;
39+
3140
// native events
3241
struct udev* udev;
3342
struct udev_monitor* mon;
@@ -412,7 +421,7 @@ void ofAppEGLWindow::setup(const ofAppEGLWindowSettings & _settings) {
412421
// pDisplay = ofGetEnv("DISPLAY");
413422
// bool bIsX11Available = (pDisplay != NULL);
414423

415-
bool bIsX11Available = ofGetEnv("DISPLAY") != NULL;
424+
bool bIsX11Available = !ofGetEnv("DISPLAY").empty();
416425

417426
if(settings.eglWindowPreference == OF_APP_WINDOW_AUTO) {
418427
if(bIsX11Available) {
@@ -1427,7 +1436,7 @@ void ofAppEGLWindow::setupNativeInput(){
14271436
tc.c_lflag &= ~ECHO;
14281437
tc.c_lflag |= ECHONL;
14291438
tcsetattr(STDIN_FILENO, TCSAFLUSH, &tc);
1430-
1439+
14311440
mb.mouseButtonState = 0;
14321441

14331442
kb.shiftPressed = false;
@@ -1495,7 +1504,7 @@ void ofAppEGLWindow::printInput(){
14951504

14961505
void ofAppEGLWindow::destroyNativeInput(){
14971506
ofLogNotice("ofAppEGLWindow") << "destroyNativeInput()";
1498-
1507+
14991508
for(device::iterator iter = inputDevices.begin(); iter != inputDevices.end(); iter++){
15001509
if(iter->second >= 0){
15011510
::close(iter->second);
@@ -1517,7 +1526,7 @@ void ofAppEGLWindow::processInput(int fd, const char * node){
15171526
static ofMouseEventArgs mouseEvent;
15181527
struct input_event ev;
15191528
char key = 0;
1520-
1529+
15211530
bool pushKeyEvent = false;
15221531
bool pushMouseEvent = false;
15231532
bool pushTouchEvent = false;
@@ -1567,7 +1576,7 @@ void ofAppEGLWindow::processInput(int fd, const char * node){
15671576
pushMouseEvent = true;
15681577
}
15691578
}else if(ev.code == BTN_TOUCH){
1570-
if(ev.value == 0){ // release
1579+
if(ev.value == 0){ // release
15711580
touchEvent.type = ofTouchEventArgs::up;
15721581
touchEvent.id = 0;
15731582
mt[touchEvent.id] = 0;
@@ -1731,7 +1740,7 @@ void ofAppEGLWindow::processInput(int fd, const char * node){
17311740
}else{
17321741
ofLogNotice("ofAppEGLWindow") << "readKeyboardEvents(): input_event.code is outside of our small range";
17331742
}
1734-
}
1743+
}
17351744
}
17361745
}else if (ev.type == EV_REL){
17371746
int axis = ev.code;
@@ -1782,7 +1791,7 @@ void ofAppEGLWindow::processInput(int fd, const char * node){
17821791
pushTouchEvent = true;
17831792
}
17841793
}
1785-
else
1794+
else
17861795
{
17871796
if (mt[touchEvent.id] == 0){
17881797
touchEvent.type = ofTouchEventArgs::down;
@@ -1840,16 +1849,16 @@ void ofAppEGLWindow::processInput(int fd, const char * node){
18401849
}
18411850
}
18421851

1843-
1844-
1852+
1853+
18451854

18461855
if(pushKeyEvent){
18471856
lock();
18481857
keyEvents.push(keyEvent);
18491858
unlock();
18501859
pushKeyEvent = false;
18511860
}
1852-
1861+
18531862
if(pushMouseEvent){
18541863
// lock the thread for a moment while we copy the data
18551864
lock();
@@ -1925,7 +1934,7 @@ void ofAppEGLWindow::readNativeUDevEvents() {
19251934
removeInput(devnode);
19261935
}
19271936
}
1928-
1937+
19291938
udev_device_unref(dev);
19301939
}else{
19311940
ofLogNotice("ofAppEGLWindow") << "readNativeUDevEvents(): device returned by receive_device() is NULL";
@@ -2304,3 +2313,5 @@ void ofAppEGLWindow::handleX11Event(const XEvent& event){
23042313
}*/
23052314
}
23062315
}
2316+
2317+
#endif

libs/openFrameworks/app/ofAppEGLWindow.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#ifdef __unix__
2+
13
#pragma once
24

35
#include "ofAppBaseWindow.h"
@@ -10,6 +12,8 @@
1012

1113
#include <queue>
1214
#include <map>
15+
16+
#include <EGL/eglplatform.h>
1317
#include <X11/Xlib.h>
1418

1519
enum ofAppEGLWindowType {
@@ -268,7 +272,7 @@ class ofAppEGLWindow : public ofAppBaseGLESWindow, public ofThread {
268272
void readNativeUDevEvents();
269273
void readNativeInputEvents();
270274

271-
void processInput(int fd, const char * node);
275+
void processInput(int fd, const char * node);
272276
void addInput(const char * node, bool isMouse);
273277
void removeInput(const char * node);
274278
void printInput();
@@ -285,3 +289,5 @@ class ofAppEGLWindow : public ofAppBaseGLESWindow, public ofThread {
285289
std::shared_ptr<ofBaseRenderer> currentRenderer;
286290
static ofAppEGLWindow * instance;
287291
};
292+
293+
#endif

libs/openFrameworks/graphics/ofCairoRenderer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ class ofCairoRenderer: public ofBaseRenderer{
196196
std::stack<glm::mat4> projectionStack;
197197
std::stack<glm::mat4> modelViewStack;
198198
std::stack<ofRectangle> viewportStack;
199-
199+
200200
ofMatrixMode currentMatrixMode;
201201

202202
std::vector<glm::vec3> sphereVerts;

libs/openFrameworks/sound/ofMediaFoundationSoundPlayer.cpp

+29-26
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#ifdef _WIN32
12

23
#include "ofMediaFoundationSoundPlayer.h"
34
#include "ofLog.h"
@@ -168,7 +169,7 @@ void ofMediaFoundationSoundPlayer::sCloseAudioSystems() {
168169
sNumInstances--;
169170
if (sNumInstances <= 0) {
170171
ofLogVerbose("ofMediaFoundationSoundPlayer") << " closing XAudio2.";
171-
sCloseXAudio2();
172+
sCloseXAudio2();
172173
}
173174
ofMediaFoundationUtils::CloseMediaFoundation();
174175
if (sNumInstances < 0) {
@@ -189,7 +190,7 @@ ofMediaFoundationSoundPlayer::~ofMediaFoundationSoundPlayer() {
189190
//--------------------
190191
bool ofMediaFoundationSoundPlayer::load(const of::filesystem::path & fileName, bool stream) {
191192
unload();
192-
193+
193194
auto filePath = fileName;
194195
std::string fileStr = ofPathToString(fileName);
195196
bool bStream = false;
@@ -223,7 +224,7 @@ bool ofMediaFoundationSoundPlayer::load(const of::filesystem::path & fileName, b
223224

224225

225226
LPCWSTR path = filePath.c_str();
226-
227+
227228

228229
hr = MFCreateSourceReaderFromURL(
229230
path,
@@ -255,14 +256,14 @@ bool ofMediaFoundationSoundPlayer::load(const of::filesystem::path & fileName, b
255256
hr = mSrcReader->GetNativeMediaType(MF_SOURCE_READER_FIRST_AUDIO_STREAM, 0, &nativeType);
256257

257258
auto nativeTypePtr = std::unique_ptr<IMFMediaType, MyComDeleterFunctor>(nativeType);
258-
// get a wave format
259+
// get a wave format
259260
hr = MFCreateWaveFormatExFromMFMediaType(nativeType, &nativeFormat, &formatSize);
260-
261+
261262
mNumChannels = nativeFormat->nChannels;
262263
mSampleRate = nativeFormat->nSamplesPerSec;
263264

264265
CoTaskMemFree(nativeFormat);
265-
266+
266267

267268
ComPtr<IMFMediaType> mediaType;
268269
hr = MFCreateMediaType(mediaType.GetAddressOf());
@@ -335,19 +336,19 @@ bool ofMediaFoundationSoundPlayer::load(const of::filesystem::path & fileName, b
335336
}
336337

337338
ofLogVerbose("ofMediaFoundationSoundPlayer::load") << "made it all the way to the end.";
338-
339+
339340
if (!mBStreaming) {
340341
mSrcReader.Reset();
341342
mSrcReader = nullptr;
342343
}
343344

344345
{
345346

346-
// create stream context for listening to voice
347+
// create stream context for listening to voice
347348
mVoiceContext = std::make_shared<StreamingVoiceContext>();
348349
// Create the source voice
349350
IXAudio2SourceVoice* pSourceVoice = nullptr;
350-
// setting max freq ratio to 3, though it may need to be higher to play at a
351+
// setting max freq ratio to 3, though it may need to be higher to play at a
351352
// faster pitch
352353
if (mBStreaming) {
353354
hr = sXAudio2->CreateSourceVoice(
@@ -430,7 +431,7 @@ void ofMediaFoundationSoundPlayer::unload() {
430431
mTotalNumFrames = 0;
431432
mNumSamplesAlreadyPlayed = 0;
432433
mBRequestNewReaderSample = false;
433-
434+
434435
LeaveCriticalSection(&m_critSec);
435436
};
436437

@@ -467,7 +468,7 @@ void ofMediaFoundationSoundPlayer::update(ofEventArgs& args) {
467468
} else {
468469
bRequestStop = true;
469470
// we need to request stop outside of the scope of the lock
470-
// since stop() also locks to set vars
471+
// since stop() also locks to set vars
471472
}
472473
}
473474
}
@@ -497,7 +498,7 @@ void ofMediaFoundationSoundPlayer::update(ofEventArgs& args) {
497498
if (!xstate.BuffersQueued && mExtraVoices.size() < 1) {
498499
// we have reached the end //
499500
if (mBLoop) {
500-
// set isPlaying to false, so that it will create a new instance
501+
// set isPlaying to false, so that it will create a new instance
501502
// for mVoice and not an Extra Voice
502503
mPosPct = 0.0f;
503504
mBIsPlaying = false;
@@ -530,7 +531,7 @@ void ofMediaFoundationSoundPlayer::play() {
530531
return;
531532
}
532533

533-
// don't want a ton of loops going on here
534+
// don't want a ton of loops going on here
534535
if (mBLoop) {
535536
stop();
536537
}
@@ -539,7 +540,7 @@ void ofMediaFoundationSoundPlayer::play() {
539540
}
540541

541542
if (mBStreaming) {
542-
// just in case, multiplay is not supported for streams
543+
// just in case, multiplay is not supported for streams
543544
_clearExtraVoices();
544545
}
545546

@@ -583,7 +584,7 @@ void ofMediaFoundationSoundPlayer::play() {
583584
XAUDIO2_BUFFER buffer = {};
584585
buffer.pAudioData = mBuffer.data();
585586
// tell the source voice not to expect any data after this buffer
586-
buffer.Flags = XAUDIO2_END_OF_STREAM;
587+
buffer.Flags = XAUDIO2_END_OF_STREAM;
587588
buffer.AudioBytes = mBuffer.size();
588589

589590
hr = pSourceVoice->SubmitSourceBuffer(&buffer);
@@ -605,7 +606,7 @@ void ofMediaFoundationSoundPlayer::play() {
605606
buffer.AudioBytes = mBuffer.size();
606607

607608
mVoice->SubmitSourceBuffer(&buffer);
608-
609+
609610
}
610611

611612
mVoice->SetVolume(mVolume);
@@ -711,7 +712,7 @@ void ofMediaFoundationSoundPlayer::setPaused(bool bP) {
711712
//--------------------
712713
void ofMediaFoundationSoundPlayer::setLoop(bool bLp) {
713714
if (bLp) {
714-
// we don't want a lot of looping iterations
715+
// we don't want a lot of looping iterations
715716
_clearExtraVoices();
716717
}
717718
mBLoop = bLp;
@@ -740,7 +741,7 @@ void ofMediaFoundationSoundPlayer::setPosition(float pct) {
740741
ofLogWarning("ofMediaFoundationSoundPlayer::setPosition") << " unable to seek.";
741742
return;
742743
}
743-
744+
744745
// ok we need to kill buffers and resubmit a buffer
745746
if (mVoice) {
746747
std::ignore = mVoice->Stop();
@@ -785,7 +786,7 @@ void ofMediaFoundationSoundPlayer::setPositionMS(int ms) {
785786
};
786787

787788
//--------------------
788-
float ofMediaFoundationSoundPlayer::getPosition() const {
789+
float ofMediaFoundationSoundPlayer::getPosition() const {
789790
return mPosPct;
790791
};
791792

@@ -880,7 +881,7 @@ void ofMediaFoundationSoundPlayer::OnSourceReaderEvent(HRESULT hrStatus, DWORD d
880881
}
881882

882883
hr = mediaBuffer->Unlock();
883-
884+
884885
if (mVoice && mVoiceContext) {
885886
XAUDIO2_VOICE_STATE state;
886887

@@ -909,7 +910,7 @@ void ofMediaFoundationSoundPlayer::OnSourceReaderEvent(HRESULT hrStatus, DWORD d
909910
std::unique_lock<std::mutex> lk(mSrcReaderMutex);
910911
mBRequestNewReaderSample = true;
911912
}
912-
913+
913914
}
914915
}
915916

@@ -953,7 +954,7 @@ void ofMediaFoundationSoundPlayer::_setPan(IXAudio2SourceVoice* avoice, float ap
953954
float outputMatrix[8];
954955
for (int i = 0; i < 8; i++) outputMatrix[i] = 0;
955956

956-
// pan of -1.0 indicates all left speaker,
957+
// pan of -1.0 indicates all left speaker,
957958
// 1.0 is all right speaker, 0.0 is split between left and right
958959
float left = 0.5f - apan / 2;
959960
float right = 0.5f + apan / 2;
@@ -990,7 +991,7 @@ void ofMediaFoundationSoundPlayer::_setPan(IXAudio2SourceVoice* avoice, float ap
990991

991992
// Assuming pVoice sends to pMasteringVoice
992993

993-
// TODO: Cache this
994+
// TODO: Cache this
994995
XAUDIO2_VOICE_DETAILS MasterVoiceDetails;
995996
sXAudioMasteringVoice->GetVoiceDetails(&MasterVoiceDetails);
996997

@@ -1019,7 +1020,7 @@ bool ofMediaFoundationSoundPlayer::_readToBuffer(IMFSourceReader* areader) {
10191020
HRESULT hr = areader->ReadSample(
10201021
MF_SOURCE_READER_FIRST_AUDIO_STREAM,
10211022
0, // Flags.
1022-
&streamIndex, // Receives the actual stream index.
1023+
&streamIndex, // Receives the actual stream index.
10231024
&flags, // Receives status flags.
10241025
&llAudioTimeStamp, // Receives the time stamp.
10251026
&audioSample // Receives the sample or NULL.
@@ -1049,14 +1050,14 @@ bool ofMediaFoundationSoundPlayer::_readToBuffer(IMFSourceReader* areader) {
10491050
if (hr != S_OK) {
10501051
continue;
10511052
}
1052-
1053+
10531054
size_t numFramesRead = uint64_t(sampleBufferLength) / (bytes64 * numChannels64);
10541055
ofLogVerbose("ofMediaFoundationSoundPlayer::_readToBuffer") << "sampleBufferLength : " << sampleBufferLength << " num frames: " << numFramesRead << std::endl;
10551056
totalFrames += numFramesRead;
10561057
std::vector<BYTE> tempBuffer;
10571058
tempBuffer.resize(sampleBufferLength, 0);
10581059
memcpy_s(tempBuffer.data(), sampleBufferLength, audioData, sampleBufferLength);
1059-
// add into the main buffer?
1060+
// add into the main buffer?
10601061
mBuffer.insert(mBuffer.end(), tempBuffer.begin(), tempBuffer.end());
10611062

10621063
hr = mediaBuffer->Unlock();
@@ -1073,3 +1074,5 @@ bool ofMediaFoundationSoundPlayer::_readToBuffer(IMFSourceReader* areader) {
10731074
ofLogVerbose("ofMediaFoundationSoundPlayer::_readToBuffer") << "Total frames read: " << (totalFrames) << " mTotalNumFrames: " << mTotalNumFrames << " dur millis: " << durMillis << " dur seconds: " << durSeconds << std::endl;
10741075
return mBuffer.size() > 0;
10751076
}
1077+
1078+
#endif

0 commit comments

Comments
 (0)