-
-
Notifications
You must be signed in to change notification settings - Fork 216
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
Add ISink::flush() #703
Comments
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Hi @gavv, I would like to work on this. Can I get it assigned? |
@jeshwanthreddy13 Sure, thanks! |
Sorry, I forgot to update task with one detail. We've recently introduced status codes, so the method should actually be |
Hi @gavv, I implemented
and returning But when I execute
I'm finding it tricky pinpointing where I might be going wrong. Could you please help me identify it? |
I took a closer look at SoxSink::write: status::StatusCode SoxSink::write(audio::Frame& frame) {
...
while (frame_size > 0) {
...
if (buffer_pos == buffer_size_) {
const status::StatusCode code = write_(buffer_data, buffer_pos);
...
}
}
const status::StatusCode code = write_(buffer_data, buffer_pos);
...
return status::StatusOK;
} We can see that the second call to Which means that the problem that we've encountered in #660 (when we created this task) is not because we don't flush from Seems that your implementation: status::StatusCode SoxSink::flush() {
sox_sample_t* buffer_data = buffer_.data();
const status::StatusCode code = write_(buffer_data, buffer_size_);
if (code != status::Statua closer look to SoxSink::write:
status::StatusCode SoxSink::write(audio::Frame& frame) {
...
while (frame_size > 0sOK) {
return code;
}
return status::StatusOK;
} ..actually writes the same buffer to sox again, i.e. it duplicates last frame. Hence the failures in tests. Furthermore, if frame passed to write() was shorter than So what we need instead is to tell sox to flush its buffer. I suspect that this buffering is actually done by stdio, because I see that it uses https://github.com/chirlu/sox/blob/42b3557e13e0fe01a83465b672d89faddbe65f49/src/formats.c#L531 If my assumption is true, we could implement flush something like this:
as it's done here: https://github.com/mansr/sox/blob/0be259eaa9ce3f3fa587a3ef0cf2c0b9c73167a2/src/formats_i.c#L149 |
Did not realise that |
…oc-streaming#703 - Added `virtual ROC_ATTR_NODISCARD status::StatusCode flush()=0` pure virtual function in `sndio::ISink`. - Added this method to all ISink implementations. - Implementations that don't use buffereing are no-op. - For SoxSink, flush() sends the buffered samples to disk. - sndio::Pump invokes `flush()` when it exits from `run()`.
…oc-streaming#703 - Added `virtual ROC_ATTR_NODISCARD status::StatusCode flush()=0` pure virtual function in `sndio::ISink`. - Added this method to all ISink implementations. - Implementations that don't use buffereing are no-op. - For SoxSink, flush() sends the buffered samples to disk. - sndio::Pump invokes `flush()` when it exits from `run()`. - Made SoxSink::write to write only when buffer_pos is greater than zero
…oc-streaming#703 - Added `virtual ROC_ATTR_NODISCARD status::StatusCode flush()=0` pure virtual function in `sndio::ISink`. - Added this method to all ISink implementations. - Implementations that don't use buffereing are no-op. - For SoxSink, flush() sends the buffered samples to disk. - sndio::Pump invokes `flush()` when it exits from `run()`. - Made SoxSink::write to write only when buffer_pos is greater than zero
…s from sink to file - Added `virtual ROC_ATTR_NODISCARD status::StatusCode flush()=0` pure virtual function in `sndio::ISink`. - Added this method to all ISink implementations. - Implementations that don't use buffereing are no-op. - For SoxSink, flush() sends the buffered samples to disk. - sndio::Pump invokes `flush()` when it exits from `run()`. - Made SoxSink::write to write only when buffer_pos is greater than zero
…o file - Added `virtual ROC_ATTR_NODISCARD status::StatusCode flush()=0` pure virtual function in `sndio::ISink`. - Added this method to all ISink implementations. - Implementations that don't use buffereing are no-op. - For SoxSink, flush() sends the buffered samples to disk. - sndio::Pump invokes `flush()` when it exits from `run()`. - Made SoxSink::write to write only when buffer_pos is greater than zero
Landed |
Implement explicit flushing of buffered samples from sink to file.
virtual void flush() = 0
to sndio::ISinkThe text was updated successfully, but these errors were encountered: