fix some types
This commit is contained in:
		
							parent
							
								
									4825365776
								
							
						
					
					
						commit
						1b7f0394f8
					
				| @ -1,5 +1,6 @@ | |||||||
| from enum import Enum | from enum import Enum | ||||||
| import ctypes | import ctypes | ||||||
|  | from ctypes import byref | ||||||
| import wave | import wave | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -20,8 +21,9 @@ class MetaData(Enum): | |||||||
| 
 | 
 | ||||||
| def main(in_file, out_file, dll_path=None): | def main(in_file, out_file, dll_path=None): | ||||||
|     if dll_path is None: |     if dll_path is None: | ||||||
|         dll_path = 'c:\\Program Files (x86)\\Audible\\Bin\\AAXSDKWin.dll' |         dll_path = 'C:/Program Files (x86)/Audible/Bin/AAXSDKWin.dll' | ||||||
| 
 | 
 | ||||||
|  |     print(dll_path) | ||||||
|     dll = ctypes.CDLL(dll_path) |     dll = ctypes.CDLL(dll_path) | ||||||
| 
 | 
 | ||||||
|     handle = open_file(dll, in_file) |     handle = open_file(dll, in_file) | ||||||
| @ -55,7 +57,7 @@ def main(in_file, out_file, dll_path=None): | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def open_file(dll, filename): | def open_file(dll, filename): | ||||||
|     handle = ctypes.pointer(ctypes.c_byte) |     handle = ctypes.pointer(ctypes.c_byte()) | ||||||
|     res = dll.AAXOpenFileWinW(handle, filename) |     res = dll.AAXOpenFileWinW(handle, filename) | ||||||
| 
 | 
 | ||||||
|     if res != 0: |     if res != 0: | ||||||
| @ -73,7 +75,7 @@ def close_file(dll, handle): | |||||||
| 
 | 
 | ||||||
| def get_audio_channel_count(dll, handle): | def get_audio_channel_count(dll, handle): | ||||||
|     n_channels = ctypes.c_uint() |     n_channels = ctypes.c_uint() | ||||||
|     res = dll.AAXGetAudioChannelCount(handle, n_channels) |     res = dll.AAXGetAudioChannelCount(handle, byref(n_channels)) | ||||||
| 
 | 
 | ||||||
|     if res != 0: |     if res != 0: | ||||||
|         raise Exception('AAXGetAudioChannelCount: {}'.format(res)) |         raise Exception('AAXGetAudioChannelCount: {}'.format(res)) | ||||||
| @ -83,7 +85,7 @@ def get_audio_channel_count(dll, handle): | |||||||
| 
 | 
 | ||||||
| def get_sample_rate(dll, handle): | def get_sample_rate(dll, handle): | ||||||
|     sample_rate = ctypes.c_uint() |     sample_rate = ctypes.c_uint() | ||||||
|     res = dll.AAXGetSampleRate(handle, sample_rate) |     res = dll.AAXGetSampleRate(handle, byref(sample_rate)) | ||||||
| 
 | 
 | ||||||
|     if res != 0: |     if res != 0: | ||||||
|         raise Exception('AAXGetSampleRate: {}'.format(res)) |         raise Exception('AAXGetSampleRate: {}'.format(res)) | ||||||
| @ -92,7 +94,7 @@ def get_sample_rate(dll, handle): | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def seek(dll, handle, position=0): | def seek(dll, handle, position=0): | ||||||
|     res = dll.AAXSeek(handle, position) |     res = dll.AAXSeek(handle, ctypes.c_int(position)) | ||||||
| 
 | 
 | ||||||
|     if res != 0: |     if res != 0: | ||||||
|         raise Exception('AAXSeek: {}'.format(res)) |         raise Exception('AAXSeek: {}'.format(res)) | ||||||
| @ -110,7 +112,7 @@ def get_encoded_audio(dll, handle, buf=None): | |||||||
|         buf = ctypes.create_string_buffer(0x400) |         buf = ctypes.create_string_buffer(0x400) | ||||||
| 
 | 
 | ||||||
|     data_len = ctypes.c_uint() |     data_len = ctypes.c_uint() | ||||||
|     res = dll.AAXGetEncodedAudio(handle, buf, len(buf), data_len) |     res = dll.AAXGetEncodedAudio(handle, buf, len(buf), byref(data_len)) | ||||||
| 
 | 
 | ||||||
