Comments (6)
Who deletes the std::string?
from oboe.
const char * may be old school but it has advantages.
The caller does not have to delete the string.
So it can easily be used in logs.
Also std::string may cause a memory allocation, which should be avoided in real-time audio.
from oboe.
There is no need to delete the string. I think, Don is proposing to return 'std::string' by value, not as a pointer to an allocated object. And in those cases compilers usually provide optimizations to avoid unneeded allocations or copying.
The advantage of returning an std::string is that the error text may be composed on the fly.
As for the 'real-time' issue—if an error happens it's already a problem, and requires taking the error handling code path, which is allowed to be non-optimal (think of exception handling).
from oboe.
It seems like we are taking something very simple and converting it to something more complex.
If we want to add the result code to the string, we could could add a convenience function that called the simple (const char *) function then added the result code and returned a std::string.
Or the app could do that very easily.
from oboe.
The motivation isn't primarily because we want to return a result code (although it does help with that), it's that users of the Oboe library may prefer to receive a std::string over a C-style string.
Some benefits of std::string over C strings: https://embeddedartistry.com/blog/2017/7/24/stdstring-vs-c-strings
As for your point about memory allocation - this is true and we should be very clear in the comments and documentation that the convertToText
method shouldn't be called in the data callback under normal conditions.
I've asked some partners for their opinions on what they'd prefer - maybe C-style strings are still en vogue for audio programmers.
from oboe.
Things are better in C++17 but Android Studio only supports up to C++14 so closing for now.
from oboe.
Related Issues (20)
- sample Buzzing and low pitched HOT 3
- Unable to set PerformanceMode::LowLatency HOT 4
- Builds with 16 KB page size HOT 4
- Add Intent for starting TEST DISCONNECT for automation HOT 1
- OboeTester: when Data Paths fails, save a WAV file recording
- OboeTester DataPaths fails intermittently when converting sample rate
- OboeTester: long tests should show running tally of pass/fail
- We should update docs/AndroidAudioHistory.md
- Question: How to find out if Oboe is performing Sample Rate Conversion? HOT 2
- Is there any way to detach a faulty oboe program or insufficient memory for it to process? HOT 4
- Can't get Low Latency HOT 2
- LiveEffect sample: is there any way to get input stream from default/incoming VOIP call audio source instead of only microphone HOT 4
- OpenSL can hang if callback returns DataCallbackResult::Stop HOT 1
- Glitch in background, exclusive mode HOT 7
- Add a foreground service to OboeTester
- OboeTester channel frequencies are too high for ChannelMask 7.1.4
- OboeTester Data Paths test failing intermittently HOT 1
- VoIP use case and Low Latency HOT 1
- FilterAudioStream doesn't round frames written and read properly. HOT 1
- Update samples to 16kb page sizes
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from oboe.