Subversion Repositories Kolibri OS

Compare Revisions

No changes between revisions

Regard whitespace Rev 2693 → Rev 3068

/programs/media/Fplay/audio.c
14,8 → 14,13
astream_t astream;
 
extern uint8_t *decoder_buffer;
int resampler_size;
volatile int sound_level_0;
volatile int sound_level_1;
 
extern volatile enum player_state player_state;
volatile enum player_state player_state;
volatile enum player_state decoder_state;
volatile enum player_state sound_state;
 
extern volatile uint32_t driver_lock;
 
46,7 → 51,7
 
mutex_unlock(&driver_lock);
 
printf("sound version 0x%x\n", version);
// printf("sound version 0x%x\n", version);
 
if( (SOUND_VERSION>(version&0xFFFF)) ||
(SOUND_VERSION<(version >> 16)))
67,6 → 72,11
return 0;
};
 
void set_audio_volume(int left, int right)
{
SetVolume(hBuff, left, right);
};
 
static uint64_t samples_lost;
static double audio_delta;
static double last_time_stamp;
89,7 → 99,7
int data_size=0;
 
if( astream.count > AVCODEC_MAX_AUDIO_FRAME_SIZE*7)
return 1;
return -1;
 
if( get_packet(qa, &pkt) == 0 )
return 0;
161,8 → 171,16
 
mutex_lock(&astream.lock);
{
if(astream.count < buffsize)
{
memset(astream.buffer+astream.count,
0, buffsize-astream.count);
astream.count = buffsize;
};
 
SetBuffer(hbuff, astream.buffer, offset, buffsize);
samples_written+= buffsize/4;
 
astream.count -= buffsize;
if(astream.count)
memcpy(astream.buffer, astream.buffer+buffsize, astream.count);
174,7 → 192,6
 
};
 
 
int audio_thread(void *param)
{
SND_EVENT evnt;
192,7 → 209,7
goto exit_whith_error;
};
 
SetVolume(hBuff,-1000,-1000);
SetVolume(hBuff,-1875,-1875);
 
if((err = GetBufferSize(hBuff, &buffsize)) != 0)
{
200,24 → 217,10
goto exit_whith_error;
};
 
buffsize = buffsize/2;
resampler_size = buffsize = buffsize/2;
 
samples = buffsize/4;
 
while( (astream.count < buffsize*2) &&
(player_state != CLOSED) )
yield();
 
mutex_lock(&astream.lock);
{
SetBuffer(hBuff, astream.buffer, 0, buffsize);
samples_written+= buffsize/4;
astream.count -= buffsize;
if(astream.count)
memcpy(astream.buffer, astream.buffer+buffsize, astream.count);
mutex_unlock(&astream.lock);
};
 
while( player_state != CLOSED)
{
uint32_t offset;
224,55 → 227,29
double event_stamp, wait_stamp;
int too_late = 0;
 
if((player_state == PAUSE) ||
(player_state == PLAY_INIT) )
switch(sound_state)
{
if( active )
case PREPARE:
 
mutex_lock(&astream.lock);
if(astream.count < buffsize*2)
{
StopBuffer(hBuff);
active = 0;
memset(astream.buffer+astream.count,
0, buffsize*2-astream.count);
astream.count = buffsize*2;
};
delay(1);
continue;
}
else if(player_state == REWIND)
{
if( active )
{
StopBuffer(hBuff);
active = 0;
};
mutex_lock(&astream.lock);
astream.count = 0;
 
SetBuffer(hBuff, astream.buffer, 0, buffsize*2);
astream.count -= buffsize*2;
if(astream.count)
memcpy(astream.buffer, astream.buffer+buffsize*2, astream.count);
mutex_unlock(&astream.lock);
delay(1);
continue;
}
else if(player_state == PAUSE_2_PLAY)
{
// SetTimeBase(hBuff, audio_base);
GetTimeStamp(hBuff, &last_time_stamp);
// printf("last_time_stamp %f\n", last_time_stamp);
if((err = PlayBuffer(hBuff, 0)) !=0 )
{
errstr = "Cannot play buffer\n\r";
goto exit_whith_error;
};
active = 1;
sync_audio(hBuff, buffsize);
player_state = PLAY;
printf("render: set audio latency to %f\n", audio_delta);
}
else if(player_state == REWIND_2_PLAY)
{
while( (astream.count < buffsize*2) &&
(player_state != CLOSED) )
yield();
SetTimeBase(hBuff, audio_base);
 
SetTimeBase(hBuff, audio_base);
case PAUSE_2_PLAY:
GetTimeStamp(hBuff, &last_time_stamp);
printf("last audio time stamp %f\n", last_time_stamp);
// printf("last audio time stamp %f\n", last_time_stamp);
if((err = PlayBuffer(hBuff, 0)) !=0 )
{
281,10 → 258,12
};
active = 1;
sync_audio(hBuff, buffsize);
player_state = PLAY;
printf("render: set audio latency to %f\n", audio_delta);
};
sound_state = PLAY;
// printf("render: set audio latency to %f\n", audio_delta);
 
/* breaktrough */
 
case PLAY:
GetNotify(&evnt);
 
if(evnt.code != 0xFF000001)
300,42 → 279,71
continue;
};
 
GetTimeStamp(hBuff, &event_stamp);
 
offset = evnt.offset;
 
while( (astream.count < buffsize) &&
(player_state != CLOSED) )
mutex_lock(&astream.lock);
if(astream.count < buffsize)
{
yield();
GetTimeStamp(hBuff, &wait_stamp);
if( (wait_stamp - event_stamp) >
samples*1500/sample_rate )
{
samples_lost+= samples;
audio_delta = (double)samples_lost*1000/sample_rate;
// printf("audio delta %f\n", audio_delta);
too_late = 1;
break;
}
memset(astream.buffer+astream.count,
0, buffsize-astream.count);
astream.count = buffsize;
};
 
if((too_late == 1) || (player_state == CLOSED))
SetBuffer(hBuff, astream.buffer, offset, buffsize);
 
{
too_late = 0;
continue;
double val = 0;
int16_t *src = (int16_t*)astream.buffer;
int samples = buffsize/2;
int i;
 
for(i = 0, val = 0; i < samples/2; i++, src++)
if(val < abs(*src))
val= abs(*src); // * *src;
 
sound_level_0 = val; //sqrt(val / (samples/2));
 
for(i = 0, val = 0; i < samples/2; i++, src++)
if(val < abs(*src))
val= abs(*src); // * *src;
 
sound_level_1 = val; //sqrt(val / (samples/2));
 
// printf("%d\n", sound_level);
};
 
mutex_lock(&astream.lock);
SetBuffer(hBuff, astream.buffer, offset, buffsize);
samples_written+= buffsize/4;
 
astream.count -= buffsize;
if(astream.count)
memcpy(astream.buffer, astream.buffer+buffsize, astream.count);
mutex_unlock(&astream.lock);
break;
 
case PLAY_2_STOP:
if( active )
{
ResetBuffer(hBuff, SND_RESET_ALL);
audio_base = -1.0;
active = 0;
}
sound_state = STOP;
break;
 
case PLAY_2_PAUSE:
if( active )
{
StopBuffer(hBuff);
};
sound_state = PAUSE;
 
case PAUSE:
case STOP:
delay(1);
};
}
 
StopBuffer(hBuff);
DestroyBuffer(hBuff);
 
return 0;
/programs/media/Fplay/fplay.c
15,7 → 15,9
#include "sound.h"
#include "fplay.h"
 
volatile enum player_state player_state;
volatile enum player_state player_state = STOP;
volatile enum player_state decoder_state = PREPARE;
volatile enum player_state sound_state = STOP;
 
uint32_t win_width, win_height;
 
33,6 → 35,8
int have_sound = 0;
 
uint8_t *decoder_buffer;
extern int resampler_size;
 
extern int sample_rate;
char *movie_file;
 
66,7 → 70,7
movie_file = argv[1];
/* register all codecs, demux and protocols */
 
// av_log_set_level(AV_LOG_INFO);
av_log_set_level(AV_LOG_FATAL);
 
avcodec_register_all();
avdevice_register_all();
133,8 → 137,6
return -1; // Didn't find a video stream
}
 
player_state = PLAY_INIT;
 
// __asm__ __volatile__("int3");
 
