Author Topic: Unusual issue with BassCd  (Read 405 times)

VorTechS

  • Posts: 270
Unusual issue with BassCd
« on: 30 Jan '18 - 10:51 »
Since converting my application to gapless playback, I've been trying to inject my old 'CD playback' code into my application, as is without changes.

Firstly there's an inconsistency in the documentation here.

Bass_CD_StreamCreate is allowing me to create more than one stream handle to the same drive without a failure.

That aside I have a scenario where the CD playback starts for a fraction of a second and then immediately ends, firing my SYNCPROC.

Here's my stream creation code:

Code: [Select]
                // Get the track as a Bass stream
                cdStreamHandle = BassCd.BASS_CD_StreamCreate(_sourceCdDrive, trackIndex, Un4seen.Bass.BASSFlag.BASS_STREAM_DECODE | Un4seen.Bass.BASSFlag.BASS_SAMPLE_FLOAT);


and then the handle is plugged into the mixer (shared across any stream creation routine I have) before being played:

Code: [Select]
                            Bass.BASS_ChannelSetPosition(_streamHandles[_currentPlaylistItem], trackTime); // rewind the file (in case it's already been played)

                            Un4seen.Bass.AddOn.Mix.BassMix.BASS_Mixer_StreamAddChannel(_mixerHandle, _streamHandles[_currentPlaylistItem], BASSFlag.BASS_MIXER_NORAMPIN | BASSFlag.BASS_MUSIC_AUTOFREE | BASSFlag.BASS_MIXER_BUFFER); // add it to the mixer

                            Bass.BASS_ChannelSetPosition(_mixerHandle, 0, BASSMode.BASS_POS_BYTES); // reset the mixer to continue playing (it's ended)

                            if (_playBackState == PlayerPlayState.Stopped || _playBackState == PlayerPlayState.None)
                            {

                                if (Bass.BASS_ChannelPlay(_mixerHandle, true))
                                {
                                    SetPlayerState(PlayerPlayState.Playing);
                                }
                            }

I guess whilst I'm looking mostly in Ian's direction, has anyone else had a similar experience or have an idea as to what might be behind this behaviour?

Ian @ un4seen

  • Administrator
  • Posts: 21326
Re: Unusual issue with BassCd
« Reply #1 on: 30 Jan '18 - 13:29 »
By default, BASSCD will automatically free an existing stream when creating a new one on the same drive, unless that is disabled via the BASS_CONFIG_CD_FREEOLD option. If you haven't disabled it, that is probably what's happening in your case. Does the problem still happen if you don't try to create a 2nd stream on the same drive?

VorTechS

  • Posts: 270
Re: Unusual issue with BassCd
« Reply #2 on: 30 Jan '18 - 15:31 »
Thanks for the reply Ian.

Yes, it's still seems to be doing it with 'seemingly' only one stream handle open on the device.

Code: [Select]
            // This is a time sensitive call, we MUST have this track loaded now to play it
            if (_streamHandles[playListItemIndex] == 0)
            {
                _streamHandles[playListItemIndex] = GetStreamHandle(applicationPoint, playListItemIndex);
            }

            // Queue the next track ready for playing, which is not time sensitive
            if (_currentDeviceMode != DeviceMode.CD)
            {
                Task.Run(() =>
                {
                    if (playListItemIndex < _currentPlaylistCount - 1 && _streamHandles[playListItemIndex + 1] == 0)
                    {
                        _streamHandles[playListItemIndex + 1] = GetStreamHandle(applicationPoint | StateChangeReason.StreamCreation, playListItemIndex + 1);
                    }
                });
            }

I set BASS_CONFIG_CD_FREEOLD to false, and playback is going ahead as it should do.

So, I dug a little deeper, and it seems trying to read tag information using BASSTag is the culprit.

(Note: file-based BassTag operations, not BassCd.BASS_CD_GetIDText)

Before I go ahead and drop code in for CD-Text, am I likely to run into the same problem if I try to read track information at playback? 

Or should I make sure read all the CD-text before starting? (which is a general design principle I've been trying to avoid)


Ian @ un4seen

  • Administrator
  • Posts: 21326
Re: Unusual issue with BassCd
« Reply #3 on: 30 Jan '18 - 17:53 »
By "BASSTag", do you mean BASS_ChannelGetTags? I don't think that has any options that apply to CD streams? For CD info, you would generally use BASS_CD_GetID instead. It should be fine to do that during playback, but let me know if you find it causes problems.

VorTechS

  • Posts: 270
Re: Unusual issue with BassCd
« Reply #4 on: 31 Jan '18 - 09:21 »
Apparently, no, that's not what I was using.  It looks like I was using this:

Code: [Select]
                TAG_INFO tagInfo = Un4seen.Bass.AddOn.Tags.BassTags.BASS_TAG_GetFromFile(filePath);

Obviously, this was an oversight as I wouldn't expect to get any Tag information from a CDA file - it was just an un-intended operation as the code progresses re-using what I already had.

I'll have a look into BASS_CD_GetID, and report back!

Thanks Ian

EWeiss

  • Posts: 365
Re: Unusual issue with BassCd
« Reply #5 on: 31 Jan '18 - 11:35 »
HI,

that is the own way what you can do..
Code: [Select]
BASS_CD_GetIDuse a free db Server as example tracktype.org then get the ID from your CD
that give you all available Information for Tags..

see.. shot


« Last Edit: 31 Jan '18 - 11:41 by EWeiss »

VorTechS

  • Posts: 270
Re: Unusual issue with BassCd
« Reply #6 on: 1 Feb '18 - 10:06 »
HI,

that is the own way what you can do..
Code: [Select]
BASS_CD_GetIDuse a free db Server as example tracktype.org then get the ID from your CD
that give you all available Information for Tags..

see.. shot

Thanks Emil.  I'll have a look at FreeDB again.  I think I used it before in another of my apps. a long time ago, so hopefully I still have a wrapper class somewhere for it.