-
-
Notifications
You must be signed in to change notification settings - Fork 217
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
roc_audio: adjust resampler coef #113
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,14 +16,12 @@ | |
namespace roc { | ||
namespace sndio { | ||
|
||
Player::Player(pipeline::IReceiver& input, | ||
core::BufferPool<audio::sample_t>& buffer_pool, | ||
Player::Player(core::BufferPool<audio::sample_t>& buffer_pool, | ||
core::IAllocator& allocator, | ||
bool oneshot, | ||
packet::channel_mask_t channels, | ||
size_t sample_rate) | ||
: output_(NULL) | ||
, input_(input) | ||
, buffer_pool_(buffer_pool) | ||
, allocator_(allocator) | ||
, clips_(0) | ||
|
@@ -34,10 +32,6 @@ Player::Player(pipeline::IReceiver& input, | |
roc_panic("player: # of channels is zero"); | ||
} | ||
|
||
if (sample_rate == 0) { | ||
roc_panic("player: sample rate is zero"); | ||
} | ||
|
||
memset(&out_signal_, 0, sizeof(out_signal_)); | ||
out_signal_.rate = sample_rate; | ||
out_signal_.channels = (unsigned)n_channels; | ||
|
@@ -71,18 +65,51 @@ bool Player::open(const char* name, const char* type) { | |
return false; | ||
} | ||
|
||
unsigned long in_rate = (unsigned long)out_signal_.rate; | ||
unsigned long out_rate = (unsigned long)output_->signal.rate; | ||
|
||
if (in_rate != 0 && in_rate != out_rate) { | ||
roc_log(LogError, | ||
"can't open output file or device with the required sample rate: " | ||
"required=%lu suggested=%lu", | ||
out_rate, in_rate); | ||
return false; | ||
} | ||
|
||
roc_log(LogInfo, | ||
"player:" | ||
" bits=%lu out_rate=%lu in_rate=%lu ch=%lu", | ||
(unsigned long)output_->encoding.bits_per_sample, out_rate, in_rate, | ||
(unsigned long)output_->signal.channels); | ||
|
||
return true; | ||
} | ||
|
||
void Player::stop() { | ||
stop_ = 1; | ||
} | ||
|
||
void Player::start(pipeline::IReceiver& input) { | ||
input_ = &input; | ||
core::Thread::start(); | ||
} | ||
|
||
size_t Player::get_sample_rate() const { | ||
if (!output_) { | ||
roc_panic("player: can't get sample rate for non-open output file or device"); | ||
} | ||
return size_t(output_->signal.rate); | ||
} | ||
|
||
void Player::run() { | ||
roc_log(LogDebug, "player: starting thread"); | ||
|
||
if (!input_) { | ||
roc_panic("player: thread is started not from the start() call"); | ||
} | ||
|
||
if (!output_) { | ||
roc_panic("player: thread is started before open() returnes success"); | ||
roc_panic("player: thread is started before open() returned success"); | ||
} | ||
|
||
loop_(); | ||
|
@@ -115,7 +142,7 @@ void Player::loop_() { | |
SOX_SAMPLE_LOCALS; | ||
|
||
while (!stop_) { | ||
pipeline::IReceiver::Status status = input_.read(frame); | ||
pipeline::IReceiver::Status status = input_->read(frame); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should panic if run() was called and input_ is null. A panic is better than a segfault. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
|
||
if (status == pipeline::IReceiver::Inactive) { | ||
if (oneshot_ && n_bufs_ != 0) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should panic if out_sample_rate is zero. A panic is better than a segfault.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed