Ticket #3433: 3433-v2.patch
| File 3433-v2.patch, 5.6 KB (added by , 19 years ago) |
|---|
-
libs/libmythtv/osdtypeteletext.h
18 18 class OSD; 19 19 class OSDType; 20 20 class OSDSurface; 21 class OSDTypeTeletext; 21 22 class TV; 22 23 23 24 class TTColor … … 106 107 int_to_page_t pages; 107 108 }; 108 109 110 class OSDUpdateLocker 111 { 112 public: 113 OSDUpdateLocker(QMutex *lock, OSDTypeTeletext *parent); 114 ~OSDUpdateLocker(void); 115 116 private: 117 QMutex *m_lock; 118 OSDTypeTeletext *m_parent; 119 }; 120 109 121 class OSDTypeTeletext : public OSDType, public TeletextViewer 110 122 { 111 123 Q_OBJECT 124 112 125 friend QColor color_tt2qt(int ttcolor); 126 friend class OSDUpdateLocker; 127 113 128 public: 114 129 OSDTypeTeletext(const QString &name, TTFFont *font, 115 130 QRect displayrect, float wmult, float hmult, OSD *osd); … … 209 224 uint8_t m_header[40]; 210 225 mutable bool m_header_changed; 211 226 mutable bool m_page_changed; 227 mutable bool m_osd_changed; 212 228 213 229 TeletextMagazine m_magazines[8]; 214 230 unsigned char m_bitswap[256]; -
libs/libmythtv/osdtypeteletext.cpp
68 68 69 69 m_transparent(false), m_revealHidden(false), 70 70 m_displaying(false), m_osd(osd), 71 m_header_changed(false), m_page_changed(false) 71 m_header_changed(false), m_page_changed(false), 72 m_osd_changed(false) 72 73 { 73 74 m_unbiasedrect = bias(m_displayrect, wmult, hmult); 74 75 … … 89 90 */ 90 91 void OSDTypeTeletext::Reset(void) 91 92 { 92 QMutexLocker locker(&m_lock);93 OSDUpdateLocker locker(&m_lock, this); 93 94 94 95 for (uint mag = 0; mag < 8; mag++) 95 96 { … … 129 130 const unsigned char* buf, 130 131 int vbimode, int lang, int flags) 131 132 { 132 QMutexLocker locker(&m_lock);133 OSDUpdateLocker locker(&m_lock, this); 133 134 134 135 int magazine = MAGAZINE(page); 135 136 if (magazine < 1 || magazine > 8) … … 207 208 void OSDTypeTeletext::AddTeletextData(int magazine, int row, 208 209 const unsigned char* buf, int vbimode) 209 210 { 210 QMutexLocker locker(&m_lock);211 OSDUpdateLocker locker(&m_lock, this); 211 212 212 213 int b1, b2, b3, err; 213 214 … … 322 323 return; 323 324 324 325 m_page_changed = true; 325 m_osd->UpdateTeletext(); 326 m_osd_changed = true; 327 // note: We cannot call UpdateTeletext from here since it will try to get the 328 // osdlock. The problem with this is that the OSD::Display might already 329 // be active and have called our Draw function and hence is pending the 330 // m_lock being freed. Since the OSD::Display uses the osdlock, our call 331 // to the UpdateTeletext would result in a semaphore deadlock. 332 // m_osd->UpdateTeletext(); 326 333 } 327 334 328 335 /** \fn OSDTypeTeletext::HeaderUpdated(unsigned char*,int) … … 479 486 */ 480 487 void OSDTypeTeletext::KeyPress(uint key) 481 488 { 482 QMutexLocker locker(&m_lock);489 OSDUpdateLocker locker(&m_lock, this); 483 490 484 491 int newPage = m_curpage; 485 492 int newSubPage = m_cursubpage; … … 665 672 */ 666 673 void OSDTypeTeletext::SetPage(int page, int subpage) 667 674 { 668 QMutexLocker locker(&m_lock);675 OSDUpdateLocker locker(&m_lock, this); 669 676 670 677 if (page < 0x100 || page > 0x899) 671 678 return; … … 1109 1116 1110 1117 void OSDTypeTeletext::Reinit(float wmult, float hmult) 1111 1118 { 1112 QMutexLocker locker(&m_lock);1119 OSDUpdateLocker locker(&m_lock, this); 1113 1120 1114 1121 m_displayrect = bias(m_unbiasedrect, wmult, hmult); 1115 1122 m_tt_colspace = m_displayrect.width() / kTeletextColumns; … … 1232 1239 } 1233 1240 } 1234 1241 1242 /** 1243 * \class OSDUpdateLocker 1244 * \brief Helper class to the OSDTypeTeletext 1245 * 1246 * This class is used to lock the m_lock semaphore when 1247 * there is a chance that the locked code will result in the 1248 * OSD::UpdateTeletext() function being called. It's purpose 1249 * is to lock the semaphore and once the locked code has 1250 * finished to check for a request to call OSD::UpdateTeletext(). 1251 * If required, the m_lock is released and the required call made 1252 * 1253 * This is to overcome the possible semaphore deadlock as follows: 1254 * \code 1255 * - Teletext data arrives -> locks m_lock 1256 * - While the teletext data is being processed the XMV request an 1257 * OSD update display 1258 * - The OSD update display will lock the osdlock 1259 * - The OSD update can results in the Teletext:Draw method being 1260 * called and hence the OSD update is now waiting on m_lock being 1261 * released to continue it's drawing process 1262 * - If the processing of the teletext data result in the function 1263 * OSD::UpdateTeletext being called, this function will try to 1264 * get the osdlock. 1265 * - This results in the classic semaphore deadlock and hence all 1266 * OSD update cease. 1267 * \endcode 1268 **************************************************************************/ 1269 1270 OSDUpdateLocker::OSDUpdateLocker(QMutex *lock, OSDTypeTeletext *parent) : 1271 m_lock(lock), m_parent(parent) 1272 { 1273 m_lock->lock(); 1274 } 1275 1276 OSDUpdateLocker::~OSDUpdateLocker(void) 1277 { 1278 // see if the osd has to be requested a redraw 1279 if (m_parent->m_osd_changed) 1280 { 1281 m_parent->m_osd_changed = false; 1282 m_lock->unlock(); 1283 // now it is safe to do the OSD update 1284 m_parent->m_osd->UpdateTeletext(); 1285 } 1286 else 1287 { 1288 // normal exit. Will result in the m_lock being released. 1289 m_lock->unlock(); 1290 } 1291 } 1292