|     if res != 0: |     if res != 0: | ||||||
|         raise Exception('AAXGetEncodedAudio: {}'.format(res)) |         raise Exception('AAXGetEncodedAudio: {}'.format(res)) | ||||||
| @ -123,7 +125,7 @@ def decode_pcm_frame(dll, handle, in_buf, in_len, out_buf=None): | |||||||
|         out_buf = ctypes.create_string_buffer(0x400 * 200) |         out_buf = ctypes.create_string_buffer(0x400 * 200) | ||||||
| 
 | 
 | ||||||
|     data_len = ctypes.c_uint() |     data_len = ctypes.c_uint() | ||||||
|     res = dll.AAXDecodedPCMFrame(handle, in_buf, in_len, out_buf, len(out_buf), data_len) |     res = dll.AAXDecodedPCMFrame(handle, in_buf, in_len, out_buf, len(out_buf), byref(data_len)) | ||||||
| 
 | 
 | ||||||
|     if res != 0: |     if res != 0: | ||||||
|         raise Exception('AAXDecodedPCMFrame: {}'.format(res)) |         raise Exception('AAXDecodedPCMFrame: {}'.format(res)) | ||||||
| @ -136,7 +138,7 @@ def get_chapter_text(dll, handle, chapter_num, buf=None): | |||||||
|         buf = ctypes.create_string_buffer(0x400) |         buf = ctypes.create_string_buffer(0x400) | ||||||
| 
 | 
 | ||||||
|     data_len = ctypes.c_uint() |     data_len = ctypes.c_uint() | ||||||
|     res = dll.AAXGetChapterText(handle, chapter_num, buf, len(buf), data_len) |     res = dll.AAXGetChapterText(handle, chapter_num, buf, len(buf), byref(data_len)) | ||||||
| 
 | 
 | ||||||
|     if res != 0: |     if res != 0: | ||||||
|         raise Exception('AAXGetChapterText: {}'.format(res)) |         raise Exception('AAXGetChapterText: {}'.format(res)) | ||||||
| @ -146,13 +148,13 @@ def get_chapter_text(dll, handle, chapter_num, buf=None): | |||||||
| 
 | 
 | ||||||
| def get_metadata(dll, handle, mdn): | def get_metadata(dll, handle, mdn): | ||||||
|     data_len = ctypes.c_uint() |     data_len = ctypes.c_uint() | ||||||
|     res = dll.AAXGetMetadataInfo(handle, mdn, None, data_len) |     res = dll.AAXGetMetadataInfo(handle, ctypes.c_int(mdn), None, byref(data_len)) | ||||||
| 
 | 
 | ||||||
|     if res != 0: |     if res != 0: | ||||||
|         raise Exception('AAXGetMetadataInfo: {}'.format(res)) |         raise Exception('AAXGetMetadataInfo: {}'.format(res)) | ||||||
| 
 | 
 | ||||||
|     buf = ctypes.create_string_buffer(data_len) |     buf = ctypes.create_string_buffer(data_len) | ||||||
|     res = dll.AAXGetMetadata(handle, mdn, buf, data_len) |     res = dll.AAXGetMetadata(handle, ctypes.int(mdn), buf, byref(data_len)) | ||||||
| 
 | 
 | ||||||
|     if res != 0: |     if res != 0: | ||||||
|         raise Exception('AAXGetChapterText: {}'.format(res)) |         raise Exception('AAXGetChapterText: {}'.format(res)) | ||||||
| @ -161,7 +163,7 @@ def get_metadata(dll, handle, mdn): | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def seek_to_chapter(dll, handle, chapter): | def seek_to_chapter(dll, handle, chapter): | ||||||
|     res = dll.AAXSeekToChapter(handle, chapter) |     res = dll.AAXSeekToChapter(handle, ctypes.c_uint(chapter)) | ||||||
| 
 | 
 | ||||||
|     if res != 0: |     if res != 0: | ||||||
|         raise Exception('AAXSeekToChapter: {}'.format(res)) |         raise Exception('AAXSeekToChapter: {}'.format(res)) | ||||||
| @ -169,7 +171,7 @@ def seek_to_chapter(dll, handle, chapter): | |||||||
| 
 | 
 | ||||||
| def get_chapter_count(dll, handle): | def get_chapter_count(dll, handle): | ||||||
|     n_chapters = ctypes.c_uint() |     n_chapters = ctypes.c_uint() | ||||||
|     res = dll.AAXGetChapterCount(handle, n_chapters) |     res = dll.AAXGetChapterCount(handle, byref(n_chapters)) | ||||||
| 
 | 
 | ||||||
