/* called when preparing a refbuf with audio data to be passed * back for queueing */ static refbuf_t *complete_buffer (source_t *source, refbuf_t *refbuf) { ogg_state_t *ogg_info = source->format->_state; refbuf->associated = ogg_info->header_pages; refbuf_addref (refbuf->associated); if (ogg_info->log_metadata) { update_comments (source); ogg_info->log_metadata = 0; } /* listeners can start anywhere unless the codecs themselves are * marking starting points */ if (ogg_info->codec_sync == NULL) refbuf->flags |= SOURCE_BLOCK_SYNC; source->client->queue_pos += refbuf->len; return refbuf; }
/* called when preparing a refbuf with audio data to be passed * back for queueing */ static refbuf_t *complete_buffer (source_t *source, refbuf_t *refbuf) { ogg_state_t *ogg_info = source->format->_state; refbuf_t *header = ogg_info->header_pages; while (header) { refbuf_addref (header); header = header->next; } refbuf->associated = ogg_info->header_pages; if (ogg_info->log_metadata) { update_comments (source); ogg_info->log_metadata = 0; } /* listeners can start anywhere unless the codecs themselves are * marking starting points */ if (ogg_info->codec_sync == NULL) refbuf->sync_point = 1; return refbuf; }
static void cb_in_received_handler(DictionaryIterator *iter, void *context) { APP_LOG(APP_LOG_LEVEL_DEBUG, "Incoming data"); // Reset ErrorExists = 0; text_layer_set_text(error_text_layer, ""); // Set any messages Tuple *message_tuple = dict_find(iter, KEY_MESSAGE); if(message_tuple){ strcpy(msg_str, message_tuple->value->cstring); text_layer_set_text(message_text_layer, msg_str); layer_mark_dirty(text_layer_get_layer(message_text_layer)); } // Get the bitmap Tuple *size_tuple = dict_find(iter, KEY_SIZE); if(size_tuple){ if(data_image) free(data_image); data_size = size_tuple->value->uint32; data_image = malloc(data_size); } // Set the image Tuple *image_tuple = dict_find(iter, KEY_IMAGE); Tuple *index_tuple = dict_find(iter, KEY_INDEX); if (index_tuple && image_tuple) { int32_t index = index_tuple->value->int32; //APP_LOG(APP_LOG_LEVEL_DEBUG, "image received index=%ld size=%d", index, image_tuple->length); memcpy(data_image + index,&image_tuple->value->uint8,image_tuple->length); if(image_tuple->length < CHUNK_SIZE){ // Clear the image if(image){ gbitmap_destroy(image); image = NULL; } #ifdef PBL_COLOR image = gbitmap_create_from_png_data(data_image, data_size); #else image = gbitmap_create_with_data(data_image); #endif bitmap_layer_set_bitmap(image_layer, image); layer_mark_dirty(bitmap_layer_get_layer(image_layer)); text_layer_set_text(message_text_layer,""); layer_mark_dirty(text_layer_get_layer(message_text_layer)); vibes_short_pulse(); light_enable_interaction(); ImgLoaded = 1; Loading = 0; text_layer_set_text(username_text_layer, usr_str); text_layer_set_background_color(username_text_layer, GColorWhite); if(ErrorExists == 1){ text_layer_set_background_color(username_text_layer, GColorClear); } layer_mark_dirty(text_layer_get_layer(username_text_layer)); } } // Set any errors Tuple *error_tuple = dict_find(iter, KEY_ERROR); if(error_tuple){ text_layer_set_text(message_text_layer,""); layer_mark_dirty(text_layer_get_layer(message_text_layer)); // Clear the image if(image){ gbitmap_destroy(image); if(data_image){ free(data_image); } image = NULL; bitmap_layer_set_bitmap(image_layer, image); } Loading = 0; ErrorExists = 1; #ifdef PBL_COLOR image = gbitmap_create_with_resource(RESOURCE_ID_ERROR_B); text_layer_set_text_color(error_text_layer, GColorBlack); #else image = gbitmap_create_with_resource(RESOURCE_ID_ERROR_A); #endif bitmap_layer_set_bitmap(image_layer, image); layer_mark_dirty(bitmap_layer_get_layer(image_layer)); text_layer_set_text(error_text_layer, error_tuple->value->cstring); layer_mark_dirty(text_layer_get_layer(error_text_layer)); vibes_short_pulse(); light_enable_interaction(); } // Prepare the username Tuple *username_tuple = dict_find(iter, KEY_USERNAME); if(username_tuple){ strcpy(usr_str, username_tuple->value->cstring); prepend(usr_str, " "); //text_layer_set_text(username_text_layer, usr_str); } // Set the likes Tuple *likes_tuple = dict_find(iter, KEY_LIKES); if(likes_tuple){ strcpy(likes_str, likes_tuple->value->cstring); update_likes(likes_str); } // Set the comments Tuple *comments_tuple = dict_find(iter, KEY_COMMENTS); if(comments_tuple){ strcpy(comments_str, comments_tuple->value->cstring); update_comments(comments_str); } // Set the caption Tuple *caption_tuple = dict_find(iter, KEY_CAPTION); if(caption_tuple){ strcpy(capt_str, caption_tuple->value->cstring); update_caption(capt_str); } }