// Get a pointer to the codec context for the video stream
232,31 → 234,16
}
 
 
static int fill_queue()
static int load_frame()
{
int eof = 0;
AVPacket packet;
 
while( !eof)
{
int err;
 
// __asm__ __volatile__("int3");
 
if(q_video.size+q_audio.size < 2*1024*1024)
{
err = av_read_frame(pFormatCtx, &packet);
if( err < 0)
if( err == 0)
{
eof = 1;
if (err != AVERROR_EOF)
printf("av_read_frame: error %x\n", err);
break;
}
if(packet.stream_index==videoStream)
{
put_packet(&q_video, &packet);
}
else if( (packet.stream_index == audioStream) &&
(have_sound != 0) )
{
263,124 → 250,163
put_packet(&q_audio, &packet);
if(audio_base == -1.0)
{
if (packet.dts != AV_NOPTS_VALUE)
audio_base = get_audio_base() * packet.dts;
if (packet.pts != AV_NOPTS_VALUE)
audio_base = get_audio_base() * packet.pts;
// printf("audio base %f\n", audio_base);
};
}
else
{
av_free_packet(&packet);
};
else av_free_packet(&packet);
}
else break;
};
else if (err != AVERROR_EOF)
printf("av_read_frame: error %x\n", err);
 
return eof;
return err;
}
 
};
 
 
void decoder()
static int fill_queue()
{
int eof;
int err = 0;
AVPacket packet;
int ret;
 
eof = fill_queue();
// __asm__ __volatile__("int3");
 
while( player_state != CLOSED && !eof)
{
int err;
while( (q_video.size+q_audio.size < 2*1024*1024) &&
!err )
err = load_frame();
 
// __asm__ __volatile__("int3");
return err;
 
if( player_state == PAUSE )
{
delay(1);
continue;
};
 
if( player_state == REWIND )
 
static void flush_all()
{
// int64_t timestamp = 0;
// int stream_index = av_find_default_stream_index(pFormatCtx);
AVPacket packet;
 
// __asm__ __volatile__("int3");
 
if (pFormatCtx->start_time != AV_NOPTS_VALUE)
rewind_pos += pFormatCtx->start_time;
 
printf("rewind %8"PRId64"\n", rewind_pos);
ret = avformat_seek_file(pFormatCtx, -1, INT64_MIN,
rewind_pos, INT64_MAX, 0);
// ret = avformat_seek_file(pFormatCtx, -1, 0,
// 0, INT64_MAX, 0);
// __asm__ __volatile__("int3");
 
if (ret < 0)
{
printf("could not seek to position %f\n",
(double)rewind_pos / AV_TIME_BASE);
}
else
{
avcodec_flush_buffers(pCodecCtx);
avcodec_flush_buffers(aCodecCtx);
 
while( get_packet(&q_video, &packet) != 0)
av_free_packet(&packet);
 
while( get_packet(&q_audio, &packet)!= 0)
av_free_packet(&packet);
audio_base = -1.0;
 
// __asm__ __volatile__("int3");
flush_video();
 
eof = fill_queue();
astream.count = 0;
};
yield();
 
flush_video();
void decoder()
{
int eof;
AVPacket packet;
int ret;
int64_t min_pos, max_pos;
 
player_state = REWIND_2_PLAY;
printf("restart\n");
continue;
};
while( player_state != CLOSED )
{
int err;
 
if(q_video.size+q_audio.size < 4*1024*1024)
// __asm__ __volatile__("int3");
 
switch(decoder_state)
{
err = av_read_frame(pFormatCtx, &packet);
if( err < 0)
case PREPARE:
eof = fill_queue();
 
do
{
eof = 1;
if (err != AVERROR_EOF)
printf("av_read_frame: error %x\n", err);
continue;
}
if(packet.stream_index==videoStream)
if( (q_video.size+q_audio.size < 4*1024*1024) &&
(eof == 0) )
{
put_packet(&q_video, &packet);
eof = load_frame();
}
else if( (packet.stream_index == audioStream) &&
(have_sound != 0) )
decode_video(pCodecCtx, &q_video);
ret = decode_audio(aCodecCtx, &q_audio);
}while(astream.count < resampler_size*2 &&
ret == 1);
 
sound_state = PREPARE;
decoder_state = PLAY;
player_state = PLAY;
 
case PLAY:
if( (q_video.size+q_audio.size < 4*1024*1024) &&
(eof == 0) )
{
put_packet(&q_audio, &packet);
eof = load_frame();
if(eof) printf("eof\n");
}
else
ret = decode_video(pCodecCtx, &q_video);
ret|= decode_audio(aCodecCtx, &q_audio);
 
if( eof && !ret)
{
av_free_packet(&packet);
decoder_state = STOP;
// printf("stop decoder\n");
};
decode_video(pCodecCtx, &q_video);
decode_audio(aCodecCtx, &q_audio);
continue;
};
decode_video(pCodecCtx, &q_video);
decode_audio(aCodecCtx, &q_audio);
 
case STOP:
delay(1);
break;
 
case PLAY_2_STOP:
while(sound_state != STOP)
delay(1);
 
flush_all();
 
if (pFormatCtx->start_time != AV_NOPTS_VALUE)
rewind_pos = pFormatCtx->start_time;
else
rewind_pos = 0;
 
ret = avformat_seek_file(pFormatCtx, -1, INT64_MIN,
rewind_pos, INT64_MAX, 0);
 
decoder_state = STOP;
break;
 
case REWIND:
while(sound_state != STOP)
yield();
 
flush_all();
int opts = 0;
if(rewind_pos < 0)
{
rewind_pos = -rewind_pos;
opts = AVSEEK_FLAG_BACKWARD;
};
 
if (pFormatCtx->start_time != AV_NOPTS_VALUE)
rewind_pos += pFormatCtx->start_time;
 
// printf("rewind %8"PRId64"\n", rewind_pos);
min_pos = rewind_pos - 1000000;
max_pos = rewind_pos + 1000000;
 
ret = avformat_seek_file(pFormatCtx, -1, INT64_MIN,
rewind_pos, INT64_MAX, 0);
 
// ret = avformat_seek_file(pFormatCtx, -1, min_pos,
// rewind_pos, max_pos, opts);
// __asm__ __volatile__("int3");
 
if (ret < 0)
{
printf("could not seek to position %f\n",
(double)rewind_pos / AV_TIME_BASE);
}
 
// printf("restart\n");
decoder_state = PREPARE;
break;
}
};
 
ret = 1;
 
while( (player_state != CLOSED) && ret)
/programs/media/Fplay/fplay.h
52,13 → 52,25
};
 
enum player_state
{ CLOSED=0,PLAY_INIT,
STOP, PAUSE, PLAY, REWIND,
PAUSE_2_PLAY, REWIND_2_PLAY
{
CLOSED = 0,
PREPARE,
STOP,
PAUSE,
PLAY,
REWIND,
PLAY_2_STOP,
PLAY_2_PAUSE,
PAUSE_2_PLAY,
REWIND_2_PLAY,
};
 
#define ID_PLAY 100
#define ID_PROGRESS 101
#define ID_STOP 101
#define ID_PROGRESS 102
#define ID_VOL_LEVEL 103
#define ID_VOL_CTRL 104
 
typedef struct
{
volatile uint32_t lock;
112,6 → 124,7
 
int init_audio(int format);
int audio_thread(void *param);
void set_audio_volume(int left, int right);
 
int init_video(AVCodecContext *ctx);
int video_thread(void *param);
178,4 → 191,4
int blit_bitmap(bitmap_t *bitmap, int dst_x, int dst_y,
int w, int h);
 
 
int init_fontlib();
/programs/media/Fplay/pixlib2.c
1,12 → 1,23
#include <stdint.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
//#include <libavcodec/avcodec.h>
//#include <libavformat/avformat.h>
//#include <libswscale/swscale.h>
#include <stdio.h>
#include <fcntl.h>
//#include <fcntl.h>
#include "../winlib/winlib.h"
#include "fplay.h"
//#include "fplay.h"
#include "system.h"
 
typedef struct
{
uint32_t width;
uint32_t height;
uint32_t pitch;
uint32_t handle;
uint8_t *data;
}bitmap_t;
 
 
#define DISPLAY_VERSION 0x0200 /* 2.00 */
 
#define SRV_GETVERSION 0
13,20 → 24,51
#define SRV_GET_CAPS 3
 
#define SRV_CREATE_SURFACE 10
#define SRV_DESTROY_SURFACE 11
#define SRV_LOCK_SURFACE 12
#define SRV_UNLOCK_SURFACE 13
#define SRV_RESIZE_SURFACE 14
#define SRV_BLIT_BITMAP 15
#define SRV_BLIT_TEXTURE 16
#define SRV_BLIT_VIDEO 17
 
#define SRV_BLIT_VIDEO 20
 
#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1)
 
//void InitPixlib(uint32_t flags);
 
#define HW_BIT_BLIT (1<<0) /* BGRX blitter */
#define HW_TEX_BLIT (1<<1) /* stretch blit */
#define HW_VID_BLIT (1<<2) /* planar and packed video */
 
uint32_t InitPixlib(uint32_t flags);
 
int create_bitmap(bitmap_t *bitmap);
int lock_bitmap(bitmap_t *bitmap);
int resize_bitmap(bitmap_t *bitmap);
int blit_bitmap(bitmap_t *bitmap, int dst_x, int dst_y,
int w, int h);
 
 
 
static uint32_t service;
static uint32_t blit_caps;
static uint32_t screen_width;
static uint32_t screen_height;
 
typedef struct
{
unsigned handle;
unsigned io_code;
void *input;
int inp_size;
void *output;
int out_size;
}ioctl_t;
 
 
 
typedef struct
{
uint32_t idx;
union
{
38,6 → 80,17
};
}hwcaps_t;
 
static inline uint32_t GetScreenSize()
{
uint32_t retval;
 
__asm__ __volatile__(
"int $0x40"
:"=a"(retval)
:"a"(61), "b"(1));
return retval;
}
 
static uint32_t get_service(char *name)
{
uint32_t retval = 0;
68,11 → 121,16
uint32_t InitPixlib(uint32_t caps)
{
uint32_t api_version;
uint32_t screensize;
hwcaps_t hwcaps;
ioctl_t io;
 
// __asm__ __volatile__("int3");
 
screensize = GetScreenSize();
screen_width = screensize >> 16;
screen_height = screensize & 0xFFFF;
 
service = get_service("DISPLAY");
if(service == 0)
goto fail;
153,8 → 211,8
 
io_10.width = bitmap->width;
io_10.height = bitmap->height;
io_10.max_width = 0;
io_10.max_height = 0;
io_10.max_width = screen_width;
io_10.max_height = screen_height;
io_10.format = 0;
 
io.handle = service;
201,22 → 259,19
int lock_bitmap(bitmap_t *bitmap)
{
// __asm__ __volatile__("int3");
int err = 0;
 
if( blit_caps & HW_BIT_BLIT )
{
struct __attribute__((packed)) /* SRV_CREATE_SURFACE */
struct __attribute__((packed)) /* SRV_LOCK_SURFACE */
{
uint32_t handle; // ignored
void *data; // ignored
uint32_t handle;
void *data;
uint32_t pitch;
 
uint32_t width;
uint32_t height;
uint32_t pitch; // ignored
 
}io_12;
 
ioctl_t io;
int err;
 
io_12.handle = bitmap->handle;
io_12.pitch = 0;
225,7 → 280,7
io.handle = service;
io.io_code = SRV_LOCK_SURFACE;
io.input = &io_12;
io.inp_size = BUFFER_SIZE(5);
io.inp_size = BUFFER_SIZE(3);
io.output = NULL;
io.out_size = 0;
 
236,33 → 291,16
bitmap->data = io_12.data;
// printf("Lock hardware surface %x pitch %d, buffer %x\n",
// bitmap->handle, bitmap->pitch, bitmap->data);
return 0;
};
return err;
};
 
return 0;
return err;
};
 
struct blit_call
{
int dstx;
int dsty;
int w;
int h;
 
int srcx;
int srcy;
int srcw;
int srch;
 
unsigned char *bitmap;
int stride;
};
 
int blit_bitmap(bitmap_t *bitmap, int dst_x, int dst_y,
int w, int h)
{
int err;
 
if( blit_caps & HW_BIT_BLIT )
{
280,22 → 318,21
int src_y;
uint32_t w;
uint32_t h;
}io_20;
}io_15;
 
ioctl_t io;
int err;
 
io_20.handle = bitmap->handle;
io_20.dst_x = dst_x;
io_20.dst_y = dst_y;
io_20.src_x = 0;
io_20.src_y = 0;
io_20.w = w;
io_20.h = h;
io_15.handle = bitmap->handle;
io_15.dst_x = dst_x;
io_15.dst_y = dst_y;
io_15.src_x = 0;
io_15.src_y = 0;
io_15.w = w;
io_15.h = h;
 
io.handle = service;
io.io_code = SRV_BLIT_VIDEO;
io.input = &io_20;
io.io_code = SRV_BLIT_BITMAP;
io.input = &io_15;
io.inp_size = BUFFER_SIZE(7);
io.output = NULL;
io.out_size = 0;
303,17 → 340,10
// printf("do blit %x pitch %d\n",bitmap->handle,
// bitmap->pitch);
err = call_service(&io);
if (call_service(&io)==0)
{
//bitmap->data = NULL; Not now, Serge
// printf("blit done\n");
// delay(1);
return 0;
};
return err;
};
 
volatile struct blit_call bc;
struct blit_call bc;
 
bc.dstx = dst_x;
bc.dsty = dst_y;
328,25 → 358,13
 
__asm__ __volatile__(
"int $0x40"
::"a"(73),"b"(0x00),"c"(&bc)
:"=a"(err)
:"a"(73),"b"(0x00),"c"(&bc)
:"memory");
return 0;
return err;
};
 
 
static inline void* user_realloc(void *mem, size_t size)
{
void *val;
__asm__ __volatile__(
"int $0x40"
:"=a"(val)
:"a"(68),"b"(20),"c"(size),"d"(mem)
:"memory");
 
return val;
}
 
int resize_bitmap(bitmap_t *bitmap)
{
// __asm__ __volatile__("int3");
353,8 → 371,37
 
if( blit_caps & HW_BIT_BLIT )
{
/* work in progress */
struct __attribute__((packed))
{
uint32_t handle;
char *data;
uint32_t new_w;
uint32_t new_h;
uint32_t pitch;
}io_14;
 
ioctl_t io;
int err;
 
io_14.handle = bitmap->handle;
io_14.new_w = bitmap->width;
io_14.new_h = bitmap->height;
 
io.handle = service;
io.io_code = SRV_RESIZE_SURFACE;
io.input = &io_14;
io.inp_size = BUFFER_SIZE(5);
io.output = NULL;
io.out_size = 0;
 
err = call_service(&io);
if(err==0)
{
bitmap->pitch = io_14.pitch;
bitmap->data = io_14.data;
};
return err;
};
 
uint32_t size;
uint32_t pitch;
/programs/media/Fplay/sound.h
74,6 → 74,7
#define SND_SETTIMEBASE 18
#define SND_GETTIMESTAMP 19
 
#define SND_RESET_ALL 3
 
#define PLAY_SYNC 0x80000000
 
/programs/media/Fplay/system.h
264,6 → 264,18
return old;
}
 
static inline
int destroy_cursor(uint32_t cursor)
{
int ret;
__asm__ __volatile__(
"int $0x40"
:"=a"(ret)
:"a"(37), "b"(6), "c"(cursor)
:"memory");
return ret;
};
 
static inline void get_proc_info(char *info)
{
__asm__ __volatile__(
279,7 → 291,7
__asm__ __volatile__(
"int $0x40"
:"=a"(val)
:"a"(68),"b"(12),"c"(size),"d"(mem)
:"a"(68),"b"(20),"c"(size),"d"(mem)
:"memory");
 
return val;
/programs/media/Fplay/utils.c
46,8 → 46,8
AVPacketList *q_pkt;
 
/* duplicate the packet */
if (av_dup_packet(pkt) < 0)
return -1;
// if (av_dup_packet(pkt) < 0)
// return -1;
 
q_pkt = av_malloc(sizeof(AVPacketList));
if (!q_pkt)
/programs/media/Fplay/video.c
8,9 → 8,8
#include "../winlib/winlib.h"
#include "sound.h"
#include "fplay.h"
#include <math.h>
 
#define CAPTION_HEIGHT 24
 
extern int res_pause_btn[];
extern int res_pause_btn_pressed[];
 
18,6 → 17,8
extern int res_play_btn_pressed[];
 
extern int64_t stream_duration;
extern volatile int sound_level_0;
extern volatile int sound_level_1;
 
typedef struct
{
27,6 → 28,7
}vframe_t;
 
vframe_t frames[4];
volatile int frames_count = 0;
 
struct SwsContext *cvt_ctx = NULL;
 
54,6 → 56,7
frames[i].pts = 0;
frames[i].ready = 0;
};
frames_count = 0;
vfx = 0;
dfx = 0;
};
65,16 → 68,12
width = ctx->width;
height = ctx->height;
 
printf("w = %d h = %d\n\r", ctx->width, ctx->height);
 
printf("w = %d h = %d\n\r", width, height);
 
// __asm__ __volatile__("int3");
 
main_render = create_render(ctx->width, ctx->height,
ctx->pix_fmt, HW_BIT_BLIT|HW_TEX_BLIT);
// render = create_render(ctx->width, ctx->height,
// ctx->pix_fmt, 0);
//
if( main_render == NULL)
{
printf("Cannot create render\n\r");
121,11 → 120,12
double current_clock;
 
if(frames[dfx].ready != 0 )
return 1;
return -1;
 
if( get_packet(qv, &pkt) == 0 )
return 0;
 
/*
current_clock = -90.0 + get_master_clock();
 
if( pkt.dts == AV_NOPTS_VALUE &&
138,7 → 138,7
pts *= av_q2d(video_time_base)*1000.0;
 
*/
if( 1 /*pts > current_clock*/)
{
frameFinished = 0;
181,6 → 181,7
 
dfx++;
dfx&= 3;
frames_count++;
};
};
av_free_packet(&pkt);
189,10 → 190,35
}
 
