void CMPEG1Stream::Pause()
{
    ThrowIfError(CheckShutdown());

    m_state = STATE_PAUSED;

    ThrowIfError(QueueEvent(MEStreamPaused, GUID_NULL, S_OK, nullptr));
}
示例#2
0
ComponentInstance	SMACIMAsdec::InitializeIMAAudioDecoder(Component inDecoderComponent, const AudioStreamBasicDescription& inFormat)
{
	UInt32 theSize;
	ComponentInstance theDecoder = OpenComponent(inDecoderComponent);
	ThrowIf(theDecoder == NULL, badComponentInstance, "SMACIMAsdec::InitializeIMAAudioDecoder: couldn't open the component");
	
	//	first, give the decoder the info we have
	theSize = sizeof(AudioStreamBasicDescription);
	ComponentResult theError = AudioCodecSetProperty(theDecoder, kAudioCodecPropertyCurrentInputFormat, theSize, &inFormat);
	ThrowIfError(theError, (CAException)theError, "SMACIMAsdec::InitializeIMAAudioDecoder: got an error setting the input format");
		
	//	now find out what it can output
	theError = AudioCodecGetPropertyInfo(theDecoder, kAudioCodecPropertySupportedOutputFormats, &theSize, NULL);
	ThrowIfError(theError, (CAException)theError, "SMACIMAsdec::InitializeIMAAudioDecoder: got an error getting the available output format list size");
	
	UInt32 theNumberAvailableOutputFormats = theSize / sizeof(AudioStreamBasicDescription);
	AudioStreamBasicDescription* theAvailableOutputFormats = new AudioStreamBasicDescription[theNumberAvailableOutputFormats];
	
	try
	{
		theSize = theNumberAvailableOutputFormats * sizeof(AudioStreamBasicDescription);
		theError = AudioCodecGetProperty(theDecoder, kAudioCodecPropertySupportedOutputFormats, &theSize, theAvailableOutputFormats);
		ThrowIfError(theError, (CAException)theError, "SMACIMAsdec::InitializeIMAAudioDecoder: got an error getting the available output formats");
	
		//	find an acceptable output format
		AudioStreamBasicDescription* theOutputFormat = FindNEFloatFormat(theAvailableOutputFormats, theNumberAvailableOutputFormats);
		ThrowIf(theOutputFormat == NULL, badFormat, "SMACIMAsdec::InitializeIMAAudioDecoder: couldn't find an acceptable output format");
		
		// finish filling out the output format
		theOutputFormat->mSampleRate = inFormat.mSampleRate;
		theOutputFormat->mChannelsPerFrame = inFormat.mChannelsPerFrame;
		theOutputFormat->mBytesPerFrame = 4 * inFormat.mChannelsPerFrame;
		theOutputFormat->mFormatID = kAudioFormatLinearPCM;
		theOutputFormat->mFormatFlags = kAudioFormatFlagsNativeFloatPacked;
		theOutputFormat->mBytesPerPacket = 4 * inFormat.mChannelsPerFrame;
		theOutputFormat->mFramesPerPacket = 1;
		theOutputFormat->mBitsPerChannel = 32;

		//	tell the decoder about it
		theSize = sizeof(AudioStreamBasicDescription);
		theError = AudioCodecSetProperty(theDecoder, kAudioCodecPropertyCurrentOutputFormat, theSize, theOutputFormat);
		ThrowIfError(theError, (CAException)theError, "SMACIMAsdec::InitializeIMAAudioDecoder: got an error setting the output format");
		
		delete[] theAvailableOutputFormats;
		theAvailableOutputFormats = NULL;
	}
	catch(...)
	{
		delete[] theAvailableOutputFormats;
		throw;
	}
	
	//	finally initialize the decoder
	theError = AudioCodecInitialize(theDecoder, NULL, NULL, NULL, 0);
	ThrowIfError(theError, (CAException)theError, "SMACIMAsdec::InitializeIMAAudioDecoder: got an error initializing the decoder");
	
	return theDecoder;
}
示例#3
0
void	SMACscom::SetInfo(SoundSource inSourceID, OSType inSelector, void* inData)
{
    switch(inSelector)
    {
        case siCompressionParams:
            {
                //	process the the new params and produce an initialized
                //	AudioCodec instance
                ComponentInstance theEncoder = SetCompressionParams(inData);
                ThrowIf(theEncoder == NULL, badFormat, "SMACscom::SetInfo: siCompressionParams didn't generate an encoder");

                //	get rid of the input data
                mSourceData = NULL;
                mOutputData.desc.sampleCount = 0;
                mOutputData.bufferSize = 0;
                mOutputData.frameCount = 0;
                mOutputData.commonFrameSize = 0;

                //	close the old encoder if necessary
                if((mEncoder != NULL) && (theEncoder != mEncoder))
                {
                    CloseComponent(mEncoder);
                }
                
                //	use the new one
                mEncoder = theEncoder;
                
                //	get the number of frames in 1 packet of data
                UInt32 theSize = sizeof(UInt32);
                ComponentResult theError = AudioCodecGetProperty(mEncoder, kAudioCodecPropertyPacketFrameSize, &theSize, &mPacketFrameSize);
                ThrowIfError(theError, (CAException)theError, "SMACscom::SetInfo: siCompressionParams got an error from AudioCodecGetProperty while getting the packet frame size");
                
                //	get the maximum number of bytes in 1 packet of data
                theSize = sizeof(UInt32);
                theError = AudioCodecGetProperty(mEncoder, kAudioCodecPropertyMaximumPacketByteSize, &theSize, &mMaxPacketByteSize);
                ThrowIfError(theError, (CAException)theError, "SMACscom::SetInfo: siCompressionParams got an error from AudioCodecGetProperty while getting the maximum packet byte size");
                
                //	toss the old output buffer
                delete[] mOutputBuffer;
                
                //	allocate enough space for 1 packet of data, since that's
                //	that's all this component will produce per call to GetSourceData
                mOutputBuffer = new Byte[mMaxPacketByteSize];
            }
            break;
        
        case siSourceIsExhausted:
			// in this case it seems to be passed by value -- ugh!
            mSourceIsExhausted = (Boolean)((UInt32)inData);
            // Now pass this on, so no break!
        default:
            ThrowIf(mSourceComponent == NULL, siUnknownInfoType, "SMACscom::SetInfo: no source to pass request to")
            ComponentResult theError = SoundComponentSetInfo(mSourceComponent, inSourceID, inSelector, inData);
            ThrowIfError(theError, (CAException)theError, "SMACscom::SetInfo: got an error from SoundComponentSetInfo");
            break;
    };
}
void CMPEG1Stream::Stop()
{
    ThrowIfError(CheckShutdown());

    m_Requests.Clear();
    m_Samples.Clear();

    m_state = STATE_STOPPED;
       
    ThrowIfError(QueueEvent(MEStreamStopped, GUID_NULL, S_OK, nullptr));
}
void CMPEG1Stream::Start(const PROPVARIANT &varStart)
{

    ThrowIfError(CheckShutdown());

    // Queue the stream-started event.
    ThrowIfError(QueueEvent(MEStreamStarted, GUID_NULL, S_OK, &varStart));

    m_state = STATE_STARTED;

    // If we are restarting from paused, there may be
    // queue sample requests. Dispatch them now.
    DispatchSamples();
}
示例#6
0
void	HLFileSystemObject::SetCreator(UInt32 inCreator)
{
	//	get the current Finder info from the catalog
	FSCatalogInfo theInfo;
	OSStatus theError = FSGetCatalogInfo(&mFSRef, kFSCatInfoFinderInfo, &theInfo, NULL, NULL, NULL);
	ThrowIfError(theError, CAException(theError), "HLFileSystemObject::SetType: couldn't get the catalog information");
	
	//	update just the creator
	FInfo* theFinderInfo = reinterpret_cast<FInfo*>(&theInfo.finderInfo);
	theFinderInfo->fdCreator = inCreator;

	//	write it back out
	theError = FSSetCatalogInfo(&mFSRef, kFSCatInfoFinderInfo, &theInfo);
	ThrowIfError(theError, CAException(theError), "HLFileSystemObject::SetType: couldn't set the catalog information");
}
示例#7
0
void	HLAudioFile::WriteAudioBytes(SInt64 inOffset, UInt32& ioNumberBytes, void* inData, bool inCache)
{
	ThrowIf(mAudioFileID == 0, CAException(fnOpnErr), "HLAudioFile::WriteAudioBytes: file isn't prepared");
	
	OSStatus theError = AudioFileWriteBytes(mAudioFileID, inCache, inOffset, &ioNumberBytes, inData);
	ThrowIfError(theError, CAException(theError), "HLAudioFile::WriteAudioBytes: couldn't write the data");
}
示例#8
0
bool	CAAudioHardwareSystem::PropertyIsSettable(AudioHardwarePropertyID inPropertyID)
{
	Boolean isWritable = false;
	OSStatus theError = AudioHardwareGetPropertyInfo(inPropertyID, NULL, &isWritable);
	ThrowIfError(theError, CAException(theError), "CAAudioHardwareSystem::PropertyIsSettable: got an error getting info about a property");
	return isWritable != 0;
}
示例#9
0
UInt32	CAAudioHardwareSystem::GetPropertyDataSize(AudioHardwarePropertyID inPropertyID)
{
	UInt32 theSize = 0;
	OSStatus theError = AudioHardwareGetPropertyInfo(inPropertyID, &theSize, NULL);
	ThrowIfError(theError, CAException(theError), "CAAudioHardwareSystem::GetPropertyDataSize: got an error getting info about a property");
	return theSize;
}
示例#10
0
bool
DeviceInstance::GetPropertyReadOnly(const char* name) const
{
   bool readOnly;
   ThrowIfError(pImpl_->GetPropertyReadOnly(name, readOnly));
   return readOnly;
}
	//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	// CopyBufferQueue()
	//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	CMSimpleQueueRef Stream::CopyBufferQueue(CMIODeviceStreamQueueAlteredProc queueAlteredProc, void* queueAlteredRefCon) const
	{
		CMSimpleQueueRef queue = NULL;
		OSStatus err = CMIOStreamCopyBufferQueue(GetObjectID(), queueAlteredProc, queueAlteredRefCon, &queue);
		ThrowIfError(err, CAException(err), "CMIO::DALA::Stream::CopyBufferQueue: CMIOStreamCopyBufferQueue() failed");
		return queue;
	}
