Skip to content
Extraits de code Groupes Projets
Vérifiée Valider 6afcd232 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

FIX: Don't SEGV when not selecting any file with OpenAudioFile

parent ecb4abac
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!1MISC: Some changes done to cmake files and project organisation
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#define MAXPIXVALUE 7 /* Some magix AV magic stuff */ #define MAXPIXVALUE 7 /* Some magix AV magic stuff */
int int
decode_audio_file(const char *path, const int sample_rate, double **const data, int *const size) decodeAudioFile(const char *path, const int sample_rate, double **const data, int *const size)
{ {
AVPacket packet; AVPacket packet;
AVFormatContext *format = avformat_alloc_context(); AVFormatContext *format = avformat_alloc_context();
......
...@@ -7,7 +7,7 @@ extern "C" { ...@@ -7,7 +7,7 @@ extern "C" {
#include <libavcodec/avcodec.h> #include <libavcodec/avcodec.h>
int decode_audio_file(const char *path, const int sample_rate, double **const data, int *const size); int decodeAudioFile(const char *path, const int sample_rate, double **const data, int *const size);
typedef struct ___RawImageData RawImageData; typedef struct ___RawImageData RawImageData;
RawImageData *RawImageDataNewFromData(const double *data, const int size); RawImageData *RawImageDataNewFromData(const double *data, const int size);
......
...@@ -35,11 +35,13 @@ void ...@@ -35,11 +35,13 @@ void
MainWindow::openAudioFile() MainWindow::openAudioFile()
{ {
QString filename = QFileDialog::getOpenFileName(this, "Select a file"); QString filename = QFileDialog::getOpenFileName(this, "Select a file");
if (filename.isEmpty())
return;
const int sample_rate = 44100; const int sample_rate = 44100;
double *data = nullptr; double *data = nullptr;
int size = 0; int size = 0;
int rc = decode_audio_file(filename.toStdString().c_str(), sample_rate, &data, &size); int rc = decodeAudioFile(filename.toStdString().c_str(), sample_rate, &data, &size);
auto data_deleter = [](double *ptr) -> void { av_free(ptr); }; auto data_deleter = [](double *ptr) -> void { av_free(ptr); };
std::unique_ptr<double, decltype(data_deleter)> data_holder(data, data_deleter); std::unique_ptr<double, decltype(data_deleter)> data_holder(data, data_deleter);
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter