[Solved->int is fine] Shouldn't AbstractFifo use long instead of int?


#1

I apologize for a potential stupid question in advance. This seems too big of an issue no one to have hit it before, so I probably am too tired and just don’t see something obvious here.

I am buffering the last few seconds of my plugin’s output, for analysis on a different thread.

In order not to lock the Audio Thread while buffering, I use an AbstractFifo. But I am puzzled by it having int’s for all indexes and size… For example if I have a 192kHz signal, 5 sec would amount to:
5 * 192 000 = 960 000 samples

Even if I buffer only small chunks (say, every block call) of samples, I would still get indexes that can’t be represented as int’s, right?

Shouldn’t the AbstractFifo be templated so we can use it with larger size arrays/buffer/etc.?

Thanks for the input and again - sorry if the question is not appropriate.

Update:
Seems on modern compilers int is no longer +-2^15, but is instead equal to long, which is +-2^31.
So AbstractFifo should work just fine up until 2 147 483 647 items.
http://en.cppreference.com/w/cpp/language/types


#2

As long your buffer is smaller than 2147483648 samples, this shouldn’t be problem


#3

I thought the limits for int are +- 2^15, while the number above is 2^31. Isn’t this the same as long?

Thanks @chkn. And sorry for the stupid question.

I found multiple places quoting 2^15 when searching for this. I think compilers made this change and now int and long don’t differ? Anyways - problem is solved (or better yet - nonexistent).


#4

the table below should answer all questions:

http://en.cppreference.com/w/cpp/language/types