mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-01 13:57:32 +00:00
Bug 1647956 - Import cubeb from upstream to 575bd44. r=padenot
pick commits: 575bd44 - resampler: avoid overflow on uint arithmetics 7bc4f13 - Add in header doc the switching devices behavior. Differential Revision: https://phabricator.services.mozilla.com/D81695
This commit is contained in:
parent
c7b500052d
commit
b1f143193d
@ -1061,3 +1061,21 @@ TEST(cubeb, passthrough_resampler_fill_input_left) {
|
||||
ASSERT_EQ(input_frame_count, output_frame_count - 8);
|
||||
}
|
||||
|
||||
TEST(cubeb, individual_methods) {
|
||||
const uint32_t channels = 2;
|
||||
const uint32_t sample_rate = 44100;
|
||||
const uint32_t frames = 256;
|
||||
|
||||
delay_line<float> dl(10, channels, sample_rate);
|
||||
uint32_t frames_needed1 = dl.input_needed_for_output(0);
|
||||
ASSERT_EQ(frames_needed1, 0u);
|
||||
|
||||
cubeb_resampler_speex_one_way<float> one_way(channels, sample_rate, sample_rate, CUBEB_RESAMPLER_QUALITY_DEFAULT);
|
||||
float buffer[channels * frames] = {0.0};
|
||||
// Add all frames in the resampler's internal buffer.
|
||||
one_way.input(buffer, frames);
|
||||
// Ask for less than the existing frames, this would create a uint overlflow without the fix.
|
||||
uint32_t frames_needed2 = one_way.input_needed_for_output(0);
|
||||
ASSERT_EQ(frames_needed2, 0u);
|
||||
}
|
||||
|
||||
|
@ -487,11 +487,17 @@ CUBEB_EXPORT void cubeb_destroy(cubeb * context);
|
||||
cubeb stream.
|
||||
@param stream_name A name for this stream.
|
||||
@param input_device Device for the input side of the stream. If NULL the
|
||||
default input device is used.
|
||||
default input device is used. Passing a valid cubeb_devid
|
||||
means the stream only ever uses that device. Passing a NULL
|
||||
cubeb_devid allows the stream to follow that device type's
|
||||
OS default.
|
||||
@param input_stream_params Parameters for the input side of the stream, or
|
||||
NULL if this stream is output only.
|
||||
@param output_device Device for the output side of the stream. If NULL the
|
||||
default output device is used.
|
||||
default output device is used. Passing a valid cubeb_devid
|
||||
means the stream only ever uses that device. Passing a NULL
|
||||
cubeb_devid allows the stream to follow that device type's
|
||||
OS default.
|
||||
@param output_stream_params Parameters for the output side of the stream, or
|
||||
NULL if this stream is input only.
|
||||
@param latency_frames Stream latency in frames. Valid range
|
||||
|
@ -19,5 +19,5 @@ origin:
|
||||
license: "ISC"
|
||||
|
||||
# update.sh will update this value
|
||||
release: "e2ffb10843c5456212f480c658edfc29930e4f55 (2020-06-10 13:03:04 +1200)"
|
||||
release: "575bd443893638da4a88468576e4e10b706c7a6c (2020-06-30 22:57:45 +1200)"
|
||||
|
||||
|
@ -283,8 +283,9 @@ public:
|
||||
* exactly `output_frame_count` resampled frames. This can return a number
|
||||
* slightly bigger than what is strictly necessary, but it guaranteed that the
|
||||
* number of output frames will be exactly equal. */
|
||||
uint32_t input_needed_for_output(uint32_t output_frame_count) const
|
||||
uint32_t input_needed_for_output(int32_t output_frame_count) const
|
||||
{
|
||||
assert(output_frame_count >= 0); // Check overflow
|
||||
int32_t unresampled_frames_left = samples_to_frames(resampling_in_buffer.length());
|
||||
int32_t resampled_frames_left = samples_to_frames(resampling_out_buffer.length());
|
||||
float input_frames_needed =
|
||||
@ -462,8 +463,9 @@ public:
|
||||
* @parameter frames_needed the number of frames one want to write into the
|
||||
* delay_line
|
||||
* @returns the number of frames one will get. */
|
||||
size_t input_needed_for_output(uint32_t frames_needed) const
|
||||
uint32_t input_needed_for_output(int32_t frames_needed) const
|
||||
{
|
||||
assert(frames_needed >= 0); // Check overflow
|
||||
return frames_needed;
|
||||
}
|
||||
/** Returns the number of frames produces for `input_frames` frames in input */
|
||||
|
Loading…
x
Reference in New Issue
Block a user