Recorder error loggin.

This commit is contained in:
Beingpax 2025-08-12 21:05:53 +05:45
parent 3304680797
commit 6935f58737
4 changed files with 32 additions and 27 deletions

View File

@ -459,7 +459,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 149; CURRENT_PROJECT_VERSION = 150;
DEVELOPMENT_ASSET_PATHS = "\"VoiceInk/Preview Content\""; DEVELOPMENT_ASSET_PATHS = "\"VoiceInk/Preview Content\"";
DEVELOPMENT_TEAM = V6J6A3VWY2; DEVELOPMENT_TEAM = V6J6A3VWY2;
ENABLE_HARDENED_RUNTIME = YES; ENABLE_HARDENED_RUNTIME = YES;
@ -493,7 +493,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 149; CURRENT_PROJECT_VERSION = 150;
DEVELOPMENT_ASSET_PATHS = "\"VoiceInk/Preview Content\""; DEVELOPMENT_ASSET_PATHS = "\"VoiceInk/Preview Content\"";
DEVELOPMENT_TEAM = V6J6A3VWY2; DEVELOPMENT_TEAM = V6J6A3VWY2;
ENABLE_HARDENED_RUNTIME = YES; ENABLE_HARDENED_RUNTIME = YES;

View File

@ -289,29 +289,7 @@ struct ConfigurationRow: View {
} }
.background(CardBackground(isSelected: isEditing)) .background(CardBackground(isSelected: isEditing))
.opacity(config.isEnabled ? 1.0 : 0.5) .opacity(config.isEnabled ? 1.0 : 0.5)
.overlay(
Group {
if isHovering {
VStack {
HStack(spacing: 4) {
Image(systemName: "hand.tap")
.font(.system(size: 10))
Text("Double-click to edit • Right-click for more options")
.font(.caption2)
}
.foregroundColor(.secondary)
.padding(.horizontal, 8)
.padding(.vertical, 4)
.background(
Capsule()
.fill(Color(NSColor.controlBackgroundColor).opacity(0.9))
)
.padding(.top, 8)
Spacer()
}
}
}
)
.onHover { hovering in .onHover { hovering in
withAnimation(.easeInOut(duration: 0.15)) { withAnimation(.easeInOut(duration: 0.15)) {
isHovering = hovering isHovering = hovering

View File

@ -4,7 +4,7 @@ import CoreAudio
import os import os
@MainActor @MainActor
class Recorder: ObservableObject { class Recorder: NSObject, ObservableObject, AVAudioRecorderDelegate {
private var recorder: AVAudioRecorder? private var recorder: AVAudioRecorder?
private let logger = Logger(subsystem: "com.prakashjoshipax.voiceink", category: "Recorder") private let logger = Logger(subsystem: "com.prakashjoshipax.voiceink", category: "Recorder")
private let deviceManager = AudioDeviceManager.shared private let deviceManager = AudioDeviceManager.shared
@ -101,6 +101,7 @@ class Recorder: ObservableObject {
do { do {
recorder = try AVAudioRecorder(url: url, settings: recordSettings) recorder = try AVAudioRecorder(url: url, settings: recordSettings)
recorder?.delegate = self
recorder?.isMeteringEnabled = true recorder?.isMeteringEnabled = true
if recorder?.record() == false { if recorder?.record() == false {
@ -196,6 +197,32 @@ class Recorder: ObservableObject {
audioMeter = newAudioMeter audioMeter = newAudioMeter
} }
// MARK: - AVAudioRecorderDelegate
func audioRecorderDidFinishRecording(_ recorder: AVAudioRecorder, successfully flag: Bool) {
if !flag {
logger.error("❌ Recording finished unsuccessfully - file may be corrupted or empty")
Task { @MainActor in
NotificationManager.shared.showNotification(
title: "Recording failed - audio file corrupted",
type: .error
)
}
}
}
func audioRecorderEncodeErrorDidOccur(_ recorder: AVAudioRecorder, error: Error?) {
if let error = error {
logger.error("❌ Recording encode error during session: \(error.localizedDescription)")
Task { @MainActor in
NotificationManager.shared.showNotification(
title: "Recording error: \(error.localizedDescription)",
type: .error
)
}
}
}
deinit { deinit {
if let observer = deviceObserver { if let observer = deviceObserver {
NotificationCenter.default.removeObserver(observer) NotificationCenter.default.removeObserver(observer)

View File

@ -170,7 +170,7 @@ class WhisperState: NSObject, ObservableObject {
self.recordedFile = permanentURL self.recordedFile = permanentURL
try await self.recorder.startRecording(toOutputFile: permanentURL) try await self.recorder.startRecording(toOutputFile: permanentURL)
await MainActor.run { await MainActor.run {
self.recordingState = .recording self.recordingState = .recording
} }