extern volatile enum player_state player_state;
extern volatile enum player_state decoder_state;
extern volatile enum player_state sound_state;
 
//rect_t win_rect;
 
extern int64_t rewind_pos;
 
static void player_stop()
{
window_t *win;
 
win = main_render->win;
 
rewind_pos = 0;
 
win->panel.play_btn->img_default = res_play_btn;
win->panel.play_btn->img_hilite = res_play_btn;
win->panel.play_btn->img_pressed = res_play_btn_pressed;
win->panel.prg->current = rewind_pos;
 
send_message(&win->panel.ctrl, MSG_PAINT, 0, 0);
player_state = STOP;
decoder_state = PLAY_2_STOP;
sound_state = PLAY_2_STOP;
render_draw_client(main_render);
// printf("stop player\n");
 
};
 
int MainWindowProc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2)
{
window_t *win;
211,13 → 237,15
break;
 
case MSG_LBTNDOWN:
 
if(player_state == PAUSE)
{
win->panel.play_btn->img_default = res_pause_btn;
win->panel.play_btn->img_hilite = res_pause_btn;
win->panel.play_btn->img_pressed = res_pause_btn_pressed;
send_message(win->panel.play_btn, MSG_PAINT, 0, 0);
player_state = PAUSE_2_PLAY;
send_message(&win->panel.play_btn->ctrl, MSG_PAINT, 0, 0);
player_state = PLAY;
sound_state = PAUSE_2_PLAY;
 
}
else if(player_state == PLAY)
225,8 → 253,9
win->panel.play_btn->img_default = res_play_btn;
win->panel.play_btn->img_hilite = res_play_btn;
win->panel.play_btn->img_pressed = res_play_btn_pressed;
send_message(win->panel.play_btn, MSG_PAINT, 0, 0);
send_message(&win->panel.play_btn->ctrl, MSG_PAINT, 0, 0);
player_state = PAUSE;
sound_state = PLAY_2_PAUSE;
}
break;
 
239,7 → 268,8
win->panel.play_btn->img_default = res_pause_btn;
win->panel.play_btn->img_hilite = res_pause_btn;
win->panel.play_btn->img_pressed = res_pause_btn_pressed;
player_state = PAUSE_2_PLAY;
player_state = PLAY;
sound_state = PAUSE_2_PLAY;
}
else if(player_state == PLAY)
{
247,24 → 277,66
win->panel.play_btn->img_hilite = res_play_btn;
win->panel.play_btn->img_pressed = res_play_btn_pressed;
player_state = PAUSE;
sound_state = PLAY_2_PAUSE;
}
else if(player_state == STOP)
{
win->panel.play_btn->img_default = res_pause_btn;
win->panel.play_btn->img_hilite = res_pause_btn;
win->panel.play_btn->img_pressed = res_pause_btn_pressed;
rewind_pos = 0;
send_message(&win->panel.ctrl, MSG_PAINT, 0, 0);
player_state = PLAY;
decoder_state = PREPARE;
}
break;
 
case 101: //ID_PROGRESS:
case ID_STOP:
player_stop();
break;
 
case ID_PROGRESS:
if(player_state != REWIND)
{
progress_t *prg = (progress_t*)arg2;
rewind_pos = (int64_t)prg->pos *
(prg->max - prg->min)/prg->ctrl.w;
rewind_pos = (prg->max - prg->min)*prg->pos/prg->ctrl.w;
// printf("progress action %f\n", (double)rewind_pos);
// printf("progress action pos: %d time: %f\n", prg->pos, (double)rewind_pos);
player_state = REWIND;
main_render->win->panel.prg->current = rewind_pos;
send_message(&main_render->win->panel.ctrl, MSG_PAINT, 0, 0);
decoder_state = REWIND;
sound_state = PLAY_2_STOP;
if(rewind_pos < prg->current)
{
prg->current = rewind_pos;
rewind_pos = -rewind_pos;
}
else
prg->current = rewind_pos;
 
win->panel.play_btn->img_default = res_pause_btn;
win->panel.play_btn->img_hilite = res_pause_btn;
win->panel.play_btn->img_pressed = res_pause_btn_pressed;
send_message(&prg->ctrl, MSG_PAINT, 0, 0);
};
break;
case ID_VOL_CTRL:
{
slider_t *sld = (slider_t*)arg2;
int peak;
int level;
 
peak = sld->min + sld->pos * (sld->max - sld->min)/(96);
// level = (log2(peak+16384)*10000.0)/15 - 10000;
level = peak;
 
// printf("level %d\n", level);
set_audio_volume(level, level);
send_message(&sld->ctrl, MSG_PAINT, 0, 0);
win->panel.lvl->vol = level;
}
 
default:
break;
}
280,6 → 352,9
 
void render_time(render_t *render)
{
progress_t *prg = main_render->win->panel.prg;
level_t *lvl = main_render->win->panel.lvl;
 
double ctime; /* milliseconds */
double fdelay; /* milliseconds */
 
290,6 → 365,16
render->win->win_command = WIN_CLOSED;
return;
}
else if(player_state == REWIND)
{
yield();
return;
}
else if (decoder_state == STOP && frames_count == 0 &&
player_state != STOP)
{
player_stop();
}
else if(player_state != PLAY)
{
yield();
296,6 → 381,7
return;
};
 
 
#ifdef VERSION_A
if(frames[vfx].ready == 1 )
{
324,8 → 410,16
// sys_time*10, frames[vfx].pts, ctime, fdelay);
 
main_render->draw(main_render, &frames[vfx].picture);
main_render->win->panel.prg->current = frames[vfx].pts*1000;
send_message(&render->win->panel.prg->ctrl, MSG_PAINT, 0, 0);
prg->current = frames[vfx].pts*1000;
// printf("current %f\n", prg->current);
lvl->current = vfx & 1 ? sound_level_1 : sound_level_0;
 
send_message(&prg->ctrl, PRG_PROGRESS, 0, 0);
 
if(main_render->win->panel.layout)
send_message(&lvl->ctrl, MSG_PAINT, 0, 0);
 
frames_count--;
frames[vfx].ready = 0;
vfx++;
vfx&= 3;
396,8 → 490,6
}
 
 
 
 
extern char *movie_file;
 
int video_thread(void *param)
407,7 → 499,7
init_winlib();
 
MainWindow = create_window(movie_file,0,
10,10,width,height+29+55,MainWindowProc);
10,10,width,height+CAPTION_HEIGHT+PANEL_HEIGHT,MainWindowProc);
 
MainWindow->panel.prg->max = stream_duration;
// printf("MainWindow %x\n", MainWindow);
417,11 → 509,12
show_window(MainWindow, NORMAL);
 
render_draw_client(main_render);
player_state = PAUSE_2_PLAY;
player_state = PLAY;
 
run_render(MainWindow, main_render);
 
// printf("exit thread\n");
fini_winlib();
 
player_state = CLOSED;
return 0;
};
473,6 → 566,8
render->rcvideo.r = width;
render->rcvideo.b = height;
 
// printf("render width %d height %d\n",width, height);
 
if( render->win_height > height )
{
int yoffs;
561,9 → 656,12
uint32_t s, sw, sh;
uint8_t state;
 
right = win->w;
bottom = win->h-CAPTION_HEIGHT-PANEL_HEIGHT;
 
right = win->w;
bottom = win->h-CAPTION_HEIGHT-55;
// printf("window width %d height %d\n",
// right, bottom);
 
render->win_state = win->win_state;
 
if(render->win_state == MINIMIZED)
579,25 → 677,19
new_w = bottom*render->ctx_width/render->ctx_height;
new_h = right*render->ctx_height/render->ctx_width;
 
// printf("new_w %d new_h %d\n", new_w, new_h);
 
s = right * bottom;
sw = right * new_h;
sh = bottom * new_w;
 
if( abs(s-sw) > abs(s-sh))
new_h = bottom;
else
if(new_w > right)
{
new_w = right;
 
if(new_w < 64)
new_h = right*render->ctx_height/render->ctx_width;
};
if(new_h > bottom)
{
new_w = 64;
new_h = 64*render->ctx_height/render->ctx_width;
new_h = bottom;
new_w = bottom*render->ctx_width/render->ctx_height;
};
 
render->win_width = win->w;
render->win_height = win->h-CAPTION_HEIGHT-55;
render->win_height = win->h-CAPTION_HEIGHT-PANEL_HEIGHT;
render_set_size(render, new_w, new_h);
};
 
620,8 → 712,8
}
else
{
dst_width = render->win_width;
dst_height = render->win_height;
dst_width = render->rcvideo.r;
dst_height = render->rcvideo.b;
};
 
cvt_ctx = sws_getCachedContext(cvt_ctx,
639,7 → 731,7
ret = lock_bitmap(bitmap);
if( ret != 0)
{
printf("Cannot lock the bitmap!\n");
printf("Cannot lock bitmap!\n");
return ;
}
 
661,12 → 753,13
blit_bitmap(bitmap, render->rcvideo.l,
CAPTION_HEIGHT+render->rcvideo.t,
render->rcvideo.r, render->rcvideo.b);
 
render->last_bitmap = bitmap;
// printf("blit_bitmap\n");
 
 
render->target++;
render->target&= 3;
// render->target++;
// render->target&= 3;
}
 
void draw_sw_picture(render_t *render, AVPicture *picture)
715,8 → 808,7
render->win_state == ROLLED)
return;
 
if((player_state == PAUSE) ||
(player_state == PLAY_INIT) )
if(player_state == PAUSE)
{
if(frames[vfx].ready == 1 )
main_render->draw(main_render, &frames[vfx].picture);
723,6 → 815,11
else
draw_bar(0, CAPTION_HEIGHT, render->win_width,
render->rcvideo.b, 0);
}
else if( player_state == STOP )
{
draw_bar(0, CAPTION_HEIGHT, render->win_width,
render->rcvideo.b, 0);
};
 
if(render->layout & HAS_TOP)
/programs/media/Fplay/winlib/alevel.raw
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/media/Fplay/winlib/button.c
2,8 → 2,14
#include "system.h"
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "winlib.h"
 
extern int res_level[];
extern int res_slider[];
extern int res_vol_slider[];
extern int res_progress_bar[];
extern int res_prg_level[];
 
extern ctrl_t *mouse_capture;
uint32_t main_cursor;
11,39 → 17,52
static int button_proc(ctrl_t *btn, uint32_t msg, uint32_t arg1, uint32_t arg2);
static int spinbtn_proc(ctrl_t *btn, uint32_t msg, uint32_t arg1, uint32_t arg2);
 
 
button_t *create_button(char *caption, int id, int x, int y,
ctrl_t *create_control(size_t size, int id, int x, int y,
int w, int h, ctrl_t *parent)
{
button_t *btn;
int len;
 
ctrl_t *ctrl;
 
if( !parent )
return NULL;
 
btn = (button_t*)malloc(sizeof(button_t));
ctrl = (ctrl_t*)malloc(size);
 
link_initialize(&btn->link);
list_initialize(&btn->child);
link_initialize(&ctrl->link);
list_initialize(&ctrl->child);
 
btn->handler = button_proc;
btn->parent = parent;
ctrl->parent = parent;
 
btn->ctx = parent->ctx;
btn->id = id;
btn->style = 0;
ctrl->ctx = parent->ctx;
ctrl->id = id;
 
btn->rc.l = x;
btn->rc.t = y ;
ctrl->rc.l = x;
ctrl->rc.t = y ;
 
btn->rc.r = x + w;
btn->rc.b = y + h;
ctrl->rc.r = x + w;
ctrl->rc.b = y + h;
 
btn->w = w;
btn->h = h;
ctrl->w = w;
ctrl->h = h;
 
list_append(&ctrl->link, &parent->child);
 
return ctrl;
};
 
 
button_t *create_button(char *caption, int id, int x, int y,
int w, int h, ctrl_t *parent)
{
button_t *btn;
int len;
 
if( !parent )
return NULL;
 
btn = (button_t*)create_control(sizeof(button_t), id, x, y, w, h, parent);
btn->ctrl.handler = button_proc;
btn->state = 0;
 
btn->caption = caption;
 
if( !caption )
62,8 → 81,6
btn->img_hilite = NULL;
btn->img_pressed = NULL;
 
list_append(&btn->link, &parent->child);
 
return btn;
};
 
108,10 → 125,10
int i, j;
int x, y;
 
ctx = btn->ctx;
ctx = btn->ctrl.ctx;
 
x = btn->rc.l - ctx->offset_x;
y = btn->rc.t - ctx->offset_y;
x = btn->ctrl.rc.l - ctx->offset_x;
y = btn->ctrl.rc.t - ctx->offset_y;
 
pixmap = ctx->pixmap;
 
124,12 → 141,12
else if(btn->state & bHighlight)
src = btn->img_hilite;
 
for(i=0; i < btn->h ;i++)
for(i=0; i < btn->ctrl.h ;i++)
{
for(j=0; j<btn->w; j++)
for(j = 0; j < btn->ctrl.w; j++)
pixmap[j] = src[j];
pixmap+= ctx->stride/4;
src+=btn->w;
src+= btn->ctrl.w;
};
 
return 0;
163,7 → 180,7
case MSG_MOUSEENTER:
// printf("mouse enter\n");
btn->state|= bHighlight;
send_message(btn, MSG_PAINT, 0, 0);
send_message(&btn->ctrl, MSG_PAINT, 0, 0);
break;
 
case MSG_MOUSELEAVE:
170,7 → 187,7
// printf("mouse leave\n");
if( (ctrl_t*)btn != mouse_capture) {
btn->state &= ~bHighlight;
send_message(btn, MSG_PAINT, 0, 0);
send_message(&btn->ctrl, MSG_PAINT, 0, 0);
};
break;
 
179,7 → 196,7
// printf("push button\n");
capture_mouse((ctrl_t*)btn);
btn->state|= bPressed;
send_message(btn, MSG_PAINT, 0, 0);
send_message(&btn->ctrl, MSG_PAINT, 0, 0);
break;
 
case MSG_LBTNUP:
193,16 → 210,16
x = ((pos_t)arg2).x;
y = ((pos_t)arg2).y;
 
if( pt_in_rect( &btn->rc, x, y) )
if( pt_in_rect( &btn->ctrl.rc, x, y) )
state = bHighlight;
else
state = 0;
 
if(action)
send_message(btn->parent,MSG_COMMAND,btn->id,(int)btn);
send_message(btn->ctrl.parent,MSG_COMMAND,btn->ctrl.id,(int)btn);
 
btn->state = state;
send_message(btn, MSG_PAINT, 0, 0);
send_message(&btn->ctrl, MSG_PAINT, 0, 0);
break;
 
case MSG_MOUSEMOVE:
216,7 → 233,7
if( ! (btn->state & bHighlight))
{
btn->state|= bHighlight;
send_message(btn, MSG_PAINT, 0, 0);
send_message(&btn->ctrl, MSG_PAINT, 0, 0);
};
 
if( (ctrl_t*)btn != mouse_capture)
227,26 → 244,26
 
old_state = btn->state;
 
if( pt_in_rect(&btn->rc, x, y) )
if( pt_in_rect(&btn->ctrl.rc, x, y) )
btn->state |= bPressed;
else
btn->state &= ~bPressed;
 
if( old_state ^ btn->state)
send_message(btn, MSG_PAINT, 0, 0);
send_message(&btn->ctrl, MSG_PAINT, 0, 0);
}
return 0;
};
 
 
int draw_progress(progress_t *prg)
int draw_progress(progress_t *prg, int background)
{
int *pixmap, src;
int *pixmap, *src;
ctx_t *ctx;
int i, j;
int x, y;
 
int len;
int len = prg->ctrl.w;
 
ctx = prg->ctrl.ctx;
 
253,19 → 270,37
x = prg->ctrl.rc.l - ctx->offset_x;
y = prg->ctrl.rc.t - ctx->offset_y;
 
if( background )
{
src = res_progress_bar;
 
pixmap = ctx->pixmap;
pixmap+= y * ctx->stride/4 + x;
 
for(i=0; i < 10; i++)
{
for(j = 0; j < len; j++)
pixmap[j] = *src;
 
pixmap+= ctx->stride/4;
src++;
};
};
 
 
len = prg->current*prg->ctrl.w/(prg->max - prg->min);
 
src = res_prg_level;
 
pixmap = ctx->pixmap;
 
pixmap+= y*ctx->stride/4 + x;
 
src = 0x32ebfb; //btn->img_default;
 
for(i=0; i < prg->ctrl.h ;i++)
{
for(j=0; j < len; j++)
pixmap[j] = src;
pixmap[j] = *src;
pixmap+= ctx->stride/4;
src++;
};
 
return 0;
280,7 → 315,7
switch( msg )
{
case MSG_PAINT:
draw_progress(prg);
draw_progress(prg, 1);
update_rect(ctrl);
break;
289,6 → 324,11
send_message(ctrl->parent,MSG_COMMAND,ctrl->id,(int)ctrl);
break;
case PRG_PROGRESS:
draw_progress(prg, 0);
update_rect(ctrl);
break;
 
default:
break;
}
305,33 → 345,273
if( !parent )
return NULL;
 
prg = (progress_t*)malloc(sizeof(progress_t));
prg = (progress_t*)create_control(sizeof(progress_t), id, x, y, w, h, parent);
 
link_initialize(&prg->ctrl.link);
list_initialize(&prg->ctrl.child);
 
prg->ctrl.handler = prg_proc;
prg->ctrl.parent = parent;
 
prg->ctrl.ctx = parent->ctx;
prg->ctrl.id = id;
prg->ctrl.rc.l = x;
prg->ctrl.rc.t = y ;
 
prg->ctrl.rc.r = x + w;
prg->ctrl.rc.b = y + h;
 
prg->ctrl.w = w;
prg->ctrl.h = h;
 
prg->min = 0;
prg->max = 1;
prg->current = 0;
prg->pos = 0;
 
list_append(&prg->ctrl.link, &parent->child);
 
return prg;
};
 
int draw_level(level_t *lvl)
{
int *pixmap, *src;
ctx_t *ctx;
int i, j;
int x, y;
 
int len;
double level;
 
ctx = lvl->ctrl.ctx;
 
x = lvl->ctrl.rc.l - ctx->offset_x;
y = lvl->ctrl.rc.t - ctx->offset_y;
 
level = (log2(lvl->current+1)-7)*12 + lvl->vol/50 ;
 
len = level;
 
if(len < 0)
len = 0;
if(len > 96)
len = 96;
 
pixmap = ctx->pixmap;
 
pixmap+= y*ctx->stride/4 + x;
 
// for(i=0; i < prg->ctrl.h ;i++)
// {
// for(j=0; j < len; j++)
// pixmap[j] = src;
// pixmap+= ctx->stride/4;
// };
 
src = lvl->img_level;
 
for(i=0; i < 10; i++)
{
for(j = 0; j < 96; j++)
pixmap[j] = 0xFF1C1C1C;
pixmap+= ctx->stride/4;
};
 
pixmap = ctx->pixmap;
pixmap+= y*ctx->stride/4 + x;
 
for(i=0; i < 10; i++)
{
for(j = 0; j < len; j++)
pixmap[j] = src[j];
pixmap+= ctx->stride/4;
src+= 96;
};
 
return 0;
};
 
 
int lvl_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2)
{
level_t *lvl = (level_t*)ctrl;
// int pos;
 
switch( msg )
{
case MSG_PAINT:
if(lvl->visible)
{
draw_level(lvl);
update_rect(ctrl);
};
break;
 
// case MSG_LBTNDOWN:
// prg->pos = ((pos_t)arg2).x - ctrl->rc.l;
// send_message(ctrl->parent,MSG_COMMAND,ctrl->id,(int)ctrl);
// break;
 
default:
break;
}
return 0;
};
 
level_t *create_level(char *caption, int id, int x, int y,
int w, int h, ctrl_t *parent)
{
level_t *lvl;
 
if( !parent )
return NULL;
 
lvl = (level_t*)create_control(sizeof(level_t), id, x, y, w, h, parent);
lvl->ctrl.handler = lvl_proc;
 
lvl->min = 0;
lvl->max = 1;
lvl->current = 0;
lvl->pos = 0;
lvl->visible = 0;
lvl->img_level = res_level;
 
return lvl;
};
 
 
int draw_slider(slider_t *sld)
{
int *pixmap, *src;
ctx_t *ctx;
int i, j;
int x, y;
 
int32_t len;
double level;
 
ctx = sld->ctrl.ctx;
 
x = sld->ctrl.rc.l - ctx->offset_x;
y = sld->ctrl.rc.t - ctx->offset_y;
 
 
len = 96 + 12;
 
pixmap = ctx->pixmap;
pixmap+= y*ctx->stride/4 + x;
 
for(i=0; i < 11; i++)
{
for(j = 0; j < len; j++)
pixmap[j] = 0xFF1C1C1C;
pixmap+= ctx->stride/4;
};
 
pixmap = ctx->pixmap;
pixmap+= (y+4)*ctx->stride/4 + x + 6;
 
src = sld->img_vol_slider;
 
for(i = 0; i < 4; i++)
{
for(j = 0; j < 96; j++)
pixmap[j] = src[j];
pixmap+= ctx->stride/4;
src+= 96;
};
 
pixmap = ctx->pixmap;
pixmap+= y*ctx->stride/4 + x + sld->pos;
 
src = res_slider;
 
for(i = 0; i < 11; i++)
{
for(j = 0; j < 12; j++)
pixmap[j] = src[j];
pixmap+= ctx->stride/4;
src+= 12;
};
 
return 0;
};
 
 
int sld_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2)
{
slider_t *sld = (slider_t*)ctrl;
int pos;
 
switch( msg )
{
case MSG_PAINT:
draw_slider(sld);
update_rect(ctrl);
break;
 
case MSG_LBTNDOWN:
capture_mouse(ctrl);
sld->mode = 1;
 
pos = ((pos_t)arg2).x - ctrl->rc.l - 6;
if( pos < 0 )
pos = 0;
else if(pos > 96)
pos = 96;
if( sld->pos != pos)
{
sld->pos = pos;
send_message(ctrl->parent,MSG_COMMAND,ctrl->id,(int)ctrl);
};
break;
 
case MSG_LBTNUP:
if(sld->mode)
{
release_mouse();
sld->mode = 0;
};
break;
 
case MSG_MOUSEMOVE:
if(sld->mode)
{
pos = ((pos_t)arg2).x - ctrl->rc.l - 6;
if( pos < 0 )
pos = 0;
else if(pos > 96)
pos = 96;
if( sld->pos != pos)
{
sld->pos = pos;
// printf("slider pos %d\n", sld->pos);
send_message(ctrl->parent,MSG_COMMAND,ctrl->id,(int)ctrl);
}
};
break;
 
case MSG_MOUSEENTER:
panel_set_layout(ctrl->parent, 1);
// printf("level on\n");
break;
 
case MSG_MOUSELEAVE:
panel_set_layout(ctrl->parent, 0);
// printf("level off\n");
break;
 
 
default:
break;
}
return 0;
};
 
 
slider_t *create_slider(char *caption, int id, int x, int y,
int w, int h, ctrl_t *parent)
{
 
slider_t *sld;
 
if( !parent )
return NULL;
 
sld = (slider_t*)create_control(sizeof(slider_t), id, x, y, w, h, parent);
sld->ctrl.handler = sld_proc;
 
sld->min = -5000;
sld->max = 0;
sld->current = 0;
sld->pos = 60;
sld->mode = 0;
sld->img_vol_slider = res_vol_slider;
 
return sld;
};
 
/programs/media/Fplay/winlib/caption.c
5,7 → 5,6
#include <stdio.h>
#include "winlib.h"
 
#define CAPTION_HEIGHT 24
#define CAPTION_CORNER_W 8
 
extern int res_caption_left[];
20,6 → 19,8
extern int res_minimize_btn_hl[];
extern int res_minimize_btn_pressed[];
 
extern uint32_t main_cursor;
 
void update_caption_size(window_t *win);
 
int caption_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2);
38,6 → 39,8
cpt->ctrl.handler = caption_proc;
cpt->ctrl.parent = (ctrl_t*)win;
 
cpt->text = win->caption_txt;
 
ctx->pixmap = user_alloc(1920*CAPTION_HEIGHT*4);
if(!ctx->pixmap)
{
102,17 → 105,27
cpt->ctrl.h = CAPTION_HEIGHT;
win->client.t = CAPTION_HEIGHT;
 
cpt->close_btn->rc.l = win->w - 25;
cpt->close_btn->rc.r = cpt->close_btn->rc.l +
cpt->close_btn->w;
cpt->close_btn->ctrl.rc.l = win->w - 25;
cpt->close_btn->ctrl.rc.r = cpt->close_btn->ctrl.rc.l +
cpt->close_btn->ctrl.w;
 
cpt->minimize_btn->rc.l = win->w - 25 - 16 - 5;
cpt->minimize_btn->rc.r = cpt->minimize_btn->rc.l +
cpt->minimize_btn->w;
cpt->minimize_btn->ctrl.rc.l = win->w - 25 - 16 - 5;
cpt->minimize_btn->ctrl.rc.r = cpt->minimize_btn->ctrl.rc.l +
cpt->minimize_btn->ctrl.w;
 
};
 
