Exemplo n.º 1
0
bool wxOSXAudioToolboxSoundData::Play(unsigned flags)
{
    Stop();

    m_flags = flags;

    wxCFRef<CFMutableStringRef> cfMutableString(CFStringCreateMutableCopy(NULL, 0, wxCFStringRef(m_sndname)));
    CFStringNormalize(cfMutableString,kCFStringNormalizationFormD);
    wxCFRef<CFURLRef> url(CFURLCreateWithFileSystemPath(kCFAllocatorDefault, cfMutableString , kCFURLPOSIXPathStyle, false));

    AudioServicesCreateSystemSoundID(url, &m_soundID);
    AudioServicesAddSystemSoundCompletion( m_soundID, CFRunLoopGetCurrent(), NULL, wxOSXAudioToolboxSoundData::CompletionCallback, (void *) this );

    bool sync = !(flags & wxSOUND_ASYNC);

    AudioServicesPlaySystemSound(m_soundID);

    if ( sync )
    {
        while( m_soundID )
        {
            CFRunLoopRun();
        }
    }

    return true;
}
Exemplo n.º 2
0
void RudeSound::LoadWave(const char *sound, eSoundEffect num)
{
	RUDE_ASSERT(num < kNumSounds, "Invalid sound num");
	RUDE_ASSERT(sound, "No sound name");
	RUDE_REPORT("RudeSound::LoadWave %s\n", sound);
	
#if 0
	char buffer[512];
	RudeFileGetFile(sound, buffer, 512);

	int result = SoundEngine_LoadEffect(buffer, &m_soundids[num]);
	//RUDE_ASSERT(result == noErr, "Could not load effect (result = %d)\n", result);
#endif
	
#if defined(RUDE_IPHONE) || defined(RUDE_MACOS)
	CFBundleRef bundle = CFBundleGetMainBundle();
	CFStringRef file = CFStringCreateWithCString(0, sound, kCFStringEncodingASCII);
	CFURLRef myURLRef = CFBundleCopyResourceURL(bundle, file, 0, 0);
	
	OSStatus error = AudioServicesCreateSystemSoundID(myURLRef, &m_soundids[num]);
	RUDE_ASSERT(error == kAudioServicesNoError, "Could not load sound %s", sound);
#endif
	
}