File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -113,8 +113,8 @@ impl SymphoniaDecoder {
113113 continue ;
114114 }
115115
116- match decoder. decode ( & current_span) {
117- Ok ( decoded) => break decoded,
116+ let decoded = match decoder. decode ( & current_span) {
117+ Ok ( decoded) => decoded,
118118 Err ( e) => match e {
119119 Error :: DecodeError ( _) => {
120120 // Decode errors are intentionally ignored with no retry limit.
@@ -124,6 +124,15 @@ impl SymphoniaDecoder {
124124 }
125125 _ => return Err ( e) ,
126126 } ,
127+ } ;
128+
129+ // Loop until we get a packet with audio frames. This is necessary because some
130+ // formats can have packets with only metadata, particularly when rewinding, in
131+ // which case the iterator would otherwise end with `None`.
132+ // Note: checking `decoded.frames()` is more reliable than `packet.dur()`, which
133+ // can resturn non-zero durations for packets without audio frames.
134+ if decoded. frames ( ) > 0 {
135+ break decoded;
127136 }
128137 } ;
129138 let spec = decoded. spec ( ) . to_owned ( ) ;
You can’t perform that action at this time.
0 commit comments