playback on mac and memory
Posted: 10 Nov 2015 15:35
Hello,
I have an application where I wanted to embed a small videoplayer based on libvlc.
right now its only starting always the same video file, and on Mac each time I start the video and stop it, I loose around 1.6MB ram whats not freed after stop.
here the basic code of the player, perhaps I made something wrong here: (im using Qt4.8 and VLC 2.2.1 on Macos)
playback:
stop:
I have an application where I wanted to embed a small videoplayer based on libvlc.
right now its only starting always the same video file, and on Mac each time I start the video and stop it, I loose around 1.6MB ram whats not freed after stop.
here the basic code of the player, perhaps I made something wrong here: (im using Qt4.8 and VLC 2.2.1 on Macos)
Code: Select all
QVector<QByteArray> vArgs;
vArgs.append("--ignore-config");
vArgs.append("--intf=dummy");
vArgs.append("--no-media-library");
vArgs.append("--no-osd");
//vArgs.append("--no-stats");
vArgs.append("--no-video-title-show");
vArgs.append("--cr-average=10000");
vArgs.append("--clock-jitter=6000");
vArgs.append("--sout-mux-caching=8000");
vArgs.append("--no-plugins-cache");// for accurate seek via internet
if (this->logging) {
vArgs.append("--verbose=2");
} else {
vArgs.append("--verbose=0");
}
#if defined(Q_OS_MAC)
// QString pluginPath = "--plugin-path="+QCoreApplication::applicationDirPath()+"/plugins";
// vArgs.append(pluginPath.toAscii());
vArgs.append("--vout=macosx");
#endif
const char* vlcArgs[12];
for (int i = 0; i < 12; i++) {
if (i < vArgs.count()) {
vlcArgs[i] = vArgs[i].constData();
} else {
vlcArgs[i] = NULL;
}
}
int argc = 0;
argc = (vArgs.count() > 12) ? 12 : vArgs.count();
//create a new libvlc instance
if((this->vlcInstance = libvlc_new(argc, vlcArgs)) == NULL) {
qDebug(Could not init libVLC");
exit(1);
}
// Create a media player playing environement
if (this->vlcInstance){
this->vlcPlayer = libvlc_media_player_new (this->vlcInstance);
} else {
exit(1);
}
Code: Select all
void player::playFile(QString fileName) {
this->vlcMedia = libvlc_media_new_path(this->vlcInstance, fileName.toUtf8().constData());
if (this->vlcMedia != NULL){
if (this->vlcPlayer == NULL) {
this->vlcPlayer = libvlc_media_player_new_from_media(this->vlcMedia);
this->initializePlayer();//needed if not the signals are disconnected
/* Integrate the video in the interface */
this->setVideoWidget(this->winID);
} else {
// qDebug("#### player is initialized");
libvlc_media_player_set_media(this->vlcPlayer, this->vlcMedia);
// this->blockEvents = false;
}
} else {
qDebug() << "media NOT INITIALIZED";
return;
}
if (this->reconnectVideo){
this->setVideoWidget(this->winID);
}
libvlc_media_release(this->vlcMedia);
int started = libvlc_media_player_play(this->vlcPlayer);
}
Code: Select all
void player::slotStopTest() {
if (libvlc_media_player_is_playing(this->vlcPlayer) == 1){
libvlc_media_player_stop(this->vlcPlayer);
//tested with and without releasing on stop, same memory problem
libvlc_media_player_release(this->vlcPlayer);
this->vlcPlayer = NULL;
if (this->reconnectVideo){
//tested if its getting better when I detach erverytime the video screen - no difference
this->unsetVideoWidget();
}
}
// libvlc_media_player_retain
}