Mercurial > mplayer.hg
comparison libvo/vo_directx.c @ 33821:240ab28c7628
Simplify printing of error strings.
author | reimar |
---|---|
date | Sun, 24 Jul 2011 20:15:53 +0000 |
parents | 4c888b1d8cac |
children | 954f6d044371 |
comparison
equal
deleted
inserted
replaced
33820:4c888b1d8cac | 33821:240ab28c7628 |
---|---|
162 if (g_ddpf[i].img_format == format) | 162 if (g_ddpf[i].img_format == format) |
163 return drv_caps[i]; | 163 return drv_caps[i]; |
164 return 0; | 164 return 0; |
165 } | 165 } |
166 | 166 |
167 struct errmap { | |
168 HRESULT err; | |
169 const char *errstr; | |
170 } static const dd_errmap[] = { | |
171 {DDERR_INCOMPATIBLEPRIMARY, "incompatible primary surface"}, | |
172 {DDERR_INVALIDCAPS, "invalid caps"}, | |
173 {DDERR_INVALIDOBJECT, "invalid object"}, | |
174 {DDERR_INVALIDPARAMS, "invalid parameters"}, | |
175 {DDERR_INVALIDRECT, "invalid rectangle"}, | |
176 {DDERR_INVALIDSURFACETYPE, "invalid surfacetype"}, | |
177 {DDERR_NODIRECTDRAWHW, "no directdraw hardware"}, | |
178 {DDERR_NOEMULATION, "can't emulate"}, | |
179 {DDERR_NOFLIPHW, "hardware can't do flip"}, | |
180 {DDERR_NOOVERLAYHW, "hardware can't do overlay"}, | |
181 {DDERR_NOSTRETCHHW, "hardware can't stretch: try to size the window back"}, | |
182 {DDERR_OUTOFMEMORY, "not enough system memory"}, | |
183 {DDERR_OUTOFVIDEOMEMORY, "not enough video memory"}, | |
184 {DDERR_UNSUPPORTED, "unsupported"}, | |
185 {DDERR_UNSUPPORTEDMODE, "unsupported mode"}, | |
186 {DDERR_HEIGHTALIGN, "height align"}, | |
187 {DDERR_XALIGN, "x align"}, | |
188 {DDERR_SURFACELOST, "surfaces lost"}, | |
189 {0, NULL} | |
190 }; | |
191 | |
192 static const char *dd_errstr(HRESULT res) | |
193 { | |
194 int i; | |
195 for (i = 0; dd_errmap[i].errstr; i++) | |
196 if (dd_errmap[i].err == res) | |
197 return dd_errmap[i].errstr; | |
198 return "unknown error"; | |
199 } | |
200 | |
167 static uint32_t Directx_CreatePrimarySurface(void) | 201 static uint32_t Directx_CreatePrimarySurface(void) |
168 { | 202 { |
169 DDSURFACEDESC2 ddsd = { .dwSize = sizeof(ddsd) }; | 203 DDSURFACEDESC2 ddsd = { .dwSize = sizeof(ddsd) }; |
170 //cleanup | 204 //cleanup |
171 if (g_lpddsPrimary) | 205 if (g_lpddsPrimary) |
235 ddrval = g_lpdd->lpVtbl->CreateSurface(g_lpdd, &ddsdOverlay, &g_lpddsOverlay, NULL); | 269 ddrval = g_lpdd->lpVtbl->CreateSurface(g_lpdd, &ddsdOverlay, &g_lpddsOverlay, NULL); |
236 if (ddrval != DD_OK) { | 270 if (ddrval != DD_OK) { |
237 if (ddrval == DDERR_INVALIDPIXELFORMAT) | 271 if (ddrval == DDERR_INVALIDPIXELFORMAT) |
238 mp_msg(MSGT_VO, MSGL_V, "<vo_directx><ERROR> invalid pixelformat: %s\n", g_ddpf[i].img_format_name); | 272 mp_msg(MSGT_VO, MSGL_V, "<vo_directx><ERROR> invalid pixelformat: %s\n", g_ddpf[i].img_format_name); |
239 else | 273 else |
240 mp_msg(MSGT_VO, MSGL_ERR, "<vo_directx><ERROR>"); | 274 mp_msg(MSGT_VO, MSGL_ERR, "<vo_directx><ERROR>create surface failed: %s (0x%x)\n", dd_errstr(ddrval), ddrval); |
241 switch (ddrval) { | |
242 case DDERR_INCOMPATIBLEPRIMARY: | |
243 mp_msg(MSGT_VO, MSGL_ERR, "incompatible primary surface\n"); | |
244 break; | |
245 case DDERR_INVALIDCAPS: | |
246 mp_msg(MSGT_VO, MSGL_ERR, "invalid caps\n"); | |
247 break; | |
248 case DDERR_INVALIDOBJECT: | |
249 mp_msg(MSGT_VO, MSGL_ERR, "invalid object\n"); | |
250 break; | |
251 case DDERR_INVALIDPARAMS: | |
252 mp_msg(MSGT_VO, MSGL_ERR, "invalid parameters\n"); | |
253 break; | |
254 case DDERR_NODIRECTDRAWHW: | |
255 mp_msg(MSGT_VO, MSGL_ERR, "no directdraw hardware\n"); | |
256 break; | |
257 case DDERR_NOEMULATION: | |
258 mp_msg(MSGT_VO, MSGL_ERR, "can't emulate\n"); | |
259 break; | |
260 case DDERR_NOFLIPHW: | |
261 mp_msg(MSGT_VO, MSGL_ERR, "hardware can't do flip\n"); | |
262 break; | |
263 case DDERR_NOOVERLAYHW: | |
264 mp_msg(MSGT_VO, MSGL_ERR, "hardware can't do overlay\n"); | |
265 break; | |
266 case DDERR_OUTOFMEMORY: | |
267 mp_msg(MSGT_VO, MSGL_ERR, "not enough system memory\n"); | |
268 break; | |
269 case DDERR_UNSUPPORTEDMODE: | |
270 mp_msg(MSGT_VO, MSGL_ERR, "unsupported mode\n"); | |
271 break; | |
272 case DDERR_OUTOFVIDEOMEMORY: | |
273 mp_msg(MSGT_VO, MSGL_ERR, "not enough video memory\n"); | |
274 break; | |
275 default: | |
276 mp_msg(MSGT_VO, MSGL_ERR, "create surface failed with 0x%x\n", ddrval); | |
277 } | |
278 return 1; | 275 return 1; |
279 } | 276 } |
280 g_lpddsBack = g_lpddsOverlay; | 277 g_lpddsBack = g_lpddsOverlay; |
281 return 0; | 278 return 0; |
282 } | 279 } |
587 // one cause might be the driver lied about minimum stretch | 584 // one cause might be the driver lied about minimum stretch |
588 // we should try upping the destination size a bit, or | 585 // we should try upping the destination size a bit, or |
589 // perhaps shrinking the source size | 586 // perhaps shrinking the source size |
590 mp_msg(MSGT_VO, MSGL_ERR, "<vo_directx><ERROR>UpdateOverlay failed\n"); | 587 mp_msg(MSGT_VO, MSGL_ERR, "<vo_directx><ERROR>UpdateOverlay failed\n"); |
591 mp_msg(MSGT_VO, MSGL_ERR, "<vo_directx><ERROR>Overlay:x1:%i,y1:%i,x2:%i,y2:%i,w:%i,h:%i\n", rd.left, rd.top, rd.right, rd.bottom, rd.right - rd.left, rd.bottom - rd.top); | 588 mp_msg(MSGT_VO, MSGL_ERR, "<vo_directx><ERROR>Overlay:x1:%i,y1:%i,x2:%i,y2:%i,w:%i,h:%i\n", rd.left, rd.top, rd.right, rd.bottom, rd.right - rd.left, rd.bottom - rd.top); |
592 mp_msg(MSGT_VO, MSGL_ERR, "<vo_directx><ERROR>"); | 589 mp_msg(MSGT_VO, MSGL_ERR, "<vo_directx><ERROR>%s (0x%x)\n", dd_errstr(ddrval), ddrval); |
593 switch (ddrval) { | 590 if (ddrval == DDERR_SURFACELOST) { |
594 case DDERR_NOSTRETCHHW: | |
595 mp_msg(MSGT_VO, MSGL_ERR, "hardware can't stretch: try to size the window back\n"); | |
596 break; | |
597 case DDERR_INVALIDRECT: | |
598 mp_msg(MSGT_VO, MSGL_ERR, "invalid rectangle\n"); | |
599 break; | |
600 case DDERR_INVALIDPARAMS: | |
601 mp_msg(MSGT_VO, MSGL_ERR, "invalid parameters\n"); | |
602 break; | |
603 case DDERR_HEIGHTALIGN: | |
604 mp_msg(MSGT_VO, MSGL_ERR, "height align\n"); | |
605 break; | |
606 case DDERR_XALIGN: | |
607 mp_msg(MSGT_VO, MSGL_ERR, "x align\n"); | |
608 break; | |
609 case DDERR_UNSUPPORTED: | |
610 mp_msg(MSGT_VO, MSGL_ERR, "unsupported\n"); | |
611 break; | |
612 case DDERR_INVALIDSURFACETYPE: | |
613 mp_msg(MSGT_VO, MSGL_ERR, "invalid surfacetype\n"); | |
614 break; | |
615 case DDERR_INVALIDOBJECT: | |
616 mp_msg(MSGT_VO, MSGL_ERR, "invalid object\n"); | |
617 break; | |
618 case DDERR_SURFACELOST: | |
619 mp_msg(MSGT_VO, MSGL_ERR, "surfaces lost\n"); | |
620 g_lpddsOverlay->lpVtbl->Restore(g_lpddsOverlay); //restore and try again | 591 g_lpddsOverlay->lpVtbl->Restore(g_lpddsOverlay); //restore and try again |
621 g_lpddsPrimary->lpVtbl->Restore(g_lpddsPrimary); | 592 g_lpddsPrimary->lpVtbl->Restore(g_lpddsPrimary); |
622 ddrval = g_lpddsOverlay->lpVtbl->UpdateOverlay(g_lpddsOverlay, &rs, g_lpddsPrimary, &rd, dwUpdateFlags, &ovfx); | 593 ddrval = g_lpddsOverlay->lpVtbl->UpdateOverlay(g_lpddsOverlay, &rs, g_lpddsPrimary, &rd, dwUpdateFlags, &ovfx); |
623 if (ddrval != DD_OK) | 594 if (ddrval != DD_OK) |
624 mp_msg(MSGT_VO, MSGL_FATAL, "<vo_directx><FATAL ERROR>UpdateOverlay failed again\n"); | 595 mp_msg(MSGT_VO, MSGL_FATAL, "<vo_directx><FATAL ERROR>UpdateOverlay failed again\n"); |
625 break; | |
626 default: | |
627 mp_msg(MSGT_VO, MSGL_ERR, " 0x%x\n", ddrval); | |
628 } | 596 } |
629 /*ok we can't do anything about it -> hide overlay*/ | 597 /*ok we can't do anything about it -> hide overlay*/ |
630 if (ddrval != DD_OK) { | 598 if (ddrval != DD_OK) { |
631 ddrval = g_lpddsOverlay->lpVtbl->UpdateOverlay(g_lpddsOverlay, NULL, g_lpddsPrimary, NULL, DDOVER_HIDE, NULL); | 599 ddrval = g_lpddsOverlay->lpVtbl->UpdateOverlay(g_lpddsOverlay, NULL, g_lpddsPrimary, NULL, DDOVER_HIDE, NULL); |
632 return 1; | 600 return 1; |