Ticket #1122: 1122-fix-v2.patch
File 1122-fix-v2.patch, 4.8 KB (added by , 20 years ago) |
---|
-
libs/libmythtv/videoout_xv.cpp
5 5 #include <cmath> 6 6 #include <ctime> 7 7 #include <cerrno> 8 #include <cassert> 8 9 9 10 #include <malloc.h> 10 11 #include <fcntl.h> … … 48 49 #define round(x) ((int) ((x) + 0.5)) 49 50 #endif 50 51 52 static QMutex open_xv_ports_lock; 53 static QMap<int,int> open_xv_ports; 54 static void add_open_xv_port(int port) 55 { 56 if (port < 0) 57 return; 58 QMutexLocker locker(&open_xv_ports_lock); 59 open_xv_ports[port] = port; 60 } 61 static void del_open_xv_port(int port) 62 { 63 if (port < 0) 64 return; 65 QMutexLocker locker(&open_xv_ports_lock); 66 open_xv_ports.remove(port); 67 } 68 static bool has_open_xv_port(int port) 69 { 70 QMutexLocker locker(&open_xv_ports_lock); 71 return open_xv_ports.find(port) != open_xv_ports.end(); 72 } 73 static uint cnt_open_xv_port(void) 74 { 75 QMutexLocker locker(&open_xv_ports_lock); 76 return open_xv_ports.count(); 77 } 51 78 52 79 //#define DEBUG_PAUSE /* enable to debug XvMC pause frame */ 53 80 … … 245 272 // ungrab port... 246 273 if (xv_port >= 0) 247 274 { 275 VERBOSE(VB_PLAYBACK, LOC + "Closing XVideo port " << xv_port); 248 276 X11S(XvUngrabPort(XJ_disp, xv_port, CurrentTime)); 277 del_open_xv_port(xv_port); 249 278 xv_port = -1; 250 279 } 251 280 … … 637 666 638 667 if (xvmc_surf_info) 639 668 surf.set(surfNum, xvmc_surf_info); 669 add_open_xv_port(p); 640 670 port = p; 641 671 #endif // USING_XVMC 642 672 } … … 646 676 { 647 677 X11S(ret = XvGrabPort(disp, p, CurrentTime)); 648 678 if (Success == ret) 679 { 680 add_open_xv_port(p); 649 681 port = p; 682 } 650 683 } 651 684 } 652 685 } … … 785 818 */ 786 819 bool VideoOutputXv::InitXvMC(MythCodecID mcodecid) 787 820 { 821 VERBOSE(VB_IMPORTANT, "InitXvMC() -- begin"); 788 822 (void)mcodecid; 789 823 #ifdef USING_XVMC 824 assert(xv_port < 0); 790 825 xv_port = GrabSuitableXvPort(XJ_disp, XJ_root, mcodecid, 791 826 XJ_width, XJ_height, xvmc_chroma, 792 827 &xvmc_surf_info); … … 826 861 delete xvmc_osd_available[i]; 827 862 xvmc_osd_available.clear(); 828 863 xvmc_osd_lock.unlock(); 864 VERBOSE(VB_PLAYBACK, LOC + "Closing XVideo port " << xv_port); 829 865 X11S(XvUngrabPort(XJ_disp, xv_port, CurrentTime)); 866 del_open_xv_port(xv_port); 830 867 xv_port = -1; 831 868 } 832 869 870 VERBOSE(VB_IMPORTANT, "InitXvMC() -- end ok("<<ok<<")"); 833 871 return ok; 834 872 #else // USING_XVMC 835 873 return false; … … 903 941 { 904 942 VERBOSE(VB_IMPORTANT, LOC_ERR + 905 943 "Couldn't find the proper XVideo image format."); 944 VERBOSE(VB_PLAYBACK, LOC + "Closing XVideo port " << xv_port); 906 945 X11S(XvUngrabPort(XJ_disp, xv_port, CurrentTime)); 946 del_open_xv_port(xv_port); 907 947 xv_port = -1; 908 948 } 909 949 … … 916 956 { 917 957 VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed to create XVideo Buffers."); 918 958 DeleteBuffers(XVideo, false); 959 VERBOSE(VB_PLAYBACK, LOC + "Closing XVideo port " << xv_port); 919 960 X11S(XvUngrabPort(XJ_disp, xv_port, CurrentTime)); 961 del_open_xv_port(xv_port); 920 962 xv_port = -1; 921 963 ok = false; 922 964 } … … 1056 1098 width, height); 1057 1099 ok = NULL != ctx; 1058 1100 DeleteXvMCContext(disp, ctx); 1101 VERBOSE(VB_PLAYBACK, LOC + "Closing XVideo port " << port); 1059 1102 X11S(XvUngrabPort(disp, port, CurrentTime)); 1103 del_open_xv_port(port); 1060 1104 } 1061 1105 } 1062 1106 X11S(XCloseDisplay(disp)); 1063 1107 1064 if (!ok )1108 if (!ok && !cnt_open_xv_port()) 1065 1109 { 1066 1110 QString msg = LOC_ERR + "Could not open XvMC port...\n" 1067 1111 "\n" … … 1182 1226 DeleteBuffers(VideoOutputSubType(), true); 1183 1227 if (xv_port >= 0) 1184 1228 { 1229 VERBOSE(VB_PLAYBACK, LOC + "Closing XVideo port " << xv_port); 1185 1230 X11S(XvUngrabPort(XJ_disp, xv_port, CurrentTime)); 1231 del_open_xv_port(xv_port); 1186 1232 xv_port = -1; 1187 1233 } 1188 1234 #endif // USING_XVMC -
libs/libmythtv/NuppelVideoPlayer.cpp
367 367 368 368 bool NuppelVideoPlayer::InitVideo(void) 369 369 { 370 VERBOSE(VB_RECORD, "InitVideo()"); 370 371 InitFilters(); 371 372 if (using_null_videoout) 372 373 { … … 447 448 448 449 void NuppelVideoPlayer::ReinitVideo(void) 449 450 { 451 VERBOSE(VB_RECORD, "ReinitVideo()"); 450 452 InitFilters(); 451 453 452 454 vidExitLock.lock();