@@ -381,7 +381,12 @@ def error(self) -> str | None:
381
381
"""
382
382
if self .handle is None :
383
383
return None
384
- return self ._library .dvdcss_error (self .handle ).strip () or None
384
+
385
+ error = self ._library .dvdcss_error (self .handle )
386
+ if not error or error == b"no error" :
387
+ return None
388
+
389
+ return error .decode ("utf8" ).strip () or None
385
390
386
391
@property
387
392
def is_scrambled (self ) -> bool :
@@ -417,21 +422,23 @@ def _load_library() -> CDLL:
417
422
)
418
423
419
424
lib = CDLL (lib_name )
425
+ dvdcss_t = c_void_p
426
+
420
427
lib .dvdcss_open .argtypes = [c_char_p ]
421
- lib .dvdcss_open .restype = c_void_p
422
- lib .dvdcss_open_stream .argtypes = [c_void_p , DvdCssStreamCb ]
423
- lib .dvdcss_open_stream .restype = c_void_p
424
- lib .dvdcss_close .argtypes = [c_void_p ]
428
+ lib .dvdcss_open .restype = dvdcss_t
429
+ lib .dvdcss_open_stream .argtypes = [dvdcss_t , DvdCssStreamCb ]
430
+ lib .dvdcss_open_stream .restype = dvdcss_t
431
+ lib .dvdcss_close .argtypes = [dvdcss_t ]
425
432
lib .dvdcss_close .restype = c_int
426
- lib .dvdcss_seek .argtypes = [c_void_p , c_int , c_int ]
433
+ lib .dvdcss_seek .argtypes = [dvdcss_t , c_int , c_int ]
427
434
lib .dvdcss_seek .restype = c_int
428
- lib .dvdcss_read .argtypes = [c_void_p , c_char_p , c_int , c_int ]
435
+ lib .dvdcss_read .argtypes = [dvdcss_t , c_char_p , c_int , c_int ]
429
436
lib .dvdcss_read .restype = c_int
430
- lib .dvdcss_readv .argtypes = [c_void_p , POINTER (Iovec ), c_int , c_int ]
437
+ lib .dvdcss_readv .argtypes = [dvdcss_t , POINTER (Iovec ), c_int , c_int ]
431
438
lib .dvdcss_readv .restype = c_int
432
- lib .dvdcss_error .argtypes = [c_void_p ]
433
- lib .dvdcss_error .restype = c_int
434
- lib .dvdcss_is_scrambled .argtypes = [c_void_p ]
439
+ lib .dvdcss_error .argtypes = [dvdcss_t ]
440
+ lib .dvdcss_error .restype = c_char_p
441
+ lib .dvdcss_is_scrambled .argtypes = [dvdcss_t ]
435
442
lib .dvdcss_is_scrambled .restype = c_int
436
443
437
444
return lib
0 commit comments