T GetProperty <T> (AudioFileProperty property) { int size, writable; if (AudioFileGetPropertyInfo(handle, property, out size, out writable) != 0) { return(default(T)); } var buffer = Marshal.AllocHGlobal(size); if (buffer == IntPtr.Zero) { return(default(T)); } try { var r = AudioFileGetProperty(handle, property, ref size, buffer); if (r == 0) { return((T)Marshal.PtrToStructure(buffer, typeof(T))); } return(default(T)); } finally { Marshal.FreeHGlobal(buffer); } }
void SetInt(AudioFileProperty property, int value) { unsafe { AudioFileSetProperty(handle, property, 4, (IntPtr)(&value)); } }
public IntPtr GetProperty(AudioFileProperty property, out int size) { int writable; var r = AudioFileGetPropertyInfo(handle, property, out size, out writable); if (r != 0) { return(IntPtr.Zero); } var buffer = Marshal.AllocHGlobal(size); if (buffer == IntPtr.Zero) { return(IntPtr.Zero); } r = AudioFileGetProperty(handle, property, ref size, buffer); if (r == 0) { return(buffer); } Marshal.FreeHGlobal(buffer); return(IntPtr.Zero); }
private void ProcessRawAudioData(bool is_finish = false) { string path = null; if (is_finish == false) { //1. Check total length off audio if (IsEnoughData() == false) { return; } path = SaveAudioFromBufferToFile(); } else { path = SaveAllAudioFromBufferFile(); } //2. Save to wav file and Put in list audio buffer if (path != null) { AudioFileProperty mp3File = new AudioFileProperty(path); mListOfflineAudioFile.Add(mp3File); } //4. Send to backend server sendAudioFileToBackend(); //5. Update View RefreshDataView(mListOfflineAudioFile); }
long GetLong(AudioFileProperty property) { unsafe { long val = 0; int size = 8; if (AudioFileGetProperty(handle, property, ref size, (IntPtr)(&val)) == 0) { return(val); } return(0); } }
IntPtr GetIntPtr(AudioFileProperty property) { unsafe { IntPtr val = IntPtr.Zero; int size = sizeof(IntPtr); if (AudioFileGetProperty(handle, property, ref size, (IntPtr)(&val)) == 0) { return(val); } return(IntPtr.Zero); } }
int GetInt(AudioFileProperty property) { unsafe { int val = 0; int size = 4; if (AudioFileGetProperty(handle, property, ref size, (IntPtr)(&val)) == 0) { return(val); } return(0); } }
private static unsafe void CopyPropertyFromFileToQueue(AudioStream *pThis, AudioFileProperty fileProp, AudioQueueProperty queueProp) { int size = sizeof(uint); OSStatus status = API.AudioFileGetPropertyInfo(pThis->AudioFile, fileProp, &size, null); if (status == 0 && size > 0) { void *pData = (void *)Marshal.AllocHGlobal(size); API.AudioFileGetProperty(pThis->AudioFile, fileProp, &size, pData); API.AudioQueueSetProperty(pThis->Queue, queueProp, pData, size); Marshal.FreeHGlobal((IntPtr)pData); } }
private void sendAudioFileToBackend() { double startSplit = 0; for (int i = 0; i < mListOfflineAudioFile.Count; ++i) { AudioFileProperty file = mListOfflineAudioFile[i]; if (file.status == AudioFileProperty.TranslateStatus.Not_Sent) { bool sendResult = Request.UploadFileToServer(mSessionId, file.FullFilePath, startSplit); if (sendResult == false) { break; } else { file.status = AudioFileProperty.TranslateStatus.Sent; mListOfflineAudioFile[i] = file; } } startSplit += file.DurationInSecond; } }
public bool GetProperty(AudioFileProperty property, ref int dataSize, IntPtr outdata) { return(AudioFileGetProperty(handle, property, ref dataSize, outdata) == 0); }
public bool GetPropertyInfo(AudioFileProperty property, out int size, out int writable) { return(AudioFileGetPropertyInfo(handle, property, out size, out writable) == 0); }
extern static OSStatus AudioFileGetPropertyInfo(AudioFileID audioFile, AudioFileProperty propertyID, out int outDataSize, out int isWritable);
public static extern unsafe OSStatus AudioFileGetPropertyInfo(AudioFileID fileID, AudioFileProperty propertyId, int *pSize, int *isWritable);
public static extern unsafe OSStatus AudioFileGetProperty(AudioFileID fileID, AudioFileProperty propertyId, int *dataSize, void *pResult);
extern static OSStatus AudioFileSetProperty(AudioFileID audioFile, AudioFileProperty property, int dataSize, IntPtr propertyData);
public bool SetProperty(AudioFileProperty property, int dataSize, IntPtr propertyData) { return(AudioFileSetProperty(handle, property, dataSize, propertyData) == 0); }
extern static OSStatus AudioFileGetProperty(AudioFileID audioFile, AudioFileProperty property, ref int dataSize, IntPtr outdata);