Merge pull request #4565 from Phasip/master
Fix moodbar segfault when playing broken mp3
This commit is contained in:
commit
3de86b902e
|
@ -158,13 +158,15 @@ void MoodbarBuilder::Normalize(QList<Rgb>* vals, double Rgb::*member) {
|
|||
}
|
||||
|
||||
QByteArray MoodbarBuilder::Finish(int width) {
|
||||
Normalize(&frames_, &Rgb::r);
|
||||
Normalize(&frames_, &Rgb::g);
|
||||
Normalize(&frames_, &Rgb::b);
|
||||
|
||||
QByteArray ret;
|
||||
ret.resize(width * 3);
|
||||
char* data = ret.data();
|
||||
if (frames_.count() == 0)
|
||||
return ret;
|
||||
|
||||
Normalize(&frames_, &Rgb::r);
|
||||
Normalize(&frames_, &Rgb::g);
|
||||
Normalize(&frames_, &Rgb::b);
|
||||
|
||||
for (int i = 0; i < width; ++i) {
|
||||
Rgb rgb;
|
||||
|
|
|
@ -181,8 +181,10 @@ GstBusSyncReply MoodbarPipeline::BusCallbackSync(GstBus*, GstMessage* msg,
|
|||
|
||||
void MoodbarPipeline::Stop(bool success) {
|
||||
success_ = success;
|
||||
data_ = builder_->Finish(1000);
|
||||
builder_.reset();
|
||||
if (builder_ != nullptr) {
|
||||
data_ = builder_->Finish(1000);
|
||||
builder_.reset();
|
||||
}
|
||||
|
||||
emit Finished(success);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue