[mythtv] Mythfrontend hang with CVS

Stacey Son mythdev at son.org
Wed Jun 9 12:33:21 EDT 2004


Xavier Hervy wrote:

> I have made a patch to fix unlock bug before the freeBSD patch was apply.

I took the liberty of updating your patches to work with the current 
cvs...   Unfortunately I have no way of doing any testing right now.

BTW,  it seems that the variable OpenedHere is no longer used in 
MythCDROMLinux::checkMedia() so I removed it.

-stacey.
-------------- next part --------------
Index: ./libs/libmyth/mythcdrom-linux.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/mythcdrom-linux.cpp,v
retrieving revision 1.1
diff -u -r1.1 mythcdrom-linux.cpp
--- ./libs/libmyth/mythcdrom-linux.cpp	4 Jun 2004 02:31:22 -0000	1.1
+++ ./libs/libmyth/mythcdrom-linux.cpp	9 Jun 2004 16:23:52 -0000
@@ -60,20 +60,18 @@
 
 MediaStatus MythCDROMLinux::checkMedia()
 {
-    bool OpenedHere = false;    
-   
     if (testMedia() != MEDIAERR_OK) 
     {
         //cout << "MythCDROMLinux::checkMedia - ";
         //cout << "Test Media result != MEDIAERR_OK" << endl;
         m_MediaType = MEDIATYPE_UNKNOWN;
-        return setStatus(MEDIASTAT_UNKNOWN, OpenedHere);
+        return setStatus(MEDIASTAT_UNKNOWN);
     }
 
     //cout << "MythCDROMLinux::checkMedia - ";
     // If it's not already open we need to at least TRY to open it for most of these checks to work.
     if (!isDeviceOpen())
-        OpenedHere = openDevice();
+        openDevice();
 
     if (isDeviceOpen()) 
     {
@@ -85,31 +83,31 @@
                 //cout << "disk ok - ";
                 if (isMounted(true))
                     //cout << "it's mounted" << endl;
-                    return setStatus(MEDIASTAT_MOUNTED, OpenedHere);
+                    return setStatus(MEDIASTAT_MOUNTED);
                 // If the disk is ok but not yet mounted we'll test it further down after this switch exits.
                 break;
             case CDS_TRAY_OPEN:
             case CDS_NO_DISC:
                 //cout << "Tray open or no disc" << endl;
                 m_MediaType = MEDIATYPE_UNKNOWN;
-                return setStatus(MEDIASTAT_OPEN, OpenedHere);
+                return setStatus(MEDIASTAT_OPEN);
                 break;
             case CDS_NO_INFO:
             case CDS_DRIVE_NOT_READY:
                 //cout << "No info or drive not ready" << endl;
                 m_MediaType = MEDIATYPE_UNKNOWN;
-                return setStatus(MEDIASTAT_UNKNOWN, OpenedHere);
+                return setStatus(MEDIASTAT_UNKNOWN);
             default:
                 //cout << "unknown result from ioctl (" << ret << ")" << endl;
                 m_MediaType = MEDIATYPE_UNKNOWN;
-                return setStatus(MEDIASTAT_UNKNOWN, OpenedHere);
+                return setStatus(MEDIASTAT_UNKNOWN);
         }
 
         if (mediaChanged()) 
         {
             //cout << "media changed - ";
             // Regardless of the actual status lie here and say it's open for now, so we can over the case of a missed open.
-            return setStatus(MEDIASTAT_OPEN, OpenedHere);
+            return setStatus(MEDIASTAT_OPEN);
         } 
         else 
         {
@@ -127,12 +125,12 @@
                         //cout << "found a data disk" << endl;
                         // We'll return NOTMOUNTED  here because we're switching media.
                         // The base class will try to mount the deivce causing the next pass to pick up the MOUNTED status.
-                        return setStatus(MEDIASTAT_NOTMOUNTED, OpenedHere);
+                        return setStatus(MEDIASTAT_NOTMOUNTED);
                         break;
                     case CDS_AUDIO:
                         //cout << "found an audio disk" << endl;
                         m_MediaType = MEDIATYPE_AUDIO;
-                        return setStatus(MEDIASTAT_USEABLE, OpenedHere);
+                        return setStatus(MEDIASTAT_USEABLE);
                         break;
                     case CDS_MIXED:
                         m_MediaType = MEDIATYPE_MIXED;
@@ -140,30 +138,30 @@
                         // Note: Mixed mode CDs require an explixit mount call since we'll usually want the audio portion.
                         //         undefine ASSUME_WANT_AUDIO to change this behavior.
                         #ifdef ASSUME_WANT_AUDIO
-                            return setStatus(MEDIASTAT_USEABLE, OpenedHere);
+                            return setStatus(MEDIASTAT_USEABLE);
                         #else
                             mount();
-                            return setStatus(MEDIASTAT_NOTMOUNTED, OpenedHere);
+                            return setStatus(MEDIASTAT_NOTMOUNTED);
                         #endif
                         break;
                     case CDS_NO_INFO:
                     case CDS_NO_DISC:
                         //cout << "found no disk" << endl;
                         m_MediaType = MEDIATYPE_UNKNOWN;
-                        return setStatus(MEDIASTAT_UNKNOWN, OpenedHere);
+                        return setStatus(MEDIASTAT_UNKNOWN);
                         break;
                     default:
                         //cout << "found unknown disk type" << endl;
                         fprintf(stderr, "Unknown data type: %d\n", type);
                         m_MediaType = MEDIATYPE_UNKNOWN;
-                        return setStatus(MEDIASTAT_UNKNOWN, OpenedHere);
+                        return setStatus(MEDIASTAT_UNKNOWN);
                 }            
             }
             else if (m_Status == MEDIASTAT_MOUNTED || 
                      m_Status == MEDIASTAT_NOTMOUNTED) 
             {
                 //cout << "current status == " << MythMediaDevice::MediaStatusStrings[m_Status] << " setting status to not mounted - ";
-                setStatus(MEDIASTAT_NOTMOUNTED, OpenedHere);
+                setStatus(MEDIASTAT_NOTMOUNTED);
             }
 
             if (m_AllowEject)
@@ -174,12 +172,9 @@
     {
         //cout << "device not open returning unknown" << endl;
         m_MediaType = MEDIATYPE_UNKNOWN;
-        return setStatus(MEDIASTAT_UNKNOWN, OpenedHere);
+        return setStatus(MEDIASTAT_UNKNOWN);
     }
 
-    if (OpenedHere)
-        closeDevice();
-
     //cout << "returning " << MythMediaDevice::MediaStatusStrings[m_Status] << endl;
     return m_Status;
 }
Index: ./libs/libmyth/mythmedia.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/mythmedia.cpp,v
retrieving revision 1.5
diff -u -r1.5 mythmedia.cpp
--- ./libs/libmyth/mythmedia.cpp	24 Feb 2004 07:31:08 -0000	1.5
+++ ./libs/libmyth/mythmedia.cpp	9 Jun 2004 16:23:57 -0000
@@ -69,9 +69,6 @@
 {
     QString MountCommand;
     
-    if (isDeviceOpen())
-        closeDevice();
-
     if (!m_SuperMount) 
     {
         // Build a command line for mount/unmount and execute it...  Is there a better way to do this?
@@ -79,8 +76,11 @@
             MountCommand.sprintf("%s %s", PATHTO_MOUNT, 
                                  (const char*)m_DevicePath);
         else
+        {
             MountCommand.sprintf("%s %s", PATHTO_UNMOUNT, 
                                  (const char*)m_DevicePath);
+            closeDevice();
+        }
     
         VERBOSE(VB_ALL,  QString("Executing '%1'").arg(MountCommand));
         if (0 == system(MountCommand)) 
@@ -91,13 +91,20 @@
                 onDeviceMounted();
             }
             else
+            {
+                m_Status = MEDIASTAT_NOTMOUNTED;
                 onDeviceUnmounted();
+            }
             return true;
         }
         else
         {
-            VERBOSE(VB_GENERAL, QString("Failed to mount %1.")
-                                       .arg(m_DevicePath));
+            if (DoMount)
+                 VERBOSE(VB_GENERAL, QString("Failed to mount %1.")
+                                        .arg(m_DevicePath));
+            else
+                 VERBOSE(VB_GENERAL, QString("Failed to unmount %1.")
+                                        .arg(m_DevicePath));
         }
     } 
     else 
@@ -131,10 +138,7 @@
 { 
     m_Locked = false;
     
-    if (closeDevice())
-        return MEDIAERR_OK;
-    
-    return MEDIAERR_FAILED;
+    return MEDIAERR_OK;
 }
 
 bool MythMediaDevice::isMounted(bool Verify)
@@ -182,7 +186,7 @@
     return false;
 }
 
-MediaStatus MythMediaDevice::setStatus( MediaStatus NewStatus, bool CloseIt )
+MediaStatus MythMediaDevice::setStatus( MediaStatus NewStatus )
 {
     MediaStatus OldStatus = m_Status;
 
@@ -207,7 +211,11 @@
                 mount();
                 break;
             case MEDIASTAT_UNKNOWN:
+                break;
             case MEDIASTAT_OPEN:
+                if (MEDIASTAT_MOUNTED == OldStatus) 
+                    umount();
+                break;
             case MEDIASTAT_USEABLE:
             case MEDIASTAT_MOUNTED:
                 // get rid of the compiler warning...
@@ -219,10 +227,6 @@
             emit statusChanged(OldStatus, this);
     }
 
-
-    if (CloseIt)
-        closeDevice();
-
     return m_Status;
 }
 
Index: ./libs/libmyth/mythmedia.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/mythmedia.h,v
retrieving revision 1.3
diff -u -r1.3 mythmedia.h
--- ./libs/libmyth/mythmedia.h	24 Feb 2004 07:31:08 -0000	1.3
+++ ./libs/libmyth/mythmedia.h	9 Jun 2004 16:24:01 -0000
@@ -85,7 +85,7 @@
     virtual void onDeviceMounted() {};
     virtual void onDeviceUnmounted() {};
 
-    MediaStatus setStatus(MediaStatus newStat, bool CloseIt=false);
+    MediaStatus setStatus(MediaStatus newStat);
 
     QString m_MountPath;        ///< The path to this media's mount point (i.e. /mnt/cdrom). Read only.
     QString m_DevicePath;       ///< The path to this media's device (i.e. /dev/cdrom). Read/write.


More information about the mythtv-dev mailing list