Check-in [27f5c22f2a]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Debugged media player example
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 27f5c22f2ad10680890131dff3aad90866c2ed5d
User & Date: bernd 2014-01-20 22:31:17
Context
2014-01-20
22:42
removed blank-screen check-in: ad46395251 user: bernd tags: trunk
22:31
Debugged media player example check-in: 27f5c22f2a user: bernd tags: trunk
01:51
Objtain class directly check-in: e4fd5c80fd user: bernd tags: trunk
Changes

Changes to gl-terminal.fs.

115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
    count s>f $FF fm/
    c@    s>f $FF fm/ glClearColor ;

: std-bg! ( index -- )  dup bg! dup std-bg ! bg>clear ;

: >white White std-bg! Black fg! ;
: >black Black std-bg! White fg! ;
>white

128 Value videocols
1   Value videorows

2Variable gl-xy  0 0 gl-xy 2!
2Variable gl-wh 24 80 gl-wh 2!
Variable gl-lineend







|







115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
    count s>f $FF fm/
    c@    s>f $FF fm/ glClearColor ;

: std-bg! ( index -- )  dup bg! dup std-bg ! bg>clear ;

: >white White std-bg! Black fg! ;
: >black Black std-bg! White fg! ;
>black \ make black default

128 Value videocols
1   Value videorows

2Variable gl-xy  0 0 gl-xy 2!
2Variable gl-wh 24 80 gl-wh 2!
Variable gl-lineend

Changes to gles2/gl-terminal.fs.

115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
    count s>f $FF fm/
    c@    s>f $FF fm/ glClearColor ;

: std-bg! ( index -- )  dup bg! dup std-bg ! bg>clear ;

: >white White std-bg! Black fg! ;
: >black Black std-bg! White fg! ;
>white

128 Value videocols
1   Value videorows

2Variable gl-xy  0 0 gl-xy 2!
2Variable gl-wh 24 80 gl-wh 2!
Variable gl-lineend







|







115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
    count s>f $FF fm/
    c@    s>f $FF fm/ glClearColor ;

: std-bg! ( index -- )  dup bg! dup std-bg ! bg>clear ;

: >white White std-bg! Black fg! ;
: >black Black std-bg! White fg! ;
>black \ make black default

128 Value videocols
1   Value videorows

2Variable gl-xy  0 0 gl-xy 2!
2Variable gl-wh 24 80 gl-wh 2!
Variable gl-lineend

Changes to gles2/omx-example.fs.

173
174
175
176
177
178
179





180
181
182
183
184
185
186
187
188
189


190

191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
...
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249








250
251
252
253
254
255
256

257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
...
281
282
283
284
285
286
287

288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
: ppause ( -- )
    playitf XA_PLAYSTATE_PAUSED playitf XAPlayItf-SetPlayState() ?success ;
: pplay ( -- )
    playitf XA_PLAYSTATE_PLAYING playitf XAPlayItf-SetPlayState() ?success ;
: pvol ( n -- )
    volitf swap volitf XAVolumeItf-SetVolumeLevel() ?success ;






: setup-player ( -- )  player IF
	destroy-player
    ELSE
	create-stuff
    THEN
    create-media create-player
    get-interfaces set-callbacks
    init-mediaplayer  ;
: stop-player ( -- )  mediaplayer0 >o mp-pause o> ;



0 Value pvol#

: start-file ( -- )
    setup-player  true init-enqueue  ppause pvol# pvol ;

also opengl

0 Value oes-program

: omx-init ( -- ) create-oes-program to oes-program ;

also android

\ vertices

0.005e Fconstant m-lr
FVariable first-timestamp  0e first-timestamp f!
: get-deltat ( -- f )
    media-sft >o getTimestamp o> d>f 1e-9 f*
    first-timestamp f@ f- ;
: set-deltat ( -- f ) get-deltat mkv-time-off f@ f- first-timestamp f! ;

: get-m ( -- r% ) ts-fd 0= IF
	get-deltat mkv-file-o >o total-duration f@ o> f/
................................................................................

2Variable lastseek
500.000 2Constant delta-seek \ 0.5 seconds
5.000.000 2Constant hide-cursor

true value show-mcursor

: draw-frame ( -- )
    oes-program init
    unit-matrix MVPMatrix set-matrix
    unit-matrix MVMatrix set-matrix
    media-sft >o updateTexImage o>
    first-timestamp f@ f0= IF  set-deltat  THEN
    0e fdup fdup 1.0e glClearColor clear
    Ambient 1 ambient% glUniform1fv
    media-tex nearest-oes








    v0 i0 rectangle
    show-mcursor IF
	hide-cursor utime lastseek 2@ d- 2over dmin d-
	d>f hide-cursor d>f f/ triangle
    THEN
    GL_TRIANGLES draw-elements
    sync ;


