Skip to content
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

Stopping playback does not stop currently playing audio files #20

Open
sgreene570 opened this issue Feb 1, 2019 · 5 comments
Open

Stopping playback does not stop currently playing audio files #20

sgreene570 opened this issue Feb 1, 2019 · 5 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@sgreene570
Copy link
Owner

pthreads need to be killed when "stopping" the play back sequence even if the song is actually longer than a couple seconds. Long wav files will play until done once they start. This is a problem.

@sgreene570 sgreene570 assigned sgreene570 and unassigned sgreene570 Feb 1, 2019
@sgreene570 sgreene570 added bug Something isn't working help wanted Extra attention is needed labels Feb 1, 2019
@sgreene570
Copy link
Owner Author

this is gonna be a little tricky to fix.
This section will need to be re-worked.
https://github.com/sgreene570/sampleZone/blob/master/sampleZone.c#L88

@sgreene570
Copy link
Owner Author

this is a big bet

@WillNilges
Copy link
Collaborator

WillNilges commented May 13, 2019

I was looking into this and I found some interesting stuff in the manpages. It might not be so complex, unless I'm missing a detail, but it should be possible to stop the thread by referencing its ID.

Before returning, a successful call to pthread_create() stores the ID
of the new thread in the buffer pointed to by thread; this identifier is
used to refer to the thread in subsequent calls to other pthreads functions.

You might also just be able to keep track of the threads in the first place with an array and then pthread_canceling them accordingly. The issue then becomes that this would probably require some intense malloc action, since big sampleZone projects would have a lot of threads.

@WillNilges
Copy link
Collaborator

So I think I've found another clue that could turn into a solution. The thread starts, and is stopped by pressing space like I've been doing, but that's not what needs to stop. In playback.c there is a for loop that appears to control playback. It might be possible to have that function listen for a ' ' and return when it hears that. That should stop the audio.

@WillNilges
Copy link
Collaborator

I might have something resembling a solution in https://github.com/WillNilges/sampleZone/tree/will-threading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants