A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd
at master 84 lines 2.6 kB view raw
1/***************************************************************************** 2 * __________ __ ___. 3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 * Source | _// __ \_/ ___\| |/ /| __ \ / __ \ \/ / 5 * Jukebox | | ( (__) ) \___| ( | \_\ ( (__) ) ( 6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 * \/ \/ \/ \/ \/ 8 * $Id$ 9 * 10 * Copyright (C) 2008 Andrew Mahone 11 * 12 * This program is free software; you can redistribute it and/or 13 * modify it under the terms of the GNU General Public License 14 * as published by the Free Software Foundation; either version 2 15 * of the License, or (at your option) any later version. 16 * 17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 18 * KIND, either express or implied. 19 * 20 ****************************************************************************/ 21 22#include "plugin.h" 23#include "lib/grey.h" 24#include "lib/mylcd.h" 25 26 27/* different graphics libraries */ 28#if LCD_DEPTH < 8 29#define USEGSLIB 30GREY_INFO_STRUCT 31#define CFORMAT &format_grey 32#else 33#define CFORMAT NULL 34#endif 35 36/* this is the plugin entry point */ 37enum plugin_status plugin_start(const void* parameter) 38{ 39 size_t plugin_buf_len; 40 unsigned char * plugin_buf = 41 (unsigned char *)rb->plugin_get_buffer(&plugin_buf_len); 42 static char filename[MAX_PATH]; 43 struct bitmap bm = { 44 .width = LCD_WIDTH, 45 .height = LCD_HEIGHT, 46 }; 47 int ret; 48 49 if(!parameter) return PLUGIN_ERROR; 50 51 rb->strcpy(filename, parameter); 52 53#ifdef USEGSLIB 54 long greysize; 55 if (!grey_init(plugin_buf, plugin_buf_len, GREY_ON_COP, 56 LCD_WIDTH, LCD_HEIGHT, &greysize)) 57 { 58 rb->splash(HZ, "grey buf error"); 59 return PLUGIN_ERROR; 60 } 61 plugin_buf += greysize; 62 plugin_buf_len -= greysize; 63#endif 64 bm.data = plugin_buf; 65 ret = rb->read_jpeg_file(filename, &bm, plugin_buf_len, 66 FORMAT_NATIVE|FORMAT_RESIZE|FORMAT_KEEP_ASPECT, 67 CFORMAT); 68 if (ret < 1) 69 return PLUGIN_ERROR; 70#ifdef USEGSLIB 71 grey_show(true); 72 grey_ub_gray_bitmap((const unsigned char *)bm.data, (LCD_WIDTH - bm.width) >> 1, 73 (LCD_HEIGHT - bm.height) >> 1, bm.width, bm.height); 74#else 75 rb->lcd_bitmap((const fb_data *)bm.data, (LCD_WIDTH - bm.width) >> 1, 76 (LCD_HEIGHT - bm.height) >> 1, bm.width, bm.height); 77#endif 78 mylcd_ub_update(); 79 while (rb->get_action(CONTEXT_STD,1) != ACTION_STD_OK) rb->yield(); 80#ifdef USEGSLIB 81 grey_release(); 82#endif 83 return PLUGIN_OK; 84}