: >pos ( r -- )
    ts-fd IF  >rai  ELSE
	0e first-timestamp f!
	mkv-file-o >o >cue o>
	<event elit, ->cues cue-task event>  THEN ;

: queue-flush ( -- )
    cues>mts-run? IF
	<event ->cue-abort cue-task event>
    THEN  clear-queue ;

: check-input ( -- )
    >looper
    ekey? IF ekey CASE
	    k-up   of pvol# 200 + 0 min dup to pvol# pvol endof 
	    k-down of pvol# 200 - dup       to pvol# pvol endof 
	ENDCASE THEN 
    *input >r r@ IF
................................................................................
		2dup 2 1 d= IF  pplay? IF
			ppause
			get-deltat mkv-time-off f! 0e first-timestamp f!
		    ELSE pplay THEN  THEN
		dup 2 = IF
		    r@ x0 @ s>f dpy-w @ fm/ 1.1e f* 0.05e f- 0e fmax 1e fmin
		    pplay? IF  ppause  THEN

		    queue-flush  >pos  true init-enqueue pplay
		THEN
		2drop
		utime lastseek 2!
	    THEN
	THEN  r@ action off
    THEN
    rdrop ;

: play-loop ( -- ) hidekb
    screen+keep pplay
    omx-init 1 level# +!
    BEGIN
	draw-frame check-input
	cues>mts-run? 0= pplay? and  IF  ppause  THEN
    level# @ 0= UNTIL
    ppause screen-keep ;
: play-ts ( addr u -- ) ['] read-ts-file is read-ts
    open-mts start-file play-loop ;







>
>
>
>
>








|

>
>

>
|






|






|







 







|
|


<
<
|

|
>
>
>
>
>
>
>
>
|
|
|
|
|
|
<
>







<
<
<
<
<







 







>
|










|







173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
...
242
243
244
245
246
247
248
249
250
251
252


253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269

270
271
272
273
274
275
276
277





278
279
280
281
282
283
284
...
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
: ppause ( -- )
    playitf XA_PLAYSTATE_PAUSED playitf XAPlayItf-SetPlayState() ?success ;
: pplay ( -- )
    playitf XA_PLAYSTATE_PLAYING playitf XAPlayItf-SetPlayState() ?success ;
: pvol ( n -- )
    volitf swap volitf XAVolumeItf-SetVolumeLevel() ?success ;

: queue-flush ( -- )
    cues>mts-run? IF
	<event ->cue-abort cue-task event>
    THEN  clear-queue ;

: setup-player ( -- )  player IF
	destroy-player
    ELSE
	create-stuff
    THEN
    create-media create-player
    get-interfaces set-callbacks
    init-mediaplayer  ;
: stop-player ( -- )  mediaplayer0 >o mp-pause o> queue-flush ;

FVariable first-timestamp  0e first-timestamp f!
FVariable prev-timestamp
0 Value pvol#

: start-file ( -- )  0e first-timestamp f!  0e mkv-time-off f!
    setup-player  true init-enqueue  ppause pvol# pvol ;

also opengl

0 Value oes-program

: omx-init ( -- ) create-oes-program to oes-program  oes-program init ;

also android

\ vertices

0.005e Fconstant m-lr

: get-deltat ( -- f )
    media-sft >o getTimestamp o> d>f 1e-9 f*
    first-timestamp f@ f- ;
: set-deltat ( -- f ) get-deltat mkv-time-off f@ f- first-timestamp f! ;

: get-m ( -- r% ) ts-fd 0= IF
	get-deltat mkv-file-o >o total-duration f@ o> f/
................................................................................

2Variable lastseek
500.000 2Constant delta-seek \ 0.5 seconds
5.000.000 2Constant hide-cursor

true value show-mcursor

: init-frame ( -- )
    oes-program glUseProgram
    unit-matrix MVPMatrix set-matrix
    unit-matrix MVMatrix set-matrix


    0e fdup fdup 1.0e glClearColor
    Ambient 1 ambient% glUniform1fv
    media-tex nearest-oes ;

: draw-frame ( -- )
    init-frame clear
    media-sft >o getTimestamp d>f 1e-9 f* prev-timestamp f!
    updateTexImage o>
    prev-timestamp f@ first-timestamp f@ f<> IF
	first-timestamp f@ f0=
	IF  set-deltat  THEN
	v0 i0 rectangle
	show-mcursor IF
	    hide-cursor utime lastseek 2@ d- 2over dmin d-
	    d>f hide-cursor d>f f/ triangle
	THEN
	GL_TRIANGLES draw-elements  sync

    THEN ;

: >pos ( r -- )
    ts-fd IF  >rai  ELSE
	0e first-timestamp f!
	mkv-file-o >o >cue o>
	<event elit, ->cues cue-task event>  THEN ;






: check-input ( -- )
    >looper
    ekey? IF ekey CASE
	    k-up   of pvol# 200 + 0 min dup to pvol# pvol endof 
	    k-down of pvol# 200 - dup       to pvol# pvol endof 
	ENDCASE THEN 
    *input >r r@ IF
................................................................................
		2dup 2 1 d= IF  pplay? IF
			ppause
			get-deltat mkv-time-off f! 0e first-timestamp f!
		    ELSE pplay THEN  THEN
		dup 2 = IF
		    r@ x0 @ s>f dpy-w @ fm/ 1.1e f* 0.05e f- 0e fmax 1e fmin
		    pplay? IF  ppause  THEN
		    queue-flush
		    >pos  true init-enqueue pplay
		THEN
		2drop
		utime lastseek 2!
	    THEN
	THEN  r@ action off
    THEN
    rdrop ;

: play-loop ( -- ) hidekb
    screen+keep pplay
    omx-init init-frame 1 level# +!
    BEGIN
	draw-frame check-input
	cues>mts-run? 0= pplay? and  IF  ppause  THEN
    level# @ 0= UNTIL
    ppause screen-keep ;
: play-ts ( addr u -- ) ['] read-ts-file is read-ts
    open-mts start-file play-loop ;

Changes to omx-example.fs.

173
174
175
176
177
178
179





180
181
182
183
184
185
186
187
188
189


190

191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
...
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249








250
251
252
253
254
255
256

257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
...
281
282
283
284
285
286
287

288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
: ppause ( -- )
    playitf XA_PLAYSTATE_PAUSED playitf XAPlayItf-SetPlayState() ?success ;
: pplay ( -- )
    playitf XA_PLAYSTATE_PLAYING playitf XAPlayItf-SetPlayState() ?success ;
: pvol ( n -- )
    volitf swap volitf XAVolumeItf-SetVolumeLevel() ?success ;






: setup-player ( -- )  player IF
	destroy-player
    ELSE
	create-stuff
    THEN
    create-media create-player
    get-interfaces set-callbacks
    init-mediaplayer  ;
: stop-player ( -- )  mediaplayer0 >o mp-pause o> ;



0 Value pvol#

: start-file ( -- )
    setup-player  true init-enqueue  ppause pvol# pvol ;

also opengl

0 Value oes-program

: omx-init ( -- ) create-oes-program to oes-program ;

also android

\ vertices

0.005e Fconstant m-lr
FVariable first-timestamp  0e first-timestamp f!
: get-deltat ( -- f )
    media-sft >o getTimestamp o> d>f 1e-9 f*
    first-timestamp f@ f- ;
: set-deltat ( -- f ) get-deltat mkv-time-off f@ f- first-timestamp f! ;

: get-m ( -- r% ) ts-fd 0= IF
	get-deltat mkv-file-o >o total-duration f@ o> f/
................................................................................

2Variable lastseek
500.000 2Constant delta-seek \ 0.5 seconds
5.000.000 2Constant hide-cursor

true value show-mcursor

: draw-frame ( -- )
    oes-program init
    unit-matrix MVPMatrix set-matrix
    unit-matrix MVMatrix set-matrix
    media-sft >o updateTexImage o>
    first-timestamp f@ f0= IF  set-deltat  THEN
    0e fdup fdup 1.0e glClearColor clear
    Ambient 1 ambient% glUniform1fv
    media-tex nearest-oes








    v0 i0 rectangle
    show-mcursor IF
	hide-cursor utime lastseek 2@ d- 2over dmin d-
	d>f hide-cursor d>f f/ triangle
    THEN
    GL_TRIANGLES draw-elements
    sync ;


: >pos ( r -- )
    ts-fd IF  >rai  ELSE
	0e first-timestamp f!
	mkv-file-o >o >cue o>
	<event elit, ->cues cue-task event>  THEN ;

: queue-flush ( -- )
    cues>mts-run? IF
	<event ->cue-abort cue-task event>
    THEN  clear-queue ;

: check-input ( -- )
    >looper
    ekey? IF ekey CASE
	    k-up   of pvol# 200 + 0 min dup to pvol# pvol endof 
	    k-down of pvol# 200 - dup       to pvol# pvol endof 
	ENDCASE THEN 
    *input >r r@ IF
................................................................................
		2dup 2 1 d= IF  pplay? IF
			ppause
			get-deltat mkv-time-off f! 0e first-timestamp f!
		    ELSE pplay THEN  THEN
		dup 2 = IF
		    r@ x0 @ s>f dpy-w @ fm/ 1.1e f* 0.05e f- 0e fmax 1e fmin
		    pplay? IF  ppause  THEN

		    queue-flush  >pos  true init-enqueue pplay
		THEN
		2drop
		utime lastseek 2!
	    THEN
	THEN  r@ action off
    THEN
    rdrop ;

: play-loop ( -- ) hidekb
    screen+keep pplay
    omx-init 1 level# +!
    BEGIN
	draw-frame check-input
	cues>mts-run? 0= pplay? and  IF  ppause  THEN
    level# @ 0= UNTIL
    ppause screen-keep ;
: play-ts ( addr u -- ) ['] read-ts-file is read-ts
    open-mts start-file play-loop ;







>
>
>
>
>








|

>
>

>
|






|






|







 







|
|


<
<
|

|
>
>
>
>
>
>
>
>
|
|
|
|
|
|
<
>







<
<
<
<
<







 







>
|










|







173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
...
242
243
244
245
246
247
248
249
250
251
252


253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269

270
271
272
273
274
275
276
277





278
279
280
281
282
283
284
...
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
: ppause ( -- )
    playitf XA_PLAYSTATE_PAUSED playitf XAPlayItf-SetPlayState() ?success ;
: pplay ( -- )
    playitf XA_PLAYSTATE_PLAYING playitf XAPlayItf-SetPlayState() ?success ;
: pvol ( n -- )
    volitf swap volitf XAVolumeItf-SetVolumeLevel() ?success ;

: queue-flush ( -- )
    cues>mts-run? IF
	<event ->cue-abort cue-task event>
    THEN  clear-queue ;

: setup-player ( -- )  player IF
	destroy-player
    ELSE
	create-stuff
    THEN
    create-media create-player
    get-interfaces set-callbacks
    init-mediaplayer  ;
: stop-player ( -- )  mediaplayer0 >o mp-pause o> queue-flush ;

FVariable first-timestamp  0e first-timestamp f!
FVariable prev-timestamp
0 Value pvol#

: start-file ( -- )  0e first-timestamp f!  0e mkv-time-off f!
    setup-player  true init-enqueue  ppause pvol# pvol ;

also opengl

0 Value oes-program

: omx-init ( -- ) create-oes-program to oes-program  oes-program init ;

also android

\ vertices

0.005e Fconstant m-lr

: get-deltat ( -- f )
    media-sft >o getTimestamp o> d>f 1e-9 f*
    first-timestamp f@ f- ;
: set-deltat ( -- f ) get-deltat mkv-time-off f@ f- first-timestamp f! ;

: get-m ( -- r% ) ts-fd 0= IF
	get-deltat mkv-file-o >o total-duration f@ o> f/
................................................................................

2Variable lastseek
500.000 2Constant delta-seek \ 0.5 seconds
5.000.000 2Constant hide-cursor

true value show-mcursor

: init-frame ( -- )
    oes-program glUseProgram
    unit-matrix MVPMatrix set-matrix
    unit-matrix MVMatrix set-matrix


    0e fdup fdup 1.0e glClearColor
    Ambient 1 ambient% glUniform1fv
    media-tex nearest-oes ;

: draw-frame ( -- )
    init-frame clear
    media-sft >o getTimestamp d>f 1e-9 f* prev-timestamp f!
    updateTexImage o>
    prev-timestamp f@ first-timestamp f@ f<> IF
	first-timestamp f@ f0=
	IF  set-deltat  THEN
	v0 i0 rectangle
	show-mcursor IF
	    hide-cursor utime lastseek 2@ d- 2over dmin d-
	    d>f hide-cursor d>f f/ triangle
	THEN
	GL_TRIANGLES draw-elements  sync

    THEN ;

: >pos ( r -- )
    ts-fd IF  >rai  ELSE
	0e first-timestamp f!
	mkv-file-o >o >cue o>
	<event elit, ->cues cue-task event>  THEN ;






: check-input ( -- )
    >looper
    ekey? IF ekey CASE
	    k-up   of pvol# 200 + 0 min dup to pvol# pvol endof 
	    k-down of pvol# 200 - dup       to pvol# pvol endof 
	ENDCASE THEN 
    *input >r r@ IF
................................................................................
		2dup 2 1 d= IF  pplay? IF
			ppause
			get-deltat mkv-time-off f! 0e first-timestamp f!
		    ELSE pplay THEN  THEN
		dup 2 = IF
		    r@ x0 @ s>f dpy-w @ fm/ 1.1e f* 0.05e f- 0e fmax 1e fmin
		    pplay? IF  ppause  THEN
		    queue-flush
		    >pos  true init-enqueue pplay
		THEN
		2drop
		utime lastseek 2!
	    THEN
	THEN  r@ action off
    THEN
    rdrop ;

: play-loop ( -- ) hidekb
    screen+keep pplay
    omx-init init-frame 1 level# +!
    BEGIN
	draw-frame check-input
	cues>mts-run? 0= pplay? and  IF  ppause  THEN
    level# @ 0= UNTIL
    ppause screen-keep ;
: play-ts ( addr u -- ) ['] read-ts-file is read-ts
    open-mts start-file play-loop ;