summaryrefslogtreecommitdiff
path: root/sys/src
diff options
context:
space:
mode:
authorSigrid Solveig Haflínudóttir <sigrid@ftrv.se>2023-05-17 20:39:36 +0000
committerSigrid Solveig Haflínudóttir <sigrid@ftrv.se>2023-05-17 20:39:36 +0000
commit0883ed0a61c38898ad926ea67eb0e9386dff4ecd (patch)
tree786fe14b6ba23e15e893dafe69c25d86767b43f7 /sys/src
parent8b269f83f4a6513734ebc933d2a33d3fbb72f90f (diff)
audio/flacdec: throw out decoded audio until finished seeking
Diffstat (limited to 'sys/src')
-rw-r--r--sys/src/cmd/audio/flacdec/flacdec.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sys/src/cmd/audio/flacdec/flacdec.c b/sys/src/cmd/audio/flacdec/flacdec.c
index 7861ef3d2..63d1527b4 100644
--- a/sys/src/cmd/audio/flacdec/flacdec.c
+++ b/sys/src/cmd/audio/flacdec/flacdec.c
@@ -10,6 +10,7 @@
static int ifd = 1;
static int pid = -1;
static int sts;
+static int silence;
static void
flushout(void)
@@ -147,7 +148,7 @@ decoutput(FLAC__StreamDecoder *dec, FLAC__Frame *frame, FLAC__int32 *buffer[], v
}
}
n = b * chans * len;
- if(n > 0 && write(ifd, buf, n) != n)
+ if(!silence && n > 0 && write(ifd, buf, n) != n)
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
@@ -192,6 +193,7 @@ int main(int argc, char *argv[])
FLAC__stream_decoder_init_stream(dec, decinput, decseek, dectell, declen, checkeof, decoutput, NULL, decerror, NULL);
if(seek > 0.0){
FLAC__uint64 srate;
+ silence = 1;
do{
if(!FLAC__stream_decoder_process_single(dec))
break;
@@ -201,6 +203,7 @@ int main(int argc, char *argv[])
FLAC__stream_decoder_flush(dec);
seek = 0.0;
}
+ silence = 0;
fprintf(stderr, "time: %g\n", seek);
}
FLAC__stream_decoder_process_until_end_of_stream(dec);