-
Notifications
You must be signed in to change notification settings - Fork 14
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
CountDownLatch.await() problem? #17
Comments
@Juanjo3299 Dear developer, 1、“latchCountdown.await();” It is waiting to generate waveform data buffer. For obtaining waveform data, you can refer to this link: https://developer.huawei.com/consumer/en/doc/development/Media-Guides/basic_functions-0000001224604517#section445719453269 |
@Juanjo3299 Dear developer, In this problem, “CountDownLatch” in the thread cannot be used as the basis for whether the thread is released. When “await” waits for 20 seconds, the thread will end. The reason why CountDownLatch is always 1 is that when importing the same audio for many times, since the audio imported for the first time is still generating the waveform, then the same audio is imported and the waveform is generated. Then, the later imported CountDownLatch will be discarded. At this time, CountDownLatch is useless, but this does not affect the waveform generation of this audio. To prevent threads from waiting all the time due to "being discarded", you can consider adding the lock or synchronized keyword to generate waveforms in turn when generating waveforms, or you can set the wait duration through await to prevent threads from waiting all the time. Another way is to maintain a list. When generating waveforms, first determine whether the current audio is generating waveforms. |
@xuxiapu Thanks, could you just provide an example of synchronized please. |
@Juanjo3299 You can refer to the following sample code. I hope it will be helpful to you.
|
@xuxiapu Hello, for now I will leave it in a certain time limit. But it would be of great help if in the example you could already apply the preventive solution of this problem to be able to apply it correctly and efficiently in my project. Thank you very much. |
@Juanjo3299 Dear developer, |
Hi everyone, in the demo/basic functions application sometimes when importing the same song twice, at the moment when "latchCountdown.await();" is called. It doesn't go to the next line of code, this affects the fact that I don't know exactly when that song finished loading.
The text was updated successfully, but these errors were encountered: