forked from KolibriOS/kolibrios
FPlay: let's type something
git-svn-id: svn://kolibrios.org@3068 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
263a9a4c7d
commit
b77955312f
@ -14,8 +14,13 @@
|
|||||||
astream_t astream;
|
astream_t astream;
|
||||||
|
|
||||||
extern uint8_t *decoder_buffer;
|
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;
|
extern volatile uint32_t driver_lock;
|
||||||
|
|
||||||
@ -46,7 +51,7 @@ int init_audio(int format)
|
|||||||
|
|
||||||
mutex_unlock(&driver_lock);
|
mutex_unlock(&driver_lock);
|
||||||
|
|
||||||
printf("sound version 0x%x\n", version);
|
// printf("sound version 0x%x\n", version);
|
||||||
|
|
||||||
if( (SOUND_VERSION>(version&0xFFFF)) ||
|
if( (SOUND_VERSION>(version&0xFFFF)) ||
|
||||||
(SOUND_VERSION<(version >> 16)))
|
(SOUND_VERSION<(version >> 16)))
|
||||||
@ -67,6 +72,11 @@ exit_whith_error:
|
|||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void set_audio_volume(int left, int right)
|
||||||
|
{
|
||||||
|
SetVolume(hBuff, left, right);
|
||||||
|
};
|
||||||
|
|
||||||
static uint64_t samples_lost;
|
static uint64_t samples_lost;
|
||||||
static double audio_delta;
|
static double audio_delta;
|
||||||
static double last_time_stamp;
|
static double last_time_stamp;
|
||||||
@ -89,7 +99,7 @@ int decode_audio(AVCodecContext *ctx, queue_t *qa)
|
|||||||
int data_size=0;
|
int data_size=0;
|
||||||
|
|
||||||
if( astream.count > AVCODEC_MAX_AUDIO_FRAME_SIZE*7)
|
if( astream.count > AVCODEC_MAX_AUDIO_FRAME_SIZE*7)
|
||||||
return 1;
|
return -1;
|
||||||
|
|
||||||
if( get_packet(qa, &pkt) == 0 )
|
if( get_packet(qa, &pkt) == 0 )
|
||||||
return 0;
|
return 0;
|
||||||
@ -111,9 +121,9 @@ int decode_audio(AVCodecContext *ctx, queue_t *qa)
|
|||||||
// {
|
// {
|
||||||
// if (pkt.pts != AV_NOPTS_VALUE)
|
// if (pkt.pts != AV_NOPTS_VALUE)
|
||||||
// audio_base = get_audio_base() * pkt.pts;
|
// audio_base = get_audio_base() * pkt.pts;
|
||||||
// printf("audio base %f\n", audio_base);
|
// printf("audio base %f\n", audio_base);
|
||||||
// };
|
// };
|
||||||
|
|
||||||
pkt_tmp.data += len;
|
pkt_tmp.data += len;
|
||||||
pkt_tmp.size -= len;
|
pkt_tmp.size -= len;
|
||||||
|
|
||||||
@ -161,8 +171,16 @@ static void sync_audio(SNDBUF hbuff, int buffsize)
|
|||||||
|
|
||||||
mutex_lock(&astream.lock);
|
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);
|
SetBuffer(hbuff, astream.buffer, offset, buffsize);
|
||||||
samples_written+= buffsize/4;
|
samples_written+= buffsize/4;
|
||||||
|
|
||||||
astream.count -= buffsize;
|
astream.count -= buffsize;
|
||||||
if(astream.count)
|
if(astream.count)
|
||||||
memcpy(astream.buffer, astream.buffer+buffsize, astream.count);
|
memcpy(astream.buffer, astream.buffer+buffsize, astream.count);
|
||||||
@ -174,7 +192,6 @@ static void sync_audio(SNDBUF hbuff, int buffsize)
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int audio_thread(void *param)
|
int audio_thread(void *param)
|
||||||
{
|
{
|
||||||
SND_EVENT evnt;
|
SND_EVENT evnt;
|
||||||
@ -192,7 +209,7 @@ int audio_thread(void *param)
|
|||||||
goto exit_whith_error;
|
goto exit_whith_error;
|
||||||
};
|
};
|
||||||
|
|
||||||
SetVolume(hBuff,-1000,-1000);
|
SetVolume(hBuff,-1875,-1875);
|
||||||
|
|
||||||
if((err = GetBufferSize(hBuff, &buffsize)) != 0)
|
if((err = GetBufferSize(hBuff, &buffsize)) != 0)
|
||||||
{
|
{
|
||||||
@ -200,139 +217,130 @@ int audio_thread(void *param)
|
|||||||
goto exit_whith_error;
|
goto exit_whith_error;
|
||||||
};
|
};
|
||||||
|
|
||||||
buffsize = buffsize/2;
|
resampler_size = buffsize = buffsize/2;
|
||||||
|
|
||||||
samples = buffsize/4;
|
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)
|
while( player_state != CLOSED)
|
||||||
{
|
{
|
||||||
uint32_t offset;
|
uint32_t offset;
|
||||||
double event_stamp, wait_stamp;
|
double event_stamp, wait_stamp;
|
||||||
int too_late = 0;
|
int too_late = 0;
|
||||||
|
|
||||||
if((player_state == PAUSE) ||
|
switch(sound_state)
|
||||||
(player_state == PLAY_INIT) )
|
|
||||||
{
|
{
|
||||||
if( active )
|
case PREPARE:
|
||||||
{
|
|
||||||
StopBuffer(hBuff);
|
|
||||||
active = 0;
|
|
||||||
};
|
|
||||||
delay(1);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else if(player_state == REWIND)
|
|
||||||
{
|
|
||||||
if( active )
|
|
||||||
{
|
|
||||||
StopBuffer(hBuff);
|
|
||||||
active = 0;
|
|
||||||
};
|
|
||||||
mutex_lock(&astream.lock);
|
|
||||||
astream.count = 0;
|
|
||||||
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);
|
mutex_lock(&astream.lock);
|
||||||
GetTimeStamp(hBuff, &last_time_stamp);
|
if(astream.count < buffsize*2)
|
||||||
printf("last audio time stamp %f\n", last_time_stamp);
|
{
|
||||||
|
memset(astream.buffer+astream.count,
|
||||||
if((err = PlayBuffer(hBuff, 0)) !=0 )
|
0, buffsize*2-astream.count);
|
||||||
{
|
astream.count = buffsize*2;
|
||||||
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);
|
|
||||||
};
|
|
||||||
|
|
||||||
GetNotify(&evnt);
|
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);
|
||||||
|
|
||||||
if(evnt.code != 0xFF000001)
|
SetTimeBase(hBuff, audio_base);
|
||||||
{
|
|
||||||
printf("invalid event code %d\n\r", evnt.code);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(evnt.stream != hBuff)
|
case PAUSE_2_PLAY:
|
||||||
{
|
GetTimeStamp(hBuff, &last_time_stamp);
|
||||||
printf("invalid stream %x hBuff= %x\n\r",
|
// printf("last audio time stamp %f\n", last_time_stamp);
|
||||||
evnt.stream, hBuff);
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
|
|
||||||
GetTimeStamp(hBuff, &event_stamp);
|
if((err = PlayBuffer(hBuff, 0)) !=0 )
|
||||||
|
{
|
||||||
|
errstr = "Cannot play buffer\n\r";
|
||||||
|
goto exit_whith_error;
|
||||||
|
};
|
||||||
|
active = 1;
|
||||||
|
sync_audio(hBuff, buffsize);
|
||||||
|
sound_state = PLAY;
|
||||||
|
// printf("render: set audio latency to %f\n", audio_delta);
|
||||||
|
|
||||||
offset = evnt.offset;
|
/* breaktrough */
|
||||||
|
|
||||||
while( (astream.count < buffsize) &&
|
case PLAY:
|
||||||
(player_state != CLOSED) )
|
GetNotify(&evnt);
|
||||||
{
|
|
||||||
yield();
|
if(evnt.code != 0xFF000001)
|
||||||
GetTimeStamp(hBuff, &wait_stamp);
|
{
|
||||||
if( (wait_stamp - event_stamp) >
|
printf("invalid event code %d\n\r", evnt.code);
|
||||||
samples*1500/sample_rate )
|
continue;
|
||||||
{
|
}
|
||||||
samples_lost+= samples;
|
|
||||||
audio_delta = (double)samples_lost*1000/sample_rate;
|
if(evnt.stream != hBuff)
|
||||||
// printf("audio delta %f\n", audio_delta);
|
{
|
||||||
too_late = 1;
|
printf("invalid stream %x hBuff= %x\n\r",
|
||||||
|
evnt.stream, hBuff);
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
|
||||||
|
offset = evnt.offset;
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
};
|
||||||
|
|
||||||
|
samples_written+= buffsize/4;
|
||||||
|
|
||||||
|
astream.count -= buffsize;
|
||||||
|
if(astream.count)
|
||||||
|
memcpy(astream.buffer, astream.buffer+buffsize, astream.count);
|
||||||
|
mutex_unlock(&astream.lock);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if((too_late == 1) || (player_state == CLOSED))
|
case PLAY_2_STOP:
|
||||||
{
|
if( active )
|
||||||
too_late = 0;
|
{
|
||||||
continue;
|
ResetBuffer(hBuff, SND_RESET_ALL);
|
||||||
};
|
audio_base = -1.0;
|
||||||
|
active = 0;
|
||||||
|
}
|
||||||
|
sound_state = STOP;
|
||||||
|
break;
|
||||||
|
|
||||||
mutex_lock(&astream.lock);
|
case PLAY_2_PAUSE:
|
||||||
SetBuffer(hBuff, astream.buffer, offset, buffsize);
|
if( active )
|
||||||
samples_written+= buffsize/4;
|
{
|
||||||
astream.count -= buffsize;
|
StopBuffer(hBuff);
|
||||||
if(astream.count)
|
};
|
||||||
memcpy(astream.buffer, astream.buffer+buffsize, astream.count);
|
sound_state = PAUSE;
|
||||||
mutex_unlock(&astream.lock);
|
|
||||||
|
case PAUSE:
|
||||||
|
case STOP:
|
||||||
|
delay(1);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
StopBuffer(hBuff);
|
StopBuffer(hBuff);
|
||||||
|
@ -15,7 +15,9 @@
|
|||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
#include "fplay.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;
|
uint32_t win_width, win_height;
|
||||||
|
|
||||||
@ -33,6 +35,8 @@ int audioStream;
|
|||||||
int have_sound = 0;
|
int have_sound = 0;
|
||||||
|
|
||||||
uint8_t *decoder_buffer;
|
uint8_t *decoder_buffer;
|
||||||
|
extern int resampler_size;
|
||||||
|
|
||||||
extern int sample_rate;
|
extern int sample_rate;
|
||||||
char *movie_file;
|
char *movie_file;
|
||||||
|
|
||||||
@ -58,7 +62,7 @@ int main( int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if(argc < 2) {
|
if(argc < 2) {
|
||||||
printf("Please provide a movie file\n");
|
printf("Please provide a movie file\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -66,7 +70,7 @@ int main( int argc, char *argv[])
|
|||||||
movie_file = argv[1];
|
movie_file = argv[1];
|
||||||
/* register all codecs, demux and protocols */
|
/* register all codecs, demux and protocols */
|
||||||
|
|
||||||
// av_log_set_level(AV_LOG_INFO);
|
av_log_set_level(AV_LOG_FATAL);
|
||||||
|
|
||||||
avcodec_register_all();
|
avcodec_register_all();
|
||||||
avdevice_register_all();
|
avdevice_register_all();
|
||||||
@ -93,7 +97,7 @@ int main( int argc, char *argv[])
|
|||||||
|
|
||||||
// stream_duration = 1000.0 * pFormatCtx->duration * av_q2d(AV_TIME_BASE_Q);
|
// stream_duration = 1000.0 * pFormatCtx->duration * av_q2d(AV_TIME_BASE_Q);
|
||||||
stream_duration = pFormatCtx->duration;
|
stream_duration = pFormatCtx->duration;
|
||||||
|
|
||||||
printf("duration %f\n", (double)stream_duration);
|
printf("duration %f\n", (double)stream_duration);
|
||||||
// Find the first video stream
|
// Find the first video stream
|
||||||
videoStream=-1;
|
videoStream=-1;
|
||||||
@ -112,7 +116,7 @@ int main( int argc, char *argv[])
|
|||||||
// pFormatCtx->streams[i]->duration *
|
// pFormatCtx->streams[i]->duration *
|
||||||
// av_q2d(pFormatCtx->streams[i]->time_base);
|
// av_q2d(pFormatCtx->streams[i]->time_base);
|
||||||
stream_duration = pFormatCtx->streams[i]->duration;
|
stream_duration = pFormatCtx->streams[i]->duration;
|
||||||
|
|
||||||
}
|
}
|
||||||
if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_AUDIO &&
|
if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_AUDIO &&
|
||||||
audioStream < 0)
|
audioStream < 0)
|
||||||
@ -133,9 +137,7 @@ int main( int argc, char *argv[])
|
|||||||
return -1; // Didn't find a video stream
|
return -1; // Didn't find a video stream
|
||||||
}
|
}
|
||||||
|
|
||||||
player_state = PLAY_INIT;
|
// __asm__ __volatile__("int3");
|
||||||
|
|
||||||
// __asm__ __volatile__("int3");
|
|
||||||
|
|
||||||
// Get a pointer to the codec context for the video stream
|
// Get a pointer to the codec context for the video stream
|
||||||
pCodecCtx=pFormatCtx->streams[videoStream]->codec;
|
pCodecCtx=pFormatCtx->streams[videoStream]->codec;
|
||||||
@ -232,153 +234,177 @@ int main( int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int load_frame()
|
||||||
|
{
|
||||||
|
AVPacket packet;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
err = av_read_frame(pFormatCtx, &packet);
|
||||||
|
if( err == 0)
|
||||||
|
{
|
||||||
|
if(packet.stream_index==videoStream)
|
||||||
|
put_packet(&q_video, &packet);
|
||||||
|
else if( (packet.stream_index == audioStream) &&
|
||||||
|
(have_sound != 0) )
|
||||||
|
{
|
||||||
|
put_packet(&q_audio, &packet);
|
||||||
|
if(audio_base == -1.0)
|
||||||
|
{
|
||||||
|
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 if (err != AVERROR_EOF)
|
||||||
|
printf("av_read_frame: error %x\n", err);
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int fill_queue()
|
static int fill_queue()
|
||||||
{
|
{
|
||||||
int eof = 0;
|
int err = 0;
|
||||||
AVPacket packet;
|
AVPacket packet;
|
||||||
|
|
||||||
while( !eof)
|
|
||||||
{
|
|
||||||
int err;
|
|
||||||
|
|
||||||
// __asm__ __volatile__("int3");
|
// __asm__ __volatile__("int3");
|
||||||
|
|
||||||
if(q_video.size+q_audio.size < 2*1024*1024)
|
while( (q_video.size+q_audio.size < 2*1024*1024) &&
|
||||||
{
|
!err )
|
||||||
err = av_read_frame(pFormatCtx, &packet);
|
err = load_frame();
|
||||||
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) )
|
|
||||||
{
|
|
||||||
put_packet(&q_audio, &packet);
|
|
||||||
if(audio_base == -1.0)
|
|
||||||
{
|
|
||||||
if (packet.dts != AV_NOPTS_VALUE)
|
|
||||||
audio_base = get_audio_base() * packet.dts;
|
|
||||||
// printf("audio base %f\n", audio_base);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
av_free_packet(&packet);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else break;
|
|
||||||
};
|
|
||||||
|
|
||||||
return eof;
|
return err;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static void flush_all()
|
||||||
|
{
|
||||||
|
AVPacket packet;
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
flush_video();
|
||||||
|
|
||||||
|
astream.count = 0;
|
||||||
|
};
|
||||||
|
|
||||||
void decoder()
|
void decoder()
|
||||||
{
|
{
|
||||||
int eof;
|
int eof;
|
||||||
AVPacket packet;
|
AVPacket packet;
|
||||||
int ret;
|
int ret;
|
||||||
|
int64_t min_pos, max_pos;
|
||||||
|
|
||||||
eof = fill_queue();
|
while( player_state != CLOSED )
|
||||||
|
|
||||||
while( player_state != CLOSED && !eof)
|
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
// __asm__ __volatile__("int3");
|
// __asm__ __volatile__("int3");
|
||||||
|
|
||||||
if( player_state == PAUSE )
|
switch(decoder_state)
|
||||||
{
|
{
|
||||||
delay(1);
|
case PREPARE:
|
||||||
continue;
|
eof = fill_queue();
|
||||||
};
|
|
||||||
|
|
||||||
if( player_state == REWIND )
|
do
|
||||||
{
|
{
|
||||||
// int64_t timestamp = 0;
|
if( (q_video.size+q_audio.size < 4*1024*1024) &&
|
||||||
// int stream_index = av_find_default_stream_index(pFormatCtx);
|
(eof == 0) )
|
||||||
|
{
|
||||||
|
eof = load_frame();
|
||||||
|
}
|
||||||
|
decode_video(pCodecCtx, &q_video);
|
||||||
|
ret = decode_audio(aCodecCtx, &q_audio);
|
||||||
|
}while(astream.count < resampler_size*2 &&
|
||||||
|
ret == 1);
|
||||||
|
|
||||||
// __asm__ __volatile__("int3");
|
sound_state = PREPARE;
|
||||||
|
decoder_state = PLAY;
|
||||||
|
player_state = PLAY;
|
||||||
|
|
||||||
if (pFormatCtx->start_time != AV_NOPTS_VALUE)
|
case PLAY:
|
||||||
rewind_pos += pFormatCtx->start_time;
|
if( (q_video.size+q_audio.size < 4*1024*1024) &&
|
||||||
|
(eof == 0) )
|
||||||
|
{
|
||||||
|
eof = load_frame();
|
||||||
|
if(eof) printf("eof\n");
|
||||||
|
}
|
||||||
|
ret = decode_video(pCodecCtx, &q_video);
|
||||||
|
ret|= decode_audio(aCodecCtx, &q_audio);
|
||||||
|
|
||||||
printf("rewind %8"PRId64"\n", rewind_pos);
|
if( eof && !ret)
|
||||||
|
{
|
||||||
ret = avformat_seek_file(pFormatCtx, -1, INT64_MIN,
|
decoder_state = STOP;
|
||||||
rewind_pos, INT64_MAX, 0);
|
// printf("stop decoder\n");
|
||||||
// ret = avformat_seek_file(pFormatCtx, -1, 0,
|
};
|
||||||
// 0, INT64_MAX, 0);
|
|
||||||
|
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");
|
// __asm__ __volatile__("int3");
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
printf("could not seek to position %f\n",
|
printf("could not seek to position %f\n",
|
||||||
(double)rewind_pos / AV_TIME_BASE);
|
(double)rewind_pos / AV_TIME_BASE);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
avcodec_flush_buffers(pCodecCtx);
|
|
||||||
avcodec_flush_buffers(aCodecCtx);
|
|
||||||
|
|
||||||
while( get_packet(&q_video, &packet) != 0)
|
// printf("restart\n");
|
||||||
av_free_packet(&packet);
|
decoder_state = PREPARE;
|
||||||
|
break;
|
||||||
while( get_packet(&q_audio, &packet)!= 0)
|
}
|
||||||
av_free_packet(&packet);
|
|
||||||
audio_base = -1.0;
|
|
||||||
|
|
||||||
// __asm__ __volatile__("int3");
|
|
||||||
|
|
||||||
eof = fill_queue();
|
|
||||||
};
|
|
||||||
yield();
|
|
||||||
|
|
||||||
flush_video();
|
|
||||||
|
|
||||||
player_state = REWIND_2_PLAY;
|
|
||||||
printf("restart\n");
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
|
|
||||||
if(q_video.size+q_audio.size < 4*1024*1024)
|
|
||||||
{
|
|
||||||
err = av_read_frame(pFormatCtx, &packet);
|
|
||||||
if( err < 0)
|
|
||||||
{
|
|
||||||
eof = 1;
|
|
||||||
if (err != AVERROR_EOF)
|
|
||||||
printf("av_read_frame: error %x\n", err);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if(packet.stream_index==videoStream)
|
|
||||||
{
|
|
||||||
put_packet(&q_video, &packet);
|
|
||||||
}
|
|
||||||
else if( (packet.stream_index == audioStream) &&
|
|
||||||
(have_sound != 0) )
|
|
||||||
{
|
|
||||||
put_packet(&q_audio, &packet);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
av_free_packet(&packet);
|
|
||||||
};
|
|
||||||
decode_video(pCodecCtx, &q_video);
|
|
||||||
decode_audio(aCodecCtx, &q_audio);
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
decode_video(pCodecCtx, &q_video);
|
|
||||||
decode_audio(aCodecCtx, &q_audio);
|
|
||||||
delay(1);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ret = 1;
|
ret = 1;
|
||||||
|
@ -39,10 +39,10 @@ struct render
|
|||||||
uint32_t layout;
|
uint32_t layout;
|
||||||
bitmap_t bitmap[4];
|
bitmap_t bitmap[4];
|
||||||
bitmap_t *last_bitmap;
|
bitmap_t *last_bitmap;
|
||||||
|
|
||||||
uint32_t ctx_format;
|
uint32_t ctx_format;
|
||||||
int target;
|
int target;
|
||||||
|
|
||||||
window_t *win;
|
window_t *win;
|
||||||
enum{
|
enum{
|
||||||
EMPTY, INIT }state;
|
EMPTY, INIT }state;
|
||||||
@ -52,13 +52,25 @@ struct render
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum player_state
|
enum player_state
|
||||||
{ CLOSED=0,PLAY_INIT,
|
{
|
||||||
STOP, PAUSE, PLAY, REWIND,
|
CLOSED = 0,
|
||||||
PAUSE_2_PLAY, REWIND_2_PLAY
|
PREPARE,
|
||||||
|
STOP,
|
||||||
|
PAUSE,
|
||||||
|
PLAY,
|
||||||
|
REWIND,
|
||||||
|
PLAY_2_STOP,
|
||||||
|
PLAY_2_PAUSE,
|
||||||
|
PAUSE_2_PLAY,
|
||||||
|
REWIND_2_PLAY,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define ID_PLAY 100
|
#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
|
typedef struct
|
||||||
{
|
{
|
||||||
volatile uint32_t lock;
|
volatile uint32_t lock;
|
||||||
@ -112,6 +124,7 @@ void render_draw_client(render_t *render);
|
|||||||
|
|
||||||
int init_audio(int format);
|
int init_audio(int format);
|
||||||
int audio_thread(void *param);
|
int audio_thread(void *param);
|
||||||
|
void set_audio_volume(int left, int right);
|
||||||
|
|
||||||
int init_video(AVCodecContext *ctx);
|
int init_video(AVCodecContext *ctx);
|
||||||
int video_thread(void *param);
|
int video_thread(void *param);
|
||||||
@ -178,4 +191,4 @@ int resize_bitmap(bitmap_t *bitmap);
|
|||||||
int blit_bitmap(bitmap_t *bitmap, int dst_x, int dst_y,
|
int blit_bitmap(bitmap_t *bitmap, int dst_x, int dst_y,
|
||||||
int w, int h);
|
int w, int h);
|
||||||
|
|
||||||
|
int init_fontlib();
|
||||||
|
@ -1,29 +1,71 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <libavcodec/avcodec.h>
|
//#include <libavcodec/avcodec.h>
|
||||||
#include <libavformat/avformat.h>
|
//#include <libavformat/avformat.h>
|
||||||
#include <libswscale/swscale.h>
|
//#include <libswscale/swscale.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <fcntl.h>
|
//#include <fcntl.h>
|
||||||
#include "../winlib/winlib.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 DISPLAY_VERSION 0x0200 /* 2.00 */
|
||||||
|
|
||||||
#define SRV_GETVERSION 0
|
#define SRV_GETVERSION 0
|
||||||
#define SRV_GET_CAPS 3
|
#define SRV_GET_CAPS 3
|
||||||
|
|
||||||
#define SRV_CREATE_SURFACE 10
|
#define SRV_CREATE_SURFACE 10
|
||||||
#define SRV_LOCK_SURFACE 12
|
#define SRV_DESTROY_SURFACE 11
|
||||||
|
#define SRV_LOCK_SURFACE 12
|
||||||
#define SRV_BLIT_VIDEO 20
|
#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 __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
|
#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
|
||||||
#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1)
|
#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 service;
|
||||||
static uint32_t blit_caps;
|
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
|
typedef struct
|
||||||
{
|
{
|
||||||
@ -38,6 +80,17 @@ typedef struct
|
|||||||
};
|
};
|
||||||
}hwcaps_t;
|
}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)
|
static uint32_t get_service(char *name)
|
||||||
{
|
{
|
||||||
uint32_t retval = 0;
|
uint32_t retval = 0;
|
||||||
@ -68,11 +121,16 @@ static int call_service(ioctl_t *io)
|
|||||||
uint32_t InitPixlib(uint32_t caps)
|
uint32_t InitPixlib(uint32_t caps)
|
||||||
{
|
{
|
||||||
uint32_t api_version;
|
uint32_t api_version;
|
||||||
hwcaps_t hwcaps;
|
uint32_t screensize;
|
||||||
ioctl_t io;
|
hwcaps_t hwcaps;
|
||||||
|
ioctl_t io;
|
||||||
|
|
||||||
// __asm__ __volatile__("int3");
|
// __asm__ __volatile__("int3");
|
||||||
|
|
||||||
|
screensize = GetScreenSize();
|
||||||
|
screen_width = screensize >> 16;
|
||||||
|
screen_height = screensize & 0xFFFF;
|
||||||
|
|
||||||
service = get_service("DISPLAY");
|
service = get_service("DISPLAY");
|
||||||
if(service == 0)
|
if(service == 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
@ -153,8 +211,8 @@ int create_bitmap(bitmap_t *bitmap)
|
|||||||
|
|
||||||
io_10.width = bitmap->width;
|
io_10.width = bitmap->width;
|
||||||
io_10.height = bitmap->height;
|
io_10.height = bitmap->height;
|
||||||
io_10.max_width = 0;
|
io_10.max_width = screen_width;
|
||||||
io_10.max_height = 0;
|
io_10.max_height = screen_height;
|
||||||
io_10.format = 0;
|
io_10.format = 0;
|
||||||
|
|
||||||
io.handle = service;
|
io.handle = service;
|
||||||
@ -201,22 +259,19 @@ int create_bitmap(bitmap_t *bitmap)
|
|||||||
int lock_bitmap(bitmap_t *bitmap)
|
int lock_bitmap(bitmap_t *bitmap)
|
||||||
{
|
{
|
||||||
// __asm__ __volatile__("int3");
|
// __asm__ __volatile__("int3");
|
||||||
|
int err = 0;
|
||||||
|
|
||||||
if( blit_caps & HW_BIT_BLIT )
|
if( blit_caps & HW_BIT_BLIT )
|
||||||
{
|
{
|
||||||
struct __attribute__((packed)) /* SRV_CREATE_SURFACE */
|
struct __attribute__((packed)) /* SRV_LOCK_SURFACE */
|
||||||
{
|
{
|
||||||
uint32_t handle; // ignored
|
uint32_t handle;
|
||||||
void *data; // ignored
|
void *data;
|
||||||
|
uint32_t pitch;
|
||||||
uint32_t width;
|
|
||||||
uint32_t height;
|
|
||||||
uint32_t pitch; // ignored
|
|
||||||
|
|
||||||
}io_12;
|
}io_12;
|
||||||
|
|
||||||
ioctl_t io;
|
ioctl_t io;
|
||||||
int err;
|
|
||||||
|
|
||||||
io_12.handle = bitmap->handle;
|
io_12.handle = bitmap->handle;
|
||||||
io_12.pitch = 0;
|
io_12.pitch = 0;
|
||||||
@ -225,7 +280,7 @@ int lock_bitmap(bitmap_t *bitmap)
|
|||||||
io.handle = service;
|
io.handle = service;
|
||||||
io.io_code = SRV_LOCK_SURFACE;
|
io.io_code = SRV_LOCK_SURFACE;
|
||||||
io.input = &io_12;
|
io.input = &io_12;
|
||||||
io.inp_size = BUFFER_SIZE(5);
|
io.inp_size = BUFFER_SIZE(3);
|
||||||
io.output = NULL;
|
io.output = NULL;
|
||||||
io.out_size = 0;
|
io.out_size = 0;
|
||||||
|
|
||||||
@ -236,33 +291,16 @@ int lock_bitmap(bitmap_t *bitmap)
|
|||||||
bitmap->data = io_12.data;
|
bitmap->data = io_12.data;
|
||||||
// printf("Lock hardware surface %x pitch %d, buffer %x\n",
|
// printf("Lock hardware surface %x pitch %d, buffer %x\n",
|
||||||
// bitmap->handle, bitmap->pitch, bitmap->data);
|
// 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 blit_bitmap(bitmap_t *bitmap, int dst_x, int dst_y,
|
||||||
int w, int h)
|
int w, int h)
|
||||||
{
|
{
|
||||||
|
int err;
|
||||||
|
|
||||||
if( blit_caps & HW_BIT_BLIT )
|
if( blit_caps & HW_BIT_BLIT )
|
||||||
{
|
{
|
||||||
@ -280,22 +318,21 @@ int blit_bitmap(bitmap_t *bitmap, int dst_x, int dst_y,
|
|||||||
int src_y;
|
int src_y;
|
||||||
uint32_t w;
|
uint32_t w;
|
||||||
uint32_t h;
|
uint32_t h;
|
||||||
}io_20;
|
}io_15;
|
||||||
|
|
||||||
ioctl_t io;
|
ioctl_t io;
|
||||||
int err;
|
|
||||||
|
|
||||||
io_20.handle = bitmap->handle;
|
io_15.handle = bitmap->handle;
|
||||||
io_20.dst_x = dst_x;
|
io_15.dst_x = dst_x;
|
||||||
io_20.dst_y = dst_y;
|
io_15.dst_y = dst_y;
|
||||||
io_20.src_x = 0;
|
io_15.src_x = 0;
|
||||||
io_20.src_y = 0;
|
io_15.src_y = 0;
|
||||||
io_20.w = w;
|
io_15.w = w;
|
||||||
io_20.h = h;
|
io_15.h = h;
|
||||||
|
|
||||||
io.handle = service;
|
io.handle = service;
|
||||||
io.io_code = SRV_BLIT_VIDEO;
|
io.io_code = SRV_BLIT_BITMAP;
|
||||||
io.input = &io_20;
|
io.input = &io_15;
|
||||||
io.inp_size = BUFFER_SIZE(7);
|
io.inp_size = BUFFER_SIZE(7);
|
||||||
io.output = NULL;
|
io.output = NULL;
|
||||||
io.out_size = 0;
|
io.out_size = 0;
|
||||||
@ -303,17 +340,10 @@ int blit_bitmap(bitmap_t *bitmap, int dst_x, int dst_y,
|
|||||||
// printf("do blit %x pitch %d\n",bitmap->handle,
|
// printf("do blit %x pitch %d\n",bitmap->handle,
|
||||||
// bitmap->pitch);
|
// bitmap->pitch);
|
||||||
err = call_service(&io);
|
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;
|
return err;
|
||||||
};
|
};
|
||||||
|
|
||||||
volatile struct blit_call bc;
|
struct blit_call bc;
|
||||||
|
|
||||||
bc.dstx = dst_x;
|
bc.dstx = dst_x;
|
||||||
bc.dsty = dst_y;
|
bc.dsty = dst_y;
|
||||||
@ -328,32 +358,49 @@ int blit_bitmap(bitmap_t *bitmap, int dst_x, int dst_y,
|
|||||||
|
|
||||||
__asm__ __volatile__(
|
__asm__ __volatile__(
|
||||||
"int $0x40"
|
"int $0x40"
|
||||||
::"a"(73),"b"(0x00),"c"(&bc)
|
:"=a"(err)
|
||||||
|
:"a"(73),"b"(0x00),"c"(&bc)
|
||||||
:"memory");
|
:"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)
|
int resize_bitmap(bitmap_t *bitmap)
|
||||||
{
|
{
|
||||||
// __asm__ __volatile__("int3");
|
// __asm__ __volatile__("int3");
|
||||||
|
|
||||||
if( blit_caps & HW_BIT_BLIT )
|
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 size;
|
||||||
|
@ -74,6 +74,7 @@ extern "C"
|
|||||||
#define SND_SETTIMEBASE 18
|
#define SND_SETTIMEBASE 18
|
||||||
#define SND_GETTIMESTAMP 19
|
#define SND_GETTIMESTAMP 19
|
||||||
|
|
||||||
|
#define SND_RESET_ALL 3
|
||||||
|
|
||||||
#define PLAY_SYNC 0x80000000
|
#define PLAY_SYNC 0x80000000
|
||||||
|
|
||||||
|
@ -264,6 +264,18 @@ uint32_t set_cursor(uint32_t cursor)
|
|||||||
return old;
|
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)
|
static inline void get_proc_info(char *info)
|
||||||
{
|
{
|
||||||
__asm__ __volatile__(
|
__asm__ __volatile__(
|
||||||
@ -279,7 +291,7 @@ void* user_realloc(void *mem, size_t size)
|
|||||||
__asm__ __volatile__(
|
__asm__ __volatile__(
|
||||||
"int $0x40"
|
"int $0x40"
|
||||||
:"=a"(val)
|
:"=a"(val)
|
||||||
:"a"(68),"b"(12),"c"(size),"d"(mem)
|
:"a"(68),"b"(20),"c"(size),"d"(mem)
|
||||||
:"memory");
|
:"memory");
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
|
@ -46,8 +46,8 @@ int put_packet(queue_t *q, AVPacket *pkt)
|
|||||||
AVPacketList *q_pkt;
|
AVPacketList *q_pkt;
|
||||||
|
|
||||||
/* duplicate the packet */
|
/* duplicate the packet */
|
||||||
if (av_dup_packet(pkt) < 0)
|
// if (av_dup_packet(pkt) < 0)
|
||||||
return -1;
|
// return -1;
|
||||||
|
|
||||||
q_pkt = av_malloc(sizeof(AVPacketList));
|
q_pkt = av_malloc(sizeof(AVPacketList));
|
||||||
if (!q_pkt)
|
if (!q_pkt)
|
||||||
|
@ -8,8 +8,7 @@
|
|||||||
#include "../winlib/winlib.h"
|
#include "../winlib/winlib.h"
|
||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
#include "fplay.h"
|
#include "fplay.h"
|
||||||
|
#include <math.h>
|
||||||
#define CAPTION_HEIGHT 24
|
|
||||||
|
|
||||||
extern int res_pause_btn[];
|
extern int res_pause_btn[];
|
||||||
extern int res_pause_btn_pressed[];
|
extern int res_pause_btn_pressed[];
|
||||||
@ -18,6 +17,8 @@ extern int res_play_btn[];
|
|||||||
extern int res_play_btn_pressed[];
|
extern int res_play_btn_pressed[];
|
||||||
|
|
||||||
extern int64_t stream_duration;
|
extern int64_t stream_duration;
|
||||||
|
extern volatile int sound_level_0;
|
||||||
|
extern volatile int sound_level_1;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@ -27,6 +28,7 @@ typedef struct
|
|||||||
}vframe_t;
|
}vframe_t;
|
||||||
|
|
||||||
vframe_t frames[4];
|
vframe_t frames[4];
|
||||||
|
volatile int frames_count = 0;
|
||||||
|
|
||||||
struct SwsContext *cvt_ctx = NULL;
|
struct SwsContext *cvt_ctx = NULL;
|
||||||
|
|
||||||
@ -50,10 +52,11 @@ void flush_video()
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 0; i < 4; i++)
|
for(i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
frames[i].pts = 0;
|
frames[i].pts = 0;
|
||||||
frames[i].ready = 0;
|
frames[i].ready = 0;
|
||||||
};
|
};
|
||||||
|
frames_count = 0;
|
||||||
vfx = 0;
|
vfx = 0;
|
||||||
dfx = 0;
|
dfx = 0;
|
||||||
};
|
};
|
||||||
@ -65,16 +68,12 @@ int init_video(AVCodecContext *ctx)
|
|||||||
width = ctx->width;
|
width = ctx->width;
|
||||||
height = ctx->height;
|
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");
|
// __asm__ __volatile__("int3");
|
||||||
|
|
||||||
main_render = create_render(ctx->width, ctx->height,
|
main_render = create_render(ctx->width, ctx->height,
|
||||||
ctx->pix_fmt, HW_BIT_BLIT|HW_TEX_BLIT);
|
ctx->pix_fmt, HW_BIT_BLIT|HW_TEX_BLIT);
|
||||||
// render = create_render(ctx->width, ctx->height,
|
|
||||||
// ctx->pix_fmt, 0);
|
|
||||||
//
|
|
||||||
if( main_render == NULL)
|
if( main_render == NULL)
|
||||||
{
|
{
|
||||||
printf("Cannot create render\n\r");
|
printf("Cannot create render\n\r");
|
||||||
@ -121,11 +120,12 @@ int decode_video(AVCodecContext *ctx, queue_t *qv)
|
|||||||
double current_clock;
|
double current_clock;
|
||||||
|
|
||||||
if(frames[dfx].ready != 0 )
|
if(frames[dfx].ready != 0 )
|
||||||
return 1;
|
return -1;
|
||||||
|
|
||||||
if( get_packet(qv, &pkt) == 0 )
|
if( get_packet(qv, &pkt) == 0 )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
/*
|
||||||
current_clock = -90.0 + get_master_clock();
|
current_clock = -90.0 + get_master_clock();
|
||||||
|
|
||||||
if( pkt.dts == AV_NOPTS_VALUE &&
|
if( pkt.dts == AV_NOPTS_VALUE &&
|
||||||
@ -135,10 +135,10 @@ int decode_video(AVCodecContext *ctx, queue_t *qv)
|
|||||||
pts= pkt.dts;
|
pts= pkt.dts;
|
||||||
else
|
else
|
||||||
pts= 0;
|
pts= 0;
|
||||||
|
|
||||||
|
|
||||||
pts *= av_q2d(video_time_base)*1000.0;
|
|
||||||
|
|
||||||
|
|
||||||
|
pts *= av_q2d(video_time_base)*1000.0;
|
||||||
|
*/
|
||||||
if( 1 /*pts > current_clock*/)
|
if( 1 /*pts > current_clock*/)
|
||||||
{
|
{
|
||||||
frameFinished = 0;
|
frameFinished = 0;
|
||||||
@ -181,6 +181,7 @@ int decode_video(AVCodecContext *ctx, queue_t *qv)
|
|||||||
|
|
||||||
dfx++;
|
dfx++;
|
||||||
dfx&= 3;
|
dfx&= 3;
|
||||||
|
frames_count++;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
av_free_packet(&pkt);
|
av_free_packet(&pkt);
|
||||||
@ -189,10 +190,35 @@ int decode_video(AVCodecContext *ctx, queue_t *qv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern volatile enum player_state player_state;
|
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;
|
//rect_t win_rect;
|
||||||
|
|
||||||
extern int64_t rewind_pos;
|
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)
|
int MainWindowProc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2)
|
||||||
{
|
{
|
||||||
window_t *win;
|
window_t *win;
|
||||||
@ -211,13 +237,15 @@ int MainWindowProc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_LBTNDOWN:
|
case MSG_LBTNDOWN:
|
||||||
|
|
||||||
if(player_state == PAUSE)
|
if(player_state == PAUSE)
|
||||||
{
|
{
|
||||||
win->panel.play_btn->img_default = res_pause_btn;
|
win->panel.play_btn->img_default = res_pause_btn;
|
||||||
win->panel.play_btn->img_hilite = res_pause_btn;
|
win->panel.play_btn->img_hilite = res_pause_btn;
|
||||||
win->panel.play_btn->img_pressed = res_pause_btn_pressed;
|
win->panel.play_btn->img_pressed = res_pause_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_2_PLAY;
|
player_state = PLAY;
|
||||||
|
sound_state = PAUSE_2_PLAY;
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(player_state == PLAY)
|
else if(player_state == PLAY)
|
||||||
@ -225,8 +253,9 @@ int MainWindowProc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2)
|
|||||||
win->panel.play_btn->img_default = res_play_btn;
|
win->panel.play_btn->img_default = res_play_btn;
|
||||||
win->panel.play_btn->img_hilite = res_play_btn;
|
win->panel.play_btn->img_hilite = res_play_btn;
|
||||||
win->panel.play_btn->img_pressed = res_play_btn_pressed;
|
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;
|
player_state = PAUSE;
|
||||||
|
sound_state = PLAY_2_PAUSE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -239,7 +268,8 @@ int MainWindowProc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2)
|
|||||||
win->panel.play_btn->img_default = res_pause_btn;
|
win->panel.play_btn->img_default = res_pause_btn;
|
||||||
win->panel.play_btn->img_hilite = res_pause_btn;
|
win->panel.play_btn->img_hilite = res_pause_btn;
|
||||||
win->panel.play_btn->img_pressed = res_pause_btn_pressed;
|
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)
|
else if(player_state == PLAY)
|
||||||
{
|
{
|
||||||
@ -247,24 +277,66 @@ int MainWindowProc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2)
|
|||||||
win->panel.play_btn->img_hilite = res_play_btn;
|
win->panel.play_btn->img_hilite = res_play_btn;
|
||||||
win->panel.play_btn->img_pressed = res_play_btn_pressed;
|
win->panel.play_btn->img_pressed = res_play_btn_pressed;
|
||||||
player_state = PAUSE;
|
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;
|
break;
|
||||||
|
|
||||||
case 101: //ID_PROGRESS:
|
case ID_STOP:
|
||||||
|
player_stop();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ID_PROGRESS:
|
||||||
if(player_state != REWIND)
|
if(player_state != REWIND)
|
||||||
{
|
{
|
||||||
progress_t *prg = (progress_t*)arg2;
|
progress_t *prg = (progress_t*)arg2;
|
||||||
|
|
||||||
rewind_pos = (int64_t)prg->pos *
|
rewind_pos = (prg->max - prg->min)*prg->pos/prg->ctrl.w;
|
||||||
(prg->max - prg->min)/prg->ctrl.w;
|
|
||||||
|
// printf("progress action pos: %d time: %f\n", prg->pos, (double)rewind_pos);
|
||||||
// printf("progress action %f\n", (double)rewind_pos);
|
player_state = REWIND;
|
||||||
player_state = REWIND;
|
decoder_state = REWIND;
|
||||||
main_render->win->panel.prg->current = rewind_pos;
|
sound_state = PLAY_2_STOP;
|
||||||
send_message(&main_render->win->panel.ctrl, MSG_PAINT, 0, 0);
|
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;
|
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:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -280,8 +352,11 @@ int MainWindowProc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2)
|
|||||||
|
|
||||||
void render_time(render_t *render)
|
void render_time(render_t *render)
|
||||||
{
|
{
|
||||||
double ctime; /* milliseconds */
|
progress_t *prg = main_render->win->panel.prg;
|
||||||
double fdelay; /* milliseconds */
|
level_t *lvl = main_render->win->panel.lvl;
|
||||||
|
|
||||||
|
double ctime; /* milliseconds */
|
||||||
|
double fdelay; /* milliseconds */
|
||||||
|
|
||||||
//again:
|
//again:
|
||||||
|
|
||||||
@ -290,12 +365,23 @@ void render_time(render_t *render)
|
|||||||
render->win->win_command = WIN_CLOSED;
|
render->win->win_command = WIN_CLOSED;
|
||||||
return;
|
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)
|
else if(player_state != PLAY)
|
||||||
{
|
{
|
||||||
yield();
|
yield();
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#ifdef VERSION_A
|
#ifdef VERSION_A
|
||||||
if(frames[vfx].ready == 1 )
|
if(frames[vfx].ready == 1 )
|
||||||
{
|
{
|
||||||
@ -324,8 +410,16 @@ void render_time(render_t *render)
|
|||||||
// sys_time*10, frames[vfx].pts, ctime, fdelay);
|
// sys_time*10, frames[vfx].pts, ctime, fdelay);
|
||||||
|
|
||||||
main_render->draw(main_render, &frames[vfx].picture);
|
main_render->draw(main_render, &frames[vfx].picture);
|
||||||
main_render->win->panel.prg->current = frames[vfx].pts*1000;
|
prg->current = frames[vfx].pts*1000;
|
||||||
send_message(&render->win->panel.prg->ctrl, MSG_PAINT, 0, 0);
|
// 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;
|
frames[vfx].ready = 0;
|
||||||
vfx++;
|
vfx++;
|
||||||
vfx&= 3;
|
vfx&= 3;
|
||||||
@ -396,8 +490,6 @@ void render_time(render_t *render)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern char *movie_file;
|
extern char *movie_file;
|
||||||
|
|
||||||
int video_thread(void *param)
|
int video_thread(void *param)
|
||||||
@ -407,7 +499,7 @@ int video_thread(void *param)
|
|||||||
init_winlib();
|
init_winlib();
|
||||||
|
|
||||||
MainWindow = create_window(movie_file,0,
|
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;
|
MainWindow->panel.prg->max = stream_duration;
|
||||||
// printf("MainWindow %x\n", MainWindow);
|
// printf("MainWindow %x\n", MainWindow);
|
||||||
@ -417,11 +509,12 @@ int video_thread(void *param)
|
|||||||
show_window(MainWindow, NORMAL);
|
show_window(MainWindow, NORMAL);
|
||||||
|
|
||||||
render_draw_client(main_render);
|
render_draw_client(main_render);
|
||||||
player_state = PAUSE_2_PLAY;
|
player_state = PLAY;
|
||||||
|
|
||||||
run_render(MainWindow, main_render);
|
run_render(MainWindow, main_render);
|
||||||
|
|
||||||
// printf("exit thread\n");
|
fini_winlib();
|
||||||
|
|
||||||
player_state = CLOSED;
|
player_state = CLOSED;
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
@ -473,6 +566,8 @@ int render_set_size(render_t *render, int width, int height)
|
|||||||
render->rcvideo.r = width;
|
render->rcvideo.r = width;
|
||||||
render->rcvideo.b = height;
|
render->rcvideo.b = height;
|
||||||
|
|
||||||
|
// printf("render width %d height %d\n",width, height);
|
||||||
|
|
||||||
if( render->win_height > height )
|
if( render->win_height > height )
|
||||||
{
|
{
|
||||||
int yoffs;
|
int yoffs;
|
||||||
@ -561,9 +656,12 @@ void render_adjust_size(render_t *render, window_t *win)
|
|||||||
uint32_t s, sw, sh;
|
uint32_t s, sw, sh;
|
||||||
uint8_t state;
|
uint8_t state;
|
||||||
|
|
||||||
|
|
||||||
right = win->w;
|
right = win->w;
|
||||||
bottom = win->h-CAPTION_HEIGHT-55;
|
bottom = win->h-CAPTION_HEIGHT-PANEL_HEIGHT;
|
||||||
|
|
||||||
|
// printf("window width %d height %d\n",
|
||||||
|
// right, bottom);
|
||||||
|
|
||||||
render->win_state = win->win_state;
|
render->win_state = win->win_state;
|
||||||
|
|
||||||
if(render->win_state == MINIMIZED)
|
if(render->win_state == MINIMIZED)
|
||||||
@ -579,25 +677,19 @@ void render_adjust_size(render_t *render, window_t *win)
|
|||||||
new_w = bottom*render->ctx_width/render->ctx_height;
|
new_w = bottom*render->ctx_width/render->ctx_height;
|
||||||
new_h = right*render->ctx_height/render->ctx_width;
|
new_h = right*render->ctx_height/render->ctx_width;
|
||||||
|
|
||||||
// printf("new_w %d new_h %d\n", new_w, new_h);
|
if(new_w > right)
|
||||||
|
|
||||||
s = right * bottom;
|
|
||||||
sw = right * new_h;
|
|
||||||
sh = bottom * new_w;
|
|
||||||
|
|
||||||
if( abs(s-sw) > abs(s-sh))
|
|
||||||
new_h = bottom;
|
|
||||||
else
|
|
||||||
new_w = right;
|
|
||||||
|
|
||||||
if(new_w < 64)
|
|
||||||
{
|
{
|
||||||
new_w = 64;
|
new_w = right;
|
||||||
new_h = 64*render->ctx_height/render->ctx_width;
|
new_h = right*render->ctx_height/render->ctx_width;
|
||||||
|
};
|
||||||
|
if(new_h > bottom)
|
||||||
|
{
|
||||||
|
new_h = bottom;
|
||||||
|
new_w = bottom*render->ctx_width/render->ctx_height;
|
||||||
};
|
};
|
||||||
|
|
||||||
render->win_width = win->w;
|
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);
|
render_set_size(render, new_w, new_h);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -620,8 +712,8 @@ void draw_hw_picture(render_t *render, AVPicture *picture)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dst_width = render->win_width;
|
dst_width = render->rcvideo.r;
|
||||||
dst_height = render->win_height;
|
dst_height = render->rcvideo.b;
|
||||||
};
|
};
|
||||||
|
|
||||||
cvt_ctx = sws_getCachedContext(cvt_ctx,
|
cvt_ctx = sws_getCachedContext(cvt_ctx,
|
||||||
@ -639,7 +731,7 @@ void draw_hw_picture(render_t *render, AVPicture *picture)
|
|||||||
ret = lock_bitmap(bitmap);
|
ret = lock_bitmap(bitmap);
|
||||||
if( ret != 0)
|
if( ret != 0)
|
||||||
{
|
{
|
||||||
printf("Cannot lock the bitmap!\n");
|
printf("Cannot lock bitmap!\n");
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -661,12 +753,13 @@ void draw_hw_picture(render_t *render, AVPicture *picture)
|
|||||||
blit_bitmap(bitmap, render->rcvideo.l,
|
blit_bitmap(bitmap, render->rcvideo.l,
|
||||||
CAPTION_HEIGHT+render->rcvideo.t,
|
CAPTION_HEIGHT+render->rcvideo.t,
|
||||||
render->rcvideo.r, render->rcvideo.b);
|
render->rcvideo.r, render->rcvideo.b);
|
||||||
|
|
||||||
render->last_bitmap = bitmap;
|
render->last_bitmap = bitmap;
|
||||||
// printf("blit_bitmap\n");
|
// printf("blit_bitmap\n");
|
||||||
|
|
||||||
|
|
||||||
render->target++;
|
// render->target++;
|
||||||
render->target&= 3;
|
// render->target&= 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_sw_picture(render_t *render, AVPicture *picture)
|
void draw_sw_picture(render_t *render, AVPicture *picture)
|
||||||
@ -715,14 +808,18 @@ void render_draw_client(render_t *render)
|
|||||||
render->win_state == ROLLED)
|
render->win_state == ROLLED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if((player_state == PAUSE) ||
|
if(player_state == PAUSE)
|
||||||
(player_state == PLAY_INIT) )
|
|
||||||
{
|
{
|
||||||
if(frames[vfx].ready == 1 )
|
if(frames[vfx].ready == 1 )
|
||||||
main_render->draw(main_render, &frames[vfx].picture);
|
main_render->draw(main_render, &frames[vfx].picture);
|
||||||
else
|
else
|
||||||
draw_bar(0, CAPTION_HEIGHT, render->win_width,
|
draw_bar(0, CAPTION_HEIGHT, render->win_width,
|
||||||
render->rcvideo.b, 0);
|
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)
|
if(render->layout & HAS_TOP)
|
||||||
|
BIN
programs/media/Fplay/winlib/alevel.raw
Normal file
BIN
programs/media/Fplay/winlib/alevel.raw
Normal file
Binary file not shown.
@ -2,8 +2,14 @@
|
|||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
#include "winlib.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;
|
extern ctrl_t *mouse_capture;
|
||||||
uint32_t main_cursor;
|
uint32_t main_cursor;
|
||||||
@ -11,6 +17,39 @@ uint32_t main_cursor;
|
|||||||
static int button_proc(ctrl_t *btn, uint32_t msg, uint32_t arg1, uint32_t arg2);
|
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);
|
static int spinbtn_proc(ctrl_t *btn, uint32_t msg, uint32_t arg1, uint32_t arg2);
|
||||||
|
|
||||||
|
ctrl_t *create_control(size_t size, int id, int x, int y,
|
||||||
|
int w, int h, ctrl_t *parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
ctrl_t *ctrl;
|
||||||
|
|
||||||
|
if( !parent )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
ctrl = (ctrl_t*)malloc(size);
|
||||||
|
|
||||||
|
link_initialize(&ctrl->link);
|
||||||
|
list_initialize(&ctrl->child);
|
||||||
|
|
||||||
|
ctrl->parent = parent;
|
||||||
|
|
||||||
|
ctrl->ctx = parent->ctx;
|
||||||
|
ctrl->id = id;
|
||||||
|
|
||||||
|
ctrl->rc.l = x;
|
||||||
|
ctrl->rc.t = y ;
|
||||||
|
|
||||||
|
ctrl->rc.r = x + w;
|
||||||
|
ctrl->rc.b = y + 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,
|
button_t *create_button(char *caption, int id, int x, int y,
|
||||||
int w, int h, ctrl_t *parent)
|
int w, int h, ctrl_t *parent)
|
||||||
@ -21,29 +60,9 @@ button_t *create_button(char *caption, int id, int x, int y,
|
|||||||
if( !parent )
|
if( !parent )
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
btn = (button_t*)malloc(sizeof(button_t));
|
btn = (button_t*)create_control(sizeof(button_t), id, x, y, w, h, parent);
|
||||||
|
btn->ctrl.handler = button_proc;
|
||||||
link_initialize(&btn->link);
|
|
||||||
list_initialize(&btn->child);
|
|
||||||
|
|
||||||
btn->handler = button_proc;
|
|
||||||
btn->parent = parent;
|
|
||||||
|
|
||||||
btn->ctx = parent->ctx;
|
|
||||||
btn->id = id;
|
|
||||||
btn->style = 0;
|
|
||||||
|
|
||||||
btn->rc.l = x;
|
|
||||||
btn->rc.t = y ;
|
|
||||||
|
|
||||||
btn->rc.r = x + w;
|
|
||||||
btn->rc.b = y + h;
|
|
||||||
|
|
||||||
btn->w = w;
|
|
||||||
btn->h = h;
|
|
||||||
|
|
||||||
btn->state = 0;
|
btn->state = 0;
|
||||||
|
|
||||||
btn->caption = caption;
|
btn->caption = caption;
|
||||||
|
|
||||||
if( !caption )
|
if( !caption )
|
||||||
@ -62,8 +81,6 @@ button_t *create_button(char *caption, int id, int x, int y,
|
|||||||
btn->img_hilite = NULL;
|
btn->img_hilite = NULL;
|
||||||
btn->img_pressed = NULL;
|
btn->img_pressed = NULL;
|
||||||
|
|
||||||
list_append(&btn->link, &parent->child);
|
|
||||||
|
|
||||||
return btn;
|
return btn;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -108,10 +125,10 @@ int draw_button_cairo(button_t *btn)
|
|||||||
int i, j;
|
int i, j;
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
ctx = btn->ctx;
|
ctx = btn->ctrl.ctx;
|
||||||
|
|
||||||
x = btn->rc.l - ctx->offset_x;
|
x = btn->ctrl.rc.l - ctx->offset_x;
|
||||||
y = btn->rc.t - ctx->offset_y;
|
y = btn->ctrl.rc.t - ctx->offset_y;
|
||||||
|
|
||||||
pixmap = ctx->pixmap;
|
pixmap = ctx->pixmap;
|
||||||
|
|
||||||
@ -124,12 +141,12 @@ int draw_button_cairo(button_t *btn)
|
|||||||
else if(btn->state & bHighlight)
|
else if(btn->state & bHighlight)
|
||||||
src = btn->img_hilite;
|
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[j] = src[j];
|
||||||
pixmap+= ctx->stride/4;
|
pixmap+= ctx->stride/4;
|
||||||
src+=btn->w;
|
src+= btn->ctrl.w;
|
||||||
};
|
};
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -163,14 +180,14 @@ int button_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2)
|
|||||||
case MSG_MOUSEENTER:
|
case MSG_MOUSEENTER:
|
||||||
// printf("mouse enter\n");
|
// printf("mouse enter\n");
|
||||||
btn->state|= bHighlight;
|
btn->state|= bHighlight;
|
||||||
send_message(btn, MSG_PAINT, 0, 0);
|
send_message(&btn->ctrl, MSG_PAINT, 0, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_MOUSELEAVE:
|
case MSG_MOUSELEAVE:
|
||||||
// printf("mouse leave\n");
|
// printf("mouse leave\n");
|
||||||
if( (ctrl_t*)btn != mouse_capture) {
|
if( (ctrl_t*)btn != mouse_capture) {
|
||||||
btn->state &= ~bHighlight;
|
btn->state &= ~bHighlight;
|
||||||
send_message(btn, MSG_PAINT, 0, 0);
|
send_message(&btn->ctrl, MSG_PAINT, 0, 0);
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -179,7 +196,7 @@ int button_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2)
|
|||||||
// printf("push button\n");
|
// printf("push button\n");
|
||||||
capture_mouse((ctrl_t*)btn);
|
capture_mouse((ctrl_t*)btn);
|
||||||
btn->state|= bPressed;
|
btn->state|= bPressed;
|
||||||
send_message(btn, MSG_PAINT, 0, 0);
|
send_message(&btn->ctrl, MSG_PAINT, 0, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_LBTNUP:
|
case MSG_LBTNUP:
|
||||||
@ -193,16 +210,16 @@ int button_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2)
|
|||||||
x = ((pos_t)arg2).x;
|
x = ((pos_t)arg2).x;
|
||||||
y = ((pos_t)arg2).y;
|
y = ((pos_t)arg2).y;
|
||||||
|
|
||||||
if( pt_in_rect( &btn->rc, x, y) )
|
if( pt_in_rect( &btn->ctrl.rc, x, y) )
|
||||||
state = bHighlight;
|
state = bHighlight;
|
||||||
else
|
else
|
||||||
state = 0;
|
state = 0;
|
||||||
|
|
||||||
if(action)
|
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;
|
btn->state = state;
|
||||||
send_message(btn, MSG_PAINT, 0, 0);
|
send_message(&btn->ctrl, MSG_PAINT, 0, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_MOUSEMOVE:
|
case MSG_MOUSEMOVE:
|
||||||
@ -216,7 +233,7 @@ int button_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2)
|
|||||||
if( ! (btn->state & bHighlight))
|
if( ! (btn->state & bHighlight))
|
||||||
{
|
{
|
||||||
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)
|
if( (ctrl_t*)btn != mouse_capture)
|
||||||
@ -227,45 +244,63 @@ int button_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2)
|
|||||||
|
|
||||||
old_state = btn->state;
|
old_state = btn->state;
|
||||||
|
|
||||||
if( pt_in_rect(&btn->rc, x, y) )
|
if( pt_in_rect(&btn->ctrl.rc, x, y) )
|
||||||
btn->state |= bPressed;
|
btn->state |= bPressed;
|
||||||
else
|
else
|
||||||
btn->state &= ~bPressed;
|
btn->state &= ~bPressed;
|
||||||
|
|
||||||
if( old_state ^ btn->state)
|
if( old_state ^ btn->state)
|
||||||
send_message(btn, MSG_PAINT, 0, 0);
|
send_message(&btn->ctrl, MSG_PAINT, 0, 0);
|
||||||
}
|
}
|
||||||
return 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;
|
ctx_t *ctx;
|
||||||
int i, j;
|
int i, j;
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
int len;
|
int len = prg->ctrl.w;
|
||||||
|
|
||||||
ctx = prg->ctrl.ctx;
|
ctx = prg->ctrl.ctx;
|
||||||
|
|
||||||
x = prg->ctrl.rc.l - ctx->offset_x;
|
x = prg->ctrl.rc.l - ctx->offset_x;
|
||||||
y = prg->ctrl.rc.t - ctx->offset_y;
|
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);
|
len = prg->current*prg->ctrl.w/(prg->max - prg->min);
|
||||||
|
|
||||||
|
src = res_prg_level;
|
||||||
|
|
||||||
pixmap = ctx->pixmap;
|
pixmap = ctx->pixmap;
|
||||||
|
pixmap+= y*ctx->stride/4 + x;
|
||||||
pixmap+= y*ctx->stride/4 + x;
|
|
||||||
|
|
||||||
src = 0x32ebfb; //btn->img_default;
|
|
||||||
|
|
||||||
for(i=0; i < prg->ctrl.h ;i++)
|
for(i=0; i < prg->ctrl.h ;i++)
|
||||||
{
|
{
|
||||||
for(j=0; j < len; j++)
|
for(j=0; j < len; j++)
|
||||||
pixmap[j] = src;
|
pixmap[j] = *src;
|
||||||
pixmap+= ctx->stride/4;
|
pixmap+= ctx->stride/4;
|
||||||
|
src++;
|
||||||
};
|
};
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -276,19 +311,24 @@ int prg_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2)
|
|||||||
{
|
{
|
||||||
progress_t *prg = (progress_t*)ctrl;
|
progress_t *prg = (progress_t*)ctrl;
|
||||||
int pos;
|
int pos;
|
||||||
|
|
||||||
switch( msg )
|
switch( msg )
|
||||||
{
|
{
|
||||||
case MSG_PAINT:
|
case MSG_PAINT:
|
||||||
draw_progress(prg);
|
draw_progress(prg, 1);
|
||||||
update_rect(ctrl);
|
update_rect(ctrl);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_LBTNDOWN:
|
case MSG_LBTNDOWN:
|
||||||
prg->pos = ((pos_t)arg2).x - ctrl->rc.l;
|
prg->pos = ((pos_t)arg2).x - ctrl->rc.l;
|
||||||
send_message(ctrl->parent,MSG_COMMAND,ctrl->id,(int)ctrl);
|
send_message(ctrl->parent,MSG_COMMAND,ctrl->id,(int)ctrl);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PRG_PROGRESS:
|
||||||
|
draw_progress(prg, 0);
|
||||||
|
update_rect(ctrl);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -305,33 +345,273 @@ progress_t *create_progress(char *caption, int id, int x, int y,
|
|||||||
if( !parent )
|
if( !parent )
|
||||||
return NULL;
|
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.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->min = 0;
|
||||||
prg->max = 1;
|
prg->max = 1;
|
||||||
prg->current = 0;
|
prg->current = 0;
|
||||||
prg->pos = 0;
|
prg->pos = 0;
|
||||||
|
|
||||||
list_append(&prg->ctrl.link, &parent->child);
|
|
||||||
|
|
||||||
return prg;
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "winlib.h"
|
#include "winlib.h"
|
||||||
|
|
||||||
#define CAPTION_HEIGHT 24
|
|
||||||
#define CAPTION_CORNER_W 8
|
#define CAPTION_CORNER_W 8
|
||||||
|
|
||||||
extern int res_caption_left[];
|
extern int res_caption_left[];
|
||||||
@ -20,6 +19,8 @@ extern int res_minimize_btn[];
|
|||||||
extern int res_minimize_btn_hl[];
|
extern int res_minimize_btn_hl[];
|
||||||
extern int res_minimize_btn_pressed[];
|
extern int res_minimize_btn_pressed[];
|
||||||
|
|
||||||
|
extern uint32_t main_cursor;
|
||||||
|
|
||||||
void update_caption_size(window_t *win);
|
void update_caption_size(window_t *win);
|
||||||
|
|
||||||
int caption_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2);
|
int caption_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2);
|
||||||
@ -38,6 +39,8 @@ int init_caption(window_t *win)
|
|||||||
cpt->ctrl.handler = caption_proc;
|
cpt->ctrl.handler = caption_proc;
|
||||||
cpt->ctrl.parent = (ctrl_t*)win;
|
cpt->ctrl.parent = (ctrl_t*)win;
|
||||||
|
|
||||||
|
cpt->text = win->caption_txt;
|
||||||
|
|
||||||
ctx->pixmap = user_alloc(1920*CAPTION_HEIGHT*4);
|
ctx->pixmap = user_alloc(1920*CAPTION_HEIGHT*4);
|
||||||
if(!ctx->pixmap)
|
if(!ctx->pixmap)
|
||||||
{
|
{
|
||||||
@ -102,16 +105,26 @@ void update_caption_size(window_t *win)
|
|||||||
cpt->ctrl.h = CAPTION_HEIGHT;
|
cpt->ctrl.h = CAPTION_HEIGHT;
|
||||||
win->client.t = CAPTION_HEIGHT;
|
win->client.t = CAPTION_HEIGHT;
|
||||||
|
|
||||||
cpt->close_btn->rc.l = win->w - 25;
|
cpt->close_btn->ctrl.rc.l = win->w - 25;
|
||||||
cpt->close_btn->rc.r = cpt->close_btn->rc.l +
|
cpt->close_btn->ctrl.rc.r = cpt->close_btn->ctrl.rc.l +
|
||||||
cpt->close_btn->w;
|
cpt->close_btn->ctrl.w;
|
||||||
|
|
||||||
cpt->minimize_btn->rc.l = win->w - 25 - 16 - 5;
|
cpt->minimize_btn->ctrl.rc.l = win->w - 25 - 16 - 5;
|
||||||
cpt->minimize_btn->rc.r = cpt->minimize_btn->rc.l +
|
cpt->minimize_btn->ctrl.rc.r = cpt->minimize_btn->ctrl.rc.l +
|
||||||
cpt->minimize_btn->w;
|
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)
|
void draw_caption(caption_t *cpt)
|
||||||
{
|
{
|
||||||
@ -157,6 +170,13 @@ void draw_caption(caption_t *cpt)
|
|||||||
src+= CAPTION_CORNER_W;
|
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;
|
ctrl_t *child;
|
||||||
child = (ctrl_t*)cpt->ctrl.child.next;
|
child = (ctrl_t*)cpt->ctrl.child.next;
|
||||||
|
|
||||||
@ -193,18 +213,19 @@ int caption_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2)
|
|||||||
send_message(child, msg, 0, arg2);
|
send_message(child, msg, 0, arg2);
|
||||||
else
|
else
|
||||||
send_message(win->child_over, MSG_MOUSELEAVE, 0, arg2);
|
send_message(win->child_over, MSG_MOUSELEAVE, 0, arg2);
|
||||||
}
|
};
|
||||||
else if( child )
|
|
||||||
send_message(child, MSG_MOUSEENTER, 0, arg2);
|
|
||||||
|
|
||||||
win->child_over = child;
|
win->child_over = child;
|
||||||
if( child )
|
if( child )
|
||||||
|
{
|
||||||
|
send_message(child, MSG_MOUSEENTER, 0, arg2);
|
||||||
send_message(child,msg,0,arg2);
|
send_message(child,msg,0,arg2);
|
||||||
// else if(main_cursor != 0)
|
}
|
||||||
// {
|
else if(main_cursor != 0)
|
||||||
// set_cursor(0);
|
{
|
||||||
// main_cursor = 0;
|
set_cursor(0);
|
||||||
// }
|
main_cursor = 0;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
BIN
programs/media/Fplay/winlib/caption_body.raw
Normal file
BIN
programs/media/Fplay/winlib/caption_body.raw
Normal file
Binary file not shown.
BIN
programs/media/Fplay/winlib/caption_left.raw
Normal file
BIN
programs/media/Fplay/winlib/caption_left.raw
Normal file
Binary file not shown.
BIN
programs/media/Fplay/winlib/caption_right.raw
Normal file
BIN
programs/media/Fplay/winlib/caption_right.raw
Normal file
Binary file not shown.
1
programs/media/Fplay/winlib/close_button.raw
Normal file
1
programs/media/Fplay/winlib/close_button.raw
Normal file
@ -0,0 +1 @@
|
|||||||
|
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˙
|
1
programs/media/Fplay/winlib/close_button_pressed.raw
Normal file
1
programs/media/Fplay/winlib/close_button_pressed.raw
Normal file
@ -0,0 +1 @@
|
|||||||
|
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˙¬©˙’<CB99>Ś˙XSO˙VPL˙XSO˙’<CB99>Ś˙¬©˙VPL˙VPL˙VPL˙VPL˙[VR˙UOL˙RLH˙RLH˙RLH˙RLH˙<48>ŤŠ˙«Ş§˙”‘Ž˙WQL˙”‘Ž˙«Ş§˙<C2A7>ŤŠ˙RLH˙RLH˙RLH˙RLH˙UOL˙PJF˙OIE˙OIE˙OIE˙OIE˙UNJ˙<4A>ŽŠ˙ިĄ˙›<CB99>–˙ިĄ˙<C484>ŽŠ˙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˙<31>~z˙žś™˙ŤŠ‡˙žś™˙<E284A2>~z˙=61˙70+˙70+˙70+˙70+˙81,˙:3/˙70+˙70+˙70+˙70+˙~{w˙žś™˙<E284A2>€|˙<50˙<30>€|˙žś™˙~{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˙
|
@ -54,19 +54,7 @@ typedef struct timer
|
|||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
link_t link;
|
ctrl_t ctrl;
|
||||||
link_t child;
|
|
||||||
|
|
||||||
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;
|
uint32_t state;
|
||||||
ostimer_t timer;
|
ostimer_t timer;
|
||||||
@ -88,6 +76,30 @@ typedef struct
|
|||||||
int pos;
|
int pos;
|
||||||
}progress_t;
|
}progress_t;
|
||||||
|
|
||||||
|
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
|
typedef struct
|
||||||
{
|
{
|
||||||
link_t link;
|
link_t link;
|
||||||
@ -148,17 +160,18 @@ typedef struct
|
|||||||
#define MSG_COMMAND 0x030
|
#define MSG_COMMAND 0x030
|
||||||
#define MSG_TIMER 0x031
|
#define MSG_TIMER 0x031
|
||||||
|
|
||||||
|
|
||||||
#define LBN_DBLCLK 0x100
|
#define LBN_DBLCLK 0x100
|
||||||
#define LBOX_READDIR 0x100
|
#define LBOX_READDIR 0x100
|
||||||
#define LBOX_GETFILENAME 0x101
|
#define LBOX_GETFILENAME 0x101
|
||||||
|
|
||||||
#define ID_CLOSE 1
|
#define PRG_PROGRESS 0x102
|
||||||
#define ID_MINIMIZE 2
|
|
||||||
|
|
||||||
#define ID_SCROLLER_UP 10
|
#define ID_CLOSE 1
|
||||||
#define ID_SCROLLER_DOWN 11
|
#define ID_MINIMIZE 2
|
||||||
#define ID_SCROLLER_THUMB 12
|
|
||||||
|
#define ID_SCROLLER_UP 10
|
||||||
|
#define ID_SCROLLER_DOWN 11
|
||||||
|
#define ID_SCROLLER_THUMB 12
|
||||||
|
|
||||||
#define send_message( ctrl, msg, arg1, arg2) \
|
#define send_message( ctrl, msg, arg1, arg2) \
|
||||||
(ctrl)->handler( (ctrl_t*)(ctrl), \
|
(ctrl)->handler( (ctrl_t*)(ctrl), \
|
||||||
|
Binary file not shown.
Binary file not shown.
150
programs/media/Fplay/winlib/fontlib.c
Normal file
150
programs/media/Fplay/winlib/fontlib.c
Normal file
@ -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);
|
||||||
|
|
@ -5,7 +5,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "winlib.h"
|
#include "winlib.h"
|
||||||
|
|
||||||
#define CAPTION_HEIGHT 29
|
|
||||||
#define CAPTION_CORNER_W 8
|
#define CAPTION_CORNER_W 8
|
||||||
#define FRAME_WIDTH 7
|
#define FRAME_WIDTH 7
|
||||||
|
|
||||||
@ -271,8 +270,8 @@ int frame_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2)
|
|||||||
w = nrc.r - nrc.l;
|
w = nrc.r - nrc.l;
|
||||||
h = nrc.b - nrc.t;
|
h = nrc.b - nrc.t;
|
||||||
|
|
||||||
if(w < 150)
|
if(w <310)
|
||||||
w = 150;
|
w = 310;
|
||||||
if(h < 120)
|
if(h < 120)
|
||||||
h = 120;
|
h = 120;
|
||||||
|
|
||||||
|
1
programs/media/Fplay/winlib/minimize_btn.raw
Normal file
1
programs/media/Fplay/winlib/minimize_btn.raw
Normal file
@ -0,0 +1 @@
|
|||||||
|
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˙
|
1
programs/media/Fplay/winlib/minimize_btn_pressed.raw
Normal file
1
programs/media/Fplay/winlib/minimize_btn_pressed.raw
Normal file
@ -0,0 +1 @@
|
|||||||
|
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+˙š<CB99>•˙š<CB99>•˙š<CB99>•˙š<CB99>•˙š<CB99>•˙š<CB99>•˙š<CB99>•˙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˙
|
@ -4,11 +4,14 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "winlib.h"
|
#include "winlib.h"
|
||||||
|
|
||||||
#define PANEL_HEIGHT 55
|
#define PANEL_CORNER_W 8
|
||||||
#define PANEL_CORNER_W 16
|
|
||||||
#define FRAME_WIDTH 7
|
#define FRAME_WIDTH 7
|
||||||
|
|
||||||
#define ID_PLAY 100
|
#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;
|
extern uint32_t main_cursor;
|
||||||
|
|
||||||
@ -22,6 +25,9 @@ extern int res_play_btn_pressed[];
|
|||||||
extern int res_pause_btn[];
|
extern int res_pause_btn[];
|
||||||
extern int res_pause_btn_pressed[];
|
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[];
|
||||||
//extern int res_minimize_btn_hl[];
|
//extern int res_minimize_btn_hl[];
|
||||||
//extern int res_minimize_btn_pressed[];
|
//extern int res_minimize_btn_pressed[];
|
||||||
@ -34,6 +40,8 @@ int init_panel(window_t *win)
|
|||||||
{
|
{
|
||||||
button_t *btn;
|
button_t *btn;
|
||||||
progress_t *prg;
|
progress_t *prg;
|
||||||
|
level_t *lvl;
|
||||||
|
slider_t *sld;
|
||||||
|
|
||||||
panel_t *panel = &win->panel;
|
panel_t *panel = &win->panel;
|
||||||
ctx_t *ctx = &panel->ctx;
|
ctx_t *ctx = &panel->ctx;
|
||||||
@ -44,6 +52,8 @@ int init_panel(window_t *win)
|
|||||||
panel->ctrl.handler = panel_proc;
|
panel->ctrl.handler = panel_proc;
|
||||||
panel->ctrl.parent = (ctrl_t*)win;
|
panel->ctrl.parent = (ctrl_t*)win;
|
||||||
|
|
||||||
|
panel->layout = 0;
|
||||||
|
|
||||||
ctx->pixmap = user_alloc(1920*PANEL_HEIGHT*4);
|
ctx->pixmap = user_alloc(1920*PANEL_HEIGHT*4);
|
||||||
if(!ctx->pixmap)
|
if(!ctx->pixmap)
|
||||||
{
|
{
|
||||||
@ -63,9 +73,23 @@ int init_panel(window_t *win)
|
|||||||
btn->img_hilite = res_pause_btn;
|
btn->img_hilite = res_pause_btn;
|
||||||
btn->img_pressed = res_pause_btn_pressed;
|
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;
|
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);
|
// btn = create_button(NULL, ID_MINIMIZE,0,5,16,18,(ctrl_t*)cpt);
|
||||||
// cpt->minimize_btn = btn;
|
// cpt->minimize_btn = btn;
|
||||||
|
|
||||||
@ -73,11 +97,60 @@ int init_panel(window_t *win)
|
|||||||
// btn->img_hilite = res_minimize_btn_hl;
|
// btn->img_hilite = res_minimize_btn_hl;
|
||||||
// btn->img_pressed = res_minimize_btn_pressed;
|
// btn->img_pressed = res_minimize_btn_pressed;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
update_panel_size(win);
|
update_panel_size(win);
|
||||||
|
|
||||||
return 1;
|
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)
|
void update_panel_size(window_t *win)
|
||||||
{
|
{
|
||||||
panel_t *panel = &win->panel;
|
panel_t *panel = &win->panel;
|
||||||
@ -115,25 +188,22 @@ void update_panel_size(window_t *win)
|
|||||||
panel->ctrl.h = PANEL_HEIGHT;
|
panel->ctrl.h = PANEL_HEIGHT;
|
||||||
win->client.b = win->h-PANEL_HEIGHT;
|
win->client.b = win->h-PANEL_HEIGHT;
|
||||||
|
|
||||||
panel->play_btn->rc.l = win->w/2 - 16;
|
panel->play_btn->ctrl.rc.l = win->w/2 - 16;
|
||||||
panel->play_btn->rc.t = panel->ctrl.rc.t+19;
|
panel->play_btn->ctrl.rc.t = panel->ctrl.rc.t+19;
|
||||||
panel->play_btn->rc.r = panel->play_btn->rc.l + panel->play_btn->w;
|
panel->play_btn->ctrl.rc.r = panel->play_btn->ctrl.rc.l + panel->play_btn->ctrl.w;
|
||||||
panel->play_btn->rc.b = panel->play_btn->rc.t + panel->play_btn->h;
|
panel->play_btn->ctrl.rc.b = panel->play_btn->ctrl.rc.t + panel->play_btn->ctrl.h;
|
||||||
|
|
||||||
panel->prg->ctrl.rc.l = 8;
|
panel->stop_btn->ctrl.rc.l = win->w/2 - 44;
|
||||||
panel->prg->ctrl.rc.t = panel->ctrl.rc.t+7;
|
panel->stop_btn->ctrl.rc.t = panel->ctrl.rc.t+23;
|
||||||
panel->prg->ctrl.rc.r = panel->ctrl.rc.r-8;
|
panel->stop_btn->ctrl.rc.r = panel->stop_btn->ctrl.rc.l + panel->stop_btn->ctrl.w;
|
||||||
panel->prg->ctrl.rc.b = panel->prg->ctrl.rc.t+8;
|
panel->stop_btn->ctrl.rc.b = panel->stop_btn->ctrl.rc.t + panel->stop_btn->ctrl.h;
|
||||||
panel->prg->ctrl.w = panel->prg->ctrl.rc.r -
|
|
||||||
panel->prg->ctrl.rc.l;
|
|
||||||
|
|
||||||
panel->prg->ctrl.h = panel->prg->ctrl.rc.b -
|
panel->sld->ctrl.rc.l = panel->ctrl.rc.l;
|
||||||
panel->prg->ctrl.rc.t;
|
panel->sld->ctrl.rc.t = panel->ctrl.rc.t+28;
|
||||||
|
panel->sld->ctrl.rc.r = panel->sld->ctrl.rc.l + panel->sld->ctrl.w;
|
||||||
// cpt->minimize_btn->rc.l = win->w - 25 - 16 - 5;
|
panel->sld->ctrl.rc.b = panel->sld->ctrl.rc.t + panel->sld->ctrl.h;
|
||||||
// cpt->minimize_btn->rc.r = cpt->minimize_btn->rc.l +
|
|
||||||
// cpt->minimize_btn->w;
|
|
||||||
|
|
||||||
|
panel_update_layout(panel);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -234,7 +304,9 @@ int panel_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2)
|
|||||||
switch((short)arg1)
|
switch((short)arg1)
|
||||||
{
|
{
|
||||||
case ID_PLAY:
|
case ID_PLAY:
|
||||||
case 101:
|
case ID_STOP:
|
||||||
|
case ID_PROGRESS:
|
||||||
|
case ID_VOL_CTRL:
|
||||||
win = get_parent_window(ctrl);
|
win = get_parent_window(ctrl);
|
||||||
send_message(win, msg, arg1, arg2);
|
send_message(win, msg, arg1, arg2);
|
||||||
break;
|
break;
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
programs/media/Fplay/winlib/pbar.raw
Normal file
BIN
programs/media/Fplay/winlib/pbar.raw
Normal file
Binary file not shown.
BIN
programs/media/Fplay/winlib/prg_level.raw
Normal file
BIN
programs/media/Fplay/winlib/prg_level.raw
Normal file
Binary file not shown.
@ -25,14 +25,26 @@ public _res_play_btn_pressed
|
|||||||
public _res_pause_btn
|
public _res_pause_btn
|
||||||
public _res_pause_btn_pressed
|
public _res_pause_btn_pressed
|
||||||
|
|
||||||
|
public _res_stop_btn
|
||||||
|
public _res_stop_btn_pressed
|
||||||
|
|
||||||
|
|
||||||
public _res_cursor_ns
|
public _res_cursor_ns
|
||||||
public _res_cursor_we
|
public _res_cursor_we
|
||||||
public _res_cursor_nwse
|
public _res_cursor_nwse
|
||||||
public _res_cursor_nesw
|
public _res_cursor_nesw
|
||||||
|
|
||||||
section '.rdata' data readable align 16
|
;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_left: file 'cptleft.raw'
|
||||||
_res_caption_right: file 'cptright.raw'
|
_res_caption_right: file 'cptright.raw'
|
||||||
@ -54,6 +66,9 @@ _res_play_btn_pressed: file 'playbp.raw'
|
|||||||
_res_pause_btn: file 'pausebtn.raw'
|
_res_pause_btn: file 'pausebtn.raw'
|
||||||
_res_pause_btn_pressed: file 'pausebp.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: file 'minbn.raw'
|
||||||
_res_minimize_btn_hl: file 'minbhl.raw'
|
_res_minimize_btn_hl: file 'minbhl.raw'
|
||||||
@ -63,3 +78,12 @@ _res_cursor_ns: file 'size_ns.cur'
|
|||||||
_res_cursor_we: file 'size_we.cur'
|
_res_cursor_we: file 'size_we.cur'
|
||||||
_res_cursor_nwse: file 'size_nwse.cur'
|
_res_cursor_nwse: file 'size_nwse.cur'
|
||||||
_res_cursor_nesw: file 'size_nesw.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'
|
||||||
|
1
programs/media/Fplay/winlib/slider.raw
Normal file
1
programs/media/Fplay/winlib/slider.raw
Normal file
@ -0,0 +1 @@
|
|||||||
|
<1C><1C><1C>\\\<5C>靠<EFBFBD><E99DA0>祆<EFBFBD><E7A586>蝌<EFBFBD><E89D8C>哪<EFBFBD><E593AA>ggg<67><1C><1C><1C><1C><1C>湝<EFBFBD><E6B99D><EFBFBD><EFBFBD><EFBFBD>篌<EFBFBD><E7AF8C>蝌<EFBFBD><E89D8C>貂<EFBFBD><E8B282><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>膊<EFBFBD><E8868A><1F><1C><1C>sss<73>耨<EFBFBD><E880A8>哌<EFBFBD><E5938C>乙<EFBFBD><E4B999>佑<EFBFBD><E4BD91>揶<EFBFBD><E68FB6>瘃<EFBFBD><E79883><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>墘<EFBFBD><E5A298><1C><1C>佑<EFBFBD><E4BD91>刎<EFBFBD><E5888E>靠<EFBFBD><E99DA0>创<EFBFBD><E5889B>构<EFBFBD><E69E84>蜒<EFBFBD><E89C92>耱<EFBFBD><E880B1><EFBFBD><EFBFBD><EFBFBD>貂<EFBFBD><E8B282>珑<EFBFBD><E78F91><03>...<2E>沣<EFBFBD><E6B2A3>缮<EFBFBD><E7BCAE>构<EFBFBD><E69E84>北<EFBFBD><E58C97><EFBFBD><EFBFBD><EFBFBD>行<EFBFBD><E8A18C>鼬<EFBFBD><E9BCAC>滗<EFBFBD><E6BB97>噜<EFBFBD><E5999C>觋<EFBFBD><E8A78B>444<34>:::<3A>苘<EFBFBD><E88B98>烫<EFBFBD><E783AB>缮<EFBFBD><E7BCAE>缮<EFBFBD><E7BCAE>缮<EFBFBD><E7BCAE>破<EFBFBD><E7A0B4>破<EFBFBD><E7A0B4>破<EFBFBD><E7A0B4>热<EFBFBD><E783AD>刎<EFBFBD><E5888E>AAA<41>!!!<21>栽<EFBFBD><E6A0BD>鬃<EFBFBD><E9AC83>揶<EFBFBD><E68FB6>殚<EFBFBD><E6AE9A><EFBFBD><EFBFBD><EFBFBD>栽<EFBFBD><E6A0BD><EFBFBD><EFBFBD><EFBFBD>鞍<EFBFBD><E99E8D>档<EFBFBD><E6A1A3>乔<EFBFBD><E4B994><10><1C>拻<EFBFBD><E68BBB>殚<EFBFBD><E6AE9A>蝌<EFBFBD><E89D8C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>栽<EFBFBD><E6A0BD>构<EFBFBD><E69E84><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>崓<EFBFBD><E5B493>000<30><1C>...<2E>鬃<EFBFBD><E9AC83><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>镲<EFBFBD><E995B2>栽<EFBFBD><E6A0BD>亮<EFBFBD><E4BAAE>吵<EFBFBD><E590B5> <EFBFBD><E38080>(((<28><1C><1C><1C>)))<29><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>梃<EFBFBD><E6A283>栽<EFBFBD><E6A0BD>破<EFBFBD><E7A0B4>垐<EFBFBD><E59E90>---<2D><1C><1C><1C><1C><1C><1C>333<33>```<60>___<5F>333<33><1C><1C><1C><1C>
|
BIN
programs/media/Fplay/winlib/stopbtn.raw
Normal file
BIN
programs/media/Fplay/winlib/stopbtn.raw
Normal file
Binary file not shown.
BIN
programs/media/Fplay/winlib/stopbtnp.raw
Normal file
BIN
programs/media/Fplay/winlib/stopbtnp.raw
Normal file
Binary file not shown.
BIN
programs/media/Fplay/winlib/vol_level.raw
Normal file
BIN
programs/media/Fplay/winlib/vol_level.raw
Normal file
Binary file not shown.
BIN
programs/media/Fplay/winlib/vol_slider.raw
Normal file
BIN
programs/media/Fplay/winlib/vol_slider.raw
Normal file
Binary file not shown.
@ -16,6 +16,9 @@ uint32_t cursor_we;
|
|||||||
uint32_t cursor_nwse;
|
uint32_t cursor_nwse;
|
||||||
uint32_t cursor_nesw;
|
uint32_t cursor_nesw;
|
||||||
|
|
||||||
|
int win_font;
|
||||||
|
|
||||||
|
|
||||||
static pos_t old_pos;
|
static pos_t old_pos;
|
||||||
|
|
||||||
ctrl_t *mouse_capture = NULL;
|
ctrl_t *mouse_capture = NULL;
|
||||||
@ -514,9 +517,26 @@ int init_resources()
|
|||||||
cursor_we = load_cursor(res_cursor_we, LOAD_FROM_MEM);
|
cursor_we = load_cursor(res_cursor_we, LOAD_FROM_MEM);
|
||||||
cursor_nwse = load_cursor(res_cursor_nwse, LOAD_FROM_MEM);
|
cursor_nwse = load_cursor(res_cursor_nwse, LOAD_FROM_MEM);
|
||||||
cursor_nesw = load_cursor(res_cursor_nesw, LOAD_FROM_MEM);
|
cursor_nesw = load_cursor(res_cursor_nesw, LOAD_FROM_MEM);
|
||||||
|
|
||||||
|
win_font = init_fontlib();
|
||||||
|
|
||||||
return 1;
|
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)
|
void init_winlib(void)
|
||||||
{
|
{
|
||||||
__asm__ __volatile__(
|
__asm__ __volatile__(
|
||||||
@ -569,7 +589,7 @@ void Blit(void *bitmap, int dst_x, int dst_y,
|
|||||||
|
|
||||||
__asm__ __volatile__(
|
__asm__ __volatile__(
|
||||||
"int $0x40"
|
"int $0x40"
|
||||||
::"a"(73),"b"(0),"c"(&bc.dstx));
|
::"a"(73),"b"(0x20),"c"(&bc.dstx));
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
|
|
||||||
#include "control.h"
|
#include "control.h"
|
||||||
|
|
||||||
|
#define CAPTION_HEIGHT 24
|
||||||
|
#define PANEL_HEIGHT 55
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
link_t link;
|
link_t link;
|
||||||
@ -31,6 +34,7 @@ typedef struct
|
|||||||
{
|
{
|
||||||
ctrl_t ctrl;
|
ctrl_t ctrl;
|
||||||
ctx_t ctx;
|
ctx_t ctx;
|
||||||
|
char *text;
|
||||||
ctrl_t *child_over;
|
ctrl_t *child_over;
|
||||||
button_t *close_btn;
|
button_t *close_btn;
|
||||||
button_t *minimize_btn;
|
button_t *minimize_btn;
|
||||||
@ -43,8 +47,12 @@ typedef struct
|
|||||||
ctx_t ctx;
|
ctx_t ctx;
|
||||||
rect_t draw;
|
rect_t draw;
|
||||||
ctrl_t *child_over;
|
ctrl_t *child_over;
|
||||||
|
int layout;
|
||||||
progress_t *prg;
|
progress_t *prg;
|
||||||
|
level_t *lvl;
|
||||||
|
slider_t *sld;
|
||||||
button_t *play_btn;
|
button_t *play_btn;
|
||||||
|
button_t *stop_btn;
|
||||||
}panel_t;
|
}panel_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@ -108,12 +116,13 @@ int def_window_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2);
|
|||||||
void frame_run(window_t *win);
|
void frame_run(window_t *win);
|
||||||
|
|
||||||
button_t *create_button(char *caption, int id, int x, int y,
|
button_t *create_button(char *caption, int id, int x, int y,
|
||||||
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);
|
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,
|
scroller_t *create_scroller(uint32_t style, int id, int x, int y,
|
||||||
int w, int h, ctrl_t *parent);
|
int w, int h, ctrl_t *parent);
|
||||||
|
|
||||||
//static uint32_t update_timers(uint32_t realtime);
|
//static uint32_t update_timers(uint32_t realtime);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user