BASS_StreamCreateFileUser broken on Windows 20H1

Started by Mokhtar,

Pete

Hi Ian,

My name is Pete and I work with Mokhtar at Amazon.  One of the scans of the updated BASS package that we obtained as part of this issue and subsequent fix showed inclusion of the FAAD2 component, which is dual-licensed under GPL and a commercial license. 

Can we engage in an offline discussion about licensing of this component?

Ian @ un4seen

The FAAD2 library is used by the BASS_AAC add-on, but not BASS itself. By default, BASS will use the AAC decoder that comes with Windows. When using the BASS_AAC add-on, the FAAD2 library needs to be licensed from Nero separately, and if I recall correctly, Amazon did that many years ago for another product that was using the BASS_AAC add-on. It doesn't sound like you're using the BASS_AAC add-on in this case though, as this thread is regarding Windows' AAC decoder. If BASS_AAC has now appeared, perhaps it was just for testing/comparison purposes?

StephBel

Hello @Ian,

Concerning Windows with AAC streams (we cannot use the AAC library).

We made a workaround that is working with version 2.4.15.0.
But now we would need to use the last release to have access to BASS_ATTRIB_VOLDSP and BASS_ATTRIB_VOLDSP_PRIORITY, but we are still receiving an error when we call BASS_ChannelGetLength and BASS_ChannelSetPosition on:
BASS_ChannelGetLength(handle, BASS_POS_BYTE); return -1
and the BASS_ErrorGetCode is BASS_ERROR_NOTAVAIL
also the BASS_ChannelSetPosition(handle, 0, BASS_POS_BYTE); return false with value of BASS_ErrorGetCode BASS_ERROR_POSITION

So we are stuck with version 2.4.15.0.

Ian @ un4seen

Please upload (or link) an affected file to have a look at here:

   ftp.un4seen.com/incoming

Also confirm how you're creating the stream from it (BASS_StreamCreateFileUser?), and the Windows version if that makes a difference.

StephBel

yes:
ret = BASS_StreamCreateFileUser(STREAMFILE_NOBUFFER, flags, &fileprocs, RAMFileStruct);
 
flags are  BASS_STREAM_DECODE | BASS_STREAM_PRESCAN | BASS_SAMPLE_FLOAT | BASS_SAMPLE_SOFTWARE | BASS_UNICODE
 
BASS_FILEPROCS fileprocs = { RAMFileCloseProc, RAMFileLenProc, RAMFileReadProc, RAMFileSeekProc };

I have Windows 11.

StephBel

Upload a audio file on the ftp...

In modify spectrum exemple added to the previous message, in void CALLBACK UpdateSpectrum(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2)

I receive the same error...I'm sure that also BASS_ChannelSetPosition will result the same error

Ian @ un4seen

It does appear that Media Foundation is unfortunately unable to get the duration of that MP4 file. Windows Media Player has the same problem with it. Do you know what encoder and settings were used to create it? Also, what is the workaround that you mentioned for BASS 2.4.15, and does that not work with 2.4.17 too?

StephBel

The workaround is basically seeking into the track (see code below).
With 2.4.17 we have error also on BASS_ChannelSetPosition(handle, BASS_POS_BYTE); 

BASS_ChannelSetPosition(handle, 0, BASS_POS_BYTE); return false with value of BASS_ErrorGetCode BASS_ERROR_POSITION.
This is working fine with older versions of BASS.

long long getLength(long long handle)
{
   long long length = BASS_ChannelGetLength(handle, BASS_POS_BYTE);
   long long position = BASS_ChannelGetPosition(handle, BASS_POS_BYTE);
 
   if (length == (long long)(-1) && position != (long long)(-1) && BASS_ChannelSetPosition(handle, 0, BASS_POS_BYTE))
   {
      long long step = 1 << 20;
      long long pos = 0;
      while (TRUE)
      {
         if (BASS_ChannelSetPosition(handle, pos + step, BASS_POS_BYTE))
            pos += step;
         else if (step != 1)
            step /= 2;
         else
         {
            length = pos;
            break;
         }
      }
      BASS_ChannelSetPosition(handle, position, BASS_POS_BYTE);
   }
 
   return length;
}

Ian @ un4seen

I see. BASS 2.4.17 does disable seeking with Media Foundation when the file's duration is unknown, while 2.4.15 still allowed seeking to be attempted. Here's a 2.4.17 update for you to try, which again allows seeking to be attempted:

   www.un4seen.com/stuff/bass.zip

From the MP4 file's tags, it looks like your app is creating the file? If so, I think the best solution would be to change the way that's done, to make the duration known. If the file is currently created via an external encoder writing to STDOUT (eg. using a callback with BASS_Encode_Start) then perhaps you could have the encoder write to a file instead? That would allow the encoder to go back and update values in the file.

StephBel

Quote from: Ian @ un4seenFrom the MP4 file's tags, it looks like your app is creating the file?
In fact this is dump from a streaming service.

Quote from: Ian @ un4seenHere's a 2.4.17 update for you to try
Thanks it seems to work!