typedef struct
{
uint32_t width;
uint32_t height;
uint32_t pitch;
uint32_t handle;
uint8_t *data;
}bitmap_t;
 
extern int win_font;
 
void draw_caption(caption_t *cpt)
{
int *pixmap, *src;
157,6 → 170,13
src+= CAPTION_CORNER_W;
};
 
bitmap_t bitmap;
 
bitmap.data = cpt->ctx.pixmap;
bitmap.pitch = cpt->ctx.stride;
 
draw_text(&bitmap, win_font, cpt->text, 8, 18, 0xFFFFFFFF);
 
ctrl_t *child;
child = (ctrl_t*)cpt->ctrl.child.next;
 
193,18 → 213,19
send_message(child, msg, 0, arg2);
else
send_message(win->child_over, MSG_MOUSELEAVE, 0, arg2);
}
else if( child )
send_message(child, MSG_MOUSEENTER, 0, arg2);
};
 
win->child_over = child;
if( child )
{
send_message(child, MSG_MOUSEENTER, 0, arg2);
send_message(child,msg,0,arg2);
// else if(main_cursor != 0)
// {
// set_cursor(0);
// main_cursor = 0;
// }
}
else if(main_cursor != 0)
{
set_cursor(0);
main_cursor = 0;
}
break;
 
 
/programs/media/Fplay/winlib/caption_body.raw
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/media/Fplay/winlib/caption_left.raw
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/media/Fplay/winlib/caption_right.raw
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/media/Fplay/winlib/close_button.raw
0,0 → 1,0
okhÿokhÿokhÿokhÿnifÿlgdÿjebÿhc_ÿhb_ÿhc_ÿjebÿlgdÿnifÿokhÿokhÿokhÿokhÿlhdÿlhdÿlhdÿidaÿfa]ÿd_[ÿd_[ÿd_[ÿd_[ÿd_[ÿd_[ÿd_[ÿfa]ÿidaÿlhdÿlhdÿlhdÿhdaÿhdaÿe`\ÿa[Wÿa[Wÿa[Wÿa[Wÿa[Wÿa[Wÿa[Wÿa[Wÿa[Wÿa[Wÿa[Wÿe`\ÿhdaÿhdaÿe`]ÿb]Yÿ]WSÿ]WSÿ]WSÿ]WSÿ]WSÿ]WSÿ]WSÿ]WSÿ]WSÿ]WSÿ]WSÿ]WSÿ]WSÿb]Yÿe`]ÿ`[Xÿ[UQÿZTPÿZTPÿª¨¥ÿª¨¥ÿZTPÿZTPÿZTPÿZTPÿZTPÿª¨¥ÿª¨¥ÿZTPÿZTPÿ[UQÿ`[Xÿ[VRÿVPLÿVPLÿVPLÿª¨¥ÿª¨¥ÿª¨¥ÿVPLÿVPLÿVPLÿª¨¥ÿª¨¥ÿª¨¥ÿVPLÿVPLÿVPLÿ[VRÿUOLÿRLHÿRLHÿRLHÿRLHÿª¨¥ÿª¨¥ÿª¨¥ÿRLHÿª¨¥ÿª¨¥ÿª¨¥ÿRLHÿRLHÿRLHÿRLHÿUOLÿPJFÿOIEÿOIEÿOIEÿOIEÿOIEÿª¨¥ÿª¨¥ÿª¨¥ÿª¨¥ÿª¨¥ÿOIEÿOIEÿOIEÿOIEÿOIEÿPJFÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿžœ™ÿžœ™ÿžœ™ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ81,ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿžœ™ÿžœ™ÿžœ™ÿžœ™ÿžœ™ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ81,ÿ:3/ÿ70+ÿ70+ÿ70+ÿ70+ÿžœ™ÿžœ™ÿžœ™ÿ70+ÿžœ™ÿžœ™ÿžœ™ÿ70+ÿ70+ÿ70+ÿ70+ÿ:3/ÿ=62ÿ70+ÿ70+ÿ70+ÿžœ™ÿžœ™ÿžœ™ÿ70+ÿ70+ÿ70+ÿžœ™ÿžœ™ÿžœ™ÿ70+ÿ70+ÿ70+ÿ=62ÿ?95ÿ92-ÿ70+ÿ70+ÿžœ™ÿžœ™ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿžœ™ÿžœ™ÿ70+ÿ70+ÿ92-ÿ?95ÿA;7ÿ=72ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ=72ÿA;7ÿA;7ÿA;7ÿ<61ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ<61ÿA;7ÿA;7ÿA;7ÿA;7ÿA;7ÿ=72ÿ92-ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ92-ÿ=72ÿA;7ÿA;7ÿA;7ÿA;7ÿA;7ÿA;7ÿA;7ÿ?95ÿ=62ÿ:3/ÿ81,ÿ70+ÿ81,ÿ:3/ÿ=62ÿ?95ÿA;7ÿA;7ÿA;7ÿA;7ÿ
/programs/media/Fplay/winlib/close_button_pressed.raw
0,0 → 1,0
okhÿokhÿokhÿokhÿnifÿlgdÿjebÿhc_ÿhb_ÿhc_ÿjebÿlgdÿnifÿokhÿokhÿokhÿokhÿlhdÿlhdÿlhdÿidaÿfa]ÿd_[ÿd_[ÿd_[ÿd_[ÿd_[ÿd_[ÿd_[ÿfa]ÿidaÿlhdÿlhdÿlhdÿhdaÿhdaÿe`\ÿa[Wÿa[Wÿa[Wÿa[Wÿa[Wÿa[Wÿa[Wÿa[Wÿa[Wÿa[Wÿa[Wÿe`\ÿhdaÿhdaÿe`]ÿb]Yÿ]WSÿ]WSÿ]WSÿ]WSÿ]WSÿ]WSÿ]WSÿ]WSÿ]WSÿ]WSÿ]WSÿ]WSÿ]WSÿb]Yÿe`]ÿ`[Xÿ[UQÿZTPÿZTPÿZTPÿZTPÿZTPÿZTPÿZTPÿZTPÿZTPÿZTPÿZTPÿZTPÿZTPÿ[UQÿ`[Xÿ[VRÿVPLÿVPLÿVPLÿVPLÿ­¬©ÿ’ŒÿXSOÿVPLÿXSOÿ’Œÿ­¬©ÿVPLÿVPLÿVPLÿVPLÿ[VRÿUOLÿRLHÿRLHÿRLHÿRLHÿŠÿ«ª§ÿ”‘ŽÿWQLÿ”‘Žÿ«ª§ÿŠÿRLHÿRLHÿRLHÿRLHÿUOLÿPJFÿOIEÿOIEÿOIEÿOIEÿUNJÿŽŠÿª¨¥ÿ›˜–ÿª¨¥ÿŽŠÿUNJÿOIEÿOIEÿOIEÿOIEÿPJFÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ?83ÿŒ‰†ÿžœ™ÿŒ‰†ÿ?83ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ81,ÿ70+ÿ70+ÿ70+ÿ70+ÿ=61ÿ~zÿžœ™ÿŠ‡ÿžœ™ÿ~zÿ=61ÿ70+ÿ70+ÿ70+ÿ70+ÿ81,ÿ:3/ÿ70+ÿ70+ÿ70+ÿ70+ÿ~{wÿžœ™ÿƒ€|ÿ<50ÿƒ€|ÿžœ™ÿ~{wÿ70+ÿ70+ÿ70+ÿ70+ÿ:3/ÿ=62ÿ70+ÿ70+ÿ70+ÿ70+ÿžœ™ÿ~{wÿ93.ÿ70+ÿ93.ÿ~{wÿžœ™ÿ70+ÿ70+ÿ70+ÿ70+ÿ=62ÿ?95ÿ92-ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ92-ÿ?95ÿA;7ÿ=72ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ=72ÿA;7ÿA;7ÿA;7ÿ<61ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ<61ÿA;7ÿA;7ÿA;7ÿA;7ÿA;7ÿ=72ÿ92-ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ92-ÿ=72ÿA;7ÿA;7ÿA;7ÿA;7ÿA;7ÿA;7ÿA;7ÿ?95ÿ=62ÿ:3/ÿ81,ÿ70+ÿ81,ÿ:3/ÿ=62ÿ?95ÿA;7ÿA;7ÿA;7ÿA;7ÿ
/programs/media/Fplay/winlib/control.h
54,20 → 54,8
 
typedef struct
{
link_t link;
link_t child;
ctrl_t ctrl;
 
handler_t *handler;
ctrl_t *parent;
 
ctx_t *ctx;
uint32_t id;
uint32_t style;
 
rect_t rc;
int w;
int h;
 
uint32_t state;
ostimer_t timer;
 
90,6 → 78,30
 
typedef struct
{
ctrl_t ctrl;
int min;
int max;
int current;
int pos;
int vol;
int visible;
void *img_level;
}level_t;
 
typedef struct
{
ctrl_t ctrl;
int min;
int max;
int current;
int pos;
int mode;
void *img_slider;
void *img_vol_slider;
}slider_t;
 
typedef struct
{
link_t link;
link_t child;
 
148,11 → 160,12
#define MSG_COMMAND 0x030
#define MSG_TIMER 0x031
 
 
#define LBN_DBLCLK 0x100
#define LBOX_READDIR 0x100
#define LBOX_GETFILENAME 0x101
 
#define PRG_PROGRESS 0x102
 
#define ID_CLOSE 1
#define ID_MINIMIZE 2
 
/programs/media/Fplay/winlib/cptleft.raw
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/programs/media/Fplay/winlib/cptright.raw
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/programs/media/Fplay/winlib/fontlib.c
0,0 → 1,150
 
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <memory.h>
#include "font_droid.h"
#include <ft2build.h>
#include FT_FREETYPE_H
 
typedef unsigned int color_t;
 
typedef struct
{
uint32_t width;
uint32_t height;
uint32_t pitch;
uint32_t handle;
uint8_t *data;
}bitmap_t;
 
 
void my_draw_bitmap(bitmap_t *win, FT_Bitmap *bitmap, int dstx, int dsty, int col)
{
uint8_t *dst;
uint8_t *src, *tmpsrc;
 
uint32_t *tmpdst;
int i, j;
 
dst = win->data + dsty * win->pitch + dstx*4;
src = bitmap->buffer;
 
for( i = 0; i < bitmap->rows; i++ )
{
tmpdst = (uint32_t*)dst;
tmpsrc = src;
 
dst+= win->pitch;
src+= bitmap->pitch;
 
for( j = 0; j < bitmap->width; j++)
{
int a = *tmpsrc++;
int sr, sg, sb;
int dr, dg, db;
 
if( a != 0) a++;
 
db = *tmpdst & 0xFF;
dg = (*tmpdst >> 8) & 0xFF;
dr = (*tmpdst >> 16) &0xFF;
 
sb = col & 0xFF;
sg = (col >> 8) & 0xFF;
sr = (col >> 16) &0xFF;
 
db = (a*sb + db*(256-a))/256;
dg = (a*sg + dg*(256-a))/256;
dr = (a*sr + dr*(256-a))/256;
 
*tmpdst++ = 0xFF000000|(dr<<16)|(dg<<8)|db;
};
}
};
 
 
int draw_text(bitmap_t * winbitmap, FT_Face face, char *text, int x, int y, int color)
{
FT_UInt glyph_index;
FT_Bool use_kerning = 0;
FT_UInt previous;
 
char ch;
int err = 0;
 
use_kerning = FT_HAS_KERNING( face );
previous = 0;
 
x <<= 6;
 
while( ch = *text++ )
{
glyph_index = FT_Get_Char_Index( face, ch );
 
if ( use_kerning && previous && glyph_index )
{
FT_Vector delta;
FT_Get_Kerning( face, previous, glyph_index, FT_KERNING_DEFAULT, &delta );
x += delta.x ;
}
 
err = FT_Load_Glyph( face, glyph_index, FT_LOAD_DEFAULT );
if ( err )
continue;
 
err = FT_Render_Glyph( face->glyph, FT_RENDER_MODE_NORMAL );
if ( err )
continue;
 
my_draw_bitmap(winbitmap, &face->glyph->bitmap, (x >> 6) + face->glyph->bitmap_left,
y - face->glyph->bitmap_top, color);
 
x += face->glyph->advance.x;
previous = glyph_index;
};
 
return err;
};
 
int init_fontlib()
{
int err;
 
static FT_Library library;
FT_Face face = NULL;
 
err = FT_Init_FreeType( &library );
if ( err )
{
printf("an error occurred during FreeType initialization\n");
goto done;
}
 
err = FT_New_Face( library, "/hd0/1/istokweb.ttf", 0, &face );
 
// err = FT_New_Memory_Face( library, pdf_font_DroidSans, 139280, 0, &face );
if ( err == FT_Err_Unknown_File_Format )
{
printf("font format is unsupported\n");
goto done;
 
}
else if ( err )
{
printf("font file could not be read or broken\n");
goto done;
 
}
 
err = FT_Set_Char_Size( face, 0, 12*64, 96, 96 );
// err = FT_Set_Pixel_Sizes( face, 0, 100 );
 
done:
 
return (int)face;
};
 
// draw_text(face,"/hd0/1/demo", 10, 80, 0x00000000);
 
/programs/media/Fplay/winlib/frame.c
5,7 → 5,6
#include <stdio.h>
#include "winlib.h"
 
#define CAPTION_HEIGHT 29
#define CAPTION_CORNER_W 8
#define FRAME_WIDTH 7
 
271,8 → 270,8
w = nrc.r - nrc.l;
h = nrc.b - nrc.t;
 
if(w < 150)
w = 150;
if(w <310)
w = 310;
if(h < 120)
h = 120;
 
/programs/media/Fplay/winlib/minimize_btn.raw
0,0 → 1,0
okhÿokhÿokhÿokhÿnifÿlgdÿjebÿhc_ÿhb_ÿhc_ÿjebÿlgdÿnifÿokhÿokhÿokhÿokhÿlhdÿlhdÿlhdÿidaÿfa]ÿd_[ÿd_[ÿd_[ÿd_[ÿd_[ÿd_[ÿd_[ÿfa]ÿidaÿlhdÿlhdÿlhdÿhdaÿhdaÿe`\ÿa[Wÿa[Wÿa[Wÿa[Wÿa[Wÿa[Wÿa[Wÿa[Wÿa[Wÿa[Wÿa[Wÿe`\ÿhdaÿhdaÿe`]ÿb]Yÿ]WSÿ]WSÿ]WSÿ]WSÿ]WSÿ]WSÿ]WSÿ]WSÿ]WSÿ]WSÿ]WSÿ]WSÿ]WSÿb]Yÿe`]ÿ`[Xÿ[UQÿZTPÿZTPÿZTPÿZTPÿZTPÿZTPÿZTPÿZTPÿZTPÿZTPÿZTPÿZTPÿZTPÿ[UQÿ`[Xÿ[VRÿVPLÿVPLÿVPLÿVPLÿVPLÿVPLÿVPLÿVPLÿVPLÿVPLÿVPLÿVPLÿVPLÿVPLÿVPLÿ[VRÿUOLÿRLHÿRLHÿRLHÿRLHÿRLHÿRLHÿRLHÿRLHÿRLHÿRLHÿRLHÿRLHÿRLHÿRLHÿRLHÿUOLÿPJFÿOIEÿOIEÿOIEÿOIEÿOIEÿOIEÿOIEÿOIEÿOIEÿOIEÿOIEÿOIEÿOIEÿOIEÿOIEÿPJFÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ81,ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ81,ÿ:3/ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ:3/ÿ=62ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ=62ÿ?95ÿ92-ÿ70+ÿ70+ÿžœ™ÿžœ™ÿžœ™ÿžœ™ÿžœ™ÿžœ™ÿžœ™ÿžœ™ÿžœ™ÿ70+ÿ70+ÿ92-ÿ?95ÿA;7ÿ=72ÿ70+ÿ70+ÿžœ™ÿžœ™ÿžœ™ÿžœ™ÿžœ™ÿžœ™ÿžœ™ÿžœ™ÿžœ™ÿ70+ÿ70+ÿ=72ÿA;7ÿA;7ÿA;7ÿ<61ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ<61ÿA;7ÿA;7ÿA;7ÿA;7ÿA;7ÿ=72ÿ92-ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ92-ÿ=72ÿA;7ÿA;7ÿA;7ÿA;7ÿA;7ÿA;7ÿA;7ÿ?95ÿ=62ÿ:3/ÿ81,ÿ70+ÿ81,ÿ:3/ÿ=62ÿ?95ÿA;7ÿA;7ÿA;7ÿA;7ÿ
/programs/media/Fplay/winlib/minimize_btn_pressed.raw
0,0 → 1,0
okhÿokhÿokhÿokhÿnifÿlgdÿjebÿhc_ÿhb_ÿhc_ÿjebÿlgdÿnifÿokhÿokhÿokhÿokhÿlhdÿlhdÿlhdÿidaÿfa]ÿd_[ÿd_[ÿd_[ÿd_[ÿd_[ÿd_[ÿd_[ÿfa]ÿidaÿlhdÿlhdÿlhdÿhdaÿhdaÿe`\ÿa[Wÿa[Wÿa[Wÿa[Wÿa[Wÿa[Wÿa[Wÿa[Wÿa[Wÿa[Wÿa[Wÿe`\ÿhdaÿhdaÿe`]ÿb]Yÿ]WSÿ]WSÿ]WSÿ]WSÿ]WSÿ]WSÿ]WSÿ]WSÿ]WSÿ]WSÿ]WSÿ]WSÿ]WSÿb]Yÿe`]ÿ`[Xÿ[UQÿZTPÿZTPÿZTPÿZTPÿZTPÿZTPÿZTPÿZTPÿZTPÿZTPÿZTPÿZTPÿZTPÿ[UQÿ`[Xÿ[VRÿVPLÿVPLÿVPLÿVPLÿVPLÿVPLÿVPLÿVPLÿVPLÿVPLÿVPLÿVPLÿVPLÿVPLÿVPLÿ[VRÿUOLÿRLHÿRLHÿRLHÿRLHÿRLHÿRLHÿRLHÿRLHÿRLHÿRLHÿRLHÿRLHÿRLHÿRLHÿRLHÿUOLÿPJFÿOIEÿOIEÿOIEÿOIEÿOIEÿOIEÿOIEÿOIEÿOIEÿOIEÿOIEÿOIEÿOIEÿOIEÿOIEÿPJFÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ81,ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ81,ÿ:3/ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ:3/ÿ=62ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ=62ÿ?95ÿ92-ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ92-ÿ?95ÿA;7ÿ=72ÿ70+ÿ70+ÿ70+ÿš˜•ÿš˜•ÿš˜•ÿš˜•ÿš˜•ÿš˜•ÿš˜•ÿ70+ÿ70+ÿ70+ÿ=72ÿA;7ÿA;7ÿA;7ÿ<61ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ<61ÿA;7ÿA;7ÿA;7ÿA;7ÿA;7ÿ=72ÿ92-ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ70+ÿ92-ÿ=72ÿA;7ÿA;7ÿA;7ÿA;7ÿA;7ÿA;7ÿA;7ÿ?95ÿ=62ÿ:3/ÿ81,ÿ70+ÿ81,ÿ:3/ÿ=62ÿ?95ÿA;7ÿA;7ÿA;7ÿA;7ÿ
/programs/media/Fplay/winlib/panel.c
4,11 → 4,14
#include <stdio.h>
#include "winlib.h"
 
#define PANEL_HEIGHT 55
#define PANEL_CORNER_W 16
#define PANEL_CORNER_W 8
#define FRAME_WIDTH 7
 
#define ID_PLAY 100
#define ID_STOP 101
#define ID_PROGRESS 102
#define ID_VOL_LEVEL 103
#define ID_VOL_CTRL 104
 
extern uint32_t main_cursor;
 
22,6 → 25,9
extern int res_pause_btn[];
extern int res_pause_btn_pressed[];
 
extern int res_stop_btn[];
extern int res_stop_btn_pressed[];
 
//extern int res_minimize_btn[];
//extern int res_minimize_btn_hl[];
//extern int res_minimize_btn_pressed[];
34,6 → 40,8
{
button_t *btn;
progress_t *prg;
level_t *lvl;
slider_t *sld;
 
panel_t *panel = &win->panel;
ctx_t *ctx = &panel->ctx;
44,6 → 52,8
panel->ctrl.handler = panel_proc;
panel->ctrl.parent = (ctrl_t*)win;
 
panel->layout = 0;
 
ctx->pixmap = user_alloc(1920*PANEL_HEIGHT*4);
if(!ctx->pixmap)
{
63,9 → 73,23
btn->img_hilite = res_pause_btn;
btn->img_pressed = res_pause_btn_pressed;
 
prg = create_progress(NULL,101,0,4,0,8,&panel->ctrl);
btn = create_button(NULL, ID_STOP,0,19,24,24,&panel->ctrl);
panel->stop_btn = btn;
 
btn->img_default = res_stop_btn;
btn->img_hilite = res_stop_btn;
btn->img_pressed = res_stop_btn_pressed;
 
prg = create_progress(NULL,ID_PROGRESS,0,4,0,10,&panel->ctrl);
panel->prg = prg;
 
lvl = create_level(NULL, ID_VOL_LEVEL, 0, 20, 96, 10, &panel->ctrl);
lvl->vol = -1875;
panel->lvl = lvl;
 
sld = create_slider(NULL, ID_VOL_CTRL, 0, 20, 96+12, 12, &panel->ctrl);
panel->sld = sld;
 
// btn = create_button(NULL, ID_MINIMIZE,0,5,16,18,(ctrl_t*)cpt);
// cpt->minimize_btn = btn;
 
73,11 → 97,60
// btn->img_hilite = res_minimize_btn_hl;
// btn->img_pressed = res_minimize_btn_pressed;
 
 
 
update_panel_size(win);
 
return 1;
};
 
 
static void panel_update_layout(panel_t *panel)
{
progress_t *prg = panel->prg;
level_t *lvl = panel->lvl;
 
if(panel->layout == 0)
{
prg->ctrl.rc.l = panel->ctrl.rc.l;
prg->ctrl.rc.t = panel->ctrl.rc.t+7;
prg->ctrl.rc.r = panel->ctrl.rc.r;
prg->ctrl.rc.b = prg->ctrl.rc.t + prg->ctrl.h;
prg->ctrl.w = prg->ctrl.rc.r - prg->ctrl.rc.l;
 
lvl->ctrl.rc.l = panel->ctrl.rc.l;
lvl->ctrl.rc.t = panel->ctrl.rc.t+7;
lvl->ctrl.rc.r = panel->lvl->ctrl.rc.l + panel->lvl->ctrl.w;
lvl->ctrl.rc.b = panel->lvl->ctrl.rc.t + panel->lvl->ctrl.h;
}
else
{
lvl->ctrl.rc.l = panel->ctrl.rc.l;
lvl->ctrl.rc.t = panel->ctrl.rc.t+7;
lvl->ctrl.rc.r = lvl->ctrl.rc.l + lvl->ctrl.w;
lvl->ctrl.rc.b = lvl->ctrl.rc.t + lvl->ctrl.h;
 
prg->ctrl.rc.l = lvl->ctrl.rc.r;
prg->ctrl.rc.t = panel->ctrl.rc.t+7;
prg->ctrl.rc.r = panel->ctrl.rc.r;
prg->ctrl.rc.b = prg->ctrl.rc.t + prg->ctrl.h;
prg->ctrl.w = prg->ctrl.rc.r - prg->ctrl.rc.l;
};
};
 
void panel_set_layout(panel_t *panel, int layout)
{
panel->layout = layout;
panel->lvl->visible = layout;
 
panel_update_layout(panel);
 
send_message(&panel->prg->ctrl, MSG_PAINT, 0, 0);
 
if(layout)
send_message(&panel->lvl->ctrl, MSG_PAINT, 0, 0);
};
 
void update_panel_size(window_t *win)
{
panel_t *panel = &win->panel;
115,25 → 188,22
panel->ctrl.h = PANEL_HEIGHT;
win->client.b = win->h-PANEL_HEIGHT;
 
panel->play_btn->rc.l = win->w/2 - 16;
panel->play_btn->rc.t = panel->ctrl.rc.t+19;
panel->play_btn->rc.r = panel->play_btn->rc.l + panel->play_btn->w;
panel->play_btn->rc.b = panel->play_btn->rc.t + panel->play_btn->h;
panel->play_btn->ctrl.rc.l = win->w/2 - 16;
panel->play_btn->ctrl.rc.t = panel->ctrl.rc.t+19;
panel->play_btn->ctrl.rc.r = panel->play_btn->ctrl.rc.l + panel->play_btn->ctrl.w;
panel->play_btn->ctrl.rc.b = panel->play_btn->ctrl.rc.t + panel->play_btn->ctrl.h;
 
panel->prg->ctrl.rc.l = 8;
panel->prg->ctrl.rc.t = panel->ctrl.rc.t+7;
panel->prg->ctrl.rc.r = panel->ctrl.rc.r-8;
panel->prg->ctrl.rc.b = panel->prg->ctrl.rc.t+8;
panel->prg->ctrl.w = panel->prg->ctrl.rc.r -
panel->prg->ctrl.rc.l;
panel->stop_btn->ctrl.rc.l = win->w/2 - 44;
panel->stop_btn->ctrl.rc.t = panel->ctrl.rc.t+23;
panel->stop_btn->ctrl.rc.r = panel->stop_btn->ctrl.rc.l + panel->stop_btn->ctrl.w;
panel->stop_btn->ctrl.rc.b = panel->stop_btn->ctrl.rc.t + panel->stop_btn->ctrl.h;
 
panel->prg->ctrl.h = panel->prg->ctrl.rc.b -
panel->prg->ctrl.rc.t;
panel->sld->ctrl.rc.l = panel->ctrl.rc.l;
panel->sld->ctrl.rc.t = panel->ctrl.rc.t+28;
panel->sld->ctrl.rc.r = panel->sld->ctrl.rc.l + panel->sld->ctrl.w;
panel->sld->ctrl.rc.b = panel->sld->ctrl.rc.t + panel->sld->ctrl.h;
 
// cpt->minimize_btn->rc.l = win->w - 25 - 16 - 5;
// cpt->minimize_btn->rc.r = cpt->minimize_btn->rc.l +
// cpt->minimize_btn->w;
 
panel_update_layout(panel);
};
 
 
234,7 → 304,9
switch((short)arg1)
{
case ID_PLAY:
case 101:
case ID_STOP:
case ID_PROGRESS:
case ID_VOL_CTRL:
win = get_parent_window(ctrl);
send_message(win, msg, arg1, arg2);
break;
/programs/media/Fplay/winlib/panel.raw
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/programs/media/Fplay/winlib/panelleft.raw
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/programs/media/Fplay/winlib/panelright.raw
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/programs/media/Fplay/winlib/pbar.raw
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/media/Fplay/winlib/prg_level.raw
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/media/Fplay/winlib/res2.asm
25,15 → 25,27
public _res_pause_btn
public _res_pause_btn_pressed
 
public _res_stop_btn
public _res_stop_btn_pressed
 
 
public _res_cursor_ns
public _res_cursor_we
public _res_cursor_nwse
public _res_cursor_nesw
 
;public _res_logo
 
public _res_level
public _res_slider
public _res_vol_slider
 
public _res_progress_bar
public _res_prg_level
 
 
section '.rdata' data readable align 16
 
 
_res_caption_left: file 'cptleft.raw'
_res_caption_right: file 'cptright.raw'
_res_caption_body: file 'cptbody.raw'
54,7 → 66,10
_res_pause_btn: file 'pausebtn.raw'
_res_pause_btn_pressed: file 'pausebp.raw'
 
_res_stop_btn: file 'stopbtn.raw'
_res_stop_btn_pressed: file 'stopbtnp.raw'
 
 
_res_minimize_btn: file 'minbn.raw'
_res_minimize_btn_hl: file 'minbhl.raw'
_res_minimize_btn_pressed: file 'minbp.raw'
63,3 → 78,12
_res_cursor_we: file 'size_we.cur'
_res_cursor_nwse: file 'size_nwse.cur'
_res_cursor_nesw: file 'size_nesw.cur'
 
;_res_logo: file 'logo.raw'
 
_res_level: file 'vol_level.raw'
_res_vol_slider: file 'vol_slider.raw'
_res_slider: file 'slider.raw'
 
_res_progress_bar: file 'pbar.raw'
_res_prg_level: file 'prg_level.raw'
/programs/media/Fplay/winlib/slider.raw
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/media/Fplay/winlib/stopbtn.raw
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/media/Fplay/winlib/stopbtnp.raw
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/media/Fplay/winlib/vol_level.raw
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/media/Fplay/winlib/vol_slider.raw
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/media/Fplay/winlib/window.c
16,6 → 16,9
uint32_t cursor_nwse;
uint32_t cursor_nesw;
 
int win_font;
 
 
static pos_t old_pos;
 
ctrl_t *mouse_capture = NULL;
514,9 → 517,26
cursor_we = load_cursor(res_cursor_we, LOAD_FROM_MEM);
cursor_nwse = load_cursor(res_cursor_nwse, LOAD_FROM_MEM);
cursor_nesw = load_cursor(res_cursor_nesw, LOAD_FROM_MEM);
 
win_font = init_fontlib();
 
return 1;
}
 
int fini_winlib()
{
int ret;
 
ret = destroy_cursor(cursor_nesw);
ret |= destroy_cursor(cursor_nwse);
ret |= destroy_cursor(cursor_we);
ret |= destroy_cursor(cursor_ns);
 
return ret;
};
 
 
 
void init_winlib(void)
{
__asm__ __volatile__(
569,7 → 589,7
 
__asm__ __volatile__(
"int $0x40"
::"a"(73),"b"(0),"c"(&bc.dstx));
::"a"(73),"b"(0x20),"c"(&bc.dstx));
 
};
 
/programs/media/Fplay/winlib/winlib.h
3,6 → 3,9
 
#include "control.h"
 
#define CAPTION_HEIGHT 24
#define PANEL_HEIGHT 55
 
typedef struct
{
link_t link;
31,6 → 34,7
{
ctrl_t ctrl;
ctx_t ctx;
char *text;
ctrl_t *child_over;
button_t *close_btn;
button_t *minimize_btn;
43,8 → 47,12
ctx_t ctx;
rect_t draw;
ctrl_t *child_over;
int layout;
progress_t *prg;
level_t *lvl;
slider_t *sld;
button_t *play_btn;
button_t *stop_btn;
}panel_t;
 
typedef struct
111,7 → 119,8
int w, int h, ctrl_t *parent);
progress_t *create_progress(char *caption, int id, int x, int y,
int w, int h, ctrl_t *parent);
 
level_t *create_level(char *caption, int id, int x, int y,
int w, int h, ctrl_t *parent);
scroller_t *create_scroller(uint32_t style, int id, int x, int y,
int w, int h, ctrl_t *parent);