From 60ead048b5f03756fcde60699aa111ccecb8a0ab Mon Sep 17 00:00:00 2001 From: JackBurton79 Date: Tue, 27 Jul 2021 14:12:30 +0200 Subject: [PATCH] MediaPlayer: close() cd/dvd device after eject. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We were not closing cd/dvd device after eject. Also changed fDevice member to a local variable, since we only use it in one place. Change-Id: I169da97501f98e30deded1f5ff53d3bc00459eab Reviewed-on: https://review.haiku-os.org/c/haiku/+/4247 Reviewed-by: Axel Dörfler --- src/apps/mediaplayer/MainWin.cpp | 7 ++++--- src/apps/mediaplayer/MainWin.h | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/apps/mediaplayer/MainWin.cpp b/src/apps/mediaplayer/MainWin.cpp index 0f2930b2e6..37eb06a047 100644 --- a/src/apps/mediaplayer/MainWin.cpp +++ b/src/apps/mediaplayer/MainWin.cpp @@ -1254,14 +1254,15 @@ MainWin::Eject() { status_t mediaStatus = B_DEV_NO_MEDIA; // find the cd player device - fDevice = FindCdPlayerDevice("/dev/disk"); + int cdPlayerFd = FindCdPlayerDevice("/dev/disk"); // get the status first - ioctl(fDevice, B_GET_MEDIA_STATUS, &mediaStatus, sizeof(mediaStatus)); + ioctl(cdPlayerFd, B_GET_MEDIA_STATUS, &mediaStatus, sizeof(mediaStatus)); // if door open, load the media, else eject the cd - status_t result = ioctl(fDevice, + status_t result = ioctl(cdPlayerFd, mediaStatus == B_DEV_DOOR_OPEN ? B_LOAD_MEDIA : B_EJECT_DEVICE); if (result != B_NO_ERROR) printf("Error ejecting device"); + close(cdPlayerFd); } diff --git a/src/apps/mediaplayer/MainWin.h b/src/apps/mediaplayer/MainWin.h index 7a477496ba..806008794c 100644 --- a/src/apps/mediaplayer/MainWin.h +++ b/src/apps/mediaplayer/MainWin.h @@ -189,7 +189,6 @@ private: bool fScaleFullscreenControls; bigtime_t fInitialSeekPosition; bool fAllowWinding; - int fDevice; static int sNoVideoWidth; };