MediaPlayer: close() cd/dvd device after eject.

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 <[email protected]>
This commit is contained in:
JackBurton79
2021-07-27 12:23:25 +00:00
committed by Axel Dörfler
parent 899fdd042a
commit 60ead048b5
2 changed files with 4 additions and 4 deletions
+4 -3
View File
@@ -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);
}