473,473 Members | 1,739 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Portaudio wants a callback function pointer, but I have the data in a class

31 New Member
Hello,

I want to use portaudio for my c++ audio project. The problem is: As you can see here and here, it wants me to pass the callback function as a function argument of openDefaultStream(). The problem is: The audio data lies in a class. So there is a object of the class AudioManager() which collects the newest samples. The problem is now: I can't pass a member function pointer to openDefaultStream(), right? Since that would require me to pass the object it should be called on as well. But if I make the function static, how can I access the newest samples then?
Sep 15 '18 #1
1 1644
weaknessforcats
9,208 Recognized Expert Moderator Expert
Write a function that receives data from AudioManager. The function then calls the member function of your class.

Pass the address of this function to Audiomanager.

When AudioManager calls the function, the data received is the input argument and the function updates an object of your class.


Check out the design pattern called Adapter.
Sep 16 '18 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Martin | last post by:
hi, i want to use a callback function for my ob_start inside of a class. but it wont work in any way. ob_start("bar") works fine if the function is not in a class. ob_start("$foo->bar") or...
2
by: Brandon | last post by:
In a templated class I wrote, there is a public typedef for a function pointer. The class has an instance of the function pointer as a private member. That pointer is declared as static so I need...
6
by: keepyourstupidspam | last post by:
Hi, I want to pass a function pointer that is a class member. This is the fn I want to pass the function pointer into: int Scheduler::Add(const unsigned long timeout, void* pFunction, void*...
2
by: TBass | last post by:
Lots of c, new to c++, yada yada yada. You've heard it all before.... Here's my problem: >From the header for a library: typedef struct loDriver { void (*ldSubscribe)(const loCaller *, int...
2
by: Sam Waller | last post by:
/********************* **********************/ I'm trying to declare a function pointer in class A and set it in class B, but I get syntax errors. How can I get this to compile and run? ...
7
by: morz | last post by:
#include <cstdlib> #include <iostream> using namespace std; what wrong with my code? how to correct this code to make it works? Thanks. class test { public:
2
by: hs.samix | last post by:
Hello, I am trying to use a library which has a function, lets call it an external function, which wants a function pointer as one of its arguments. If I use that library in a C program, all...
5
by: romcab | last post by:
Hi guys, I know function pointers but I'm having a hard time about callback function when it is associated with abstract class. I have an example code below which I got from a book. Kindly...
7
by: ghulands | last post by:
I am having trouble implementing some function pointer stuff in c++ An object can register itself for many events void addEventListener(CFObject *target, CFEventHandler callback, uint8_t...
6
by: sasha | last post by:
I have a c++ code that callls csharp. Now I want to be able to pass a function pointer from C++ to Csharp code and have c# callback to it. Is it possible and how? Here is what I have so far :...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.