Skip to content

Commit 9e05d97

Browse files
authored
Merge branch 'openframeworks:master' into avplayer
2 parents 0340590 + 4777b61 commit 9e05d97

File tree

16 files changed

+188
-89
lines changed

16 files changed

+188
-89
lines changed

.github/workflows/of.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
steps:
3333
- uses: actions/checkout@v4
3434
- name: Docker Step
35-
run: "docker run -di --name emscripten -v $PWD:/src emscripten/emsdk:3.1.73 bash"
35+
run: "docker run -di --name emscripten -v $PWD:/src emscripten/emsdk:3.1.74 bash"
3636
# - name: Determine Release
3737
# id: vars
3838
# shell: bash
@@ -173,12 +173,12 @@ jobs:
173173
suffix: arm-linux-gnueabihf,
174174
alladdons: 1,
175175
}
176-
- {
177-
libs: armv7l,
178-
multistrap_arch: armhf,
179-
suffix: arm-linux-gnueabihf,
180-
alladdons: 1,
181-
}
176+
# - {
177+
# libs: armv7l,
178+
# multistrap_arch: armhf,
179+
# suffix: arm-linux-gnueabihf,
180+
# alladdons: 1,
181+
# }
182182
- {
183183
libs: aarch64,
184184
multistrap_arch: arm64,

LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
---
44

5-
Copyright (c) 2004 - openFrameworks Community
5+
Copyright (c) 2025 - openFrameworks Community
66

77
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
88

examples/sound/audioOutputExample/src/ofApp.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,19 @@ void ofApp::setup(){
4545
// Latest linux versions default to the HDMI output
4646
// this usually fixes that. Also check the list of available
4747
// devices if sound doesn't work
48+
49+
//settings.setApi(ofSoundDevice::MS_ASIO);
50+
//settings.setApi(ofSoundDevice::MS_WASAPI);
51+
//settings.setApi(ofSoundDevice::MS_DS);
52+
4853
auto devices = soundStream.getMatchingDevices("default");
4954
if(!devices.empty()){
5055
settings.setOutDevice(devices[0]);
5156
}
5257

5358

59+
60+
5461
settings.setOutListener(this);
5562
settings.sampleRate = sampleRate;
5663
settings.numOutputChannels = 2;

libs/openFrameworks/events/ofEvents.cpp

+20-13
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ double ofGetLastFrameTime() {
4848
if (window) {
4949
return window->events().getLastFrameTime();
5050
} else {
51-
return 0.f;
51+
return 0.0;
5252
}
5353
}
5454

@@ -123,9 +123,10 @@ int ofGetPreviousMouseY() {
123123
}
124124

125125
ofCoreEvents::ofCoreEvents()
126-
: targetRate(0)
126+
: targetRate(60.0)
127+
, fixedRateTimeNanos(std::chrono::nanoseconds(ofGetFixedStepForFps(60.0)))
127128
, bFrameRateSet(false)
128-
, fps(60)
129+
, fps(60.0)
129130
, currentMouseX(0)
130131
, currentMouseY(0)
131132
, previousMouseX(0)
@@ -183,6 +184,7 @@ void ofCoreEvents::enable() {
183184

184185
void ofCoreEvents::setTimeModeSystem() {
185186
timeMode = System;
187+
fps.setTimeMode(timeMode);
186188
}
187189

188190
ofTimeMode ofCoreEvents::getTimeMode() const {
@@ -192,11 +194,13 @@ ofTimeMode ofCoreEvents::getTimeMode() const {
192194
void ofCoreEvents::setTimeModeFixedRate(uint64_t nanosecsPerFrame) {
193195
timeMode = FixedRate;
194196
fixedRateTimeNanos = std::chrono::nanoseconds(nanosecsPerFrame);
197+
fps.setTimeMode(timeMode);
195198
}
196199

197200
void ofCoreEvents::setTimeModeFiltered(float alpha) {
198201
timeMode = Filtered;
199202
fps.setFilterAlpha(alpha);
203+
fps.setTimeMode(timeMode);
200204
}
201205

202206
//--------------------------------------
@@ -210,13 +214,18 @@ void ofCoreEvents::setFrameRate(int _targetRate) {
210214
bFrameRateSet = false;
211215
} else {
212216
bFrameRateSet = true;
213-
targetRate = _targetRate;
217+
targetRate = static_cast<float>(_targetRate);
214218

215219
// uint64_t nanosPerFrame = 1000000000.0 / (double)targetRate;
216220
// timer.setPeriodicEvent(nanosPerFrame);
217221

218-
timerFps.setFps(targetRate);
222+
timerFps.setFps(_targetRate);
223+
fps.setTargetFPS(targetRate);
224+
if (timeMode == FixedRate) {
225+
ofSetTimeModeFixedRate(ofGetFixedStepForFps(targetRate));
226+
}
219227
}
228+
220229
}
221230

222231
bool ofCoreEvents::getTargetFrameRateEnabled() const {
@@ -301,15 +310,8 @@ bool ofCoreEvents::notifyUpdate() {
301310

302311
//------------------------------------------
303312
bool ofCoreEvents::notifyDraw() {
304-
auto attended = ofNotifyEvent(draw, voidEventArgs);
305-
306-
if (bFrameRateSet) {
307-
// timer.waitNext();
308-
timerFps.waitNext();
309-
}
310-
311313
if (fps.getNumFrames() == 0) {
312-
if (bFrameRateSet) fps = ofFpsCounter(targetRate);
314+
if (bFrameRateSet) fps = ofFpsCounter(targetRate, timeMode);
313315
} else {
314316
/*if(ofIsVerticalSyncEnabled()){
315317
float rate = ofGetRefreshRate();
@@ -318,7 +320,12 @@ bool ofCoreEvents::notifyDraw() {
318320
lastFrameTime = intervals*1000000/rate;
319321
}*/
320322
}
323+
if (bFrameRateSet) {
324+
// timer.waitNext();
325+
timerFps.waitNext();
326+
}
321327
fps.newFrame();
328+
auto attended = ofNotifyEvent(draw, voidEventArgs);
322329
return attended;
323330
}
324331

libs/openFrameworks/events/ofEvents.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ class ofCoreEvents {
406406
bool notifyDragEvent(ofDragInfo info);
407407

408408
private:
409-
float targetRate;
409+
float targetRate = 60.0f;
410410
bool bFrameRateSet;
411411
ofTimerFps timerFps;
412412
// ofTimer timer;
@@ -420,7 +420,7 @@ class ofCoreEvents {
420420
int modifiers = 0;
421421

422422
enum TimeMode {
423-
System,
423+
System = 0,
424424
FixedRate,
425425
Filtered,
426426
} timeMode

libs/openFrameworks/sound/ofRtAudioSoundStream.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,16 @@ bool ofRtAudioSoundStream::setup(const ofSoundStreamSettings & settings_)
140140

141141
try {
142142
if (settings.getApi() != ofSoundDevice::Api::UNSPECIFIED) {
143+
ofLogNotice() << "Initialing RtAudio Requested API: " << settings.getApi();
143144
audio = std::make_shared<RtAudio>(toRtAudio(settings.getApi()));
144145
}else{
146+
ofLogNotice() << "Initialing RtAudio with UNSPECIFIED API";
145147
audio = std::make_shared<RtAudio>();
146148
}
149+
ofLogNotice() << "Initialized RtAudio with API: " << RtAudio::getApiName(audio->getCurrentApi());
147150
}
148151
catch (std::exception &error) {
149-
ofLogError() << error.what();
152+
ofLogError() << "Failed to initialize RtAudio: " << error.what();
150153
return false;
151154
}
152155

@@ -155,6 +158,7 @@ bool ofRtAudioSoundStream::setup(const ofSoundStreamSettings & settings_)
155158
if (settings.numInputChannels > 0) {
156159
if (!settings.getInDevice()) {
157160
ofSoundDevice device;
161+
device.api = settings.getApi();
158162
device.deviceID = audio->getDefaultInputDevice();
159163
settings.setInDevice(device);
160164
}
@@ -165,6 +169,7 @@ bool ofRtAudioSoundStream::setup(const ofSoundStreamSettings & settings_)
165169
if (settings.numOutputChannels > 0) {
166170
if (!settings.getOutDevice()) {
167171
ofSoundDevice device;
172+
device.api = settings.getApi();
168173
device.deviceID = audio->getDefaultOutputDevice();
169174
settings.setOutDevice(device);
170175
}

libs/openFrameworks/sound/ofSoundBaseTypes.cpp

+11-4
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,25 @@ std::string toString(ofSoundDevice::Api api){
2222
case ofSoundDevice::MS_DS:
2323
return "MS DirectShow";
2424
default:
25-
return "Unkown API";
25+
return "Unknown API";
2626
}
2727
}
2828

2929

3030
void ofBaseSoundStream::printDeviceList() const {
3131
ofLogNotice("ofBaseSoundStream::printDeviceList") << std::endl;
3232
#ifndef TARGET_EMSCRIPTEN
33-
for(int i=ofSoundDevice::ALSA; i<ofSoundDevice::NUM_APIS; ++i){
34-
ofSoundDevice::Api api = (ofSoundDevice::Api)i;
33+
std::vector<ofSoundDevice::Api> platformApis;
34+
#ifdef TARGET_LINUX
35+
platformApis = { ofSoundDevice::ALSA, ofSoundDevice::PULSE, ofSoundDevice::OSS, ofSoundDevice::JACK };
36+
#elif defined(TARGET_OSX)
37+
platformApis = { ofSoundDevice::OSX_CORE };
38+
#elif defined(TARGET_WIN32)
39+
platformApis = { ofSoundDevice::MS_WASAPI, ofSoundDevice::MS_ASIO, ofSoundDevice::MS_DS };
40+
#endif
41+
for (auto api : platformApis) {
3542
auto devices = getDeviceList(api);
36-
if(!devices.empty()){
43+
if (!devices.empty()) {
3744
ofLogNotice("ofBaseSoundStream::printDeviceList") << "Api: " << toString(api);
3845
ofLogNotice("ofBaseSoundStream::printDeviceList") << devices;
3946
}

libs/openFrameworks/sound/ofSoundStream.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ bool ofSoundStreamSettings::setInDevice(const ofSoundDevice & device){
6666
}
6767
api = device.api;
6868
inDevice = device;
69+
inDevice.api = api;
6970
return true;
7071
}
7172

@@ -76,6 +77,7 @@ bool ofSoundStreamSettings::setOutDevice(const ofSoundDevice & device){
7677
}
7778
api = device.api;
7879
outDevice = device;
80+
outDevice.api = api;
7981
return true;
8082
}
8183

@@ -86,7 +88,7 @@ bool ofSoundStreamSettings::setApi(ofSoundDevice::Api api){
8688
return false;
8789
}
8890
if(api!=ofSoundDevice::UNSPECIFIED && outDevice.deviceID!=-1 && outDevice.api != api){
89-
ofLogError("ofSoundStreamSettings") << "Setting API after setting IN device with api: " << toString(outDevice.api) << " won't do anything";
91+
ofLogError("ofSoundStreamSettings") << "Setting API after setting OUT device with api: " << toString(outDevice.api) << " won't do anything";
9092
return false;
9193
}
9294
this->api = api;

libs/openFrameworks/utils/ofConstants.h

+14-8
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,13 @@ enum ofTargetPlatform{
150150
#define GLEW_NO_GLU
151151
#define TARGET_GLFW_WINDOW
152152
#define OF_CAIRO
153-
#define OF_RTAUDIO
154153
#include "GL/glew.h"
155154
#include "GL/wglew.h"
155+
#define OF_RTAUDIO
156156
#define __WINDOWS_DS__
157-
#define __WINDOWS_MM__
157+
#define __WINDOWS_WASAPI__
158+
#define __WINDOWS_ASIO__
159+
#define __WINDOWS_MM__ // rtMidi?
158160
#if (_MSC_VER) // microsoft visual studio
159161
//TODO: Fix this in the code instead of disabling the warnings
160162
#define _CRT_SECURE_NO_WARNINGS
@@ -200,18 +202,15 @@ enum ofTargetPlatform{
200202
#endif
201203

202204
#if defined(TARGET_OS_OSX) && !defined(TARGET_OF_IOS)
203-
#ifndef __MACOSX_CORE__
204-
#define __MACOSX_CORE__
205-
#endif
206205
#define TARGET_GLFW_WINDOW
207206
#define OF_CAIRO
208207
#define OF_RTAUDIO
209-
208+
#ifndef __MACOSX_CORE__
209+
#define __MACOSX_CORE__ // rtAudio
210+
#endif
210211
#ifndef OF_NO_FMOD
211212
#define OF_NO_FMOD
212213
#endif
213-
214-
215214
#include "GL/glew.h"
216215
#include "OpenGL/OpenGL.h"
217216

@@ -245,6 +244,13 @@ enum ofTargetPlatform{
245244
#else // desktop linux
246245
#define TARGET_GLFW_WINDOW
247246
#define OF_RTAUDIO
247+
#ifndef __LINUX_PULSE__
248+
#define __LINUX_PULSE__
249+
#endif
250+
#ifndef __LINUX_ALSA__
251+
#define __LINUX_ALSA__
252+
#endif
253+
#define __LINUX_OSS__
248254
#include <GL/glew.h>
249255
#endif
250256

0 commit comments

Comments
 (0)