-
-
Notifications
You must be signed in to change notification settings - Fork 429
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
[audio] Improve audio duration computation #3675
[audio] Improve audio duration computation #3675
Conversation
3e0275a
to
58244bd
Compare
@@ -102,7 +104,9 @@ public AudioFormat getFormat() { | |||
|
|||
@Override | |||
public int read() throws IOException { | |||
return inputStream.read(); | |||
int read = inputStream.read(); | |||
alreadyRead++; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it rather alreadyRead += read;
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "alreadyRead" counter is the amount of bytes read.
The read() method reads only one byte and return the value of this byte.
So just +1 at every call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
logger.debug("Cannot compute the duration of input stream with method java stream sound analysis", | ||
e); | ||
Integer bitRate = audioFormat.getBitRate(); | ||
Integer channel = audioFormat.getChannels(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
channel
is then apparently not used, is it normal ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I used this on a previous try but it is not needed.
I will remove it.
Allows the use of a Sizeable interface (for AudioStream that we know the length of, but we cannot clone). We can then improve the duration detection, for example for the pulseaudio sink (PR coming after). We can also give the length information to sink in more cases. Add the support of the mark / reset methods to some common AudioStream. We then allow more stream analysis for sink requiring it (Stream analysis often requires to get back in time after consuming a few bytes) Signed-off-by: Gwendal Roulleau <[email protected]>
58244bd
to
5fd27ca
Compare
Build failed in "Automation Integration Tests". Not sure it have any link with your PR. |
Allows the use of a Sizeable interface (for AudioStream that we know the length of, but we cannot clone). We can then improve the duration detection, for example for the pulseaudio sink (PR coming after). We can also give the length information to sink in more cases. Add the support of the mark / reset methods to some common AudioStream. We then allow more stream analysis for sink requiring it (Stream analysis often requires to get back in time after consuming a few bytes) Signed-off-by: Gwendal Roulleau <[email protected]> GitOrigin-RevId: 3ec1457
Add another way of computing sound duration (using information from the AudioFormat class)
Allows the use of a "Sizeable" interface (for AudioStream that we know the length of, but we cannot clone). We can then improve the success of the duration detection, for example for the pulseaudio sink (PR coming after). We can also give the length information to sink in more cases, even if we cannot clone the stream.
Add the support of the mark / reset methods to some common AudioStream. We then allow more stream analysis for sink requiring it (Stream analysis often requires to get back in time after consuming a few bytes)