Hi Happy new year to all! I am getting the error code DSERR_OBJECTNOTFOUND on calling the API IDirectMusicSegmentState8::GetSegment(...). I am unable to find why. This error occurs in my notification-handling thread (I have adapted it from the Todor Fay's DirectMusic book). Relevant excerpts of the code follow: // Notification-hanlding thread function while (pMainFrame->m_bNotifyThreadRunning) { DWORD dw = WaitForSingleObject(pMainFrame->m_hNotify, INFINITE); while ((pPerformance->GetNotificationPMsg(&pPmsg) == S_OK)) { // TRACE(_T("Retrieved a notification\n")); if (pPmsg->dwType == DMUS_PMSGT_NOTIFICATION) { // TRACE(_T("Processing notification...\n")); if ((pPmsg->punkUser) && (pPmsg->guidNotificationType == GUID_NOTIFICATION_SEGMENT)) { IDirectMusicSegmentState8* pSegmentState = NULL; IDirectMusicSegment* pNotifySegment = NULL; IDirectMusicSegment8* pNotifySegment8 = NULL; CSMAudioTrack *pSMAudioTrack = NULL; // TRACE(_T("Notification type = GUID_NOTIFICATION_SEGMENT\n")); // The pPMsg->punkUser contains a IDirectMusicSegmentState8, // which we can query for the segment that the SegmentState refers to. if( FAILED( hr = pPmsg->punkUser->QueryInterface( IID_IDirectMusicSegmentState8, (VOID**) &pSegmentState ) ) ) { // An error occured goto _cleanup; } if( FAILED( hr = pSegmentState->GetSegment( &pNotifySegment ) ) ) { #ifdef _DEBUG DXTRACE_ERR_MSGBOX( TEXT("GetSegment"), hr ); // This is where the error occurs #endif // An error occured goto _cleanup; } if( FAILED( hr = pNotifySegment->QueryInterface( IID_IDirectMusicSegment8, (VOID**) &pNotifySegment8 ) ) ) { // An error occured goto _cleanup; } // TRACE(_T("Trying to match segment...\n")); // pSegment is a pointer to the primary segment - We are trying to // catch notifications only for the primary segment if ((pNotifySegment8 == pSegment) && (pNotifySegment8 != NULL)) { // TRACE(_T("Found segment match...\n")); if (pPmsg->dwNotificationOption == DMUS_NOTIFICATION_SEGLOOP) { // Do something with SEGLOOP notification } else if (pPmsg->dwNotificationOption == DMUS_NOTIFICATION_SEGEND) { // Do something with SEGEND notification } } _cleanup: // Cleanup SAFE_RELEASE( pSegmentState ); SAFE_RELEASE( pNotifySegment ); SAFE_RELEASE( pNotifySegment8 ); } } // Done with the notification pPerformance->FreePMsg((DMUS_PMSG *) pPmsg); } } The lines where the problem occurs are shown in bold red font above. Note that the problem happens only occasionally. I had a hunch that this could be related to the notification-handling thread starting before actual start of playback, but if that was the case, there should not have been any notifications, and the second while loop should not have been entered. One of the bad consequences of the above error is that the program never receive the SEGEND notification on the playing segment, and hence I never know when the playback stopped (to stop the cursor movement in my application). There is no documentation on the error code DSERR_OBJECTNOTFOUND in MSDN and/or the Internet. Furthermore, I don't know why the GetSegment(...) function would throw a DirectSound-related error (DSERR_OBJECTNOTFOUND). Can someone please help? Thank you Abhijit --------------------------------- Do you Yahoo!? Yahoo! Mail - now with 250MB free storage. Learn more.