Ticket #3433: 3433-v1.patch
File 3433-v1.patch, 8.0 KB (added by , 17 years ago) |
---|
-
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 OSDTypeTeletext::OSDUpdateLocker locker(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 OSDTypeTeletext::OSDUpdateLocker locker(this); 133 134 134 135 int magazine = MAGAZINE(page); 135 136 if (magazine < 1 || magazine > 8) … … 189 190 for (uint j = 8; j < 40; j++) 190 191 ttpage->data[0][j] = m_bitswap[buf[j]]; 191 192 } 192 else 193 else 193 194 { 194 195 memcpy(ttpage->data[0]+0, buf, 40); 195 196 } 196 197 if ( !(ttpage->flags & TP_INTERRUPTED_SEQ)) 197 198 if ( !(ttpage->flags & TP_INTERRUPTED_SEQ)) 198 199 { 199 200 memcpy(m_header, ttpage->data[0], 40); 200 201 HeaderUpdated(ttpage->data[0],ttpage->lang); … … 204 205 /** \fn OSDTypeTeletext::AddTeletextData(int,int,const unsigned char*,int) 205 206 * \brief Adds Teletext Data from TeletextDecoder 206 207 */ 207 void OSDTypeTeletext::AddTeletextData(int magazine, int row, 208 void OSDTypeTeletext::AddTeletextData(int magazine, int row, 208 209 const unsigned char* buf, int vbimode) 209 210 { 210 QMutexLocker locker(&m_lock);211 OSDTypeTeletext::OSDUpdateLocker locker(this); 211 212 212 213 int b1, b2, b3, err; 213 214 … … 227 228 { 228 229 for (uint j = 0; j < 40; j++) 229 230 ttpage->data[row][j] = m_bitswap[buf[j]]; 230 } 231 else 231 } 232 else 232 233 { 233 234 memcpy(ttpage->data[row], buf, 40); 234 235 } … … 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) 329 336 * \brief Updates the header (given in page with language lang) 330 * 337 * 331 338 * \param page Pointer to the header which should be displayed 332 339 * \param lang Language of the header 333 340 * … … 359 366 * 360 367 * \param page Page number 361 368 * \param direction find page before or after the given page 362 * \return TeletextPage (NULL if not found) 369 * \return TeletextPage (NULL if not found) 363 370 */ 364 371 const TeletextPage *OSDTypeTeletext::FindPageInternal( 365 372 int page, int direction) const … … 412 419 * \param subpage Subpage number (if set to -1, find the first subpage) 413 420 * \param direction find page before or after the given page 414 421 * (only if Subpage is not -1) 415 * \return TeletextSubPage (NULL if not found) 422 * \return TeletextSubPage (NULL if not found) 416 423 */ 417 424 const TeletextSubPage *OSDTypeTeletext::FindSubPageInternal( 418 425 int page, int subpage, int direction) const … … 479 486 */ 480 487 void OSDTypeTeletext::KeyPress(uint key) 481 488 { 482 QMutexLocker locker(&m_lock);489 OSDTypeTeletext::OSDUpdateLocker locker(this); 483 490 484 491 int newPage = m_curpage; 485 492 int newSubPage = m_cursubpage; … … 523 530 newSubPage = -1; 524 531 m_curpage_showheader = true; 525 532 break; 526 } 533 } 527 534 528 535 case TTKey::kPrevPage: 529 536 { … … 665 672 */ 666 673 void OSDTypeTeletext::SetPage(int page, int subpage) 667 674 { 668 QMutexLocker locker(&m_lock);675 OSDTypeTeletext::OSDUpdateLocker locker(this); 669 676 670 677 if (page < 0x100 || page > 0x899) 671 678 return; … … 796 803 } 797 804 798 805 /** \fn OSDTypeTeletext::DrawCharacter(OSDSurface*,int,int,QChar,int) const 799 * \brief Draws a character at posistion x, y 806 * \brief Draws a character at posistion x, y 800 807 * 801 808 * \param x X position (40 cols) 802 809 * \param y Y position (25 rows) … … 1109 1116 1110 1117 void OSDTypeTeletext::Reinit(float wmult, float hmult) 1111 1118 { 1112 QMutexLocker locker(&m_lock);1119 OSDTypeTeletext::OSDUpdateLocker locker(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 **************************************************************************** 1244 * 1245 * OSDUpdateLocker - helper class to the OSDTypeTeletext. 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 * 1255 * -Teletext data arrives -> locks m_lock 1256 * -While the teletext data is being processed the XMV request an OSD update display 1257 * -The OSD update display will lock the osdlock 1258 * -The OSD update can results in the Teletext:Draw function being call and hence the 1259 * OSD update is now waiting on m_lock being released to continue it's drawing process 1260 * -If the processing of the teletext data result in the function OSD::UpdateTeletext 1261 * being called, this function will try to get the osdlock. 1262 * -This results in the classic semaphore deadlock and hence all OSD update cease. 1263 * 1264 ***************************************************************************** 1265 */ 1266 OSDTypeTeletext::OSDUpdateLocker::OSDUpdateLocker(OSDTypeTeletext *parent) 1267 :parent(parent) 1268 { 1269 parent->m_lock.lock(); 1270 } 1271 1272 OSDTypeTeletext::OSDUpdateLocker::~OSDUpdateLocker(void) 1273 { 1274 if (parent->m_osd_changed == true) // see if the osd has to be requested to redraw 1275 { 1276 parent->m_osd_changed = false; // clear the flag 1277 parent->m_lock.unlock(); // and remove the m_lock 1278 parent->m_osd->UpdateTeletext(); // now it is safe to do the OSD update 1279 return; 1280 } 1281 parent->m_lock.unlock(); // normal exit. Will result in the m_lock being released. 1282 } 1283 -
libs/libmythtv/osdtypeteletext.h
170 170 const TeletextPage *FindPageInternal(int,int) const; 171 171 172 172 private: 173 class OSDUpdateLocker 174 { 175 public: 176 OSDUpdateLocker(OSDTypeTeletext *parent); 177 ~OSDUpdateLocker(void); 178 private: 179 OSDTypeTeletext *parent; 180 }; 181 173 182 QMutex m_lock; 183 174 184 QRect m_displayrect; 175 185 QRect m_unbiasedrect; 176 186 … … 209 219 uint8_t m_header[40]; 210 220 mutable bool m_header_changed; 211 221 mutable bool m_page_changed; 222 mutable bool m_osd_changed; 212 223 213 224 TeletextMagazine m_magazines[8]; 214 225 unsigned char m_bitswap[256];