···11+/*
22+This file is part of Darling.
33+44+Copyright (C) 2020 Lubos Dolezel
55+66+Darling is free software: you can redistribute it and/or modify
77+it under the terms of the GNU General Public License as published by
88+the Free Software Foundation, either version 3 of the License, or
99+(at your option) any later version.
1010+1111+Darling is distributed in the hope that it will be useful,
1212+but WITHOUT ANY WARRANTY; without even the implied warranty of
1313+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414+GNU General Public License for more details.
1515+1616+You should have received a copy of the GNU General Public License
1717+along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818+*/
1919+2020+#include "AudioFileFormatManager.h"
2121+2222+AudioFileFormatManager::AudioFileFormatManager()
2323+{
2424+2525+}
2626+2727+void AudioFileFormatManager::buildDatabase()
2828+{
2929+ AudioComponentDescription acd = { 0 };
3030+ acd.componentType = 'afil';
3131+3232+ AudioComponent component = nullptr;
3333+3434+ while ((component = ::AudioComponentFindNext(component, &acd)) != nullptr)
3535+ {
3636+ AudioComponentInstance inst;
3737+ OSStatus status = ::AudioComponentInstanceNew(component, &inst);
3838+3939+ if (status != noErr)
4040+ continue;
4141+4242+ analyzeAudioFileComponent(inst);
4343+ ::AudioComponentInstanceDispose(inst);
4444+ }
4545+}
4646+4747+void AudioFileFormatManager::analyzeAudioFileComponent(AudioFileComponent component)
4848+{
4949+ /*
5050+ kAudioFileComponent_FileTypeName = 'ftnm',
5151+ kAudioFileComponent_UTIsForType = 'futi',
5252+ kAudioFileComponent_MIMETypesForType = 'fmim',
5353+ kAudioFileComponent_ExtensionsForType = 'fext',
5454+ kAudioFileComponent_AvailableFormatIDs = 'fmid',
5555+ */
5656+}
5757+5858+AudioFileFormatManager* AudioFileFormatManager::instance()
5959+{
6060+ static AudioFileFormatManager inst;
6161+ return &inst;
6262+}
···11+/*
22+This file is part of Darling.
33+44+Copyright (C) 2020 Lubos Dolezel
55+66+Darling is free software: you can redistribute it and/or modify
77+it under the terms of the GNU General Public License as published by
88+the Free Software Foundation, either version 3 of the License, or
99+(at your option) any later version.
1010+1111+Darling is distributed in the hope that it will be useful,
1212+but WITHOUT ANY WARRANTY; without even the implied warranty of
1313+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414+GNU General Public License for more details.
1515+1616+You should have received a copy of the GNU General Public License
1717+along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818+*/
1919+2020+2121+#ifndef _AUDIO_FILE_FORMAT_MANAGER_H
2222+#define _AUDIO_FILE_FORMAT_MANAGER_H
2323+#include <AudioToolbox/AudioComponent.h>
2424+#include <AudioToolbox/AudioFileComponent.h>
2525+2626+class __attribute__((visibility("hidden"))) AudioFileFormatManager
2727+{
2828+private:
2929+ AudioFileFormatManager();
3030+ void buildDatabase();
3131+ void analyzeAudioFileComponent(AudioFileComponent component);
3232+public:
3333+ static AudioFileFormatManager* instance();
3434+};
3535+3636+#endif
3737+
+37
src/CoreAudio/AudioToolbox/AudioFormat.cpp
···11+/*
22+This file is part of Darling.
33+44+Copyright (C) 2020 Lubos Dolezel
55+66+Darling is free software: you can redistribute it and/or modify
77+it under the terms of the GNU General Public License as published by
88+the Free Software Foundation, either version 3 of the License, or
99+(at your option) any later version.
1010+1111+Darling is distributed in the hope that it will be useful,
1212+but WITHOUT ANY WARRANTY; without even the implied warranty of
1313+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414+GNU General Public License for more details.
1515+1616+You should have received a copy of the GNU General Public License
1717+along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818+*/
1919+#include <AudioToolbox/AudioFormat.h>
2020+#include <CoreServices/MacErrors.h>
2121+2222+OSStatus AudioFormatGetPropertyInfo( AudioFormatPropertyID inPropertyID,
2323+ UInt32 inSpecifierSize,
2424+ const void * _Nullable inSpecifier,
2525+ UInt32 * outPropertyDataSize)
2626+{
2727+ return unimpErr;
2828+}
2929+3030+OSStatus AudioFormatGetProperty( AudioFormatPropertyID inPropertyID,
3131+ UInt32 inSpecifierSize,
3232+ const void * _Nullable inSpecifier,
3333+ UInt32 * _Nullable ioPropertyDataSize,
3434+ void * _Nullable outPropertyData)
3535+{
3636+ return unimpErr;
3737+}
+27
src/CoreAudio/AudioToolbox/AudioToolbox.cpp
···11+/*
22+This file is part of Darling.
33+44+Copyright (C) 2020 Lubos Dolezel
55+66+Darling is free software: you can redistribute it and/or modify
77+it under the terms of the GNU General Public License as published by
88+the Free Software Foundation, either version 3 of the License, or
99+(at your option) any later version.
1010+1111+Darling is distributed in the hope that it will be useful,
1212+but WITHOUT ANY WARRANTY; without even the implied warranty of
1313+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414+GNU General Public License for more details.
1515+1616+You should have received a copy of the GNU General Public License
1717+along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818+*/
1919+2020+#include <AudioToolbox/AudioToolbox.h>
2121+#include <iostream>
2222+2323+void CAShow(void* inObject)
2424+{
2525+ // TODO: print something useful
2626+ std::cout << "CAShow: " << inObject << std::endl;
2727+}
···11+/*
22+This file is part of Darling.
33+44+Copyright (C) 2020 Lubos Dolezel
55+66+Darling is free software: you can redistribute it and/or modify
77+it under the terms of the GNU General Public License as published by
88+the Free Software Foundation, either version 3 of the License, or
99+(at your option) any later version.
1010+1111+Darling is distributed in the hope that it will be useful,
1212+but WITHOUT ANY WARRANTY; without even the implied warranty of
1313+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414+GNU General Public License for more details.
1515+1616+You should have received a copy of the GNU General Public License
1717+along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818+*/
1919+2020+2121+#include <AudioToolbox/ExtendedAudioFile.h>
2222+#include <CoreServices/MacErrors.h>
2323+2424+// TODO: Implement with the help of CAAudioFile?
2525+2626+OSStatus ExtAudioFileOpenURL( CFURLRef inURL,
2727+ ExtAudioFileRef _Nullable * _Nonnull outExtAudioFile)
2828+{
2929+ return unimpErr;
3030+}
3131+3232+OSStatus ExtAudioFileWrapAudioFileID(AudioFileID inFileID,
3333+ Boolean inForWriting,
3434+ ExtAudioFileRef _Nullable * _Nonnull outExtAudioFile)
3535+{
3636+ return unimpErr;
3737+}
3838+3939+OSStatus ExtAudioFileCreateWithURL( CFURLRef inURL,
4040+ AudioFileTypeID inFileType,
4141+ const AudioStreamBasicDescription * inStreamDesc,
4242+ const AudioChannelLayout * _Nullable inChannelLayout,
4343+ UInt32 inFlags,
4444+ ExtAudioFileRef _Nullable * _Nonnull outExtAudioFile)
4545+{
4646+ return unimpErr;
4747+}
4848+4949+OSStatus ExtAudioFileOpen( const struct FSRef * inFSRef,
5050+ ExtAudioFileRef _Nullable * _Nonnull outExtAudioFile)
5151+{
5252+ return unimpErr;
5353+}
5454+5555+OSStatus ExtAudioFileCreateNew( const struct FSRef * inParentDir,
5656+ CFStringRef inFileName,
5757+ AudioFileTypeID inFileType,
5858+ const AudioStreamBasicDescription * inStreamDesc,
5959+ const AudioChannelLayout * _Nullable inChannelLayout,
6060+ ExtAudioFileRef _Nullable * _Nonnull outExtAudioFile)
6161+{
6262+ return unimpErr;
6363+}
6464+6565+OSStatus ExtAudioFileDispose( ExtAudioFileRef inExtAudioFile)
6666+{
6767+ return unimpErr;
6868+}
6969+7070+OSStatus ExtAudioFileRead( ExtAudioFileRef inExtAudioFile,
7171+ UInt32 * ioNumberFrames,
7272+ AudioBufferList * ioData)
7373+{
7474+ return unimpErr;
7575+}
7676+7777+OSStatus ExtAudioFileWrite( ExtAudioFileRef inExtAudioFile,
7878+ UInt32 inNumberFrames,
7979+ const AudioBufferList * ioData)
8080+{
8181+ return unimpErr;
8282+}
8383+8484+OSStatus ExtAudioFileWriteAsync( ExtAudioFileRef inExtAudioFile,
8585+ UInt32 inNumberFrames,
8686+ const AudioBufferList * _Nullable ioData)
8787+{
8888+ return unimpErr;
8989+}
9090+9191+OSStatus ExtAudioFileSeek( ExtAudioFileRef inExtAudioFile,
9292+ SInt64 inFrameOffset)
9393+{
9494+ return unimpErr;
9595+}
9696+9797+OSStatus ExtAudioFileTell( ExtAudioFileRef inExtAudioFile,
9898+ SInt64 * outFrameOffset)
9999+{
100100+ return unimpErr;
101101+}
102102+103103+OSStatus ExtAudioFileGetPropertyInfo(ExtAudioFileRef inExtAudioFile,
104104+ ExtAudioFilePropertyID inPropertyID,
105105+ UInt32 * _Nullable outSize,
106106+ Boolean * _Nullable outWritable)
107107+{
108108+ return unimpErr;
109109+}
110110+111111+OSStatus ExtAudioFileGetProperty( ExtAudioFileRef inExtAudioFile,
112112+ ExtAudioFilePropertyID inPropertyID,
113113+ UInt32 * ioPropertyDataSize,
114114+ void * outPropertyData)
115115+{
116116+ return unimpErr;
117117+}
118118+119119+OSStatus ExtAudioFileSetProperty( ExtAudioFileRef inExtAudioFile,
120120+ ExtAudioFilePropertyID inPropertyID,
121121+ UInt32 inPropertyDataSize,
122122+ const void * inPropertyData)
123123+{
124124+ return unimpErr;
125125+}
+64
src/CoreAudio/AudioToolbox/MusicDevice.cpp
···11+/*
22+This file is part of Darling.
33+44+Copyright (C) 2020 Lubos Dolezel
55+66+Darling is free software: you can redistribute it and/or modify
77+it under the terms of the GNU General Public License as published by
88+the Free Software Foundation, either version 3 of the License, or
99+(at your option) any later version.
1010+1111+Darling is distributed in the hope that it will be useful,
1212+but WITHOUT ANY WARRANTY; without even the implied warranty of
1313+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414+GNU General Public License for more details.
1515+1616+You should have received a copy of the GNU General Public License
1717+along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818+*/
1919+2020+#include <AudioToolbox/MusicDevice.h>
2121+#include <CoreServices/MacErrors.h>
2222+#include <iostream>
2323+2424+OSStatus
2525+MusicDeviceMIDIEvent( MusicDeviceComponent inUnit,
2626+ UInt32 inStatus,
2727+ UInt32 inData1,
2828+ UInt32 inData2,
2929+ UInt32 inOffsetSampleFrame)
3030+{
3131+ std::cerr << "NOT IMPLEMENTED: " << __FUNCTION__ << std::endl;
3232+ return unimpErr;
3333+}
3434+3535+OSStatus
3636+MusicDeviceSysEx( MusicDeviceComponent inUnit,
3737+ const UInt8 * inData,
3838+ UInt32 inLength)
3939+{
4040+ std::cerr << "NOT IMPLEMENTED: " << __FUNCTION__ << std::endl;
4141+ return unimpErr;
4242+}
4343+4444+OSStatus
4545+MusicDeviceStartNote( MusicDeviceComponent inUnit,
4646+ MusicDeviceInstrumentID inInstrument,
4747+ MusicDeviceGroupID inGroupID,
4848+ NoteInstanceID * outNoteInstanceID,
4949+ UInt32 inOffsetSampleFrame,
5050+ const MusicDeviceNoteParams * inParams)
5151+{
5252+ std::cerr << "NOT IMPLEMENTED: " << __FUNCTION__ << std::endl;
5353+ return unimpErr;
5454+}
5555+5656+OSStatus
5757+MusicDeviceStopNote( MusicDeviceComponent inUnit,
5858+ MusicDeviceGroupID inGroupID,
5959+ NoteInstanceID inNoteInstanceID,
6060+ UInt32 inOffsetSampleFrame)
6161+{
6262+ std::cerr << "NOT IMPLEMENTED: " << __FUNCTION__ << std::endl;
6363+ return unimpErr;
6464+}