-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Threading not working as expected on Linux #8
Comments
I am not currently working on a linux machine however i will look into the issue you are having. |
I had another, closer, look at the code today and I can see that in bool cAudioThread::start() {
cAudioMutexBasicLock lock(Mutex);
if(IsInit)
return IsInit;
IsInit = true;
#ifdef CAUDIO_PLATFORM_WIN
ThreadHandle = reinterpret_cast<HANDLE>(_beginthreadex(0, 0, threadFunc, this, 0, &ThreadID));
if(ThreadHandle == 0)
CloseHandle( ThreadHandle );
#else
ThreadID = pthread_create( &ThreadHandle, 0, threadFunc, this );
#endif
IsInit = ThreadID != 0;
return IsInit;
} the function returns false on linux, the thread never gets created. I'll look some more at the docs for this tomorrow and see if I can figure out why this would be. I have already made sure that cmake configures gcc to run with the -pthread option (as indicated it should by googling a bit ...) but that had no effect. If you have any idea of what might be wrong here please dont hessitate to point me in the right drection ;o) I have never played with threads before, so this might be a long ride for me othervice ... |
Installing a linux box so i can begin testing. |
Found the problem. This section: #else
ThreadID = pthread_create( &ThreadHandle, 0, threadFunc, this );
#endif
IsInit = ThreadID != 0;
return IsInit; should be: #else
pthread_create( &ThreadHandle, 0, threadFunc, this );
#endif
IsInit = ThreadHandle != 0;
return IsInit; With that fix threadin works as expected on Linux as well ... I'll open a pull request for the fix in a sec ;o) |
Awesome i got caught up yesterday and i wasn't able to look into it. glad you found it. Ill pull once you submit |
Pull request issued ;o) I'll close this issue now. |
Just tested on windows its working correctly. GJ |
Thank you ;o) |
Problem
When building on Linux the variable for threading gets set to 1 all through the CMake config, CMake headers and generated headers. No warnings or errors during compile but the audioManager does not get updated automatically as expected on a threaded version of the library.
Symptoms
All the examples, where the threaded library should make music play through to the end, requires an additional line of
audioMgr->update()
in thewhile(mysound->isPlaying())
block to work as expected.Investigation
I followed the code to the point that I'm sure it's configured correctly and that pthreads gets included in the build. However I think the assistance of a main developer on this issue might get us to a resolution faster.
Solution
I'm prepared to spend time and effort on fixing this issue, seams logical since I'm building on Linux anyways, but would request the help of a developer to get into the code faster (no point in floundering around for a week ;o). Contact me if you can help. I'll get stuck in in the meanwhile...
The text was updated successfully, but these errors were encountered: