|
Hello,
I have a problem playing MP3 in queue with the BASS mp3 free DLL version 2.4.0.1 on a particular computer in our application (VB.NET). We have tested the same code with success on about 10 computers, but on 1 computer it fails on the second mp3 file, when it is loaded. This computer is a IBM ThinkPad T43 laptop with Windows Media Player 11 installed.
The error occurres on the BASS_StreamCreateFile command. It returns the error BASS_ERROR_CODEC. The first MP3 file is played correctly with the same code! The second time the BASS_StreamCreateFile is called from the BASS_SYNC_MIXTIME event. The BASS_SYNC_MIXTIME event is defined here:
' Handler Mixer events for audio buffers _onEndingSync = New SYNCPROC(AddressOf OnEnding) Bass.BASS_ChannelSetSync(_mixer, BASSSync.BASS_SYNC_END Or BASSSync.BASS_SYNC_MIXTIME, 0, _onEndingSync, 0)
The OnEnding event is calling this function, which is the same function that is used when the first MP3 file is played:
Private Sub PlayQueuedStream(ByVal _mixer As Integer, ByVal initial As Boolean) If _audioQueue.Count > 0 Then Dim audioStream As IO.Stream = _audioQueue.Dequeue Dim buffer(audioStream.Length) As Byte Dim hGCFile As GCHandle
audioStream.Read(buffer, 0, buffer.Length)
hGCFile = GCHandle.Alloc(buffer, GCHandleType.Pinned) ' Put handle in queue so we can release is at time audio finished playing _bufferGCHandleQueue.Enqueue(hGCFile)
_source = Bass.BASS_StreamCreateFile(hGCFile.AddrOfPinnedObject(), 0L, buffer.Length, BASSFlag.BASS_STREAM_DECODE) If _source <> 0 Then ' Determine current stream length, this is cached here to prevent having to reload audio _currentStreamLength = Bass.BASS_ChannelBytes2Seconds(_source, Bass.BASS_ChannelGetLength(_source))
PostAsyncOperation(PostedEventEnum.AudioStreamLoaded)
Me._state = playerState.isPlaying If initial Then ' initial is set to true for first played sound in queue If BassMix.BASS_Mixer_StreamAddChannel(_mixer, _source, BASSFlag.BASS_STREAM_AUTOFREE) Then If Not Bass.BASS_ChannelPlay(_mixer, True) Then Throw New InteractionControlException("Error while attempting to play audio.") End If Else Throw New InteractionControlException("Error while attempting to add stream to mixer.") End If initial = False Else ' not first sound played, disable ramp-in, and reset mixer If Not BassMix.BASS_Mixer_StreamAddChannel(_mixer, _source, BASSFlag.BASS_STREAM_AUTOFREE Or BASSFlag.BASS_MIXER_NORAMPIN) Then Throw New InteractionControlException("Error while attempting to add stream to mixer.") End If Bass.BASS_ChannelSetPosition(_mixer, 0) End If
' Need to do async because this method is also called within OnEndingStream which runs on a different thread PostAsyncOperation(PostedEventEnum.BeginningStream) Else
Throw New InteractionControlException(String.Format("Error while attempting to load stream. ({0})", Bass.BASS_ErrorGetCode().ToString())) End If _isStopping = False End If End Sub
I'm clueless why this doesn't work on the particular computer. Can someone help me?
|