예제 #1
0
NAudioUnit::~NAudioUnit()
{
	int i;
	
	// delete sound channel
	if(_sndChannel)
	{
		SndDisposeChannel(_sndChannel, true);
		_sndChannel = NULL;
	}

	// delete sample memory	
	for(i=0; i<4; i++)
		delete [] _pSquares[i];
	delete [] _pTriangle;
	delete [] _pNoise;
	
	// delete buffers
	if(_bInitialized)
	{
		delete [] _pBuffers[0];
		delete [] _pBuffers[1];
		delete [] _pTempBuf;
	}
}
/*
 * delete_fluid_sndmgr_audio_driver
 */
int delete_fluid_sndmgr_audio_driver(fluid_audio_driver_t* p)
{
  fluid_sndmgr_audio_driver_t* dev = (fluid_sndmgr_audio_driver_t*) p;

  if (dev != NULL) {
    if (dev->channel != NULL) {
      SndDisposeChannel(dev->channel, 1);
    }
    if (dev->doubleCallbackProc != NULL) {
      DisposeRoutineDescriptor(dev->doubleCallbackProc);
    }
    if (dev->doubleHeader != NULL) {
      if(dev->doubleHeader->dbhBufferPtr[0] != NULL) {
	FLUID_FREE(dev->doubleHeader->dbhBufferPtr[0]);
      }
      if (dev->doubleHeader->dbhBufferPtr[1] != NULL) {
	FLUID_FREE(dev->doubleHeader->dbhBufferPtr[1]);
      }
      FLUID_FREE(dev->doubleHeader);
    }
    if (dev->convbuffers[0] != NULL) {
      FLUID_FREE(dev->convbuffers[0]);
    }
    if (dev->convbuffers[1] != NULL) {
      FLUID_FREE(dev->convbuffers[1]);
    }

    FLUID_FREE(dev);
  }
  return 0;
}
예제 #3
0
 virtual ~wxSMTimer()
 {
     if(m_pbPlaying)
         *m_pbPlaying = false;
     SndDisposeChannel((SndChannelPtr)m_pSndChannel, TRUE);
     Stop();
 }
