Repository navigation
Conversation
|
|
||
| if (ip_data->sf == 0) { | ||
| return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; | ||
| } |
There was a problem hiding this comment.
ip_data->sf should be non zero after _open. if it's zero things are terribly wrong.
There was a problem hiding this comment.
There was a problem hiding this comment.
diff --git a/ip/flac.c b/ip/flac.c
index 90a97b6..1bc585e 100644
--- a/ip/flac.c
+++ b/ip/flac.c
@@ -66,6 +66,8 @@ static T(ReadStatus) read_cb(const Dec *dec, unsigned char *buf, size_t *size, v
struct flac_private *priv = ip_data->private;
int rc;
+ fprintf(stderr, "ip_data->sf = %d\n", ip_data->sf);
+
if (priv->pos == priv->len) {
*size = 0;
return E(READ_STATUS_END_OF_STREAM);Tells me that it's zero sometimes.
There was a problem hiding this comment.
No, my bad. This was the wrong callback.
| } | ||
| priv->ignore_next_write = 1; | ||
| priv->buf_rpos = 0; | ||
| priv->buf_wpos = 0; |
There was a problem hiding this comment.
the FLAC__stream_decoder_seek_absolute will internally call seek_to_absolute_sample_, which process a frame. See https://github.com/xiph/flac/blob/4f47b63e9c971e6391590caf00a0f2a5ed612e67/src/libFLAC/stream_decoder.c#L3140 .
so the wirte_cb will be called during flac_seek.
If buf position is reset to 0, the first block is entirely missing.
Thus, flushing and buf resetting should only be done when something is wrong.
There was a problem hiding this comment.
Then you need to set these before calling seek.
There was a problem hiding this comment.
No. These should never be reset when things are performing without error. otherwise you might get partial samples if flac_read is not finished through the end, and the stream will be broken.
There was a problem hiding this comment.
Let's say that we're seeking from 5s to 10s. At the point of the seek we've already buffered the samples up to 5.5s. If we don't reset these values, then, after the seek, we'll continue to play the samples from 5s to 5.5s and only then start to play the samples at 10s.
Is this the intended behavior?
There was a problem hiding this comment.
I think the original author is mislead by flac doc, which mentioned the stream may contain a partial block when seeking. So he tried to reset that block. But what flac doc really means is you won't get the entire block as you normally do when using process_single, becauce the sample may live in the middle of a flac block (which contains various samples). But flac ensures you that you won't get partial samples. You'll always get right data stream when doing seek_absolute. There's no need to reset at all.
There was a problem hiding this comment.
I don't think you've answered my question. I'm talking about our buffer flac_private::buf. Should we not clear this buffer before seeking?
There was a problem hiding this comment.
You are right. Done.
| } | ||
| priv->ignore_next_write = 1; | ||
| priv->buf_rpos = 0; | ||
| priv->buf_wpos = 0; |
There was a problem hiding this comment.
You are right. Done.
|
Merged. |
fix #678