示例#12
0
bool	HLDirectoryFactory::ObjectIsA(const FSRef& inFSRef) const
{
	FSCatalogInfo theCatalogInfo;
	OSStatus theError = FSGetCatalogInfo(&inFSRef, kFSCatInfoNodeFlags, &theCatalogInfo, NULL, NULL, NULL);
	ThrowIfError(theError, CAException(theError), "HLDirectoryFactory::ObjectIsA: couldn't get the catalog info");
	return (theCatalogInfo.nodeFlags & kFSNodeIsDirectoryMask) != 0;
}
示例#13
0
bool	HLFileSystemObject::IsVolume() const
{
	FSCatalogInfo theCatalogInfo;
	OSStatus theError = FSGetCatalogInfo(&mFSRef, kFSCatInfoNodeFlags | kFSCatInfoNodeID, &theCatalogInfo, NULL, NULL, NULL);
	ThrowIfError(theError, CAException(theError), "HLFileSystemObject::IsVolume: couldn't get the catalog info");
	return ((theCatalogInfo.nodeFlags & kFSNodeIsDirectoryMask) != 0) && (theCatalogInfo.nodeID == fsRtDirID);
}
示例#14
0
bool
DeviceInstance::IsPropertySequenceable(const char* name) const
{
   bool isSequenceable;
   ThrowIfError(pImpl_->IsPropertySequenceable(name, isSequenceable));
   return isSequenceable;
}
bool	CAAudioHardwareStream::PropertyIsSettable(UInt32 inChannel, AudioHardwarePropertyID inPropertyID) const
{
	Boolean isWritable = false;
	OSStatus theError = AudioStreamGetPropertyInfo(GetAudioStreamID(), inChannel, inPropertyID, NULL, &isWritable);
	ThrowIfError(theError, CAException(theError), "CAAudioHardwareStream::PropertyIsSettable: got an error getting info about a property");
	return isWritable != 0;
}
示例#16
0
double
DeviceInstance::GetPropertyUpperLimit(const char* name) const
{
   double highLimit;
   ThrowIfError(pImpl_->GetPropertyUpperLimit(name, highLimit));
   return highLimit;
}
示例#17
0
MM::PropertyType
DeviceInstance::GetPropertyType(const char* name) const
{
   MM::PropertyType propType;
   ThrowIfError(pImpl_->GetPropertyType(name, propType));
   return propType;
}
示例#18
0
double
DeviceInstance::GetPropertyLowerLimit(const char* name) const
{
   double lowLimit;
   ThrowIfError(pImpl_->GetPropertyLowerLimit(name, lowLimit));
   return lowLimit;
}
示例#19
0
bool
DeviceInstance::HasPropertyLimits(const char* name) const
{
   bool hasLimits;
   ThrowIfError(pImpl_->HasPropertyLimits(name, hasLimits));
   return hasLimits;
}
示例#20
0
bool
DeviceInstance::GetPropertyInitStatus(const char* name) const
{
   bool isPreInit;
   ThrowIfError(pImpl_->GetPropertyInitStatus(name, isPreInit));
   return isPreInit;
}
bool	CAHALAudioObject::IsPropertySettable(AudioObjectPropertyAddress& inAddress) const
{
	Boolean isSettable = false;
	OSStatus theError = AudioObjectIsPropertySettable(mObjectID, &inAddress, &isSettable);
	ThrowIfError(theError, CAException(theError), "CAHALAudioObject::IsPropertySettable: got an error getting info about a property");
	return isSettable != 0;
}
示例#22
0
bool	HLFileSystemObject::IsFile() const
{
	FSCatalogInfo theCatalogInfo;
	OSStatus theError = FSGetCatalogInfo(&mFSRef, kFSCatInfoNodeFlags, &theCatalogInfo, NULL, NULL, NULL);
	ThrowIfError(theError, CAException(theError), "HLFileSystemObject::IsFile: couldn't get the catalog info");
	return (theCatalogInfo.nodeFlags & kFSNodeIsDirectoryMask) == 0;
}
UInt32	CAHALAudioObject::GetPropertyDataSize(AudioObjectPropertyAddress& inAddress, UInt32 inQualifierDataSize, const void* inQualifierData) const
{
	UInt32 theDataSize = 0;
	OSStatus theError = AudioObjectGetPropertyDataSize(mObjectID, &inAddress, inQualifierDataSize, inQualifierData, &theDataSize);
	ThrowIfError(theError, CAException(theError), "CAHALAudioObject::GetPropertyDataSize: got an error getting the property data size");
	return theDataSize;
}
示例#24
0
//#if defined(__BLOCKS__) && (__MAC_OS_X_VERSION_MAX_ALLOWED > __MAC_10_6)
AudioDeviceIOProcID	CAHALAudioDevice::CreateIOProcIDWithBlock(dispatch_queue_t inDispatchQueue, AudioDeviceIOBlock inIOBlock)
{
	AudioDeviceIOProcID theAnswer = NULL;
	OSStatus theError = AudioDeviceCreateIOProcIDWithBlock(&theAnswer, mObjectID, inDispatchQueue, inIOBlock);
	ThrowIfError(theError, CAException(theError), "CAHALAudioDevice::CreateIOProcIDWithBlock: got an error creating the IOProc ID");
	return theAnswer;
}
示例#25
0
void	HLAudioFile::Close()
{
	if(mOpenCount > 0)
	{
		//	only close the file if it is open
		
		//	decrement the open count
		--mOpenCount;
		
		if(mOpenCount == 0)
		{
			//	no one wants the file open, so really close it
			OSStatus theError = 0;
			if(mAudioFileID != 0)
			{
				theError = AudioFileClose(mAudioFileID);
				mAudioFileID = 0;
			}
			
			//	clear the permissions
			mOpenForReading = false;
			mOpenForWriting = false;
			
			//	check for errors
			ThrowIfError(theError, CAException(theError), "HLAudioFile::Close: couldn't close the fork");
		}
	}
}
示例#26
0
HLFileSystemObject*	HLAudioFileFactory::Create(const FSRef& inParentFSRef, CFStringRef inName, const void* inData, UInt32 inDataSize)
{
	HLFile* theFile = NULL;
	
	//	the data for an HLAudioFile is a stream descption
	ThrowIf(inDataSize != sizeof(AudioStreamBasicDescription), CAException(paramErr), "HLAudioFileFactory::Create: the data is supposed to be an AudioStreamBasicDescription");

	const AudioStreamBasicDescription* theFormat = reinterpret_cast<const AudioStreamBasicDescription*>(inData);

	//	create the file on disk
	FSRef theFSRef;
	AudioFileID theAudioFileID = 0;
	OSStatus theError = AudioFileCreate(&inParentFSRef, inName, mObjectType, theFormat, 0, &theFSRef, &theAudioFileID);
	if(theError == 0)
	{
		AudioFileClose(theAudioFileID);
		
		//	make the object
		theFile = CreateObject(theFSRef);
		theFile->Prepare();
	}
	else
	{
		ThrowIfError(theError, CAException(theError), "HLAudioFileFactory::Create: AudioFileCreate failed");
	}
	
	return theFile;
}
示例#27
0
long
DeviceInstance::GetPropertySequenceMaxLength(const char* propertyName) const
{
   long nrEvents;
   ThrowIfError(pImpl_->GetPropertySequenceMaxLength(propertyName, nrEvents));
   return nrEvents;
}
示例#28
0
void	HLAudioFile::Open(bool inForReading, bool inForWriting)
{
	if(mOpenCount == 0)
	{
		//	only actully open the file the first time
		
		//	save off the permissions
		mOpenForReading = inForReading;
		mOpenForWriting = inForWriting;
		
		//	open the file
		SInt8 thePermissions = 0;
		if(mOpenForReading)
		{
			thePermissions += fsRdPerm;
		}
		if(mOpenForWriting)
		{
			thePermissions += fsWrPerm;
		}
		OSStatus theError = AudioFileOpen(&mFSRef, thePermissions, 0, &mAudioFileID);
		ThrowIfError(theError, CAException(theError), "HLAudioFile::Open: couldn't open the file");
	}
	else
	{
		//	file is already open, so it's an error if someone tries to add permissions
		ThrowIf((mOpenForReading && !mOpenForWriting) && inForWriting, CAException(fBsyErr), "HLAudioFile::Open: can't add write permissions");
		ThrowIf((!mOpenForReading && mOpenForWriting) && inForReading, CAException(fBsyErr), "HLAudioFile::Open: can't add read permissions");
	}

	//	increment the open count
	++mOpenCount;
}
UInt32	CAAudioHardwareStream::GetPropertyDataSize(UInt32 inChannel, AudioHardwarePropertyID inPropertyID) const
{
	UInt32 theSize = 0;
	OSStatus theError = AudioStreamGetPropertyInfo(GetAudioStreamID(), inChannel, inPropertyID, &theSize, NULL);
	ThrowIfError(theError, CAException(theError), "CAAudioHardwareStream::GetPropertyDataSize: got an error getting info about a property");
	return theSize;
}
示例#30
0
AudioDeviceIOProcID	CAHALAudioDevice::CreateIOProcID(AudioDeviceIOProc inIOProc, void* inClientData)
{
	AudioDeviceIOProcID theAnswer = NULL;
	OSStatus theError = AudioDeviceCreateIOProcID(mObjectID, inIOProc, inClientData, &theAnswer);
	ThrowIfError(theError, CAException(theError), "CAHALAudioDevice::CreateIOProcID: got an error creating the IOProc ID");
	return theAnswer;
}