@@ -1103,6 +1103,90 @@ void MCPlatformSoundGetProperty(MCPlatformSoundRef sound, MCPlatformSoundPropert
11031103
11041104// //////////////////////////////////////////////////////////////////////////////
11051105
1106+ // Implementation guidence:
1107+ //
1108+ // This is basic abstraction of the sound recording functionality which the
1109+ // engine currently has.
1110+ //
1111+ // The platform sound recorder opaque type should be a procedural wrapper around
1112+ // a class which implements an abstract interface (just like the PlatformPlayer).
1113+ //
1114+ // Initially we need an implementation using the QT Sequence Grabber which needs
1115+ // to use the SGAudioMediaType (essentially this means that the code in the engine
1116+ // already for this is not usable - its heavily tied to SoundMediaType which
1117+ // crashes on modern Mac's).
1118+ //
1119+ // There is a sample code project 'WhackedTV' which should be useful to base the
1120+ // implementation on. This project goes a bit further than we need though - our
1121+ // dialog only needs to be the QT one provided by SCRequestImageSettings so that
1122+ // should hopefully simplify things.
1123+ //
1124+ // The SoundRecorder object should hold all the necessary system state to operate
1125+ // and whilst recording should ensure that things are idled appropriately using
1126+ // a Cocoa timer rather than requiring the engine to call an idle-proc (which is
1127+ // what is currently required).
1128+ //
1129+
1130+ typedef struct MCPlatformSoundRecorder *MCPlatformSoundRecorderRef;
1131+
1132+ struct MCPlatformSoundRecorderConfiguration
1133+ {
1134+ // The input to use for sound recording - this should be an id as returned by ListInputs.
1135+ unsigned int input;
1136+ // The sample rate for recording.
1137+ double sample_rate;
1138+ // The number of bits per sample.
1139+ unsigned int sample_bit_count;
1140+ // The number of channels.
1141+ unsigned int channel_count;
1142+ // The compressor to use - this should be an id as returned by ListCompressors.
1143+ unsigned int compression_type;
1144+ // Any extra info specific to a compressor - this is an opaque sequence of bytes. If nil
1145+ // when setting configuration, per-compressor defaults should be used.
1146+ uint8_t *extra_info;
1147+ size_t extra_info_size;
1148+ };
1149+
1150+ typedef bool (*MCPlatformSoundRecorderListInputsCallback)(void *context, unsigned int input_id, const char *label);
1151+ typedef bool (*MCPlatformSoundRecorderListCompressorsCallback)(void *context, unsigned int compressor_id, const char *label);
1152+
1153+ void MCPlatformSoundRecorderCreate (MCPlatformSoundRecorderRef& r_recorder);
1154+
1155+ void MCPlatformSoundRecorderRetain (MCPlatformSoundRecorderRef recorder);
1156+ void MCPlatformSoundRecorderRelease (MCPlatformSoundRecorderRef recorder);
1157+
1158+ // Return true if the recorder is recording.
1159+ bool MCPlatformSoundRecorderIsRecording (MCPlatformSoundRecorderRef recorder);
1160+
1161+ // Return the current volume of the recorded input - if not recording, return 0.
1162+ double MCPlatformSoundRecorderGetLoudness (MCPlatformSoundRecorderRef recorder);
1163+
1164+ // Start sound recording to the given file. If the sound recorder is already recording then
1165+ // the existing recording should be cancelled (stop and delete output file).
1166+ bool MCPlatformSoundRecorderStart (MCPlatformSoundRecorderRef recorder, const char *filename);
1167+ // Stop the sound recording.
1168+ void MCPlatformSoundRecorderStop (MCPlatformSoundRecorderRef recorder);
1169+
1170+ // Call callback for each possible input device available - if the callback returns 'false' at any point
1171+ // enumeration is cancelled, and the false will be returned.
1172+ bool MCPlatformSoundRecorderListInputs (MCPlatformSoundRecorderRef recorder, MCPlatformSoundRecorderListInputsCallback callback, void *context);
1173+ // Call callback for each possible compressor available - if the callback returns 'false' at any point
1174+ // enumeration is cancelled, and the false will be returned.
1175+ bool MCPlatformSoundRecorderListCompressors (MCPlatformSoundRecorderRef recorder, MCPlatformSoundRecorderListCompressorsCallback callback, void *context);
1176+
1177+ // Get the current sound recording configuration. The caller is responsible for freeing 'extra_info'.
1178+ void MCPlatformSoundRecorderGetConfiguration (MCPlatformSoundRecorderRef recorder, MCPlatformSoundRecorderConfiguration& r_config);
1179+ // Set the current sound recording configuration.
1180+ void MCPlatformSoundRecorderSetConfiguration (MCPlatformSoundRecorderRef recorder, const MCPlatformSoundRecorderConfiguration& config);
1181+
1182+ // Popup a configuration dialog for the compressors. If the dialog is not cancelled the
1183+ // sound recorders config will have been updated.
1184+ void MCPlatformSoundRecorderBeginConfigurationDialog (MCPlatformSoundRecorderRef recorder);
1185+ // End the configuration dialog.
1186+ MCPlatformDialogResult MCPlatformSoundRecorderEndConfigurationDialog (MCPlatformSoundRecorderRef recorder);
1187+
1188+ // //////////////////////////////////////////////////////////////////////////////
1189+
11061190void MCPlatformSwitchFocusToView (MCPlatformWindowRef window, uint32_t id);
11071191
11081192// //////////////////////////////////////////////////////////////////////////////
0 commit comments