Hi steve,
I'm also getting a 'Unable to create output pin' - preceeded by a NULL pointer exception.
This is happenning when playing a from a 16bit (i think) file to a 4bit file in gapless mode. The 4bit file can be played from stopped, but not when already playing.
As I'm a programmer I'll post up some code.
pin = filter->CreateRenderPin(&wfx.Format, FALSE);
if (!pin)
{
// driver can't handle WAVEFORMATEXTENSIBLE, so fall back to
// WAVEFORMATEX format descriptor and try again
wfx.Format.wFormatTag = WAVE_FORMAT_PCM;
// set unused members to zero
wfx.Format.cbSize = 0;
wfx.Samples.wValidBitsPerSample = 0;
wfx.dwChannelMask = 0;
wfx.SubFormat = GUID_NULL;
pin = filter->CreateRenderPin(&wfx.Format, FALSE); <---------
}
if (!pin)
{
MessageBox(hwnd, "Unable to create output pin", "Error!", MB_OK);
return FALSE;
}
This line fails to create the 'pin' when in gapless mode, but not when stopped. As 'pin' is left NULL the player thread then dies a horrible death .
Hi, that's very strange, I haven't seen that at all, in fact, that's the last thing I'd expect because with Gapless turned on it shouldn't destroy the output filter when changing tracks (normally it will destroy and recreate the output filter).
As I read it, from your code, it will always try to recreate 'pin' even in gapless mode if the format changes:
int KSCore::StartInternal(int samplerate, int numchannels, int bitspersamp)
...
switch(bitspersamp)
{
case 20:
MessageBox(hwnd, "20 bit audio is not currently supported", "Error!", MB_OK);
return -1;
case 24:
if (numchannels == 2) {
wfx.Format.wBitsPerSample = 32;
wfx.Format.nBlockAlign = 8;
}
else if (numchannels == 1) {
wfx.Format.wBitsPerSample = 32;
wfx.Format.nBlockAlign = 4;
}
else {
MessageBox(hwnd, "Only 1 or 2 channels is supported for 24 bit playback.", "Error!", MB_OK);
return -1;
}
break;
default:
break;
}
// Gapless enhancement
if (mode == MODE_STARTED) { // already playing
if (config->gapless_enabled) {
if (0 == memcmp(&wfx_cur,&wfx,sizeof(WAVEFORMATEXTENSIBLE))) {
should_be_playing = TRUE;
return 1000; // no format change detected, so just carry on
}
}
else
End();
}
if (!OpenOutput(wfx)) { <------ gets run if there is a format change even in gapless mode.
return -1;
}
...
}
This is not realy much of a problem as I dont spend my time listenning to 4bit music , but if it could fail more gacefully .
As a side note I see that you dont have 'pin' very thread safe. You are continously accessing it in your playig thread, but you also reasign it in your OpenOutput function. It doesnt seem to cause any problems on the other hand though....
[I'm assumming your using the Release CFG profile here for compiling, if your not disraguard the following....]
Do you know you have the _DEBUG macro set rather than the _NDEBUG in your release cfg profile (could cause use of debug functions etc) and you have the linker producing debug info in your DLL (47kb in release vs 264kb in release CFG).
Hope this helps.