mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-11 13:30:07 -05:00
stream: add function to set adaptive resampler rate
Make a function to set the adaptive resampler.
This commit is contained in:
parent
188d920733
commit
433afeaa1e
2 changed files with 29 additions and 0 deletions
|
|
@ -2595,3 +2595,23 @@ int pw_stream_trigger_process(struct pw_stream *stream)
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SPA_EXPORT
|
||||||
|
int pw_stream_set_rate(struct pw_stream *stream, double rate)
|
||||||
|
{
|
||||||
|
struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this);
|
||||||
|
bool enable;
|
||||||
|
|
||||||
|
if (impl->rate_match == NULL)
|
||||||
|
return -ENOTSUP;
|
||||||
|
|
||||||
|
if (rate <= 0.0) {
|
||||||
|
rate = 1.0;
|
||||||
|
enable = false;
|
||||||
|
} else {
|
||||||
|
enable = true;
|
||||||
|
}
|
||||||
|
impl->rate_match->rate = rate;
|
||||||
|
SPA_FLAG_UPDATE(impl->rate_match->flags, SPA_IO_RATE_MATCH_FLAG_ACTIVE, enable);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -662,6 +662,15 @@ int pw_stream_trigger_process(struct pw_stream *stream);
|
||||||
* Since 1.2.6 */
|
* Since 1.2.6 */
|
||||||
int pw_stream_emit_event(struct pw_stream *stream, const struct spa_event *event);
|
int pw_stream_emit_event(struct pw_stream *stream, const struct spa_event *event);
|
||||||
|
|
||||||
|
/** Adjust the rate of the stream.
|
||||||
|
* When the stream is using an adaptive resampler, adjust the resampler rate.
|
||||||
|
* When there is no resampler, -ENOTSUP is returned. Activating the adaptive
|
||||||
|
* resampler will add a small amount of delay to the samples, you can deactivate
|
||||||
|
* it again by setting a value <= 0.0.
|
||||||
|
* Since 1.4.0 */
|
||||||
|
int pw_stream_set_rate(struct pw_stream *stream, double rate);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \}
|
* \}
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue