Video Player

Post your NXJ projects, project ideas, etc here!

Moderators: roger, 99jonathan, imaqine

Re: Video Player

Postby matejdro » Fri May 04, 2012 10:52 pm

As I said, if I send bytes faster, audio will start to play faster than it should.
matejdro
Novice
 
Posts: 54
Joined: Wed Mar 14, 2012 9:10 am

Re: Video Player

Postby skoehler » Fri May 04, 2012 10:59 pm

matejdro wrote:As I said, if I send bytes faster, audio will start to play faster than it should.

Of course, if you try to add 255 samples to the buffer, and playSamples lets you know that it was only able to add 200 samples to the buffer, and you forget to try again later to add the remeining 55 bytes, then audio will (seem to) start playing faster,

Show me code, which handles the return value of playSamples. And I'll tell you whether that is correct.
skoehler
leJOS Team Member
 
Posts: 1114
Joined: Thu Oct 30, 2008 4:54 pm

Re: Video Player

Postby matejdro » Sat May 05, 2012 8:10 am

Currently it is not handled yet (just simple if statement , that prints out something if its less than 255. I will try to handle it now.
matejdro
Novice
 
Posts: 54
Joined: Wed Mar 14, 2012 9:10 am

Re: Video Player

Postby matejdro » Sat May 05, 2012 11:29 am

I hit very weird issue: As long as PC only have output stream and NXT only have input stream, communication works.

But If I create input stream on PC or output stream on NXT, communication will not work (NXT will freeze on .readByte() and PC will freeze on .flush().

This prevents me from NXT signaling PC when is ready to receive sound.
matejdro
Novice
 
Posts: 54
Joined: Wed Mar 14, 2012 9:10 am

Re: Video Player

Postby gloomyandy » Wed May 09, 2012 6:03 pm

I assume this is using USB? That seems very strange. You certainly can not on the PC side have one thread reading while another writes, but it is very common to have both input and output streams with USB connections. P,lease post a short sample that demonstrates the problem.

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3004
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Video Player

Postby matejdro » Mon May 14, 2012 5:51 am

When I init both DataInputStream and DataOutput stream:

PC:
Code: Select all
      DataOutputStream output = new DataOutputStream(new BufferedOutputStream(connector.getOutputStream(), 5000));
        DataInputStream input = new DataInputStream(connector.getInputStream());

NXT:
Code: Select all
DataInputStream input = new DataInputStream(new BufferedInputStream(connection.openInputStream(), 4000));
       DataOutputStream output = connection.openDataOutputStream();


NXT will stall on readByte() method and PC will stall on flush() method. This is without even using any NXT -> PC code. If I comment out DataInputStream on PC and DataOutputStream on NXT, it strangely works. I have to comment out both (If I for example just comment out DataInputStream on PC, but leave DataOutputStream on NXT it will not work).

:?
matejdro
Novice
 
Posts: 54
Joined: Wed Mar 14, 2012 9:10 am

Re: Video Player

Postby gloomyandy » Mon May 14, 2012 6:36 am

I think you need to create a set of small test programs that shows the problem and post them here. That way we can take a look at what is going on....

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3004
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Previous

Return to NXJ Projects

Who is online

Users browsing this forum: No registered users and 2 guests

cron
more stuff