Author Topic: BASS_ERROR_FILEOPEN after 600+ songs  (Read 321 times)

carl9000

  • Posts: 4
BASS_ERROR_FILEOPEN after 600+ songs
« on: 11 Jun '19 - 17:01 »
I've made a music player that streams over icecast. I'm having a problem with the program crashing around 685 - 687 songs played. The error occurs when it loads the next song using BASS_StreamCreateFile. For some reason it's throwing a BASS_ERROR_FILEOPEN error and I'm not sure why. I have 325 songs in the playlist and so this song should have been opened and played before since it crashes around the 685th or so song played. Could this be a memory issues? I've checked the RAM usage and I do not see any issues. I am running this in Mono in Ubuntu.

Any ideas or suggestions would be helpful.

Ian @ un4seen

  • Administrator
  • Posts: 21991
Re: BASS_ERROR_FILEOPEN after 600+ songs
« Reply #1 on: 11 Jun '19 - 17:36 »
You may be hitting Linux's per-process open files limit. You can change the limit in the /etc/security/limits.conf file:

Code: [Select]
<username> - nofile <number>

The default is usually 1024, so try a number higher than that.

carl9000

  • Posts: 4
Re: BASS_ERROR_FILEOPEN after 600+ songs
« Reply #2 on: 13 Jun '19 - 16:08 »
You may be hitting Linux's per-process open files limit. You can change the limit in the /etc/security/limits.conf file:

Code: [Select]
<username> - nofile <number>

The default is usually 1024, so try a number higher than that.

Interesting I'll give this a try. Shouldn't BASS be closing each file after it's done playback? or does linux not consider a file closed until the main process has ended?

EDIT: So I think you may be right here. I did a lsof -p on the process to get a list of open files for that process and all played songs are still open and some songs are even opened multiple times. What is the proper way to manually close a file after playback has completed? I am using BASS_StreamCreateFile. Would BASS_StreamFree close the file?
« Last Edit: 13 Jun '19 - 16:51 by carl9000 »

Ian @ un4seen

  • Administrator
  • Posts: 21991
Re: BASS_ERROR_FILEOPEN after 600+ songs
« Reply #3 on: 13 Jun '19 - 17:12 »
Yes, will need to free the streams to close the files (and release memory allocated to the streams). You can do that by calling BASS_StreamFree, or setting the BASS_STREAM_AUTOFREE flag on the streams to have them freed automatically after playback.

carl9000

  • Posts: 4
Re: BASS_ERROR_FILEOPEN after 600+ songs
« Reply #4 on: 17 Jun '19 - 18:05 »
So I've added BASS_StreamFree to the songs BASS_SYNC_END SYNCPROC to free the stream after the song is done playing. Unfortunately this results in a crash. I did some searching and it seems you can not call BASS_StreamFree from a BASS_SYNC_END SYNCPROC and would need to do this from another thread. How would I go about this in C#? All the examples were in C++ using PostMessage.

Edit:
I got it done using a new thread to monitor a list of streams to free and freeing them when new streams are added. All is working now.
« Last Edit: 17 Jun '19 - 18:52 by carl9000 »

Ian @ un4seen

  • Administrator
  • Posts: 21991
Re: BASS_ERROR_FILEOPEN after 600+ songs
« Reply #5 on: 18 Jun '19 - 14:53 »
That sounds like your BASS_SYNC_END sync is a "mixtime" sync, as it should otherwise be fine to call BASS_StreamFree in the sync's callback. If you happen to be playing the streams through a mixer, you can use the BASS_STREAM_AUTOFREE flag in your BASS_Mixer_StreamAddChannel call to have the stream automatically freed when the mixer finishes playing it.