|     if res != 0: |     if res != 0: | ||||||
|         raise Exception('AAXGetChapterCount: {}'.format(res)) |         raise Exception('AAXGetChapterCount: {}'.format(res)) | ||||||
| @ -179,7 +181,7 @@ def get_chapter_count(dll, handle): | |||||||
| 
 | 
 | ||||||
| def get_current_chapter(dll, handle): | def get_current_chapter(dll, handle): | ||||||
|     chapter = ctypes.c_uint() |     chapter = ctypes.c_uint() | ||||||
|     res = dll.AAXGetCurrentChapter(handle, chapter) |     res = dll.AAXGetCurrentChapter(handle, byref(chapter)) | ||||||
| 
 | 
 | ||||||
|     if res != 0: |     if res != 0: | ||||||
|         raise Exception('AAXGetCurrentChapter: {}'.format(res)) |         raise Exception('AAXGetCurrentChapter: {}'.format(res)) | ||||||
| @ -189,7 +191,7 @@ def get_current_chapter(dll, handle): | |||||||
| 
 | 
 | ||||||
| def get_duration(dll, handle): | def get_duration(dll, handle): | ||||||
|     duration = ctypes.c_uint() |     duration = ctypes.c_uint() | ||||||
|     res = dll.AAXGetDuration(handle, duration) |     res = dll.AAXGetDuration(handle, byref(duration)) | ||||||
| 
 | 
 | ||||||
|     if res != 0: |     if res != 0: | ||||||
|         raise Exception('AAXGetDuration: {}'.format(res)) |         raise Exception('AAXGetDuration: {}'.format(res)) | ||||||
| @ -199,7 +201,7 @@ def get_duration(dll, handle): | |||||||
| 
 | 
 | ||||||
| def get_playback_position(dll, handle): | def get_playback_position(dll, handle): | ||||||
|     position = ctypes.c_uint() |     position = ctypes.c_uint() | ||||||
|     res = dll.AAXGetPlaybackPosition(handle, position) |     res = dll.AAXGetPlaybackPosition(handle, byref(position)) | ||||||
| 
 | 
 | ||||||
|     if res != 0: |     if res != 0: | ||||||
|         raise Exception('AAXGetPlaybackPosition: {}'.format(res)) |         raise Exception('AAXGetPlaybackPosition: {}'.format(res)) | ||||||
| @ -209,7 +211,7 @@ def get_playback_position(dll, handle): | |||||||
| 
 | 
 | ||||||
| def get_chapter_start_time(dll, handle, chapter): | def get_chapter_start_time(dll, handle, chapter): | ||||||
|     position = ctypes.c_uint() |     position = ctypes.c_uint() | ||||||
|     res = dll.AAXGetChapterStartTime(handle, position, chapter) |     res = dll.AAXGetChapterStartTime(handle, byref(position), chapter) | ||||||
| 
 | 
 | ||||||
|     if res != 0: |     if res != 0: | ||||||
|         raise Exception('AAXGetChapterStartTime: {}'.format(res)) |         raise Exception('AAXGetChapterStartTime: {}'.format(res)) | ||||||
| @ -219,7 +221,7 @@ def get_chapter_start_time(dll, handle, chapter): | |||||||
| 
 | 
 | ||||||
| def get_avg_bitrate(dll, handle): | def get_avg_bitrate(dll, handle): | ||||||
|     bitrate = ctypes.c_uint() |     bitrate = ctypes.c_uint() | ||||||
|     res = dll.AAXGetAvgBitrate(handle, bitrate) |     res = dll.AAXGetAvgBitrate(handle, byref(bitrate)) | ||||||
| 
 | 
 | ||||||
|     if res != 0: |     if res != 0: | ||||||
|         raise Exception('AAXGetAvgBitrate: {}'.format(res)) |         raise Exception('AAXGetAvgBitrate: {}'.format(res)) | ||||||
| @ -229,7 +231,7 @@ def get_avg_bitrate(dll, handle): | |||||||
| 
 | 
 | ||||||
| def get_max_bitrate(dll, handle): | def get_max_bitrate(dll, handle): | ||||||
|     bitrate = ctypes.c_uint() |     bitrate = ctypes.c_uint() | ||||||
|     res = dll.AAXGetMaxBitrate(handle, bitrate) |     res = dll.AAXGetMaxBitrate(handle, byref(bitrate)) | ||||||
| 
 | 
 | ||||||
|     if res != 0: |     if res != 0: | ||||||
|         raise Exception('AAXGetAvgBitrate: {}'.format(res)) |         raise Exception('AAXGetAvgBitrate: {}'.format(res)) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user