types.rs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. #![allow(non_camel_case_types, dead_code)]
  2. use libc::{size_t, c_int, c_char, c_void};
  3. use session::sp_session;
  4. #[derive(Clone, Copy)]
  5. #[repr(u32)]
  6. pub enum sp_error {
  7. SP_ERROR_OK = 0,
  8. SP_ERROR_BAD_API_VERSION = 1,
  9. SP_ERROR_API_INITIALIZATION_FAILED = 2,
  10. SP_ERROR_TRACK_NOT_PLAYABLE = 3,
  11. SP_ERROR_BAD_APPLICATION_KEY = 5,
  12. SP_ERROR_BAD_USERNAME_OR_PASSWORD = 6,
  13. SP_ERROR_USER_BANNED = 7,
  14. SP_ERROR_UNABLE_TO_CONTACT_SERVER = 8,
  15. SP_ERROR_CLIENT_TOO_OLD = 9,
  16. SP_ERROR_OTHER_PERMANENT = 10,
  17. SP_ERROR_BAD_USER_AGENT = 11,
  18. SP_ERROR_MISSING_CALLBACK = 12,
  19. SP_ERROR_INVALID_INDATA = 13,
  20. SP_ERROR_INDEX_OUT_OF_RANGE = 14,
  21. SP_ERROR_USER_NEEDS_PREMIUM = 15,
  22. SP_ERROR_OTHER_TRANSIENT = 16,
  23. SP_ERROR_IS_LOADING = 17,
  24. SP_ERROR_NO_STREAM_AVAILABLE = 18,
  25. SP_ERROR_PERMISSION_DENIED = 19,
  26. SP_ERROR_INBOX_IS_FULL = 20,
  27. SP_ERROR_NO_CACHE = 21,
  28. SP_ERROR_NO_SUCH_USER = 22,
  29. SP_ERROR_NO_CREDENTIALS = 23,
  30. SP_ERROR_NETWORK_DISABLED = 24,
  31. SP_ERROR_INVALID_DEVICE_ID = 25,
  32. SP_ERROR_CANT_OPEN_TRACE_FILE = 26,
  33. SP_ERROR_APPLICATION_BANNED = 27,
  34. SP_ERROR_OFFLINE_TOO_MANY_TRACKS = 31,
  35. SP_ERROR_OFFLINE_DISK_CACHE = 32,
  36. SP_ERROR_OFFLINE_EXPIRED = 33,
  37. SP_ERROR_OFFLINE_NOT_ALLOWED = 34,
  38. SP_ERROR_OFFLINE_LICENSE_LOST = 35,
  39. SP_ERROR_OFFLINE_LICENSE_ERROR = 36,
  40. SP_ERROR_LASTFM_AUTH_ERROR = 39,
  41. SP_ERROR_INVALID_ARGUMENT = 40,
  42. SP_ERROR_SYSTEM_FAILURE = 41,
  43. }
  44. #[repr(C)]
  45. #[derive(Copy,Clone)]
  46. pub struct sp_session_config {
  47. pub api_version: c_int,
  48. pub cache_location: *const c_char,
  49. pub settings_location: *const c_char,
  50. pub application_key: *const c_void,
  51. pub application_key_size: size_t,
  52. pub user_agent: *const c_char,
  53. pub callbacks: *const sp_session_callbacks,
  54. pub userdata: *mut c_void,
  55. pub compress_playlists: bool,
  56. pub dont_save_metadata_for_playlists: bool,
  57. pub initially_unload_playlists: bool,
  58. pub device_id: *const c_char,
  59. pub proxy: *const c_char,
  60. pub proxy_username: *const c_char,
  61. pub proxy_password: *const c_char,
  62. pub tracefile: *const c_char,
  63. }
  64. #[repr(C)]
  65. #[derive(Clone, Copy)]
  66. pub struct sp_session_callbacks {
  67. pub logged_in: Option<unsafe extern "C" fn(session: *mut sp_session,
  68. error: sp_error)>,
  69. pub logged_out: Option<unsafe extern "C" fn(session: *mut sp_session)>,
  70. pub metadata_updated: Option<unsafe extern "C" fn(session: *mut sp_session)>,
  71. pub connection_error: Option<unsafe extern "C" fn(session: *mut sp_session,
  72. error: sp_error)>,
  73. pub message_to_user: Option<unsafe extern "C" fn(session: *mut sp_session,
  74. message: *const c_char)>,
  75. pub notify_main_thread: Option<unsafe extern "C" fn(session: *mut sp_session)>,
  76. pub music_delivery: Option<unsafe extern "C" fn(session: *mut sp_session,
  77. format: *const sp_audioformat,
  78. frames: *const c_void,
  79. num_frames: c_int)
  80. -> c_int>,
  81. pub play_token_lost: Option<unsafe extern "C" fn(session: *mut sp_session)>,
  82. pub log_message: Option<unsafe extern "C" fn(session: *mut sp_session,
  83. data: *const c_char)>,
  84. pub end_of_track: Option<unsafe extern "C" fn(session: *mut sp_session)>,
  85. pub streaming_error: Option<unsafe extern "C" fn(session: *mut sp_session,
  86. error: sp_error)>,
  87. pub userinfo_updated: Option<unsafe extern "C" fn(session: *mut sp_session)>,
  88. pub start_playback: Option<unsafe extern "C" fn(session: *mut sp_session)>,
  89. pub stop_playback: Option<unsafe extern "C" fn(session: *mut sp_session)>,
  90. pub get_audio_buffer_stats: Option<unsafe extern "C" fn(session: *mut sp_session,
  91. stats: *mut sp_audio_buffer_stats)>,
  92. pub offline_status_updated: Option<unsafe extern "C" fn(session: *mut sp_session)>,
  93. pub offline_error: Option<unsafe extern "C" fn(session: *mut sp_session,
  94. error: sp_error)>,
  95. pub credentials_blob_updated: Option<unsafe extern "C" fn(session: *mut sp_session,
  96. blob: *const c_char)>,
  97. pub connectionstate_updated: Option<unsafe extern "C" fn(session: *mut sp_session)>,
  98. pub scrobble_error: Option<unsafe extern "C" fn(session: *mut sp_session,
  99. error: sp_error)>,
  100. pub private_session_mode_changed: Option<unsafe extern "C" fn(session: *mut sp_session,
  101. is_private: bool)>,
  102. }
  103. #[repr(C)]
  104. #[derive(Clone, Copy)]
  105. pub struct sp_audioformat {
  106. pub sample_type: sp_sampletype,
  107. pub sample_rate: c_int,
  108. pub channels: c_int,
  109. }
  110. #[derive(Clone, Copy)]
  111. #[repr(u32)]
  112. pub enum sp_sampletype {
  113. SP_SAMPLETYPE_INT16_NATIVE_ENDIAN = 0,
  114. _Dummy // rust #10292
  115. }
  116. #[repr(C)]
  117. #[derive(Clone, Copy)]
  118. pub struct sp_audio_buffer_stats {
  119. pub samples: c_int,
  120. pub stutter: c_int,
  121. }