def data(self): """The raw image data as a bytestring. Will always return :class:`None` if the image isn't loaded. """ if not self.is_loaded: return None data_size_ptr = ffi.new("size_t *") data = lib.sp_image_data(self._sp_image, data_size_ptr) buffer_ = ffi.buffer(data, data_size_ptr[0]) data_bytes = buffer_[:] assert len(data_bytes) == data_size_ptr[0], "%r == %r" % (len(data_bytes), data_size_ptr[0]) return data_bytes
def data(self): """The raw image data as a bytestring. Will always return :class:`None` if the image isn't loaded. """ if not self.is_loaded: return None data_size_ptr = ffi.new('size_t *') data = lib.sp_image_data(self._sp_image, data_size_ptr) buffer_ = ffi.buffer(data, data_size_ptr[0]) data_bytes = buffer_[:] assert len(data_bytes) == data_size_ptr[0], '%r == %r' % ( len(data_bytes), data_size_ptr[0]) return data_bytes
def music_delivery(sp_session, sp_audioformat, frames, num_frames): if not spotify.session_instance: return 0 if spotify.session_instance.num_listeners( SessionEvent.MUSIC_DELIVERY) == 0: logger.debug('Got music delivery, but no event listener') return 0 logger.debug('Got music delivery of %d frames', num_frames) audio_format = spotify.AudioFormat(sp_audioformat) buffer_ = ffi.buffer(frames, audio_format.frame_size() * num_frames) frames_bytes = buffer_[:] return spotify.session_instance.call(SessionEvent.MUSIC_DELIVERY, spotify.session_instance, audio_format, frames_bytes, num_frames)
def music_delivery(sp_session, sp_audioformat, frames, num_frames): if not spotify._session_instance: return 0 if spotify._session_instance.num_listeners( SessionEvent.MUSIC_DELIVERY) == 0: logger.debug('Music delivery, but no listener') return 0 audio_format = spotify.AudioFormat(sp_audioformat) frames_buffer = ffi.buffer(frames, audio_format.frame_size() * num_frames) frames_bytes = frames_buffer[:] num_frames_consumed = spotify._session_instance.call( SessionEvent.MUSIC_DELIVERY, spotify._session_instance, audio_format, frames_bytes, num_frames) logger.debug('Music delivery of %d frames, %d consumed', num_frames, num_frames_consumed) return num_frames_consumed
def music_delivery(sp_session, sp_audioformat, frames, num_frames): if not spotify._session_instance: return 0 if spotify._session_instance.num_listeners( SessionEvent.MUSIC_DELIVERY) == 0: logger.debug('Music delivery, but no listener') return 0 audio_format = spotify.AudioFormat(sp_audioformat) frames_buffer = ffi.buffer( frames, audio_format.frame_size() * num_frames) frames_bytes = frames_buffer[:] num_frames_consumed = spotify._session_instance.call( SessionEvent.MUSIC_DELIVERY, spotify._session_instance, audio_format, frames_bytes, num_frames) logger.debug( 'Music delivery of %d frames, %d consumed', num_frames, num_frames_consumed) return num_frames_consumed