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
Fixed blocksize support in _Recorder.record((with pulseaudio) #11
Conversation
Thank you for your answer. I saw the pull request but nothing happened for 3 weeks so I thought that I could take over. |
You couldn't know this, but @stvol is a colleague of mine, and we had a few discussions about this topic already. He has been away for a few days, that's why progress on that pull request stalled. However, your pull request has made me think about this problem in more depth. My original issue with this kind of scheme was that a user could, hypothetically, open a It seemed like a difficult problem, since pulseaudio does not seem to expose any API for checking for buffer overflows while recording. Today I learned why (by trying it out): Pulse just buffers everything, and will never overrun as long as your memory doesn't fill up. I tried as much as several minutes without issues. This is incredibly convenient, and means that we can go ahead and fix this problem. That said, let's talk API:
I think I don't like how we have to set both
What do you think about these options? |
The solution I found to this problem was to implement the So on the first option, the current For the second option, it's possible that a user would want to request Another question, what should be the value of Also, what drives the choice of the 1ms sleep here in the record code? Maybe the samples will be available before with a small Tell me if I can help or if I let @stvol and you to do what you will decide to do. |
exactly!
Sorry for being unclear: I meant, if the user says
I was thinking about this, too. It should probably be much smaller than your expected
In coreaudio, the only way you can access recorded data is in a callback. This loop just polls a queue that is filled by the callback. It's not a great solution. I am currently working on a better version that uses signals instead of polling, which should be much cleaner.
If you want to, you can go ahead and implement either of the above solutions ( |
I was talking about pulseaudio, and I guess it's not the same. I'm no expert in any of these three libraries, that's why I'm asking.
I'm going to (try to) implement the |
Sorry about that. There are two places where a sleep-wait like this happens, and the more egregious place is in the coreaudio code (which I had open in a separate tab, and confused it with your link). The reason is much the same, though: waiting for new data. I don't want to busy-wait, as this would saturate the CPU unnecessarily and steal resources that other threads might want to use. I guess the correct solution in this case would be to register a callback using (This is untested, but something I intend to try out next week or so)
Cool! I'll look forward to it! |
Here are the proposed changes suggested in #10
fixed_blocksize
(defaultFalse
) in the_Recorder
class_Rercorder.flush
method to empty and return the last unused chunkHere is a working example