# pcmreadcallback being called just after createStream

**URL:** <https://qa.fmod.com/t/pcmreadcallback-being-called-just-after-createstream/12066>\
**Category:** FMOD Engine\
**Created:** [October 1, 2015, 8:05am UTC](https://qa.fmod.com/t/pcmreadcallback-being-called-just-after-createstream/12066 "2015-10-01T08:05:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![seraphiel](https://avatars.discourse-cdn.com/v4/letter/s/6bbea6/32.png) [@seraphiel](https://qa.fmod.com/u/seraphiel)\
**Post date:** [October 1, 2015, 8:05am UTC](https://qa.fmod.com/t/pcmreadcallback-being-called-just-after-createstream/12066/1 "2015-10-01T08:05:46Z")

</div>

Hi

I’m creating a sound stream like this:  
FMOD\_CREATESOUNDEXINFO exinfo;  
  
exinfo.pcmreadcallback = pcmreadcallback; /\* User callback for reading. _/  
exinfo.pcmsetposcallback = pcmsetposcallback; /_ User callback for seeking. _/  
exinfo.userdata = new FMODSoundData(bufferSize_4); // =32KB for 4608-byte packets  
info(“before creating stream”);  
result = system-\>createStream(0, mode, &exinfo, &sound);  
info(“after creating stream”);

and in my pcmreadcallback method  
I have a printout whenever it is called:  
FMOD\_RESULT F\_CALLBACK pcmreadcallback(FMOD\_SOUND\* sound,  
void \*data,  
u32 datalen)  
{  
// some code  
println (“pcmreadcallback called”);  
}

In my console, I’m getting 8 invocations of pcmreadcallback when createStream is called.  
eg in console:  
before creating stream  
pcmreadback called x 8  
after creating stream

Why is this so?  
Is there something I’m overlooking? Is it normal for pcmreadcallback to be called during createStream?  
I’ve tested with fmod 1.6.10 and 1.5.09 and both exhibit the same behaviour.

---

<div class="post-metadata">

**Author:** ![seraphiel](https://avatars.discourse-cdn.com/v4/letter/s/6bbea6/32.png) [@seraphiel](https://qa.fmod.com/u/seraphiel)\
**Post date:** [October 1, 2015, 8:35am UTC](https://qa.fmod.com/t/pcmreadcallback-being-called-just-after-createstream/12066/2 "2015-10-01T08:35:27Z")

</div>

Figured it out, it was because I didn’t open the stream with FMOD\_OPENONLY

---

<div class="post-metadata">

**Author:** ![brett](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/brett/32/261_2.png) [@brett](https://qa.fmod.com/u/brett)\
**Post date:** [October 1, 2015, 8:41am UTC](https://qa.fmod.com/t/pcmreadcallback-being-called-just-after-createstream/12066/3 "2015-10-01T08:41:31Z")

</div>

As soon as you open a stream, it prebuffers , ready for instant playback. You can use FMOD\_NONBLOCKING if you dont want it to stall the main thread. FMOD\_OPENONLY is not a good idea as it will mean a large delay before the sound starts, because you didnt prebuffer anything.

---

<div class="post-metadata">

**Author:** ![seraphiel](https://avatars.discourse-cdn.com/v4/letter/s/6bbea6/32.png) [@seraphiel](https://qa.fmod.com/u/seraphiel)\
**Post date:** [October 1, 2015, 9:11am UTC](https://qa.fmod.com/t/pcmreadcallback-being-called-just-after-createstream/12066/4 "2015-10-01T09:11:08Z")

</div>

I see.  
I am trying to debug an issue where the first 8 invocations of my dsp’s read callback return silence. So I thought it might be this issue.  
Doesn’t seem to be though.