예제 #4
0
파일: sound.cpp 프로젝트: 3v1n0/wxWidgets
void wxOSXSoundManagerSoundData::DoStop()
{
    if ( m_pSndChannel )
    {
        SndDisposeChannel(m_pSndChannel, TRUE /* stop immediately, not after playing */);
        m_pSndChannel = NULL;
        wxSound::SoundStopped(this);
    }

    if (IsMarkedForDeletion())
        delete this;
}
예제 #5
0
파일: music.c 프로젝트: DrItanium/moo
void free_music_channel(
	void)
{
	if (music_state && music_state->initialized && music_state->channel)
	{
		OSErr error;
		
		error= SndDisposeChannel(music_state->channel, TRUE);
		vwarn(error==noErr, csprintf(temporary, "SndDisposeChannel returned %d;g", error));
		music_state->channel= NULL;
	}
}
예제 #6
0
void BURGERCALL MADSndClose(MADDriverRec *inMADDriver)
{
	if (inMADDriver->MusicChannelPP) {
		SndDisposeChannel(inMADDriver->MusicChannelPP,TRUE);
		inMADDriver->MusicChannelPP = 0;
	}
	if (inMADDriver->CallBackUPP) {
		DisposeSndCallBackUPP(inMADDriver->CallBackUPP);
		inMADDriver->CallBackUPP = 0;
	}
	DeallocAPointer(inMADDriver->SndBuffer);
	inMADDriver->SndBuffer = 0;
}
예제 #7
0
static void Mac_CloseAudio(_THIS)
{
    int i;

    if ( channel != NULL ) {
        /* Clean up the audio channel */
        SndDisposeChannel(channel, true);
        channel = NULL;
    }
    for ( i=0; i<2; ++i ) {
        if ( audio_buf[i] ) {
            free(audio_buf[i]);
            audio_buf[i] = NULL;
        }
    }
}
예제 #8
0
static void Mac_CloseAudio(_THIS) {
   
   int i;
   
   running = 0;
   
   if (channel) {
      SndDisposeChannel (channel, true);
      channel = NULL;
   }
   
    for ( i=0; i<2; ++i ) {
        if ( buffer[i] ) {
            free(buffer[i]);
            buffer[i] = NULL;
        }
    }
}
예제 #9
0
static void
SNDMGR_CloseDevice(_THIS)
{
    running = 0;

    if (this->hidden != NULL) {
        if (this->hidden->channel) {
            SndDisposeChannel(this->hidden->channel, true);
            this->hidden->channel = NULL;
        }

        SDL_free(buffer[0]);
        SDL_free(buffer[1]);
        buffer[0] = buffer[1] = NULL;

        SDL_free(this->hidden);
        this->hidden = NULL;
    }
}
예제 #10
0
static void SoundChannel_Term(void) {

volatile QSOUND		qs;
	SndChannelPtr	hdl;
	SndCallBackUPP	cb;

	qs = &QSound;
	hdl = qs->hdl;
	qs->hdl = NULL;
	cb = qs->cb;
	qs->cb = NULL;

#if TARGET_API_MAC_CARBON
	if (cb) {
		DisposeSndCallBackUPP(cb);
	}
#endif
	if (hdl) {
		SndDisposeChannel(hdl, TRUE);
	}
}
예제 #11
0
int audio_close(snd_node *n)
{
  buffer_state *data = (buffer_state *)n->u.audio.descriptor;
  OSErr err;
  
  if (data->recording) {
    SPBStopRecording(data->refnum);
    SPBCloseDevice(data->refnum);
    
    if (data->starved) {
      data->starved = 0;
    }
    
    #ifndef TARGET_CARBON
    DisposeRoutineDescriptor(data->params.interruptRoutine);
    #endif

    free((void *)data->recBuffer);
  }
  else {
    data->finished = 1;
    
    SndCallBackUPP callBack = data->chan->callBack;
    
    err = SndDisposeChannel(data->chan,
                            true         // quiets the channel now
                            );

    #ifndef TARGET_CARBON
    DisposeRoutineDescriptor(callBack);
    #endif
    
    free((void *)data->buffer);  
    free((void *)data->nextBuffer);
  }
  
  free((void *)data);

  return SND_SUCCESS;
}
예제 #12
0
static
int finish(struct audio_finish *finish)
{
  int i, result = 0;

  if (set_pause(0) == -1 || drain() == -1)
    result = -1;

  if (SndDisposeChannel(channel, FALSE) != noErr && result == 0) {
    audio_error = _("SndDisposeChannel() failed");
    result = -1;
  }

  for (i = 0; i < NBUFFERS; ++i) {
    if (MPDeleteSemaphore(output[i].semaphore) != noErr && result == 0) {
      audio_error = _("failed to delete synchronization object");
      result = -1;
    }
  }

  return result;
}
예제 #13
0
void close_network_speaker(
  void)
{
  if (speaker) {
    OSErr error;

    error= SndDisposeChannel(speaker->channel, true);
    warn(error==noErr);

    DisposePtr((Ptr)speaker->header->dbhBufferPtr[0]);
    DisposePtr((Ptr)speaker->header->dbhBufferPtr[1]);
    DisposePtr((Ptr)speaker->header);
    DisposePtr((Ptr)speaker->channel);
    DisposePtr((Ptr)speaker->queue);
    DisposePtr((Ptr)speaker);

    speaker= (struct speaker_definition *) NULL;
  }

#ifdef SPEEX
  destroy_speex_decoder();
#endif
}
예제 #14
0
bool wxSound::DoPlay(unsigned flags) const
{
    Stop();

    Movie movie;

    switch(m_type)
    {
    case wxSound_MEMORY:
        {
            if (!wxInitQT())
                return false;
            Handle myHandle, dataRef = nil;
            MovieImportComponent miComponent;
            Track targetTrack = nil;
            TimeValue addedDuration = 0;
            long outFlags = 0;
            OSErr err;
            ComponentResult result;

            myHandle = NewHandleClear((Size)m_waveLength);

            BlockMove(m_hSnd, *myHandle, m_waveLength);

            err = PtrToHand(&myHandle, &dataRef, sizeof(Handle));

            if (memcmp(&m_hSnd[8], "WAVE", 4) == 0)
                miComponent = OpenDefaultComponent(MovieImportType, kQTFileTypeWave);
            else if (memcmp(&m_hSnd[8], "AIFF", 4) == 0)
                miComponent = OpenDefaultComponent(MovieImportType, kQTFileTypeAIFF);
            else if (memcmp(&m_hSnd[8], "AIFC", 4) == 0)
                miComponent = OpenDefaultComponent(MovieImportType, kQTFileTypeAIFC);
            else
            {
                wxLogSysError(wxT("wxSound - Location in memory does not contain valid data"));
                return false;
            }

            movie = NewMovie(0);

            result = MovieImportDataRef(miComponent,                dataRef,
                                        HandleDataHandlerSubType,   movie,
                                        nil,                        &targetTrack,
                                        nil,                        &addedDuration,
                                        movieImportCreateTrack,     &outFlags);

            if (result != noErr)
            {
                wxLogSysError(wxString::Format(wxT("Couldn't import movie data\nError:%i"), (int)result));
            }

            SetMovieVolume(movie, kFullVolume);
            GoToBeginningOfMovie(movie);

            DisposeHandle(myHandle);
        }
        break;
    case wxSound_RESOURCE:
        {
            SoundComponentData data;
            unsigned long numframes, offset;

            ParseSndHeader((SndListHandle)m_hSnd, &data, &numframes, &offset);
            //m_waveLength = numFrames * data.numChannels;

            SndChannelPtr pSndChannel;
            SndNewChannel(&pSndChannel, sampledSynth,
                initNoInterp
                + (data.numChannels == 1 ? initMono : initStereo), NULL);

            if(SndPlay(pSndChannel, (SndListHandle) m_hSnd, flags & wxSOUND_ASYNC ? 1 : 0) != noErr)
                return false;

            if (flags & wxSOUND_ASYNC)
            {
                lastSoundTimer = ((wxSMTimer*&)m_pTimer)
                    = new wxSMTimer(pSndChannel, m_hSnd, flags & wxSOUND_LOOP ? 1 : 0,
                                    &lastSoundIsPlaying);
                lastSoundIsPlaying = true;

                ((wxTimer*)m_pTimer)->Start(MOVIE_DELAY, wxTIMER_CONTINUOUS);
            }
            else
                SndDisposeChannel(pSndChannel, TRUE);

            return true;
        }
        break;
    case wxSound_FILE:
        {
            if (!wxInitQT())
                return false;

            OSErr err = noErr ;

            Handle dataRef = NULL;
            OSType dataRefType;

            err = QTNewDataReferenceFromFullPathCFString(wxMacCFStringHolder(m_sndname,wxLocale::GetSystemEncoding()),
                (UInt32)kQTNativeDefaultPathStyle, 0, &dataRef, &dataRefType);

            wxASSERT(err == noErr);

            if (NULL != dataRef || err != noErr)
            {
                err = NewMovieFromDataRef( &movie, newMovieDontAskUnresolvedDataRefs , NULL, dataRef, dataRefType );
                wxASSERT(err == noErr);
                DisposeHandle(dataRef);
            }

            if (err != noErr)
            {
                wxLogSysError(
                    wxString::Format(wxT("wxSound - Could not open file: %s\nError:%i"), m_sndname.c_str(), err )
                    );
                return false;
            }
        }
        break;
    default:
        return false;
    }//end switch(m_type)

    //Start the movie!
    StartMovie(movie);

    if (flags & wxSOUND_ASYNC)
    {
        //Start timer and play movie asyncronously
        lastSoundTimer = ((wxQTTimer*&)m_pTimer) =
            new wxQTTimer(movie, flags & wxSOUND_LOOP ? 1 : 0,
                          &lastSoundIsPlaying);
        lastSoundIsPlaying = true;
        ((wxQTTimer*)m_pTimer)->Start(MOVIE_DELAY, wxTIMER_CONTINUOUS);
    }
    else
    {
        wxASSERT_MSG(!(flags & wxSOUND_LOOP), wxT("Can't loop and play syncronously at the same time"));

        //Play movie until it ends, then exit
        //Note that due to quicktime caching this may not always
        //work 100% correctly
        while (!IsMovieDone(movie))
            MoviesTask(movie, 1);

        DisposeMovie(movie);
    }

    return true;
}
예제 #15
0
static void macos_close_sound ()
{
	SndDisposeChannel (channel, true);
	free (buffer[0]);
	free (buffer[1]);
}
예제 #16
0
static void SndCh_dealloc(SndChannelObject *self)
{
	SndDisposeChannel(self->ob_itself, 1);
	Py_XDECREF(self->ob_callback);
	PyObject_Free((PyObject *)self);
}
예제 #17
0
파일: macsnd.c 프로젝트: Agyar/NetHack
void
mac_speaker (struct obj *instr, char *melody) {
	SndChannelPtr theChannel = (SndChannelPtr) 0;
	SndCommand theCmd;
	Handle theSound;
	unsigned char theName [32];
	char *n = (char *) &theName [1];
	int typ = instr->otyp;
	const char *actualn = OBJ_NAME (objects [typ]);

	/*
	 * First: are we in the library ?
	 */
	if (flags.silent) {
		return;
	}

	/*
	 * Is this a known instrument ?
	 */
	strcpy (n, actualn);
	theName [0] = strlen (n);
	theSound = GetNamedResource ('snd ', theName);
	if (! theSound) {
		return;
	}
	HLock (theSound);

	/*
	 * Set up the synth
	 */
	if (SndNewChannel(&theChannel, sampledSynth, initMono +
		initNoInterp, (void *) 0) == noErr) {
		char midi_note [] = {57, 59, 60, 62, 64, 65, 67};

		short err;
		short snd_len = SND_LEN (theSound) / 18;

		theCmd.cmd = soundCmd;
		theCmd.param1 = 0;
		theCmd.param2 = (long) SND_BUFFER (theSound);
		err = SndDoCommand (theChannel, &theCmd, false);

	/*
	 * We rack 'em up all in a row
	 * The mac will play them correctly and then end, since
	 * we do a sync close below.
	 *
	 */
		while (*melody && ! err) {
			while (*melody > 'G') {
				*melody -= 8;
			}
			while (*melody < 'A') {
				*melody += 8;
			}
			theCmd.cmd = freqDurationCmd;
			theCmd.param1 = snd_len;
			theCmd.param2 = midi_note [*melody - 'A'];
			err = SndDoCommand (theChannel, &theCmd, false);
			melody ++;
		}
		SndDisposeChannel (theChannel, false);	/* Sync wait for completion */
		ReleaseResource (theSound);
	}
}
예제 #18
0
GBSoundChannel::~GBSoundChannel() {
	if ( SndDisposeChannel(channel, true) )
		throw GBGenericError("couldn't dispose sound channel");
}
예제 #19
0
/*
===============
SNDDMA_Shutdown
===============
*/
void SNDDMA_Shutdown(void) {
	if ( s_sndChan ) {
		SndDisposeChannel( s_sndChan, true );
		s_sndChan = NULL;
	}
}